/// <summary> /// Initializes a new instance of the <see cref="ExplodingGrenadeEventArgs"/> class. /// </summary> /// <param name="thrower"><inheritdoc cref="Thrower"/></param> /// <param name="grenade"><inheritdoc cref="Grenade"/></param> /// <param name="targets"><inheritdoc cref="TargetsToAffect"/></param> public ExplodingGrenadeEventArgs(Player thrower, EffectGrenade grenade, Collider[] targets) { Thrower = thrower ?? Server.Host; GrenadeType = grenadeDictionary[grenade.GetType()]; Grenade = grenade; TargetsToAffect = ListPool <Player> .Shared.Rent(); foreach (Collider collider in targets) { if (!(Grenade is ExplosionGrenade) || !collider.TryGetComponent(out IDestructible destructible) || !ReferenceHub.TryGetHubNetID(destructible.NetworkId, out ReferenceHub hub)) { continue; } Player player = Player.Get(hub); if (player == null) { continue; } if (!TargetsToAffect.Contains(player)) { TargetsToAffect.Add(player); } } }
/// <summary> /// Initializes a new instance of the <see cref="ExplodingGrenadeEventArgs"/> class. /// </summary> /// <param name="thrower"><inheritdoc cref="Thrower"/></param> /// <param name="grenade"><inheritdoc cref="Grenade"/></param> /// <param name="players"><inheritdoc cref="TargetsToAffect"/></param> public ExplodingGrenadeEventArgs(Player thrower, EffectGrenade grenade, List <Player> players) { Thrower = thrower ?? Server.Host; GrenadeType = grenadeDictionary[grenade.GetType()]; Grenade = grenade; TargetsToAffect = ListPool <Player> .Shared.Rent(); TargetsToAffect.AddRange(players); }