v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
71
source/game/StarAmbient.hpp
Normal file
71
source/game/StarAmbient.hpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef STAR_AMBIENT_HPP
|
||||
#define STAR_AMBIENT_HPP
|
||||
|
||||
#include "StarJson.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
STAR_CLASS(AudioInstance);
|
||||
STAR_STRUCT(AmbientTrackGroup);
|
||||
STAR_STRUCT(AmbientNoisesDescription);
|
||||
STAR_CLASS(AmbientManager);
|
||||
|
||||
struct AmbientTrackGroup {
|
||||
AmbientTrackGroup();
|
||||
AmbientTrackGroup(StringList tracks);
|
||||
AmbientTrackGroup(Json const& config, String const& directory = "");
|
||||
|
||||
Json toJson() const;
|
||||
|
||||
StringList tracks;
|
||||
};
|
||||
|
||||
// represents the ambient sounds data for a biome
|
||||
struct AmbientNoisesDescription {
|
||||
AmbientNoisesDescription();
|
||||
AmbientNoisesDescription(AmbientTrackGroup day, AmbientTrackGroup night);
|
||||
AmbientNoisesDescription(Json const& config, String const& directory = "");
|
||||
|
||||
Json toJson() const;
|
||||
|
||||
AmbientTrackGroup daySounds;
|
||||
AmbientTrackGroup nightSounds;
|
||||
};
|
||||
|
||||
typedef AmbientTrackGroup WeatherNoisesDescription;
|
||||
typedef shared_ptr<WeatherNoisesDescription> WeatherNoisesDescriptionPtr;
|
||||
|
||||
// manages the running ambient sounds
|
||||
class AmbientManager {
|
||||
public:
|
||||
// Automatically calls cancelAll();
|
||||
~AmbientManager();
|
||||
|
||||
void setTrackSwitchGrace(float grace);
|
||||
void setTrackFadeInTime(float fadeInTime);
|
||||
|
||||
// Returns a new AudioInstance if a new ambient sound is to be started.
|
||||
AudioInstancePtr updateAmbient(AmbientNoisesDescriptionPtr current, bool dayTime = false);
|
||||
AudioInstancePtr updateWeather(WeatherNoisesDescriptionPtr current);
|
||||
void cancelAll();
|
||||
|
||||
void setVolume(float volume, float delay, float duration);
|
||||
|
||||
private:
|
||||
AudioInstancePtr m_currentTrack;
|
||||
AudioInstancePtr m_weatherTrack;
|
||||
String m_currentTrackName;
|
||||
String m_weatherTrackName;
|
||||
float m_trackFadeInTime = 0.0f;
|
||||
float m_trackSwitchGrace = 0.0f;
|
||||
double m_trackGraceTimestamp = 0;
|
||||
Deque<String> m_recentTracks;
|
||||
float m_volume = 1.0f;
|
||||
float m_delay = 0.0f;
|
||||
float m_duration = 0.0f;
|
||||
bool m_volumeChanged = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue