RaptorLogicLocalHost
RAPTOR's built-in Logic host for one player on one machine, in Play and in a built player.
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.Logic | Raptor.Logic.Runtime | class | preview, since 0.1.0 |
Starts after the first scene loads, unless another host has claimed Logic with RaptorLogicHosts.Claim. It stops if another host claims Logic later. It finds every logic object in the loaded scenes, fires their "Level starts" events and steps their graphs on the fixed time step.
Only the static members below are supported API.
public sealed class RaptorLogicLocalHost : MonoBehaviourProperties
ReadsUseKey
public static bool ReadsUseKey { get; set; }When true (the default), the host reads the use key, which is E, or the gamepad west button when the Input System package is installed. Set it to false if your own input calls Press and Release.
The host reads it every frame. It resets to true at the start of every Play session.
ShowUsePrompt
public static bool ShowUsePrompt { get; set; }When true (the default), the host shows the use prompt while the player looks at a button or switch they can use. The prompt is the use key and the Usable's Prompt text, such as "E Use". Set it to false if your HUD shows its own prompt.
The host reads it every frame. It resets to true at the start of every Play session.
Methods
DamageObject
public static bool DamageObject(GameObject target, float amount)Deals amount HP of damage to target, a logic object with Health or any child of one. The damage counts as the player's, so "Hurt by: Players" accepts it and "Object damaged" reports the player. Does nothing while no local host runs.
| Parameter | Type | Description |
|---|---|---|
target | GameObject | The logic object hit, or any child of it. |
amount | float | Damage in HP. |
Returns: True when a logic object with Health took the hit.
Press
public static bool Press()Call when your use button goes down. Uses the button or switch the player is looking at, like the use key. A Usable with "Hold for" is used once the button has been held that long. Call Release when the button comes up. Does nothing while no local host runs.
Returns: True when something was used immediately. False when nothing was used or a hold started.
Release
public static void Release()Call when your use button comes up. Ends a "Hold for" press.
Events
ObjectDestroyed
public static event Action<GameObject> ObjectDestroyed;Raised each time a logic object with Health loses its last HP. The object's "Object destroyed" event runs on the next Logic tick. This event does not remove the GameObject. The object's "Destroyed at 0" setting decides what happens to it. Use it to add a break effect, score or sound.
Raised on the main thread. Subscribers are cleared at the start of every Play session, so subscribe from OnEnable or Start.
Related types
- RaptorLogicHosts: Decides which host runs Logic in a Play session.