using System; using jeanf.EventSystem; using UnityEngine; namespace jeanf.universalplayer { /// /// The player's internal delegate surface. Package components raise and subscribe /// HERE — plain C# events: zero inspector wiring, compile-checked names, no /// per-frame ScriptableObject indirection. SO event channels exist only at the /// project boundary, piped in both directions by /// (the single place channel assets are referenced). /// /// House rule applies: subscribe and unsubscribe with NAMED methods only. /// (Control-scheme changes stay on , /// which already followed this pattern before the bridge existed.) /// public static class PlayerEvents { // ---- outbound: the package raises, the bridge forwards to project channels ---- public static event Action HmdStateChanged; public static event Action HmdConnectionChanged; public static event Action XrIssueReported; public static event Action PlayerMovingChanged; public static event Action SeatedChanged; public static event Action FallRecovered; public static event Action MapTogglePressed; public static event Action InventoryTogglePressed; // ---- bidirectional: raised internally AND by project channels ---- public static event Action CameraResetRequested; // ---- inbound: the bridge forwards project channel raises, internals react ---- public static event Action MouselookStateChanged; public static event Action MenuStateChanged; public static event Action SceneLoadingChanged; public static event Action PauseRequested; public static event Action PlayerTeleported; public static event Action ObjectTeleported; public static event Action SitRequested; // ---- internal: FadeMask reports when the world is black from loading / // teleporting (a menu-caused black is NOT included — menus need a cursor) ---- public static event Action ScreenFadeChanged; // ---- internal: something rejected a click/interaction ("you can't do that // here"). CursorStateController flashes the reticle its invalid color. ---- public static event Action InvalidActionSignaled; // ---- internal: locomotion moments raised by PlayerMovement (desktop modes — // XR has no jump and XRI owns its locomotion). FootstepAudio plays foley off // these; animation/VFX/project code can subscribe too. Not bridged to SO // channels yet — ask for a PlayerChannelsSO slot if a project needs one. ---- public static event Action PlayerJumped; /// Feet regained the ground; the payload is the downward impact speed in m/s (positive). public static event Action PlayerLanded; /// Crossed the crouch midpoint: true = now crouched, false = stood back up. public static event Action CrouchStateChanged; /// True while sit/stand player input should be ignored (iPad drawn, world UI, …). /// Projects forward primaryItemState into this. Scenario sit/stand is unaffected. public static event Action SitInputSuppressedChanged; /// False while a cinematic lock forbids player-initiated standing (Jump / VR stick / move). /// Default is unlocked (true). Scenario sit/stand is unaffected. public static event Action AllowPlayerExitChanged; public static void RaiseHmdState(bool mounted) => HmdStateChanged?.Invoke(mounted); public static void RaiseHmdConnection(bool connected) => HmdConnectionChanged?.Invoke(connected); public static void RaiseXrIssue(string message) => XrIssueReported?.Invoke(message); public static void RaisePlayerMoving(bool moving) => PlayerMovingChanged?.Invoke(moving); public static void RaiseSeated(bool seated) => SeatedChanged?.Invoke(seated); public static void RaiseFallRecovered(string message) => FallRecovered?.Invoke(message); public static void RaiseMapToggle() => MapTogglePressed?.Invoke(); public static void RaiseInventoryToggle() => InventoryTogglePressed?.Invoke(); public static void RaiseCameraReset() => CameraResetRequested?.Invoke(); public static void RaiseMouselookState(bool canLook) => MouselookStateChanged?.Invoke(canLook); public static void RaiseMenuState(bool menuOpen) => MenuStateChanged?.Invoke(menuOpen); public static void RaiseSceneLoading(bool loading) => SceneLoadingChanged?.Invoke(loading); public static void RaisePause(bool paused) => PauseRequested?.Invoke(paused); public static void RaisePlayerTeleported(TeleportInformation info) => PlayerTeleported?.Invoke(info); public static void RaiseObjectTeleported(TeleportInformation info) => ObjectTeleported?.Invoke(info); public static void RaiseScreenFade(bool faded) => ScreenFadeChanged?.Invoke(faded); public static void RaiseSitRequest(GameObject seatObject) => SitRequested?.Invoke(seatObject); /// Flash the cursor's "invalid request" color — call when a click/interaction is rejected. public static void RaiseInvalidAction() => InvalidActionSignaled?.Invoke(); public static void RaisePlayerJumped() => PlayerJumped?.Invoke(); public static void RaisePlayerLanded(float impactSpeed) => PlayerLanded?.Invoke(impactSpeed); public static void RaiseCrouchState(bool crouched) => CrouchStateChanged?.Invoke(crouched); public static void RaiseSitInputSuppressed(bool suppressed) => SitInputSuppressedChanged?.Invoke(suppressed); public static void RaiseAllowPlayerExit(bool allow) => AllowPlayerExitChanged?.Invoke(allow); } }