Module SypherEngine

Class Entity

java.lang.Object
dev.aurumbyte.sypherengine.ecs.Entity
All Implemented Interfaces:
IRenderable
Direct Known Subclasses:
Sprite2D, UIElement

public abstract class Entity extends Object implements IRenderable

The base entity class, which all game entities must extend

Since:
0.3.0
Author:
AurumByte
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) javafx.geometry.Rectangle2D
    Deprecated. 
    (package private) List<Component>
    The components of each entity
    float
    height of the entity
    (package private) boolean
    Whether the entity is no longer needed or not
    The KeyListener for the current entity, which is an instance passed by the gamemanager
    The MouseListener for the current entity, which is an instance passed by the gamemanager
    (package private) Vector2
    Position of the entity
    float
    Rotation of the entity
    (package private) float
    Scale of the entity
    (package private) String
    Entity tag, to help identify multiple entities from one another
    float
    width of the entity
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a component to the entity
    void
    addComponents(Component... components)
    Adds multiple components to the entity
    void
    Adds multiple components to the entity
    boolean
    Deprecated.
    Gets the center of the entity
    Gets the components of the entity
    double
    Gets the height of the entity
    Gets the position of the entity (where its drawn)
    float
    Gets the rotation of the entity
    float
    Gets the scale of the entity
    Gets the tag (name) of the entity
    double
    Gets the width of the entity
    boolean
    Return if the entity is no longer used or not
    abstract void
    The entity's render loop
    void
    rotate(float rotation)
    Sets the rotation of the entity (rotates the entity)
    void
    setBoundary(int xPos, int yPos, int width, int height)
    Deprecated.
    void
    setBoundary(javafx.geometry.Rectangle2D boundary)
    Deprecated.
    void
    setHeight(float height)
    Sets the height of the entity
    void
    setIsDead(boolean dead)
    Set whether the entity is being used or not
    void
    setPosition(float xPos, float yPos)
    Sets the position of the entity (where its drawn)
    void
    setScale(float scale)
    Sets the scale of the entity
    void
    Sets the entity's tag
    void
    setWidth(float width)
    Sets the width of the entity
     
    abstract void
    update(float deltaTime)
    The entity's update loop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • keyListener

      public KeyListener keyListener
      The KeyListener for the current entity, which is an instance passed by the gamemanager
    • mouseListener

      public MouseListener mouseListener
      The MouseListener for the current entity, which is an instance passed by the gamemanager
    • position

      Vector2 position
      Position of the entity
    • rotation

      public float rotation
      Rotation of the entity
    • scale

      float scale
      Scale of the entity
    • width

      public float width
      width of the entity
    • height

      public float height
      height of the entity
    • isDead

      boolean isDead
      Whether the entity is no longer needed or not
    • tag

      String tag
      Entity tag, to help identify multiple entities from one another
    • components

      List<Component> components
      The components of each entity
    • boundary

      @Deprecated javafx.geometry.Rectangle2D boundary
      Deprecated.
      Boundary of the entity
  • Constructor Details

    • Entity

      public Entity()
  • Method Details

    • update

      public abstract void update(float deltaTime)

      The entity's update loop

      Specified by:
      update in interface IRenderable
      Parameters:
      deltaTime - The deltaTime
      Since:
      0.3.0
    • render

      public abstract void render(SypherEngine engine)

      The entity's render loop

      Specified by:
      render in interface IRenderable
      Parameters:
      engine - the main engine
      Since:
      0.3.0
    • getPosition

      public Vector2 getPosition()

      Gets the position of the entity (where its drawn)

      Since:
      0.3.0
    • setPosition

      public void setPosition(float xPos, float yPos)

      Sets the position of the entity (where its drawn)

      Parameters:
      xPos - The position of the entity (x coord)
      yPos - The position of the entity (y coord)
      Since:
      0.3.0
    • setHeight

      public void setHeight(float height)

      Sets the height of the entity

      Parameters:
      height - The new height of the entity
      Since:
      0.3.0
    • setWidth

      public void setWidth(float width)

      Sets the width of the entity

      Parameters:
      width - The new width of the entity
      Since:
      0.3.0
    • setScale

      public void setScale(float scale)

      Sets the scale of the entity

      Parameters:
      scale - The new scale of the entity
      Since:
      0.3.0
    • rotate

      public void rotate(float rotation)

      Sets the rotation of the entity (rotates the entity)

      Parameters:
      rotation - The value by which the object should be rotated
      Since:
      0.3.0
    • getRotation

      public float getRotation()

      Gets the rotation of the entity

      Since:
      0.3.0
    • getScale

      public float getScale()

      Gets the scale of the entity

      Since:
      0.3.0
    • getCenter

      public Vector2 getCenter()

      Gets the center of the entity

      Since:
      0.3.0
    • getWidth

      public double getWidth()

      Gets the width of the entity

      Since:
      0.3.0
    • getHeight

      public double getHeight()

      Gets the height of the entity

      Since:
      0.3.0
    • getTag

      public String getTag()

      Gets the tag (name) of the entity

      Since:
      0.3.0
    • getComponents

      public List<Component> getComponents()

      Gets the components of the entity

      Since:
      0.3.0
    • addComponent

      public void addComponent(Component component)

      Adds a component to the entity

      Parameters:
      component - The component to be added
      Since:
      0.3.0
    • addComponents

      public void addComponents(Component... components)

      Adds multiple components to the entity

      Parameters:
      components - The components to be added
      Since:
      0.3.0
    • addComponents

      public void addComponents(List<Component> components)

      Adds multiple components to the entity

      Parameters:
      components - The components to be added
      Since:
      0.3.0
    • isDead

      public boolean isDead()

      Return if the entity is no longer used or not

      Since:
      0.3.0
    • setIsDead

      public void setIsDead(boolean dead)

      Set whether the entity is being used or not

      Parameters:
      dead - Toggle whether the entity is used or not
      Since:
      0.3.0
    • setBoundary

      @Deprecated public void setBoundary(javafx.geometry.Rectangle2D boundary)
      Deprecated.
    • setBoundary

      @Deprecated public void setBoundary(int xPos, int yPos, int width, int height)
      Deprecated.
    • setTag

      public void setTag(String tag)

      Sets the entity's tag

      Parameters:
      tag - The new tag of the entity
      Since:
      0.3.0
    • collidesWith

      @Deprecated public boolean collidesWith(Entity other)
      Deprecated.
    • toString

      public String toString()
      Overrides:
      toString in class Object