Class gameEvent

java.lang.Object
name.moore.kevin.ze.game.events.gameEvent
All Implemented Interfaces:
Serializable

public class gameEvent extends Object implements Serializable
A gameEvent is used to broadcast that something of note has happened in the in-game world such as a ship arriving at a planet.

The event is broadcast onto the global eventbus, others who subscribe to that bus can then listen for and act upon these events. A simple way to find who is interested in a specific message is to use 'find usages' of the enum REASON

Examples

  • initiate construction of a new industrial on a planet:
    zapp.getGameBus().post(new gameEvent(industrySpec2, new Date(), gameEvent.REASON.CONSTRUCT, planet0));
  • instruct a ship to travel towards a planet:
    zapp.getGameBus().post(new gameEvent(ship1, new Date(), gameEvent.REASON.DEPART, planet2));
Events that concern application control such as menus and screens are handled by the windowEvent class.
Author:
Kevin Moore <dev@kevin.moore.name>
See Also:
EventBus, Serialized Form
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
      Constant Field Values
    • primary

      private Long primary
      The EntityId of the thing primarily generating the event. Longs because EntityId isn't serialisable :( so use the underlying Long
    • secondary

      private Long secondary
      Optional secondary involved entity.
    • when

      LocalDate when
      Use a Date object to record when the event happened in the game (not in real world).

      Using a standard Date library rather than our homegrown starDate increases portability.

    • r

      private final gameEvent.REASON r
      The REASON enum for this event.
  • Constructor Details

    • gameEvent

      public gameEvent(com.simsilica.es.EntityId primary, LocalDate d, gameEvent.REASON r)
      Parameters:
      primary -
      d -
      r -
    • gameEvent

      public gameEvent(com.simsilica.es.EntityId primary, LocalDate d, gameEvent.REASON r, com.simsilica.es.EntityId secondary)
      Constructor with EventIds.
      Parameters:
      primary -
      d -
      r -
      secondary -
  • Method Details

    • getWhen

      public LocalDate getWhen()
      Returns:
      cant be null since the constructor insists it is set.
    • getReason

      public gameEvent.REASON getReason()
      Returns:
    • getPrimary

      public com.simsilica.es.EntityId getPrimary()
      Returns:
    • getSecondary

      public com.simsilica.es.EntityId getSecondary()
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns: