Exemplo n.º 1
0
        /// <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);
                }
            }
        }
Exemplo n.º 2
0
        /// <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);
        }