Class Event<C extends Context>
java.lang.Object
modelarium.entities.attributes.AttributeBase<C>
modelarium.entities.attributes.events.Event<C>
- Type Parameters:
C- the type of context this event is given
- All Implemented Interfaces:
Attribute
- Direct Known Subclasses:
AgentEvent,EnvironmentEvent
public abstract sealed class Event<C extends Context>
extends AttributeBase<C>
permits AgentEvent, EnvironmentEvent
Abstract class for representing an attribute whose behaviour only runs when a trigger condition is met.
Each tick, an event's trigger condition is checked, its behaviour is run if the condition holds, and (if the
event is logged) the trigger state is recorded. This class is extended by AgentEvent and
EnvironmentEvent.
-
Method Summary
Modifier and TypeMethodDescriptionCreates and returns an immutable version of this attribute.booleanReturns whether this event's trigger condition is currently met.protected abstract booleanisTriggered(C context) Determines whether this event's trigger condition is met.voidrun()Runs this event's behaviour for the current tick.protected abstract voidRuns this event's behaviour.toString()Returns the string representation of the event's triggered status.Methods inherited from class modelarium.entities.attributes.AttributeBase
accessLevel, context, isLogged, name
-
Method Details
-
toString
Returns the string representation of the event's triggered status. -
isTriggered
public boolean isTriggered()Returns whether this event's trigger condition is currently met.- Returns:
- true if the event is triggered, false otherwise
-
run
public void run()Runs this event's behaviour for the current tick. -
isTriggered
Determines whether this event's trigger condition is met. Must be implemented by subclasses.- Parameters:
context- the context the event can use in its trigger logic- Returns:
- true if the event is triggered, false otherwise
-
run
Runs this event's behaviour. Must be implemented by subclasses.- Parameters:
context- the context the event can use in its behaviour
-
getAsImmutable
Creates and returns an immutable version of this attribute.- Returns:
- the new
ReadOnlyEventinstance
-