class Rosegold::ManualControl

Overview

Transport-independent owner of gameplay input. While granted, a bounded snapshot stream from an outside controller drives the native physics and interaction paths and scripted gameplay writes are ignored. Revoking clears only the owner's input and completes the release on the next real PLAY tick.

Defined in:

rosegold/control/manual_control.cr

Constant Summary

MAX_LOOK_DELTA_DEGREES = 90.0_f32
MAX_TAPS = 4
RELEASE_WAIT = 1.second

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Rosegold::Client) #

[View source]

Instance Method Detail

def after_tick : Nil #

A release completes only after a whole tick that began after the revoke.


[View source]
def before_tick : Nil #

[View source]
def bind_host(host : Host) : Nil #

Binds host, first revoking any grant that belongs to a different host.


[View source]
def bound_host?(host : Host) : Bool #

[View source]
def clear(grant_id : UInt64) : Bool #

Discards pending frames and one-shots and neutralizes held input now, keeping the grant and its sequence.


[View source]
def client : Client #

[View source]
def debug_until_returned : Symbol #

Grants control and suspends only the calling fiber until the controller returns it. Raises Cancelled when the grant ends any other way.


[View source]
def enforce_physics : Nil #

Re-asserts the controller's movement state at the start of physics so keys a script obtained earlier cannot change it between interactions and physics.


[View source]
def grant : UInt64 | Nil #

Starts a grant and returns its id, or the live one if already granted. Never waits: returns nil while a previous grant's release tick is outstanding, when the bound host is disabled, or when a cleanup callback revoked the new grant before it returned.


[View source]
def grant_id : UInt64 | Nil #

Identity of the live grant; nil unless the controller currently owns input.


[View source]
def granted? : Bool #

[View source]
def host_available? : Bool #

[View source]
def host_enabled_or_unbound? : Bool #

[View source]
def ice_road? : Bool #

Whether native ticks hold forward, sprint and jump after a cardinal snap.


[View source]
def owns_input? : Bool #

Whether the controller owns gameplay input or is still being released.


[View source]
def releasing? : Bool #

[View source]
def reset(reason : Reason = Reason::SessionChanged) : Nil #

The single packet-free lifecycle transition for a world or connection change: no release tick can follow. Samples unresolved inventory before clearing, then ends the debug waiter and any takeover exactly once.


[View source]
def return_to_script(grant_id : UInt64) : Bool #

The controller's Return to script action.


[View source]
def revoke(reason : Reason = Reason::Revoked, only_grant : UInt64 | Nil = nil) : Bool #

Ends the grant. Held input is cleared at once; the release packets go out on the next real PLAY tick, and scripted writes stay gated until then. Returns false when nothing was granted or only_grant is stale.


[View source]
def script_authority(operation : String) : UInt64 | Nil #

Like #script_write_allowed?, but returns a token for a write that yields or queues before it reaches the wire; check it with #script_authority?.


[View source]
def script_authority?(authority : UInt64) : Bool #

Whether no grant or session reset happened since authority was taken and none owns input now.


[View source]
def script_write_allowed?(operation : String) : Bool #

Whether a scripted gameplay write may proceed. A grant blocks it. A pending release makes it wait up to RELEASE_WAIT for the release tick, except on the packet reader or ticker, which never wait. A grant or session reset during the wait refuses the write, even if the grant is released again.


[View source]
def submit(grant_id : UInt64, sequence : UInt64, input : Input, deadline : Time::Instant | Nil = nil) : Bool #

Queues input for the next tick. Rejects a stale grant or sequence. When deadline passes before the tick that would use the frame, the held input is neutralized instead.


[View source]
def unbind_host(host : Host) : Nil #

Detaches host; if it was the bound host, ends any grant as disabled.


[View source]
def unresolved_inventory? : Bool #

Whether the cursor holds a stack or the host reports unresolved inventory work.


[View source]