Class AbstractEntity
- java.lang.Object
-
- de.extio.spacecraft.shared.model.entity.AbstractEntity
-
- All Implemented Interfaces:
HasPosition2
,HasPositionAndDimension2
- Direct Known Subclasses:
AbstractEntityMod
,ActionItemEntity
,InfoEntity
,PhysicalEntity
,RestrictedEntity
public abstract class AbstractEntity extends Object implements HasPositionAndDimension2
AbstractEntity is the root of all entities. It only provides basic functionality, you may look into PhysicalEntity / StructureEntity for entities representing something physical or InfoEntity representing markers, game logic or scripts.
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.logging.log4j.Logger
LOGGER
protected Map<UUID,List<AbstractEntity>>
serverRestrictedEntities
protected RestrictedEntitySurface
serverRestrictedEntitySurfaceBo
-
Constructor Summary
Constructors Constructor Description AbstractEntity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
create(UUID uuid, AbstractEntityDef entityDef, int entityDefIdx, UUID parentCompositeEntity)
Central initialization of non-transient fields (usually on server side).protected DrawTileImageBo
createClientDrawTileImageBo()
Client side: Creates and sets up a DrawTileImageBo rendering business object to render this entity on a tileCoordI2
getDimension()
int
getEntityDef()
UUID
getEntityDefUUID()
EntityLayer
getEntityLayer()
EntityManager
getEntityManager()
Edge2
getOrientation()
UUID
getParentCompositeEntity()
CoordI2
getPosition()
Map<UUID,List<AbstractEntity>>
getServerRestrictedEntities()
int
getServerRestrictEntitiesLastUpdate()
int
getServerRestrictEntitiesWalls()
int
getTileset()
CoordI2
getTilesetPosition()
UUID
getUuid()
boolean
isDirty()
boolean
isLocalInit()
void
localCopy(AbstractEntity other)
Local copy of transient fieldsvoid
localInit(AbstractEntityDef entityDef)
Local initialization of transient fieldsboolean
onClientAction(ClientEntityAction clientAction, AbstractCompositeEntity targetCompositeEntity, AbstractEntity targetEntity)
Client side: Callback if the player selected an actionvoid
onClientActionMessage(GameActionMessage message)
Client side: Callback after a message has been received for this entityvoid
onClientDrawEntity(List<RenderingBo> renderingBo)
Client side: Draws this entityvoid
onClientFrame(boolean selected)
Client side: Callback on each frame for general logicString
onClientGenerateEntityDetails()
Client side: Returns details about this entity.void
onClientSelectedPointToEntity(AbstractCompositeEntity otherCompositeEntity, AbstractEntity other, int modifiers, List<ClientEntityAction> outClientActions)
Client side: Callback when this entity is selected and cursor is pointing to another entityvoid
onClientSelectedPointToNoClientEntityAction(int modifiers)
Client side: Callback when this entity is selected and onClientSelectedPointToEntity + onClientSelectedPointToWorldPos did not set any possible actionvoid
onClientSelectedPointToWorldPos(CoordI2 worldPos, List<CompositeAndEntityId> atPosition, int modifiers, List<ClientEntityAction> outClientActions)
Client side: Callback when this entity is selected and cursor is pointing to an empty tile in the game worldvoid
onServerActionMessage(GameActionMessage message, UUID sender, GameSession gameSession)
Server side: Callback after a message has been received for this entity.void
onServerTurnPass0(GameSession gameSession)
Server side: Executes code on every server turn, main pass 1 of 2.void
onServerTurnPass1(GameSession gameSession)
Server side: Executes code on every server turn, main pass 2 of 2.void
onServerTurnPass2PostComposites(GameSession gameSession)
Server side: Executes code on every server turn, postprocessing pass after composite entity pass 2.void
serverCleanupRestrictedEntities(AbstractCompositeEntity parent, GameSession gameSession)
Server side: Cleans up restricted entity surfaces.void
serverPrepareRestrictedEntities(UUID recipient, AbstractCompositeEntity parent, GameSession gameSession)
Server side: Prepares RestrictedEntity instances to be presented instead of this entity to a player.boolean
serverRestrictEntity(UUID recipient, AbstractCompositeEntity parent, GameSession gameSession)
Server side: Checks whether this entity should be restricted to the player recipient, i.e.void
serverTranslateEntityPass0(Edge2 rotation, CoordI2 posSrc, CoordI2 origDim, AbstractCompositeEntity parent, GameSession gameSession)
Server side: Parent composite entity is rotated, rotates this entityvoid
serverTranslateEntityPass1(Edge2 rotation, CoordI2 posSrc, CoordI2 origDim, AbstractCompositeEntity parent, GameSession gameSession)
Server side: Postprocesses rotation of the parent composite entity.void
setClientActions(List<ClientEntityAction> clientActions)
void
setDirty(boolean dirty)
void
setEntityDef(int entityDef)
void
setEntityManager(EntityManager entityManager)
void
setLocalInit(boolean localInit)
void
setOrientation(Edge2 orientation)
void
setParentCompositeEntity(UUID parentCompositeEntity)
void
setPosition(CoordI2 position)
Use this method for initial entity placement after EntityManager::create, but never update position after the initial EntityManager::put.void
setServerRestrictedEntities(Map<UUID,List<AbstractEntity>> serverRestrictedEntities)
void
setServerRestrictEntitiesLastUpdate(int serverRestrictedEntityLastUpdate)
void
setServerRestrictEntitiesWalls(int serverRestrictEntitiesWalls)
void
setUuid(UUID uuid)
void
update(AbstractEntity other)
Incremental update of non-transient fields (usually transferred from server)
-
-
-
Field Detail
-
LOGGER
protected static final org.apache.logging.log4j.Logger LOGGER
-
serverRestrictedEntities
protected transient Map<UUID,List<AbstractEntity>> serverRestrictedEntities
-
serverRestrictedEntitySurfaceBo
protected transient RestrictedEntitySurface serverRestrictedEntitySurfaceBo
-
-
Method Detail
-
create
public void create(UUID uuid, AbstractEntityDef entityDef, int entityDefIdx, UUID parentCompositeEntity)
Central initialization of non-transient fields (usually on server side). Is only called once in the whole life cycle of an entity.
-
localInit
public void localInit(AbstractEntityDef entityDef)
Local initialization of transient fields
-
localCopy
public void localCopy(AbstractEntity other)
Local copy of transient fields
-
update
public void update(AbstractEntity other)
Incremental update of non-transient fields (usually transferred from server)
-
onClientFrame
public void onClientFrame(boolean selected)
Client side: Callback on each frame for general logic
-
onClientDrawEntity
public void onClientDrawEntity(List<RenderingBo> renderingBo)
Client side: Draws this entity
-
onClientSelectedPointToEntity
public void onClientSelectedPointToEntity(AbstractCompositeEntity otherCompositeEntity, AbstractEntity other, int modifiers, List<ClientEntityAction> outClientActions)
Client side: Callback when this entity is selected and cursor is pointing to another entity
-
onClientSelectedPointToWorldPos
public void onClientSelectedPointToWorldPos(CoordI2 worldPos, List<CompositeAndEntityId> atPosition, int modifiers, List<ClientEntityAction> outClientActions)
Client side: Callback when this entity is selected and cursor is pointing to an empty tile in the game world
-
onClientSelectedPointToNoClientEntityAction
public void onClientSelectedPointToNoClientEntityAction(int modifiers)
Client side: Callback when this entity is selected and onClientSelectedPointToEntity + onClientSelectedPointToWorldPos did not set any possible action
-
onClientAction
public boolean onClientAction(ClientEntityAction clientAction, AbstractCompositeEntity targetCompositeEntity, AbstractEntity targetEntity)
Client side: Callback if the player selected an action
-
onClientActionMessage
public void onClientActionMessage(GameActionMessage message)
Client side: Callback after a message has been received for this entity
-
onClientGenerateEntityDetails
public String onClientGenerateEntityDetails()
Client side: Returns details about this entity. These details are text-only and are shown on the left in the entity details view after selecting an entity.
-
onServerActionMessage
public void onServerActionMessage(GameActionMessage message, UUID sender, GameSession gameSession)
Server side: Callback after a message has been received for this entity. Sender is either the player id of the sender on client side or null if the message was sent internally on server side
-
onServerTurnPass0
public void onServerTurnPass0(GameSession gameSession)
Server side: Executes code on every server turn, main pass 1 of 2. Executed after composite entities pass 0
-
onServerTurnPass1
public void onServerTurnPass1(GameSession gameSession)
Server side: Executes code on every server turn, main pass 2 of 2. Executed right after onServerTurnPass0 executed for all entities and before composite entities pass 1
-
onServerTurnPass2PostComposites
public void onServerTurnPass2PostComposites(GameSession gameSession)
Server side: Executes code on every server turn, postprocessing pass after composite entity pass 2. It is highly recommended to not change the main business state here but only do calculations based on that state
-
setClientActions
public void setClientActions(List<ClientEntityAction> clientActions)
-
serverTranslateEntityPass0
public void serverTranslateEntityPass0(Edge2 rotation, CoordI2 posSrc, CoordI2 origDim, AbstractCompositeEntity parent, GameSession gameSession)
Server side: Parent composite entity is rotated, rotates this entity
-
serverTranslateEntityPass1
public void serverTranslateEntityPass1(Edge2 rotation, CoordI2 posSrc, CoordI2 origDim, AbstractCompositeEntity parent, GameSession gameSession)
Server side: Postprocesses rotation of the parent composite entity. This also means that this entity is now at a different position in the tile grid
-
serverRestrictEntity
public boolean serverRestrictEntity(UUID recipient, AbstractCompositeEntity parent, GameSession gameSession)
Server side: Checks whether this entity should be restricted to the player recipient, i.e. details about this entity (state, ...) are sent to this player or not. See also RestrictedEntitySurface
-
serverPrepareRestrictedEntities
public void serverPrepareRestrictedEntities(UUID recipient, AbstractCompositeEntity parent, GameSession gameSession)
Server side: Prepares RestrictedEntity instances to be presented instead of this entity to a player. See also RestrictedEntitySurface
-
serverCleanupRestrictedEntities
public void serverCleanupRestrictedEntities(AbstractCompositeEntity parent, GameSession gameSession)
Server side: Cleans up restricted entity surfaces. See also See also RestrictedEntitySurface
-
createClientDrawTileImageBo
protected DrawTileImageBo createClientDrawTileImageBo()
Client side: Creates and sets up a DrawTileImageBo rendering business object to render this entity on a tile
-
getEntityDef
public int getEntityDef()
-
setEntityDef
public void setEntityDef(int entityDef)
-
getEntityDefUUID
public UUID getEntityDefUUID()
-
getPosition
public CoordI2 getPosition()
- Specified by:
getPosition
in interfaceHasPosition2
-
setPosition
public void setPosition(CoordI2 position)
Use this method for initial entity placement after EntityManager::create, but never update position after the initial EntityManager::put. This will break 2D index! Use EntityManager::move instead.
-
getDimension
public CoordI2 getDimension()
- Specified by:
getDimension
in interfaceHasPositionAndDimension2
-
getOrientation
public Edge2 getOrientation()
-
setOrientation
public void setOrientation(Edge2 orientation)
-
getUuid
public UUID getUuid()
-
setUuid
public void setUuid(UUID uuid)
-
getParentCompositeEntity
public UUID getParentCompositeEntity()
-
setParentCompositeEntity
public void setParentCompositeEntity(UUID parentCompositeEntity)
-
getTileset
public int getTileset()
-
getTilesetPosition
public CoordI2 getTilesetPosition()
-
getEntityLayer
public EntityLayer getEntityLayer()
-
setDirty
public void setDirty(boolean dirty)
-
isDirty
public boolean isDirty()
-
getEntityManager
public EntityManager getEntityManager()
-
setEntityManager
public void setEntityManager(EntityManager entityManager)
-
isLocalInit
public boolean isLocalInit()
-
setLocalInit
public void setLocalInit(boolean localInit)
-
getServerRestrictEntitiesLastUpdate
public int getServerRestrictEntitiesLastUpdate()
-
setServerRestrictEntitiesLastUpdate
public void setServerRestrictEntitiesLastUpdate(int serverRestrictedEntityLastUpdate)
-
getServerRestrictEntitiesWalls
public int getServerRestrictEntitiesWalls()
-
setServerRestrictEntitiesWalls
public void setServerRestrictEntitiesWalls(int serverRestrictEntitiesWalls)
-
getServerRestrictedEntities
public Map<UUID,List<AbstractEntity>> getServerRestrictedEntities()
-
setServerRestrictedEntities
public void setServerRestrictedEntities(Map<UUID,List<AbstractEntity>> serverRestrictedEntities)
-
-