1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#include "BsCorePrerequisites.h"
4#include "Scene/BsGameObject.h"
5#include "Scene/BsGameObjectHandle.h"
6#include "Error/BsException.h"
7#include "Scene/BsGameObject.h"
8#include "Private/RTTI/BsGameObjectHandleRTTI.h"
9
10namespace bs
11{
12 GameObjectHandleBase::GameObjectHandleBase(const SPtr<GameObject>& ptr)
13 {
14 mData = bs_shared_ptr_new<GameObjectHandleData>(ptr->mInstanceData);
15 }
16
17 bool GameObjectHandleBase::isDestroyed(bool checkQueued) const
18 {
19 return mData->mPtr == nullptr || mData->mPtr->object == nullptr
20 || (checkQueued && mData->mPtr->object->_getIsDestroyed());
21 }
22
23 void GameObjectHandleBase::_setHandleData(const SPtr<GameObject>& object)
24 {
25 mData->mPtr = object->mInstanceData;
26 }
27
28 void GameObjectHandleBase::throwIfDestroyed() const
29 {
30 if(isDestroyed())
31 {
32 BS_EXCEPT(InternalErrorException, "Trying to access an object that has been destroyed.");
33 }
34 }
35
36 RTTITypeBase* GameObjectHandleBase::getRTTIStatic()
37 {
38 return GameObjectHandleRTTI::instance();
39 }
40
41 RTTITypeBase* GameObjectHandleBase::getRTTI() const
42 {
43 return GameObjectHandleBase::getRTTIStatic();
44 }
45}