fixed camera with lookat functions
This commit is contained in:
@@ -3,7 +3,7 @@ using Sandbox;
|
|||||||
|
|
||||||
namespace LuckerGame.Components.Lucker.Cameras;
|
namespace LuckerGame.Components.Lucker.Cameras;
|
||||||
|
|
||||||
public abstract class AbstractCamera : EntityComponent<Entities.Lucker>, ISingletonComponent
|
public abstract partial class AbstractCamera : EntityComponent<Entities.Lucker>, ISingletonComponent
|
||||||
{
|
{
|
||||||
public virtual bool ShouldShowCursor => false;
|
public virtual bool ShouldShowCursor => false;
|
||||||
protected Vector3 CameraPosition { get; set; }
|
protected Vector3 CameraPosition { get; set; }
|
||||||
@@ -16,11 +16,11 @@ public abstract class AbstractCamera : EntityComponent<Entities.Lucker>, ISingle
|
|||||||
/// Handles any input-independent camera updates (ie following a pawn)
|
/// Handles any input-independent camera updates (ie following a pawn)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void UpdateCameraParameters();
|
protected abstract void UpdateCameraParameters();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles any input dependent camera updates (ie moving around a top down cam)
|
/// Handles any input dependent camera updates (ie moving around a top down cam)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract void BuildInput();
|
public virtual void BuildInput() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies Camera parameters to the static Camera
|
/// Applies Camera parameters to the static Camera
|
||||||
|
|||||||
@@ -4,13 +4,38 @@ namespace LuckerGame.Components.Lucker.Cameras;
|
|||||||
|
|
||||||
public partial class FixedCamera : AbstractCamera, ISingletonComponent
|
public partial class FixedCamera : AbstractCamera, ISingletonComponent
|
||||||
{
|
{
|
||||||
public override void BuildInput()
|
[Net] public float FieldOfViewValue { get; set; } = 70f;
|
||||||
{
|
public override bool ShouldShowCursor => true;
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateCameraParameters()
|
protected override void UpdateCameraParameters()
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
FieldOfView = FieldOfViewValue;
|
||||||
|
FirstPersonViewer = null;
|
||||||
|
SoundSource = new Transform { Position = CameraPosition };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ClientRpc doesn't allow for nullable versions of non-nullable types
|
||||||
|
/// so here we are
|
||||||
|
/// </summary>
|
||||||
|
public void UpdateCameraPositionRotation( Vector3? position = null, Rotation? rotation = null )
|
||||||
|
{
|
||||||
|
CameraPosition = (Vector3)(position.Equals( null ) ? CameraPosition : position);
|
||||||
|
CameraRotation = (Rotation)(rotation.Equals( null ) ? CameraRotation : rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ClientRpc]
|
||||||
|
public void LookAt( Vector3 position )
|
||||||
|
{
|
||||||
|
UpdateCameraPositionRotation( position );
|
||||||
|
}
|
||||||
|
[ClientRpc]
|
||||||
|
public void LookAt( Rotation rotation )
|
||||||
|
{
|
||||||
|
UpdateCameraPositionRotation( rotation: rotation );
|
||||||
|
}
|
||||||
|
[ClientRpc]
|
||||||
|
public void LookAt( Vector3 position, Rotation rotation )
|
||||||
|
{
|
||||||
|
UpdateCameraPositionRotation( position, rotation );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class TerryRaces : Minigame
|
|||||||
{
|
{
|
||||||
public override string Name => "Terry Races";
|
public override string Name => "Terry Races";
|
||||||
private List<Lucker> Players { get; set; }
|
private List<Lucker> Players { get; set; }
|
||||||
|
private FixedCamera camera;
|
||||||
|
|
||||||
public override void Initialize( List<Lucker> players )
|
public override void Initialize( List<Lucker> players )
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,9 @@ public class TerryRaces : Minigame
|
|||||||
// Setup cameras for players
|
// Setup cameras for players
|
||||||
Players.ForEach( player =>
|
Players.ForEach( player =>
|
||||||
{
|
{
|
||||||
player.Components.Create<RTSCamera>();
|
camera = player.Components.Create<FixedCamera>();
|
||||||
|
camera.LookAt( new Vector3( -110f, 4f, 180f ), Rotation.FromPitch( 45 ) );
|
||||||
|
camera.FieldOfViewValue = 120f;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
Players.Select( ( player, i ) => (Player: player, Index: i) ).ToList().ForEach( pair =>
|
Players.Select( ( player, i ) => (Player: player, Index: i) ).ToList().ForEach( pair =>
|
||||||
@@ -41,7 +44,6 @@ public class TerryRaces : Minigame
|
|||||||
|
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Cleanup()
|
public override void Cleanup()
|
||||||
|
|||||||
Reference in New Issue
Block a user