CmGameObjectHandle.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "CmPrerequisites.h"
  2. #include "CmGameObject.h"
  3. #include "CmGameObjectHandle.h"
  4. #include "CmException.h"
  5. #include "CmGameObjectHandleRTTI.h"
  6. namespace CamelotFramework
  7. {
  8. GameObjectHandleBase::GameObjectHandleBase(const std::shared_ptr<GameObjectHandleData>& data)
  9. :mData(data)
  10. { }
  11. GameObjectHandleBase::GameObjectHandleBase(const std::shared_ptr<GameObject> ptr)
  12. {
  13. mData = cm_shared_ptr<GameObjectHandleData, PoolAlloc>(ptr->mInstanceData);
  14. }
  15. GameObjectHandleBase::GameObjectHandleBase(std::nullptr_t ptr)
  16. {
  17. mData->mPtr = nullptr;
  18. }
  19. GameObjectHandleBase::GameObjectHandleBase()
  20. { }
  21. void GameObjectHandleBase::throwIfDestroyed() const
  22. {
  23. if(isDestroyed())
  24. {
  25. CM_EXCEPT(InternalErrorException, "Trying to access an object that has been destroyed.");
  26. }
  27. }
  28. RTTITypeBase* GameObjectHandleBase::getRTTIStatic()
  29. {
  30. return GameObjectHandleRTTI::instance();
  31. }
  32. RTTITypeBase* GameObjectHandleBase::getRTTI() const
  33. {
  34. return ResourceHandleBase::getRTTIStatic();
  35. }
  36. }