Class LocationCondition
- All Implemented Interfaces:
EventCondition, EventCondition.Ticking
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface EventCondition
EventCondition.Event<T>, EventCondition.Ticking, EventCondition.TrackedEvent<T>, EventCondition.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BuilderCodec<LocationCondition> static final Stringstatic final EventCondition.TypeFields inherited from interface EventCondition
ARRAY_CODEC, EMPTY_ARRAY, TYPE_CODEC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonCancel(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.booleanonComplete(WorldEvent event) Called after all conditions in the stage have returnedtruefromEventCondition.test(), before the stage's actions are run.booleanonStart(WorldEvent event) Called when the stage this condition belongs to begins, afterEventCondition.reset().voidreset()Resets the condition to its unsatisfied state before a new stage iteration begins.booleantest()Returnstruewhen this condition has been satisfied.voidtick(float dt, Store<EntityStore> store) Updates the condition's internal state.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EventCondition
merge
-
Field Details
-
ID
- See Also:
-
TYPE
-
CODEC
-
-
Constructor Details
-
LocationCondition
public LocationCondition()
-
-
Method Details
-
test
public boolean test()Description copied from interface:EventConditionReturnstruewhen 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.- Specified by:
testin interfaceEventCondition- Returns:
trueif the condition is met
-
reset
public void reset()Description copied from interface:EventConditionResets the condition to its unsatisfied state before a new stage iteration begins.Called before
EventCondition.onStart(WorldEvent)at the start of a stage. All transient fields (timers, flags, cached context references) should be cleared here.- Specified by:
resetin interfaceEventCondition
-
onCancel
Description copied from interface:EventConditionCalled 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 theWorldEventinEventCondition.onStart(WorldEvent)that they would have removed inEventCondition.onComplete(WorldEvent)if the Fork were successful.- Specified by:
onCancelin interfaceEventCondition- Parameters:
event- the world event whose fork just canceled
-
tick
Description copied from interface:EventCondition.TickingUpdates the condition's internal state.Set a flag or update a counter here; do not call
EventCondition.test()from within this method. The manager readsEventCondition.test()aftertickreturns.- Specified by:
tickin interfaceEventCondition.Ticking- Parameters:
dt- elapsed seconds since the last tick dispatch for this condition typestore- the entity store for the world the condition is running in
-
onStart
Description copied from interface:EventConditionCalled when the stage this condition belongs to begins, afterEventCondition.reset().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.- Specified by:
onStartin interfaceEventCondition- Parameters:
event- the world event whose stage is starting- Returns:
falseto abort the stage before it runs
-
onComplete
Description copied from interface:EventConditionCalled after all conditions in the stage have returnedtruefromEventCondition.test(), 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.- Specified by:
onCompletein interfaceEventCondition- Parameters:
event- the world event whose stage just completed- Returns:
falseto treat the stage as failed
-