Class EntityLocation
java.lang.Object
net.demilich.metastone.game.entities.EntityLocation
- All Implemented Interfaces:
Serializable
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, Spellsource.ZonesMessage.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 java.util.List that sets this property on an Entity whenever it is the argument to an EntityZone#add(Object) or EntityZone#move(Entity, EntityZone).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 Entity#getIndex()} method to find the index quickly).for the method that gets the EntityZone from a player object.for a method that iterates through all the entities in all the zones in a GameContextfor a method that iterates through all the entities in all the zones for a GameState (a GameState stores all the data/model that is needed to reconstruct a GameContext.- Serialized Form
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEntityLocation(com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones zone, int player, int index) Create the location with the specified zone, player and index. -
Method Summary
Modifier and TypeMethodDescriptionbooleanintgetIndex()Gets the index in theEntityZonefor this location.intGets the index of the player for this location, orEntity.NO_OWNERif it has not yet been assigned.com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.ZonesgetZone()Gets the zone of this location.inthashCode()toString()
-
Field Details
-
UNASSIGNED
An unassigned location.
-
-
Constructor Details
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getZone
public com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones getZone()Gets the zone of this location.- Returns:
- The zone.
- See Also:
-
for a complete description of each zone.
-
getPlayer
public int getPlayer()Gets the index of the player for this location, orEntity.NO_OWNERif it has not yet been assigned. (With the exception ofUNASSIGNED, aplayerfields with a value ofEntity.NO_OWNERis an invalid location.- Returns:
- The player index, or
-1if it has not yet been assigned. - See Also:
-
getIndex
public int getIndex()Gets the index in theEntityZonefor this location.- Returns:
- The index.
- See Also:
-
toString
-