class GameObjectHandle

Inherits: IReflectable

A handle that can point to various types of game objects.

It primarily keeps track if the object is still alive, so anything still referencing it doesn't accidentally use it.

Public

Constructors

GameObjectHandle

GameObjectHandle()

Methods

IsDestroyed

bool IsDestroyed(bool checkQueued = false) const

Returns true if the object the handle is pointing to has been destroyed.

checkQueued
Game objects can be queued for destruction but not actually destroyed yet, and still accessible. If this is false this method will return true only if the object is completely inaccessible (fully destroyed). If this is true this method will return true if object is completely inaccessible or if it is just queued for destruction.

IsValid

bool IsValid() const

Returns true if the handle points to a non-null object and the object is not queued for destruction.

GetId

const UUID &GetId() const

Returns the globally unique ID of the object the handle is referencing.

Get

GameObject *Get() const

Returns pointer to the referenced GameObject.

GetShared

SPtr<GameObject> GetShared() const

Returns the shared pointer to the referenced GameObject.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Operators

operator->

GameObject *operator->() const

Returns pointer to the referenced GameObject.

operator*

GameObject &operator*() const

Returns reference to the referenced GameObject.

Internal

Methods

GetSharedHandleData

const SPtr<GameObjectHandleData> &GetSharedHandleData() const

Returns internal handle data.

ClearObjectInstanceData

void ClearObjectInstanceData()

Clears the handle so it doesn't point to any object.

Note this will affect any other handles sharing the handle data.

SetObjectInstanceData

void SetObjectInstanceData(const SPtr<GameObject> &object)

Updates the handle so it points to the provided object.

Note this will affect any other handles sharing the handle data.

SetObjectInstanceData

void SetObjectInstanceData(const GameObjectHandle &other)

Updates the handle so it points to the same object as the provided object.

Compared to the other overload of this method, this one has the advantage that its able to handle objects have been destroyed. The handle data will remain to be valid in case the object is later resurrected.

Note this will affect any other handles sharing the handle data.

Protected

Constructors

GameObjectHandle

GameObjectHandle(const SPtr<GameObject> &object)

GameObjectHandle

GameObjectHandle(SPtr<GameObjectHandleData> sharedHandleData)

GameObjectHandle

GameObjectHandle(std::nullptr_t)

Fields

mSharedHandleData

SPtr<GameObjectHandleData> mSharedHandleData

Data shared between a set of handles pointing the referenced object.