Class AbstractEntity

    • Constructor Detail

      • AbstractEntity

        public AbstractEntity​(byte spriteId)
        Create an abstractEntity.
        Parameters:
        spriteId - objects with id = -1 will be deleted. 0 are invisible objects
      • AbstractEntity

        public AbstractEntity​(byte spriteId,
                              byte value)
        Create an abstractEntity.
        Parameters:
        spriteId - objects with id -1 are to be deleted. 0 are invisible objects
        value -
    • Method Detail

      • registerEngineEntities

        public static void registerEngineEntities​()
        Registers engine entities in a map.
      • registerEntity

        public static void registerEntity​(java.lang.String name,
                                          java.lang.Class<? extends AbstractEntity> entityClass)
        Register a class of entities. The class must have a constructor without parameters.
        Parameters:
        name - the name of the entitie. e.g. "Ball"
        entityClass - the class you want to register
      • getRegisteredEntities

        public static java.util.HashMap<java.lang.String,java.lang.Class<? extends AbstractEntity>> getRegisteredEntities​()
        Get a map of the registered entities
        Returns:
      • update

        public void update​(float dt)
        Updates the logic of the object.
        Parameters:
        dt - time since last update in game time
      • setPosition

        public void setPosition​(Position pos)
        Description copied from class: AbstractGameObject
        Set the coordinates without safety check. May use different object pointing to the same position.
        Specified by:
        setPosition in class AbstractGameObject
        Parameters:
        pos - the coordinates you want to set
      • setPosition

        public void setPosition​(Point pos)
        keeps the reference
        Parameters:
        pos -
      • isOnGround

        public boolean isOnGround​()
        Is the entity laying/standing on the ground?
        Returns:
        true when on the ground. False if in air or not in memory.
      • spawn

        public AbstractEntity spawn​(Point point)
        Add this entity to the map-> let it spawn
        Parameters:
        point - the point in the game world where the object is. If it was previously set this is ignored.
        Returns:
        returns itself
      • hasPosition

        public boolean hasPosition​()
        Is the object active on the map? If you spawn the object it has a position afterwards
        Returns:
      • setSpriteCategory

        public void setSpriteCategory​(char c)
        Set the spriteCategory used for the lookup of the sprite.
        Parameters:
        c -
      • setName

        public void setName​(java.lang.String name)
        Parameters:
        name -
      • setDimensionZ

        public void setDimensionZ​(int dimensionZ)
        Set the height of the object.
        Parameters:
        dimensionZ - game space
      • isSavedPersistent

        public boolean isSavedPersistent​()
        Is the oject saved on the map?
        Returns:
        true if savedin map file.
      • setSavePersistent

        public void setSavePersistent​(boolean persisent)
        Mark objects to not be saved in disk. Gets passed to the children. Temp objects should not be saved.
        Parameters:
        persisent - new value of persisent
      • getMass

        public float getMass​()
        Get the mass of the object.
        Returns:
        in kg
      • setMass

        public void setMass​(float mass)
        Parameters:
        mass - in kg
      • isIndestructible

        public boolean isIndestructible​()
        If the object can not be damaged. Object can still be disposed and removed from map.
        Returns:
      • setIndestructible

        public void setIndestructible​(boolean indestructible)
        If the object can not be damaged. Object can still be disposed and removed from map.
        Parameters:
        indestructible -
      • takeDamage

        public void takeDamage​(byte value)
        Called when gets damage. Health is between 0 and 100. Plays a sound. It is recommended to use an event to trigger the damaging so that each object manages it's own damage. If is set to indestructible via setIndestructible(boolean) can not be damaged.
        Parameters:
        value - between 0 and 100
        See Also:
        isIndestructible()
      • setDamageSounds

        public void setDamageSounds​(java.lang.String[] sound)
        Parameters:
        sound -
      • heal

        public void heal​(byte value)
        Heals the entity. to-do: should be replaced with messages/events
        Parameters:
        value -
      • getLightlevelR

        public float getLightlevelR​()
        Description copied from class: AbstractGameObject
        How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.
        Specified by:
        getLightlevelR in class AbstractGameObject
        Returns:
        1 is default bright. 0 is black.
      • getLightlevelG

        public float getLightlevelG​()
        Description copied from class: AbstractGameObject
        How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.
        Specified by:
        getLightlevelG in class AbstractGameObject
        Returns:
        1 is default bright. 0 is black.
      • getLightlevelB

        public float getLightlevelB​()
        Description copied from class: AbstractGameObject
        How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.
        Specified by:
        getLightlevelB in class AbstractGameObject
        Returns:
        1 is default bright. 0 is black.
      • setLightlevel

        public void setLightlevel​(float lightlevel)
        Description copied from class: AbstractGameObject
        Set the brightness of the object. The lightlevel is a scaling factor. 1 is default value.
        Specified by:
        setLightlevel in class AbstractGameObject
        Parameters:
        lightlevel - 1 is default bright. 0 is black.
      • getHealth

        public float getHealth​()
        Returns:
        from maximum 100
      • setHealth

        public void setHealth​(float health)
        clamps to [0..100]. You may prefer damage and heal(byte). Ignores invincibility.
        Parameters:
        health -
        See Also:
        takeDamage(byte)
      • setUseRawDelta

        public void setUseRawDelta​(boolean useRawDelta)
        Parameters:
        useRawDelta -
      • useRawDelta

        public boolean useRawDelta​()
        Returns:
      • requestChunk

        public void requestChunk​()
        loads the chunk at the position
      • getCollidingEntities

        public java.util.LinkedList<AbstractEntity> getCollidingEntities​()
        * get every entity which is colliding
        Returns:
      • getCollidingEntities

        public <T> java.util.LinkedList<T> getCollidingEntities​(java.lang.Class<T> filter)
        O(n) n:amount of entities. ignores if is obstacle.
        Type Parameters:
        T -
        Parameters:
        filter - only where the filter is true is returned
        Returns:
      • collidesWith

        public boolean collidesWith​(AbstractEntity ent)
        spherical collision check
        Parameters:
        ent -
        Returns:
      • getCoveredBlocks

        public java.util.LinkedList<RenderCell> getCoveredBlocks​(RenderStorage rs)
        get the blocks which must be rendered before
        Parameters:
        rs -
        Returns:
      • addComponent

        public void addComponent​(Component component)
        Parameters:
        component -
      • getComponents

        public <T extends ComponentComponent getComponents​(java.lang.Class<T> filterType)
        Type Parameters:
        T -
        Parameters:
        filterType -
        Returns:
      • getComponents

        public java.util.LinkedList<Component> getComponents​()
      • removeComponent

        public void removeComponent​(Component component)
        Parameters:
        component -
      • shouldBeDisposed

        public boolean shouldBeDisposed​()
        false if in update list of map.
        Returns:
        true if disposing next tick
        See Also:
        dispose()
      • dispose

        public void dispose​()
        Deletes the object from the map and every other container. The opposite to spawn() but also sets a flag to remove it completely.
        See Also:
        shouldBeDisposed(), removeFromMap()
      • setSpriteId

        public void setSpriteId​(byte id)
        Parameters:
        id -
      • setSpriteValue

        public void setSpriteValue​(byte value)
        Parameters:
        value -
      • isMarkedDS

        public final boolean isMarkedDS​(int id)
        Check if it is marked in this frame. Used for depth sorting.
        Parameters:
        id - camera id
        Returns:
        See Also:
        TopologicalSort.visit(TopoGraphNode)
      • markAsVisitedDS

        public void markAsVisitedDS​(int id)
        Marks as visited in the depth sorting algorithm.
        Parameters:
        id - camera id
        See Also:
        TopologicalSort.visit(TopoGraphNode)