diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-07-28 13:37:17 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-07-28 13:37:17 +0100 |
| commit | f137095304f456b06229e4d17ee8249e974fceaf (patch) | |
| tree | 23d4aa9d3c8b5ddfc432bfa68b5e4e761641f6e0 /code/pawn/Player.cs | |
| parent | 8b69e65e51507118b014a0426ae6f957b78a0707 (diff) | |
Add spectator mode
Diffstat (limited to 'code/pawn/Player.cs')
| -rw-r--r-- | code/pawn/Player.cs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/code/pawn/Player.cs b/code/pawn/Player.cs index a1b126a..68d383d 100644 --- a/code/pawn/Player.cs +++ b/code/pawn/Player.cs @@ -47,6 +47,7 @@ public partial class Player : AnimatedEntity [BindComponent] public PlayerController Controller { get; }
[BindComponent] public PlayerAnimator Animator { get; }
[BindComponent] public PlayerInventory Inventory { get; }
+ [BindComponent] public PlayerSpectator Spectator { get; }
public Ragdoll PlayerRagdoll { get; set; }
public ClothingContainer PlayerClothingContainer { get; set; }
@@ -74,6 +75,7 @@ public partial class Player : AnimatedEntity Tags.Add( "livingplayer" );
EnableAllCollisions = true;
EnableDrawing = true;
+ Components.Remove( Spectator );
Components.Create<PlayerController>();
Components.Create<PlayerAnimator>();
Components.Create<PlayerInventory>();
@@ -85,6 +87,7 @@ public partial class Player : AnimatedEntity {
DisablePlayer();
DeleteRagdoll();
+ Components.RemoveAll();
}
public void DeleteRagdoll()
@@ -118,6 +121,7 @@ public partial class Player : AnimatedEntity ragdoll.PhysicsGroup.AddVelocity(LastAttackForce / 100);
PlayerClothingContainer.DressEntity( ragdoll );
PlayerRagdoll = ragdoll;
+ Components.Create<PlayerSpectator>();
}
public override void TakeDamage( DamageInfo info )
@@ -150,6 +154,7 @@ public partial class Player : AnimatedEntity Controller?.Simulate( cl );
Animator?.Simulate();
Inventory?.Simulate( cl );
+ Spectator?.Simulate();
EyeLocalPosition = Vector3.Up * (64f * Scale);
}
@@ -174,10 +179,13 @@ public partial class Player : AnimatedEntity ViewAngles = viewAngles.Normal;
}
- bool IsThirdPerson { get; set; } = false;
-
public override void FrameSimulate( IClient cl )
{
+ if (Spectator != null)
+ {
+ Spectator.FrameSimulate(this);
+ return;
+ }
SimulateRotation();
Camera.Rotation = ViewAngles.ToRotation();
|
