From 1e5c6393a6b29eb00dbb8fb137d86647cb0c356b Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Fri, 28 Jul 2023 22:06:03 +0100 Subject: Add TryUnstuck and death overlay --- code/phase/AssignPhase.cs | 7 ++++--- code/phase/PlayPhase.cs | 8 +++++++- code/phase/WaitPhase.cs | 31 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) (limited to 'code/phase') diff --git a/code/phase/AssignPhase.cs b/code/phase/AssignPhase.cs index 26c9fc1..0ae6bd2 100644 --- a/code/phase/AssignPhase.cs +++ b/code/phase/AssignPhase.cs @@ -21,9 +21,10 @@ public class AssignPhase : BasePhase var detectivesNeeded = 1; var murderersNeeded = 1; - List spawnpoints = Entity.All.OfType().OrderBy( x => Guid.NewGuid() ).ToList(); + Random random = new(); + List spawnpoints = Entity.All.OfType().OrderBy( _ => random.Next() ).ToList(); var clients = Game.Clients.ToList(); - foreach ( int i in Enumerable.Range( 0, clients.Count ).OrderBy( x => Guid.NewGuid() ) ) + foreach ( int i in Enumerable.Range( 0, clients.Count ).OrderBy( _ => random.Next() ) ) { var client = clients[i]; if (client.Pawn != null) @@ -60,7 +61,7 @@ public class AssignPhase : BasePhase var spawnpoint = spawnpoints[0]; spawnpoints.RemoveAt( 0 ); var tx = spawnpoint.Transform; - tx.Position = tx.Position + Vector3.Up * 50.0f; + tx.Position = tx.Position + Vector3.Up * 10.0f; pawn.Transform = tx; RoleOverlay.Show( To.Single( client ) ); diff --git a/code/phase/PlayPhase.cs b/code/phase/PlayPhase.cs index 118529e..b6210b3 100644 --- a/code/phase/PlayPhase.cs +++ b/code/phase/PlayPhase.cs @@ -47,6 +47,7 @@ public class PlayPhase : BasePhase { Log.Info( "Removing blind from " + entity.Name ); BlindedOverlay.Hide( To.Single( entity ) ); + DeathOverlay.Hide( To.Single( entity ) ); if (entity is Player pawn && pawn.IsValid() ) { if (pawn.Controller != null) pawn.Controller.SpeedMultiplier = 1; @@ -103,20 +104,25 @@ public class PlayPhase : BasePhase } Player victimPlayer = (Player)victim; Player killerPlayer = (Player)killer; + Team victimTeam = victimPlayer.CurrentTeam; Team killerTeam = killerPlayer.CurrentTeam; + victimPlayer.CurrentTeam = Team.Spectator; Log.Info( victimPlayer + " died to " + killerPlayer ); + if (victimTeam != Team.Murderer && killerTeam != Team.Murderer) { Log.Info( killerPlayer + " shot a bystander"); + ChatBox.Say( killerPlayer.Client.Name + " killed an innocent bystander" ); + BlindedOverlay.Show( To.Single( killer ) ); + if (killerPlayer.Controller != null) killerPlayer.Controller.SpeedMultiplier = 0.3f; if (killerPlayer.Inventory != null) { - Log.Info( killerPlayer + "bonk"); killerPlayer.Inventory.AllowPickup = false; killerPlayer.Inventory.SpillContents(killerPlayer.EyePosition, killerPlayer.AimRay.Forward); } diff --git a/code/phase/WaitPhase.cs b/code/phase/WaitPhase.cs index 4f2e876..9eab094 100644 --- a/code/phase/WaitPhase.cs +++ b/code/phase/WaitPhase.cs @@ -23,6 +23,7 @@ public class WaitPhase : BasePhase { base.NextPhase = new AssignPhase(); base.IsFinished = true; + return; } else if (CountIn && !_isCountDown) { @@ -34,6 +35,36 @@ public class WaitPhase : BasePhase _isCountDown = false; base.TimeLeft = -1; } + + foreach (var client in Game.Clients) + { + if (client.Pawn == null) + { + var pawn = new Player(); + client.Pawn = pawn; + + var spawnpoints = Entity.All.OfType(); + var randomSpawnPoint = spawnpoints.OrderBy( x => Guid.NewGuid() ).FirstOrDefault(); + if ( randomSpawnPoint != null ) + { + var tx = randomSpawnPoint.Transform; + tx.Position = tx.Position + Vector3.Up * 50.0f; + pawn.Transform = tx; + } + + pawn.CurrentTeam = Team.Bystander; + pawn.Spawn(); + pawn.Respawn(); + } else + { + var pawn = (Player)client.Pawn; + if (pawn.LifeState == LifeState.Dead) + { + pawn.CurrentTeam = Team.Bystander; + pawn.Respawn(); + } + } + } } public override void HandleClientJoin( ClientJoinedEvent e ) -- cgit v1.2.3-70-g09d2