AtmosphereManager
A class in Root.Township, Alta.Environmental.Atmosphere.
Runs the scene's atmosphere plugins (ambient light, fog, sky, ambient audio) and blends between atmosphere sets as the local player moves between chunks. A single instance in AtmosphereManager.instance; does its visible work on clients.
- Listed in World, chunks and saving
- Inherits or implements
NetworkEntityBehaviour - Nested types
ResolveAtmosphere - Documented in Time and environment
Constructors
| Member | What it is |
|---|---|
AtmosphereManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static AtmosphereManager instance | The current manager, set on Awake and Initialize. |
9 private and internal fields
| Member | What it is |
|---|---|
private float ambienceLerpTime | Backing field for AmbienceLerpTime. |
private AtmospherePlugin[] availablePlugins | The child atmosphere plugins; sets enable or disable them by index. |
private AtmosphereSet baseSet | The default atmosphere set used when the chunk has no override. |
private int currentPriorityPlugin | Index of the plugin that currently has priority, or -1 when none. |
private AtmosphereSet currentSet | Backing field for CurrentSet. |
private static Logger logger | NLog logger for this class. |
private float positionLerpSpeed | Backing field for PositionLerpSpeed. |
private bool save | Editor toggle for saving a new set; it only resets itself in this build. |
private string setName | Editor name for a new atmosphere set. |
Properties
| Member | What it is |
|---|---|
LerpingFloatValue AmbienceAudio { get; private set; } | Blend value between main (1) and secondary (0) ambient audio. |
float AmbienceLerpTime { get; } | Seconds to blend ambience when changing sets. |
AtmosphereColor AmbientColor { get; private set; } | Blended ambient light colour, written to RenderSettings.ambientLight. |
AtmospherePlugin[] AtmospherePlugins { get; } | The plugin components under the manager. |
Color CurrentFogColor { get; } | The current RenderSettings.fogColor. |
float CurrentFogDensity { get; } | The current RenderSettings.fogDensity. |
AtmosphereSet CurrentSet { get; } | The atmosphere set last applied. |
AtmosphereColor FogColor { get; private set; } | Blended fog colour, also pushed to the global fog shader colour. |
LerpingControlledFloatValue FogDensity { get; private set; } | Blended fog density. |
AtmospherePlugin MainAudio { get; private set; } | Plugin playing the main ambient audio. |
float PositionLerpSpeed { get; } | Speed plugins use to follow positions. |
AtmospherePlugin SecondaryAudio { get; private set; } | Plugin whose ambient audio is fading out. |
Events
| Member | What it is |
|---|---|
event AtmosphereManager.ResolveAtmosphere Resolve | Lets you replace the set chosen for a chunk before it is applied. Pass the set by ref. |
Methods
| Member | What it is |
|---|---|
bool CheckPriority(AtmospherePlugin plugin) | Makes a plugin the priority one if it ranks at least as high as the current; returns whether it is. |
void ClearPriority(AtmospherePlugin plugin) | Clears priority if the given plugin had it. |
AtmospherePlugin GetHighestPlugin(AtmosphereSet set) | Meant to return the highest priority enabled plugin in a set; in this build it returns the last enabled one. |
override void Initialize() | Sets up all plugins and blended values and applies the base set. |
override void OnConnected(Player player) | Passes a new player on to every plugin. |
void ReadAtmosphereSet(AtmosphereSet set, Color? overrideAmbience = null) | Applies a set: turns plugins on or off and blends ambience, optionally with an ambient colour override. |
void ReturnToBase() | Applies the local player's chunk override set, or the base set. |
void SetAudio(AtmospherePlugin newAudioPlugin, bool isRegularLerping = true) | Makes a plugin the main audio and fades the old one out. |
void SetBackGroundAudioSet(AtmosphereSet newBackGroundSet) | Starts a set's audio plugin as the secondary (background) audio. |
protected void Awake() | Sets the instance and hooks the local player's spawn and chunk changes. |
9 private and internal methods
| Member | What it is |
|---|---|
private void EnsureAtmosphere(LocationChunk chunk) | Applies the chunk's override atmosphere set (after Resolve handlers can change it) when the local player changes chunk. |
private void InitializeProperties() | Creates the lerping ambient colour, fog colour, fog density and ambience volume values that drive render settings, and hooks audio muting. |
private void LocalPlayerSet(IPlayer player) | Hooks the local player's chunk changes so the atmosphere follows them. |
private void OnDestroy() | Unhooks the local player events. |
private void OnValidate() | Collects the child AtmospherePlugin components into availablePlugins. |
private void OverrideAtmosphere(PlayerController player) | When the local player controller spawns, finds the chunk containing it and applies that chunk's atmosphere. |
private void SetupNewMainAudio(AtmospherePlugin newAudioPlugin, bool isRegularLerping) | Makes a plugin the main ambience audio, moves the old one to secondary and crossfades between them. |
private void ToggleGlobalAmbienceMute(bool isMuted) | Mutes or unmutes the main ambience audio when the audio manager's mute changes. |
private void Update() | Steps the ambient colour, fog and ambience volume lerps each frame. |
Used in
Members of other types that take, return or hold a AtmosphereManager: