Create FPS Test minigame with other shit

This commit is contained in:
Keenan Turley
2023-08-03 21:32:33 -07:00
parent bdb25fd3ce
commit 97a2442d03
15 changed files with 758 additions and 13 deletions

View File

@@ -6,11 +6,11 @@ namespace LuckerGame.Components.Lucker.Cameras;
public abstract class AbstractCamera : EntityComponent<Entities.Lucker>, ISingletonComponent
{
public virtual bool ShouldShowCursor => false;
protected Vector3 CameraPosition { get; set; }
protected Rotation CameraRotation { get; set; }
protected float FieldOfView { get; set; }
protected IEntity FirstPersonViewer { get; set; }
protected Transform SoundSource { get; set; }
public Vector3 CameraPosition { get; set; }
public Rotation CameraRotation { get; set; }
public float FieldOfView { get; set; }
public IEntity FirstPersonViewer { get; set; }
public Transform SoundSource { get; set; }
/// <summary>
/// Handles any input-independent camera updates (ie following a pawn)

View File

@@ -0,0 +1,43 @@
using Sandbox;
namespace LuckerGame.Components.Lucker.Cameras;
public class FpsCamera : AbstractCamera
{
protected override void UpdateCameraParameters()
{
if ( Entity.Pawn is not Minigames.FpsTest.Pawn pawn)
{
return;
}
CameraRotation = pawn.ViewAngles.ToRotation();
FieldOfView = Screen.CreateVerticalFieldOfView( Game.Preferences.FieldOfView );
FirstPersonViewer = pawn;
CameraPosition = pawn.EyePosition;
}
public override void BuildInput()
{
if ( Input.StopProcessing )
return;
if ( Entity.Pawn is not Minigames.FpsTest.Pawn pawn )
{
return;
}
var look = Input.AnalogLook;
if ( pawn.ViewAngles.pitch is > 90f or < -90f )
{
look = look.WithYaw( look.yaw * -1f );
}
var viewAngles = pawn.ViewAngles;
viewAngles += look;
viewAngles.pitch = viewAngles.pitch.Clamp( -89f, 89f );
viewAngles.roll = 0f;
pawn.ViewAngles = viewAngles.Normal;
}
}

View File

@@ -7,7 +7,7 @@ namespace LuckerGame.Components.Lucker.Cameras;
/// <summary>
/// A top down camera that can be
/// </summary>
public partial class RTSCamera : AbstractCamera, ISingletonComponent
public partial class RTSCamera : AbstractCamera
{
public override bool ShouldShowCursor => true;
private const float MaxDistance = 400f;