Interface EventCondition
- All Known Subinterfaces:
EventCondition.Event<T>, EventCondition.Ticking, EventCondition.TrackedEvent<T>
- All Known Implementing Classes:
EnterInstanceTeleporterCondition, EnterPortalCondition, EventEndCondition, GameFlagLevelCondition, IntervalCondition, LocationCondition, NoCondition, ProximityCondition, SignalCondition, TimeCondition, WorldClosedCondition
true from test().
Choose a sub-interface based on how the condition should be driven:
EventCondition.Tickingfor conditions that poll state on a timer (e.g. proximity, timers).EventCondition.Eventfor conditions driven by a specificEcsEvent(e.g. event end).EventCondition.TrackedEventfor event-driven conditions that also filter by the entity'sTrackedComponent(e.g. "entity spawned by this event was killed").
All condition classes must have a corresponding EventCondition.Type constant registered via
WorldEventsPlugin.registerConditionType(), and a EventCondition.Config inner class that acts
as the asset-side factory.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAsset-side factory for anEventCondition.static interfaceEventCondition.Event<T extends EcsEvent>A condition driven by a specificEcsEventtype rather than polling.static interfaceA condition that is driven by a repeating tick rather than by events.static interfaceEventCondition.TrackedEvent<T extends EcsEvent>A condition driven by a specificEcsEventtype, additionally filtered by theTrackedComponentof the entity that triggered it.static final recordMetadata used to register a condition class with theConditionManager. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ArrayCodec<EventCondition> static final EventCondition[]static final CodecMapCodec<EventCondition> -
Method Summary
Modifier and TypeMethodDescriptiondefault voidmerge(EventCondition other) Copies runtime state fromotherinto this condition.default voidonCancel(WorldEvent event) Called if the condition belongs to a Fork that has been canceled due to a different Fork at the same Stage completing first.default booleanonComplete(WorldEvent event) Called after all conditions in the stage have returnedtruefromtest(), before the stage's actions are run.default booleanonStart(WorldEvent event) Called when the stage this condition belongs to begins, afterreset().voidreset()Resets the condition to its unsatisfied state before a new stage iteration begins.booleantest()Returnstruewhen this condition has been satisfied.
-
Field Details
-
TYPE_CODEC
-
ARRAY_CODEC
-
EMPTY_ARRAY
-
-
Method Details
-
test
boolean test()Returnstruewhen this condition has been satisfied.This method is called frequently and must be side-effect free. Update internal state in
EventCondition.Ticking.tick(float, Store)orEventCondition.Event.handle(World, T)instead.- Returns:
trueif the condition is met
-
reset
void reset()Resets the condition to its unsatisfied state before a new stage iteration begins.Called before
onStart(WorldEvent)at the start of a stage. All transient fields (timers, flags, cached context references) should be cleared here. -
onStart
Called when the stage this condition belongs to begins, afterreset().Implementations typically use this to look up values in the event context that the condition needs in order to operate (e.g. a location or a child event reference). If a required context value is absent, log a warning and return
falseto abort the stage immediately.- Parameters:
event- the world event whose stage is starting- Returns:
falseto abort the stage before it runs
-
onComplete
Called after all conditions in the stage have returnedtruefromtest(), before the stage's actions are run.This is the correct place to write results into the event context (e.g.
LocationConditionwrites the chosen location as aLocationContexthere). Returnfalseif the condition cannot produce a valid result, which will treat the stage as failed.- Parameters:
event- the world event whose stage just completed- Returns:
falseto treat the stage as failed
-
onCancel
Called if the condition belongs to a Fork that has been canceled due to a different Fork at the same Stage completing first.Implementations should use this to clean up any
Contextthat they added to theWorldEventinonStart(WorldEvent)that they would have removed inonComplete(WorldEvent)if the Fork were successful.- Parameters:
event- the world event whose fork just canceled
-
merge
Copies runtime state fromotherinto this condition.Called when a persisted condition is restored from storage. The (this) condition is built from its asset config, and the loaded state from the (other) condition is merged into it.
- Parameters:
other- the loaded condition to merge state from.
-