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 StringcrewTilesetNameprotected booleandeadprotected doubleemEmissionstatic RgbaColorGREEN_HIGHLIGHTprotected List<UUID>operatorsstatic RgbaColorRED_HIGHLIGHTprotected StringrestrictedHullEntityDefNameprotected StringrestrictedWallEntityDefNameprotected Map<EntityGroupsOptions,Matrix2<Integer>>serverEntityGroupsCacheprotected intserverLastAttackedprotected List<UUID>serverLastAttackedByprotected StringshareCodeprotected StringshipClassNameprotected intteamprotected byte[]thumbnailprotected intthumbnailVersion-
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 CoordI2compressDimension()Compresses the dimension of this composite.voidcreate(UUID uuid, CoordI2 position, CoordI2 dimension)Called upon initial creation of this composite entity.StringgetCrewTilesetName()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.doublegetEmEmission()List<UUID>getOperators()StringgetRestrictedHullEntityDefName()StringgetRestrictedHullEntityDefName(boolean team)StringgetRestrictedWallEntityDefName()StringgetRestrictedWallEntityDefName(boolean team)Map<EntityGroupsOptions,Matrix2<Integer>>getServerEntityGroupsCache()intgetServerLastAttacked()List<UUID>getServerLastAttackedBy()StringgetShareCode()StringgetShipClassName()intgetTeam()byte[]getThumbnail()intgetThumbnailVersion()booleanisDead()protected booleankillCondition(GameSession gameSession)Server side: Checks if the SpaceCraft has been killedvoidlocalCopy(AbstractCompositeEntity other)Local copy of all fields that are not covered by update()voidlocalInit(EntityManager entityManager)Local initialization of transient fields.voidonClientDraw(List<RenderingBo> renderingBo)Client side: Draw effects related to this composite entity.protected booleanonServerCollision(GameSession gameSession, Map<AbstractCompositeEntity,List<AbstractEntity>> entityLevelCollisions)Server side: Callback for additional logic when a collision happenedprotected voidonServerHullBreach(CoordI2 position, int change, GameSession gameSession)Server side: Additional logic on tiles with a hull breachprotected voidonServerSpaceCraftKilled(GameSession gameSession, boolean initial)Server side: Called every turn when the spacecraft has been killedvoidonServerTurnPass0(GameSession gameSession)Server side: Called every turn to contain any logic related to this entitiy.voidonServerTurnPass1(GameSession gameSession)Server side: Called every turn to contain any logic related to this entitiy.voidonServerTurnPass2(GameSession gameSession)Server side: Called every turn to contain any logic related to this entitiy.voidresetFieldsForPermanentStorage()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.booleanrotate(GameSession gameSession, Edge2 direction)Rotates this composite entityprotected voidserverHullBreach(GameSession gameSession)Server side: Implements hull breaches on tiles.voidsetCrewTilesetName(String crewTilesetName)voidsetDead(boolean dead)voidsetDynamicSerializationProperties(Map<String,Object> properties)This is the counterpart of getDynamicSerializationProperties(), see the description there.voidsetEmEmission(double emEmission)voidsetOperators(List<UUID> operators)voidsetRestrictedHullEntityDefName(String restrictedHullEntityDefName)voidsetRestrictedWallEntityDefName(String restrictedWallEntityDefName)voidsetServerLastAttacked(int serverLastAttacked)voidsetServerLastAttackedBy(List<UUID> serverLastAttackedBy)voidsetShareCode(String shareCode)voidsetShipClassName(String shipClassName)voidsetTeam(int team)voidsetThumbnail(byte[] thumbnail)voidsetThumbnailVersion(int thumbnailVersion)voidupdate(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:AbstractCompositeEntityCalled 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:
createin classAbstractCompositeEntity
-
update
public void update(AbstractCompositeEntity other)
Description copied from class:AbstractCompositeEntityUpdates non-transient fields (i.e. when receiving an entity update from server or copying a composite entity)- Overrides:
updatein classAbstractCompositeEntity
-
localInit
public void localInit(EntityManager entityManager)
Description copied from class:AbstractCompositeEntityLocal initialization of transient fields. See also create() and update()- Overrides:
localInitin classAbstractCompositeEntity
-
localCopy
public void localCopy(AbstractCompositeEntity other)
Description copied from class:AbstractCompositeEntityLocal copy of all fields that are not covered by update()- Overrides:
localCopyin classAbstractCompositeEntity
-
getDynamicSerializationProperties
public Map<String,Object> getDynamicSerializationProperties(boolean incremental, UUID recipient)
Description copied from class:AbstractCompositeEntityDynamic 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:
getDynamicSerializationPropertiesin classAbstractCompositeEntity
-
getDynamicSerializationPropertiesForSeparateTransfer
public Map<String,Object> getDynamicSerializationPropertiesForSeparateTransfer(boolean incremental, UUID recipient)
Description copied from class:AbstractCompositeEntitySame concept as for getDynamicSerializationProperties(), but these properties are transferred separately. Use case are large data like thumbnails.- Overrides:
getDynamicSerializationPropertiesForSeparateTransferin classAbstractCompositeEntity
-
setDynamicSerializationProperties
public void setDynamicSerializationProperties(Map<String,Object> properties)
Description copied from class:AbstractCompositeEntityThis is the counterpart of getDynamicSerializationProperties(), see the description there.- Overrides:
setDynamicSerializationPropertiesin classAbstractCompositeEntity
-
resetFieldsForPermanentStorage
public void resetFieldsForPermanentStorage()
Description copied from class:AbstractCompositeEntityThis 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:
resetFieldsForPermanentStoragein classAbstractCompositeEntity
-
onClientDraw
public void onClientDraw(List<RenderingBo> renderingBo)
Description copied from class:AbstractCompositeEntityClient side: Draw effects related to this composite entity. All entities are already drawn separately by the game core.- Overrides:
onClientDrawin classAbstractCompositeEntity
-
onServerTurnPass0
public void onServerTurnPass0(GameSession gameSession)
Description copied from class:AbstractCompositeEntityServer 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:
onServerTurnPass0in classAbstractCompositeEntity
-
onServerTurnPass1
public void onServerTurnPass1(GameSession gameSession)
Description copied from class:AbstractCompositeEntityServer 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:
onServerTurnPass1in classAbstractCompositeEntity
-
onServerTurnPass2
public void onServerTurnPass2(GameSession gameSession)
Description copied from class:AbstractCompositeEntityServer side: Called every turn to contain any logic related to this entitiy. Pass2 is called after pass1 was called on all composites.- Overrides:
onServerTurnPass2in classAbstractCompositeEntity
-
onServerCollision
protected boolean onServerCollision(GameSession gameSession, Map<AbstractCompositeEntity,List<AbstractEntity>> entityLevelCollisions)
Description copied from class:AbstractCompositeEntityServer side: Callback for additional logic when a collision happened- Overrides:
onServerCollisionin classAbstractCompositeEntity
-
compressDimension
public CoordI2 compressDimension()
Description copied from class:AbstractCompositeEntityCompresses the dimension of this composite. A compressed composite has no unoccupied space around it's borders.- Overrides:
compressDimensionin 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:AbstractCompositeEntityRotates this composite entity- Overrides:
rotatein 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:
getServerEntityGroupsCachein interfaceHasServerEntityGroupsCache
-
getServerLastAttacked
public int getServerLastAttacked()
- Specified by:
getServerLastAttackedin interfaceHasAttackerInfo
-
setServerLastAttacked
public void setServerLastAttacked(int serverLastAttacked)
- Specified by:
setServerLastAttackedin interfaceHasAttackerInfo
-
getServerLastAttackedBy
public List<UUID> getServerLastAttackedBy()
- Specified by:
getServerLastAttackedByin interfaceHasAttackerInfo
-
setServerLastAttackedBy
public void setServerLastAttackedBy(List<UUID> serverLastAttackedBy)
- Specified by:
setServerLastAttackedByin interfaceHasAttackerInfo
-
getShareCode
public String getShareCode()
-
setShareCode
public void setShareCode(String shareCode)
-
-