Files
ichni_Official/Assets/ThemeBundles/DepartureToMultiverse/Scripts/Game/Environment/DTMGlobalFog.cs
SoulliesOfficial 56cee0cf01 修复
2026-03-18 13:42:23 -04:00

116 lines
5.2 KiB
C#

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<string> 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<DTMGlobalFog>();
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<HeightFogGlobal>();
}
// 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
}
}