using System; using System.Collections.Generic; using Ichni.RhythmGame.Beatmap; using UnityEngine; using AtmosphericHeightFog; using FogMode = AtmosphericHeightFog.FogMode; namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse { public class DTMGlobalFog : EnvironmentObject { #region [暴露属性字段] Exposed Fields public HeightFogGlobal heightFogGlobal; public FlexibleFloat fogColorStartR, fogColorStartG, fogColorStartB, fogColorStartA; public FlexibleFloat fogColorEndR, fogColorEndG, fogColorEndB, fogColorEndA; public FlexibleFloat fogColorDuo; public FlexibleFloat skyboxFogIntensity; public FlexibleFloat skyboxFogHeight; public FlexibleFloat skyboxFogFalloff; public FlexibleFloat skyboxFogOffset; #endregion #region [生命周期与工厂] Lifecycle & Factory public static DTMGlobalFog GenerateElement(string elementName, Guid id, List tags, bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement, bool isStatic, FlexibleFloat fogColorStartR, FlexibleFloat fogColorStartG, FlexibleFloat fogColorStartB, FlexibleFloat fogColorStartA, FlexibleFloat fogColorEndR, FlexibleFloat fogColorEndG, FlexibleFloat fogColorEndB, FlexibleFloat fogColorEndA, FlexibleFloat fogColorDuo, FlexibleFloat skyboxFogIntensity, FlexibleFloat skyboxFogHeight, FlexibleFloat skyboxFogFalloff, FlexibleFloat skyboxFogOffset) { DTMGlobalFog globalFog = EnvironmentObject.GenerateElement(elementName, id, tags, isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent(); globalFog.fogColorStartR = fogColorStartR; globalFog.fogColorStartG = fogColorStartG; globalFog.fogColorStartB = fogColorStartB; globalFog.fogColorStartA = fogColorStartA; globalFog.fogColorEndR = fogColorEndR; globalFog.fogColorEndG = fogColorEndG; globalFog.fogColorEndB = fogColorEndB; globalFog.fogColorEndA = fogColorEndA; globalFog.fogColorDuo = fogColorDuo; globalFog.skyboxFogIntensity = skyboxFogIntensity; globalFog.skyboxFogHeight = skyboxFogHeight; globalFog.skyboxFogFalloff = skyboxFogFalloff; globalFog.skyboxFogOffset = skyboxFogOffset; return globalFog; } public override void FirstSetUpObject(bool isFirstGenerated) { if (heightFogGlobal == null) { heightFogGlobal = GetComponentInChildren(); } // Ensure fog mode is set to script settings so it accepts our overrides if (heightFogGlobal != null) { heightFogGlobal.fogMode = FogMode.UseScriptSettings; } } #endregion #region [事件动画逻辑] Event Animation Logic private void Update() { if (heightFogGlobal == null) return; float songTime = CoreServices.TimeProvider.SongTime; fogColorStartR?.UpdateFlexibleFloat(songTime); fogColorStartG?.UpdateFlexibleFloat(songTime); fogColorStartB?.UpdateFlexibleFloat(songTime); fogColorStartA?.UpdateFlexibleFloat(songTime); fogColorEndR?.UpdateFlexibleFloat(songTime); fogColorEndG?.UpdateFlexibleFloat(songTime); fogColorEndB?.UpdateFlexibleFloat(songTime); fogColorEndA?.UpdateFlexibleFloat(songTime); fogColorDuo?.UpdateFlexibleFloat(songTime); skyboxFogIntensity?.UpdateFlexibleFloat(songTime); skyboxFogHeight?.UpdateFlexibleFloat(songTime); skyboxFogFalloff?.UpdateFlexibleFloat(songTime); skyboxFogOffset?.UpdateFlexibleFloat(songTime); if (fogColorStartR != null && fogColorStartG != null && fogColorStartB != null && fogColorStartA != null) { heightFogGlobal.fogColorStart = new Color(fogColorStartR.value, fogColorStartG.value, fogColorStartB.value, fogColorStartA.value); } if (fogColorEndR != null && fogColorEndG != null && fogColorEndB != null && fogColorEndA != null) { heightFogGlobal.fogColorEnd = new Color(fogColorEndR.value, fogColorEndG.value, fogColorEndB.value, fogColorEndA.value); } if (fogColorDuo != null) heightFogGlobal.fogColorDuo = fogColorDuo.value; if (skyboxFogIntensity != null) heightFogGlobal.skyboxFogIntensity = skyboxFogIntensity.value; if (skyboxFogHeight != null) heightFogGlobal.skyboxFogHeight = skyboxFogHeight.value; if (skyboxFogFalloff != null) heightFogGlobal.skyboxFogFalloff = skyboxFogFalloff.value; if (skyboxFogOffset != null) heightFogGlobal.skyboxFogOffset = skyboxFogOffset.value; } #endregion } }