Components/Camera/PodiumCamera.cs

A camera behaviour used for the end-of-game podium. When the game mode is in the Podium state and a PodiumStage with a CameraTarget exists, it takes control and returns a static CameraPose at the target's world position, rotation, and a configurable field of view.

using Machines.GameModes;

namespace Machines.Components;

/// <summary>
/// Camera at the end of the game that moves to a fixed position for the podium
/// </summary>
public sealed class PodiumCamera : CameraBehaviour
{
	[Property, Group( "Framing" )]
	public float FieldOfView { get; set; } = 60f;

	public override int Priority => 100;

	public override bool WantsControl
	{
		get
		{
			var mode = BaseGameMode.Current;
			if ( !mode.IsValid() || mode.State != GameModeState.Podium )
				return false;

			var stage = PodiumStage.Current;
			return stage.IsValid() && stage.CameraTarget.IsValid();
		}
	}

	public override CameraPose Evaluate( CameraPose current )
	{
		var stage = PodiumStage.Current;
		if ( !stage.IsValid() || !stage.CameraTarget.IsValid() )
			return current;

		var target = stage.CameraTarget;
		return new CameraPose( target.WorldPosition, target.WorldRotation, FieldOfView );
	}
}