Cozy Wather + buld systeme
This commit is contained in:
@@ -0,0 +1,272 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System.Collections;
|
||||
using DistantLands.Cozy.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
|
||||
[ExecuteAlways]
|
||||
public class CozyAmbienceModule : CozyBiomeModuleBase<CozyAmbienceModule>
|
||||
{
|
||||
|
||||
[CozySearchable("Ambiences", "Ambience profiles", "profiles")]
|
||||
public AmbienceProfile[] ambienceProfiles = new AmbienceProfile[0];
|
||||
|
||||
[System.Serializable]
|
||||
public class WeightedAmbience
|
||||
{
|
||||
public AmbienceProfile ambienceProfile;
|
||||
[Range(0, 1)]
|
||||
public float weight;
|
||||
public bool transitioning;
|
||||
public IEnumerator Transition(float value, float time)
|
||||
{
|
||||
transitioning = true;
|
||||
float t = 0;
|
||||
float start = weight;
|
||||
|
||||
while (t < time)
|
||||
{
|
||||
|
||||
float div = (t / time);
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
weight = Mathf.Lerp(start, value, div);
|
||||
t += Time.deltaTime;
|
||||
|
||||
}
|
||||
|
||||
weight = value;
|
||||
ambienceProfile.SetWeight(weight);
|
||||
transitioning = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<WeightedAmbience> weightedAmbience = new List<WeightedAmbience>();
|
||||
|
||||
[CozySearchable("Ambience", "Ambience profile", "profile")]
|
||||
public AmbienceProfile currentAmbienceProfile;
|
||||
public AmbienceProfile ambienceChangeCheck;
|
||||
public float timeToChangeProfiles = 7;
|
||||
public float ambienceTimer;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
if (isBiomeModule)
|
||||
return;
|
||||
|
||||
if (ambienceProfiles.Length == 0)
|
||||
{
|
||||
FindAllAmbiences();
|
||||
}
|
||||
|
||||
foreach (AmbienceProfile profile in ambienceProfiles)
|
||||
{
|
||||
foreach (FXProfile fx in profile.FX)
|
||||
fx?.InitializeEffect(weatherSphere);
|
||||
}
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
SetNextAmbience();
|
||||
weightedAmbience = new List<WeightedAmbience>() { new WeightedAmbience() { weight = 1, ambienceProfile = currentAmbienceProfile } };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void FindAllAmbiences()
|
||||
{
|
||||
|
||||
List<AmbienceProfile> profiles = new List<AmbienceProfile>();
|
||||
|
||||
foreach (AmbienceProfile i in EditorUtilities.GetAllInstances<AmbienceProfile>())
|
||||
if (i.name != "Default Ambience")
|
||||
profiles.Add(i);
|
||||
|
||||
foreach (AmbienceProfile profile in ambienceProfiles)
|
||||
{
|
||||
foreach (FXProfile fx in profile.FX)
|
||||
fx?.InitializeEffect(weatherSphere);
|
||||
}
|
||||
|
||||
ambienceProfiles = profiles.ToArray();
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public override void UpdateWeatherWeights()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
if (ambienceChangeCheck != currentAmbienceProfile)
|
||||
{
|
||||
SetAmbience(currentAmbienceProfile);
|
||||
}
|
||||
|
||||
if (weatherSphere.timeModule)
|
||||
ambienceTimer -= Time.deltaTime * weatherSphere.timeModule.modifiedTimeSpeed;
|
||||
else
|
||||
ambienceTimer -= Time.deltaTime / 1440;
|
||||
|
||||
if (ambienceTimer <= 0)
|
||||
{
|
||||
SetNextAmbience();
|
||||
}
|
||||
|
||||
// Added a catch to stop ambience at very low weight
|
||||
for (int i = weightedAmbience.Count - 1; i >= 0; i--)
|
||||
{
|
||||
WeightedAmbience w = weightedAmbience[i];
|
||||
|
||||
if (w.weight <= 0 && w.transitioning == false)
|
||||
{
|
||||
w.ambienceProfile.SetWeight(0);
|
||||
weightedAmbience.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ComputeBiomeWeights();
|
||||
// ManageBiomeWeights();
|
||||
}
|
||||
|
||||
public override void UpdateFXWeights()
|
||||
{
|
||||
foreach (WeightedAmbience weather in weightedAmbience)
|
||||
{
|
||||
// Moved weight calculation to the FX weights method
|
||||
if (weather != null && weather.ambienceProfile)
|
||||
weather.ambienceProfile.SetWeight(weather.weight * weight);
|
||||
}
|
||||
}
|
||||
public override void UpdateBiomeModule()
|
||||
{
|
||||
currentAmbienceProfile.SetWeight(weight);
|
||||
}
|
||||
|
||||
public void SetNextAmbience()
|
||||
{
|
||||
|
||||
currentAmbienceProfile = WeightedRandom(ambienceProfiles.ToArray());
|
||||
|
||||
}
|
||||
|
||||
public void SetAmbience(AmbienceProfile profile)
|
||||
{
|
||||
|
||||
currentAmbienceProfile = profile;
|
||||
ambienceChangeCheck = currentAmbienceProfile;
|
||||
|
||||
if (weightedAmbience.Find(x => x.ambienceProfile == profile) == null)
|
||||
weightedAmbience.Add(new WeightedAmbience() { weight = 0, ambienceProfile = profile, transitioning = true });
|
||||
|
||||
foreach (WeightedAmbience j in weightedAmbience)
|
||||
{
|
||||
if (j.ambienceProfile == profile)
|
||||
{
|
||||
StartCoroutine(j.Transition(1, timeToChangeProfiles));
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(j.Transition(0, timeToChangeProfiles));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ambienceTimer += Random.Range(currentAmbienceProfile.minTime, currentAmbienceProfile.maxTime);
|
||||
}
|
||||
|
||||
public void SetAmbience(AmbienceProfile profile, float timeToChange)
|
||||
{
|
||||
|
||||
currentAmbienceProfile = profile;
|
||||
ambienceChangeCheck = currentAmbienceProfile;
|
||||
|
||||
if (weightedAmbience.Find(x => x.ambienceProfile == profile) == null)
|
||||
weightedAmbience.Add(new WeightedAmbience() { weight = 0, ambienceProfile = profile, transitioning = true });
|
||||
|
||||
foreach (WeightedAmbience j in weightedAmbience)
|
||||
{
|
||||
|
||||
if (j.ambienceProfile == profile)
|
||||
StartCoroutine(j.Transition(1, timeToChange));
|
||||
else
|
||||
StartCoroutine(j.Transition(0, timeToChange));
|
||||
|
||||
}
|
||||
|
||||
ambienceTimer += Random.Range(currentAmbienceProfile.minTime, currentAmbienceProfile.maxTime);
|
||||
}
|
||||
|
||||
public void SkipTime(float timeToSkip) => ambienceTimer -= timeToSkip;
|
||||
|
||||
public AmbienceProfile WeightedRandom(AmbienceProfile[] profiles)
|
||||
{
|
||||
AmbienceProfile i = null;
|
||||
List<float> floats = new List<float>();
|
||||
float totalChance = 0;
|
||||
|
||||
foreach (AmbienceProfile k in profiles)
|
||||
{
|
||||
float chance;
|
||||
|
||||
if (weatherSphere.weatherModule)
|
||||
if (k.dontPlayDuring.Contains(weatherSphere.weatherModule.ecosystem.currentWeather))
|
||||
chance = 0;
|
||||
else
|
||||
chance = k.GetChance(weatherSphere);
|
||||
else
|
||||
chance = k.GetChance(weatherSphere);
|
||||
|
||||
floats.Add(chance);
|
||||
totalChance += chance;
|
||||
}
|
||||
|
||||
if (totalChance == 0)
|
||||
{
|
||||
i = (AmbienceProfile)Resources.Load("Default Ambience");
|
||||
Debug.LogWarning("Could not find a suitable ambience given the current selected profiles and chance effectors. Defaulting to an empty ambience.");
|
||||
return i;
|
||||
}
|
||||
|
||||
float selection = Random.Range(0, totalChance);
|
||||
|
||||
int m = 0;
|
||||
float l = 0;
|
||||
|
||||
while (l <= selection)
|
||||
{
|
||||
if (selection >= l && selection < l + floats[m])
|
||||
{
|
||||
i = profiles[m];
|
||||
break;
|
||||
}
|
||||
l += floats[m];
|
||||
m++;
|
||||
|
||||
}
|
||||
|
||||
if (!i)
|
||||
{
|
||||
i = profiles[0];
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public float GetTimeTillNextAmbience() => ambienceTimer;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9658bfcb43a1f5d439faba1cccfec118
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- weatherSphere: {instanceID: 0}
|
||||
- currentAmbienceProfile: {fileID: 11400000, guid: e1524d194ad97f34ebbaddeea31a44ca,
|
||||
type: 2}
|
||||
- ambienceChangeCheck: {fileID: 11400000, guid: e1524d194ad97f34ebbaddeea31a44ca,
|
||||
type: 2}
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 718a6dd5871d1014c96a89569253c5d2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyAmbienceModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,463 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using DistantLands.Cozy.Data;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyAtmosphereModule : CozyBiomeModuleBase<CozyAtmosphereModule>
|
||||
{
|
||||
[CozySearchable(true, "sky", "atmosphere", "fog", "lighting", "clouds")]
|
||||
public AtmosphereProfile atmosphereProfile;
|
||||
public bool transitioningAtmosphere = false;
|
||||
|
||||
public override void PropogateVariables()
|
||||
{
|
||||
|
||||
if (atmosphereProfile == null)
|
||||
{
|
||||
Debug.LogWarning("Cozy Weather requires an active atmosphere profile to function properly.\nPlease ensure that the active CozyWeather script contains all necessary profile references.");
|
||||
return;
|
||||
}
|
||||
|
||||
SetAtmosphereVariables();
|
||||
}
|
||||
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (!isBiomeModule)
|
||||
{
|
||||
ComputeBiomeWeights();
|
||||
weatherSphere.UpdateShaderVariables();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Immediately sets all of the atmosphere variables.
|
||||
/// </summary>
|
||||
void SetAtmosphereVariables()
|
||||
{
|
||||
|
||||
float i = weatherSphere.usePhysicalSunHeight ? weatherSphere.modifiedDayPercentage : weatherSphere.dayPercentage;
|
||||
|
||||
weatherSphere.gradientExponent = atmosphereProfile.gradientExponent.GetFloatValue(i);
|
||||
weatherSphere.acScale = atmosphereProfile.acScale.GetFloatValue(i);
|
||||
weatherSphere.ambientLightHorizonColor = atmosphereProfile.ambientLightHorizonColor.GetColorValue(i);
|
||||
weatherSphere.ambientLightZenithColor = atmosphereProfile.ambientLightZenithColor.GetColorValue(i);
|
||||
weatherSphere.ambientLightMultiplier = atmosphereProfile.ambientLightMultiplier.GetFloatValue(i);
|
||||
weatherSphere.chemtrailsMoveSpeed = atmosphereProfile.chemtrailsMoveSpeed.GetFloatValue(i);
|
||||
weatherSphere.cirroMoveSpeed = atmosphereProfile.cirroMoveSpeed.GetFloatValue(i);
|
||||
weatherSphere.cirrusMoveSpeed = atmosphereProfile.cirrusMoveSpeed.GetFloatValue(i);
|
||||
weatherSphere.clippingThreshold = atmosphereProfile.clippingThreshold.GetFloatValue(i);
|
||||
weatherSphere.cloudCohesion = atmosphereProfile.cloudCohesion.GetFloatValue(i);
|
||||
weatherSphere.cloudColor = atmosphereProfile.cloudColor.GetColorValue(i);
|
||||
weatherSphere.cloudDetailAmount = atmosphereProfile.cloudDetailAmount.GetFloatValue(i);
|
||||
weatherSphere.cloudDetailScale = atmosphereProfile.cloudDetailScale.GetFloatValue(i);
|
||||
weatherSphere.cloudHighlightColor = atmosphereProfile.cloudHighlightColor.GetColorValue(i);
|
||||
weatherSphere.cloudMainScale = atmosphereProfile.cloudMainScale.GetFloatValue(i);
|
||||
weatherSphere.cloudMoonColor = atmosphereProfile.cloudMoonColor.GetColorValue(i);
|
||||
weatherSphere.cloudMoonHighlightFalloff = atmosphereProfile.cloudMoonHighlightFalloff.GetFloatValue(i);
|
||||
weatherSphere.cloudSunHighlightFalloff = atmosphereProfile.cloudSunHighlightFalloff.GetFloatValue(i);
|
||||
weatherSphere.cloudTextureColor = atmosphereProfile.cloudTextureColor.GetColorValue(i);
|
||||
weatherSphere.cloudThickness = atmosphereProfile.cloudThickness.GetFloatValue(i);
|
||||
weatherSphere.cloudWindSpeed = atmosphereProfile.cloudWindSpeed.GetFloatValue(i);
|
||||
weatherSphere.fogColor1 = atmosphereProfile.fogColor1.GetColorValue(i);
|
||||
weatherSphere.fogColor2 = atmosphereProfile.fogColor2.GetColorValue(i);
|
||||
weatherSphere.fogColor3 = atmosphereProfile.fogColor3.GetColorValue(i);
|
||||
weatherSphere.fogColor4 = atmosphereProfile.fogColor4.GetColorValue(i);
|
||||
weatherSphere.fogColor5 = atmosphereProfile.fogColor5.GetColorValue(i);
|
||||
weatherSphere.fogStart1 = atmosphereProfile.fogStart1.GetFloatValue(i);
|
||||
weatherSphere.fogStart2 = atmosphereProfile.fogStart2.GetFloatValue(i);
|
||||
weatherSphere.fogStart3 = atmosphereProfile.fogStart3.GetFloatValue(i);
|
||||
weatherSphere.fogStart4 = atmosphereProfile.fogStart4.GetFloatValue(i);
|
||||
weatherSphere.fogDensityMultiplier = atmosphereProfile.fogDensityMultiplier.GetFloatValue(i);
|
||||
weatherSphere.fogFlareColor = atmosphereProfile.fogFlareColor.GetColorValue(i);
|
||||
weatherSphere.fogMoonFlareColor = atmosphereProfile.fogMoonFlareColor.GetColorValue(i);
|
||||
weatherSphere.fogHeight = atmosphereProfile.fogHeight.GetFloatValue(i);
|
||||
weatherSphere.fogVariationAmount = atmosphereProfile.fogVariationAmount.GetFloatValue(i);
|
||||
weatherSphere.fogVariationDirection = atmosphereProfile.fogVariationDirection;
|
||||
weatherSphere.fogVariationDistance = atmosphereProfile.fogVariationDistance.GetFloatValue(i);
|
||||
weatherSphere.fogVariationScale = atmosphereProfile.fogVariationScale.GetFloatValue(i);
|
||||
weatherSphere.fogLightFlareFalloff = atmosphereProfile.fogLightFlareFalloff.GetFloatValue(i);
|
||||
weatherSphere.fogLightFlareIntensity = atmosphereProfile.fogLightFlareIntensity.GetFloatValue(i);
|
||||
weatherSphere.fogLightFlareSquish = atmosphereProfile.fogLightFlareSquish.GetFloatValue(i);
|
||||
weatherSphere.fogBase = atmosphereProfile.fogBase.GetFloatValue(i);
|
||||
weatherSphere.heightFogColor = atmosphereProfile.heightFogColor.GetColorValue(i);
|
||||
weatherSphere.heightFogDistance = atmosphereProfile.heightFogDistance.GetFloatValue(i);
|
||||
weatherSphere.heightFogIntensity = atmosphereProfile.heightFogIntensity.GetFloatValue(i);
|
||||
weatherSphere.heightFogTransition = atmosphereProfile.heightFogTransition.GetFloatValue(i);
|
||||
weatherSphere.heightFogVariationAmount = atmosphereProfile.heightFogVariationAmount.GetFloatValue(i);
|
||||
weatherSphere.heightFogVariationScale = atmosphereProfile.heightFogVariationScale.GetFloatValue(i);
|
||||
weatherSphere.galaxy1Color = atmosphereProfile.galaxy1Color.GetColorValue(i);
|
||||
weatherSphere.galaxy2Color = atmosphereProfile.galaxy2Color.GetColorValue(i);
|
||||
weatherSphere.galaxy3Color = atmosphereProfile.galaxy3Color.GetColorValue(i);
|
||||
weatherSphere.galaxyIntensity = atmosphereProfile.galaxyIntensity.GetFloatValue(i);
|
||||
weatherSphere.highAltitudeCloudColor = atmosphereProfile.highAltitudeCloudColor.GetColorValue(i);
|
||||
weatherSphere.lightScatteringColor = atmosphereProfile.lightScatteringColor.GetColorValue(i);
|
||||
weatherSphere.moonlightColor = atmosphereProfile.moonlightColor.GetColorValue(i);
|
||||
weatherSphere.moonColor = atmosphereProfile.moonColor.GetColorValue(i);
|
||||
weatherSphere.moonFalloff = atmosphereProfile.moonFalloff.GetFloatValue(i);
|
||||
weatherSphere.moonFlareColor = atmosphereProfile.moonFlareColor.GetColorValue(i);
|
||||
weatherSphere.useRainbow = atmosphereProfile.useRainbow;
|
||||
weatherSphere.rainbowPosition = atmosphereProfile.rainbowPosition.GetFloatValue(i);
|
||||
weatherSphere.rainbowWidth = atmosphereProfile.rainbowWidth.GetFloatValue(i);
|
||||
weatherSphere.shadowDistance = atmosphereProfile.shadowDistance.GetFloatValue(i);
|
||||
weatherSphere.skyHorizonColor = atmosphereProfile.skyHorizonColor.GetColorValue(i);
|
||||
weatherSphere.skyZenithColor = atmosphereProfile.skyZenithColor.GetColorValue(i);
|
||||
weatherSphere.spherize = atmosphereProfile.spherize.GetFloatValue(i);
|
||||
weatherSphere.starColor = atmosphereProfile.starColor.GetColorValue(i);
|
||||
weatherSphere.sunColor = atmosphereProfile.sunColor.GetColorValue(i);
|
||||
weatherSphere.sunDirection = atmosphereProfile.sunDirection.GetFloatValue(i);
|
||||
weatherSphere.sunFalloff = atmosphereProfile.sunFalloff.GetFloatValue(i);
|
||||
weatherSphere.sunFlareColor = atmosphereProfile.sunFlareColor.GetColorValue(i);
|
||||
weatherSphere.sunlightColor = atmosphereProfile.sunlightColor.GetColorValue(i);
|
||||
weatherSphere.moonlightShadows = atmosphereProfile.moonlightShadows;
|
||||
weatherSphere.sunlightShadows = atmosphereProfile.sunlightShadows;
|
||||
weatherSphere.sunPitch = atmosphereProfile.sunPitch.GetFloatValue(i);
|
||||
weatherSphere.sunSize = atmosphereProfile.sunSize.GetFloatValue(i);
|
||||
weatherSphere.textureAmount = atmosphereProfile.textureAmount.GetFloatValue(i);
|
||||
weatherSphere.fogSmoothness = atmosphereProfile.fogSmoothness.GetFloatValue(i);
|
||||
weatherSphere.texturePanDirection = atmosphereProfile.texturePanDirection;
|
||||
weatherSphere.cloudTexture = atmosphereProfile.cloudTexture;
|
||||
weatherSphere.chemtrailsTexture = atmosphereProfile.chemtrailsTexture;
|
||||
weatherSphere.cirrusCloudTexture = atmosphereProfile.cirrusCloudTexture;
|
||||
weatherSphere.altocumulusCloudTexture = atmosphereProfile.altocumulusCloudTexture;
|
||||
weatherSphere.cirrostratusCloudTexture = atmosphereProfile.cirrostratusCloudTexture;
|
||||
weatherSphere.starMap = atmosphereProfile.starMap;
|
||||
weatherSphere.galaxyMap = atmosphereProfile.galaxyMap;
|
||||
weatherSphere.galaxyStarMap = atmosphereProfile.galaxyStarMap;
|
||||
weatherSphere.galaxyVariationMap = atmosphereProfile.galaxyVariationMap;
|
||||
weatherSphere.lightScatteringMap = atmosphereProfile.lightScatteringMap;
|
||||
|
||||
weatherSphere.partlyCloudyLuxuryClouds = atmosphereProfile.partlyCloudyLuxuryClouds;
|
||||
weatherSphere.mostlyCloudyLuxuryClouds = atmosphereProfile.mostlyCloudyLuxuryClouds;
|
||||
weatherSphere.overcastLuxuryClouds = atmosphereProfile.overcastLuxuryClouds;
|
||||
weatherSphere.lowBorderLuxuryClouds = atmosphereProfile.lowBorderLuxuryClouds;
|
||||
weatherSphere.highBorderLuxuryClouds = atmosphereProfile.highBorderLuxuryClouds;
|
||||
weatherSphere.lowNimbusLuxuryClouds = atmosphereProfile.lowNimbusLuxuryClouds;
|
||||
weatherSphere.midNimbusLuxuryClouds = atmosphereProfile.midNimbusLuxuryClouds;
|
||||
weatherSphere.highNimbusLuxuryClouds = atmosphereProfile.highNimbusLuxuryClouds;
|
||||
weatherSphere.luxuryVariation = atmosphereProfile.luxuryVariation;
|
||||
|
||||
weatherSphere.constellationIntensity = atmosphereProfile.constellationIntensity.GetFloatValue(i);
|
||||
weatherSphere.lightScatteringPosition = atmosphereProfile.lightScatteringPosition.GetFloatValue(i);
|
||||
weatherSphere.lightScatteringHeight = atmosphereProfile.lightScatteringHeight.GetFloatValue(i);
|
||||
weatherSphere.skyFogAmount = atmosphereProfile.skyFogAmount.GetFloatValue(i);
|
||||
weatherSphere.cloudsFogAmount = atmosphereProfile.cloudsFogAmount.GetFloatValue(i);
|
||||
weatherSphere.cloudsFogLightAmount = atmosphereProfile.cloudsFogLightAmount.GetFloatValue(i);
|
||||
|
||||
weatherSphere.starDomeTexture = atmosphereProfile.starDomeTexture;
|
||||
weatherSphere.constellationDomeTexture = atmosphereProfile.constellationDomeTexture;
|
||||
weatherSphere.galaxyDomeTexture = atmosphereProfile.galaxyDomeTexture;
|
||||
weatherSphere.lightScatteringMap = atmosphereProfile.lightScatteringMap;
|
||||
weatherSphere.rainbowTexture = atmosphereProfile.rainbowTexture;
|
||||
|
||||
#if COZY_URP || COZY_HDRP
|
||||
weatherSphere.sunFlare = atmosphereProfile.sunFlare;
|
||||
weatherSphere.moonFlare = atmosphereProfile.moonFlare;
|
||||
#endif
|
||||
|
||||
foreach (CozyAtmosphereModule biome in biomes)
|
||||
{
|
||||
if (biome == null) continue;
|
||||
if (biome.system.weight == 0) continue;
|
||||
if (biome.atmosphereProfile == null) continue;
|
||||
|
||||
if (biome.atmosphereProfile.gradientExponent)
|
||||
weatherSphere.gradientExponent = Mathf.Lerp(weatherSphere.gradientExponent, biome.atmosphereProfile.gradientExponent.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.ambientLightHorizonColor)
|
||||
weatherSphere.ambientLightHorizonColor = Color.Lerp(weatherSphere.ambientLightHorizonColor, biome.atmosphereProfile.ambientLightHorizonColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.ambientLightZenithColor)
|
||||
weatherSphere.ambientLightZenithColor = Color.Lerp(weatherSphere.ambientLightZenithColor, biome.atmosphereProfile.ambientLightZenithColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.ambientLightMultiplier)
|
||||
weatherSphere.ambientLightMultiplier = Mathf.Lerp(weatherSphere.ambientLightMultiplier, biome.atmosphereProfile.ambientLightMultiplier.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.clippingThreshold)
|
||||
weatherSphere.clippingThreshold = Mathf.Lerp(weatherSphere.clippingThreshold, biome.atmosphereProfile.clippingThreshold.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.cloudCohesion)
|
||||
weatherSphere.cloudCohesion = Mathf.Lerp(weatherSphere.cloudCohesion, biome.atmosphereProfile.cloudCohesion.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.cloudColor)
|
||||
weatherSphere.cloudColor = Color.Lerp(weatherSphere.cloudColor, biome.atmosphereProfile.cloudColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.cloudHighlightColor)
|
||||
weatherSphere.cloudHighlightColor = Color.Lerp(weatherSphere.cloudHighlightColor, biome.atmosphereProfile.cloudHighlightColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.cloudMoonColor)
|
||||
weatherSphere.cloudMoonColor = Color.Lerp(weatherSphere.cloudMoonColor, biome.atmosphereProfile.cloudMoonColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.cloudMoonHighlightFalloff)
|
||||
weatherSphere.cloudMoonHighlightFalloff = Mathf.Lerp(weatherSphere.cloudMoonHighlightFalloff, biome.atmosphereProfile.cloudMoonHighlightFalloff.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.cloudSunHighlightFalloff)
|
||||
weatherSphere.cloudSunHighlightFalloff = Mathf.Lerp(weatherSphere.cloudSunHighlightFalloff, biome.atmosphereProfile.cloudSunHighlightFalloff.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.cloudTextureColor)
|
||||
weatherSphere.cloudTextureColor = Color.Lerp(weatherSphere.cloudTextureColor, biome.atmosphereProfile.cloudTextureColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.cloudThickness)
|
||||
weatherSphere.cloudThickness = Mathf.Lerp(weatherSphere.cloudThickness, biome.atmosphereProfile.cloudThickness.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogColor1)
|
||||
weatherSphere.fogColor1 = Color.Lerp(weatherSphere.fogColor1, biome.atmosphereProfile.fogColor1.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogColor2)
|
||||
weatherSphere.fogColor2 = Color.Lerp(weatherSphere.fogColor2, biome.atmosphereProfile.fogColor2.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogColor3)
|
||||
weatherSphere.fogColor3 = Color.Lerp(weatherSphere.fogColor3, biome.atmosphereProfile.fogColor3.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogColor4)
|
||||
weatherSphere.fogColor4 = Color.Lerp(weatherSphere.fogColor4, biome.atmosphereProfile.fogColor4.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogColor5)
|
||||
weatherSphere.fogColor5 = Color.Lerp(weatherSphere.fogColor5, biome.atmosphereProfile.fogColor5.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogStart1)
|
||||
weatherSphere.fogStart1 = Mathf.Lerp(weatherSphere.fogStart1, biome.atmosphereProfile.fogStart1.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogStart2)
|
||||
weatherSphere.fogStart2 = Mathf.Lerp(weatherSphere.fogStart2, biome.atmosphereProfile.fogStart2.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogStart3)
|
||||
weatherSphere.fogStart3 = Mathf.Lerp(weatherSphere.fogStart3, biome.atmosphereProfile.fogStart3.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogStart4)
|
||||
weatherSphere.fogStart4 = Mathf.Lerp(weatherSphere.fogStart4, biome.atmosphereProfile.fogStart4.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogDensityMultiplier)
|
||||
weatherSphere.fogDensityMultiplier = Mathf.Lerp(weatherSphere.fogDensityMultiplier, biome.atmosphereProfile.fogDensityMultiplier.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogFlareColor)
|
||||
weatherSphere.fogFlareColor = Color.Lerp(weatherSphere.fogFlareColor, biome.atmosphereProfile.fogFlareColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogMoonFlareColor)
|
||||
weatherSphere.fogMoonFlareColor = Color.Lerp(weatherSphere.fogMoonFlareColor, biome.atmosphereProfile.fogMoonFlareColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogHeight)
|
||||
weatherSphere.fogHeight = Mathf.Lerp(weatherSphere.fogHeight, biome.atmosphereProfile.fogHeight.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogVariationAmount)
|
||||
weatherSphere.fogVariationAmount = Mathf.Lerp(weatherSphere.fogVariationAmount, biome.atmosphereProfile.fogVariationAmount.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogVariationDistance)
|
||||
weatherSphere.fogVariationDistance = Mathf.Lerp(weatherSphere.fogVariationDistance, biome.atmosphereProfile.fogVariationDistance.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogLightFlareFalloff)
|
||||
weatherSphere.fogLightFlareFalloff = Mathf.Lerp(weatherSphere.fogLightFlareFalloff, biome.atmosphereProfile.fogLightFlareFalloff.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogLightFlareIntensity)
|
||||
weatherSphere.fogLightFlareIntensity = Mathf.Lerp(weatherSphere.fogLightFlareIntensity, biome.atmosphereProfile.fogLightFlareIntensity.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogLightFlareSquish)
|
||||
weatherSphere.fogLightFlareSquish = Mathf.Lerp(weatherSphere.fogLightFlareSquish, biome.atmosphereProfile.fogLightFlareSquish.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.galaxy1Color)
|
||||
weatherSphere.galaxy1Color = Color.Lerp(weatherSphere.galaxy1Color, biome.atmosphereProfile.galaxy1Color.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.galaxy2Color)
|
||||
weatherSphere.galaxy2Color = Color.Lerp(weatherSphere.galaxy2Color, biome.atmosphereProfile.galaxy2Color.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.galaxy3Color)
|
||||
weatherSphere.galaxy3Color = Color.Lerp(weatherSphere.galaxy3Color, biome.atmosphereProfile.galaxy3Color.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.galaxyIntensity)
|
||||
weatherSphere.galaxyIntensity = Mathf.Lerp(weatherSphere.galaxyIntensity, biome.atmosphereProfile.galaxyIntensity.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.highAltitudeCloudColor)
|
||||
weatherSphere.highAltitudeCloudColor = Color.Lerp(weatherSphere.highAltitudeCloudColor, biome.atmosphereProfile.highAltitudeCloudColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.lightScatteringColor)
|
||||
weatherSphere.lightScatteringColor = Color.Lerp(weatherSphere.lightScatteringColor, biome.atmosphereProfile.lightScatteringColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.moonlightColor)
|
||||
weatherSphere.moonlightColor = Color.Lerp(weatherSphere.moonlightColor, biome.atmosphereProfile.moonlightColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.moonColor)
|
||||
weatherSphere.moonColor = Color.Lerp(weatherSphere.moonColor, biome.atmosphereProfile.moonColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.moonFalloff)
|
||||
weatherSphere.moonFalloff = Mathf.Lerp(weatherSphere.moonFalloff, biome.atmosphereProfile.moonFalloff.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.moonFlareColor)
|
||||
weatherSphere.moonFlareColor = Color.Lerp(weatherSphere.moonFlareColor, biome.atmosphereProfile.moonFlareColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.rainbowPosition)
|
||||
weatherSphere.rainbowPosition = Mathf.Lerp(weatherSphere.rainbowPosition, biome.atmosphereProfile.rainbowPosition.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.rainbowWidth)
|
||||
weatherSphere.rainbowWidth = Mathf.Lerp(weatherSphere.rainbowWidth, biome.atmosphereProfile.rainbowWidth.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.shadowDistance)
|
||||
weatherSphere.shadowDistance = Mathf.Lerp(weatherSphere.shadowDistance, biome.atmosphereProfile.shadowDistance.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.skyHorizonColor)
|
||||
weatherSphere.skyHorizonColor = Color.Lerp(weatherSphere.skyHorizonColor, biome.atmosphereProfile.skyHorizonColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.skyZenithColor)
|
||||
weatherSphere.skyZenithColor = Color.Lerp(weatherSphere.skyZenithColor, biome.atmosphereProfile.skyZenithColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.spherize)
|
||||
weatherSphere.spherize = Mathf.Lerp(weatherSphere.spherize, biome.atmosphereProfile.spherize.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.starColor)
|
||||
weatherSphere.starColor = Color.Lerp(weatherSphere.starColor, biome.atmosphereProfile.starColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.sunColor)
|
||||
weatherSphere.sunColor = Color.Lerp(weatherSphere.sunColor, biome.atmosphereProfile.sunColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.sunDirection)
|
||||
weatherSphere.sunDirection = Mathf.Lerp(weatherSphere.sunDirection, biome.atmosphereProfile.sunDirection.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.sunFalloff)
|
||||
weatherSphere.sunFalloff = Mathf.Lerp(weatherSphere.sunFalloff, biome.atmosphereProfile.sunFalloff.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.sunFlareColor)
|
||||
weatherSphere.sunFlareColor = Color.Lerp(weatherSphere.sunFlareColor, biome.atmosphereProfile.sunFlareColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.sunlightColor)
|
||||
weatherSphere.sunlightColor = Color.Lerp(weatherSphere.sunlightColor, biome.atmosphereProfile.sunlightColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.sunPitch)
|
||||
weatherSphere.sunPitch = Mathf.Lerp(weatherSphere.sunPitch, biome.atmosphereProfile.sunPitch.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.sunSize)
|
||||
weatherSphere.sunSize = Mathf.Lerp(weatherSphere.sunSize, biome.atmosphereProfile.sunSize.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.textureAmount)
|
||||
weatherSphere.textureAmount = Mathf.Lerp(weatherSphere.textureAmount, biome.atmosphereProfile.textureAmount.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogSmoothness)
|
||||
weatherSphere.fogSmoothness = Mathf.Lerp(weatherSphere.fogSmoothness, biome.atmosphereProfile.fogSmoothness.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.fogBase)
|
||||
weatherSphere.fogBase = Mathf.Lerp(weatherSphere.fogBase, biome.atmosphereProfile.fogBase.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.heightFogColor)
|
||||
weatherSphere.heightFogColor = Color.Lerp(weatherSphere.heightFogColor, biome.atmosphereProfile.heightFogColor.GetColorValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.heightFogDistance)
|
||||
weatherSphere.heightFogDistance = Mathf.Lerp(weatherSphere.heightFogDistance, biome.atmosphereProfile.heightFogDistance.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.heightFogIntensity)
|
||||
weatherSphere.heightFogIntensity = Mathf.Lerp(weatherSphere.heightFogIntensity, biome.atmosphereProfile.heightFogIntensity.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.heightFogTransition)
|
||||
weatherSphere.heightFogTransition = Mathf.Lerp(weatherSphere.heightFogTransition, biome.atmosphereProfile.heightFogTransition.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.heightFogVariationAmount)
|
||||
weatherSphere.heightFogVariationAmount = Mathf.Lerp(weatherSphere.heightFogVariationAmount, biome.atmosphereProfile.heightFogVariationAmount.GetFloatValue(i), biome.weight);
|
||||
if (biome.atmosphereProfile.heightFogVariationScale)
|
||||
weatherSphere.heightFogVariationScale = Mathf.Lerp(weatherSphere.heightFogVariationScale, biome.atmosphereProfile.heightFogVariationScale.GetFloatValue(i), biome.weight);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Smoothly interpolates the current atmosphere profile and all of the impacted settings by the transition time.
|
||||
/// </summary>
|
||||
public void ChangeAtmosphere(AtmosphereProfile end, float transitionTime)
|
||||
{
|
||||
|
||||
StartCoroutine(TransitionAtmosphere(end, transitionTime));
|
||||
|
||||
}
|
||||
|
||||
IEnumerator TransitionAtmosphere(AtmosphereProfile end, float transitionTime)
|
||||
{
|
||||
|
||||
|
||||
float gradientExponentStart = weatherSphere.gradientExponent;
|
||||
float acScaleStart = weatherSphere.acScale;
|
||||
Color ambientLightHorizonColorStart = weatherSphere.ambientLightHorizonColor;
|
||||
Color ambientLightZenithColorStart = weatherSphere.ambientLightZenithColor;
|
||||
float ambientLightMultiplierStart = weatherSphere.ambientLightMultiplier;
|
||||
float chemtrailsMoveSpeedStart = weatherSphere.chemtrailsMoveSpeed;
|
||||
float cirroMoveSpeedStart = weatherSphere.cirroMoveSpeed;
|
||||
float cirrusMoveSpeedStart = weatherSphere.cirrusMoveSpeed;
|
||||
float clippingThresholdStart = weatherSphere.clippingThreshold;
|
||||
float cloudCohesionStart = weatherSphere.cloudCohesion;
|
||||
Color cloudColorStart = weatherSphere.cloudColor;
|
||||
float cloudDetailAmountStart = weatherSphere.cloudDetailAmount;
|
||||
float cloudDetailScaleStart = weatherSphere.cloudDetailScale;
|
||||
Color cloudHighlightColorStart = weatherSphere.cloudHighlightColor;
|
||||
float cloudMainScaleStart = weatherSphere.cloudMainScale;
|
||||
Color cloudMoonColorStart = weatherSphere.cloudMoonColor;
|
||||
float cloudMoonHighlightFalloffStart = weatherSphere.cloudMoonHighlightFalloff;
|
||||
float cloudSunHighlightFalloffStart = weatherSphere.cloudSunHighlightFalloff;
|
||||
Color cloudTextureColorStart = weatherSphere.cloudTextureColor;
|
||||
float cloudThicknessStart = weatherSphere.cloudThickness;
|
||||
float cloudWindSpeedStart = weatherSphere.cloudWindSpeed;
|
||||
Color fogColor1Start = weatherSphere.fogColor1;
|
||||
Color fogColor2Start = weatherSphere.fogColor2;
|
||||
Color fogColor3Start = weatherSphere.fogColor3;
|
||||
Color fogColor4Start = weatherSphere.fogColor4;
|
||||
Color fogColor5Start = weatherSphere.fogColor5;
|
||||
float fogStart1Start = weatherSphere.fogStart1;
|
||||
float fogStart2Start = weatherSphere.fogStart2;
|
||||
float fogStart3Start = weatherSphere.fogStart3;
|
||||
float fogStart4Start = weatherSphere.fogStart4;
|
||||
float fogDensityMultiplierStart = weatherSphere.fogDensityMultiplier;
|
||||
Color fogFlareColorStart = weatherSphere.fogFlareColor;
|
||||
float fogHeightStart = weatherSphere.fogHeight;
|
||||
float fogLightFlareFalloffStart = weatherSphere.fogLightFlareFalloff;
|
||||
float fogLightFlareIntensityStart = weatherSphere.fogLightFlareIntensity;
|
||||
float fogLightFlareSquishStart = weatherSphere.fogLightFlareSquish;
|
||||
Color galaxy1ColorStart = weatherSphere.galaxy1Color;
|
||||
Color galaxy2ColorStart = weatherSphere.galaxy2Color;
|
||||
Color galaxy3ColorStart = weatherSphere.galaxy3Color;
|
||||
Color highAltitudeCloudColorStart = weatherSphere.highAltitudeCloudColor;
|
||||
Color lightScatteringColorStart = weatherSphere.lightScatteringColor;
|
||||
Color moonlightColorStart = weatherSphere.moonlightColor;
|
||||
Color moonFlareColorStart = weatherSphere.moonFlareColor;
|
||||
Color skyHorizonColorStart = weatherSphere.skyHorizonColor;
|
||||
Color skyZenithColorStart = weatherSphere.skyZenithColor;
|
||||
Color starColorStart = weatherSphere.starColor;
|
||||
Color sunColorStart = weatherSphere.sunColor;
|
||||
Color sunFlareColorStart = weatherSphere.sunFlareColor;
|
||||
Color sunlightColorStart = weatherSphere.sunlightColor;
|
||||
float galaxyIntensityStart = weatherSphere.galaxyIntensity;
|
||||
float moonFalloffStart = weatherSphere.moonFalloff;
|
||||
float rainbowPositionStart = weatherSphere.rainbowPosition;
|
||||
float rainbowWidthStart = weatherSphere.rainbowWidth;
|
||||
float shadowDistanceStart = weatherSphere.shadowDistance;
|
||||
float spherizeStart = weatherSphere.spherize;
|
||||
float sunDirectionStart = weatherSphere.sunDirection;
|
||||
float sunFalloffStart = weatherSphere.sunFalloff;
|
||||
float sunPitchStart = weatherSphere.sunPitch;
|
||||
float sunSizeStart = weatherSphere.sunSize;
|
||||
float textureAmountStart = weatherSphere.textureAmount;
|
||||
|
||||
|
||||
transitioningAtmosphere = true;
|
||||
float t = transitionTime;
|
||||
|
||||
while (t > 0)
|
||||
{
|
||||
|
||||
float div = 1 - (t / transitionTime);
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
weatherSphere.gradientExponent = Mathf.Lerp(gradientExponentStart, end.gradientExponent.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.acScale = Mathf.Lerp(acScaleStart, end.acScale.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.ambientLightHorizonColor = Color.Lerp(ambientLightHorizonColorStart, end.ambientLightHorizonColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.ambientLightZenithColor = Color.Lerp(ambientLightZenithColorStart, end.ambientLightZenithColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.ambientLightMultiplier = Mathf.Lerp(ambientLightMultiplierStart, end.ambientLightMultiplier.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.chemtrailsMoveSpeed = Mathf.Lerp(chemtrailsMoveSpeedStart, end.chemtrailsMoveSpeed.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cirroMoveSpeed = Mathf.Lerp(cirroMoveSpeedStart, end.cirroMoveSpeed.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cirrusMoveSpeed = Mathf.Lerp(cirrusMoveSpeedStart, end.cirrusMoveSpeed.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.clippingThreshold = Mathf.Lerp(clippingThresholdStart, end.clippingThreshold.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudCohesion = Mathf.Lerp(cloudCohesionStart, end.cloudCohesion.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudColor = Color.Lerp(cloudColorStart, end.cloudColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudDetailAmount = Mathf.Lerp(cloudDetailAmountStart, end.cloudDetailAmount.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudDetailScale = Mathf.Lerp(cloudDetailScaleStart, end.cloudDetailScale.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudHighlightColor = Color.Lerp(cloudHighlightColorStart, end.cloudHighlightColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudMainScale = Mathf.Lerp(cloudMainScaleStart, end.cloudMainScale.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudMoonColor = Color.Lerp(cloudMoonColorStart, end.cloudMoonColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudMoonHighlightFalloff = Mathf.Lerp(cloudMoonHighlightFalloffStart, end.cloudMoonHighlightFalloff.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudSunHighlightFalloff = Mathf.Lerp(cloudSunHighlightFalloffStart, end.cloudSunHighlightFalloff.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudTextureColor = Color.Lerp(cloudTextureColorStart, end.cloudTextureColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudThickness = Mathf.Lerp(cloudThicknessStart, end.cloudThickness.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.cloudWindSpeed = Mathf.Lerp(cloudWindSpeedStart, end.cloudWindSpeed.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogColor1 = Color.Lerp(fogColor1Start, end.fogColor1.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogColor2 = Color.Lerp(fogColor2Start, end.fogColor2.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogColor3 = Color.Lerp(fogColor3Start, end.fogColor3.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogColor4 = Color.Lerp(fogColor4Start, end.fogColor4.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogColor5 = Color.Lerp(fogColor5Start, end.fogColor5.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogStart1 = Mathf.Lerp(fogStart1Start, end.fogStart1.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogStart2 = Mathf.Lerp(fogStart2Start, end.fogStart2.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogStart3 = Mathf.Lerp(fogStart3Start, end.fogStart3.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogStart4 = Mathf.Lerp(fogStart4Start, end.fogStart4.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogDensityMultiplier = Mathf.Lerp(fogDensityMultiplierStart, end.fogDensityMultiplier.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogFlareColor = Color.Lerp(fogFlareColorStart, end.fogFlareColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogHeight = Mathf.Lerp(fogHeightStart, end.fogHeight.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogLightFlareFalloff = Mathf.Lerp(fogLightFlareFalloffStart, end.fogLightFlareFalloff.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogLightFlareIntensity = Mathf.Lerp(fogLightFlareIntensityStart, end.fogLightFlareIntensity.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.fogLightFlareSquish = Mathf.Lerp(fogLightFlareSquishStart, end.fogLightFlareSquish.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.galaxy1Color = Color.Lerp(galaxy1ColorStart, end.galaxy1Color.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.galaxy2Color = Color.Lerp(galaxy2ColorStart, end.galaxy2Color.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.galaxy3Color = Color.Lerp(galaxy3ColorStart, end.galaxy3Color.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.galaxyIntensity = Mathf.Lerp(galaxyIntensityStart, end.galaxyIntensity.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.highAltitudeCloudColor = Color.Lerp(highAltitudeCloudColorStart, end.highAltitudeCloudColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.lightScatteringColor = Color.Lerp(lightScatteringColorStart, end.lightScatteringColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.moonlightColor = Color.Lerp(moonlightColorStart, end.moonlightColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.moonFalloff = Mathf.Lerp(moonFalloffStart, end.moonFalloff.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.moonFlareColor = Color.Lerp(moonFlareColorStart, end.moonFlareColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.rainbowPosition = Mathf.Lerp(rainbowPositionStart, end.rainbowPosition.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.rainbowWidth = Mathf.Lerp(rainbowWidthStart, end.rainbowWidth.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.shadowDistance = Mathf.Lerp(shadowDistanceStart, end.shadowDistance.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.skyHorizonColor = Color.Lerp(skyHorizonColorStart, end.skyHorizonColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.skyZenithColor = Color.Lerp(skyZenithColorStart, end.skyZenithColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.spherize = Mathf.Lerp(spherizeStart, end.spherize.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.starColor = Color.Lerp(starColorStart, end.starColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.sunColor = Color.Lerp(sunColorStart, end.sunColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.sunDirection = Mathf.Lerp(sunDirectionStart, end.sunDirection.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.sunFalloff = Mathf.Lerp(sunFalloffStart, end.sunFalloff.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.sunFlareColor = Color.Lerp(sunFlareColorStart, end.sunFlareColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.sunlightColor = Color.Lerp(sunlightColorStart, end.sunlightColor.GetColorValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.sunPitch = Mathf.Lerp(sunPitchStart, end.sunPitch.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.sunSize = Mathf.Lerp(sunSizeStart, end.sunSize.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
weatherSphere.textureAmount = Mathf.Lerp(textureAmountStart, end.textureAmount.GetFloatValue(weatherSphere.modifiedDayPercentage), div);
|
||||
|
||||
t -= Time.deltaTime;
|
||||
|
||||
}
|
||||
|
||||
transitioningAtmosphere = false;
|
||||
atmosphereProfile = end;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbc05fce84dfbb84699cd646f2c74e60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- weatherSphere: {instanceID: 0}
|
||||
- atmosphereProfile: {fileID: 11400000, guid: 8cc0487e978305c49a20079f78f36ba0,
|
||||
type: 2}
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 75645812b98cbf94b9dd8d2f9401cf16, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyAtmosphereModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,98 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
#if BUTO
|
||||
using OccaSoftware.Buto.Runtime;
|
||||
#endif
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyButoModule : CozyModule
|
||||
{
|
||||
|
||||
#if BUTO
|
||||
|
||||
[SerializeField]
|
||||
[CozySearchable("Buto", "profile", "volumetric fog")]
|
||||
private ButoVolumetricFog fog;
|
||||
[SerializeField]
|
||||
private VolumeProfile volumeProfile;
|
||||
[CozySearchable]
|
||||
[Range(0, 2)] public float fogBrightnessMultiplier;
|
||||
[CozySearchable]
|
||||
[Range(0, 2)] public float fogDensityMultiplier;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
TryFindFog();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (weatherSphere == null)
|
||||
base.InitializeModule();
|
||||
|
||||
if (CozyWeather.FreezeUpdateInEditMode && !Application.isPlaying)
|
||||
return;
|
||||
|
||||
if (fog)
|
||||
{
|
||||
|
||||
fog.colorInfluence.Override(1);
|
||||
fog.litColor.Override(weatherSphere.fogColor5 * fogBrightnessMultiplier);
|
||||
fog.shadowedColor.Override(weatherSphere.fogColor5 * 0.5f * fogBrightnessMultiplier);
|
||||
fog.fogDensity.Override(fogDensityMultiplier * 10 * weatherSphere.fogDensity);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
TryFindFog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TryFindFog()
|
||||
{
|
||||
|
||||
if (volumeProfile)
|
||||
{
|
||||
|
||||
foreach (VolumeComponent component in volumeProfile.components)
|
||||
{
|
||||
|
||||
if (component is ButoVolumetricFog)
|
||||
{
|
||||
fog = (ButoVolumetricFog)component;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Volume vol in FindObjectsByType<Volume>(FindObjectsSortMode.None))
|
||||
{
|
||||
foreach (VolumeComponent component in vol.profile.components)
|
||||
{
|
||||
|
||||
if (component is ButoVolumetricFog)
|
||||
{
|
||||
fog = (ButoVolumetricFog)component;
|
||||
volumeProfile = vol.profile;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("Could not find instance of Buto in the scene!");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c49b4ff419bca584a910d5be53afeb06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: af124ffd6c0114b4e8c1146096b51451, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyButoModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,172 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using UnityEngine;
|
||||
using DistantLands.Cozy.Data;
|
||||
using UnityEngine.Serialization;
|
||||
using System;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyClimateModule : CozyBiomeModuleBase<CozyClimateModule>
|
||||
{
|
||||
[CozySearchable(true, "wet", "precipitation", "hot", "cold", "humidity", "temperature")]
|
||||
public ClimateProfile climateProfile;
|
||||
public CozyWeather.ControlMethod controlMethod = CozyWeather.ControlMethod.profile;
|
||||
|
||||
|
||||
[CozySearchable]
|
||||
[Tooltip("Adds an offset to the local temperature. Useful for adding biomes or climate change by location or elevation")]
|
||||
public float localTemperatureFilter;
|
||||
[CozySearchable]
|
||||
[Tooltip("Adds an offset to the local precipitation. Useful for adding biomes or climate change by location or elevation")]
|
||||
public float localPrecipitationFilter;
|
||||
internal float temperatureOffset;
|
||||
internal float precipitationOffset;
|
||||
[CozySearchable]
|
||||
public float currentTemperature;
|
||||
[CozySearchable]
|
||||
public float currentPrecipitation;
|
||||
|
||||
[Range(0, 1)]
|
||||
[CozySearchable]
|
||||
public float snowAmount;
|
||||
[FormerlySerializedAs("m_SnowMeltSpeed")]
|
||||
[CozySearchable]
|
||||
public float snowMeltSpeed = 0.35f;
|
||||
[Range(0, 1)]
|
||||
[CozySearchable]
|
||||
[FormerlySerializedAs("wetness")]
|
||||
public float groundwaterAmount;
|
||||
[CozySearchable]
|
||||
[FormerlySerializedAs("m_DryingSpeed")]
|
||||
public float dryingSpeed = 0.5f;
|
||||
public float snowSpeed;
|
||||
public float rainSpeed;
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
isBiomeModule = GetComponent<CozyBiome>();
|
||||
base.InitializeModule();
|
||||
|
||||
if (isBiomeModule)
|
||||
return;
|
||||
weatherSphere.climateModule = this;
|
||||
AddBiome();
|
||||
|
||||
}
|
||||
|
||||
public override void CozyUpdateLoop()
|
||||
{
|
||||
ComputeBiomeWeights();
|
||||
|
||||
snowAmount += Time.deltaTime * snowSpeed;
|
||||
|
||||
if (snowSpeed <= 0)
|
||||
if (currentTemperature > 32)
|
||||
snowAmount -= Time.deltaTime * snowMeltSpeed * 0.03f;
|
||||
|
||||
groundwaterAmount += (Time.deltaTime * rainSpeed) + (-1 * dryingSpeed * 0.001f);
|
||||
|
||||
snowAmount = Mathf.Clamp01(snowAmount);
|
||||
groundwaterAmount = Mathf.Clamp01(groundwaterAmount);
|
||||
|
||||
if (controlMethod == CozyWeather.ControlMethod.profile)
|
||||
{
|
||||
if (!climateProfile)
|
||||
return;
|
||||
|
||||
currentTemperature = climateProfile.GetTemperature(weatherSphere) + localTemperatureFilter + temperatureOffset;
|
||||
currentPrecipitation = Mathf.Clamp(climateProfile.GetHumidity(weatherSphere) + localPrecipitationFilter + precipitationOffset, 0, 100);
|
||||
}
|
||||
|
||||
foreach (CozyClimateModule biome in biomes)
|
||||
{
|
||||
currentTemperature = Mathf.Lerp(currentTemperature, biome.currentTemperature, biome.weight);
|
||||
currentPrecipitation = Mathf.Lerp(currentPrecipitation, biome.currentPrecipitation, biome.weight);
|
||||
}
|
||||
|
||||
Shader.SetGlobalFloat("CZY_SnowAmount", snowAmount);
|
||||
Shader.SetGlobalFloat("CZY_WetnessAmount", groundwaterAmount);
|
||||
}
|
||||
|
||||
public override void FrameReset()
|
||||
{
|
||||
|
||||
temperatureOffset = 0;
|
||||
precipitationOffset = 0;
|
||||
|
||||
snowSpeed = 0;
|
||||
rainSpeed = 0;
|
||||
|
||||
}
|
||||
|
||||
public float GetTemperature()
|
||||
{
|
||||
if (controlMethod == CozyWeather.ControlMethod.native)
|
||||
return currentTemperature;
|
||||
else
|
||||
return climateProfile.GetTemperature(weatherSphere) + localTemperatureFilter;
|
||||
|
||||
}
|
||||
|
||||
public float GetTemperature(float time)
|
||||
{
|
||||
|
||||
return climateProfile.GetTemperature(weatherSphere, time) + localTemperatureFilter;
|
||||
|
||||
}
|
||||
|
||||
[Obsolete("Please use GetHumidity instead.")]
|
||||
public float GetPrecipitation()
|
||||
{
|
||||
|
||||
return climateProfile.GetHumidity(weatherSphere) + localPrecipitationFilter;
|
||||
|
||||
}
|
||||
public float GetHumidity()
|
||||
{
|
||||
|
||||
return climateProfile.GetHumidity(weatherSphere) + localPrecipitationFilter;
|
||||
|
||||
}
|
||||
|
||||
[Obsolete("Please use GetHumidity instead.")]
|
||||
public float GetPrecipitation(float time)
|
||||
{
|
||||
|
||||
return climateProfile.GetHumidity(weatherSphere, time) + localPrecipitationFilter;
|
||||
}
|
||||
|
||||
public float GetHumidity(float time)
|
||||
{
|
||||
|
||||
return climateProfile.GetHumidity(weatherSphere, time) + localPrecipitationFilter;
|
||||
}
|
||||
|
||||
public override void DeinitializeModule()
|
||||
{
|
||||
base.DeinitializeModule();
|
||||
|
||||
Shader.SetGlobalFloat("CZY_WindTime", 0);
|
||||
Shader.SetGlobalVector("CZY_WindDirection", Vector3.zero);
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateBiomeModule()
|
||||
{
|
||||
if (controlMethod == CozyWeather.ControlMethod.profile)
|
||||
{
|
||||
if (!climateProfile)
|
||||
return;
|
||||
|
||||
currentTemperature = climateProfile.GetTemperature(weatherSphere) + localTemperatureFilter + temperatureOffset;
|
||||
currentPrecipitation = Mathf.Clamp(climateProfile.GetHumidity(weatherSphere) + localPrecipitationFilter + precipitationOffset, 0, 100);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a5b9d489c177c74c89b78ab58439d40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- weatherSphere: {instanceID: 0}
|
||||
- climateProfile: {fileID: 11400000, guid: e1a4bf0206b48d4428e0e961e057af39, type: 2}
|
||||
executionOrder: 3
|
||||
icon: {fileID: 2800000, guid: e2beee9336739484189066227b4acf6b, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyClimateModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,16 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyDebugModule : CozyModule
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31d5070020e382e44abb9933c88ac332
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: f6b90b12a9a93744d801d84d05b2ad18, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyDebugModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,191 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using DistantLands.Cozy.Data;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
public class CozyEventModule : CozyBiomeModuleBase<CozyEventModule>
|
||||
{
|
||||
[CozySearchable]
|
||||
public UnityEvent onDawn;
|
||||
[CozySearchable]
|
||||
public UnityEvent onMorning;
|
||||
[CozySearchable]
|
||||
public UnityEvent onDay;
|
||||
[CozySearchable]
|
||||
public UnityEvent onAfternoon;
|
||||
[CozySearchable]
|
||||
public UnityEvent onEvening;
|
||||
[CozySearchable]
|
||||
public UnityEvent onTwilight;
|
||||
[CozySearchable]
|
||||
public UnityEvent onNight;
|
||||
[CozySearchable]
|
||||
public UnityEvent onNewMinute;
|
||||
[CozySearchable]
|
||||
public UnityEvent onNewHour;
|
||||
[CozySearchable]
|
||||
public UnityEvent onNewDay;
|
||||
[CozySearchable]
|
||||
public UnityEvent onNewYear;
|
||||
[CozySearchable]
|
||||
public UnityEvent onWeatherProfileChange;
|
||||
|
||||
[System.Serializable]
|
||||
public class CozyEvent
|
||||
{
|
||||
|
||||
public EventFX fxReference;
|
||||
public UnityEvent onPlay;
|
||||
public UnityEvent onStop;
|
||||
|
||||
}
|
||||
|
||||
[CozySearchable]
|
||||
public CozyEvent[] cozyEvents;
|
||||
|
||||
public bool inBiome = false;
|
||||
public UnityEvent onEnterBiome;
|
||||
public UnityEvent onExitBiome;
|
||||
public UnityEvent whileInBiome;
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
base.InitializeModule();
|
||||
|
||||
if (GetComponent<CozyWeather>())
|
||||
{
|
||||
|
||||
GetComponent<CozyWeather>().InitializeModule(typeof(CozyEventModule));
|
||||
DestroyImmediate(this);
|
||||
Debug.LogWarning("Add modules in the settings tab in COZY 2!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
isBiomeModule = GetComponent<CozyBiome>();
|
||||
if (isBiomeModule)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
foreach (CozyEvent i in cozyEvents)
|
||||
{
|
||||
if (i.fxReference)
|
||||
{
|
||||
i.fxReference.onCall += i.onPlay.Invoke;
|
||||
i.fxReference.onEnd += i.onStop.Invoke;
|
||||
}
|
||||
}
|
||||
|
||||
StartCoroutine(Refresh());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void DeinitializeModule()
|
||||
{
|
||||
base.DeinitializeModule();
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
foreach (CozyEvent i in cozyEvents)
|
||||
{
|
||||
if (i.fxReference)
|
||||
{
|
||||
i.fxReference.onCall -= i.onPlay.Invoke;
|
||||
i.fxReference.onEnd -= i.onStop.Invoke;
|
||||
}
|
||||
}
|
||||
|
||||
CozyWeather.Events.onDawn -= onDawn.Invoke;
|
||||
CozyWeather.Events.onMorning -= onMorning.Invoke;
|
||||
CozyWeather.Events.onDay -= onDay.Invoke;
|
||||
CozyWeather.Events.onAfternoon -= onAfternoon.Invoke;
|
||||
CozyWeather.Events.onEvening -= onEvening.Invoke;
|
||||
CozyWeather.Events.onTwilight -= onTwilight.Invoke;
|
||||
CozyWeather.Events.onNight -= onNight.Invoke;
|
||||
CozyWeather.Events.onNewMinute -= onNewMinute.Invoke;
|
||||
CozyWeather.Events.onNewHour -= onNewHour.Invoke;
|
||||
CozyWeather.Events.onNewDay -= onNewDay.Invoke;
|
||||
CozyWeather.Events.onNewYear -= onNewYear.Invoke;
|
||||
CozyWeather.Events.onWeatherChange -= onWeatherProfileChange.Invoke;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator Refresh()
|
||||
{
|
||||
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
CozyWeather.Events.onDawn += onDawn.Invoke;
|
||||
CozyWeather.Events.onMorning += onMorning.Invoke;
|
||||
CozyWeather.Events.onDay += onDay.Invoke;
|
||||
CozyWeather.Events.onAfternoon += onAfternoon.Invoke;
|
||||
CozyWeather.Events.onEvening += onEvening.Invoke;
|
||||
CozyWeather.Events.onTwilight += onTwilight.Invoke;
|
||||
CozyWeather.Events.onNight += onNight.Invoke;
|
||||
CozyWeather.Events.onNewMinute += onNewMinute.Invoke;
|
||||
CozyWeather.Events.onNewHour += onNewHour.Invoke;
|
||||
CozyWeather.Events.onNewDay += onNewDay.Invoke;
|
||||
CozyWeather.Events.onNewYear += onNewYear.Invoke;
|
||||
CozyWeather.Events.onWeatherChange += onWeatherProfileChange.Invoke;
|
||||
|
||||
}
|
||||
|
||||
public void LogConsoleEvent()
|
||||
{
|
||||
|
||||
Debug.Log("Test Event Passed.");
|
||||
|
||||
}
|
||||
|
||||
public void LogConsoleEvent(string log)
|
||||
{
|
||||
|
||||
Debug.Log($"Test Event Passed. Log: {log}");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update is called every frame, if the MonoBehaviour is enabled.
|
||||
/// </summary>
|
||||
void Update()
|
||||
{
|
||||
if (!isBiomeModule)
|
||||
{
|
||||
ComputeBiomeWeights();
|
||||
return;
|
||||
}
|
||||
|
||||
if (weight == 1)
|
||||
{
|
||||
whileInBiome.Invoke();
|
||||
if (inBiome != true)
|
||||
{
|
||||
inBiome = true;
|
||||
onEnterBiome.Invoke();
|
||||
}
|
||||
}
|
||||
if (weight == 0 && inBiome != false)
|
||||
{
|
||||
inBiome = false;
|
||||
onExitBiome.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fbee55630edd4f4487bf959afde3d53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: bd2373e47db522e4283bd351d94000c6, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyEventModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,126 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using DistantLands.Cozy.Data;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
|
||||
[ExecuteAlways]
|
||||
public class CozyInteractionsModule : CozyModule
|
||||
{
|
||||
|
||||
[CozySearchable(true)]
|
||||
public MaterialManagerProfile profile;
|
||||
// public List<PrecipitationFX> precipitationFXes = new List<PrecipitationFX>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
if (profile == null)
|
||||
return;
|
||||
|
||||
SetupStaticGlobalVariables();
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public override void CozyUpdateLoop()
|
||||
{
|
||||
if (weatherSphere == null)
|
||||
base.InitializeModule();
|
||||
|
||||
if (profile == null)
|
||||
return;
|
||||
|
||||
if (CozyWeather.FreezeUpdateInEditMode && !Application.isPlaying)
|
||||
return;
|
||||
|
||||
SetupStaticGlobalVariables();
|
||||
|
||||
foreach (MaterialManagerProfile.ModulatedValue i in profile.modulatedValues)
|
||||
{
|
||||
switch (i.modulationTarget)
|
||||
{
|
||||
case MaterialManagerProfile.ModulatedValue.ModulationTarget.globalColor:
|
||||
Shader.SetGlobalColor(i.targetVariableName, i.mappedGradient.Evaluate(GetPercentage(i.modulationSource)));
|
||||
break;
|
||||
case MaterialManagerProfile.ModulatedValue.ModulationTarget.globalValue:
|
||||
Shader.SetGlobalFloat(i.targetVariableName, i.mappedCurve.Evaluate(GetPercentage(i.modulationSource)));
|
||||
break;
|
||||
case MaterialManagerProfile.ModulatedValue.ModulationTarget.materialColor:
|
||||
if (i.targetMaterial)
|
||||
i.targetMaterial.SetColor(i.targetVariableName, i.mappedGradient.Evaluate(GetPercentage(i.modulationSource)));
|
||||
break;
|
||||
case MaterialManagerProfile.ModulatedValue.ModulationTarget.materialValue:
|
||||
if (i.targetMaterial)
|
||||
i.targetMaterial.SetFloat(i.targetVariableName, i.mappedCurve.Evaluate(GetPercentage(i.modulationSource)));
|
||||
break;
|
||||
case MaterialManagerProfile.ModulatedValue.ModulationTarget.terrainLayerColor:
|
||||
if (i.targetLayer)
|
||||
i.targetLayer.specular = i.mappedGradient.Evaluate(GetPercentage(i.modulationSource));
|
||||
break;
|
||||
case MaterialManagerProfile.ModulatedValue.ModulationTarget.terrainLayerTint:
|
||||
if (i.targetLayer)
|
||||
i.targetLayer.diffuseRemapMax = i.mappedGradient.Evaluate(GetPercentage(i.modulationSource));
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float GetPercentage(MaterialManagerProfile.ModulatedValue.ModulationSource modulationSource)
|
||||
{
|
||||
|
||||
float i = 0;
|
||||
|
||||
switch (modulationSource)
|
||||
{
|
||||
case (MaterialManagerProfile.ModulatedValue.ModulationSource.dayPercent):
|
||||
if (weatherSphere.timeModule)
|
||||
i = weatherSphere.timeModule.currentTime;
|
||||
break;
|
||||
case (MaterialManagerProfile.ModulatedValue.ModulationSource.precipitation):
|
||||
if (weatherSphere.climateModule)
|
||||
i = Mathf.Clamp01(weatherSphere.climateModule.currentPrecipitation / 100);
|
||||
break;
|
||||
case (MaterialManagerProfile.ModulatedValue.ModulationSource.rainAmount):
|
||||
if (weatherSphere.climateModule)
|
||||
i = weatherSphere.climateModule.groundwaterAmount;
|
||||
break;
|
||||
case (MaterialManagerProfile.ModulatedValue.ModulationSource.snowAmount):
|
||||
if (weatherSphere.climateModule)
|
||||
i = weatherSphere.climateModule.snowAmount;
|
||||
break;
|
||||
case (MaterialManagerProfile.ModulatedValue.ModulationSource.temperature):
|
||||
if (weatherSphere.climateModule)
|
||||
i = Mathf.Clamp01(weatherSphere.climateModule.GetTemperature() / 100);
|
||||
break;
|
||||
case (MaterialManagerProfile.ModulatedValue.ModulationSource.yearPercent):
|
||||
if (weatherSphere.timeModule)
|
||||
i = weatherSphere.timeModule.yearPercentage;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return i;
|
||||
|
||||
}
|
||||
|
||||
public void SetupStaticGlobalVariables()
|
||||
{
|
||||
|
||||
Shader.SetGlobalFloat("CZY_SnowScale", profile.snowNoiseSize);
|
||||
Shader.SetGlobalTexture("CZY_SnowTexture", profile.snowTexture);
|
||||
Shader.SetGlobalColor("CZY_SnowColor", profile.snowColor);
|
||||
Shader.SetGlobalFloat("CZY_PuddleScale", profile.puddleScale);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b63a15514aacb5f4297f97ade092a0f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- weatherSphere: {instanceID: 0}
|
||||
- system: {instanceID: 0}
|
||||
- profile: {fileID: 11400000, guid: 9811ba7ef96ef254eb2034d42353f712, type: 2}
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 4a33bb3031a091045b466491e3ae4b90, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyInteractionsModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,119 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
|
||||
[ExecuteAlways]
|
||||
public class CozyMicrosplatModule : CozyModule
|
||||
{
|
||||
|
||||
public enum UpdateFrequency { everyFrame, onAwake, viaScripting }
|
||||
[CozySearchable("Microsplat")]
|
||||
public UpdateFrequency updateFrequency;
|
||||
|
||||
[Header("Wetness")]
|
||||
[CozySearchable]
|
||||
public bool updateWetness = true;
|
||||
[Range(0f, 1f)]
|
||||
[CozySearchable]
|
||||
public float minWetness = 0f;
|
||||
[Range(0f, 1f)]
|
||||
[CozySearchable]
|
||||
public float maxWetness = 1f;
|
||||
[Header("Rain Ripples")]
|
||||
[CozySearchable]
|
||||
public bool updateRainRipples = true;
|
||||
[Header("Puddle Settings")]
|
||||
[CozySearchable]
|
||||
public bool updatePuddles = true;
|
||||
[Header("Stream Settings")]
|
||||
[CozySearchable]
|
||||
public bool updateStreams = true;
|
||||
[Header("Snow Settings")]
|
||||
[CozySearchable]
|
||||
public bool updateSnow = true;
|
||||
[Header("Wind Settings")]
|
||||
[CozySearchable]
|
||||
public bool updateWindStrength = true;
|
||||
|
||||
private static readonly int GlobalSnowLevel = Shader.PropertyToID("_Global_SnowLevel");
|
||||
private static readonly int GlobalWetnessParams = Shader.PropertyToID("_Global_WetnessParams");
|
||||
private static readonly int GlobalPuddleParams = Shader.PropertyToID("_Global_PuddleParams");
|
||||
private static readonly int GlobalRainIntensity = Shader.PropertyToID("_Global_RainIntensity");
|
||||
private static readonly int GlobalStreamMax = Shader.PropertyToID("_Global_StreamMax");
|
||||
private static readonly int GlobalWindParticulateStrength = Shader.PropertyToID("_Global_WindParticulateStrength");
|
||||
private static readonly int GlobalSnowParticulateStrength = Shader.PropertyToID("_Global_SnowParticulateStrength");
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
public override void InitializeModule()
|
||||
{
|
||||
base.InitializeModule();
|
||||
|
||||
if (updateFrequency == UpdateFrequency.onAwake)
|
||||
{
|
||||
UpdateShaderProperties();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
|
||||
if (CozyWeather.FreezeUpdateInEditMode && !Application.isPlaying)
|
||||
return;
|
||||
|
||||
if (updateFrequency == UpdateFrequency.everyFrame)
|
||||
{
|
||||
UpdateShaderProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateShaderProperties()
|
||||
{
|
||||
|
||||
if (weatherSphere.climateModule)
|
||||
{
|
||||
if (updateSnow)
|
||||
{
|
||||
Shader.SetGlobalFloat(GlobalSnowLevel, weatherSphere.climateModule.snowAmount);
|
||||
}
|
||||
if (updateWetness)
|
||||
{
|
||||
float currentWetness = Mathf.Clamp(weatherSphere.climateModule.groundwaterAmount, minWetness, maxWetness);
|
||||
Shader.SetGlobalVector(GlobalWetnessParams, new Vector2(minWetness, currentWetness));
|
||||
}
|
||||
if (updatePuddles)
|
||||
{
|
||||
Shader.SetGlobalFloat(GlobalPuddleParams, weatherSphere.climateModule.groundwaterAmount);
|
||||
}
|
||||
if (updateRainRipples)
|
||||
{
|
||||
Shader.SetGlobalFloat(GlobalRainIntensity, weatherSphere.climateModule.groundwaterAmount);
|
||||
}
|
||||
if (updateStreams)
|
||||
{
|
||||
Shader.SetGlobalFloat(GlobalStreamMax, weatherSphere.climateModule.groundwaterAmount);
|
||||
}
|
||||
}
|
||||
|
||||
// if (weatherSphere.vfxModule)
|
||||
// {
|
||||
// if (updateWindStrength)
|
||||
// {
|
||||
// Shader.SetGlobalFloat(GlobalWindParticulateStrength, weatherSphere.vfxModule.windManager.windSpeed);
|
||||
// }
|
||||
// if (updateSnow && updateWindStrength)
|
||||
// {
|
||||
// Shader.SetGlobalFloat(GlobalSnowParticulateStrength, weatherSphere.vfxModule.windManager.windSpeed);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d722bd33be7b664d8ac3890ad5aedf1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 6bdf8bec4f4df094387a67a8fb1d6e89, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyMicrosplatModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,96 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if THE_VISUAL_ENGINE
|
||||
using TheVisualEngine;
|
||||
#elif THE_VEGETATION_ENGINE
|
||||
using TheVegetationEngine;
|
||||
#endif
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
|
||||
[ExecuteAlways]
|
||||
public class CozyPureNatureModule : CozyModule
|
||||
{
|
||||
|
||||
public enum UpdateFrequency { everyFrame, onAwake, viaScripting }
|
||||
public UpdateFrequency updateFrequency;
|
||||
|
||||
private CozyWindModule wind;
|
||||
|
||||
|
||||
[Tooltip("Base wind animate the trunks")]
|
||||
[Range(0f, 5f)]
|
||||
public float baseWindPower = 3f;
|
||||
[Tooltip("Base wind animate the trunks")]
|
||||
public float baseWindSpeed = 1f;
|
||||
|
||||
[Tooltip("Bursts are managed by a moving World-Space noise that multiply the base wind speed and power")]
|
||||
[Range(0f, 10f)]
|
||||
public float burstsPower = 0.5f;
|
||||
[Tooltip("Speed of the Bursts noise")]
|
||||
public float burstsSpeed = 5f;
|
||||
[Tooltip("Size of the Bursts noise in Word-Space")]
|
||||
public float burstsScale = 10f;
|
||||
|
||||
[Tooltip("Micro wind animate the leaves")]
|
||||
[Range(0f, 1f)]
|
||||
public float microPower = 0.1f;
|
||||
[Tooltip("Micro wind animate the leaves")]
|
||||
public float microSpeed = 1f;
|
||||
[Tooltip("Micro wind animate the leaves")]
|
||||
public float microFrequency = 3f;
|
||||
|
||||
public float renderDistance = 30f;
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
SetupModule(new Type[1] { typeof(CozyWindModule) });
|
||||
wind = weatherSphere.GetModule<CozyWindModule>();
|
||||
base.InitializeModule();
|
||||
|
||||
if (updateFrequency != UpdateFrequency.viaScripting)
|
||||
UpdateIntegration();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
public override void CozyUpdateLoop()
|
||||
{
|
||||
if (CozyWeather.FreezeUpdateInEditMode && !Application.isPlaying)
|
||||
return;
|
||||
|
||||
if (updateFrequency == UpdateFrequency.everyFrame)
|
||||
UpdateIntegration();
|
||||
}
|
||||
|
||||
public void UpdateIntegration()
|
||||
{
|
||||
|
||||
UpdateWind();
|
||||
|
||||
}
|
||||
|
||||
void UpdateWind()
|
||||
{
|
||||
Shader.SetGlobalFloat("WindPower", baseWindPower * wind.windAmount);
|
||||
Shader.SetGlobalFloat("WindSpeed", baseWindSpeed * wind.windSpeed);
|
||||
Shader.SetGlobalFloat("WindBurstsPower", burstsPower * wind.windGusting);
|
||||
Shader.SetGlobalFloat("WindBurstsSpeed", burstsSpeed * wind.windSpeed);
|
||||
Shader.SetGlobalFloat("WindBurstsScale", burstsScale);
|
||||
Shader.SetGlobalFloat("MicroPower", microPower * wind.windGusting);
|
||||
Shader.SetGlobalFloat("MicroSpeed", microSpeed * wind.windSpeed);
|
||||
Shader.SetGlobalFloat("MicroFrequency", microFrequency);
|
||||
Shader.SetGlobalFloat("GrassRenderDist", renderDistance);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31364be7b06ea4647aa3fd6a55a9827d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 2f9f0595e0d5f8845a8b467b29f958ca, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyPureNatureModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,213 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if COZY_URP
|
||||
using UnityEngine.Rendering.Universal;
|
||||
#endif
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyReflectionsModule : CozyModule
|
||||
{
|
||||
|
||||
public enum UpdateFrequency { everyFrame, onAwake, onHour, viaScripting }
|
||||
[CozySearchable("Reflection")]
|
||||
public UpdateFrequency updateFrequency;
|
||||
[CozySearchable]
|
||||
public Cubemap reflectionCubemap;
|
||||
public Camera reflectionCamera;
|
||||
[Tooltip("How many frames should pass before the cubemap renders again? A value of 0 renders every frame and a value of 30 renders once every 30 frames.")]
|
||||
[Range(0, 30)]
|
||||
[CozySearchable]
|
||||
public int framesBetweenRenders = 10;
|
||||
[Tooltip("What layers should be rendered into the skybox reflections?.")]
|
||||
[CozySearchable]
|
||||
public LayerMask layerMask = 2;
|
||||
public bool automaticallySetLayer;
|
||||
private int framesLeft;
|
||||
public int minimumQualityLevel;
|
||||
|
||||
[Tooltip("Refresh the skybox reflections when the scene loads or unloads.")]
|
||||
[CozySearchable]
|
||||
public bool refreshOnSceneChange;
|
||||
#if COZY_URP
|
||||
public int rendererOverride;
|
||||
public UniversalAdditionalCameraData cameraData;
|
||||
#endif
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
|
||||
base.InitializeModule();
|
||||
reflectionCubemap = Resources.Load("Materials/Reflection Cubemap") as Cubemap;
|
||||
RenderSettings.customReflectionTexture = reflectionCubemap;
|
||||
RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Custom;
|
||||
if (automaticallySetLayer)
|
||||
{
|
||||
weatherSphere.fogMesh.gameObject.layer = ToLayer(layerMask);
|
||||
weatherSphere.skyMesh.gameObject.layer = ToLayer(layerMask);
|
||||
weatherSphere.cloudMesh.gameObject.layer = ToLayer(layerMask);
|
||||
}
|
||||
|
||||
if (updateFrequency == UpdateFrequency.onAwake || updateFrequency == UpdateFrequency.onHour)
|
||||
{
|
||||
StartCoroutine(RenderReflections());
|
||||
}
|
||||
if (updateFrequency == UpdateFrequency.onHour)
|
||||
{
|
||||
CozyWeather.Events.onNewHour += QueueReflections;
|
||||
}
|
||||
}
|
||||
|
||||
new void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
if (updateFrequency == UpdateFrequency.onHour)
|
||||
{
|
||||
CozyWeather.Events.onNewHour -= QueueReflections;
|
||||
}
|
||||
}
|
||||
|
||||
public override void CozyUpdateLoop()
|
||||
{
|
||||
if (weatherSphere == null)
|
||||
{
|
||||
base.InitializeModule();
|
||||
}
|
||||
|
||||
if (CozyWeather.FreezeUpdateInEditMode && !Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (updateFrequency == UpdateFrequency.everyFrame)
|
||||
{
|
||||
if (framesLeft < 0)
|
||||
{
|
||||
StartCoroutine(RenderReflections());
|
||||
framesLeft = framesBetweenRenders + 6;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
framesLeft--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSceneLoaded()
|
||||
{
|
||||
RefreshReflectionsOnSceneChange();
|
||||
}
|
||||
|
||||
public override void OnSceneUnloaded()
|
||||
{
|
||||
RefreshReflectionsOnSceneChange();
|
||||
}
|
||||
|
||||
protected void RefreshReflectionsOnSceneChange()
|
||||
{
|
||||
if (refreshOnSceneChange)
|
||||
StartCoroutine(RenderReflections());
|
||||
}
|
||||
|
||||
public int ToLayer(LayerMask mask)
|
||||
{
|
||||
int value = mask.value;
|
||||
if (value == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (int l = 1; l < 32; l++)
|
||||
{
|
||||
if ((value & (1 << l)) != 0)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override void DeinitializeModule()
|
||||
{
|
||||
base.DeinitializeModule();
|
||||
|
||||
if (reflectionCamera)
|
||||
{
|
||||
DestroyImmediate(reflectionCamera.gameObject);
|
||||
}
|
||||
if (updateFrequency == UpdateFrequency.onHour)
|
||||
{
|
||||
CozyWeather.Events.onNewHour -= QueueReflections;
|
||||
}
|
||||
|
||||
RenderSettings.customReflectionTexture = null;
|
||||
|
||||
}
|
||||
|
||||
public void QueueReflections()
|
||||
{
|
||||
|
||||
StartCoroutine(RenderReflections());
|
||||
}
|
||||
|
||||
public IEnumerator RenderReflections()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
yield break;
|
||||
|
||||
if (QualitySettings.GetQualityLevel() < minimumQualityLevel || reflectionCubemap == null)
|
||||
yield break;
|
||||
|
||||
if (!weatherSphere.cozyCamera)
|
||||
{
|
||||
Debug.LogError("COZY Reflections requires the cozy camera to be set in the settings tab!");
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (reflectionCamera == null)
|
||||
{
|
||||
SetupCamera();
|
||||
}
|
||||
|
||||
reflectionCamera.enabled = true;
|
||||
reflectionCamera.transform.position = transform.position;
|
||||
reflectionCamera.nearClipPlane = weatherSphere.cozyCamera.nearClipPlane;
|
||||
reflectionCamera.farClipPlane = weatherSphere.cozyCamera.farClipPlane;
|
||||
reflectionCamera.cullingMask = layerMask;
|
||||
reflectionCamera.RenderToCubemap(reflectionCubemap);
|
||||
reflectionCamera.enabled = false;
|
||||
|
||||
for (int face = 0; face < 6; face++)
|
||||
{
|
||||
reflectionCamera.RenderToCubemap(reflectionCubemap, (int)Mathf.Pow(2, face));
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetupCamera()
|
||||
{
|
||||
GameObject i = new GameObject
|
||||
{
|
||||
name = "COZY Reflection Camera",
|
||||
hideFlags = HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild | HideFlags.HideInHierarchy
|
||||
};
|
||||
|
||||
reflectionCamera = i.AddComponent<Camera>();
|
||||
reflectionCamera.depth = -50;
|
||||
reflectionCamera.enabled = false;
|
||||
|
||||
#if COZY_URP
|
||||
cameraData = reflectionCamera.GetComponent<UniversalAdditionalCameraData>();
|
||||
cameraData?.SetRenderer(rendererOverride);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 616fcb3956df9b84f9c9e454fc1b6230
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: d6a487c980e3f9841a4165e5b60200ff, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyReflectionsModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,295 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DistantLands.Cozy.Data;
|
||||
#if COZY_URP || COZY_HDRP
|
||||
using UnityEngine.Rendering;
|
||||
#endif
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozySatelliteModule : CozyModule
|
||||
{
|
||||
|
||||
|
||||
[CozySearchable("moon", "satellite")]
|
||||
public SatelliteProfile[] satellites = new SatelliteProfile[0];
|
||||
[HideInInspector]
|
||||
public Transform satHolder = null;
|
||||
[CozySearchable]
|
||||
public bool hideInHierarchy = true;
|
||||
private Light moonLight;
|
||||
[CozySearchable]
|
||||
public int mainMoon;
|
||||
[CozySearchable]
|
||||
public bool useLight = true;
|
||||
#if COZY_URP || COZY_HDRP
|
||||
public LensFlareComponentSRP moonLensFlare;
|
||||
#endif
|
||||
|
||||
public enum MoonPhase
|
||||
{
|
||||
newMoon, waxingCrescent, firstQuarter, waxingGibbous, fullMoon, waningGibbous, thirdQuarter, waningCrescent
|
||||
}
|
||||
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
moonLight = weatherSphere.GetChild<Light>("Moon Light");
|
||||
moonLight.enabled = true;
|
||||
base.InitializeModule();
|
||||
#if COZY_URP || COZY_HDRP
|
||||
if (weatherSphere.moonFlare.flare != null)
|
||||
if (moonLight.GetComponent<LensFlareComponentSRP>())
|
||||
moonLensFlare = moonLight.GetComponent<LensFlareComponentSRP>();
|
||||
else
|
||||
moonLensFlare = moonLight.gameObject.AddComponent<LensFlareComponentSRP>();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
UpdateSatellites();
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (CozyWeather.FreezeUpdateInEditMode && !Application.isPlaying)
|
||||
return;
|
||||
|
||||
if (satHolder == null)
|
||||
{
|
||||
UpdateSatellites();
|
||||
}
|
||||
if (moonLight == null)
|
||||
{
|
||||
moonLight = weatherSphere.GetChild<Light>("Moon Light");
|
||||
}
|
||||
|
||||
if (satHolder.hideFlags == (HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild) && hideInHierarchy)
|
||||
UpdateSatellites();
|
||||
|
||||
if (weatherSphere.cozyCamera && Application.isPlaying)
|
||||
satHolder.position = weatherSphere.cozyCamera.transform.position;
|
||||
|
||||
if (satellites != null)
|
||||
foreach (SatelliteProfile sat in satellites)
|
||||
{
|
||||
if (!sat)
|
||||
break;
|
||||
|
||||
if (sat.orbitRef == null)
|
||||
UpdateSatellites();
|
||||
|
||||
if (sat.changedLastFrame == true)
|
||||
UpdateSatellites();
|
||||
|
||||
|
||||
if (sat.linkToDay && weatherSphere.timeModule)
|
||||
{
|
||||
float dec = sat.declination * Mathf.Sin(Mathf.PI * 2 * (((weatherSphere.modifiedDayPercentage - 0.5f) + (float)(weatherSphere.timeModule.currentDay + sat.rotationPeriodOffset + weatherSphere.timeModule.DaysPerYear * weatherSphere.timeModule.currentYear) % sat.declinationPeriod) / sat.declinationPeriod));
|
||||
sat.orbitRef.localEulerAngles = new Vector3(0, weatherSphere.sunDirection + sat.satelliteDirection, weatherSphere.sunPitch + sat.satellitePitch + dec);
|
||||
sat.satelliteRotation = ((360 * weatherSphere.modifiedDayPercentage) + sat.orbitOffset - 90) + (weatherSphere.modifiedDayPercentage - 0.5f + (float)(sat.rotationPeriodOffset + weatherSphere.timeModule.AbsoluteDay) % sat.rotationPeriod) / sat.rotationPeriod * 360;
|
||||
sat.orbitRef.GetChild(0).localEulerAngles = Vector3.right * sat.satelliteRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
sat.orbitRef.localEulerAngles = new Vector3(0, weatherSphere.sunDirection + sat.satelliteDirection, weatherSphere.sunPitch + sat.satellitePitch);
|
||||
// sat.orbitRef.GetChild(0).localEulerAngles = Vector3.right * ((360 * weatherSphere.dayPercentage) + sat.orbitOffset - 90);
|
||||
sat.satelliteRotation = ((360 * weatherSphere.modifiedDayPercentage) + sat.orbitOffset - 90);
|
||||
sat.orbitRef.GetChild(0).localEulerAngles = Vector3.right * sat.satelliteRotation;
|
||||
|
||||
sat.moonRef.localEulerAngles = sat.initialRotation + sat.satelliteRotateAxis.normalized * Time.timeSinceLevelLoad * sat.satelliteRotateSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
if (!moonLight)
|
||||
return;
|
||||
|
||||
if (satellites.Length == 0)
|
||||
{
|
||||
weatherSphere.moonDirection = Vector3.up;
|
||||
moonLight.transform.forward = Vector3.up;
|
||||
Shader.SetGlobalVector("CZY_MoonDirection", weatherSphere.moonDirection);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
weatherSphere.moonDirection = -moonLight.transform.forward;
|
||||
Shader.SetGlobalVector("CZY_MoonDirection", -moonLight.transform.forward);
|
||||
|
||||
if (mainMoon >= satellites.Length)
|
||||
mainMoon = satellites.Length - 1;
|
||||
|
||||
float moonBrightness = Mathf.Clamp01(Mathf.Sin((weatherSphere.dayPercentage + 0.25f) * 2 * Mathf.PI) + 0.25f) * Mathf.Clamp01(4 * Vector3.Dot(moonLight.transform.forward, Vector3.down));
|
||||
|
||||
moonLight.transform.forward = satellites[mainMoon].orbitRef.GetChild(0).forward;
|
||||
moonLight.enabled = weatherSphere.moonlightColor.grayscale > 0.05f && satellites.Length > 0 && useLight && !weatherSphere.sunLight.enabled;
|
||||
moonLight.color = weatherSphere.moonlightColor * weatherSphere.sunFilter * moonBrightness;
|
||||
moonLight.shadows = moonLight.enabled ? weatherSphere.moonlightShadows : LightShadows.None;
|
||||
|
||||
#if COZY_URP || COZY_HDRP
|
||||
if (moonLensFlare)
|
||||
{
|
||||
moonLensFlare.intensity = weatherSphere.moonFlare.flare ? moonBrightness : 0;
|
||||
moonLensFlare.lensFlareData = weatherSphere.moonFlare.flare;
|
||||
moonLensFlare.allowOffScreen = weatherSphere.moonFlare.allowOffscreen;
|
||||
moonLensFlare.radialScreenAttenuationCurve = weatherSphere.moonFlare.screenAttenuation;
|
||||
moonLensFlare.distanceAttenuationCurve = weatherSphere.moonFlare.screenAttenuation;
|
||||
moonLensFlare.scale = weatherSphere.moonFlare.scale;
|
||||
moonLensFlare.occlusionRadius = weatherSphere.moonFlare.occlusionRadius;
|
||||
moonLensFlare.useOcclusion = weatherSphere.moonFlare.useOcclusion;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void UpdateSatellites()
|
||||
{
|
||||
|
||||
Transform oldHolder = null;
|
||||
|
||||
|
||||
if (satHolder)
|
||||
{
|
||||
oldHolder = satHolder;
|
||||
}
|
||||
|
||||
satHolder = new GameObject("Cozy Satellites").transform;
|
||||
if (hideInHierarchy)
|
||||
satHolder.gameObject.hideFlags = HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild | HideFlags.HideInHierarchy;
|
||||
else
|
||||
satHolder.gameObject.hideFlags = HideFlags.DontSaveInEditor | HideFlags.DontSaveInBuild;
|
||||
|
||||
|
||||
|
||||
if (satellites != null)
|
||||
foreach (SatelliteProfile i in satellites)
|
||||
{
|
||||
InitializeSatellite(i);
|
||||
}
|
||||
|
||||
if (oldHolder)
|
||||
DestroyImmediate(oldHolder.gameObject);
|
||||
|
||||
}
|
||||
|
||||
public void DestroySatellites()
|
||||
{
|
||||
|
||||
if (satHolder)
|
||||
DestroyImmediate(satHolder.gameObject);
|
||||
|
||||
}
|
||||
|
||||
public void DestroySatellite(SatelliteProfile sat)
|
||||
{
|
||||
|
||||
if (sat.orbitRef)
|
||||
DestroyImmediate(sat.orbitRef.gameObject);
|
||||
|
||||
}
|
||||
|
||||
public override void DeinitializeModule()
|
||||
{
|
||||
moonLight.enabled = false;
|
||||
DestroySatellites();
|
||||
Shader.SetGlobalVector("CZY_MoonDirection", Vector3.down);
|
||||
}
|
||||
|
||||
public void InitializeSatellite(SatelliteProfile sat)
|
||||
{
|
||||
|
||||
|
||||
float dist = 0;
|
||||
|
||||
if (weatherSphere.lockToCamera != CozyWeather.LockToCameraStyle.DontLockToCamera && weatherSphere.cozyCamera)
|
||||
dist = .92f * weatherSphere.cozyCamera.farClipPlane * sat.distance;
|
||||
else
|
||||
dist = .92f * 1000 * sat.distance * weatherSphere.transform.localScale.x;
|
||||
|
||||
sat.orbitRef = new GameObject(sat.name).transform;
|
||||
sat.orbitRef.parent = satHolder;
|
||||
sat.orbitRef.transform.localPosition = Vector3.zero;
|
||||
var orbitArm = new GameObject("Orbit Arm");
|
||||
orbitArm.transform.parent = sat.orbitRef;
|
||||
orbitArm.transform.localPosition = Vector3.zero;
|
||||
orbitArm.transform.localEulerAngles = Vector3.zero;
|
||||
sat.moonRef = Instantiate(sat.satelliteReference, Vector3.forward * dist, Quaternion.identity, sat.orbitRef.GetChild(0)).transform;
|
||||
sat.moonRef.transform.localPosition = -Vector3.forward * dist;
|
||||
sat.moonRef.transform.localEulerAngles = sat.initialRotation;
|
||||
sat.moonRef.transform.localScale = sat.satelliteReference.transform.localScale * sat.size * (sat.autoScaleByDistance ? dist / 1000 : 1);
|
||||
sat.orbitRef.localEulerAngles = new Vector3(0, sat.satelliteDirection, sat.satellitePitch);
|
||||
sat.orbitRef.GetChild(0).localEulerAngles = Vector3.right * ((360 * weatherSphere.dayPercentage) + sat.orbitOffset);
|
||||
sat.changedLastFrame = false;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
List<SatelliteProfile> profiles = new List<SatelliteProfile>
|
||||
{
|
||||
Resources.Load("Profiles/Satellites/Stylized Moon") as SatelliteProfile
|
||||
};
|
||||
satellites = profiles.ToArray();
|
||||
}
|
||||
|
||||
public MoonPhase GetMoonPhase()
|
||||
{
|
||||
if (!weatherSphere.timeModule || satellites.Length == 0)
|
||||
return MoonPhase.newMoon;
|
||||
|
||||
SatelliteProfile moon = satellites[mainMoon];
|
||||
|
||||
|
||||
int phase = Mathf.FloorToInt(
|
||||
((weatherSphere.timeModule.AbsoluteDay + moon.rotationPeriodOffset + 1) % moon.rotationPeriod) / (moon.rotationPeriod / 8f));
|
||||
|
||||
return (MoonPhase)Mathf.Clamp(phase, 0, 7);
|
||||
|
||||
}
|
||||
|
||||
public string GetMoonPhaseName()
|
||||
{
|
||||
string name = "New Moon";
|
||||
switch (GetMoonPhase())
|
||||
{
|
||||
case MoonPhase.newMoon:
|
||||
name = "New Moon";
|
||||
break;
|
||||
case MoonPhase.waxingCrescent:
|
||||
name = "Waxing Crescent";
|
||||
break;
|
||||
case MoonPhase.firstQuarter:
|
||||
name = "First Quarter";
|
||||
break;
|
||||
case MoonPhase.waxingGibbous:
|
||||
name = "Waxing Gibbous";
|
||||
break;
|
||||
case MoonPhase.fullMoon:
|
||||
name = "Full Moon";
|
||||
break;
|
||||
case MoonPhase.waningGibbous:
|
||||
name = "Waning Gibbous";
|
||||
break;
|
||||
case MoonPhase.thirdQuarter:
|
||||
name = "Third Quarter";
|
||||
break;
|
||||
case MoonPhase.waningCrescent:
|
||||
name = "Waning Crescent";
|
||||
break;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ff66a3b6d1c71942be925d6ef19482d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: d6d096f39b66f2d4fbf0ced720779466, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozySatelliteModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,164 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using UnityEngine;
|
||||
using DistantLands.Cozy.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
public class CozySaveLoadModule : CozyModule
|
||||
{
|
||||
|
||||
public struct DataSave
|
||||
{
|
||||
public MeridiemTime currentTime;
|
||||
public int day;
|
||||
public int year;
|
||||
public AmbienceProfile currentAmbience;
|
||||
public float ambienceTimer;
|
||||
public WeatherProfile currentWeather;
|
||||
public float weatherTimer;
|
||||
public List<CozyEcosystem.WeatherPattern> forecast;
|
||||
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
InitializeModule();
|
||||
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
Save(0);
|
||||
}
|
||||
|
||||
public void Save(int slot)
|
||||
{
|
||||
|
||||
if (weatherSphere == null)
|
||||
InitializeModule();
|
||||
|
||||
|
||||
DataSave save = new DataSave();
|
||||
|
||||
if (weatherSphere.GetModule(out CozyAmbienceModule module))
|
||||
{
|
||||
save.ambienceTimer = module.ambienceTimer;
|
||||
save.currentAmbience = module.currentAmbienceProfile;
|
||||
}
|
||||
if (weatherSphere.weatherModule)
|
||||
{
|
||||
save.forecast = weatherSphere.weatherModule.ecosystem.currentForecast;
|
||||
save.currentWeather = weatherSphere.weatherModule.ecosystem.currentWeather;
|
||||
save.weatherTimer = weatherSphere.weatherModule.ecosystem.weatherTimer;
|
||||
}
|
||||
if (weatherSphere.timeModule)
|
||||
{
|
||||
save.currentTime = weatherSphere.timeModule.currentTime;
|
||||
save.day = weatherSphere.timeModule.currentDay;
|
||||
save.year = weatherSphere.timeModule.currentYear;
|
||||
}
|
||||
|
||||
PlayerPrefs.SetString($"CZY_Save_{slot}", JsonUtility.ToJson(save));
|
||||
|
||||
Debug.Log($"Saved COZY instance to slot 0\n{save}");
|
||||
|
||||
}
|
||||
|
||||
public string SaveToExternalJSON()
|
||||
{
|
||||
|
||||
DataSave save = new DataSave();
|
||||
|
||||
if (weatherSphere.GetModule(out CozyAmbienceModule module))
|
||||
{
|
||||
save.ambienceTimer = module.ambienceTimer;
|
||||
save.currentAmbience = module.currentAmbienceProfile;
|
||||
}
|
||||
if (weatherSphere.weatherModule)
|
||||
{
|
||||
save.forecast = weatherSphere.weatherModule.ecosystem.currentForecast;
|
||||
save.currentWeather = weatherSphere.weatherModule.ecosystem.currentWeather;
|
||||
save.weatherTimer = weatherSphere.weatherModule.ecosystem.weatherTimer;
|
||||
}
|
||||
if (weatherSphere.timeModule)
|
||||
{
|
||||
save.currentTime = weatherSphere.timeModule.currentTime;
|
||||
save.day = weatherSphere.timeModule.currentDay;
|
||||
save.year = weatherSphere.timeModule.currentYear;
|
||||
}
|
||||
|
||||
|
||||
Debug.Log("Wrote COZY instance to external JSON");
|
||||
return JsonUtility.ToJson(save);
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
|
||||
Load(0);
|
||||
|
||||
}
|
||||
public void Load(int slot)
|
||||
{
|
||||
|
||||
|
||||
if (weatherSphere == null)
|
||||
InitializeModule();
|
||||
|
||||
DataSave save = JsonUtility.FromJson<DataSave>(PlayerPrefs.GetString("CZY_Save_0"));
|
||||
|
||||
if (weatherSphere.GetModule(out CozyAmbienceModule module))
|
||||
{
|
||||
module.ambienceTimer = save.ambienceTimer;
|
||||
module.currentAmbienceProfile = save.currentAmbience;
|
||||
}
|
||||
weatherSphere.weatherModule.ecosystem.currentForecast = save.forecast;
|
||||
weatherSphere.weatherModule.ecosystem.currentWeather = save.currentWeather;
|
||||
weatherSphere.weatherModule.ecosystem.weatherTimer = save.weatherTimer;
|
||||
weatherSphere.timeModule.currentTime = save.currentTime;
|
||||
weatherSphere.timeModule.currentDay = save.day;
|
||||
weatherSphere.timeModule.currentYear = save.year;
|
||||
|
||||
weatherSphere.SetupReferences();
|
||||
|
||||
Debug.Log("Loaded COZY save to current instance");
|
||||
}
|
||||
|
||||
public void LoadFromExternalJSON(string JSONSave)
|
||||
{
|
||||
|
||||
DataSave save = JsonUtility.FromJson<DataSave>(JSONSave);
|
||||
|
||||
JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString("CZY_Save_0"), save);
|
||||
|
||||
if (weatherSphere.GetModule(out CozyAmbienceModule module))
|
||||
{
|
||||
module.ambienceTimer = save.ambienceTimer;
|
||||
module.currentAmbienceProfile = save.currentAmbience;
|
||||
}
|
||||
weatherSphere.weatherModule.ecosystem.currentForecast = save.forecast;
|
||||
weatherSphere.weatherModule.ecosystem.currentWeather = save.currentWeather;
|
||||
weatherSphere.weatherModule.ecosystem.weatherTimer = save.weatherTimer;
|
||||
weatherSphere.timeModule.currentTime = save.currentTime;
|
||||
weatherSphere.timeModule.currentDay = save.day;
|
||||
weatherSphere.timeModule.currentYear = save.year;
|
||||
|
||||
weatherSphere.SetupReferences();
|
||||
|
||||
weatherSphere.SetupReferences();
|
||||
|
||||
Debug.Log("Loaded external JSON to current COZY instance");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9561d7657ccb4c54bad2f3d24fe45330
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 48767fceba992a04794c96aeb9e92fa1, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozySaveLoadModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,174 @@
|
||||
using UnityEngine;
|
||||
#if THE_VISUAL_ENGINE
|
||||
using TheVisualEngine;
|
||||
#elif THE_VEGETATION_ENGINE
|
||||
using TheVegetationEngine;
|
||||
#endif
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyTVEModule : CozyModule
|
||||
{
|
||||
public enum UpdateFrequency { everyFrame, onAwake, viaScripting }
|
||||
public UpdateFrequency updateFrequency;
|
||||
|
||||
[Header("Control Settings")]
|
||||
[Tooltip("Enable motion integration with TVE")]
|
||||
public bool enableMotionControl = true;
|
||||
[Tooltip("Enable season integration with TVE")]
|
||||
public bool enableSeasonControl = true;
|
||||
[Tooltip("Enable wetness integration with TVE")]
|
||||
public bool enableWetnessControl = true;
|
||||
[Tooltip("Enable snow integration with TVE")]
|
||||
public bool enableSnowControl = true;
|
||||
|
||||
#if THE_VISUAL_ENGINE
|
||||
public TVEManager visualManager;
|
||||
#elif THE_VEGETATION_ENGINE
|
||||
public TVEGlobalControl globalControl;
|
||||
public TVEGlobalMotion globalMotion;
|
||||
#endif
|
||||
|
||||
void Awake()
|
||||
{
|
||||
InitializeModule();
|
||||
|
||||
#if THE_VEGETATION_ENGINE || THE_VISUAL_ENGINE
|
||||
if (updateFrequency == UpdateFrequency.onAwake)
|
||||
UpdateTVE();
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
base.InitializeModule();
|
||||
|
||||
if (!weatherSphere)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
#if THE_VISUAL_ENGINE
|
||||
if (!visualManager)
|
||||
visualManager = FindObjectOfType<TVEManager>();
|
||||
|
||||
if (!visualManager)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
visualManager.mainLight = weatherSphere.sunLight;
|
||||
#elif THE_VEGETATION_ENGINE
|
||||
if (!globalControl)
|
||||
globalControl = FindObjectOfType<TVEGlobalControl>();
|
||||
|
||||
if (!globalControl)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!globalMotion)
|
||||
globalMotion = FindObjectOfType<TVEGlobalMotion>();
|
||||
|
||||
if (!globalMotion)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
globalControl.mainLight = weatherSphere.sunLight;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (CozyWeather.FreezeUpdateInEditMode && !Application.isPlaying)
|
||||
return;
|
||||
|
||||
if (updateFrequency == UpdateFrequency.everyFrame)
|
||||
UpdateTVE();
|
||||
}
|
||||
|
||||
public void UpdateTVE()
|
||||
{
|
||||
#if THE_VEGETATION_ENGINE
|
||||
if (weatherSphere.climateModule)
|
||||
{
|
||||
if (enableWetnessControl)
|
||||
globalControl.globalWetness = weatherSphere.climateModule.groundwaterAmount;
|
||||
|
||||
if (enableSnowControl)
|
||||
globalControl.globalOverlay = weatherSphere.climateModule.snowAmount;
|
||||
}
|
||||
|
||||
if (enableSeasonControl)
|
||||
globalControl.seasonControl = Mathf.Clamp(weatherSphere.timeModule.yearPercentage * 4, 0, 4);
|
||||
|
||||
if (enableMotionControl)
|
||||
{
|
||||
float windPower = 0f;
|
||||
Vector3 windDirection = Vector3.forward;
|
||||
|
||||
if (weatherSphere.windModule != null)
|
||||
{
|
||||
// Scale wind power from Cozy's 0-2 range to TVE's 0-1 range by halving it
|
||||
windPower = weatherSphere.windModule.windAmount * 0.5f;
|
||||
windDirection = weatherSphere.windModule.WindDirection;
|
||||
|
||||
// Safety check for NaN or infinity
|
||||
if (float.IsNaN(windPower) || float.IsInfinity(windPower))
|
||||
{
|
||||
windPower = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp to 1 just in case wind goes beyond TVE's maximum
|
||||
globalMotion.windPower = Mathf.Clamp01(windPower);
|
||||
globalMotion.transform.LookAt(globalMotion.transform.position + windDirection, Vector3.up);
|
||||
}
|
||||
#elif THE_VISUAL_ENGINE
|
||||
if (weatherSphere.climateModule)
|
||||
{
|
||||
if (enableWetnessControl)
|
||||
visualManager.globalAtmoData.wetnessIntensity = weatherSphere.climateModule.groundwaterAmount;
|
||||
|
||||
if (enableSnowControl)
|
||||
visualManager.globalAtmoData.overlayIntensity = weatherSphere.climateModule.snowAmount;
|
||||
}
|
||||
|
||||
if (enableSeasonControl)
|
||||
visualManager.seasonControl = Mathf.Clamp(weatherSphere.timeModule.yearPercentage * 4, 0, 4);
|
||||
|
||||
if (enableMotionControl)
|
||||
{
|
||||
float windPower = 0f;
|
||||
Vector3 windDirection = Vector3.forward;
|
||||
|
||||
if (weatherSphere.windModule != null)
|
||||
{
|
||||
// Scale wind power from Cozy's 0-2 range to TVE's 0-1 range by halving it
|
||||
windPower = weatherSphere.windModule.windAmount * 0.5f;
|
||||
windDirection = weatherSphere.windModule.WindDirection;
|
||||
|
||||
// Safety check for NaN or infinity
|
||||
if (float.IsNaN(windPower) || float.IsInfinity(windPower))
|
||||
{
|
||||
windPower = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp to 1 just in case wind goes beyond TVE's maximum
|
||||
visualManager.motionControl = Mathf.Clamp01(windPower);
|
||||
visualManager.transform.LookAt(visualManager.transform.position + windDirection, Vector3.up);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cd9cd510650ae7499b8b48b40972bcc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 0728b5315a36ebc44b977d243085518a, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyTVEModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,391 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using DistantLands.Cozy.Data;
|
||||
using UnityEngine.Serialization;
|
||||
using System;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyTimeModule : CozyModule
|
||||
{
|
||||
|
||||
public CozyTransitModule transit;
|
||||
public PerennialProfile perennialProfile;
|
||||
public CozyDateOverride overrideDate;
|
||||
[Range(0, 1)]
|
||||
public float yearPercentage = 0;
|
||||
public float modifiedDayPercentage
|
||||
{
|
||||
get
|
||||
{
|
||||
return transit ? transit.ModifyDayPercentage(currentTime) / 360 : currentTime;
|
||||
}
|
||||
}
|
||||
public bool transitioningTime;
|
||||
|
||||
[FormerlySerializedAs("m_DayPercentage")]
|
||||
[CozySearchable]
|
||||
public MeridiemTime currentTime = 0;
|
||||
|
||||
public int AbsoluteDay => (currentDay % DaysPerYear) + DaysPerYear * currentYear;
|
||||
|
||||
[CozySearchable]
|
||||
public int currentDay;
|
||||
[CozySearchable]
|
||||
public int currentYear;
|
||||
public CozyTimeModule parentModule;
|
||||
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
base.InitializeModule();
|
||||
weatherSphere.timeModule = this;
|
||||
}
|
||||
|
||||
internal override bool CheckIfModuleCanBeRemoved(out string warning)
|
||||
{
|
||||
if (weatherSphere.GetModule<CozyTransitModule>() != null)
|
||||
{
|
||||
warning = "Transit Module";
|
||||
return false;
|
||||
}
|
||||
warning = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
internal override bool CheckIfModuleCanBeAdded(out string warning)
|
||||
{
|
||||
if (weatherSphere.GetModule<SystemTimeModule>() != null)
|
||||
{
|
||||
warning = "System Time Module";
|
||||
return false;
|
||||
}
|
||||
warning = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
SetupTime();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (weatherSphere.timeModule == null)
|
||||
weatherSphere.timeModule = this;
|
||||
|
||||
ManageTime();
|
||||
|
||||
yearPercentage = GetCurrentYearPercentage();
|
||||
|
||||
}
|
||||
|
||||
void SetupTime()
|
||||
{
|
||||
if (perennialProfile.resetTimeOnStart)
|
||||
currentTime = perennialProfile.startTime;
|
||||
|
||||
|
||||
if (perennialProfile.realisticYear)
|
||||
perennialProfile.daysPerYear = perennialProfile.GetRealisticDaysPerYear(currentYear);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constrains the time to fit within the length parameters set on the perennial profile.
|
||||
/// </summary>
|
||||
private void ConstrainTime()
|
||||
{
|
||||
if (currentTime >= 1)
|
||||
{
|
||||
currentTime -= 1;
|
||||
ChangeDay(1);
|
||||
weatherSphere.events.RaiseOnDayChange();
|
||||
}
|
||||
|
||||
if (currentTime < 0)
|
||||
{
|
||||
currentTime += 1;
|
||||
ChangeDay(-1);
|
||||
weatherSphere.events.RaiseOnDayChange();
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeDay(int change)
|
||||
{
|
||||
|
||||
if (overrideDate)
|
||||
{
|
||||
overrideDate.ChangeDay(change);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!perennialProfile.progressDay)
|
||||
return;
|
||||
|
||||
currentDay += change;
|
||||
|
||||
if (currentDay >= perennialProfile.daysPerYear)
|
||||
{
|
||||
currentDay -= perennialProfile.daysPerYear;
|
||||
currentYear++;
|
||||
weatherSphere.events.RaiseOnYearChange();
|
||||
}
|
||||
|
||||
if (currentDay < 0)
|
||||
{
|
||||
currentDay += perennialProfile.daysPerYear;
|
||||
currentYear--;
|
||||
weatherSphere.events.RaiseOnYearChange();
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("GetDaysPerYear() is deprecated. Please use DaysPerYear instead.")]
|
||||
public int GetDaysPerYear()
|
||||
{
|
||||
if (overrideDate)
|
||||
return overrideDate.DaysPerYear();
|
||||
|
||||
if (perennialProfile.realisticYear)
|
||||
return perennialProfile.GetRealisticDaysPerYear(currentYear);
|
||||
else
|
||||
return perennialProfile.daysPerYear;
|
||||
}
|
||||
|
||||
public int DaysPerYear
|
||||
{
|
||||
get
|
||||
{
|
||||
if (overrideDate)
|
||||
return overrideDate.DaysPerYear();
|
||||
|
||||
if (perennialProfile.realisticYear)
|
||||
return perennialProfile.GetRealisticDaysPerYear(currentYear);
|
||||
else
|
||||
return perennialProfile.daysPerYear;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetSunTransitTime(out MeridiemTime sunrise, out MeridiemTime sunset)
|
||||
{
|
||||
if (transit)
|
||||
{
|
||||
transit.GetSunTransitTime(out sunrise, out sunset);
|
||||
return;
|
||||
}
|
||||
|
||||
sunrise = 0.25f;
|
||||
sunset = 0.75f;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current year percentage (0 - 1).
|
||||
/// </summary>
|
||||
public float GetCurrentYearPercentage()
|
||||
{
|
||||
|
||||
if (overrideDate)
|
||||
return overrideDate.GetCurrentYearPercentage();
|
||||
|
||||
float dat = DayAndTime();
|
||||
return dat / (float)DaysPerYear;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current year percentage (0 - 1) after a number of ticks has passed.
|
||||
/// </summary>
|
||||
public float GetCurrentYearPercentage(float inTIme)
|
||||
{
|
||||
if (overrideDate)
|
||||
return overrideDate.GetCurrentYearPercentage(inTIme);
|
||||
|
||||
float dat = DayAndTime() + inTIme;
|
||||
return dat / perennialProfile.daysPerYear;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current day plus the current day percentage (0-1).
|
||||
/// </summary>
|
||||
public float DayAndTime()
|
||||
{
|
||||
if (overrideDate)
|
||||
return overrideDate.DayAndTime();
|
||||
|
||||
return currentDay + currentTime;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manages the movement of time in the scene.
|
||||
/// </summary>
|
||||
public void ManageTime()
|
||||
{
|
||||
|
||||
if (Application.isPlaying && !perennialProfile.pauseTime)
|
||||
currentTime += modifiedTimeSpeed * Time.deltaTime;
|
||||
|
||||
ConstrainTime();
|
||||
|
||||
}
|
||||
|
||||
public float modifiedTimeSpeed
|
||||
{
|
||||
get
|
||||
{
|
||||
return perennialProfile.timeMovementSpeed * (perennialProfile.pauseTime ? 0 : 1) * (perennialProfile.modulateTimeSpeed ? perennialProfile.timeSpeedMultiplier.Evaluate(currentTime) : 1) / 1440;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Skips the weather system forward by the ticksToSkip value.
|
||||
/// </summary>
|
||||
public void SkipTime(MeridiemTime timeToSkip)
|
||||
{
|
||||
|
||||
|
||||
currentTime += (float)timeToSkip;
|
||||
|
||||
if (weatherSphere.GetModule<CozyAmbienceModule>())
|
||||
weatherSphere.GetModule<CozyAmbienceModule>().SkipTime(timeToSkip);
|
||||
|
||||
foreach (CozySystem i in weatherSphere.systems)
|
||||
{
|
||||
i.SkipTime(timeToSkip);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SkipTime(MeridiemTime timeToSkip, int daysToSkip)
|
||||
{
|
||||
|
||||
currentTime += (float)timeToSkip;
|
||||
currentDay += daysToSkip;
|
||||
|
||||
if (weatherSphere.GetModule<CozyAmbienceModule>())
|
||||
weatherSphere.GetModule<CozyAmbienceModule>().SkipTime(timeToSkip + daysToSkip);
|
||||
|
||||
foreach (CozySystem i in weatherSphere.systems)
|
||||
{
|
||||
i.SkipTime(timeToSkip + daysToSkip);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHour(int hour)
|
||||
{
|
||||
currentTime = new MeridiemTime(hour, currentTime.minutes, currentTime.seconds, currentTime.milliseconds);
|
||||
}
|
||||
public void SetMinute(int minute)
|
||||
{
|
||||
currentTime = new MeridiemTime(currentTime.hours, minute, currentTime.seconds, currentTime.milliseconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the title for the current month.
|
||||
/// </summary>
|
||||
public string MonthTitle(float month)
|
||||
{
|
||||
|
||||
|
||||
if (perennialProfile.realisticYear)
|
||||
{
|
||||
|
||||
GetCurrentMonth(out string monthName, out int monthDay, out float monthPercentage);
|
||||
return monthName + " " + monthDay;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
float j = Mathf.Floor(month * 12);
|
||||
float monthLength = perennialProfile.daysPerYear / 12;
|
||||
float monthTime = DayAndTime() - (j * monthLength);
|
||||
|
||||
PerennialProfile.DefaultYear monthName = (PerennialProfile.DefaultYear)j;
|
||||
PerennialProfile.TimeDivisors monthTimeName = PerennialProfile.TimeDivisors.Mid;
|
||||
|
||||
if ((monthTime / monthLength) < 0.33f)
|
||||
monthTimeName = PerennialProfile.TimeDivisors.Early;
|
||||
else if ((monthTime / monthLength) > 0.66f)
|
||||
monthTimeName = PerennialProfile.TimeDivisors.Late;
|
||||
else
|
||||
monthTimeName = PerennialProfile.TimeDivisors.Mid;
|
||||
|
||||
|
||||
return $"{monthTimeName} {monthName}";
|
||||
}
|
||||
}
|
||||
|
||||
public void GetCurrentMonth(out string monthName, out int monthDay, out float monthPercentage)
|
||||
{
|
||||
|
||||
int i = currentDay;
|
||||
int j = 0;
|
||||
|
||||
while (i > ((perennialProfile.useLeapYear && currentYear % 4 == 0) ? perennialProfile.leapYear[j].days : perennialProfile.standardYear[j].days))
|
||||
{
|
||||
|
||||
i -= (perennialProfile.useLeapYear && currentYear % 4 == 0) ? perennialProfile.leapYear[j].days : perennialProfile.standardYear[j].days;
|
||||
|
||||
j++;
|
||||
|
||||
if (j >= ((perennialProfile.useLeapYear && currentYear % 4 == 0) ? perennialProfile.leapYear.Length : perennialProfile.standardYear.Length))
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
PerennialProfile.Month k = (perennialProfile.useLeapYear && currentYear % 4 == 0) ? perennialProfile.leapYear[j] : perennialProfile.standardYear[j];
|
||||
|
||||
monthName = k.name;
|
||||
monthDay = i;
|
||||
monthPercentage = k.days;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Smoothly skips a set amount of time into the future.
|
||||
/// <param name="timeToSkip">The day percentage (given in a float or Meridiem Time) to skip forward.</param>
|
||||
/// <param name="time">The time in seconds it takes to transition to the new time.</param>
|
||||
/// </summary>
|
||||
public void TransitionTime(float timeToSkip, float time)
|
||||
{
|
||||
|
||||
StartCoroutine(TransitionTime(currentTime, timeToSkip, time));
|
||||
|
||||
}
|
||||
|
||||
IEnumerator TransitionTime(float startDayPercentage, float timeToSkip, float time)
|
||||
{
|
||||
|
||||
transitioningTime = true;
|
||||
float t = time;
|
||||
float targetTime = timeToSkip % 1;
|
||||
float targetDay = Mathf.Floor(timeToSkip);
|
||||
float transitionSpeed = timeToSkip / time;
|
||||
|
||||
while (t > 0)
|
||||
{
|
||||
|
||||
float div = 1 - (t / time);
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
currentTime += Time.deltaTime * transitionSpeed;
|
||||
|
||||
t -= Time.deltaTime;
|
||||
|
||||
}
|
||||
|
||||
transitioningTime = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a04d78c316cde1b4d9ab219d80d25d11
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- weatherSphere: {instanceID: 0}
|
||||
- transit: {instanceID: 0}
|
||||
- perennialProfile: {fileID: 11400000, guid: 8ce0d8458b4495b4593c1e03027a0ce5, type: 2}
|
||||
- overrideTime: {instanceID: 0}
|
||||
- overrideDate: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 133489adeebdafa48b245f103e2e3ef7, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyTimeModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,357 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyTransitModule : CozyModule
|
||||
{
|
||||
|
||||
[System.Serializable]
|
||||
public struct TimeWeightRelation
|
||||
{
|
||||
[MeridiemTimeAttribute] public float time; [Range(0, 360)] public float sunHeight; [Range(0, 1)] public float weight;
|
||||
|
||||
public TimeWeightRelation(float time, float sunHeight, float weight)
|
||||
{
|
||||
this.time = time;
|
||||
this.sunHeight = sunHeight;
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
||||
[HideInInspector]
|
||||
public AnimationCurve sunMovementCurve;
|
||||
|
||||
[Tooltip("Specifies the default weight of the sunrise.")]
|
||||
[CozySearchable]
|
||||
public TimeWeightRelation sunriseWeight = new TimeWeightRelation(0.25f, 90, 0.2f);
|
||||
[Tooltip("Specifies the default weight of the day.")]
|
||||
[CozySearchable]
|
||||
public TimeWeightRelation dayWeight = new TimeWeightRelation(0.5f, 180, 0.2f);
|
||||
[Tooltip("Specifies the default weight of the sunset.")]
|
||||
[CozySearchable]
|
||||
public TimeWeightRelation sunsetWeight = new TimeWeightRelation(0.75f, 270, 0.2f);
|
||||
[Tooltip("Specifies the default weight of the night.")]
|
||||
[CozySearchable]
|
||||
public TimeWeightRelation nightWeight = new TimeWeightRelation(1, 360, 0.2f);
|
||||
|
||||
[Tooltip("Specifies the day length multiplier in the spring.")]
|
||||
[Range(-1, 1)]
|
||||
[CozySearchable]
|
||||
public float springDayLengthOffset = 0;
|
||||
[Tooltip("Specifies the day length multiplier in the summer.")]
|
||||
[Range(-1, 1)]
|
||||
[CozySearchable]
|
||||
public float summerDayLengthOffset = 0.4f;
|
||||
[Tooltip("Specifies the day length multiplier in the fall.")]
|
||||
[Range(-1, 1)]
|
||||
[CozySearchable]
|
||||
public float fallDayLengthOffset = 0;
|
||||
[Tooltip("Specifies the day length multiplier in the winter.")]
|
||||
[Range(-1, 1)]
|
||||
[CozySearchable]
|
||||
public float winterDayLengthOffset = -0.3f;
|
||||
|
||||
|
||||
[HideTitle(4)]
|
||||
public AnimationCurve dayWeightsDisplayCurve;
|
||||
[HideTitle(4)]
|
||||
public AnimationCurve yearWeightsCurve;
|
||||
public enum TimeCurveSettings { linearDay, simpleCurve, advancedCurve }
|
||||
public TimeCurveSettings timeCurveSettings;
|
||||
|
||||
[System.Serializable]
|
||||
public class TimeBlock
|
||||
{
|
||||
public MeridiemTime start;
|
||||
public MeridiemTime end;
|
||||
public TimeBlock(float startDayPercentage, float endDayPercentage)
|
||||
{
|
||||
start = startDayPercentage;
|
||||
end = endDayPercentage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CozySearchable]
|
||||
public TimeBlock dawnBlock = new TimeBlock(4f / 24f, 5.5f / 24f);
|
||||
[CozySearchable]
|
||||
public TimeBlock morningBlock = new TimeBlock(6f / 24f, 7f / 24f);
|
||||
[CozySearchable]
|
||||
public TimeBlock dayBlock = new TimeBlock(7.5f / 24f, 9f / 24f);
|
||||
[CozySearchable]
|
||||
public TimeBlock afternoonBlock = new TimeBlock(13f / 24f, 14f / 24f);
|
||||
[CozySearchable]
|
||||
public TimeBlock eveningBlock = new TimeBlock(16f / 24f, 18f / 24f);
|
||||
[CozySearchable]
|
||||
public TimeBlock twilightBlock = new TimeBlock(20f / 24f, 21f / 24f);
|
||||
[CozySearchable]
|
||||
public TimeBlock nightBlock = new TimeBlock(21f / 24f, 22f / 24f);
|
||||
|
||||
public enum TimeBlockName { dawn, morning, day, afternoon, evening, twilight, night }
|
||||
|
||||
public void GetModifiedDayPercent()
|
||||
{
|
||||
|
||||
yearWeightsCurve = new AnimationCurve(new Keyframe[5]
|
||||
{
|
||||
new Keyframe(0, winterDayLengthOffset, 0, 0),
|
||||
new Keyframe(0.25f, springDayLengthOffset, 0, 0),
|
||||
new Keyframe(0.5f, summerDayLengthOffset, 0, 0),
|
||||
new Keyframe(0.75f, fallDayLengthOffset, 0, 0),
|
||||
new Keyframe(1, winterDayLengthOffset, 0, 0)
|
||||
});
|
||||
|
||||
float offset = yearWeightsCurve.Evaluate(weatherSphere.timeModule.yearPercentage) / 5;
|
||||
|
||||
switch (timeCurveSettings)
|
||||
{
|
||||
|
||||
case TimeCurveSettings.advancedCurve:
|
||||
sunMovementCurve = new AnimationCurve(new Keyframe[5]
|
||||
{
|
||||
new Keyframe(0, 0, 0, 0, nightWeight.weight, nightWeight.weight),
|
||||
new Keyframe(sunriseWeight.time - offset, sunriseWeight.sunHeight, 0, 0, sunriseWeight.weight, sunriseWeight.weight),
|
||||
new Keyframe(dayWeight.time, dayWeight.sunHeight, 0, 0, dayWeight.weight, dayWeight.weight),
|
||||
new Keyframe(sunsetWeight.time + offset, sunsetWeight.sunHeight, 0, 0, sunsetWeight.weight, sunsetWeight.weight),
|
||||
new Keyframe(1, sunsetWeight.sunHeight > dayWeight.sunHeight ? 360 : 0, 0, 0, nightWeight.weight, nightWeight.weight)
|
||||
});
|
||||
|
||||
dayWeightsDisplayCurve = new AnimationCurve(new Keyframe[5]
|
||||
{
|
||||
new Keyframe(0, 0, 0, 0, nightWeight.weight, nightWeight.weight),
|
||||
new Keyframe(sunriseWeight.time - offset, sunriseWeight.sunHeight, 0, 0, sunriseWeight.weight, sunriseWeight.weight),
|
||||
new Keyframe(dayWeight.time, dayWeight.sunHeight, 0, 0, dayWeight.weight, dayWeight.weight),
|
||||
new Keyframe(sunsetWeight.time + offset, sunsetWeight.sunHeight > 180 ? 360 - sunsetWeight.sunHeight : sunsetWeight.sunHeight, 0, 0, sunsetWeight.weight, sunsetWeight.weight),
|
||||
new Keyframe(1, 0, 0, 0, nightWeight.weight, nightWeight.weight)
|
||||
});
|
||||
break;
|
||||
|
||||
case TimeCurveSettings.simpleCurve:
|
||||
sunMovementCurve = new AnimationCurve(new Keyframe[5]
|
||||
{
|
||||
new Keyframe(0, 0, 0, 0, nightWeight.weight, nightWeight.weight),
|
||||
new Keyframe(0.25f - offset, 90f, 0, 0, sunriseWeight.weight, sunriseWeight.weight),
|
||||
new Keyframe(0.5f, 180f, 0, 0, dayWeight.weight, dayWeight.weight),
|
||||
new Keyframe(0.75f + offset, 270f, 0, 0, sunsetWeight.weight, sunsetWeight.weight),
|
||||
new Keyframe(1, 360, 0, 0, nightWeight.weight, nightWeight.weight)
|
||||
});
|
||||
|
||||
dayWeightsDisplayCurve = new AnimationCurve(new Keyframe[5]
|
||||
{
|
||||
new Keyframe(0, 0, 0, 0, nightWeight.weight, nightWeight.weight),
|
||||
new Keyframe(0.25f - offset, 90f, 0, 0, sunriseWeight.weight, sunriseWeight.weight),
|
||||
new Keyframe(0.5f, 180f, 0, 0, dayWeight.weight, dayWeight.weight),
|
||||
new Keyframe(0.75f + offset, 90, 0, 0, sunsetWeight.weight, sunsetWeight.weight),
|
||||
new Keyframe(1, 0, 0, 0, nightWeight.weight, nightWeight.weight)
|
||||
});
|
||||
break;
|
||||
|
||||
case TimeCurveSettings.linearDay:
|
||||
sunMovementCurve = new AnimationCurve(new Keyframe[5]
|
||||
{
|
||||
new Keyframe(0, 0, 0, 0, 0, 0),
|
||||
new Keyframe(0.25f - offset, 90, 0, 0, 0, 0),
|
||||
new Keyframe(0.5f, 180, 0, 0, 0, 0),
|
||||
new Keyframe(0.75f + offset, 270, 0, 0, 0, 0),
|
||||
new Keyframe(1, 360, 0, 0, 0, 0)
|
||||
});
|
||||
|
||||
dayWeightsDisplayCurve = new AnimationCurve(new Keyframe[5]
|
||||
{
|
||||
new Keyframe(0, 0, 0, 0, 0, 0),
|
||||
new Keyframe(0.25f - offset, 90, 0, 0, 0, 0),
|
||||
new Keyframe(0.5f, 180, 0, 0, 0, 0),
|
||||
new Keyframe(0.75f + offset, 90, 0, 0, 0, 0),
|
||||
new Keyframe(1, 0, 0, 0, 0, 0)
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetSunTransitTime(out MeridiemTime sunrise, out MeridiemTime sunset)
|
||||
{
|
||||
yearWeightsCurve = new AnimationCurve(new Keyframe[5]
|
||||
{
|
||||
new Keyframe(0, winterDayLengthOffset, 0, 0),
|
||||
new Keyframe(0.25f, springDayLengthOffset, 0, 0),
|
||||
new Keyframe(0.5f, summerDayLengthOffset, 0, 0),
|
||||
new Keyframe(0.75f, fallDayLengthOffset, 0, 0),
|
||||
new Keyframe(1, winterDayLengthOffset, 0, 0)
|
||||
});
|
||||
|
||||
float offset = yearWeightsCurve.Evaluate(weatherSphere.timeModule.yearPercentage) / 5;
|
||||
sunrise = 0.25f - offset;
|
||||
sunset = 0.75f + offset;
|
||||
|
||||
if (timeCurveSettings == TimeCurveSettings.advancedCurve)
|
||||
{
|
||||
sunrise = sunriseWeight.time - offset;
|
||||
sunset = sunsetWeight.time + offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
base.SetupModule(new Type[1] { typeof(CozyTimeModule) });
|
||||
|
||||
CozyWeather.Events.onNewDay += GetModifiedDayPercent;
|
||||
if (weatherSphere.timeModule)
|
||||
{
|
||||
weatherSphere.timeModule.transit = this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
SetupTimeEvents();
|
||||
GetModifiedDayPercent();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
ManageTimeEvents();
|
||||
}
|
||||
|
||||
private void ManageTimeEvents()
|
||||
{
|
||||
|
||||
if (weatherSphere.timeModule.currentTime > weatherSphere.events.timeToCheckFor && !(weatherSphere.timeModule.currentTime > nightBlock.start && weatherSphere.events.timeToCheckFor == dawnBlock.start))
|
||||
{
|
||||
if (weatherSphere.timeModule.currentTime > nightBlock.start && weatherSphere.events.timeToCheckFor == nightBlock.start)
|
||||
{
|
||||
weatherSphere.events.RaiseOnNight();
|
||||
weatherSphere.events.timeToCheckFor = dawnBlock.start;
|
||||
}
|
||||
else if (weatherSphere.timeModule.currentTime > twilightBlock.start && weatherSphere.events.timeToCheckFor == twilightBlock.start)
|
||||
{
|
||||
weatherSphere.events.RaiseOnTwilight();
|
||||
weatherSphere.events.timeToCheckFor = nightBlock.start;
|
||||
}
|
||||
else if (weatherSphere.timeModule.currentTime > eveningBlock.start && weatherSphere.events.timeToCheckFor == eveningBlock.start)
|
||||
{
|
||||
weatherSphere.events.RaiseOnEvening();
|
||||
weatherSphere.events.timeToCheckFor = twilightBlock.start;
|
||||
}
|
||||
else if (weatherSphere.timeModule.currentTime > afternoonBlock.start && weatherSphere.events.timeToCheckFor == afternoonBlock.start)
|
||||
{
|
||||
weatherSphere.events.RaiseOnAfternoon();
|
||||
weatherSphere.events.timeToCheckFor = eveningBlock.start;
|
||||
}
|
||||
else if (weatherSphere.timeModule.currentTime > dayBlock.start && weatherSphere.events.timeToCheckFor == dayBlock.start)
|
||||
{
|
||||
weatherSphere.events.RaiseOnDay();
|
||||
weatherSphere.events.timeToCheckFor = afternoonBlock.start;
|
||||
}
|
||||
else if (weatherSphere.timeModule.currentTime > morningBlock.start && weatherSphere.events.timeToCheckFor == morningBlock.start)
|
||||
{
|
||||
weatherSphere.events.RaiseOnMorning();
|
||||
weatherSphere.events.timeToCheckFor = dayBlock.start;
|
||||
}
|
||||
else
|
||||
{
|
||||
weatherSphere.events.RaiseOnDawn();
|
||||
weatherSphere.events.timeToCheckFor = morningBlock.start;
|
||||
}
|
||||
}
|
||||
|
||||
// if (weatherSphere.timeModule.currentTime < weatherSphere.events.timeToCheckFor - 0.25f) { SetupTimeEvents(); }
|
||||
if (Mathf.FloorToInt(weatherSphere.timeModule.currentTime * 24) != weatherSphere.events.currentHour)
|
||||
{
|
||||
weatherSphere.events.currentHour = Mathf.FloorToInt(weatherSphere.timeModule.currentTime * 24);
|
||||
weatherSphere.events.RaiseOnNewHour();
|
||||
}
|
||||
if (Mathf.FloorToInt(weatherSphere.timeModule.currentTime * 1440) != weatherSphere.events.currentMinute)
|
||||
{
|
||||
weatherSphere.events.currentMinute = Mathf.FloorToInt(weatherSphere.timeModule.currentTime * 1440);
|
||||
weatherSphere.events.RaiseOnMinutePass();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SetupTimeEvents()
|
||||
{
|
||||
weatherSphere.events.timeToCheckFor = dawnBlock.start;
|
||||
if (weatherSphere.timeModule.currentTime > dawnBlock.start)
|
||||
weatherSphere.events.timeToCheckFor = morningBlock.start;
|
||||
if (weatherSphere.timeModule.currentTime > morningBlock.start)
|
||||
weatherSphere.events.timeToCheckFor = dayBlock.start;
|
||||
if (weatherSphere.timeModule.currentTime > dayBlock.start)
|
||||
weatherSphere.events.timeToCheckFor = afternoonBlock.start;
|
||||
if (weatherSphere.timeModule.currentTime > afternoonBlock.start)
|
||||
weatherSphere.events.timeToCheckFor = eveningBlock.start;
|
||||
if (weatherSphere.timeModule.currentTime > eveningBlock.start)
|
||||
weatherSphere.events.timeToCheckFor = twilightBlock.start;
|
||||
if (weatherSphere.timeModule.currentTime > twilightBlock.start)
|
||||
weatherSphere.events.timeToCheckFor = nightBlock.start;
|
||||
if (weatherSphere.timeModule.currentTime > nightBlock.start)
|
||||
weatherSphere.events.timeToCheckFor = dawnBlock.start;
|
||||
|
||||
weatherSphere.events.currentHour = Mathf.FloorToInt(weatherSphere.timeModule.currentTime * 24);
|
||||
weatherSphere.events.currentMinute = Mathf.FloorToInt(weatherSphere.timeModule.currentTime * 1440);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public float ModifyDayPercentage(float input)
|
||||
{
|
||||
return sunMovementCurve.Evaluate(input);
|
||||
}
|
||||
|
||||
public TimeBlockName GetTimeBlock()
|
||||
{
|
||||
TimeBlockName currentBlock = TimeBlockName.night;
|
||||
float time = weatherSphere.timeModule.currentTime;
|
||||
|
||||
if (time > dawnBlock.start && time < morningBlock.start)
|
||||
currentBlock = TimeBlockName.dawn;
|
||||
if (time > morningBlock.start && time < dayBlock.start)
|
||||
currentBlock = TimeBlockName.morning;
|
||||
if (time > dayBlock.start && time < afternoonBlock.start)
|
||||
currentBlock = TimeBlockName.day;
|
||||
if (time > afternoonBlock.start && time < eveningBlock.start)
|
||||
currentBlock = TimeBlockName.afternoon;
|
||||
if (time > eveningBlock.start && time < twilightBlock.start)
|
||||
currentBlock = TimeBlockName.evening;
|
||||
if (time > twilightBlock.start && time < nightBlock.start)
|
||||
currentBlock = TimeBlockName.twilight;
|
||||
|
||||
return currentBlock;
|
||||
|
||||
}
|
||||
|
||||
public TimeBlockName GetTimeBlock(float time)
|
||||
{
|
||||
TimeBlockName currentBlock = TimeBlockName.night;
|
||||
|
||||
if (time > dawnBlock.start && time < morningBlock.start)
|
||||
currentBlock = TimeBlockName.dawn;
|
||||
if (time > morningBlock.start && time < dayBlock.start)
|
||||
currentBlock = TimeBlockName.morning;
|
||||
if (time > dayBlock.start && time < afternoonBlock.start)
|
||||
currentBlock = TimeBlockName.day;
|
||||
if (time > afternoonBlock.start && time < eveningBlock.start)
|
||||
currentBlock = TimeBlockName.afternoon;
|
||||
if (time > eveningBlock.start && time < twilightBlock.start)
|
||||
currentBlock = TimeBlockName.evening;
|
||||
if (time > twilightBlock.start && time < nightBlock.start)
|
||||
currentBlock = TimeBlockName.twilight;
|
||||
|
||||
return currentBlock;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 523b51446a0cf424b8ab74839a6360a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: c7c267e54a3f18e4a98511fd9f73e807, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyTransitModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,295 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using UnityEngine;
|
||||
using DistantLands.Cozy.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyWeatherModule : CozyBiomeModuleBase<CozyWeatherModule>, ICozyEcosystem
|
||||
{
|
||||
public float cumulus;
|
||||
public float cirrus;
|
||||
public float altocumulus;
|
||||
public float cirrostratus;
|
||||
public float chemtrails;
|
||||
public float nimbus;
|
||||
public float nimbusHeight;
|
||||
public float nimbusVariation;
|
||||
public float borderHeight;
|
||||
public float borderEffect;
|
||||
public float borderVariation;
|
||||
public float fogDensity;
|
||||
|
||||
public float filterSaturation;
|
||||
public float filterValue;
|
||||
public Color filterColor = Color.white;
|
||||
public Color sunFilter = Color.white;
|
||||
public Color cloudFilter = Color.white;
|
||||
|
||||
[CozySearchable(true)]
|
||||
public CozyEcosystem ecosystem;
|
||||
|
||||
public CozyEcosystem Ecosystem { get => ecosystem; set => ecosystem = value; }
|
||||
public CozySystem LocalSystem { get => system; }
|
||||
|
||||
[WeatherRelation]
|
||||
[CozySearchable]
|
||||
public List<WeatherRelation> currentWeatherProfiles = new List<WeatherRelation>();
|
||||
public FilterFX defaultFilter;
|
||||
public CloudFX defaultClouds;
|
||||
|
||||
private WeatherProfile strongestWeather;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
RunChecks();
|
||||
|
||||
ecosystem.SetupEcosystem();
|
||||
ResetFilter();
|
||||
ResetClouds();
|
||||
WeatherProfile strongestWeatherThisFrame = currentWeatherProfiles.Count == 0 ? null : currentWeatherProfiles
|
||||
.OrderByDescending(w => w.weight)
|
||||
.First().profile;
|
||||
|
||||
if (strongestWeatherThisFrame != strongestWeather)
|
||||
{
|
||||
strongestWeather = strongestWeatherThisFrame;
|
||||
weatherSphere.events.RaiseOnWeatherChange();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void InitializeModule()
|
||||
{
|
||||
isBiomeModule = GetComponent<CozyBiome>();
|
||||
|
||||
if (isBiomeModule)
|
||||
{
|
||||
AddBiome();
|
||||
return;
|
||||
}
|
||||
base.InitializeModule();
|
||||
weatherSphere.weatherModule = this;
|
||||
AddBiome();
|
||||
|
||||
}
|
||||
|
||||
private void RunChecks()
|
||||
{
|
||||
defaultClouds = (CloudFX)Resources.Load("Default Profiles/Default Clouds");
|
||||
defaultFilter = (FilterFX)Resources.Load("Default Profiles/Default Filter");
|
||||
|
||||
ecosystem ??= new CozyEcosystem();
|
||||
|
||||
if (system == weatherSphere)
|
||||
weatherSphere.weatherModule = this;
|
||||
ecosystem.weatherSphere = weatherSphere;
|
||||
ecosystem.system = system;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
foreach (WeatherProfile profile in ecosystem.forecastProfile.profilesToForecast)
|
||||
{
|
||||
foreach (FXProfile fx in profile.FX)
|
||||
fx?.InitializeEffect(weatherSphere);
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateWeatherWeights()
|
||||
{
|
||||
ecosystem.UpdateEcosystem();
|
||||
ManageGlobalEcosystem();
|
||||
UpdateWeatherByWeight();
|
||||
|
||||
WeatherProfile strongestWeatherThisFrame = currentWeatherProfiles.Count == 0 ? null : currentWeatherProfiles
|
||||
.OrderByDescending(w => w.weight)
|
||||
.First().profile;
|
||||
|
||||
if (strongestWeatherThisFrame != strongestWeather)
|
||||
{
|
||||
strongestWeather = strongestWeatherThisFrame;
|
||||
weatherSphere.events.RaiseOnWeatherChange();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateFXWeights()
|
||||
{
|
||||
foreach (WeatherRelation weather in currentWeatherProfiles)
|
||||
{
|
||||
weather.profile.SetWeatherWeight(weather.weight);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FrameReset()
|
||||
{
|
||||
ResetClouds();
|
||||
ResetFilter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the weather color filter based on the currently active Filter FX profiles.
|
||||
/// </summary>
|
||||
void ResetFilter()
|
||||
{
|
||||
if (ecosystem == null)
|
||||
return;
|
||||
|
||||
|
||||
filterSaturation = defaultFilter.filterSaturation;
|
||||
filterValue = defaultFilter.filterValue;
|
||||
filterColor = defaultFilter.filterColor;
|
||||
sunFilter = defaultFilter.sunFilter;
|
||||
cloudFilter = defaultFilter.cloudFilter;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the clouds based on the currently active Cloud FX profiles.
|
||||
/// </summary>
|
||||
void ResetClouds()
|
||||
{
|
||||
if (ecosystem == null)
|
||||
return;
|
||||
|
||||
cumulus = defaultClouds.cumulusCoverage;
|
||||
cirrus = defaultClouds.cirrusCoverage;
|
||||
altocumulus = defaultClouds.altocumulusCoverage;
|
||||
cirrostratus = defaultClouds.cirrostratusCoverage;
|
||||
chemtrails = defaultClouds.chemtrailCoverage;
|
||||
nimbus = defaultClouds.nimbusCoverage;
|
||||
nimbusHeight = defaultClouds.nimbusHeightEffect;
|
||||
nimbusVariation = defaultClouds.nimbusVariation;
|
||||
borderHeight = defaultClouds.borderHeight;
|
||||
borderEffect = defaultClouds.borderEffect;
|
||||
borderVariation = defaultClouds.borderVariation;
|
||||
fogDensity = defaultClouds.fogDensity;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send all weather information to the main COZY Weather Sphere for rendering.
|
||||
///</summary>
|
||||
public override void PropogateVariables()
|
||||
{
|
||||
weatherSphere.cumulus = cumulus;
|
||||
weatherSphere.cirrus = cirrus;
|
||||
weatherSphere.altocumulus = altocumulus;
|
||||
weatherSphere.cirrostratus = cirrostratus;
|
||||
weatherSphere.chemtrails = chemtrails;
|
||||
weatherSphere.nimbus = nimbus;
|
||||
weatherSphere.nimbusHeightEffect = nimbusHeight;
|
||||
weatherSphere.nimbusVariation = nimbusVariation;
|
||||
weatherSphere.borderHeight = borderHeight;
|
||||
weatherSphere.borderEffect = borderEffect;
|
||||
weatherSphere.borderVariation = borderVariation;
|
||||
weatherSphere.fogDensity = fogDensity;
|
||||
|
||||
weatherSphere.filterSaturation = filterSaturation;
|
||||
weatherSphere.filterValue = filterValue;
|
||||
weatherSphere.filterColor = filterColor;
|
||||
weatherSphere.sunFilter = sunFilter;
|
||||
weatherSphere.cloudFilter = cloudFilter;
|
||||
}
|
||||
|
||||
void ManageGlobalEcosystem()
|
||||
{
|
||||
if (system == null) RunChecks();
|
||||
currentWeatherProfiles.Clear();
|
||||
|
||||
if (weight > 0)
|
||||
foreach (WeatherRelation weatherRelation in ecosystem.weightedWeatherProfiles)
|
||||
{
|
||||
if (weatherRelation.weight == 0)
|
||||
{
|
||||
weatherRelation.profile.SetWeatherWeight(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentWeatherProfiles.Find(x => x.profile == weatherRelation.profile) != null)
|
||||
{
|
||||
currentWeatherProfiles.Find(x => x.profile == weatherRelation.profile).weight += weatherRelation.weight * weight;
|
||||
continue;
|
||||
}
|
||||
|
||||
WeatherRelation l = new WeatherRelation
|
||||
{
|
||||
profile = weatherRelation.profile,
|
||||
weight = weatherRelation.weight * weight
|
||||
};
|
||||
currentWeatherProfiles.Add(l);
|
||||
|
||||
}
|
||||
|
||||
foreach (CozyWeatherModule biome in biomes)
|
||||
{
|
||||
if (biome == null) continue;
|
||||
|
||||
CozyEcosystem localEcosystem = biome.Ecosystem;
|
||||
|
||||
if (biome.weight > 0)
|
||||
{
|
||||
foreach (WeatherRelation weatherRelation in localEcosystem.weightedWeatherProfiles)
|
||||
{
|
||||
if (weatherRelation.weight == 0)
|
||||
{
|
||||
if (weatherRelation.profile)
|
||||
weatherRelation.profile.SetWeatherWeight(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentWeatherProfiles.Find(x => x.profile == weatherRelation.profile) != null)
|
||||
{
|
||||
currentWeatherProfiles.Find(x => x.profile == weatherRelation.profile).weight += weatherRelation.weight * biome.weight;
|
||||
continue;
|
||||
}
|
||||
|
||||
WeatherRelation l = new WeatherRelation();
|
||||
l.profile = weatherRelation.profile;
|
||||
l.weight = weatherRelation.weight * biome.weight;
|
||||
currentWeatherProfiles.Add(l);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (WeatherRelation i in localEcosystem.weightedWeatherProfiles)
|
||||
{
|
||||
i.profile.SetWeatherWeight(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWeatherByWeight()
|
||||
{
|
||||
ComputeBiomeWeights();
|
||||
|
||||
float weatherWeightAcrossSystems = 0;
|
||||
|
||||
foreach (WeatherRelation i in currentWeatherProfiles) weatherWeightAcrossSystems += i.weight;
|
||||
|
||||
if (weatherWeightAcrossSystems == 0)
|
||||
weatherWeightAcrossSystems = 1;
|
||||
|
||||
foreach (WeatherRelation i in currentWeatherProfiles)
|
||||
{
|
||||
i.weight /= weatherWeightAcrossSystems;
|
||||
// i.profile.SetWeatherWeight(i.weight);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90a63f037b9d8b54987e07c69557b6f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- weatherSphere: {instanceID: 0}
|
||||
- system: {instanceID: 0}
|
||||
- parentModule: {instanceID: 0}
|
||||
- defaultFilter: {fileID: 11400000, guid: b3b90f04f4696264c9aab62e9c3c68a5, type: 2}
|
||||
- defaultClouds: {fileID: 11400000, guid: 40c748033998bf243ae542ca195124b7, type: 2}
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: e51b7563b2e461141a757c1b77ca0217, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyWeatherModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,136 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using UnityEngine;
|
||||
using DistantLands.Cozy.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class CozyWindModule : CozyModule
|
||||
{
|
||||
|
||||
[CozySearchable]
|
||||
public WindFX defaultWindProfile;
|
||||
[CozySearchable]
|
||||
public WindZone windZone;
|
||||
|
||||
public float windSpeed;
|
||||
public float windChangeSpeed;
|
||||
public float windAmount;
|
||||
public float windGusting;
|
||||
private Vector3 m_WindDirection;
|
||||
private float m_Seed;
|
||||
[Tooltip("Multiplies the total wind power by a coefficient.")]
|
||||
[Range(0, 2)]
|
||||
[CozySearchable]
|
||||
public float windMultiplier = 1;
|
||||
[CozySearchable]
|
||||
public bool useWindzone = true;
|
||||
[CozySearchable]
|
||||
public bool useShaderWind = true;
|
||||
private float m_WindTime;
|
||||
public List<WindFX> windFXes = new List<WindFX>();
|
||||
|
||||
public bool overrideWindDirection = false;
|
||||
|
||||
public Vector3 WindDirection
|
||||
{
|
||||
get { return m_WindDirection; }
|
||||
set { m_WindDirection = value; }
|
||||
}
|
||||
|
||||
#if ZEPHYR
|
||||
public DistantLands.Zephyr.ZephyrWind zephyrWind;
|
||||
#endif
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
weatherSphere.windModule = this;
|
||||
|
||||
if (!defaultWindProfile)
|
||||
defaultWindProfile = (WindFX)Resources.Load("Default Profiles/Default Wind");
|
||||
|
||||
m_WindTime = 0;
|
||||
m_Seed = Random.value * 1000;
|
||||
|
||||
|
||||
#if ZEPHYR
|
||||
zephyrWind = DistantLands.Zephyr.ZephyrWind.Instance;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void CozyUpdateLoop()
|
||||
{
|
||||
|
||||
if (defaultWindProfile == null)
|
||||
{
|
||||
Debug.LogWarning("Default wind profile is required for the COZY Wind Module");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!overrideWindDirection)
|
||||
{
|
||||
float i = 360 * Mathf.PerlinNoise(m_Seed, Time.time * windChangeSpeed / 100000);
|
||||
m_WindDirection = new Vector3(Mathf.Sin(i), 0, Mathf.Cos(i)).normalized;
|
||||
}
|
||||
|
||||
|
||||
if (useWindzone)
|
||||
{
|
||||
|
||||
if (windZone)
|
||||
{
|
||||
windZone.transform.LookAt(windZone.transform.position + m_WindDirection, Vector3.up);
|
||||
windZone.windMain = windAmount * windMultiplier;
|
||||
windZone.windPulseMagnitude = windGusting;
|
||||
windZone.windPulseFrequency = windSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
m_WindTime += Time.deltaTime * windSpeed;
|
||||
|
||||
if (useShaderWind)
|
||||
{
|
||||
Shader.SetGlobalFloat("CZY_WindTime", m_WindTime);
|
||||
Shader.SetGlobalVector("CZY_WindDirection", m_WindDirection * windAmount * windMultiplier);
|
||||
}
|
||||
|
||||
#if ZEPHYR
|
||||
if (zephyrWind) {
|
||||
zephyrWind.TargetDirection = m_WindDirection;
|
||||
zephyrWind.targetWindStrength = windAmount * windMultiplier;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public override void FrameReset()
|
||||
{
|
||||
if (defaultWindProfile)
|
||||
{
|
||||
windSpeed = defaultWindProfile.windSpeed;
|
||||
windAmount = defaultWindProfile.windAmount;
|
||||
windGusting = defaultWindProfile.windGusting;
|
||||
windChangeSpeed = defaultWindProfile.windChangeSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DeinitializeModule()
|
||||
{
|
||||
base.DeinitializeModule();
|
||||
|
||||
Shader.SetGlobalFloat("CZY_WindTime", 0);
|
||||
Shader.SetGlobalVector("CZY_WindDirection", Vector3.zero);
|
||||
|
||||
}
|
||||
|
||||
public float WindSpeedInKnots => windAmount * windSpeed * windMultiplier * 10f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c876b65dcaef0845aa187019a7f70bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- cachedWeatherSphere: {instanceID: 0}
|
||||
- cachedSystem: {instanceID: 0}
|
||||
- defaultWindProfile: {fileID: 11400000, guid: 94bed43d2a7d48f428f62cb4dcb20a81,
|
||||
type: 2}
|
||||
- windZone: {instanceID: 0}
|
||||
executionOrder: 3
|
||||
icon: {fileID: 2800000, guid: 1e5d1669bf992464b8919cb9312f8d17, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/CozyWindModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,16 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
public class ExampleModule : CozyModule
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ddc9ac0ca989914db71b29e0645f324
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: db319a0b03d0cda4eb6b0b013758f7ce, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/ExampleModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,76 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
public class SystemTimeModule : CozyTimeModule
|
||||
{
|
||||
|
||||
[MeridiemTimeAttribute]
|
||||
[SerializeField]
|
||||
private float m_SystemTime = 0.5f;
|
||||
[SerializeField]
|
||||
[CozySearchable]
|
||||
public bool pauseTime;
|
||||
[Tooltip("How many times should the COZY day complete per real world day.")]
|
||||
[CozySearchable]
|
||||
public float timeMultiplier = 1;
|
||||
[Tooltip("How many times should the COZY year complete per real world year.")]
|
||||
[CozySearchable]
|
||||
public float dateMultiplier = 1;
|
||||
|
||||
public enum TimeGatherMode { Local, UTC }
|
||||
|
||||
[CozySearchable]
|
||||
public TimeGatherMode timeGatherMode;
|
||||
[Tooltip("Adds an offset to the gathered time in hours.")]
|
||||
[CozySearchable]
|
||||
public float hourOffset;
|
||||
|
||||
internal override bool CheckIfModuleCanBeAdded(out string warning)
|
||||
{
|
||||
if (weatherSphere.moduleHolder.GetComponents<CozyTimeModule>().Length != 1)
|
||||
{
|
||||
warning = "Time Module";
|
||||
return false;
|
||||
}
|
||||
warning = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (weatherSphere.timeModule == null)
|
||||
weatherSphere.timeModule = this;
|
||||
|
||||
if (!pauseTime)
|
||||
{
|
||||
if (timeGatherMode == TimeGatherMode.Local)
|
||||
{
|
||||
m_SystemTime = (hourOffset * 3600000 + (float)DateTime.Now.TimeOfDay.TotalMilliseconds) * timeMultiplier / 86400000 % 1;
|
||||
yearPercentage = (float)DateTime.Now.DayOfYear / 365 * dateMultiplier % 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_SystemTime = (hourOffset * 3600000 + (float)DateTime.UtcNow.TimeOfDay.TotalMilliseconds) * timeMultiplier / 86400000 % 1;
|
||||
yearPercentage = (float)DateTime.UtcNow.DayOfYear / 365 * dateMultiplier % 1;
|
||||
}
|
||||
currentTime = m_SystemTime;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public new float modifiedTimeSpeed
|
||||
{
|
||||
get
|
||||
{
|
||||
return timeMultiplier / 86400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 920cb16b93ad663418d9c8a3d5e6ee00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- weatherSphere: {instanceID: 0}
|
||||
- transit: {instanceID: 0}
|
||||
- perennialProfile: {fileID: 11400000, guid: 8ce0d8458b4495b4593c1e03027a0ce5, type: 2}
|
||||
- overrideDate: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: c9721a6a80209884da4fe2253a3f0e35, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/SystemTimeModule.cs
|
||||
uploadId: 939148
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da6129da33fdf17458f526c2b41d1f07
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
public abstract class CozyDateOverride : CozyModule
|
||||
{
|
||||
|
||||
public float yearPercentage;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current year percentage (0 - 1).
|
||||
/// </summary>
|
||||
public abstract float GetCurrentYearPercentage();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current year percentage (0 - 1) after a number of ticks has passed.
|
||||
/// </summary>
|
||||
public abstract float GetCurrentYearPercentage(float inTicks);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current day plus the current day percentage (0-1).
|
||||
/// </summary>
|
||||
public abstract float DayAndTime();
|
||||
public abstract void ChangeDay(int days);
|
||||
public abstract int DaysPerYear();
|
||||
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38912360c0640ed4ead24a3400425363
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/Utility Modules/CozyDateOverride.cs
|
||||
uploadId: 939148
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// Distant Lands 2025
|
||||
// COZY: Stylized Weather 3
|
||||
// All code included in this file is protected under the Unity Asset Store Eula
|
||||
|
||||
namespace DistantLands.Cozy
|
||||
{
|
||||
|
||||
public abstract class CozyTimeOverride : CozyModule
|
||||
{
|
||||
|
||||
|
||||
public float dayPercentage;
|
||||
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50275bcc4bad01347b537f7d8b33d6aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 271742
|
||||
packageName: 'COZY: Stylized Weather 3'
|
||||
packageVersion: 3.6.20
|
||||
assetPath: Packages/com.distantlands.cozy.core/Runtime/Modules/Utility Modules/CozyTimeOverride.cs
|
||||
uploadId: 939148
|
||||
Reference in New Issue
Block a user