Class WorldEntity

java.lang.Object
eu.iv4xr.framework.mainConcepts.WorldEntity
All Implemented Interfaces:
Serializable

public class WorldEntity extends Object implements Serializable
See Also:
Serialized Form
  • Field Details

    • id

      public final String id
      A unique id identifying this entity.
    • type

      public final String type
      The type-name of the entity, e.g. "door".
    • timestamp

      public long timestamp
      Represent the last time the state of this entity is sampled.
    • lastStutterTimestamp

      public long lastStutterTimestamp
      The last time the state of this entity is sampled, after which its state is always sampled to be the same as its current state (the start of stutter period towards the current state). If the value is -1, if this time is not known.
    • position

      public Vec3 position
      The center position of this entity,
    • extent

      public Vec3 extent
      Bounding box of this entity.
    • velocity

      public Vec3 velocity
    • dynamic

      public final boolean dynamic
      If true then this entity is "dynamic", which means that its state may change at the runtime. Note that an entity does not have to be moving (having velocity) to be dynamic.
    • properties

      public Map<String,​Serializable> properties
    • elements

      public Map<String,​WorldEntity> elements
  • Constructor Details

    • WorldEntity

      public WorldEntity(String id, String type, boolean dynamic)
  • Method Details

    • hasSameState

      public boolean hasSameState(WorldEntity old)
      Let e be non-null and represent the same entity as this entity (they have the same ID), but its state is possibly different than this entity. This method checks if both entity have the same state. Dynamic entity is assumed not to change state. Else this method first check the hash-value of both entities. If they are the same, this method performs deep comparison of position, velocity, properties, and sub-entities. This might be a bit expensive; override this method if a faster implementation is wanted.
    • getProperty

      public Serializable getProperty(String propertyName)
    • getBooleanProperty

      public boolean getBooleanProperty(String propertyName)
    • getStringProperty

      public String getStringProperty(String propertyName)
    • getIntProperty

      public int getIntProperty(String propertyName)
    • linkPreviousState

      public void linkPreviousState(WorldEntity e)
      This will link e as the previous state of this Entity. The previous state of e is cleared to null (we only want to track the history of past state up to length 1). This method assume that e represents the same Entity as this Entity (e.g. they have the same id).
    • getPreviousState

      public WorldEntity getPreviousState()
      Return a WorldEntity representing this entity's previous state, if that is tracked.
    • hasChangedState

      public boolean hasChangedState()
      True if this entity has no previous state, or if its state differs from its previous. Note that we only track 1x previous state (so there is no longer chain of previous states).
    • hasPreviousState

      public boolean hasPreviousState()
    • assignTimeStamp

      public void assignTimeStamp(long ts)
      Set the time-stamp of this Entity and its elements to the given time.
    • isMovingEntity

      public boolean isMovingEntity()
      If true then this entity is a moving entity. This is defined as having a non-null velocity. Note that the entity may still have a zero velocity; but it will still be classified as "moving".
    • hashCode

      public int hashCode()
      The hashcode of this Entity.
      Overrides:
      hashCode in class Object
    • deepclone

      public WorldEntity deepclone() throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • toString

      public String toString()
      Overrides:
      toString in class Object