From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Audio/AudioListener.h | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Runtime/Audio/AudioListener.h (limited to 'Runtime/Audio/AudioListener.h') diff --git a/Runtime/Audio/AudioListener.h b/Runtime/Audio/AudioListener.h new file mode 100644 index 0000000..187ddb4 --- /dev/null +++ b/Runtime/Audio/AudioListener.h @@ -0,0 +1,62 @@ +#ifndef __AUDIOLISTENER_H__ +#define __AUDIOLISTENER_H__ + +#if ENABLE_AUDIO + +#include "Runtime/GameCode/Behaviour.h" +#include "Runtime/Math/Vector3.h" +#include "AudioBehaviour.h" + +class Transform; + +class AudioListener : public AudioBehaviour +{ +public: + + REGISTER_DERIVED_CLASS (AudioListener, AudioBehaviour) + DECLARE_OBJECT_SERIALIZE (AudioListener) + + AudioListener (MemLabelId label, ObjectCreationMode mode); + // virtual ~AudioListener (); declared-by-macro + + void AwakeFromLoad (AwakeFromLoadMode awakeMode); + int GetVelocityUpdateMode() const { return m_VelocityUpdateMode; } + void SetVelocityUpdateMode(int update) { m_VelocityUpdateMode=update; } + + // Behaviour + virtual void Update(); + virtual void FixedUpdate(); + + ListNode& GetNode() { return m_Node; } + + const Vector3f& GetPosition() const { return m_LastPosition; } + + void OnAddComponent(); + + static void InitializeClass (); + static void CleanupClass(); + + void Cleanup(); + + void SetAlternativeTransform(Transform* t); + +private: + virtual void AddToManager (); + virtual void RemoveFromManager (); + void DoUpdate (); + void ApplyFilters(); + +private: + Vector3f m_LastPosition; + int m_VelocityUpdateMode; + + PPtr m_AltTransform; + const Transform& GetCurrentTransform() const; + + ListNode m_Node; + + friend class AudioManager; +}; + +#endif //ENABLE_AUDIO +#endif // __AUDIOLISTENER_H__ -- cgit v1.1-26-g67d0