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

@@ -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;
}
}