arcade2d
Interface

WorldDependencyResolver

world/dependencies.types.ts:55

Dependency resolver passed to WorldComponent.resolveDependencies. Exposes lookups against other components on the same World host; does not expose a requireFromWorld-style escape hatch because world components have no parent tier to reach into.

Lookups are type-based: pass a component constructor, get the matching instance back. The resolver throws an EngineError (with a descriptive message naming the requesting component and the missing type) when a required lookup can't be satisfied.

Properties

readonly #
host: World

The World the component is being added to. Exposed so components needing the host itself (rather than a sibling component) don't have to capture it from elsewhere.

Methods

#
optionalSibling(type: DependencyComponentConstructor<T>): null | T

Same as WorldDependencyResolver.requireSibling but returns null instead of throwing on miss or ambiguity. The two failure modes collapse to a single null — use WorldDependencyResolver.requireSibling if you need to distinguish them.

Parameters

Returns

null | T

The matching sibling instance, or null if not found or ambiguous.

#
requireSibling(type: DependencyComponentConstructor<T>): T

Resolves a sibling component on the same host by type. Throws ErrorCode.WORLD_COMPONENT_DEPENDENCY_MISSING if no sibling of the type exists, and ErrorCode.WORLD_COMPONENT_DEPENDENCY_AMBIGUOUS if more than one does.

Excludes the requesting component itself from the search — it doesn't count as its own sibling.

Parameters

Returns

T

The single matching sibling instance.

ESC