Class AbstractCompositeEntity

    • Field Detail

      • LOGGER

        protected static final org.apache.logging.log4j.Logger LOGGER
      • DAMAGEWAVE_DIRECTIONS

        protected static final CoordI2[] DAMAGEWAVE_DIRECTIONS
      • DAMAGE_CONSUMER_ENTITY

        public static final Integer DAMAGE_CONSUMER_ENTITY
      • DAMAGE_CONSUMER_SHIELD

        public static final Integer DAMAGE_CONSUMER_SHIELD
      • DAMAGE_CONSUMER_BOTH

        public static final Integer DAMAGE_CONSUMER_BOTH
      • ROTATE_COLLISION_COLOR

        protected static final RgbaColor ROTATE_COLLISION_COLOR
      • uuid

        protected UUID uuid
      • position

        protected CoordI2 position
      • dimension

        protected CoordI2 dimension
      • velocityVector

        protected CoordD2 velocityVector
      • accelerationVector

        protected CoordD2 accelerationVector
      • precisePosition

        protected CoordD2 precisePosition
      • prevPosition

        protected CoordI2 prevPosition
      • splitEntityGroups

        protected boolean splitEntityGroups
      • fresh

        protected transient boolean fresh
      • dirty

        protected transient boolean dirty
      • positionDirty

        protected transient boolean positionDirty
      • fields

        protected transient Fields fields
      • prevVelocityVector

        protected transient CoordD2 prevVelocityVector
      • lastMovement

        protected transient int lastMovement
      • sumMassCached

        protected transient double sumMassCached
      • sumMassCachedTurn

        protected transient int sumMassCachedTurn
    • Constructor Detail

      • AbstractCompositeEntity

        public AbstractCompositeEntity()
    • Method Detail

      • resetStatic

        public void resetStatic()
        Resets static fields when a new game is initialized. This method is not static to enable subclasses to add own logic (as java does not support overriding static methods)
      • localInit

        public void localInit​(EntityManager entityManager)
        Local initialization of transient fields. See also create() and update()
      • localCopy

        public void localCopy​(AbstractCompositeEntity other)
        Local copy of all fields that are not covered by update()
      • create

        public void create​(UUID uuid,
                           CoordI2 position,
                           CoordI2 dimension)
        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()
      • update

        public void update​(AbstractCompositeEntity other)
        Updates non-transient fields (i.e. when receiving an entity update from server or copying a composite entity)
      • getDynamicSerializationProperties

        public 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. These properties provide a way to implement complex serialization logic (i.e. views) and to distinguish between incremental and full updates.
      • getDynamicSerializationPropertiesForSeparateTransfer

        public Map<String,​Object> getDynamicSerializationPropertiesForSeparateTransfer​(boolean incremental,
                                                                                             UUID recipient)
        Same concept as for getDynamicSerializationProperties(), but these properties are transferred separately. Use case are large data like thumbnails.
      • setDynamicSerializationProperties

        public void setDynamicSerializationProperties​(Map<String,​Object> properties)
        This is the counterpart of getDynamicSerializationProperties(), see the description there.
      • resetFieldsForPermanentStorage

        public 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.
      • restoreFieldsFromPermanentStorage

        public void restoreFieldsFromPermanentStorage()
        Counterpart of resetFieldsForPermanentStorage() to initialize certain fields again after loading from disk.
      • excludeDynamicSerializationPropertiesPermanentStorage

        public void excludeDynamicSerializationPropertiesPermanentStorage​(Map<String,​Object> dynamicSerializationProperties)
        This method provide the possibility to reset certain dynamic properties that are relevant at runtime but not relevant for storing it permanently to disk.
      • onRemove

        public void onRemove()
        This callback is called when this composite is removed from world manager.
      • onClientFrame

        public void onClientFrame()
        Client side: Called on each frame
      • onClientDraw

        public void onClientDraw​(List<RenderingBo> renderingBo)
        Client side: Draw effects related to this composite entity. All entities are already drawn separately by the game core.
      • onClientActionMessage

        public void onClientActionMessage​(GameActionMessage message)
        Client side: Callback when a GameActionMessage has been received that is addressed to this composite
      • onServerActionMessage

        public void onServerActionMessage​(GameSession gameSession,
                                          UUID sender,
                                          GameActionMessage message)
        Server side: Callback when a GameActionMessage has been received that is addressed to this composite
        Parameters:
        sender - Player id of the sender or null if the message was sent on server side
      • onServerTurnPass0

        public void onServerTurnPass0​(GameSession gameSession)
        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.
      • onServerTurnPass1

        public void onServerTurnPass1​(GameSession gameSession)
        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.
      • onServerTurnPass2

        public void onServerTurnPass2​(GameSession gameSession)
        Server side: Called every turn to contain any logic related to this entitiy. Pass2 is called after pass1 was called on all composites.
      • sumMass

        public double sumMass()
        Sums up the total mass of this composite
      • handleMove

        protected void handleMove​(GameSession gameSession)
        Server side: Called on every turn twice (pass0 and pass1) to handle movement of this composite
      • handleMoveApply

        protected void handleMoveApply​(GameSession gameSession,
                                       CoordD2 newPositionPrecise)
        Applies a new spatial position on this composite entity
      • damageWave

        public void damageWave​(GameSession gameSession,
                               DamageWaveOptions damageWaveOptions,
                               List<AbstractEntity> damagedEntities)
        Distributes incoming damage on entities.
        There are certain aspects relevant for the calculation:
        * A tiles consists of several layered entities
        * An entity only absorbs a certain amount of damage (plateaus), which is also dependent on the weapon
        * A tile can be protected by shields
        * Also shields have plateaus
        * Damage that is not absorbed propagates to nearby tiles
        * Damage cannot propagate through some tiles in certain directions, i.e. walls, unless the entity is destroyed
        * Propagated damage is dampened
        * Damage handlers for tiles are pluggable
      • accelerate

        public void accelerate​(CoordD2 a)
        Accelerates composite entity. Implements a speed limit based on mass. (I'm aware that in reality there is nothing like that in space well below relativistic levels - this is purely implemented because of gameplay considerations. Almost no space game allows to accelerate indefinitely!)
        Parameters:
        a - Acceleration vector
      • calculateVMax

        public double calculateVMax()
        Calculates the speed limit for this composite
      • compressDimension

        public CoordI2 compressDimension()
        Compresses the dimension of this composite. A compressed composite has no unoccupied space around it's borders.
      • rotate

        public boolean rotate​(GameSession gameSession,
                              Edge2 direction)
        Rotates this composite entity
      • splitEntityGroups

        protected void splitEntityGroups​(GameSession gameSession)
        Splits this composite entity by connected areas to several separated copies, e.g. breaking down a composite after some entities have been destroyed
      • getUuid

        public UUID getUuid()
        UUID of this composite
      • setUuid

        public void setUuid​(UUID uuid)
      • setPosition

        public void setPosition​(CoordI2 position)
        Only use this setter to set the initial position right after WorldManager#create before the first Worldmanager#put. Directly setting the position in any other circumstance will make WorldManager inconsistent and will lead to errors. Use WorldManager#move instead.
      • setDimension

        public void setDimension​(CoordI2 dimension)
      • getVelocityVector

        public CoordD2 getVelocityVector()
      • setVelocityVector

        public void setVelocityVector​(CoordD2 velocityVector)
      • getPrecisePosition

        public CoordD2 getPrecisePosition()
      • setPrecisePosition

        public void setPrecisePosition​(CoordD2 precisePosition)
      • setEntityManager

        public void setEntityManager​(EntityManager entityManager)
      • isFresh

        public boolean isFresh()
      • setFresh

        public void setFresh​(boolean fresh)
      • isDirty

        public boolean isDirty()
      • setDirty

        public void setDirty​(boolean dirty)
      • isLocalInit

        public boolean isLocalInit()
      • isSplitEntityGroups

        public boolean isSplitEntityGroups()
      • setSplitEntityGroups

        public void setSplitEntityGroups​(boolean splitEntityGroups)
      • getAnimationOffset

        public CoordD2 getAnimationOffset()
      • getServerLastInViewPort

        public Map<UUID,​Integer> getServerLastInViewPort()
      • isRemoved

        public boolean isRemoved()
      • getFields

        public Fields getFields()
      • getPrevPosition

        public CoordI2 getPrevPosition()
      • setPrevPosition

        public void setPrevPosition​(CoordI2 prevPosition)
      • getAccelerationVector

        public CoordD2 getAccelerationVector()
      • setAccelerationVector

        public void setAccelerationVector​(CoordD2 accelerationVector)
      • isShadowed

        public boolean isShadowed()
      • setShadowed

        public void setShadowed​(boolean shadowed)
      • isPositionDirty

        public boolean isPositionDirty()
      • setPositionDirty

        public void setPositionDirty​(boolean positionDirty)
      • getLastRotation

        public int getLastRotation()
      • getLastRotationDirection

        public Edge2 getLastRotationDirection()
      • getServerScannedBy

        public Map<UUID,​Integer> getServerScannedBy()
      • getServerMeshesLastPublished

        public Map<UUID,​Integer> getServerMeshesLastPublished()
      • setServerMeshesLastPublished

        public void setServerMeshesLastPublished​(Map<UUID,​Integer> meshesLastPublished)
      • getCompositeEntityFactoryClassName

        public String getCompositeEntityFactoryClassName()
      • setCompositeEntityFactoryClassName

        public void setCompositeEntityFactoryClassName​(String compositeEntityFactoryClassName)
      • getServerFieldsLastPublished

        public Map<UUID,​Integer> getServerFieldsLastPublished()
      • setServerFieldsLastPublished

        public void setServerFieldsLastPublished​(Map<UUID,​Integer> serverFieldsLastPublished)
      • getLastEdited

        public String getLastEdited()
      • setLastEdited

        public void setLastEdited​(String version)
      • getSceneTag

        public UUID getSceneTag()
      • setSceneTag

        public void setSceneTag​(UUID sceneTag)