1
1
using HarmonyLib ;
2
+ using Splotch . Event . GameEvents ;
2
3
using Splotch . Loader ;
3
4
using System ;
4
5
using System . Collections . Generic ;
@@ -127,9 +128,9 @@ public static void RunHandlers(Event e)
127
128
/// <summary>
128
129
/// An event that can be cancelled
129
130
/// </summary>
130
- public abstract class CancellableEvent : Event
131
+ public interface Cancellable
131
132
{
132
- public bool Cancelled { get ; set ; } = false ;
133
+ bool Cancelled { get ; set ; }
133
134
}
134
135
135
136
/// <summary>
@@ -144,8 +145,9 @@ namespace Splotch.Event.AbilityEvents
144
145
/// <summary>
145
146
/// A class that should be extended by any ability-related events
146
147
/// </summary>
147
- public abstract class AbilityEvent : CancellableEvent
148
+ public abstract class AbilityEvent : Event , Cancellable
148
149
{
150
+ public bool Cancelled { get ; set ; } = false ;
149
151
150
152
/// <summary>
151
153
/// Gets the ability related to the event
@@ -225,13 +227,24 @@ namespace Splotch.Event.PlayerEvents
225
227
/// <summary>
226
228
/// A class that should be extended by any player-related events
227
229
/// </summary>
228
- public abstract class PlayerEvent : Event
230
+ public abstract class PlayerEvent : GameEvent
229
231
{
230
232
/// <summary>
231
233
/// Retrieves the player related to the event
232
234
/// </summary>
233
235
/// <returns></returns>
234
236
public abstract Player GetPlayer ( ) ;
237
+ public override GameSessionHandler GetGameSessionHandler ( )
238
+ {
239
+ Player player = GetPlayer ( ) ;
240
+ FieldInfo selfRefField = typeof ( GameSessionHandler ) . GetField ( "selfRef" , BindingFlags . Static | BindingFlags . NonPublic ) ;
241
+ return selfRefField . GetValue ( null ) as GameSessionHandler ;
242
+ }
243
+
244
+ public SlimeController GetSlimeController ( )
245
+ {
246
+ return GetSlimeControllers ( ) [ GetPlayer ( ) . Id - 1 ] ;
247
+ }
235
248
}
236
249
237
250
public class PlayerDeathEvent : PlayerEvent
@@ -308,4 +321,20 @@ public static void Patch(ref PlayerBody __instance)
308
321
RunHandlers ( e ) ;
309
322
}
310
323
}
324
+
325
+ }
326
+
327
+ namespace Splotch . Event . GameEvents
328
+ {
329
+ public abstract class GameEvent : Event , Cancellable
330
+ {
331
+ public bool Cancelled { get ; set ; } = false ;
332
+
333
+ public abstract GameSessionHandler GetGameSessionHandler ( ) ;
334
+ public SlimeController [ ] GetSlimeControllers ( )
335
+ {
336
+ FieldInfo slimeControllersField = typeof ( GameSessionHandler ) . GetField ( "slimeControllers" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
337
+ return slimeControllersField . GetValue ( GetGameSessionHandler ( ) ) as SlimeController [ ] ;
338
+ }
339
+ }
311
340
}
0 commit comments