Cozy Wather + buld systeme

This commit is contained in:
2026-07-07 16:43:51 +02:00
parent 031ac42e5d
commit 6b26ae3376
2140 changed files with 3482825 additions and 2252 deletions
@@ -0,0 +1,160 @@
// Distant Lands 2025.
using DistantLands.Cozy.Data;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;
namespace DistantLands.Cozy
{
public class CozyParticles : MonoBehaviour
{
private CozyWeather weatherSphere;
[SerializeField]
private VisualEffect[] m_VisualEffects;
[SerializeField]
private ParticleSystem[] m_ParticleSystems;
[System.Serializable]
public class ParticleType
{
public ParticleSystem particleSystem;
public float emissionAmount;
}
[HideInInspector]
public List<ParticleType> m_ParticleTypes;
// Start is called before the first frame update
void Awake()
{
weatherSphere = CozyWeather.instance;
if (m_ParticleSystems.Length == 0)
m_ParticleSystems = GetComponentsInChildren<ParticleSystem>();
if (m_VisualEffects.Length == 0)
m_VisualEffects = GetComponentsInChildren<VisualEffect>();
foreach (ParticleSystem i in m_ParticleSystems)
{
if (i == null)
continue;
ParticleType j = new ParticleType
{
particleSystem = i,
emissionAmount = i.emission.rateOverTime.constant
};
m_ParticleTypes.Add(j);
}
foreach (ParticleType i in m_ParticleTypes)
{
ParticleSystem.EmissionModule k = i.particleSystem.emission;
ParticleSystem.MinMaxCurve j = k.rateOverTime;
j.constant = 0;
k.rateOverTime = j;
}
foreach (VisualEffect i in m_VisualEffects)
{
i.Stop();
}
}
public void SetupTriggers()
{
foreach (ParticleType particle in m_ParticleTypes)
{
ParticleSystem.TriggerModule triggers = particle.particleSystem.trigger;
triggers.enter = ParticleSystemOverlapAction.Kill;
triggers.inside = ParticleSystemOverlapAction.Kill;
for (int j = 0; j < weatherSphere.cozyTriggers.Count; j++)
{
triggers.SetCollider(j, weatherSphere.cozyTriggers[j]);
}
}
/// NOTE: VFX Graph does not currently support triggers. Maybe take a look at this in the future
}
public void Play()
{
if (this == null)
return;
foreach (ParticleType particle in m_ParticleTypes)
{
ParticleSystem.EmissionModule i = particle.particleSystem.emission;
ParticleSystem.MinMaxCurve j = i.rateOverTime;
// j.constant = particle.emissionAmount * particleManager.multiplier;
i.rateOverTime = j;
if (particle.particleSystem.isStopped)
particle.particleSystem.Play();
}
foreach (VisualEffect particle in m_VisualEffects)
{
particle.Play();
}
}
public void Stop()
{
if (m_ParticleTypes != null)
foreach (ParticleType particle in m_ParticleTypes)
{
if (particle.particleSystem != null)
if (particle.particleSystem.isPlaying)
particle.particleSystem.Stop();
}
foreach (VisualEffect particle in m_VisualEffects)
{
particle.Stop();
}
}
public void Play(float weight)
{
if (this == null)
return;
foreach (ParticleType particle in m_ParticleTypes)
{
ParticleSystem.EmissionModule i = particle.particleSystem.emission;
ParticleSystem.MinMaxCurve j = i.rateOverTime;
j.constant = Mathf.Lerp(0, particle.emissionAmount, weight);
i.rateOverTime = j;
if (particle.particleSystem.isStopped)
particle.particleSystem.Play();
}
foreach (VisualEffect particle in m_VisualEffects)
{
if (weight > 0.5f)
particle.Play();
else
particle.Stop();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 12fb4c6168a6068438c5659902a12d6f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: bc6c5dfabf8c7e148ac95a5968760967, 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/Utility/Auxillary/CozyParticles.cs
uploadId: 939148
@@ -0,0 +1,94 @@
// Distant Lands 2025.
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy
{
[ExecuteAlways]
public class CozySatellite : MonoBehaviour
{
public float orbitOffset;
public float satelliteRotateSpeed;
public float satelliteDirection;
private Transform m_Satellite;
private CozyWeather m_WeatherManager;
// Start is called before the first frame update
void Awake()
{
m_Satellite = transform.GetChild(0);
m_WeatherManager = CozyWeather.instance;
}
// Update is called once per frame
void Update()
{
m_Satellite.localEulerAngles = m_Satellite.localEulerAngles + Vector3.up * Time.deltaTime * satelliteRotateSpeed;
transform.localEulerAngles = new Vector3(-((m_WeatherManager.timeModule.currentTime * 360) - 90 + orbitOffset), satelliteDirection, 0);
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(CozySatellite))]
[CanEditMultipleObjects]
public class E_CozySatellite : Editor
{
public int windowNum;
Color proCol = (Color)new Color32(50, 50, 50, 255);
Color unityCol = (Color)new Color32(194, 194, 194, 255);
void OnEnable()
{
serializedObject.Update();
serializedObject.FindProperty("icon1").objectReferenceValue = Resources.Load<Texture>("Atmosphere");
serializedObject.FindProperty("icon2").objectReferenceValue = Resources.Load<Texture>("CozyCalendar");
serializedObject.FindProperty("icon3").objectReferenceValue = Resources.Load<Texture>("Weather Profile-01");
serializedObject.FindProperty("icon4").objectReferenceValue = Resources.Load<Texture>("CozyTrigger");
serializedObject.ApplyModifiedProperties();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.HelpBox("NOTICE: This component is now deprecated and will be removed in a future version of COZY. Please use the new satellite profile system instead!", MessageType.Warning);
EditorGUILayout.PropertyField(serializedObject.FindProperty("orbitOffset"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("satelliteRotateSpeed"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("satelliteDirection"));
serializedObject.ApplyModifiedProperties();
}
}
#endif
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 41ba371ea3ae4f347a8de37780cd241e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: a6c39375dd258204aa76f23fef804eb2, 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/Utility/Auxillary/CozySatellite.cs
uploadId: 939148
@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DistantLands.Cozy
{
[ExecuteAlways]
public class CozySetMoonDirection : MonoBehaviour
{
CozyWeather weatherSphere;
// Update is called once per frame
void Update()
{
if (weatherSphere == null)
weatherSphere = CozyWeather.instance;
weatherSphere.moonDirection = -transform.forward;
Shader.SetGlobalVector("CZY_MoonDirection", -transform.forward);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 5e918ceee2d7ce04cba44d902dfef036
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: a6c39375dd258204aa76f23fef804eb2, 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/Utility/Auxillary/CozySetMoonDirection.cs
uploadId: 939148
@@ -0,0 +1,120 @@
// Distant Lands 2025.
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy
{
public class CozyThunder : MonoBehaviour
{
[SerializeField]
private AudioClip[] m_ThunderSounds;
[SerializeField]
private AnimationCurve m_LightIntensity;
[SerializeField]
private Vector2 m_ThunderDelayRange;
private Light m_Light;
private AudioSource m_AudioSource;
private float m_WakeTime;
private float m_WakeAmount;
private float m_ThunderDelay;
private delegate void OnStopThunder();
private static OnStopThunder onStopThunder;
public static void StopThunder()
{
onStopThunder.Invoke();
}
// Destroys the thunder when the stopThunder delegate runs
void DestroyThunder()
{
Destroy(gameObject);
}
//Add listeners
void OnEnable()
{
onStopThunder += DestroyThunder;
}
void OnDisable()
{
onStopThunder -= DestroyThunder;
}
// Start is called before the first frame update
void Start()
{
m_WakeTime = Time.time;
m_Light = GetComponentInChildren<Light>();
m_AudioSource = GetComponentInChildren<AudioSource>();
m_AudioSource.clip = m_ThunderSounds[Random.Range(0, m_ThunderSounds.Length)];
m_ThunderDelay = Random.Range(m_ThunderDelayRange.x, m_ThunderDelayRange.y);
}
// Update is called once per frame
void Update()
{
m_WakeAmount = Time.time - m_WakeTime;
m_Light.intensity = m_LightIntensity.Evaluate(m_WakeAmount);
if (m_WakeAmount > m_AudioSource.clip.length + m_ThunderDelay)
{
Destroy(gameObject);
return;
}
if (m_WakeAmount > m_ThunderDelay && !m_AudioSource.isPlaying)
m_AudioSource.Play();
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(CozyThunder))]
[CanEditMultipleObjects]
public class E_Thunder : Editor
{
CozyThunder cozythunder;
void OnEnable()
{
cozythunder = (CozyThunder)target;
}
public override void OnInspectorGUI()
{
if (cozythunder == null)
if (target)
cozythunder = (CozyThunder)target;
else
return;
serializedObject.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ThunderSounds"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ThunderDelayRange"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_LightIntensity"));
EditorGUILayout.Space();
serializedObject.ApplyModifiedProperties();
}
}
#endif
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8a485a9f0a3a8924ea3e262631070f21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 3700da53e9facc044af615d22cdcada1, 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/Utility/Auxillary/CozyThunder.cs
uploadId: 939148
@@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using DistantLands.Cozy.Data;
using UnityEngine;
namespace DistantLands.Cozy
{
public class CozyThunderManager : MonoBehaviour
{
private float thunderTimer = 0;
public CozyWeather weatherSphere;
public ThunderFX thunderFX;
// Update is called once per frame
public void PlayEffect(float weight)
{
if (!Application.isPlaying)
return;
if (weight > 0.5f)
{
thunderTimer -= Time.deltaTime;
if (thunderTimer <= 0)
{
Strike();
}
if (thunderTimer > thunderFX.timeBetweenStrikes.y)
{
thunderTimer = thunderFX.timeBetweenStrikes.y;
}
}
}
public void Strike()
{
if (!weatherSphere.cozyCamera) return;
Camera cozyCamera = weatherSphere.cozyCamera;
Vector3 worldPoint;
if (Random.value > thunderFX.spawnInFrustumPercentage)
{
Vector3 randomPoint = new Vector3(
Random.Range(thunderFX.minScreenXmultiplier, thunderFX.maxScreenXmultiplier),
Random.Range(thunderFX.minScreenYmultiplier, thunderFX.maxScreenYmultiplier),
Random.Range(cozyCamera.nearClipPlane + thunderFX.minimumDistance, thunderFX.maximumDistance)
);
worldPoint = cozyCamera.ViewportToWorldPoint(randomPoint);
}
else
worldPoint = cozyCamera.transform.position + new Vector3(Random.Range(-1, 1), 0, Random.Range(-1, 1)).normalized * Random.Range(thunderFX.minimumDistance, thunderFX.maximumDistance);
worldPoint.y = cozyCamera.transform.position.y;
Transform i = Instantiate(thunderFX.thunderPrefab, worldPoint, Quaternion.identity, transform).transform;
i.LookAt(cozyCamera.transform.position);
thunderTimer = Random.Range(thunderFX.timeBetweenStrikes.x, thunderFX.timeBetweenStrikes.y);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 693d5f9762fdb294c95a6a559735abf2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 3700da53e9facc044af615d22cdcada1, 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/Utility/Auxillary/CozyThunderManager.cs
uploadId: 939148
@@ -0,0 +1,145 @@
// Distant Lands 2025.
using DistantLands.Cozy.Data;
using UnityEngine;
using UnityEngine.Events;
namespace DistantLands.Cozy
{
[RequireComponent(typeof(Collider))]
public class CozyVolume : MonoBehaviour
{
public enum TriggerType { setWeather, triggerEvent, setTime, setDay, setAtmosphere, setAmbience }
public enum SetType { setInstantly, transition }
public enum TriggerState { onEnter, onStay, onExit }
[SerializeField]
private TriggerType m_TriggerType;
[SerializeField]
private TriggerState m_TriggerState;
[SerializeField]
private SetType m_SetType;
[SerializeField]
private string m_Tag = "Untagged";
private CozyWeather m_CozyWeather;
[SerializeField]
private WeatherProfile m_WeatherProfile;
[SerializeField]
private float m_TransitionTime;
[SerializeField]
private UnityEvent m_Event;
[SerializeField]
private AtmosphereProfile m_AtmosphereProfile;
[SerializeField]
private AmbienceProfile m_AmbienceProfile;
[SerializeField]
[MeridiemTimeAttribute]
private float time;
[SerializeField]
private int day;
[SerializeField]
private float transitionTime;
private void Awake()
{
m_CozyWeather = CozyWeather.instance;
}
public void Run()
{
if (m_SetType == SetType.setInstantly)
Set();
else
Transition();
}
public void Transition()
{
switch (m_TriggerType)
{
case TriggerType.setWeather:
// m_CozyWeather.weather.SetWeather(m_WeatherProfile, m_TransitionTime);
break;
case TriggerType.triggerEvent:
m_Event.Invoke();
break;
case TriggerType.setAtmosphere:
m_CozyWeather.atmosphereModule.ChangeAtmosphere(m_AtmosphereProfile, m_TransitionTime);
break;
case TriggerType.setDay:
m_CozyWeather.timeModule.TransitionTime(time, day);
break;
case TriggerType.setTime:
m_CozyWeather.timeModule.TransitionTime(time, m_CozyWeather.timeModule.currentDay);
break;
case TriggerType.setAmbience:
m_CozyWeather.GetModule<CozyAmbienceModule>().SetAmbience(m_AmbienceProfile, m_TransitionTime);
break;
}
}
public void Set()
{
switch (m_TriggerType)
{
case TriggerType.setWeather:
m_CozyWeather.weatherModule.ecosystem.currentWeather = m_WeatherProfile;
break;
case TriggerType.triggerEvent:
m_Event.Invoke();
break;
case TriggerType.setAtmosphere:
m_CozyWeather.atmosphereModule.atmosphereProfile = m_AtmosphereProfile;
m_CozyWeather.ResetQuality();
break;
case TriggerType.setDay:
m_CozyWeather.timeModule.currentDay = day;
break;
case TriggerType.setTime:
m_CozyWeather.timeModule.currentTime = time;
break;
case TriggerType.setAmbience:
if (m_CozyWeather.GetModule<CozyAmbienceModule>() != null)
m_CozyWeather.GetModule<CozyAmbienceModule>().SetAmbience(m_AmbienceProfile, 0);
break;
}
}
private void OnTriggerEnter(Collider other)
{
if (m_TriggerState != TriggerState.onEnter)
return;
if (other.gameObject.tag == m_Tag)
Run();
}
private void OnTriggerStay(Collider other)
{
if (m_TriggerState != TriggerState.onStay)
return;
if (other.gameObject.tag == m_Tag)
Run();
}
private void OnTriggerExit(Collider other)
{
if (m_TriggerState != TriggerState.onExit)
return;
if (other.gameObject.tag == m_Tag)
Run();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c6482b02fe8b5da44ac7193533316403
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: a3400f766e1fb304fae54e304d5c8f20, 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/Utility/Auxillary/CozyVolume.cs
uploadId: 939148