| 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 "Scene/BsComponent.h" | 
| 4 | #include "Scene/BsSceneObject.h" | 
| 5 | #include "Private/RTTI/BsComponentRTTI.h" | 
| 6 | |
| 7 | namespace bs | 
| 8 | { | 
| 9 | Component::Component(HSceneObject parent) | 
| 10 | :mParent(std::move(parent)) | 
| 11 | { | 
| 12 | setName( "Component"); | 
| 13 | } | 
| 14 | |
| 15 | bool Component::typeEquals(const Component& other) | 
| 16 | { | 
| 17 | return getRTTI()->getRTTIId() == other.getRTTI()->getRTTIId(); | 
| 18 | } | 
| 19 | |
| 20 | bool Component::calculateBounds(Bounds& bounds) | 
| 21 | { | 
| 22 | Vector3 position = SO()->getTransform().getPosition(); | 
| 23 | |
| 24 | bounds = Bounds(AABox(position, position), Sphere(position, 0.0f)); | 
| 25 | return false; | 
| 26 | } | 
| 27 | |
| 28 | void Component::destroy(bool immediate) | 
| 29 | { | 
| 30 | SO()->destroyComponent(this, immediate); | 
| 31 | } | 
| 32 | |
| 33 | void Component::destroyInternal(GameObjectHandleBase& handle, bool immediate) | 
| 34 | { | 
| 35 | if (immediate) | 
| 36 | GameObjectManager::instance().unregisterObject(handle); | 
| 37 | else | 
| 38 | GameObjectManager::instance().queueForDestroy(handle); | 
| 39 | } | 
| 40 | |
| 41 | RTTITypeBase* Component::getRTTIStatic() | 
| 42 | { | 
| 43 | return ComponentRTTI::instance(); | 
| 44 | } | 
| 45 | |
| 46 | RTTITypeBase* Component::getRTTI() const | 
| 47 | { | 
| 48 | return Component::getRTTIStatic(); | 
| 49 | } | 
| 50 | } | 
