BsComponent.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsComponent.h"
  4. #include "BsSceneObject.h"
  5. #include "BsComponentRTTI.h"
  6. namespace BansheeEngine
  7. {
  8. Component::Component(const HSceneObject& parent)
  9. :mParent(parent), mNotifyFlags(TCF_None)
  10. {
  11. setName("Component");
  12. }
  13. Component::~Component()
  14. {
  15. }
  16. bool Component::typeEquals(const Component& other)
  17. {
  18. return getRTTI()->getRTTIId() == other.getRTTI()->getRTTIId();
  19. }
  20. bool Component::calculateBounds(Bounds& bounds)
  21. {
  22. Vector3 position = SO()->getWorldPosition();
  23. bounds = Bounds(AABox(position, position), Sphere(position, 0.0f));
  24. return false;
  25. }
  26. void Component::destroy(bool immediate)
  27. {
  28. SO()->destroyComponent(this, immediate);
  29. }
  30. void Component::destroyInternal(GameObjectHandleBase& handle, bool immediate)
  31. {
  32. if (immediate)
  33. GameObjectManager::instance().unregisterObject(handle);
  34. else
  35. GameObjectManager::instance().queueForDestroy(handle);
  36. }
  37. RTTITypeBase* Component::getRTTIStatic()
  38. {
  39. return ComponentRTTI::instance();
  40. }
  41. RTTITypeBase* Component::getRTTI() const
  42. {
  43. return Component::getRTTIStatic();
  44. }
  45. }