Entity
// An object used in a scene or overlay. An entity has no functionality of its own, but uses components
// to provide functionality. An entity can be part of a hierarchy and have a super entity (parent) and
// sub entities (children). The engine owns entities after they are added to a scene or overlay, so they
// don't have to be explicity destroyed. Entity usage must be after a scene is finalized and before the
// scene is released.
class RVAPI Entity
{
public:
// Get key.
EntKey GetKey() const;
// Get externally assigned type id.
uint GetType() const;
// Get subentity count.
uint GetSubEntCount() const;
// Get super entity.
template<typename K = Entity>
K &GetSupEnt() const { return (K &)GetSupEnt_(); }
// Get entity subentity at [n].
template<typename K = Entity>
K &GetSubEnt(uint n) const { return (K &)GetSubEnt_(n); }
// Remove all subentities.
void ClearSubEnts();
// Manually Forward update entity. Also update subentities if [recur] is true.
void Forward(bool recur = true);
// Manually Reverse update entity. Also update subentities if [recur] is true.
void Reverse(bool recur = true);
// Destroy entity at end of scene updates.
void Destroy();
// Internal.
void *operator () () const;
// Internal.
static uint reserved();
// Constructor.
Entity();
// Destructor.
virtual ~Entity();
protected:
// Forward callback.
virtual void OnForward() {}
// Reverse callback.
virtual void OnReverse() {}
// Serialization callback.
virtual void OnSerialize(File &/*file*/) const {}
private:
Entity &GetSupEnt_() const;
Entity &GetSubEnt_(uint n) const;
friend class EntityBridge;
};