Class Events

All Implemented Interfaces:
DeepCopyable<Attributes>

public class Events extends Attributes
A concrete collection class for managing Event attributes.

Each event is uniquely named and stored internally. During each simulation tick, the run() method checks whether each event is triggered before executing its logic.

This class extends Attributes and uses the underlying storage and indexing mechanisms provided there.

  • Constructor Details

    • Events

      public Events()
  • Method Details

    • add

      public void add(Event event)
      Adds a single event to the collection.
      Parameters:
      event - the event to add
    • add

      public void add(List<Event> events)
      Adds a list of events to the collection.
      Parameters:
      events - a list of Event instances
    • get

      public Event get(String name)
      Retrieves an event by name.
      Parameters:
      name - the name of the event
      Returns:
      the matching Event, or null if not found
    • get

      public Event get(int index)
      Retrieves an event by index.
      Parameters:
      index - the index of the event
      Returns:
      the Event at the given index
    • run

      public void run()
      Executes all triggered events in the collection.

      Each event is first checked with isTriggered() before being run. This allows events to conditionally execute based on internal or external logic.

      Specified by:
      run in class Attributes
    • deepCopy

      public Events deepCopy()