예제 #1
0
파일: Gamemode.cs 프로젝트: 0-jack/sbox-ttt
        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
파일: Gamemode.cs 프로젝트: 0-jack/sbox-ttt
        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);
        }