Comp<T extends App<T>> class
- Inheritance
-
- Mixed-in types
-
- Self<Comp<T>>
- HasSceneAccess<T>
- HasEntityAccess<T>
- HasVars<T, Comp<T>>
- IsActivatable<T, Comp<T>>
- IsAddable<T, Comp<T>>
- IsClonable<T, Comp<T>, Cloner<T>>
- IsDisposable<T, Comp<T>>
- IsDrawable<T, Comp<T>>
- IsEventEmittable<T, Comp<T>>
- IsEventHistoryHolder<T, Comp<T>>
- IsInputHandleable<Comp<T>>
- IsRemovable<T, Comp<T>>
- IsUpdatable<T, Comp<T>>
- IsComponentManagable<T, Comp<T>>
- IsStateHolder<T, Comp<T>, AnyCompSnapshot<T>>
- IsPersistable<T, Comp<T>, AnyCompSnapshot<T>>
- Implementers
Constructors
-
Comp(T app, {bool populateDefaults = true})
-
Methods
-
addComp<C extends Comp<T>>(C component)
→ Comp<T>
-
Adds
component as a new top-level component.
inherited
-
addCompIfNotExists<C extends Comp<T>>(C component)
→ Comp<T>
-
Adds
component only if no top-level component of type C already exists.
inherited
-
bookmarkState(String name)
→ AnyCompSnapshot<T>
-
inherited
-
callback(void callback())
→ void
-
inherited
-
captureSnapshot()
→ AnyCompSnapshot<T>
-
override
-
captureSnapshotAs<X extends S>()
→ X
-
inherited
-
clearEventHistory()
→ void
-
Clears history of recorded events.
inherited
-
clone<X extends E>([Cloner<T>? cloner])
→ X
-
Produces a clone of this object.
inherited
-
cloneInto<X extends E>(X target, [Cloner<T>? cloner])
→ X
-
inherited
-
containsComp<C extends Comp<T>>()
→ bool
-
Whether a component of type
C exists anywhere in this subtree.
inherited
-
countAllComps<C extends Comp<T>>()
→ int
-
Recursively counts every component of type
C in this subtree.
inherited
-
createClone(Comp<T> newInstance, [Cloner<T>? cloner])
→ Comp<T>
-
Override to customize how state is copied into
newInstance.
inherited
-
createInstance()
→ Comp<T>
-
Override to provide a fresh uninitialized instance of this type.
override
-
createSnapshot()
→ AnyCompSnapshot<T>
-
override
-
decVar<V extends num>(VarKey<V> key, [V? amount])
→ V
-
inherited
-
disableComp<C extends Comp<T>>()
→ Comp<T>
-
Deactivates every top-level component of type
C.
inherited
-
disableComps()
→ Comp<T>
-
Deactivates all top-level components (not nested).
inherited
-
disableEverything()
→ Comp<T>
-
Recursively deactivates every component, including nested ones.
inherited
-
dispatch(Event<T> event, {EventScope scope = .local})
→ void
-
Dispatches an
event immediately and synchronously, bypassing the central event queue.
inherited
-
emit(Event<T> event, {EventScope scope = .local})
→ void
-
Queues an
event into the central application event queue for asynchronous processing.
inherited
-
enableComp<C extends Comp<T>>()
→ Comp<T>
-
Activates every top-level component of type
C.
inherited
-
enableComps()
→ Comp<T>
-
Activates all top-level components.
inherited
-
enableEverything()
→ Comp<T>
-
Recursively activates every component, including nested ones.
inherited
-
findAllComps<C extends Comp<T>>()
→ Iterable<C>
-
Recursively finds every component of type
C in this subtree.
inherited
-
findAllCompsWith<C extends Comp<T>>()
→ Iterable<Comp<T>>
-
Recursively finds every component that itself contains a nested
component of type
C (i.e. returns the containing components, not
the matches themselves).
inherited
-
findComp<C extends Comp<T>>()
→ C?
-
Recursively finds the first component of type
C in this subtree.
inherited
-
findCompInChildren<C extends Comp<T>>()
→ C?
-
Finds the first direct child component of type
C (non-recursive).
inherited
-
findCompInParent<C extends Comp<T>>()
→ C?
-
Walks up the hierarchy and returns the nearest ancestor component of
type
C, if any.
inherited
-
findCompNearest<C extends Comp<T>>()
→ C?
-
Finds the closest component of type
C via breadth-first search.
inherited
-
findCompSiblings<C extends Comp<T>>()
→ Iterable<C>
-
Returns sibling components at the same level as this one.
inherited
-
findCompWhere<C extends Comp<T>>(bool predicate(C))
→ C?
-
Recursively finds the first component of type
C satisfying predicate.
inherited
-
forEachCompRecursive<C extends Comp<T>>(void callback(C))
→ void
-
Recursively invokes
callback on every component of type C in this subtree.
inherited
-
get<C extends Comp<T>>()
→ C?
-
Returns the first top-level component matching type
C, or null.
inherited
-
getAll<C extends Comp<T>>()
→ List<C>
-
Returns all top-level components matching type
C.
inherited
-
getAncestors()
→ Iterable<ECSBase<T>>
-
Returns every ancestor of this component, from immediate parent up to the root.
inherited
-
getClones()
→ Iterable<Comp<T>>
-
Returns all clones produced from this object.
inherited
-
getCompLeaves()
→ Iterable<Comp<T>>
-
Returns every leaf component in this subtree (components with no children).
inherited
-
getComponents()
→ Iterable<Comp<T>>
-
Returns the top-level components attached directly to this entity/component
(does not recurse into nested components).
inherited
-
getDepth()
→ int
-
Returns the depth/level in the hierarchy.
inherited
-
getEverything()
→ List<Comp<T>>
-
Recursively collects every component in this subtree, including nested ones.
inherited
-
getOrSetVar<V>(VarKey<V> key, V fallback)
→ V
-
inherited
-
getParentAs<P extends ECSBase<T>>()
→ P?
-
Returns parent cast to
P, or null if the cast would fail.
inherited
-
getPath()
→ List<ECSBase<T>>
-
Returns the path from the root down to this one, inclusive.
inherited
-
getPersistableData({bool force = false})
→ MapData
-
override
-
getRecordedEvents({double? duration, ECSBase<T>? origin, bool filter(Event<T> event)?})
→ List<Event<T>>
-
Events dispatched within the last
duration sim-scaled seconds,
optionally filtered to a specific origin.
inherited
-
getVar<V>(VarKey<V> key)
→ V?
-
inherited
-
getVarSafe<V>(VarKey<V> key, V fallback)
→ V
-
inherited
-
has<C extends Comp<T>>()
→ bool
-
Whether a top-level component of type
C exists.
inherited
-
has2<A extends Comp<T>, B extends Comp<T>>()
→ bool
-
Whether top-level components of BOTH type
A and type B exist.
inherited
-
has2ByType(Type a, Type b)
→ bool
-
Whether top-level components whose
runtimeType matches both a and b
exist.
inherited
-
has3<A extends Comp<T>, B extends Comp<T>, C extends Comp<T>>()
→ bool
-
Whether top-level components of types
A, B, and C all exist.
inherited
-
has3ByType(Type a, Type b, Type c)
→ bool
-
Whether top-level components whose
runtimeType matches a, b, and c
all exist.
inherited
-
hasAny<A extends Comp<T>, B extends Comp<T>>()
→ bool
-
Whether a top-level component of type
A OR type B exists.
inherited
-
hasByType(Type type)
→ bool
-
Whether a top-level component whose
runtimeType == type exists.
inherited
-
hasParentOf<P extends ECSBase<T>>()
→ bool
-
Whether parent is of type
P.
inherited
-
hasVar(VarKey key)
→ bool
-
inherited
-
incVar<V extends num>(VarKey<V> key, [V? amount])
→ V
-
inherited
-
isAncestorOf(Comp<T> other)
→ bool
-
-
isDescendantOf(Comp<T> other)
→ bool
-
-
listenHandleInput(void fn(Comp<T> self))
→ Comp<T>
-
Registers
fn to be called during the input handling phase.
inherited
-
listenOnActivate(void fn(Comp<T> self))
→ Comp<T>
-
Registers
fn to be called whenever the active state changes.
inherited
-
listenOnAdd(void fn(Comp<T> self, ECSBase<T> parent))
→ Comp<T>
-
Registers
fn as an add listener.
inherited
-
listenOnAfterAdd(void fn(Comp<T> self, ECSBase<T> parent))
→ Comp<T>
-
Registers
fn as an after-add listener.
inherited
-
listenOnAfterClone(void fn(Comp<T> copy, [Cloner<T>? cloner]))
→ Comp<T>
-
Registers
fn as an after-clone listener.
inherited
-
listenOnAfterCompAdd(void fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnAfterCompClone(void fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnAfterCompRemove(void fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnAfterRemove(void fn(Comp<T> self))
→ Comp<T>
-
Registers
fn as an after-remove listener.
inherited
-
listenOnBeforeAdd(bool fn(Comp<T> self, ECSBase<T> parent))
→ Comp<T>
-
Registers
fn as a before-add listener.
inherited
-
listenOnBeforeClone(bool fn(Comp<T> copy, [Cloner<T>? cloner]))
→ Comp<T>
-
Registers
fn as a before-clone listener.
inherited
-
listenOnBeforeCompAdd(bool fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnBeforeCompClone(bool fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnBeforeCompRemove(bool fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnBeforeEvent(bool fn(Comp<T> self, Event<T> event))
→ Comp<T>
-
Registers
fn as a before-event listener.
inherited
-
listenOnBeforeEventRecorded(bool fn(Comp<T> self, Event<T> event))
→ Comp<T>
-
Registers
fn as a before-event-record listener.
inherited
-
listenOnBeforeRemove(bool fn(Comp<T> other))
→ Comp<T>
-
Registers
fn as a before-remove listener.
inherited
-
listenOnBeforeStorePersistable(bool fn(Comp<T> other))
→ Comp<T>
-
Registers
fn as a before-persistence listener.
inherited
-
listenOnClone(void fn(Comp<T> copy, [Cloner<T>? cloner]))
→ Comp<T>
-
Registers
fn as a clone listener.
inherited
-
listenOnCompAdd(void fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnCompClone(void fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnCompRemove(void fn(Comp<T> self, Comp<T> component))
→ Comp<T>
-
inherited
-
listenOnDispose(void fn(Comp<T> self))
→ Comp<T>
-
Registers
fn to be called at the disposal of the owned ECS object.
inherited
-
listenOnDraw(void fn(Comp<T> self, double dt))
→ Comp<T>
-
Registers
fn to be called during the draw phase each frame.
inherited
-
listenOnEvent(void fn(Comp<T> self, Event<T> event))
→ Comp<T>
-
Registers
fn to be called for every incoming event.
inherited
-
listenOnEventRecorded(void fn(Comp<T> self, Event<T> event))
→ Comp<T>
-
Registers
fn to be called for every event recorded.
inherited
-
listenOnRemove(void fn(Comp<T> self))
→ Comp<T>
-
Registers
fn as a remove listener.
inherited
-
listenOnStorePersistable(MapData fn(Comp<T> self, MapData data))
→ Comp<T>
-
Registers
fn as an store persistable listener.
inherited
-
listenOnUpdate(void fn(Comp<T> self, double dt))
→ Comp<T>
-
Registers
fn to be called during the update phase each frame.
inherited
-
mergeCompsInto<X extends IsAnyComponentManagable<T>>(X into, {Cloner<T>? cloner, bool replaceComponents = true})
→ void
-
inherited
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
on<C extends Comp<T>>(void callback(C))
→ Comp<T>
-
Invokes
callback with the first top-level component matching type C,
if one exists.
inherited
-
on2<A extends Comp<T>, B extends Comp<T>>(void callback(A, B))
→ Comp<T>
-
Invokes
callback with the first top-level components matching types
A and B, if both exist.
inherited
-
on3<A extends Comp<T>, B extends Comp<T>, C extends Comp<T>>(void callback(A, B, C))
→ Comp<T>
-
Invokes
callback with the first top-level components matching types
A, B, and C, if all three exist.
inherited
-
onActivate()
→ void
-
Override to react when the active state changes.
inherited
-
onAdd(ECSBase<T> parent)
→ void
-
Override to react when the add is about to complete.
inherited
-
onAfterAdd(ECSBase<T> parent)
→ void
-
Override to react after the add has completed.
inherited
-
onAfterClone(Comp<T> copy, [Cloner<T>? cloner])
→ void
-
Override to react after cloning has completed.
inherited
-
onAfterCompAdd(Comp<T> component)
→ void
-
inherited
-
onAfterCompClone(Comp<T> copy)
→ void
-
inherited
-
onAfterCompRemove(Comp<T> component)
→ void
-
inherited
-
onAfterRemove()
→ void
-
Override to react after removal has completed.
inherited
-
onAll<C extends Comp<T>>(void callback(List<C> components))
→ Comp<T>
-
Invokes
callback with every top-level component matching type C.
inherited
-
onBeforeAdd(ECSBase<T> parent)
→ bool
-
Override to cancel the add from within the class.
inherited
-
onBeforeClone(Comp<T> copy, [Cloner<T>? cloner])
→ bool
-
Override to cancel cloning from within the class.
inherited
-
onBeforeCompAdd(Comp<T> component)
→ bool
-
inherited
-
onBeforeCompClone(Comp<T> copy)
→ bool
-
inherited
-
onBeforeCompRemove(Comp<T> component)
→ bool
-
inherited
-
onBeforeEvent(Event<T> event)
→ bool
-
Override to cancel an event handling from within the class.
inherited
-
onBeforeEventRecorded(Event<T> event)
→ bool
-
Override to cancel an event handling from within the class.
inherited
-
onBeforeRemove()
→ bool
-
Override to cancel removal from within the class.
inherited
-
onBeforeStorePersistable()
→ bool
-
Override to cancel the persistence from within the class.
inherited
-
onClone(Comp<T> copy, [Cloner<T>? cloner])
→ void
-
Override to react when cloning is about to complete.
inherited
-
onCloned(Comp<T> original)
→ void
-
Called on the copy after cloning completes, with a reference to
original.
inherited
-
onCompAdd(Comp<T> component)
→ void
-
inherited
-
onCompClone(Comp<T> copy)
→ void
-
inherited
-
onCompRemove(Comp<T> component)
→ void
-
inherited
-
onDispose()
→ void
-
Override to react at the disposal.
inherited
-
onDraw(double dt)
→ void
-
Override to react during the draw phase each frame.
inherited
-
onEvent(Event<T> event)
→ void
-
Override to handle incoming events within the class.
inherited
-
onEventRecorded(Event<T> event)
→ void
-
Override to handle incoming events within the class.
inherited
-
onInput()
→ void
-
Override to handle input within the class.
inherited
-
onRemove()
→ void
-
Override to react when removal is about to complete.
inherited
-
onRestorePersistableData(MapTraversable data, {String? id})
→ void
-
Override to react during the restoration of persistable data.
inherited
-
onSelf(void fn(Comp<T> self))
→ Comp<T>
-
Calls
fn with self and returns self, for fluent chaining.
inherited
-
onStorePersistable(MapData data)
→ MapData
-
Override to react when the persistence is about to complete.
inherited
-
onUpdate(double dt)
→ void
-
Override to react during the update phase each frame.
inherited
-
persistAutoLoad({int? slot})
→ void
-
inherited
-
persistAutoSave({required double interval, required int slots})
→ AnyCompSnapshot<T>?
-
inherited
-
removeComp<C extends Comp<T>>()
→ Comp<T>
-
Removes the first top-level component matching type
C.
inherited
-
removeCompByType(Type type)
→ Comp<T>
-
Removes the first top-level component whose
runtimeType == type.
inherited
-
removeCompExact(Comp<T> component)
→ Comp<T>
-
Removes the exact component.
inherited
-
removeCompNested<C extends Comp<T>>()
→ void
-
Recursively removes every component of type
C from this subtree.
inherited
-
removeComps<C extends Comp<T>>()
→ Comp<T>
-
Removes all top-level components matching type
C.
inherited
-
removeEverything()
→ Comp<T>
-
Removes every top-level component.
inherited
-
replaceComp(Comp<T> component)
→ Comp<T>
-
Replaces the first top-level component whose
runtimeType == component.runtimeType with component.
inherited
-
replayRecordedEvents({double? fromTime, ECSBase<T>? origin, bool filter(Event<T> event)?})
→ void
-
Re-dispatches events from
fromTime sim-scaled seconds ago to now.
inherited
-
restoreBookmarkedState(String name, {SnapshotMissingPolicy onMissing = .skip, })
→ void
-
inherited
-
restorePersistableData(MapTraversable data, {String? id})
→ void
-
override
-
restoreSnapshot(covariant AnyCompSnapshot<T> snapshot)
→ void
-
override
-
run(Task<T> task)
→ void
-
inherited
-
setActive(bool active)
→ Comp<T>
-
Sets the active state to
active and fires the activation hook.
inherited
-
setVar<V>(VarKey<V> key, V value)
→ Comp<T>
-
inherited
-
storePersistable()
→ MapData?
-
inherited
-
swapComp<A extends Comp<T>>(Comp<T> newC)
→ Comp<T>
-
Replaces the first top-level component of type
A with newC.
No-op if no component of type A exists.
inherited
-
swapComps<A extends Comp<T>>(Comp<T> newC)
→ Comp<T>
-
Removes all the top-level components of type
A and adds newC.
No-op if no component of type A exists.
inherited
-
task(Task<T> task)
→ void
-
inherited
-
toggleActive()
→ Comp<T>
-
Toggles the active state and fires the activation hook.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited
-
uniqKey(String key)
→ String
-
Returns a key namespaced to this object's namedId.
inherited
-
whenClone(Comp<T> fn(Comp<T> newInstance, [Cloner<T>? cloner]))
→ Comp<T>
-
Registers
fn as the clone factory, replacing the default clone behavior.
inherited
-
whenCloned(Comp<T> fn(Comp<T> self, Comp<T> copy))
→ Comp<T>
-
Registers
fn to run after the clone is produced.
inherited
-
whenCreateInstance(Comp<T> fn(Comp<T> component))
→ Comp<T>
-
Registers
fn as the instance factory used during cloning.
inherited