Files
Project-M/Assets/_Project/Scripts/Client/Input/AimPresentation.cs
T
2026-06-04 13:45:46 -07:00

31 lines
1.7 KiB
C#

namespace ProjectM.Client
{
/// <summary>
/// Static bridge from the client input gather (which owns active-device detection) to the presentation
/// layer (<see cref="AimReticleSystem"/>), mirroring the <c>PrototypeCameraRig</c> statics idiom. Holds
/// the last detected input scheme so the reticle system can switch the on-screen cursor (mouse
/// crosshair) vs the world reticle (gamepad) without re-deriving raw device state. Process-local and
/// presentation-only — never read by the simulation.
/// </summary>
public static class AimPresentation
{
/// <summary>Active scheme (<see cref="ProjectM.Simulation.InputSchemeId"/>): 0 = mouse/keyboard, 1 = gamepad.</summary>
public static byte Scheme;
/// <summary>When true, <see cref="AimReticleSystem"/> keeps the OS cursor VISIBLE even while aiming (the
/// editor-only DebugOverlay sets this so its IMGUI buttons stay clickable). Non-#if so the reticle system
/// can read it in any build; nothing sets it outside the editor.</summary>
public static bool ForceCursorVisible;
// Static fields can survive editor domain reloads (fast enter-play-mode); reset on every play-enter so a
// stale gamepad value from a prior session can't briefly hide the cursor / show the world reticle before
// the input gather republishes the real scheme.
[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.SubsystemRegistration)]
static void ResetOnEnterPlayMode()
{
Scheme = ProjectM.Simulation.InputSchemeId.KeyboardMouse;
ForceCursorVisible = false;
}
}
}