11using HarmonyLib ;
22using PulsarModLoader . Chat . Extensions ;
3+ using PulsarModLoader . MPModChecks ;
34using PulsarModLoader . Patches ;
45
56namespace PulsarModLoader
@@ -17,82 +18,85 @@ public class Events
1718 /// <summary>
1819 /// creates PulsarModLoader.Events Instance. Additionally adds PML events
1920 /// </summary>
20- public Events ( )
21+ internal Events ( )
2122 {
2223 Instance = this ;
2324 }
2425
2526 /// <summary>
26- /// Called by Event EnterNewGame
27+ /// used by EnterNewGameEvent
2728 /// </summary>
28- public delegate void EnterNewGameEvent ( ) ;
29+ public delegate void EnterNewGameDelegate ( ) ;
2930
3031 /// <summary>
3132 /// Postfixes PLGlobal.EnterNewGame(). Called by PLNetworkManager.ClientWaitForHubIDAndLoadLevel and PLNetworkManager.ServerWaitForHubIDAndLoadLevel.
3233 /// </summary>
33- public event EnterNewGameEvent EnterNewGame ;
34+ public event EnterNewGameDelegate EnterNewGameEvent ;
3435
3536 [ HarmonyPatch ( typeof ( PLGlobal ) , "EnterNewGame" ) ]
3637 class EnterNewGamePatch
3738 {
3839 static void Postfix ( )
3940 {
40- Events . Instance . EnterNewGame ? . Invoke ( ) ;
41+ //Clear NetworkedPeers on game enter
42+ MPModCheckManager . Instance . NetworkedPeersModLists . Clear ( ) ;
43+
44+ Events . Instance . EnterNewGameEvent ? . Invoke ( ) ;
4145 }
4246 }
4347
4448 /// <summary>
45- /// Called by Event OnLeaveGame
49+ /// Used by OnLeaveGameEvent
4650 /// </summary>
47- public delegate void OnLeaveGameEvent ( ) ;
51+ public delegate void OnLeaveGameDelegate ( ) ;
4852
4953 /// <summary>
5054 /// Prefixes PLNetworkManager.OnLeaveGame(bool). Called by a variety of methods centered around intentionally and unintentionally leaving a game.
5155 /// </summary>
52- public event OnLeaveGameEvent OnLeaveGame ;
56+ public event OnLeaveGameDelegate OnLeaveGameEvent ;
5357
5458 [ HarmonyPatch ( typeof ( PLNetworkManager ) , "OnLeaveGame" ) ]
5559 class OnLeaveGamePatch
5660 {
5761 static void Prefix ( )
5862 {
59- Events . Instance . OnLeaveGame ? . Invoke ( ) ;
63+ Events . Instance . OnLeaveGameEvent ? . Invoke ( ) ;
6064 }
6165 }
6266
6367
6468 /// <summary>
65- /// Called By Event GameOver
69+ /// Used By GameOverEvent
6670 /// </summary>
6771 /// <param name="backToMainMenu"></param>
68- public delegate void GameOverEvent ( bool backToMainMenu ) ;
72+ public delegate void GameOverDelegate ( bool backToMainMenu ) ;
6973
7074 /// <summary>
7175 /// Prefixes PLNetworkManager.GameOver(Bool), Called by PLNetworkManager.OnLoeavGame, PLServer.SendGameOver, PLServer.ServerWaitForClientsToLeaveGame
7276 /// </summary>
73- public event GameOverEvent GameOver ;
77+ public event GameOverDelegate GameOverEvent ;
7478
7579 [ HarmonyPatch ( typeof ( PLNetworkManager ) , "GameOver" ) ]
7680 class GameOverPatch
7781 {
7882 static void Prefix ( bool backToMainMenu )
7983 {
80- Events . Instance . GameOver ? . Invoke ( backToMainMenu ) ;
84+ Events . Instance . GameOverEvent ? . Invoke ( backToMainMenu ) ;
8185 }
8286 }
8387
8488
8589 /// <summary>
86- /// Called by Event SpawnNewPlayer
90+ /// Used by SpawnNewPlayerEvent
8791 /// </summary>
8892 /// <param name="newPhotonPlayer"></param>
8993 /// <param name="inPlayerName"></param>
90- public delegate void SpawnNewPlayerEvent ( PhotonPlayer newPhotonPlayer , string inPlayerName ) ;
94+ public delegate void SpawnNewPlayerDelegate ( PhotonPlayer newPhotonPlayer , string inPlayerName ) ;
9195
9296 /// <summary>
9397 /// Postfixes PLServer.SpawnNewPlayer(PhotonPlayer, String) Called By PLServer.LoginMessage. Onle called for players connecting.
9498 /// </summary>
95- public event SpawnNewPlayerEvent SpawnNewPlayer ;
99+ public event SpawnNewPlayerDelegate SpawnNewPlayerEvent ;
96100
97101 [ HarmonyPatch ( typeof ( PLServer ) , "SpawnNewPlayer" ) ]
98102 class SpawnNewPlayerPatch
@@ -102,21 +106,21 @@ static void Postfix(PhotonPlayer newPhotonPlayer, string inPlayerName)
102106 //Updates PlayerList on Player Added.
103107 PhotonProperties . UpdatePlayerList ( ) ;
104108
105- Events . Instance . SpawnNewPlayer ? . Invoke ( newPhotonPlayer , inPlayerName ) ;
109+ Events . Instance . SpawnNewPlayerEvent ? . Invoke ( newPhotonPlayer , inPlayerName ) ;
106110 }
107111 }
108112
109113
110114 /// <summary>
111- /// Called by Event RemovePlayer
115+ /// Used by RemovePlayerEvent
112116 /// </summary>
113117 /// <param name="player"></param>
114- public delegate void RemovePlayerEvent ( PLPlayer player ) ;
118+ public delegate void RemovePlayerDelegate ( PLPlayer player ) ;
115119
116120 /// <summary>
117121 /// Prefixes PLServer.RemovePlayer(PLPlayer) Called by PLNetworkManager.OnPhotonPlayerDisconnected, PLServer.ServerRemoveBot, PLServer.ServerRemoveCrewBotPlayer
118122 /// </summary>
119- public event RemovePlayerEvent RemovePlayer ;
123+ public event RemovePlayerDelegate RemovePlayerEvent ;
120124
121125 [ HarmonyPatch ( typeof ( PLServer ) , "RemovePlayer" ) ]
122126 class RemovePlayerPatch
@@ -126,20 +130,20 @@ static void Prefix(PLPlayer inPlayer)
126130 //Updates PlayerList on Player Added
127131 PhotonProperties . UpdatePlayerList ( ) ;
128132
129- Events . Instance . RemovePlayer ? . Invoke ( inPlayer ) ;
133+ Events . Instance . RemovePlayerEvent ? . Invoke ( inPlayer ) ;
130134 }
131135 }
132136
133137
134138 /// <summary>
135- /// Called by Event ServerStart
139+ /// Used by ServerStartEvent
136140 /// </summary>
137- public delegate void ServerStartEvent ( PLServer instance ) ;
141+ public delegate void ServerStartDelegate ( PLServer instance ) ;
138142
139143 /// <summary>
140144 /// Postfixes PLServer.Start(). Called by Unity after creation of a server instance.
141145 /// </summary>
142- public event ServerStartEvent ServerStart ;
146+ public event ServerStartDelegate ServerStartEvent ;
143147
144148 [ HarmonyPatch ( typeof ( PLServer ) , "Start" ) ]
145149 class ServerStartPatch
@@ -150,7 +154,45 @@ static void Postfix(PLServer __instance)
150154 ChatHelper . publicCached = false ;
151155 HandlePublicCommands . RequestPublicCommands ( ) ;
152156
153- Events . Instance . ServerStart ? . Invoke ( __instance ) ;
157+ Events . Instance . ServerStartEvent ? . Invoke ( __instance ) ;
158+ }
159+ }
160+
161+ /// <summary>
162+ /// Used by ClientModlistRecievedEvent
163+ /// </summary>
164+ /// <param name="IncomingPlayer"></param>
165+ public delegate void ClientModlistRecievedDelegate ( PhotonPlayer IncomingPlayer ) ;
166+
167+
168+ /// <summary>
169+ /// Called after a client modlist has been recieved by the MPModCheckManager instance.
170+ /// </summary>
171+ public event ClientModlistRecievedDelegate ClientModlistRecievedEvent ;
172+
173+ internal void CallClientModlistRecievedEvent ( PhotonPlayer IncomingPlayer )
174+ {
175+ ClientModlistRecievedEvent ? . Invoke ( IncomingPlayer ) ;
176+ }
177+
178+
179+ /// <summary>
180+ /// Used by ServerOnClientVerifiedEvent
181+ /// </summary>
182+ /// <param name="JoiningPhotonPlayer"></param>
183+ public delegate void ServerOnClientVerifiedDelegate ( PhotonPlayer JoiningPhotonPlayer ) ;
184+
185+ /// <summary>
186+ /// Called after a client is succesfully verified, as a postfix to PLServer.ServerOnClientVerified(PhotonPlayer).
187+ /// </summary>
188+ public ServerOnClientVerifiedDelegate ServerOnClientVerifiedEvent ;
189+
190+ [ HarmonyPatch ( typeof ( PLServer ) , "ServerOnClientVerified" ) ]
191+ class ServerOnClientVerifiedPatch
192+ {
193+ static void Postfix ( PhotonPlayer client )
194+ {
195+ Events . Instance . ServerOnClientVerifiedEvent ? . Invoke ( client ) ;
154196 }
155197 }
156198 }
0 commit comments