/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/EnginePlugins/MiniAudioPlugin/Components/MiniAudioSoundComponent.h
119 строк
4 KB
Jan Krassnigg
Fixed several public header includes (#1753)
03 янв 2026, 21:23
Не верифицирован
03 янв 2026, 21:23
1a4bcb1
Код
Авторство
О чём код?
#pragma once #include <Core/ResourceManager/ResourceHandle.h> #include <Core/World/Component.h> #include <Core/World/ComponentManager.h> #include <MiniAudioPlugin/MiniAudioPluginDLL.h> struct ezMiniAudioSoundInstance; using ezMiniAudioSoundResourceHandle = ezTypedResourceHandle<class ezMiniAudioSoundResource>; class ezMiniAudioSoundComponentManager : public ezComponentManager<class ezMiniAudioSoundComponent, ezBlockStorageType::FreeList> { public: ezMiniAudioSoundComponentManager(ezWorld* pWorld); virtual void Initialize() override; virtual void Deinitialize() override; private: friend class ezMiniAudioSoundComponent; void UpdateEvents(const ezWorldModule::UpdateContext& context); ezUInt32 m_uiFirstComponentIndex = 0; }; ////////////////////////////////////////////////////////////////////////// class EZ_MINIAUDIOPLUGIN_DLL ezMiniAudioSoundComponent : public ezComponent { EZ_DECLARE_COMPONENT_TYPE(ezMiniAudioSoundComponent, ezComponent, ezMiniAudioSoundComponentManager); ////////////////////////////////////////////////////////////////////////// // ezComponent public: virtual void SerializeComponent(ezWorldWriter& inout_stream) const override; virtual void DeserializeComponent(ezWorldReader& inout_stream) override; protected: virtual void OnSimulationStarted() override; virtual void OnDeactivated() override; ////////////////////////////////////////////////////////////////////////// // ezMiniAudioComponent private: friend class ezComponentManagerSimple<class ezMiniAudioSoundComponent, ezComponentUpdateType::WhenSimulating>; ////////////////////////////////////////////////////////////////////////// // ezMiniAudioSoundComponent public: ezMiniAudioSoundComponent(); ~ezMiniAudioSoundComponent(); void SetPaused(bool b); // [ property ] bool GetPaused() const { return m_bPaused; } // [ property ] void SetPitch(float f); // [ property ] float GetPitch() const { return m_fPitch; } // [ property ] void SetVolume(float f); // [ property ] float GetVolume() const { return m_fComponentVolume; } // [ property ] /// \brief If set, the global game speed does not affect the pitch of this event. /// /// This is important for global sounds, such as music or UI effects, so that they always play at their regular speed, /// even when the game is in slow motion. void SetNoGlobalPitch(bool bEnable); // [ property ] bool GetNoGlobalPitch() const; // [ property ] ezEnum<ezOnComponentFinishedAction2> m_OnFinishedAction; // [ property ] /// \brief Makes the sound play. /// /// If it was not yet playing, it starts playing a new sound. /// If it was already playing, but paused, playback is resumed. /// If it was already playing, there is no change. void Play(); // [ scriptable ] /// \brief If a sound is playing, it pauses at the current play position. /// /// Call Play() to resume playing. void Pause(); // [ scriptable ] /// \brief Interrupts the sound playback abruptly. void Stop(); // [ scriptable ] /// \brief Stops the sound, by fading it out over a short period. void FadeOut(ezTime fadeDuration); // [ scriptable ] /// \brief Plays a completely new sound at the location of this component and with all its current properties. /// /// Pitch, volume, position and direction are copied to the new sound instance. /// The new sound then plays to the end and cannot be controlled through this component any further. /// No sound should be playing on this component, when using this function. void StartOneShot(); // [ scriptable ] protected: void OnMsgDeleteGameObject(ezMsgDeleteGameObject& msg); // [ msg handler ] void Update(); void UpdateParameters(ezMiniAudioSoundInstance* pInstance, float fVolume, float fPitch) const; friend class ezMiniAudioSingleton; void SoundFinished(); ezMiniAudioSoundResourceHandle m_hSound; float m_fComponentVolume = 1.0f; float m_fPitch = 1.0f; float m_fResourceVolume = 1.0f; float m_fResourcePitch = 1.0f; bool m_bPaused = false; ezMiniAudioSoundInstance* m_pInstance = nullptr; };