Class SpaceCraft
- java.lang.Object
-
- de.extio.spacecraft.shared.model.entity.AbstractCompositeEntity
-
- de.extio.spacecraft.shared.model.entity.builtin.composite.SpaceCraft
-
- All Implemented Interfaces:
HasAttackerInfo
,HasServerEntityGroupsCache
,HasPosition2
,HasPositionAndDimension2
,SpatialIndex2Capable
- Direct Known Subclasses:
SpaceShip
public class SpaceCraft extends AbstractCompositeEntity implements HasServerEntityGroupsCache, HasAttackerInfo
SpaceCraft is the base class for all ships in this game.
When to use which type:
* SpaceCraft: Ships controlled by AI, cannot spawn on a player slot in a game session
* SpaceShip: Ships controlled by players or AI, can spawn on a player slot in a game session (but only needs to if players join the ship)
* SpaceStation: Specialization of SpaceShip for stationary (big) stations. Similar to SpaceShip
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.extio.spacecraft.shared.model.entity.AbstractCompositeEntity
AbstractCompositeEntity.CollisionCalculationResult, AbstractCompositeEntity.DefaultDamageWaveDamageHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected String
crewTilesetName
protected boolean
dead
protected double
emEmission
static RgbaColor
GREEN_HIGHLIGHT
protected List<UUID>
operators
static RgbaColor
RED_HIGHLIGHT
protected String
restrictedHullEntityDefName
protected String
restrictedWallEntityDefName
protected Map<EntityGroupsOptions,Matrix2<Integer>>
serverEntityGroupsCache
protected int
serverLastAttacked
protected List<UUID>
serverLastAttackedBy
protected String
shareCode
protected String
shipClassName
protected int
team
protected byte[]
thumbnail
protected int
thumbnailVersion
-
Fields inherited from class de.extio.spacecraft.shared.model.entity.AbstractCompositeEntity
accelerationVector, DAMAGE_COLORS, DAMAGE_CONSUMER_BOTH, DAMAGE_CONSUMER_ENTITY, DAMAGE_CONSUMER_SHIELD, DAMAGEWAVE_DIRECTIONS, dimension, dirty, entityManager, fields, fresh, lastMovement, LOGGER, meshes, position, positionDirty, precisePosition, prevPosition, prevVelocityVector, ROTATE_COLLISION_COLOR, splitEntityGroups, sumMassCached, sumMassCachedTurn, uuid, velocityVector, VMAX_M_LB, VMAX_M_UB, VMAX_VEL_MAX, VMAX_VEL_MIN, VMAX_VEL_VAR
-
-
Constructor Summary
Constructors Constructor Description SpaceCraft()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CoordI2
compressDimension()
Compresses the dimension of this composite.void
create(UUID uuid, CoordI2 position, CoordI2 dimension)
Called upon initial creation of this composite entity.String
getCrewTilesetName()
Map<String,Object>
getDynamicSerializationProperties(boolean incremental, UUID recipient)
Dynamic serialization properties are created when transferring data from server to client (or vice versa) as well as when persisting a composite to disk.Map<String,Object>
getDynamicSerializationPropertiesForSeparateTransfer(boolean incremental, UUID recipient)
Same concept as for getDynamicSerializationProperties(), but these properties are transferred separately.double
getEmEmission()
List<UUID>
getOperators()
String
getRestrictedHullEntityDefName()
String
getRestrictedHullEntityDefName(boolean team)
String
getRestrictedWallEntityDefName()
String
getRestrictedWallEntityDefName(boolean team)
Map<EntityGroupsOptions,Matrix2<Integer>>
getServerEntityGroupsCache()
int
getServerLastAttacked()
List<UUID>
getServerLastAttackedBy()
String
getShareCode()
String
getShipClassName()
int
getTeam()
byte[]
getThumbnail()
int
getThumbnailVersion()
boolean
isDead()
protected boolean
killCondition(GameSession gameSession)
Server side: Checks if the SpaceCraft has been killedvoid
localCopy(AbstractCompositeEntity other)
Local copy of all fields that are not covered by update()void
localInit(EntityManager entityManager)
Local initialization of transient fields.void
onClientDraw(List<RenderingBo> renderingBo)
Client side: Draw effects related to this composite entity.protected boolean
onServerCollision(GameSession gameSession, Map<AbstractCompositeEntity,List<AbstractEntity>> entityLevelCollisions)
Server side: Callback for additional logic when a collision happenedprotected void
onServerHullBreach(CoordI2 position, int change, GameSession gameSession)
Server side: Additional logic on tiles with a hull breachprotected void
onServerSpaceCraftKilled(GameSession gameSession, boolean initial)
Server side: Called every turn when the spacecraft has been killedvoid
onServerTurnPass0(GameSession gameSession)
Server side: Called every turn to contain any logic related to this entitiy.void
onServerTurnPass1(GameSession gameSession)
Server side: Called every turn to contain any logic related to this entitiy.void
onServerTurnPass2(GameSession gameSession)
Server side: Called every turn to contain any logic related to this entitiy.void
resetFieldsForPermanentStorage()
This method provide the possibility to reset certain non-transient fields that are relevant at runtime but not relevant for storing it permanently to disk.boolean
rotate(GameSession gameSession, Edge2 direction)
Rotates this composite entityprotected void
serverHullBreach(GameSession gameSession)
Server side: Implements hull breaches on tiles.void
setCrewTilesetName(String crewTilesetName)
void
setDead(boolean dead)
void
setDynamicSerializationProperties(Map<String,Object> properties)
This is the counterpart of getDynamicSerializationProperties(), see the description there.void
setEmEmission(double emEmission)
void
setOperators(List<UUID> operators)
void
setRestrictedHullEntityDefName(String restrictedHullEntityDefName)
void
setRestrictedWallEntityDefName(String restrictedWallEntityDefName)
void
setServerLastAttacked(int serverLastAttacked)
void
setServerLastAttackedBy(List<UUID> serverLastAttackedBy)
void
setShareCode(String shareCode)
void
setShipClassName(String shipClassName)
void
setTeam(int team)
void
setThumbnail(byte[] thumbnail)
void
setThumbnailVersion(int thumbnailVersion)
void
update(AbstractCompositeEntity other)
Updates non-transient fields (i.e.-
Methods inherited from class de.extio.spacecraft.shared.model.entity.AbstractCompositeEntity
accelerate, calculateCollision, calculateVMax, damageWave, excludeDynamicSerializationPropertiesPermanentStorage, getAccelerationVector, getAnimationOffset, getCompositeEntityFactoryClassName, getDimension, getEntityManager, getEntityNetworkConsolesCache, getFields, getLastEdited, getLastRotation, getLastRotationDirection, getMeshes, getPosition, getPrecisePosition, getPrevPosition, getSceneTag, getServerFieldsLastPublished, getServerLastInViewPort, getServerMeshesLastPublished, getServerScannedBy, getUuid, getVelocityVector, handleMove, handleMoveApply, includeInSpatialIndex2ResultSet, isDirty, isFresh, isInSpatialIndex2ResultSet, isLocalInit, isPositionDirty, isRemoved, isShadowed, isSplitEntityGroups, onClientActionMessage, onClientFrame, onRemove, onServerActionMessage, priorityCalculateCollision, resetStatic, restoreFieldsFromPermanentStorage, setAccelerationVector, setCompositeEntityFactoryClassName, setDimension, setDirty, setEntityManager, setFresh, setLastEdited, setPosition, setPositionDirty, setPrecisePosition, setPrevPosition, setSceneTag, setServerFieldsLastPublished, setServerMeshesLastPublished, setShadowed, setSplitEntityGroups, setUuid, setVelocityVector, splitEntityGroups, sumMass
-
-
-
-
Field Detail
-
RED_HIGHLIGHT
public static final RgbaColor RED_HIGHLIGHT
-
GREEN_HIGHLIGHT
public static final RgbaColor GREEN_HIGHLIGHT
-
emEmission
protected double emEmission
-
dead
protected boolean dead
-
team
protected int team
-
shipClassName
protected transient String shipClassName
-
thumbnail
protected transient byte[] thumbnail
-
thumbnailVersion
protected transient int thumbnailVersion
-
restrictedWallEntityDefName
protected transient String restrictedWallEntityDefName
-
restrictedHullEntityDefName
protected transient String restrictedHullEntityDefName
-
crewTilesetName
protected transient String crewTilesetName
-
shareCode
protected transient String shareCode
-
serverEntityGroupsCache
protected transient Map<EntityGroupsOptions,Matrix2<Integer>> serverEntityGroupsCache
-
serverLastAttacked
protected transient int serverLastAttacked
-
-
Method Detail
-
create
public void create(UUID uuid, CoordI2 position, CoordI2 dimension)
Description copied from class:AbstractCompositeEntity
Called upon initial creation of this composite entity. This method is not called locally (i.e. when the composite has been transferred from server to client), so only initialize non-transient fields here. See also localInit()- Overrides:
create
in classAbstractCompositeEntity
-
update
public void update(AbstractCompositeEntity other)
Description copied from class:AbstractCompositeEntity
Updates non-transient fields (i.e. when receiving an entity update from server or copying a composite entity)- Overrides:
update
in classAbstractCompositeEntity
-
localInit
public void localInit(EntityManager entityManager)
Description copied from class:AbstractCompositeEntity
Local initialization of transient fields. See also create() and update()- Overrides:
localInit
in classAbstractCompositeEntity
-
localCopy
public void localCopy(AbstractCompositeEntity other)
Description copied from class:AbstractCompositeEntity
Local copy of all fields that are not covered by update()- Overrides:
localCopy
in classAbstractCompositeEntity
-
getDynamicSerializationProperties
public Map<String,Object> getDynamicSerializationProperties(boolean incremental, UUID recipient)
Description copied from class:AbstractCompositeEntity
Dynamic serialization properties are created when transferring data from server to client (or vice versa) as well as when persisting a composite to disk. These properties provide a way to implement complex serialization logic (i.e. views) and to distinguish between incremental and full updates.- Overrides:
getDynamicSerializationProperties
in classAbstractCompositeEntity
-
getDynamicSerializationPropertiesForSeparateTransfer
public Map<String,Object> getDynamicSerializationPropertiesForSeparateTransfer(boolean incremental, UUID recipient)
Description copied from class:AbstractCompositeEntity
Same concept as for getDynamicSerializationProperties(), but these properties are transferred separately. Use case are large data like thumbnails.- Overrides:
getDynamicSerializationPropertiesForSeparateTransfer
in classAbstractCompositeEntity
-
setDynamicSerializationProperties
public void setDynamicSerializationProperties(Map<String,Object> properties)
Description copied from class:AbstractCompositeEntity
This is the counterpart of getDynamicSerializationProperties(), see the description there.- Overrides:
setDynamicSerializationProperties
in classAbstractCompositeEntity
-
resetFieldsForPermanentStorage
public void resetFieldsForPermanentStorage()
Description copied from class:AbstractCompositeEntity
This method provide the possibility to reset certain non-transient fields that are relevant at runtime but not relevant for storing it permanently to disk.- Overrides:
resetFieldsForPermanentStorage
in classAbstractCompositeEntity
-
onClientDraw
public void onClientDraw(List<RenderingBo> renderingBo)
Description copied from class:AbstractCompositeEntity
Client side: Draw effects related to this composite entity. All entities are already drawn separately by the game core.- Overrides:
onClientDraw
in classAbstractCompositeEntity
-
onServerTurnPass0
public void onServerTurnPass0(GameSession gameSession)
Description copied from class:AbstractCompositeEntity
Server side: Called every turn to contain any logic related to this entitiy. Pass0 is called at the beginning of the cycle before entity callbacks have been called.- Overrides:
onServerTurnPass0
in classAbstractCompositeEntity
-
onServerTurnPass1
public void onServerTurnPass1(GameSession gameSession)
Description copied from class:AbstractCompositeEntity
Server side: Called every turn to contain any logic related to this entitiy. Pass1 is called after both entity callback passes have been called for all composites.- Overrides:
onServerTurnPass1
in classAbstractCompositeEntity
-
onServerTurnPass2
public void onServerTurnPass2(GameSession gameSession)
Description copied from class:AbstractCompositeEntity
Server side: Called every turn to contain any logic related to this entitiy. Pass2 is called after pass1 was called on all composites.- Overrides:
onServerTurnPass2
in classAbstractCompositeEntity
-
onServerCollision
protected boolean onServerCollision(GameSession gameSession, Map<AbstractCompositeEntity,List<AbstractEntity>> entityLevelCollisions)
Description copied from class:AbstractCompositeEntity
Server side: Callback for additional logic when a collision happened- Overrides:
onServerCollision
in classAbstractCompositeEntity
-
compressDimension
public CoordI2 compressDimension()
Description copied from class:AbstractCompositeEntity
Compresses the dimension of this composite. A compressed composite has no unoccupied space around it's borders.- Overrides:
compressDimension
in classAbstractCompositeEntity
-
serverHullBreach
protected void serverHullBreach(GameSession gameSession)
Server side: Implements hull breaches on tiles. The hull is breached when floor entity is destroyed and shield strength on this tile is less than 1 plateau. Hull breaches leak O2 to space and may have more custom logic implemented
-
onServerHullBreach
protected void onServerHullBreach(CoordI2 position, int change, GameSession gameSession)
Server side: Additional logic on tiles with a hull breach
-
killCondition
protected boolean killCondition(GameSession gameSession)
Server side: Checks if the SpaceCraft has been killed
-
onServerSpaceCraftKilled
protected void onServerSpaceCraftKilled(GameSession gameSession, boolean initial)
Server side: Called every turn when the spacecraft has been killed
-
rotate
public boolean rotate(GameSession gameSession, Edge2 direction)
Description copied from class:AbstractCompositeEntity
Rotates this composite entity- Overrides:
rotate
in classAbstractCompositeEntity
-
getShipClassName
public String getShipClassName()
-
setShipClassName
public void setShipClassName(String shipClassName)
-
getEmEmission
public double getEmEmission()
-
setEmEmission
public void setEmEmission(double emEmission)
-
getThumbnail
public byte[] getThumbnail()
-
setThumbnail
public void setThumbnail(byte[] thumbnail)
-
getThumbnailVersion
public int getThumbnailVersion()
-
setThumbnailVersion
public void setThumbnailVersion(int thumbnailVersion)
-
isDead
public boolean isDead()
-
setDead
public void setDead(boolean dead)
-
getTeam
public int getTeam()
-
setTeam
public void setTeam(int team)
-
getRestrictedWallEntityDefName
public String getRestrictedWallEntityDefName()
-
getRestrictedWallEntityDefName
public String getRestrictedWallEntityDefName(boolean team)
-
setRestrictedWallEntityDefName
public void setRestrictedWallEntityDefName(String restrictedWallEntityDefName)
-
getRestrictedHullEntityDefName
public String getRestrictedHullEntityDefName()
-
getRestrictedHullEntityDefName
public String getRestrictedHullEntityDefName(boolean team)
-
setRestrictedHullEntityDefName
public void setRestrictedHullEntityDefName(String restrictedHullEntityDefName)
-
getCrewTilesetName
public String getCrewTilesetName()
-
setCrewTilesetName
public void setCrewTilesetName(String crewTilesetName)
-
getServerEntityGroupsCache
public Map<EntityGroupsOptions,Matrix2<Integer>> getServerEntityGroupsCache()
- Specified by:
getServerEntityGroupsCache
in interfaceHasServerEntityGroupsCache
-
getServerLastAttacked
public int getServerLastAttacked()
- Specified by:
getServerLastAttacked
in interfaceHasAttackerInfo
-
setServerLastAttacked
public void setServerLastAttacked(int serverLastAttacked)
- Specified by:
setServerLastAttacked
in interfaceHasAttackerInfo
-
getServerLastAttackedBy
public List<UUID> getServerLastAttackedBy()
- Specified by:
getServerLastAttackedBy
in interfaceHasAttackerInfo
-
setServerLastAttackedBy
public void setServerLastAttackedBy(List<UUID> serverLastAttackedBy)
- Specified by:
setServerLastAttackedBy
in interfaceHasAttackerInfo
-
getShareCode
public String getShareCode()
-
setShareCode
public void setShareCode(String shareCode)
-
-