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 | #pragma once |
4 | |
5 | #include "BsCorePrerequisites.h" |
6 | #include "Audio/BsAudioListener.h" |
7 | #include "Scene/BsComponent.h" |
8 | |
9 | namespace bs |
10 | { |
11 | /** @addtogroup Components-Core |
12 | * @{ |
13 | */ |
14 | |
15 | /** |
16 | * @copydoc AudioListener |
17 | * |
18 | * @note Wraps AudioListener as a Component. |
19 | */ |
20 | class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Audio,n:AudioListener) CAudioListener : public Component |
21 | { |
22 | public: |
23 | CAudioListener(const HSceneObject& parent); |
24 | virtual ~CAudioListener() = default; |
25 | |
26 | /** @name Internal |
27 | * @{ |
28 | */ |
29 | |
30 | /** Returns the AudioListener implementation wrapped by this component. */ |
31 | AudioListener* _getInternal() const { return mInternal.get(); } |
32 | |
33 | /** @} */ |
34 | |
35 | /************************************************************************/ |
36 | /* COMPONENT OVERRIDES */ |
37 | /************************************************************************/ |
38 | protected: |
39 | friend class SceneObject; |
40 | |
41 | /** @copydoc Component::onInitialized() */ |
42 | void onInitialized() override; |
43 | |
44 | /** @copydoc Component::onDestroyed() */ |
45 | void onDestroyed() override; |
46 | |
47 | /** @copydoc Component::onDisabled() */ |
48 | void onDisabled() override; |
49 | |
50 | /** @copydoc Component::onEnabled() */ |
51 | void onEnabled() override; |
52 | |
53 | /** @copydoc Component::onTransformChanged() */ |
54 | void onTransformChanged(TransformChangedFlags flags) override; |
55 | |
56 | /** @copydoc Component::update() */ |
57 | void update() override; |
58 | protected: |
59 | using Component::destroyInternal; |
60 | |
61 | /** Creates the internal representation of the AudioListener and restores the values saved by the Component. */ |
62 | void restoreInternal(); |
63 | |
64 | /** Destroys the internal AudioListener representation. */ |
65 | void destroyInternal(); |
66 | |
67 | /** |
68 | * Updates the transform of the internal AudioListener representation from the transform of the component's scene |
69 | * object. |
70 | */ |
71 | void updateTransform(); |
72 | |
73 | SPtr<AudioListener> mInternal; |
74 | Vector3 mLastPosition = Vector3::ZERO; |
75 | Vector3 mVelocity = Vector3::ZERO; |
76 | |
77 | /************************************************************************/ |
78 | /* RTTI */ |
79 | /************************************************************************/ |
80 | public: |
81 | friend class CAudioListenerRTTI; |
82 | static RTTITypeBase* getRTTIStatic(); |
83 | RTTITypeBase* getRTTI() const override; |
84 | |
85 | protected: |
86 | CAudioListener(); // Serialization only |
87 | }; |
88 | |
89 | /** @} */ |
90 | } |