diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-07-28 22:06:03 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-07-28 22:06:03 +0100 |
| commit | 1e5c6393a6b29eb00dbb8fb137d86647cb0c356b (patch) | |
| tree | 95cbba0e7ade6bd97675480c2559c8e01f74a635 /code/pawn/PlayerSpectator.cs | |
| parent | f137095304f456b06229e4d17ee8249e974fceaf (diff) | |
Add TryUnstuck and death overlay
Diffstat (limited to 'code/pawn/PlayerSpectator.cs')
| -rw-r--r-- | code/pawn/PlayerSpectator.cs | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/code/pawn/PlayerSpectator.cs b/code/pawn/PlayerSpectator.cs deleted file mode 100644 index c468de0..0000000 --- a/code/pawn/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();
- }
-}
|
