aboutsummaryrefslogtreecommitdiffstats
path: root/code/pawn/component/PlayerSpectator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'code/pawn/component/PlayerSpectator.cs')
-rw-r--r--code/pawn/component/PlayerSpectator.cs48
1 files changed, 0 insertions, 48 deletions
diff --git a/code/pawn/component/PlayerSpectator.cs b/code/pawn/component/PlayerSpectator.cs
deleted file mode 100644
index c468de0..0000000
--- a/code/pawn/component/PlayerSpectator.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using Sandbox;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace MurderGame;
-
-public class PlayerSpectator : EntityComponent<Player>
-{
- public Player Target { get; set; }
-
- public void Simulate()
- {
- if (Target == null || !Target.IsValid() || Target.LifeState == LifeState.Dead)
- {
- var targets = GetTargets();
- if ( targets.Count == 0 )
- {
- Target = null;
- return;
- }
- var nextTarget = targets.First();
- Target = (Player)nextTarget.Pawn;
- }
- }
-
- public void FrameSimulate( Player player )
- {
- if ( Target == null || !Target.IsValid() || Target.LifeState == LifeState.Dead ) return;
-
- // SimulateRotation(player);
- Camera.Rotation = Target.EyeRotation;
- Camera.FieldOfView = Screen.CreateVerticalFieldOfView( Game.Preferences.FieldOfView );
-
- Camera.FirstPersonViewer = Target;
- Camera.Position = Target.EyePosition;
- }
-
- protected void SimulateRotation(Player player)
- {
- player.EyeRotation = Target.ViewAngles.ToRotation();
- player.Rotation = Target.ViewAngles.WithPitch( 0f ).ToRotation();
- }
-
- public List<IClient> GetTargets()
- {
- return Game.Clients.Where(c => c.Pawn is Player player && player.CurrentTeam != Team.Spectator && player.LifeState == LifeState.Alive).ToList();
- }
-}