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 "Components/BsCSkybox.h"
4#include "Private/RTTI/BsCSkyboxRTTI.h"
5#include "Scene/BsSceneManager.h"
6#include "Renderer/BsSkybox.h"
7
8namespace bs
9{
10 CSkybox::CSkybox()
11 {
12 setFlag(ComponentFlag::AlwaysRun, true);
13 setName("Skybox");
14 }
15
16 CSkybox::CSkybox(const HSceneObject& parent)
17 : Component(parent)
18 {
19 setFlag(ComponentFlag::AlwaysRun, true);
20 setName("Skybox");
21 }
22
23 CSkybox::~CSkybox()
24 {
25 mInternal->destroy();
26 }
27
28 void CSkybox::onInitialized()
29 {
30 // If mInternal already exists this means this object was deserialized,
31 // so all we need to do is initialize it.
32 if (mInternal != nullptr)
33 mInternal->initialize();
34 else
35 mInternal = Skybox::create();
36
37 gSceneManager()._bindActor(mInternal, sceneObject());
38 }
39
40 void CSkybox::onDestroyed()
41 {
42 gSceneManager()._unbindActor(mInternal);
43 }
44
45 RTTITypeBase* CSkybox::getRTTIStatic()
46 {
47 return CSkyboxRTTI::instance();
48 }
49
50 RTTITypeBase* CSkybox::getRTTI() const
51 {
52 return CSkybox::getRTTIStatic();
53 }
54}
55