Skip to content

Commit

Permalink
ExplosionType
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Jan 7, 2025
1 parent 49fdfac commit 0d72d4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion EXILED/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public class ExplodingGrenadeEventArgs : IPlayerEvent, IDeniableEvent
/// <param name="position"><inheritdoc cref="Position"/></param>
/// <param name="grenade"><inheritdoc cref="Projectile"/></param>
/// <param name="targets"><inheritdoc cref="TargetsToAffect"/></param>
public ExplodingGrenadeEventArgs(Footprint thrower, Vector3 position, ExplosionGrenade grenade, Collider[] targets)
/// <param name="explosionType"><inheritdoc cref="ExplosionType"/></param>
public ExplodingGrenadeEventArgs(Footprint thrower, Vector3 position, ExplosionGrenade grenade, Collider[] targets, ExplosionType explosionType)
{
Player = Player.Get(thrower.Hub);
Projectile = Pickup.Get<EffectGrenadeProjectile>(grenade);
Position = position;
TargetsToAffect = HashSetPool<Player>.Pool.Get();
ExplosionType = explosionType;

if (Projectile.Base is not ExplosionGrenade)
return;
Expand Down Expand Up @@ -97,6 +99,7 @@ public ExplodingGrenadeEventArgs(Player thrower, EffectGrenade grenade, HashSet<
Player = thrower ?? Server.Host;
Projectile = Pickup.Get<EffectGrenadeProjectile>(grenade);
Position = Projectile.Position;
ExplosionType = ExplosionType.Custom;
TargetsToAffect = HashSetPool<Player>.Pool.Get(targetsToAffect ?? new HashSet<Player>());
IsAllowed = isAllowed;
}
Expand All @@ -114,6 +117,12 @@ public ExplodingGrenadeEventArgs(Player thrower, EffectGrenade grenade, HashSet<
/// </summary>
public Vector3 Position { get; }

/// <summary>
/// Gets or sets the Explosion type.
/// </summary>
/// <remarks>Unkown explosion will use <see cref="ExplosionType.Custom"/>.</remarks>
public ExplosionType ExplosionType { get; set; }

/// <summary>
/// Gets the players who could be affected by the grenade, if any, and the damage that be dealt.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// Collider[]
new(OpCodes.Ldloc_3),

// ExplodingGrenadeEventArgs ev = new(player, position, grenade, colliders);
new(OpCodes.Newobj, DeclaredConstructor(typeof(ExplodingGrenadeEventArgs), new[] { typeof(Footprint), typeof(Vector3), typeof(ExplosionGrenade), typeof(Collider[]) })),
// explosionType
new(OpCodes.Ldarg_3),

// ExplodingGrenadeEventArgs ev = new(player, position, grenade, colliders, ExplosionType);
new(OpCodes.Newobj, DeclaredConstructor(typeof(ExplodingGrenadeEventArgs), new[] { typeof(Footprint), typeof(Vector3), typeof(ExplosionGrenade), typeof(Collider[]), typeof(ExplosionType) })),
new(OpCodes.Dup),
new(OpCodes.Dup),
new(OpCodes.Stloc, ev.LocalIndex),
Expand Down

0 comments on commit 0d72d4d

Please sign in to comment.