Пример #1
0
        public override void OnPlayerDied(Player player, Controllable controllable)
        {
            if (player == null)
            {
                return;
            }

            MyHud.BroadcastMessage($"{player.Name} has died");

            if (Authority)
            {
                var position  = controllable.Position;
                var eyeAngles = controllable.EyeAngles;

                var deathCamera = new DeathCamera();
                deathCamera.Spawn();
                player.Controlling = deathCamera;

                deathCamera.Position = position;
                deathCamera.Teleport(position);

                deathCamera.EyeAngles       = eyeAngles;
                deathCamera.ClientEyeAngles = eyeAngles;

                if (Phase == Phase.RoundActive && player.Team == (int)Team.Human)
                {
                    player.Team = (int)Team.Barrel;
                }

                if (Phase != Phase.RoundOver)
                {
                    RespawnPlayerLater(player, deathCamera, 3.0);
                }
            }
        }
Пример #2
0
        async void RespawnPlayerLater(Player player, DeathCamera deathCamera, double delay)
        {
            await Delay(TimeSpan.FromSeconds(delay));

            while (deathCamera.IsValid && !deathCamera.WantsToRespawn)
            {
                await Task.Yield();
            }

            if (Phase != Phase.RoundActive &&
                Phase != Phase.RoundWarmup)
            {
                return;
            }

            if (deathCamera != null && deathCamera.IsValid)
            {
                deathCamera.ClientClearTarget();
                deathCamera.Destroy();
            }

            RespawnPlayer(player);
        }