Skip to content
Bit Quirky Behavior Trees and
State Machines

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or enter a complete API identifier.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v0.6.0
Menu

BitQuirky.Behavior.Authority

Public behavior trees and state machines: runtime symbols in BitQuirky.Behavior.Authority.

Source snapshot ad0983d00d77.

Assembly: BitQuirky.Behavior.Runtime

Category: Low-level runtime

C#
readonly struct BitQuirky.Behavior.Authority.AuthorityContext

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:129-297

Implements: IEquatable<AuthorityContext>

Per-instance execution role. Built once at boot and passed to the tick job; cheap value type so it can travel through Burst code paths without managed indirection.

Responsibilities:

  • Carry the executing role for the running instance.
  • Decide whether a node may tick given its declared AuthorityKind, per data-model.md section Authority Context.
  • Provide a single Evaluateentry the runtime tick job calls for (“Runtime refuses to tick a node in a mismatching context”).

Does NOT:

  • Hold mutable state - once constructed, the context is immutable.
  • Allocate managed memory (Burst-compatible).
  • Decide blackboard ownership - that lives in BakedAuthorityEntryand the validator.

C#
public bool AlsoActsAsHost { get; }

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:169

Editor / test contexts can elect to act as host for the purposes of host-authoritative ticking. A non-host client never gets this.

C#
public bool InEditor { get; }

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:177

True when running in the Unity Editor process (editor play-mode or edit-mode). Required for ticking EditorTestOnlynodes - shipping builds set this to false and refuse those nodes .

C#
public BitQuirky.Behavior.Authority.ExecutingRole Role { get; }

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:163

Role this instance executes as. Fixed when the context is constructed and never changes.

AuthorityContext(ExecutingRole role, bool alsoActsAsHost, bool inEditor)

Section titled “AuthorityContext(ExecutingRole role, bool alsoActsAsHost, bool inEditor)”
C#
public AuthorityContext(BitQuirky.Behavior.Authority.ExecutingRole role, bool alsoActsAsHost = false, bool inEditor = false)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:150-157

Build a context.alsoActsAsHostlets EditorTesttick host-authoritative

  • client-presentation nodes the way a host editor would (this matches macro-test runs that drive the live simulation in a single editor process).

C#
public bool CanTick(BitQuirky.Behavior.Authority.AuthorityKind nodeAuthority)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:235-236

Convenience: true whenEvaluatewould return Allowed.

CanTick(BakedAuthorityContext bakedAuthority)

Section titled “CanTick(BakedAuthorityContext bakedAuthority)”
C#
public bool CanTick(BitQuirky.Behavior.Baked.BakedAuthorityContext bakedAuthority)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:250-251

Convenience overload that accepts the baked authority code, so a caller can pass BakedNode.Authoritystraight in; true when such a node may tick here.

C#
public static BitQuirky.Behavior.Authority.AuthorityContext Client(bool inEditor = false)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:188-189

Standard non-host client context: ticks client-presentation only.

C#
public static BitQuirky.Behavior.Authority.AuthorityContext EditorTest()

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:196-197

Editor / macro-test context. Acts as host so it can drive the full simulation locally and additionally permits EditorTestOnlynodes.

C#
public bool Equals(BitQuirky.Behavior.Authority.AuthorityContext other)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:257

Two contexts are equal when they carry the same role and the same host and editor flags.

C#
public override bool Equals(object obj)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:262

Equal only to anotherAuthorityContextwith the same role and flags.

C#
public BitQuirky.Behavior.Authority.AuthorityGateOutcome Evaluate(BitQuirky.Behavior.Authority.AuthorityKind nodeAuthority)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:203-229

Pure decision: may a node with the given declared authority tick in this context? Burst-callable.

Evaluate(BakedAuthorityContext bakedAuthority)

Section titled “Evaluate(BakedAuthorityContext bakedAuthority)”
C#
public BitQuirky.Behavior.Authority.AuthorityGateOutcome Evaluate(BitQuirky.Behavior.Baked.BakedAuthorityContext bakedAuthority)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:243-244

Convenience overload that accepts the baked authority code, so the tick job can passBakedNode.Authoritystraight in without translating.

C#
public static BitQuirky.Behavior.Authority.AuthorityKind FromBaked(BitQuirky.Behavior.Baked.BakedAuthorityContext baked)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:289

Map the baked numeric authority code back to the logical kind. Stable byte values across the three enums are deliberate so this is just a cast.

C#
public override int GetHashCode()

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:265

Hash over the role and flag bits, so equal contexts hash alike.

C#
public static BitQuirky.Behavior.Authority.AuthorityContext Host(bool inEditor = false)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:182-183

Standard host context: ticks host-authoritative + client-presentation.

C#
public static BitQuirky.Behavior.Baked.BakedAuthorityContext ToBaked(BitQuirky.Behavior.Authority.AuthorityKind kind)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:294

Inverse ofFromBaked.

C#
public override string ToString()

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:277-278

Returns a diagnostic string naming the role and both flags; intended for logs, not for parsing.

op_Equality(AuthorityContext a, AuthorityContext b)

Section titled “op_Equality(AuthorityContext a, AuthorityContext b)”
C#
public static bool operator ==(BitQuirky.Behavior.Authority.AuthorityContext a, BitQuirky.Behavior.Authority.AuthorityContext b)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:268

True when both contexts carry the same role and flags.

op_Inequality(AuthorityContext a, AuthorityContext b)

Section titled “op_Inequality(AuthorityContext a, AuthorityContext b)”
C#
public static bool operator !=(BitQuirky.Behavior.Authority.AuthorityContext a, BitQuirky.Behavior.Authority.AuthorityContext b)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:271

True when the contexts differ in role or in either flag.

Category: Low-level runtime

C#
enum BitQuirky.Behavior.Authority.AuthorityGateOutcome

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:87-107

Underlying type: byte

Outcome reported by the runtime gate.

C#
Allowed = 0

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:92

The node may tick on this instance.

C#
AuthorityMismatch = 1

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:99

The node’s authority does not match the executing context. The node MUST reportauthority-mismatchand decline to tick (section Tick contract).

C#
UndeclaredAuthority = 2

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:106

The node’s authority isUnknown; the runtime cannot decide. Bake-time validation should have rejected this - the gate refuses to tick to surface the regression.

Category: Low-level runtime

C#
class BitQuirky.Behavior.Authority.AuthorityHandoffHandler

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:123-424

Coordinates host-migration handoff for one or more followers. Invoked by the host loop the moment authority changes (FishNet migration, lobby host swap, etc.) and BEFORE the next tick step.

Responsibilities:

  • For every follower whose authority changed: enumerate every registeredIExternalServiceAdapterand call OnAuthorityHandoff. The default adapter response is Cancel; adapters that support replay returnResume.
  • Apply the node author’s AuthorityHandoffResolutionto the follower’s runtime instance: Restart (default) cancels pending externals on the instance; Resume keeps them and lets adapter replay re-issue; Abort cancels pending externals AND stamps a typed AuthorityHandofffailure.
  • Record a structuredAuthorityHandoffReportper follower so diagnostics surfaces (e.g.follower.behavior-report) can show what happened.

Does NOT:

  • Reach into adapter internals: the contract is the IExternalServiceAdapterinterface only.
  • Mutate consumer gameplay data directly: pending external cancellation flows through the completion ring.
  • Log viaLog / LogTrace; reports surface through command surfaces.

C#
public System.Collections.Generic.IReadOnlyList<BitQuirky.Behavior.ExternalService.IExternalServiceAdapter> Adapters { get; }

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:161

Adapters this handler consults on every handoff, in registration order. Fixed at construction.

AuthorityHandoffHandler(IEnumerable<IExternalServiceAdapter> adapters)

Section titled “AuthorityHandoffHandler(IEnumerable<IExternalServiceAdapter> adapters)”
C#
public AuthorityHandoffHandler(System.Collections.Generic.IEnumerable<BitQuirky.Behavior.ExternalService.IExternalServiceAdapter> adapters)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:138-155

Copies the registered adapter set the handler notifies on migration.

Exceptions

  • ArgumentNullException: adapters is null.
  • ArgumentException: adapters contains a null adapter.

ResolveBatch(IReadOnlyList<FollowerHandoffRequest> requests, int frameNumber, ExternalServiceCompletionRing completionRing, BehaviorRuntimeInstance[] instances, List<AuthorityHandoffReport> reports)

Section titled “ResolveBatch(IReadOnlyList<FollowerHandoffRequest> requests, int frameNumber, ExternalServiceCompletionRing completionRing, BehaviorRuntimeInstance[] instances, List<AuthorityHandoffReport> reports)”
C#
public void ResolveBatch(System.Collections.Generic.IReadOnlyList<BitQuirky.Behavior.Authority.FollowerHandoffRequest> requests, int frameNumber, BitQuirky.Behavior.ExternalService.ExternalServiceCompletionRing completionRing, BitQuirky.Behavior.Execution.BehaviorRuntimeInstance[] instances, System.Collections.Generic.List<BitQuirky.Behavior.Authority.AuthorityHandoffReport> reports)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:301-331

Resolve a handoff for a batch of followers. Each follower gets its own report; the order matches the input order.

ResolveForFollower(EntityId entityId, int frameNumber, ExternalServiceCompletionRing completionRing, AuthorityHandoffResolution resolution, ref BehaviorRuntimeInstance instance)

Section titled “ResolveForFollower(EntityId entityId, int frameNumber, ExternalServiceCompletionRing completionRing, AuthorityHandoffResolution resolution, ref BehaviorRuntimeInstance instance)”
C#
public BitQuirky.Behavior.Authority.AuthorityHandoffReport ResolveForFollower(UnityEngine.EntityId entityId, int frameNumber, BitQuirky.Behavior.ExternalService.ExternalServiceCompletionRing completionRing, BitQuirky.Behavior.Nodes.AuthorityHandoffResolution resolution, ref BitQuirky.Behavior.Execution.BehaviorRuntimeInstance instance)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:175-189

Resolve a handoff for one follower. Mutates instancein place per the node author’s resolution.

The active node’s resolution (resolution) is read by the runtime instance from the active baked node’s authoring metadata; the handler accepts it as a parameter so it can be unit-tested without round-tripping through the bake.

ResolveForFollower(EntityId entityId, int frameNumber, ExternalServiceCompletionRing completionRing, AuthorityHandoffResolution resolution, ref BehaviorRuntimeInstance instance, NativeArray<BehaviorActionRuntimeState> actionStates)

Section titled “ResolveForFollower(EntityId entityId, int frameNumber, ExternalServiceCompletionRing completionRing, AuthorityHandoffResolution resolution, ref BehaviorRuntimeInstance instance, NativeArray<BehaviorActionRuntimeState> actionStates)”
C#
public BitQuirky.Behavior.Authority.AuthorityHandoffReport ResolveForFollower(UnityEngine.EntityId entityId, int frameNumber, BitQuirky.Behavior.ExternalService.ExternalServiceCompletionRing completionRing, BitQuirky.Behavior.Nodes.AuthorityHandoffResolution resolution, ref BitQuirky.Behavior.Execution.BehaviorRuntimeInstance instance, Unity.Collections.NativeArray<BitQuirky.Behavior.Execution.BehaviorActionRuntimeState> actionStates)

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:196-295

Resolves a handoff while also reconciling the additive per-action progress table. Running action rows are retained only for an accepted Resume; every other outcome marks them interrupted exactly once before the list either restarts or reports failure.

Category: Low-level runtime

C#
enum BitQuirky.Behavior.Authority.AuthorityHandoffOutcome

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:40-70

Underlying type: byte

Outcome of a handoff resolution for one follower. Surfaces back to the runtime instance as a typed AuthorityHandofffailure when the node author’s resolution isAbort, or asNoneafter a successful restart / resume.

C#
Aborted = 3

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:69

Node author elected Abort. The node drops to a typedAuthorityHandoff failure on the next tick.

C#
NoPending = 0

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:46

No outstanding pending externals: the follower’s active node keeps ticking under the new authority unchanged.

C#
Restarted = 1

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:53

Pending externals were cancelled (default) and the active node will restart on the next tick. Adapters posted CancelledByHandoffrecords.

C#
Resumed = 2

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:61

Adapters supporting replay re-issued every outstanding pending id; the node resumes seamlessly. Bake validation guarantees this is reachable only when every awaited adapter SupportsReplay.

Category: Low-level runtime

C#
struct BitQuirky.Behavior.Authority.AuthorityHandoffReport

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:78-89

One row of handoff diagnostics: what happened to a follower’s pending externals during the handoff. Surfaced via follower.behavior-reportso the operator can see why a node restarted / aborted.

C#
public UnityEngine.EntityId EntityId

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:81

Follower this row describes.

C#
public BitQuirky.Behavior.Authority.AuthorityHandoffOutcome Outcome

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:83

What the handoff did to the follower’s in-flight work.

C#
public int PendingExternalsResolved

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:88

How many of the follower’s pending external operations the handoff dealt with, whether they were cancelled, replayed, or aborted.

Category: Low-level runtime

C#
enum BitQuirky.Behavior.Authority.AuthorityKind

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:35-48

Underlying type: byte

Authority context declared on a behavior node. Numeric values are stable across bakes and are kept in lock-step with BakedAuthorityContextand the authoring-layer BehaviorSourceAuthorityenum so a single byte round-trips between parse, bake, native artifact, and runtime gate without re-mapping.

C#
ClientPresentation = 2

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:44

A client instance may tick the node, for presentation only.

C#
EditorTestOnly = 3

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:47

Only an editor test may tick the node, never a shipped session.

C#
HostAuthoritative = 1

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:41

Only the authoritative host instance may tick the node.

C#
Unknown = 0

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:38

No authority was declared; the gate refuses to tick the node.

Category: Low-level runtime

C#
enum BitQuirky.Behavior.Authority.ExecutingRole

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:54-82

Underlying type: byte

Role of the executing instance. The runtime authority gate compares this against a node’s declaredAuthorityKind.

C#
Client = 2

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:70

Non-host client (e.g. a remote peer). May tick ClientPresentationnodes only.

C#
EditorTest = 3

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:81

Editor play-mode + macro-test runs. May tick EditorTestOnlynodes (and is the ONLY role allowed to do so; player / headless / shipping builds refuse). Treated as host-equivalent for HostAuthoritative/ ClientPresentationnodes when AlsoActsAsHostis set.

C#
Host = 1

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:64

Authoritative simulation. The host is also a client (it renders the same view), but only the host instance ticks HostAuthoritativenodes.

C#
Unknown = 0

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:57

The executing role was never set; the gate refuses every authority-bearing node.

Category: Low-level runtime

C#
struct BitQuirky.Behavior.Authority.FollowerHandoffRequest

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:433-442

One follower’s handoff request: which follower, and the active node’s declared resolution (read from the baked node’s authoring metadata by the host loop).

C#
public UnityEngine.EntityId EntityId

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:436

Follower whose authority changed.

C#
public BitQuirky.Behavior.Nodes.AuthorityHandoffResolution Resolution

Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:441

Resolution declared by the follower’s active node, which decides whether its pending external work restarts, resumes, or aborts.

Source fingerprint: sha256:ad0983d00d773d882bc61865e18d8c5559e009d181e5891575cd7f262515b23e

Full-size image