Esempio n. 1
0
        public void OnDied(DiedEventArgs ev)
        {
            if (Tracking.PlayersInvisibleByCommand.Contains(ev.Target))
            {
                Tracking.PlayersInvisibleByCommand.Remove(ev.Target);
            }
            if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Target) && Tracking.PlayersWithSubclasses[ev.Target].Abilities.Contains(AbilityType.ExplodeOnDeath))
            {
                GrenadeManager  grenadeManager = ev.Target.ReferenceHub.gameObject.GetComponent <GrenadeManager>();
                GrenadeSettings settings       = grenadeManager.availableGrenades.FirstOrDefault(g => g.inventoryID == ItemType.GrenadeFrag);
                Grenade         grenade        = UnityEngine.Object.Instantiate(settings.grenadeInstance).GetComponent <Grenade>();
                grenade.fuseDuration = Tracking.PlayersWithSubclasses[ev.Target].FloatOptions.ContainsKey("ExplodeOnDeathFuseTimer") ?
                                       Tracking.PlayersWithSubclasses[ev.Target].FloatOptions["ExplodeOnDeathFuseTimer"] : 2f;
                grenade.FullInitData(grenadeManager, ev.Target.Position, Quaternion.Euler(grenade.throwStartAngle),
                                     grenade.throwLinearVelocityOffset, grenade.throwAngularVelocity);
                NetworkServer.Spawn(grenade.gameObject);
            }

            Tracking.AddPreviousTeam(ev.Target);
            Tracking.RemoveZombie(ev.Target);
            Tracking.RemoveAndAddRoles(ev.Target, true);
            Timing.CallDelayed(0.1f, () => {
                Tracking.CheckRoundEnd();
            });
        }