Create FPS Test minigame with other shit
This commit is contained in:
43
code/EntityComponents/Lucker/Cameras/FpsCamera.cs
Normal file
43
code/EntityComponents/Lucker/Cameras/FpsCamera.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user