Files
Project-M/Assets/_Project/Scripts/Client/Presentation/CameraResolver.cs
T
kronic 55e98a9275 Hygiene B4b: extract CameraResolver (dedup triplicated ResolveCamera)
The byte-identical ResolveCamera() (Camera.main -> PrototypeCameraRig fallback) in PlayerInputGatherSystem, BuildSendSystem, and AimReticleSystem now call one CameraResolver.Resolve(); camera-resolution policy lives in one place. Behaviour-identical; compiles clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 13:07:40 -07:00

22 lines
810 B
C#

namespace ProjectM.Client
{
/// <summary>
/// Resolves the gameplay camera for the client systems that cursor-raycast against the ground (input aim,
/// build placement, aim reticle): <see cref="UnityEngine.Camera.main"/>, falling back to the
/// <see cref="PrototypeCameraRig"/>'s Camera. Single source so the camera-resolution policy lives in one place.
/// </summary>
public static class CameraResolver
{
public static UnityEngine.Camera Resolve()
{
var cam = UnityEngine.Camera.main;
if (cam == null)
{
var rig = UnityEngine.Object.FindAnyObjectByType<PrototypeCameraRig>();
if (rig != null) cam = rig.GetComponent<UnityEngine.Camera>();
}
return cam;
}
}
}