@@ -39,6 +39,9 @@ public class Plastic : CustomGrenade
3939 public static Dictionary < Pickup , Player > PlacedCharges { get ; } = [ ] ;
4040 public static Dictionary < ushort , Player > Charges { get ; } = [ ] ;
4141 public static Plastic Instance { get ; private set ; } = null ! ;
42+
43+ private const float DetonationDelay = 3f ; // Delay in seconds before the grenade can explode
44+ private static Dictionary < Pickup , float > ThrowTimes { get ; } = new ( ) ;
4245 public override SpawnProperties ? SpawnProperties { get ; set ; } = new ( )
4346
4447 {
@@ -72,6 +75,14 @@ public void Handler(Pickup? charge, C4RemoveMethod method = C4RemoveMethod.Drop,
7275 {
7376 if ( charge ? . Position is null ) return ;
7477
78+ if ( method == C4RemoveMethod . Detonate && ThrowTimes . TryGetValue ( charge , out float throwTime ) )
79+ {
80+ if ( Time . time - throwTime < DetonationDelay )
81+ {
82+ return ;
83+ }
84+ }
85+
7586 if ( detonator == null && charge != null ) { method = C4RemoveMethod . Drop ; }
7687 else { detonator = Charges . TryGetValue ( charge . Serial , out var foundPlayer ) ? foundPlayer : null ; }
7788
@@ -98,6 +109,7 @@ public void Handler(Pickup? charge, C4RemoveMethod method = C4RemoveMethod.Drop,
98109 }
99110
100111 PlacedCharges . Remove ( charge ) ;
112+ ThrowTimes . Remove ( charge ) ; // Remove from the throw time dictionary
101113 charge . Destroy ( ) ;
102114 }
103115
@@ -138,6 +150,7 @@ protected override void OnThrownProjectile(ThrownProjectileEventArgs ev)
138150 {
139151 PlacedCharges . Add ( ev . Pickup , ev . Player ) ;
140152 Charges . Add ( ev . Projectile . Serial , ev . Player ) ;
153+ ThrowTimes [ ev . Pickup ] = Time . time ; // Store the throw time
141154 }
142155
143156 base . OnThrownProjectile ( ev ) ;
0 commit comments