Class PhysicalEntity
- java.lang.Object
-
- de.extio.spacecraft.shared.model.entity.AbstractEntity
-
- de.extio.spacecraft.shared.model.entity.builtin.live.PhysicalEntity
-
- All Implemented Interfaces:
HasPosition2
,HasPositionAndDimension2
- Direct Known Subclasses:
AbstractMeshEntity
,CrewEntity
,FloorEntity
,ImageSurfaceEntity
,LootContainer
,StructureEntity
public abstract class PhysicalEntity extends AbstractEntity
Physical entities represent everything that has a form, e.g. doors, weapons, crew, ...
-
-
Field Summary
Fields Modifier and Type Field Description protected Queue<ClientEntityAction>
clientEntityActionQueue
protected int
clientPoseAnimation
protected CoordI2
clientPoseTilesetPosition
protected boolean
enabled
protected String
entityAction
protected String
entityActionPending
protected int
entityActionPendingTurn
protected UUID
entityActionPlayer
protected CompositeAndEntityId
entityActionTarget
protected CoordI2
entityActionTargetCoord
protected double
health
protected UUID
loggedInEntity
protected boolean
onDamageDestroyImmediately
protected boolean
onDamageSplit
protected int
onDamageSplitThreshold
protected PathFindingEntitySupport
pathFindingEntitySupport
-
Fields inherited from class de.extio.spacecraft.shared.model.entity.AbstractEntity
LOGGER, serverRestrictedEntities, serverRestrictedEntitySurfaceBo
-
-
Constructor Summary
Constructors Constructor Description PhysicalEntity()
-
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 void
enableEntity(boolean enable)
Server side: Called when the enabled state changedString
getEntityAction()
String
getEntityActionPending()
CompositeAndEntityId
getEntityActionTarget()
CoordI2
getEntityActionTargetCoord()
double
getHealth()
UUID
getLoggedInEntity()
int
getOnDamageSplitThreshold()
PathFindingEntitySupport
getPathFindingEntitySupport()
CoordI2
getSubTileOffset()
CoordI2
getTilesetPosition()
void
handleEnabledState(GameSession gameSession)
Server side: Handles changing the enabled state of this entityboolean
isEnabled()
boolean
isOnDamageDestroyImmediately()
boolean
isOnDamageSplit()
boolean
isOperational()
Returns whether the entity is ready to execute actionsvoid
localCopy(AbstractEntity other)
Local copy of transient fieldsvoid
localInit(AbstractEntityDef entityDef)
Local initialization of transient fieldsvoid
nextClientEntityAction(boolean newActions)
boolean
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 entityClientConsoleComplexControlAction
onClientComplexConsoleControlEvent(boolean controlsActive, int button, CoordI2 normalizedCoordinate)
Client side: Called when the user interacted with the entity consolevoid
onClientComplexConsoleControlEvent(Event event)
Client side: Called when the user interacted with the entity consolevoid
onClientDamage(double oldHealth)
Client side: Called when the entity took damagevoid
onClientDrawConsoleControls(boolean controlsActive, List<ClientConsoleControlSet> consoleControls)
Client side: Draws controls on the entity consolevoid
onClientDrawEntity(List<RenderingBo> renderingBo)
Client side: Draws this entityvoid
onClientDrawEntityAction(List<RenderingBo> renderingBo, String action, boolean pending, CoordI2 subTileOffset)
Client side: Draws a certain action the entity is executingvoid
onClientDrawEntityActions(List<RenderingBo> renderingBo)
Client side: Draws general effects that are related to actions the entity is executingvoid
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
onServerActionMessage(GameActionMessage message, UUID sender, GameSession gameSession)
Server side: Callback after a message has been received for this entity.void
onServerConsoleControlEvent(GameSession gameSession, UUID sender, String controlId, Object payload)
Server side: Called when the user interacted with a control in the entity consolevoid
onServerDamage(GameSession gameSession, double oldHealth)
Server side: Called when the entity took damagevoid
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
serverAbortEntityAction(GameSession gameSession, boolean publishAsPendingAction)
Server side: Aborts the current action the entity is executingdouble
serverCalculateEmEmission(GameSession gameSession)
Server side: Calculates the EM emission of this entityvoid
serverSetEntityAction(String qualifier, CompositeAndEntityId target, CoordI2 targetCoord, boolean abortFirst, boolean forceNeedsOperator, boolean ignoreNeedsOperator, boolean deferActionMessage, UUID playerId, GameSession gameSession)
Server side: Sets an action the entity is executingprotected void
serverSplitOnDamage(GameSession gameSession)
Server side: Executes splitting an entity away from the current parent to a separate composite entity after taking heavy damage.void
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
setEnabled(boolean enabled)
void
setHealth(double health)
Sets the health of this entity.void
setLoggedInEntity(UUID loggedInEntity)
void
setOnDamageDestroyImmediately(boolean onDamageDestroyImmediately)
void
setOnDamageSplit(boolean onDamageSplit)
void
setOnDamageSplitThreshold(int onDamageSplitThreshold)
void
update(AbstractEntity other)
Incremental update of non-transient fields (usually transferred from server)-
Methods inherited from class de.extio.spacecraft.shared.model.entity.AbstractEntity
createClientDrawTileImageBo, getDimension, getEntityDef, getEntityDefUUID, getEntityLayer, getEntityManager, getOrientation, getParentCompositeEntity, getPosition, getServerRestrictedEntities, getServerRestrictEntitiesLastUpdate, getServerRestrictEntitiesWalls, getTileset, getUuid, isDirty, isLocalInit, onClientSelectedPointToWorldPos, onServerTurnPass2PostComposites, serverCleanupRestrictedEntities, serverPrepareRestrictedEntities, serverRestrictEntity, serverTranslateEntityPass0, setDirty, setEntityDef, setEntityManager, setLocalInit, setOrientation, setParentCompositeEntity, setPosition, setServerRestrictedEntities, setServerRestrictEntitiesLastUpdate, setServerRestrictEntitiesWalls, setUuid
-
-
-
-
Field Detail
-
health
protected double health
-
entityAction
protected String entityAction
-
entityActionTarget
protected CompositeAndEntityId entityActionTarget
-
entityActionTargetCoord
protected CoordI2 entityActionTargetCoord
-
entityActionPending
protected String entityActionPending
-
entityActionPendingTurn
protected int entityActionPendingTurn
-
entityActionPlayer
protected UUID entityActionPlayer
-
loggedInEntity
protected UUID loggedInEntity
-
enabled
protected boolean enabled
-
pathFindingEntitySupport
protected PathFindingEntitySupport pathFindingEntitySupport
-
onDamageDestroyImmediately
protected transient boolean onDamageDestroyImmediately
-
onDamageSplit
protected transient boolean onDamageSplit
-
onDamageSplitThreshold
protected transient int onDamageSplitThreshold
-
clientEntityActionQueue
protected transient Queue<ClientEntityAction> clientEntityActionQueue
-
clientPoseAnimation
protected transient int clientPoseAnimation
-
clientPoseTilesetPosition
protected transient CoordI2 clientPoseTilesetPosition
-
-
Method Detail
-
setHealth
public void setHealth(double health)
Sets the health of this entity. Setting health 0.0 means the entity has been destroyed
-
create
public void create(UUID uuid, AbstractEntityDef entityDef, int entityDefIdx, UUID parentCompositeEntity)
Description copied from class:AbstractEntity
Central initialization of non-transient fields (usually on server side). Is only called once in the whole life cycle of an entity.- Overrides:
create
in classAbstractEntity
-
localInit
public void localInit(AbstractEntityDef entityDef)
Description copied from class:AbstractEntity
Local initialization of transient fields- Overrides:
localInit
in classAbstractEntity
-
localCopy
public void localCopy(AbstractEntity other)
Description copied from class:AbstractEntity
Local copy of transient fields- Overrides:
localCopy
in classAbstractEntity
-
update
public void update(AbstractEntity other)
Description copied from class:AbstractEntity
Incremental update of non-transient fields (usually transferred from server)- Overrides:
update
in classAbstractEntity
-
onClientFrame
public void onClientFrame(boolean selected)
Description copied from class:AbstractEntity
Client side: Callback on each frame for general logic- Overrides:
onClientFrame
in classAbstractEntity
-
onClientDrawEntity
public void onClientDrawEntity(List<RenderingBo> renderingBo)
Description copied from class:AbstractEntity
Client side: Draws this entity- Overrides:
onClientDrawEntity
in classAbstractEntity
-
onClientDrawEntityActions
public void onClientDrawEntityActions(List<RenderingBo> renderingBo)
Client side: Draws general effects that are related to actions the entity is executing
-
onClientDrawEntityAction
public void onClientDrawEntityAction(List<RenderingBo> renderingBo, String action, boolean pending, CoordI2 subTileOffset)
Client side: Draws a certain action the entity is executing
-
onClientSelectedPointToEntity
public void onClientSelectedPointToEntity(AbstractCompositeEntity otherCompositeEntity, AbstractEntity other, int modifiers, List<ClientEntityAction> outClientActions)
Description copied from class:AbstractEntity
Client side: Callback when this entity is selected and cursor is pointing to another entity- Overrides:
onClientSelectedPointToEntity
in classAbstractEntity
-
onClientSelectedPointToNoClientEntityAction
public void onClientSelectedPointToNoClientEntityAction(int modifiers)
Description copied from class:AbstractEntity
Client side: Callback when this entity is selected and onClientSelectedPointToEntity + onClientSelectedPointToWorldPos did not set any possible action- Overrides:
onClientSelectedPointToNoClientEntityAction
in classAbstractEntity
-
onClientAction
public boolean onClientAction(ClientEntityAction clientAction, AbstractCompositeEntity targetCompositeEntity, AbstractEntity targetEntity)
Description copied from class:AbstractEntity
Client side: Callback if the player selected an action- Overrides:
onClientAction
in classAbstractEntity
-
onClientActionMessage
public void onClientActionMessage(GameActionMessage message)
Description copied from class:AbstractEntity
Client side: Callback after a message has been received for this entity- Overrides:
onClientActionMessage
in classAbstractEntity
-
onClientGenerateEntityDetails
public String onClientGenerateEntityDetails()
Description copied from class:AbstractEntity
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.- Overrides:
onClientGenerateEntityDetails
in classAbstractEntity
-
onServerActionMessage
public void onServerActionMessage(GameActionMessage message, UUID sender, GameSession gameSession)
Description copied from class:AbstractEntity
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- Overrides:
onServerActionMessage
in classAbstractEntity
-
onServerTurnPass0
public void onServerTurnPass0(GameSession gameSession)
Description copied from class:AbstractEntity
Server side: Executes code on every server turn, main pass 1 of 2. Executed after composite entities pass 0- Overrides:
onServerTurnPass0
in classAbstractEntity
-
handleEnabledState
public void handleEnabledState(GameSession gameSession)
Server side: Handles changing the enabled state of this entity
-
enableEntity
protected void enableEntity(boolean enable)
Server side: Called when the enabled state changed
-
onServerTurnPass1
public void onServerTurnPass1(GameSession gameSession)
Description copied from class:AbstractEntity
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- Overrides:
onServerTurnPass1
in classAbstractEntity
-
getTilesetPosition
public CoordI2 getTilesetPosition()
- Overrides:
getTilesetPosition
in classAbstractEntity
-
onClientDamage
public void onClientDamage(double oldHealth)
Client side: Called when the entity took damage
-
onServerDamage
public void onServerDamage(GameSession gameSession, double oldHealth)
Server side: Called when the entity took damage
-
setClientActions
public void setClientActions(List<ClientEntityAction> clientActions)
- Overrides:
setClientActions
in classAbstractEntity
-
isOperational
public boolean isOperational()
Returns whether the entity is ready to execute actions
-
onClientDrawConsoleControls
public void onClientDrawConsoleControls(boolean controlsActive, List<ClientConsoleControlSet> consoleControls)
Client side: Draws controls on the entity console
-
onClientComplexConsoleControlEvent
public ClientConsoleComplexControlAction onClientComplexConsoleControlEvent(boolean controlsActive, int button, CoordI2 normalizedCoordinate)
Client side: Called when the user interacted with the entity console
-
onClientComplexConsoleControlEvent
public void onClientComplexConsoleControlEvent(Event event)
Client side: Called when the user interacted with the entity console
-
onServerConsoleControlEvent
public void onServerConsoleControlEvent(GameSession gameSession, UUID sender, String controlId, Object payload)
Server side: Called when the user interacted with a control in the entity console
-
nextClientEntityAction
public void nextClientEntityAction(boolean newActions)
-
serverSetEntityAction
public void serverSetEntityAction(String qualifier, CompositeAndEntityId target, CoordI2 targetCoord, boolean abortFirst, boolean forceNeedsOperator, boolean ignoreNeedsOperator, boolean deferActionMessage, UUID playerId, GameSession gameSession)
Server side: Sets an action the entity is executing
-
serverAbortEntityAction
public void serverAbortEntityAction(GameSession gameSession, boolean publishAsPendingAction)
Server side: Aborts the current action the entity is executing
-
serverSplitOnDamage
protected void serverSplitOnDamage(GameSession gameSession)
Server side: Executes splitting an entity away from the current parent to a separate composite entity after taking heavy damage. This is an optional feature that needs to be enabled in entity def
-
serverTranslateEntityPass1
public void serverTranslateEntityPass1(Edge2 rotation, CoordI2 posSrc, CoordI2 origDim, AbstractCompositeEntity parent, GameSession gameSession)
Description copied from class:AbstractEntity
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- Overrides:
serverTranslateEntityPass1
in classAbstractEntity
-
serverCalculateEmEmission
public double serverCalculateEmEmission(GameSession gameSession)
Server side: Calculates the EM emission of this entity
-
getHealth
public double getHealth()
-
getSubTileOffset
public CoordI2 getSubTileOffset()
-
getEntityAction
public String getEntityAction()
-
getEntityActionTarget
public CompositeAndEntityId getEntityActionTarget()
-
getEntityActionTargetCoord
public CoordI2 getEntityActionTargetCoord()
-
getEntityActionPending
public String getEntityActionPending()
-
getLoggedInEntity
public UUID getLoggedInEntity()
-
setLoggedInEntity
public void setLoggedInEntity(UUID loggedInEntity)
-
isEnabled
public boolean isEnabled()
-
setEnabled
public void setEnabled(boolean enabled)
-
getPathFindingEntitySupport
public PathFindingEntitySupport getPathFindingEntitySupport()
-
isOnDamageDestroyImmediately
public boolean isOnDamageDestroyImmediately()
-
setOnDamageDestroyImmediately
public void setOnDamageDestroyImmediately(boolean onDamageDestroyImmediately)
-
isOnDamageSplit
public boolean isOnDamageSplit()
-
setOnDamageSplit
public void setOnDamageSplit(boolean onDamageSplit)
-
getOnDamageSplitThreshold
public int getOnDamageSplitThreshold()
-
setOnDamageSplitThreshold
public void setOnDamageSplitThreshold(int onDamageSplitThreshold)
-
-