Class EntityLocation

All Implemented Interfaces:

public final class EntityLocation
extends java.lang.Object
The location of an entity inside a GameContext.

Every entity has an EntityLocation that starts as UNASSIGNED. The creator of the Entity object should add it to an EntityZone, which sets that entity's Entity.entityLocation.

A location has a Player, Zones and Integer index tuple that are comparable and exclusive--only one entity can be in a given location at a given time. These locations are used to find entities like GameContext.tryFind(EntityReference), to support effects like AdjacentEffectSpell, and to support networking effects and diffing for game state.

See Also:
to look up an entity's current location., to get the entity's index in an entity zone., for the that sets this property on an whenever it is the argument to an or ., for the method to use to move an entity from one entity to another when you already know which zone the entity is in., for the method that moves an entity from its current zone to the newly specified zone., to get the index of the an entity in O(1) time (it just uses its } method to find the index quickly)., for the method that gets the from a player object., for a method that iterates through all the entities in all the zones in a , for a method that iterates through all the entities in all the zones for a (a stores all the data/model that is needed to reconstruct a ., Serialized Form
  • Field Summary

    Modifier and Type Field Description
    static EntityLocation UNASSIGNED
    An unassigned location.
  • Constructor Summary

    Constructor Description
    EntityLocation​(Zones zone, int player, int index)
    Create the location with the specified zone, player and index.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object other)  
    int getIndex()
    Gets the index in the EntityZone for this location.
    int getPlayer()
    Gets the index of the player for this location, or Entity.NO_OWNER if it has not yet been assigned.
    Zones getZone()
    Gets the zone of this location.
    int hashCode()  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait