1- using Exiled . API . Enums ;
1+ namespace RemoteKeycard ;
22
3- namespace RemoteKeycard ;
4-
5- using System ;
3+ #if EXILED
64using Exiled . API . Features ;
75using Exiled . Events . EventArgs . Player ;
8- using Interactables . Interobjects . DoorUtils ;
9- using Players = Exiled . Events . Handlers . Player ;
6+ using PlayerEvents = Exiled . Events . Handlers . Player ;
7+ #else
8+ using LabApi . Events . Handlers ;
9+ using LabApi . Events . Arguments . PlayerEvents ;
10+ using System . Linq ;
11+ #endif
12+ using System ;
13+ using MapGeneration . Distributors ;
14+ using Log = LabApi . Features . Console . Logger ;
1015
1116public class EventHandlers
1217{
@@ -26,38 +31,51 @@ public EventHandlers(Config config)
2631 /// </summary>
2732 public void Start ( )
2833 {
29- Log . Debug ( "Registering Events" ) ;
30- Players . InteractingDoor += OnDoorInteract ;
31- Players . UnlockingGenerator += OnGeneratorUnlock ;
32- Players . InteractingLocker += OnLockerInteract ;
33- Players . ActivatingWarheadPanel += OnWarheadUnlock ;
34+ PlayerEvents . InteractingDoor += OnDoorInteract ;
35+ PlayerEvents . UnlockingGenerator += OnGeneratorUnlock ;
36+ PlayerEvents . InteractingLocker += OnLockerInteract ;
37+ #if EXILED
38+ PlayerEvents . ActivatingWarheadPanel += OnWarheadUnlock ;
39+ #else
40+ PlayerEvents . UnlockingWarheadButton += OnWarheadUnlock ;
41+ #endif
3442 }
3543
3644 /// <summary>
3745 /// Unregisters all events used.
3846 /// </summary>
3947 public void Stop ( )
4048 {
41- Players . InteractingDoor -= OnDoorInteract ;
42- Players . UnlockingGenerator -= OnGeneratorUnlock ;
43- Players . InteractingLocker -= OnLockerInteract ;
44- Players . ActivatingWarheadPanel -= OnWarheadUnlock ;
49+ PlayerEvents . InteractingDoor -= OnDoorInteract ;
50+ PlayerEvents . UnlockingGenerator -= OnGeneratorUnlock ;
51+ PlayerEvents . InteractingLocker -= OnLockerInteract ;
52+ #if EXILED
53+ PlayerEvents . ActivatingWarheadPanel -= OnWarheadUnlock ;
54+ #else
55+ PlayerEvents . UnlockingWarheadButton -= OnWarheadUnlock ;
56+ #endif
4557 }
4658
59+ #if EXILED
4760 private void OnDoorInteract ( InteractingDoorEventArgs ev )
61+ #else
62+ private void OnDoorInteract ( PlayerInteractingDoorEventArgs ev )
63+ #endif
4864 {
49- Log . Debug ( "Door Interact Event" ) ;
65+ Log . Debug ( "Door Interact Event" , Plugin . Instance . Config . Debug ) ;
5066 try
5167 {
5268 if ( ! _config . AffectDoors )
5369 return ;
5470
55- Log . Debug (
56- $ "Allowed: { ev . IsAllowed } , Permission?: { ev . Player . HasKeycardPermission ( ev . Door . KeycardPermissions ) } , Current Item: ${ ev . Player . CurrentItem } ") ;
57-
58- if ( ! ev . IsAllowed && ev . Player . HasKeycardPermission ( ev . Door . KeycardPermissions ) &&
59- ! ev . Door . IsLocked )
71+ Log . Debug ( $ "Allowed: { ev . IsAllowed } , Permission?: { ev . Player . HasKeycardPermission ( ev . Door . Base ) } , Current Item: ${ ev . Player . CurrentItem } ", Plugin . Instance . Config . Debug ) ;
72+ #if EXILED
73+ if ( ! ev . IsAllowed && ev . Player . HasKeycardPermission ( ev . Door . Base ) && ! ev . Door . IsLocked )
6074 ev . IsAllowed = true ;
75+ #else
76+ if ( ! ev . CanOpen && ev . Player . HasKeycardPermission ( ev . Door . Base ) && ! ev . Door . IsLocked )
77+ ev . CanOpen = true ;
78+ #endif
6179 }
6280 catch ( Exception e )
6381 {
@@ -66,67 +84,86 @@ private void OnDoorInteract(InteractingDoorEventArgs ev)
6684 }
6785 }
6886
69- private void OnWarheadUnlock ( ActivatingWarheadPanelEventArgs ev )
87+ #if EXILED
88+ private void OnGeneratorUnlock ( UnlockingGeneratorEventArgs ev )
89+ #else
90+ private void OnGeneratorUnlock ( PlayerUnlockingGeneratorEventArgs ev )
91+ #endif
7092 {
71- Log . Debug ( "Warhead Unlock Event" ) ;
93+ Log . Debug ( "Generator Unlock Event" , Plugin . Instance . Config . Debug ) ;
7294 try
7395 {
74- if ( ! _config . AffectWarheadPanel )
96+ if ( ! _config . AffectGenerators )
7597 return ;
7698
77- Log . Debug (
78- $ "Allowed: { ev . IsAllowed } , Permission?: { ev . Player . HasKeycardPermission ( KeycardPermissions . AlphaWarhead ) } ") ;
79-
80- if ( ! ev . IsAllowed && ev . Player . HasKeycardPermission ( KeycardPermissions . AlphaWarhead ) )
99+ Log . Debug ( $ "Allowed: { ev . IsAllowed } , Permission?: { ev . Player . HasKeycardPermission ( ev . Generator . Base ) } ", Plugin . Instance . Config . Debug ) ;
100+ #if EXILED
101+ if ( ! ev . IsAllowed && ev . Player . HasKeycardPermission ( ev . Generator . Base ) )
81102 ev . IsAllowed = true ;
103+ #else
104+ if ( ! ev . CanOpen && ev . Player . HasKeycardPermission ( ev . Generator . Base ) )
105+ ev . CanOpen = true ;
106+ #endif
82107 }
83108 catch ( Exception e )
84109 {
85110 if ( _config . ShowExceptions )
86- Log . Warn ( $ "{ nameof ( OnWarheadUnlock ) } : { e . Message } \n { e . StackTrace } ") ;
111+ Log . Warn ( $ "{ nameof ( OnGeneratorUnlock ) } : { e . Message } \n { e . StackTrace } ") ;
87112 }
88113 }
89114
90- private void OnGeneratorUnlock ( UnlockingGeneratorEventArgs ev )
115+ #if EXILED
116+ private void OnLockerInteract ( InteractingLockerEventArgs ev )
91117 {
92- Log . Debug ( "Generator Unlock Event" ) ;
118+ LockerChamber locker = ev . InteractingChamber ? . Base ;
119+ #else
120+ private void OnLockerInteract ( PlayerInteractingLockerEventArgs ev )
121+ {
122+ LockerChamber locker = ev . Chamber ? . Base ;
123+ #endif
124+ Log . Debug ( "Locker Interact Event" , Plugin . Instance . Config . Debug ) ;
93125 try
94126 {
95- if ( ! _config . AffectGenerators )
127+ if ( ! _config . AffectScpLockers )
96128 return ;
97129
98- Log . Debug (
99- $ "Allowed: { ev . IsAllowed } , Permission?: { ev . Player . HasKeycardPermission ( ev . Generator . KeycardPermissions ) } ") ;
100-
101- if ( ! ev . IsAllowed && ev . Player . HasKeycardPermission ( ev . Generator . KeycardPermissions ) )
130+ Log . Debug ( $ "Allowed: { ev . IsAllowed } , Permission?: { ev . Player . HasKeycardPermission ( locker ) } ", Plugin . Instance . Config . Debug ) ;
131+ #if EXILED
132+ if ( ! ev . IsAllowed && locker != null && ev . Player . HasKeycardPermission ( locker ) )
102133 ev . IsAllowed = true ;
134+ #else
135+ if ( ! ev . CanOpen && locker != null && ev . Player . HasKeycardPermission ( locker ) )
136+ ev . CanOpen = true ;
137+ #endif
103138 }
104139 catch ( Exception e )
105140 {
106141 if ( _config . ShowExceptions )
107- Log . Warn ( $ "{ nameof ( OnGeneratorUnlock ) } : { e . Message } \n { e . StackTrace } ") ;
142+ Log . Warn ( $ "{ nameof ( OnLockerInteract ) } : { e . Message } \n { e . StackTrace } ") ;
108143 }
109144 }
110145
111- private void OnLockerInteract ( InteractingLockerEventArgs ev )
146+ #if EXILED
147+ private void OnWarheadUnlock ( ActivatingWarheadPanelEventArgs ev )
148+ #else
149+ private void OnWarheadUnlock ( PlayerUnlockingWarheadButtonEventArgs ev )
150+ #endif
112151 {
113- Log . Debug ( "Locker Interact Event" ) ;
152+ Log . Debug ( "Warhead Unlock Event" , Plugin . Instance . Config . Debug ) ;
114153 try
115154 {
116- if ( ! _config . AffectScpLockers )
155+ if ( ! _config . AffectWarheadPanel )
117156 return ;
118157
119- Log . Debug (
120- $ "Allowed: { ev . IsAllowed } , Permission?: { ev . Player . HasKeycardPermission ( ev . InteractingChamber . RequiredPermissions , true ) } ") ;
158+ Log . Debug ( $ "Allowed: { ev . IsAllowed } , Permission?: { ev . Player . HasKeycardPermission ( AlphaWarheadActivationPanel . Instance ) } ", Plugin . Instance . Config . Debug ) ;
121159
122- if ( ! ev . IsAllowed && ev . InteractingChamber != null &&
123- ev . Player . HasKeycardPermission ( ev . InteractingChamber . RequiredPermissions , true ) )
160+ if ( ! ev . IsAllowed && ev . Player . HasKeycardPermission ( AlphaWarheadActivationPanel . Instance ) )
124161 ev . IsAllowed = true ;
125162 }
126163 catch ( Exception e )
127164 {
128165 if ( _config . ShowExceptions )
129- Log . Warn ( $ "{ nameof ( OnLockerInteract ) } : { e . Message } \n { e . StackTrace } ") ;
166+ Log . Warn ( $ "{ nameof ( OnWarheadUnlock ) } : { e . Message } \n { e . StackTrace } ") ;
130167 }
131168 }
132169}
0 commit comments