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>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user