-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoomServiceLuaEvents.cs
More file actions
105 lines (91 loc) · 2.87 KB
/
RoomServiceLuaEvents.cs
File metadata and controls
105 lines (91 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using ZeepSDK.Scripting.ZUA;
using ZeepSDK.Scripting;
using ZeepkistClient;
namespace RoomService
{
/// <summary>
/// Represents an event triggered when the lobby timer changes.
/// </summary>
public class OnLobbyTimerEvent : ILuaEvent
{
/// <summary>
/// Gets the name of the Lua event.
/// </summary>
public string Name => "RoomService_OnLobbyTimer";
private Action<int> _lobbyTimerAction;
/// <summary>
/// Subscribes to the lobby timer event and invokes the corresponding Lua function.
/// </summary>
public void Subscribe()
{
_lobbyTimerAction = time =>
{
ScriptingApi.CallFunction(Name, time);
};
Plugin.Instance.LobbyTimerAction += _lobbyTimerAction;
}
/// <summary>
/// Unsubscribes from the lobby timer event.
/// </summary>
public void Unsubscribe()
{
if (_lobbyTimerAction != null)
{
Plugin.Instance.LobbyTimerAction -= _lobbyTimerAction;
_lobbyTimerAction = null;
}
}
}
public class OnPlayerSetTimeEvent : ILuaEvent
{
/// <summary>
/// Gets the name of the Lua event.
/// </summary>
public string Name => "RoomService_OnPlayerSetTime";
private Action<PlayerTime> _playerSetTimeAction;
/// <summary>
/// Subscribes to the lobby timer event and invokes the corresponding Lua function.
/// </summary>
public void Subscribe()
{
_playerSetTimeAction = playerTime =>
{
ScriptingApi.CallFunction(Name, playerTime);
};
Plugin.Instance.PlayerSetTime += _playerSetTimeAction;
}
/// <summary>
/// Unsubscribes from the lobby timer event.
/// </summary>
public void Unsubscribe()
{
if (_playerSetTimeAction != null)
{
Plugin.Instance.PlayerSetTime -= _playerSetTimeAction;
_playerSetTimeAction = null;
}
}
}
public class OnLeaderboardChangeEvent : ILuaEvent
{
/// <summary>
/// Gets the name of the Lua event.
/// </summary>
public string Name => "RoomService_LeaderboardLogging";
/// <summary>
/// Subscribes to the leaderboard changes to process them
/// </summary>
public void Subscribe()
{
ZeepkistNetwork.LeaderboardUpdated += Plugin.Instance.ProcessLeaderboardUpdate;
}
/// <summary>
/// Unsubscribes from the leaderboard event.
/// </summary>
public void Unsubscribe()
{
ZeepkistNetwork.LeaderboardUpdated -= Plugin.Instance.ProcessLeaderboardUpdate;
}
}
}