diff options
Diffstat (limited to 'code/pawn/component/camera/SpectatorCameraComponent.cs')
| -rw-r--r-- | code/pawn/component/camera/SpectatorCameraComponent.cs | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/code/pawn/component/camera/SpectatorCameraComponent.cs b/code/pawn/component/camera/SpectatorCameraComponent.cs index 215b9ca..9dce4c3 100644 --- a/code/pawn/component/camera/SpectatorCameraComponent.cs +++ b/code/pawn/component/camera/SpectatorCameraComponent.cs @@ -1,6 +1,6 @@ -using Sandbox;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
+using Sandbox;
namespace MurderGame;
@@ -17,7 +17,8 @@ public partial class SpectatorCameraComponent : BaseCameraComponent Target = null;
return;
}
- if (Target == null || !Target.IsValid() || Target.LifeState == LifeState.Dead)
+
+ if ( Target == null || !Target.IsValid() || Target.LifeState == LifeState.Dead )
{
FindNextTarget( targets, false );
return;
@@ -36,7 +37,10 @@ public partial class SpectatorCameraComponent : BaseCameraComponent public override void FrameSimulate( IClient cl )
{
- if ( Target == null || !Target.IsValid() || Target.LifeState == LifeState.Dead ) return;
+ if ( Target == null || !Target.IsValid() || Target.LifeState == LifeState.Dead )
+ {
+ return;
+ }
Camera.Rotation = Target.EyeRotation;
Camera.FieldOfView = Screen.CreateVerticalFieldOfView( Game.Preferences.FieldOfView );
@@ -47,27 +51,36 @@ public partial class SpectatorCameraComponent : BaseCameraComponent private List<IClient> GetTargets()
{
- return Game.Clients.Where(c => c.Pawn is Player player && player.Team != Team.Spectator && player.LifeState == LifeState.Alive).ToList();
+ return Game.Clients.Where( c =>
+ c.Pawn is Player player && player.Team != Team.Spectator && player.LifeState == LifeState.Alive ).ToList();
}
-
- private void FindNextTarget(List<IClient> targets, bool backwards)
+
+ private void FindNextTarget( List<IClient> targets, bool backwards )
{
if ( !backwards )
{
- if ( ++TargetIndex >= targets.Count ) TargetIndex = 0;
- }
- else {
- if ( --TargetIndex < 0 ) TargetIndex = targets.Count - 1;
+ if ( ++TargetIndex >= targets.Count )
+ {
+ TargetIndex = 0;
+ }
+ }
+ else
+ {
+ if ( --TargetIndex < 0 )
+ {
+ TargetIndex = targets.Count - 1;
+ }
}
+
var nextTarget = targets[TargetIndex];
Target = (Player)nextTarget.Pawn;
}
-
+
public override InventoryComponent GetObservedInventory()
{
return Target?.Inventory;
}
-
+
public override float GetObservedHealth()
{
return Target?.Health ?? base.GetObservedHealth();
@@ -77,13 +90,13 @@ public partial class SpectatorCameraComponent : BaseCameraComponent {
return Target?.Team ?? base.GetObservedTeam();
}
-
+
public override string GetObservedName()
{
var characterName = Target?.CharacterName ?? "";
- return string.IsNullOrWhiteSpace( characterName ) ? (Target?.Client.Name ?? "Unknown") : characterName;
+ return string.IsNullOrWhiteSpace( characterName ) ? Target?.Client.Name ?? "Unknown" : characterName;
}
-
+
public override string GetObservedColour()
{
return Target?.HexColor ?? base.GetObservedColour();
|
