@@ -35,7 +35,7 @@ You should have received a copy of the GNU General Public License
35
35
using System . Linq ;
36
36
using UnityEngine ;
37
37
38
- [ assembly: MelonInfo ( typeof ( AntiGrief ) , "Anti-Grief" , "1.2.4 " , "databomb" , "https://github.com/data-bomb/Silica" ) ]
38
+ [ assembly: MelonInfo ( typeof ( AntiGrief ) , "Anti-Grief" , "1.3.0 " , "databomb" , "https://github.com/data-bomb/Silica" ) ]
39
39
[ assembly: MelonGame ( "Bohemia Interactive" , "Silica" ) ]
40
40
[ assembly: MelonOptionalDependencies ( "Admin Mod" ) ]
41
41
@@ -47,6 +47,7 @@ public class AntiGrief : MelonMod
47
47
static MelonPreferences_Entry < int > _NegativeKillsThreshold = null ! ;
48
48
static MelonPreferences_Entry < bool > _NegativeKills_Penalty_Ban = null ! ;
49
49
static MelonPreferences_Entry < bool > _StructureAntiGrief_IgnoreNodes = null ! ;
50
+ static MelonPreferences_Entry < bool > _BlockShrimpControllers = null ! ;
50
51
51
52
private const string ModCategory = "Silica" ;
52
53
@@ -56,13 +57,15 @@ public override void OnInitializeMelon()
56
57
_NegativeKillsThreshold ??= _modCategory . CreateEntry < int > ( "Grief_NegativeKills_Threshold" , - 125 ) ;
57
58
_NegativeKills_Penalty_Ban ??= _modCategory . CreateEntry < bool > ( "Grief_NegativeKills_Penalty_Ban" , true ) ;
58
59
_StructureAntiGrief_IgnoreNodes ??= _modCategory . CreateEntry < bool > ( "Grief_IgnoreFriendlyNodesDestroyed" , true ) ;
60
+ _BlockShrimpControllers ??= _modCategory . CreateEntry < bool > ( "Grief_BlockShrimpTakeOver" , true ) ;
59
61
}
60
62
61
63
62
64
public override void OnLateInitializeMelon ( )
63
65
{
64
- //subscribing to the event
66
+ //subscribing to the events
65
67
Event_Roles . OnRoleChanged += OnRoleChanged ;
68
+ Event_Units . OnRequestEnterUnit += OnRequestEnterUnit ;
66
69
67
70
#if NET6_0
68
71
bool QListLoaded = RegisteredMelons . Any ( m => m . Info . Name == "QList" ) ;
@@ -243,6 +246,48 @@ public static void Postfix(MP_Strategy __instance, Structure __0, EDamageType __
243
246
}
244
247
}
245
248
249
+ public void OnRequestEnterUnit ( object ? sender , OnRequestEnterUnitArgs args )
250
+ {
251
+ try
252
+ {
253
+ if ( args == null )
254
+ {
255
+ return ;
256
+ }
257
+
258
+ if ( ! _BlockShrimpControllers . Value )
259
+ {
260
+ return ;
261
+ }
262
+
263
+ Player player = args . Player ;
264
+ Unit unit = args . Unit ;
265
+
266
+ if ( player == null || player . Team == null || unit == null )
267
+ {
268
+ return ;
269
+ }
270
+
271
+ // if the player isn't on the alien team, we can skip this check
272
+ if ( player . Team . Index != ( int ) SiConstants . ETeam . Alien )
273
+ {
274
+ return ;
275
+ }
276
+
277
+ // is it a shrimp?
278
+ if ( unit . IsResourceHolder )
279
+ {
280
+ MelonLogger . Msg ( "Found " + player . PlayerName + " trying to use an Alien shrimp." ) ;
281
+ HelperMethods . SendChatMessageToPlayer ( player , HelperMethods . chatPrefix , " use of shrimp is not permitted on this server." ) ;
282
+ args . Block = true ;
283
+ }
284
+ }
285
+ catch ( Exception error )
286
+ {
287
+ HelperMethods . PrintError ( error , "Failed to run OnRequestEnterUnit" ) ;
288
+ }
289
+ }
290
+
246
291
// hook DestroyAllUnitsForPlayer pre and override game code to prevent aliens from dying
247
292
public void OnRoleChanged ( object ? sender , OnRoleChangedArgs args )
248
293
{
@@ -301,7 +346,6 @@ public void OnRoleChanged(object? sender, OnRoleChangedArgs args)
301
346
{
302
347
HelperMethods . PrintError ( error , "Failed to run OnRoleChanged" ) ;
303
348
}
304
-
305
349
}
306
350
307
351
public static bool IsHighValueAlienUnit ( Unit unit )
0 commit comments