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,8 @@
fileFormatVersion: 2
guid: bede4bf747a12594aae1d48790c22036
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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
@@ -0,0 +1,70 @@
using UnityEngine;
using DistantLands.Cozy.Data;
using System.Collections.Generic;
using System.Collections;
namespace DistantLands.Cozy
{
[System.Serializable]
public class CozyForecastManagement
{
public ForecastProfile forecastProfile;
public enum EcosystemStyle { manual, forecast, dailyForecast, automatic }
[Tooltip("How should this ecosystem manage weather selection? " +
"Manual allows you to manually select the weather profile that this ecosystem will use and the weights will adjust accordingly," +
" Forecast allows for dynamically changing weather based on a predetermined forecast that runs entirely on it's own.")]
public EcosystemStyle weatherSelectionMode;
public List<WeatherPattern> currentForecast;
[System.Serializable]
public class WeatherPattern
{
public WeatherProfile profile;
public float weatherProfileDuration;
public float startTicks;
public float endTicks;
}
public float weatherTransitionTime = 15;
public float weatherTimer;
[Range(0, 1)]
public float weight;
public WeatherProfile currentWeather;
public WeatherProfile weatherChangeCheck;
[WeatherRelation]
public List<WeightedWeather> weightedWeatherProfiles;[System.Serializable]
public class WeightedWeather
{
[Range(0, 1)] public float weight; public WeatherProfile profile; public bool transitioning = true;
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;
transitioning = false;
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b97aaf26e19b8d74484725eead4aa4e0
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/Utility/CozyForecastManagement.cs
uploadId: 939148
@@ -0,0 +1,29 @@
using System;
using UnityEngine;
using System.Collections.Generic;
using DistantLands.Cozy.Data;
using UnityEngine.Serialization;
namespace DistantLands.Cozy
{
public class CozySearchable : PropertyAttribute
{
public string[] keywords;
public bool deepSearch;
public CozySearchable(params string[] keywords)
{
this.keywords = keywords;
this.deepSearch = false;
}
public CozySearchable(bool deepSearch, params string[] keywords)
{
this.keywords = keywords;
this.deepSearch = deepSearch;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1d6bcb00fa14d8444a2f96f27b30f4e5
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/Utility/CozySearchable.cs
uploadId: 939148
@@ -0,0 +1,268 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DistantLands.Cozy
{
public static class CozyShaderIDs
{
public static int CZY_FogColor1ID;
public static int CZY_FogColor2ID;
public static int CZY_FogColor3ID;
public static int CZY_FogColor4ID;
public static int CZY_FogColor5ID;
public static int CZY_FogLitColorID;
public static int CZY_FogShadowColorID;
public static int CZY_FogColorStart1ID;
public static int CZY_FogColorStart2ID;
public static int CZY_FogColorStart3ID;
public static int CZY_FogColorStart4ID;
public static int CZY_FogIntensityID;
public static int CZY_FogOffsetID;
public static int CZY_LightFlareSquishID;
public static int CZY_FogSmoothnessID;
public static int CZY_FogDepthMultiplierID;
public static int CZY_LightColorID;
public static int CZY_FogMoonFlareColorID;
public static int CZY_VariationAmountID;
public static int CZY_VariationScaleID;
public static int CZY_VariationWindDirectionID;
public static int CZY_VariationDistanceID;
public static int CZY_SunDirectionID;
public static int CZY_LightFalloffID;
public static int CZY_LightIntensityID;
public static int CZY_FilterColorID;
public static int CZY_SunFilterColorID;
public static int CZY_CloudFilterColorID;
public static int CZY_FilterValueID;
public static int CZY_FilterSaturationID;
public static int CZY_CumulusCoverageMultiplierID;
public static int CZY_NimbusMultiplierID;
public static int CZY_NimbusHeightID;
public static int CZY_NimbusVariationID;
public static int CZY_BorderHeightID;
public static int CZY_BorderEffectID;
public static int CZY_BorderVariationID;
public static int CZY_AltocumulusMultiplierID;
public static int CZY_CirrostratusMultiplierID;
public static int CZY_ChemtrailsMultiplierID;
public static int CZY_CirrusMultiplierID;
public static int CZY_CloudTextureID;
public static int CZY_ChemtrailsTextureID;
public static int CZY_CirrusTextureID;
public static int CZY_CirrostratusTextureID;
public static int CZY_AltocumulusTextureID;
public static int CZY_PartlyCloudyLuxuryCloudsTextureID;
public static int CZY_MostlyCloudyLuxuryCloudsTextureID;
public static int CZY_OvercastLuxuryCloudsTextureID;
public static int CZY_LowBorderLuxuryCloudsTextureID;
public static int CZY_HighBorderLuxuryCloudsTextureID;
public static int CZY_LowNimbusLuxuryCloudsTextureID;
public static int CZY_MidNimbusLuxuryCloudsTextureID;
public static int CZY_HighNimbusLuxuryCloudsTextureID;
public static int CZY_LuxuryVariationTextureID;
public static int CZY_StarMapID;
public static int CZY_GalaxyStarMapID;
public static int CZY_GalaxyVariationMapID;
public static int CZY_GalaxyMapID;
public static int CZY_TexturePanDirectionID;
public static int CZY_ZenithColorID;
public static int CZY_HorizonColorID;
public static int CZY_StarColorID;
public static int CZY_GalaxyMultiplierID;
public static int CZY_RainbowIntensityID;
public static int CZY_PowerID;
public static int CZY_SunSizeID;
public static int CZY_SunColorID;
public static int CZY_MoonColorID;
public static int CZY_SunHaloFalloffID;
public static int CZY_SunHaloColorID;
public static int CZY_MoonFlareColorID;
public static int CZY_MoonFlareFalloffID;
public static int CZY_GalaxyColor1ID;
public static int CZY_GalaxyColor2ID;
public static int CZY_GalaxyColor3ID;
public static int CZY_LightColumnColorID;
public static int CZY_RainbowSizeID;
public static int CZY_RainbowWidthID;
public static int CZY_StormDirectionID;
public static int CZY_CloudColorID;
public static int CZY_CloudHighlightColorID;
public static int CZY_AltoCloudColorID;
public static int CZY_CloudTextureColorID;
public static int CZY_CloudMoonColorID;
public static int CZY_SunFlareFalloffID;
public static int CZY_CloudMoonFalloffID;
public static int CZY_WindSpeedID;
public static int CZY_CloudCohesionID;
public static int CZY_SpherizeID;
public static int CZY_ShadowingDistanceID;
public static int CZY_ClippingThresholdID;
public static int CZY_CloudThicknessID;
public static int CZY_MainCloudScaleID;
public static int CZY_DetailScaleID;
public static int CZY_DetailAmountID;
public static int CZY_TextureAmountID;
public static int CZY_AltocumulusScaleID;
public static int CZY_CirrostratusMoveSpeedID;
public static int CZY_CirrusMoveSpeedID;
public static int CZY_ChemtrailsMoveSpeedID;
public static int CZY_DayPercentageID;
public static int CZY_YearPercentageID;
public static int CZY_NorthID;
public static int CZY_WestID;
public static int CZY_SunDirectionParamsID;
public static int CZY_EclipseDirectionID;
public static int CZY_MoonSizeID;
public static int CZY_HeightFogBaseID;
public static int CZY_HeightFogBaseVariationScaleID;
public static int CZY_HeightFogBaseVariationAmountID;
public static int CZY_HeightFogTransitionID;
public static int CZY_HeightFogDistanceID;
public static int CZY_HeightFogColorID;
public static int CZY_HeightFogIntensityID;
public static int CZY_StarDomeTextureID;
public static int CZY_ConstellationDomeTextureID;
public static int CZY_ConstellationIntensityID;
public static int CZY_GalaxyDomeTextureID;
public static int CZY_LightColumnsTextureID;
public static int CZY_LightColumnsPositionID;
public static int CZY_LightColumnsHeightID;
public static int CZY_RainbowTextureID;
public static int CZY_SkyFogAmountID;
public static int CZY_CloudsFogAmountID;
public static int CZY_CloudsFogLightAmountID;
public static void GrabShaderIDs()
{
CZY_FogColor1ID = Shader.PropertyToID("CZY_FogColor1");
CZY_FogColor2ID = Shader.PropertyToID("CZY_FogColor2");
CZY_FogColor3ID = Shader.PropertyToID("CZY_FogColor3");
CZY_FogColor4ID = Shader.PropertyToID("CZY_FogColor4");
CZY_FogColor5ID = Shader.PropertyToID("CZY_FogColor5");
CZY_FogColorStart1ID = Shader.PropertyToID("CZY_FogColorStart1");
CZY_FogColorStart2ID = Shader.PropertyToID("CZY_FogColorStart2");
CZY_FogColorStart3ID = Shader.PropertyToID("CZY_FogColorStart3");
CZY_FogColorStart4ID = Shader.PropertyToID("CZY_FogColorStart4");
CZY_FogIntensityID = Shader.PropertyToID("CZY_FogIntensity");
CZY_FogOffsetID = Shader.PropertyToID("CZY_FogOffset");
CZY_LightFlareSquishID = Shader.PropertyToID("CZY_LightFlareSquish");
CZY_FogSmoothnessID = Shader.PropertyToID("CZY_FogSmoothness");
CZY_FogDepthMultiplierID = Shader.PropertyToID("CZY_FogDepthMultiplier");
CZY_LightColorID = Shader.PropertyToID("CZY_LightColor");
CZY_FogMoonFlareColorID = Shader.PropertyToID("CZY_FogMoonFlareColor");
CZY_VariationAmountID = Shader.PropertyToID("CZY_VariationAmount");
CZY_VariationScaleID = Shader.PropertyToID("CZY_VariationScale");
CZY_VariationWindDirectionID = Shader.PropertyToID("CZY_VariationWindDirection");
CZY_VariationDistanceID = Shader.PropertyToID("CZY_VariationDistance");
CZY_SunDirectionID = Shader.PropertyToID("CZY_SunDirection");
CZY_LightFalloffID = Shader.PropertyToID("CZY_LightFalloff");
CZY_LightIntensityID = Shader.PropertyToID("CZY_LightIntensity");
CZY_FilterColorID = Shader.PropertyToID("CZY_FilterColor");
CZY_SunFilterColorID = Shader.PropertyToID("CZY_SunFilterColor");
CZY_CloudFilterColorID = Shader.PropertyToID("CZY_CloudFilterColor");
CZY_FilterValueID = Shader.PropertyToID("CZY_FilterValue");
CZY_FilterSaturationID = Shader.PropertyToID("CZY_FilterSaturation");
CZY_CumulusCoverageMultiplierID = Shader.PropertyToID("CZY_CumulusCoverageMultiplier");
CZY_NimbusMultiplierID = Shader.PropertyToID("CZY_NimbusMultiplier");
CZY_NimbusHeightID = Shader.PropertyToID("CZY_NimbusHeight");
CZY_NimbusVariationID = Shader.PropertyToID("CZY_NimbusVariation");
CZY_BorderHeightID = Shader.PropertyToID("CZY_BorderHeight");
CZY_BorderEffectID = Shader.PropertyToID("CZY_BorderEffect");
CZY_BorderVariationID = Shader.PropertyToID("CZY_BorderVariation");
CZY_AltocumulusMultiplierID = Shader.PropertyToID("CZY_AltocumulusMultiplier");
CZY_CirrostratusMultiplierID = Shader.PropertyToID("CZY_CirrostratusMultiplier");
CZY_ChemtrailsMultiplierID = Shader.PropertyToID("CZY_ChemtrailsMultiplier");
CZY_CirrusMultiplierID = Shader.PropertyToID("CZY_CirrusMultiplier");
CZY_CloudTextureID = Shader.PropertyToID("CZY_CloudTexture");
CZY_ChemtrailsTextureID = Shader.PropertyToID("CZY_ChemtrailsTexture");
CZY_CirrusTextureID = Shader.PropertyToID("CZY_CirrusTexture");
CZY_CirrostratusTextureID = Shader.PropertyToID("CZY_CirrostratusTexture");
CZY_AltocumulusTextureID = Shader.PropertyToID("CZY_AltocumulusTexture");
CZY_StarMapID = Shader.PropertyToID("CZY_StarMap");
CZY_GalaxyStarMapID = Shader.PropertyToID("CZY_GalaxyStarMap");
CZY_GalaxyVariationMapID = Shader.PropertyToID("CZY_GalaxyVariationMap");
CZY_GalaxyMapID = Shader.PropertyToID("CZY_GalaxyMap");
CZY_TexturePanDirectionID = Shader.PropertyToID("CZY_TexturePanDirection");
CZY_ZenithColorID = Shader.PropertyToID("CZY_ZenithColor");
CZY_HorizonColorID = Shader.PropertyToID("CZY_HorizonColor");
CZY_StarColorID = Shader.PropertyToID("CZY_StarColor");
CZY_GalaxyMultiplierID = Shader.PropertyToID("CZY_GalaxyMultiplier");
CZY_RainbowIntensityID = Shader.PropertyToID("CZY_RainbowIntensity");
CZY_PowerID = Shader.PropertyToID("CZY_Power");
CZY_SunSizeID = Shader.PropertyToID("CZY_SunSize");
CZY_SunColorID = Shader.PropertyToID("CZY_SunColor");
CZY_MoonColorID = Shader.PropertyToID("CZY_MoonColor");
CZY_SunHaloFalloffID = Shader.PropertyToID("CZY_SunHaloFalloff");
CZY_SunHaloColorID = Shader.PropertyToID("CZY_SunHaloColor");
CZY_MoonFlareColorID = Shader.PropertyToID("CZY_MoonFlareColor");
CZY_MoonFlareFalloffID = Shader.PropertyToID("CZY_MoonFlareFalloff");
CZY_GalaxyColor1ID = Shader.PropertyToID("CZY_GalaxyColor1");
CZY_GalaxyColor2ID = Shader.PropertyToID("CZY_GalaxyColor2");
CZY_GalaxyColor3ID = Shader.PropertyToID("CZY_GalaxyColor3");
CZY_LightColumnColorID = Shader.PropertyToID("CZY_LightColumnColor");
CZY_RainbowSizeID = Shader.PropertyToID("CZY_RainbowSize");
CZY_RainbowWidthID = Shader.PropertyToID("CZY_RainbowWidth");
CZY_StormDirectionID = Shader.PropertyToID("CZY_StormDirection");
CZY_CloudColorID = Shader.PropertyToID("CZY_CloudColor");
CZY_CloudHighlightColorID = Shader.PropertyToID("CZY_CloudHighlightColor");
CZY_AltoCloudColorID = Shader.PropertyToID("CZY_AltoCloudColor");
CZY_CloudTextureColorID = Shader.PropertyToID("CZY_CloudTextureColor");
CZY_CloudMoonColorID = Shader.PropertyToID("CZY_CloudMoonColor");
CZY_SunFlareFalloffID = Shader.PropertyToID("CZY_SunFlareFalloff");
CZY_CloudMoonFalloffID = Shader.PropertyToID("CZY_CloudMoonFalloff");
CZY_WindSpeedID = Shader.PropertyToID("CZY_WindSpeed");
CZY_CloudCohesionID = Shader.PropertyToID("CZY_CloudCohesion");
CZY_SpherizeID = Shader.PropertyToID("CZY_Spherize");
CZY_ShadowingDistanceID = Shader.PropertyToID("CZY_ShadowingDistance");
CZY_ClippingThresholdID = Shader.PropertyToID("CZY_ClippingThreshold");
CZY_CloudThicknessID = Shader.PropertyToID("CZY_CloudThickness");
CZY_MainCloudScaleID = Shader.PropertyToID("CZY_MainCloudScale");
CZY_DetailScaleID = Shader.PropertyToID("CZY_DetailScale");
CZY_DetailAmountID = Shader.PropertyToID("CZY_DetailAmount");
CZY_TextureAmountID = Shader.PropertyToID("CZY_TextureAmount");
CZY_AltocumulusScaleID = Shader.PropertyToID("CZY_AltocumulusScale");
CZY_CirrostratusMoveSpeedID = Shader.PropertyToID("CZY_CirrostratusMoveSpeed");
CZY_CirrusMoveSpeedID = Shader.PropertyToID("CZY_CirrusMoveSpeed");
CZY_ChemtrailsMoveSpeedID = Shader.PropertyToID("CZY_ChemtrailsMoveSpeed");
CZY_NorthID = Shader.PropertyToID("CZY_North");
CZY_SunDirectionParamsID = Shader.PropertyToID("CZY_SunDirectionParams");
CZY_WestID = Shader.PropertyToID("CZY_West");
CZY_DayPercentageID = Shader.PropertyToID("CZY_DayPercentage");
CZY_YearPercentageID = Shader.PropertyToID("CZY_YearPercentage");
CZY_EclipseDirectionID = Shader.PropertyToID("CZY_EclipseDirection");
CZY_MoonSizeID = Shader.PropertyToID("CZY_MoonSize");
CZY_PartlyCloudyLuxuryCloudsTextureID = Shader.PropertyToID("CZY_PartlyCloudyTexture");
CZY_MostlyCloudyLuxuryCloudsTextureID = Shader.PropertyToID("CZY_MostlyCloudyTexture");
CZY_OvercastLuxuryCloudsTextureID = Shader.PropertyToID("CZY_OvercastTexture");
CZY_LowBorderLuxuryCloudsTextureID = Shader.PropertyToID("CZY_LowBorderTexture");
CZY_HighBorderLuxuryCloudsTextureID = Shader.PropertyToID("CZY_HighBorderTexture");
CZY_LowNimbusLuxuryCloudsTextureID = Shader.PropertyToID("CZY_LowNimbusTexture");
CZY_MidNimbusLuxuryCloudsTextureID = Shader.PropertyToID("CZY_MidNimbusTexture");
CZY_HighNimbusLuxuryCloudsTextureID = Shader.PropertyToID("CZY_HighNimbusTexture");
CZY_LuxuryVariationTextureID = Shader.PropertyToID("CZY_LuxuryVariation");
CZY_HeightFogBaseID = Shader.PropertyToID("CZY_HeightFogBase");
CZY_HeightFogBaseVariationScaleID = Shader.PropertyToID("CZY_HeightFogBaseVariationScale");
CZY_HeightFogBaseVariationAmountID = Shader.PropertyToID("CZY_HeightFogBaseVariationAmount");
CZY_HeightFogTransitionID = Shader.PropertyToID("CZY_HeightFogTransition");
CZY_HeightFogDistanceID = Shader.PropertyToID("CZY_HeightFogDistance");
CZY_HeightFogColorID = Shader.PropertyToID("CZY_HeightFogColor");
CZY_HeightFogIntensityID = Shader.PropertyToID("CZY_HeightFogIntensity");
CZY_StarDomeTextureID = Shader.PropertyToID("CZY_StarDomeTexture");
CZY_ConstellationDomeTextureID = Shader.PropertyToID("CZY_ConstellationDomeTexture");
CZY_ConstellationIntensityID = Shader.PropertyToID("CZY_ConstellationIntensity");
CZY_GalaxyDomeTextureID = Shader.PropertyToID("CZY_GalaxyDomeTexture");
CZY_LightColumnsTextureID = Shader.PropertyToID("CZY_LightColumnsTexture");
CZY_LightColumnsPositionID = Shader.PropertyToID("CZY_LightColumnsPosition");
CZY_LightColumnsHeightID = Shader.PropertyToID("CZY_LightColumnsHeight");
CZY_RainbowTextureID = Shader.PropertyToID("CZY_RainbowTexture");
CZY_SkyFogAmountID = Shader.PropertyToID("CZY_SkyFogAmount");
CZY_CloudsFogAmountID = Shader.PropertyToID("CZY_CloudsFogAmount");
CZY_CloudsFogLightAmountID = Shader.PropertyToID("CZY_CloudsFogLightAmount");
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 67a8a6fda7ce94a4496b2a1ea0f87206
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/Utility/CozyShaderIDs.cs
uploadId: 939148
@@ -0,0 +1,80 @@
using System.Collections;
using DistantLands.Cozy.Data;
using UnityEngine;
namespace DistantLands.Cozy
{
public class CozyUtilities
{
public static float Remap(float sourceStart, float sourceEnd, float destinationStart, float destinationEnd, float value)
{
var ratio = Mathf.InverseLerp(sourceStart, sourceEnd, value);
return Mathf.Lerp(destinationStart, destinationEnd, ratio);
}
public static T GetOverriableDefault<T>()
{
return default;
}
public static Color GetOverriableDefault()
{
return Color.clear;
}
}
[System.Serializable]
public class WeatherRelation
{
[Range(0, 1)] public float weight; public WeatherProfile profile; public bool transitioning = true;
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;
transitioning = false;
}
}
[System.Serializable]
public struct Overridable<T>
{
public T value;
public bool overrideValue;
public static implicit operator bool(Overridable<T> data)
{
return data.overrideValue;
}
public Overridable(T _value, bool _overrideValue)
{
overrideValue = _overrideValue;
value = _value;
}
public static implicit operator T(Overridable<T> data)
{
return data.overrideValue ? data.value : CozyUtilities.GetOverriableDefault<T>();
}
public static implicit operator Overridable<T>(T value)
{
return new Overridable<T>(value, true);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a2ee05f5e5370034e80dc0a5c736d58d
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/Utility/CozyUtilities.cs
uploadId: 939148
@@ -0,0 +1,200 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace DistantLands.Cozy
{
[ExecuteAlways]
public class CustomCollisionShape : MonoBehaviour
{
public MeshCollider trigger;
public Color displayColor = new Color(1, 1, 1, 1);
public List<Vector3> bounds = new List<Vector3>() { new Vector3(-5, 0, 5), new Vector3(5, 0, 5), new Vector3(5, 0, -5), new Vector3(-5, 0, -5) };
public float height = 10;
void OnEnable()
{
if (!trigger)
CheckTrigger();
}
void OnDisable()
{
if (trigger.gameObject.activeInHierarchy)
DestroyImmediate(trigger);
}
public void CheckTrigger()
{
trigger = gameObject.AddComponent<MeshCollider>();
trigger.sharedMesh = BuildZoneCollider();
trigger.convex = true;
trigger.isTrigger = true;
}
public Mesh BuildZoneCollider()
{
Mesh mesh = new Mesh();
mesh.name = $"{name} Custom Trigger Mesh";
List<Vector3> verts = new List<Vector3>();
List<int> tris = new List<int>();
foreach (Vector3 i in bounds)
{
verts.Add(i);
verts.Add(new Vector3(i.x, height, i.z));
}
for (int i = 0; i < bounds.Count; i++)
{
if (i == 0)
{
tris.Add(0);
tris.Add(verts.Count - 1);
tris.Add(verts.Count - 2);
tris.Add(0);
tris.Add(1);
tris.Add(verts.Count - 1);
}
else
{
int start = i * 2;
tris.Add(start);
tris.Add(start - 1);
tris.Add(start - 2);
tris.Add(start);
tris.Add(start + 1);
tris.Add(start - 1);
}
}
for (int i = 0; i < verts.Count - 4; i += 2)
{
tris.Add(0);
tris.Add(i + 2);
tris.Add(i + 4);
tris.Add(1);
tris.Add(i + 3);
tris.Add(i + 5);
}
mesh.SetVertices(verts);
mesh.SetTriangles(tris, 0, true);
mesh.RecalculateNormals();
return mesh;
}
private void OnDrawGizmos()
{
if (!trigger)
return;
if (bounds.Count >= 3)
{
for (int i = 0; i < bounds.Count; i++)
{
Gizmos.color = new Color(displayColor.r, displayColor.g, displayColor.b, 0.3f);
Gizmos.DrawSphere(TransformToLocalSpace(bounds[i]), 0.2f);
Vector3 point = Vector3.zero;
if (i == 0)
point = bounds.Last();
else
point = bounds[i - 1];
Gizmos.color = new Color(displayColor.r, displayColor.g, displayColor.b, 1);
Gizmos.DrawLine(TransformToLocalSpace(bounds[i]), TransformToLocalSpace(point));
}
for (int i = 0; i < bounds.Count; i++)
{
Gizmos.color = new Color(displayColor.r, displayColor.g, displayColor.b, 0.5f);
Gizmos.DrawSphere(TransformToLocalSpace(bounds[i]) + Vector3.up * height, 0.2f);
Vector3 point = Vector3.zero;
if (i == 0)
point = bounds.Last();
else
point = bounds[i - 1];
Gizmos.color = new Color(displayColor.r, displayColor.g, displayColor.b, 1);
Gizmos.DrawLine(TransformToLocalSpace(bounds[i]) + Vector3.up * height, TransformToLocalSpace(point) + Vector3.up * height);
Gizmos.DrawLine(TransformToLocalSpace(bounds[i]), TransformToLocalSpace(bounds[i]) + Vector3.up * height);
Gizmos.color = new Color(displayColor.r, displayColor.g, displayColor.b, 0.3f);
Gizmos.DrawLine((TransformToLocalSpace(bounds[i]) + TransformToLocalSpace(point)) / 2,
(TransformToLocalSpace(bounds[i]) + TransformToLocalSpace(point)) / 2 + Vector3.up * height);
}
Gizmos.DrawMesh(trigger.sharedMesh, -1, transform.position, Quaternion.identity, Vector3.one);
}
}
private Vector3 TransformToLocalSpace(Vector3 pos)
{
Vector3 i = pos.x * transform.right + pos.y * transform.up + pos.z * transform.forward;
i += transform.position;
return i;
}
}
#if UNITY_EDITOR
[CanEditMultipleObjects]
[CustomEditor(typeof(CustomCollisionShape))]
public class E_CustomCollisionShape : Editor
{
public CustomCollisionShape shape;
public void OnEnable()
{
shape = (CustomCollisionShape)target;
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(serializedObject.FindProperty("bounds"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("height"));
if (EditorGUI.EndChangeCheck())
if (shape.trigger)
shape.trigger.sharedMesh = shape.BuildZoneCollider();
else
shape.CheckTrigger();
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("displayColor"));
EditorGUI.indentLevel--;
serializedObject.ApplyModifiedProperties();
}
}
#endif
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 978ead49855efd445a235d40d8e65181
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/Utility/CustomCollisionShape.cs
uploadId: 939148
@@ -0,0 +1,787 @@
using System;
using UnityEngine;
using System.Collections.Generic;
using DistantLands.Cozy.Data;
using UnityEngine.Serialization;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy
{
[Serializable]
public class VariableProperty
{
public bool overrideValue = true;
public enum Mode { interpolate, constant }
public Mode mode = Mode.constant;
[ColorUsage(true, true)]
public Color colorVal = Color.white;
[GradientUsage(true)]
public Gradient gradientVal;
public float floatVal = 1;
public AnimationCurve curveVal = new AnimationCurve() { keys = new Keyframe[2] { new Keyframe(0, 1), new Keyframe(1, 1) } };
public static implicit operator bool(VariableProperty data)
{
return data.overrideValue;
}
public void GetValue(out Color color, float time)
{
color = mode == Mode.constant ? colorVal : gradientVal.Evaluate(time);
}
public void GetValue(out float value, float time)
{
value = mode == Mode.constant ? floatVal : curveVal.Evaluate(time);
}
public Color GetColorValue(float time)
{
return mode == Mode.constant ? colorVal : gradientVal.Evaluate(time);
}
public float GetFloatValue(float time)
{
return mode == Mode.constant ? floatVal : curveVal.Evaluate(time);
}
}
public class ProperyRelation
{
public VariableProperty property;
}
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(CozyPropertyTypeAttribute))]
public class CustomAtmospherePropertyDrawer : PropertyDrawer
{
bool color;
float min;
float max;
CozyPropertyTypeAttribute _attribute;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (CozyPropertyTypeAttribute)attribute;
if (_attribute.min != _attribute.max)
{
min = _attribute.min;
max = _attribute.max;
}
color = _attribute.color;
EditorGUI.BeginProperty(position, label, property);
var toggleRect = new Rect(position.x, position.y, 20, position.height);
var labelRect = new Rect(position.x + 22, position.y, (position.width - 45) / 2, position.height);
var unitRect = new Rect(position.x + 22 + ((position.width - 45) / 2), position.y, (position.width - 45) / 2, position.height);
var dropdown = new Rect(position.x + (position.width - 35), position.y, 35, position.height);
var toggle = property.FindPropertyRelative("overrideValue");
var mode = property.FindPropertyRelative("mode");
var floatVal = property.FindPropertyRelative("floatVal");
EditorGUI.PropertyField(toggleRect, toggle, GUIContent.none);
EditorGUI.PrefixLabel(labelRect, label);
EditorGUI.BeginDisabledGroup(!toggle.boolValue);
if (color)
{
if (mode.intValue == 0)
EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("gradientVal"), GUIContent.none);
if (mode.intValue == 1)
EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("colorVal"), GUIContent.none);
}
else
{
if (mode.intValue == 0)
EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("curveVal"), GUIContent.none);
if (mode.intValue == 1)
if (_attribute.min != _attribute.max)
EditorGUI.Slider(unitRect, floatVal, min, max, GUIContent.none);
else
EditorGUI.PropertyField(unitRect, floatVal, GUIContent.none);
}
EditorGUI.PropertyField(dropdown, mode, GUIContent.none);
EditorGUI.EndDisabledGroup();
EditorGUI.EndProperty();
}
}
[UnityEditor.CustomPropertyDrawer(typeof(MonthListAttribute))]
public class MonthListDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
var rect1 = new Rect(position.x, position.y, 40, EditorGUIUtility.singleLineHeight);
var rect2 = new Rect(position.x + 50, position.y, position.width / 2 - 54, EditorGUIUtility.singleLineHeight);
var rect3 = new Rect(position.x + position.width / 2, position.y, position.width / 2 - 4, EditorGUIUtility.singleLineHeight);
var rect4 = new Rect(position.x + position.width / 2 - 4, position.y, position.width / 2 - 4, EditorGUIUtility.singleLineHeight);
var name = property.FindPropertyRelative("name");
var days = property.FindPropertyRelative("days");
EditorGUI.LabelField(rect1, "Month Name");
EditorGUI.PropertyField(rect2, name, GUIContent.none);
EditorGUI.PropertyField(rect3, days, new GUIContent(days.displayName));
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float lineCount = 1.15f;
return EditorGUIUtility.singleLineHeight * lineCount + EditorGUIUtility.standardVerticalSpacing * 2f * (lineCount - 1);
}
}
[UnityEditor.CustomPropertyDrawer(typeof(MeridiemTimeAttribute))]
public class MeridiemTimeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Keyboard), label);
var indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
float div = position.width - 50;
var hoursRect = new Rect(position.x + div, position.y, 22, position.height);
var colonRect = new Rect(position.x + div + 22, position.y, 5, position.height);
var minutesRect = new Rect(position.x + div + 28, position.y, 22, position.height);
var sliderRect = new Rect(position.x, position.y, div - 5, position.height);
float percentage = property.floatValue;
MeridiemTime time = percentage;
EditorGUI.LabelField(colonRect, ":");
EditorGUI.BeginChangeCheck();
int hours = Mathf.Clamp(EditorGUI.IntField(hoursRect, GUIContent.none, Mathf.FloorToInt(time.hours)), 0, 24);
int minutes = Mathf.Clamp(EditorGUI.IntField(minutesRect, GUIContent.none, Mathf.FloorToInt(time.minutes)), 0, 60);
if (EditorGUI.EndChangeCheck())
property.floatValue = new MeridiemTime(hours, minutes);
if (div > 55)
property.floatValue = GUI.HorizontalSlider(sliderRect, property.floatValue, 0, 1);
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
}
}
[UnityEditor.CustomPropertyDrawer(typeof(FXAttribute))]
public class FXDrawer : PropertyDrawer
{
string title;
FXAttribute _attribute;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (FXAttribute)attribute;
title = _attribute.title;
float height = EditorGUIUtility.singleLineHeight;
var unitARect = new Rect(position.x, position.y, position.width, height);
EditorGUI.BeginProperty(position, label, property);
EditorGUI.PropertyField(unitARect, property, GUIContent.none);
position = new Rect(position.x + 30, position.y, position.width - 30, position.height);
if (property.objectReferenceValue != null)
{
FXProfile profile = (FXProfile)property.objectReferenceValue;
(Editor.CreateEditor(profile) as E_FXProfile).RenderInWindow(position);
}
// if (title != "")
// EditorGUI.PropertyField(position, property, GUIContent.none);
// else
// EditorGUI.PropertyField(position, property, new GUIContent(title));
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float lineCount = 1;
if (property.objectReferenceValue != null)
{
FXProfile profile = (FXProfile)property.objectReferenceValue;
lineCount += 0.5f + (Editor.CreateEditor(profile) as E_FXProfile).GetLineHeight();
}
return EditorGUIUtility.singleLineHeight * lineCount + EditorGUIUtility.standardVerticalSpacing * (lineCount - 1);
}
}
[UnityEditor.CustomPropertyDrawer(typeof(HideTitleAttribute))]
public class HideTitleDrawer : PropertyDrawer
{
string title;
HideTitleAttribute _attribute;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (HideTitleAttribute)attribute;
title = _attribute.title;
EditorGUI.BeginProperty(position, label, property);
if (title != "")
EditorGUI.PropertyField(position, property, GUIContent.none);
else
EditorGUI.PropertyField(position, property, new GUIContent(title));
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
_attribute = (HideTitleAttribute)attribute;
return EditorGUIUtility.singleLineHeight * _attribute.lines;
}
}
[UnityEditor.CustomPropertyDrawer(typeof(OverrideRangeAttribute))]
public class OverrideRangeDrawer : PropertyDrawer
{
OverrideRangeAttribute _attribute;
SerializedProperty value;
SerializedProperty useOverride;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
useOverride = property.FindPropertyRelative("overrideValue");
_attribute = (OverrideRangeAttribute)attribute;
EditorGUI.BeginProperty(position, label, property);
Rect posA = new Rect(position.x, position.y, position.height, position.height);
Rect posB = new Rect(position.x + position.height + 5, position.y, position.width - (position.height + 5), position.height);
EditorGUI.PropertyField(posA, useOverride, GUIContent.none);
EditorGUI.BeginDisabledGroup(!useOverride.boolValue);
property.FindPropertyRelative("value").floatValue = EditorGUI.Slider(posB, label, property.FindPropertyRelative("value").floatValue, _attribute.MinValue, _attribute.MaxValue);
EditorGUI.EndDisabledGroup();
EditorGUI.EndProperty();
}
}
[UnityEditor.CustomPropertyDrawer(typeof(Overridable<float>))]
public class OverrideDrawer : PropertyDrawer
{
SerializedProperty useOverride;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
useOverride = property.FindPropertyRelative("overrideValue");
EditorGUI.BeginProperty(position, label, property);
Rect posA = new Rect(position.x, position.y, position.height, position.height);
Rect posB = new Rect(position.x + position.height + 5, position.y, position.width - (position.height + 5), position.height);
EditorGUI.PropertyField(posA, property.FindPropertyRelative("overrideValue"), GUIContent.none);
EditorGUI.BeginDisabledGroup(!useOverride.boolValue);
EditorGUI.PropertyField(posB, property.FindPropertyRelative("value"), label);
EditorGUI.EndDisabledGroup();
EditorGUI.EndProperty();
}
}
[UnityEditor.CustomPropertyDrawer(typeof(Overridable<Color>))]
public class OverrideColorDrawer : PropertyDrawer
{
SerializedProperty useOverride;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
useOverride = property.FindPropertyRelative("overrideValue");
EditorGUI.BeginProperty(position, label, property);
Rect posA = new Rect(position.x, position.y, position.height, position.height);
Rect posB = new Rect(position.x + position.height + 5, position.y, position.width - (position.height + 5), position.height);
EditorGUI.PropertyField(posA, property.FindPropertyRelative("overrideValue"), GUIContent.none);
EditorGUI.BeginDisabledGroup(!useOverride.boolValue);
property.FindPropertyRelative("value").colorValue = EditorGUI.ColorField(posB, label, property.FindPropertyRelative("value").colorValue, true, true, true);
EditorGUI.PropertyField(posB, property.FindPropertyRelative("value"), label);
EditorGUI.EndDisabledGroup();
EditorGUI.EndProperty();
}
}
[UnityEditor.CustomPropertyDrawer(typeof(SetHeightAttribute))]
public class SetHeightDrawer : PropertyDrawer
{
int lines;
SetHeightAttribute _attribute;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (SetHeightAttribute)attribute;
lines = _attribute.lines;
position = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight * lines);
EditorGUI.BeginProperty(position, label, property);
EditorGUI.PropertyField(position, property, label);
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
_attribute = (SetHeightAttribute)attribute;
lines = _attribute.lines;
return EditorGUIUtility.singleLineHeight * lines;
}
}
[UnityEditor.CustomPropertyDrawer(typeof(DisplayHorizontallyAttribute))]
public class DisplayHorizontallyDrawer : PropertyDrawer
{
DisplayHorizontallyAttribute _attribute;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (DisplayHorizontallyAttribute)attribute;
EditorGUI.BeginProperty(position, label, property);
EditorGUI.LabelField(position, label);
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * (property.CountInProperty() + 2);
}
}
[UnityEditor.CustomPropertyDrawer(typeof(MultiAudioAttribute))]
public class MultiAudioDrawer : PropertyDrawer
{
MultiAudioAttribute _attribute;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (MultiAudioAttribute)attribute;
EditorGUI.BeginProperty(position, label, property);
var titleRect = new Rect(position.x, position.y, position.width / 2, EditorGUIUtility.singleLineHeight);
var typeRect = new Rect(position.x + (position.width / 2), position.y, position.width / 2, EditorGUIUtility.singleLineHeight);
var unitRect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight, position.width - 25, EditorGUIUtility.singleLineHeight);
var dropdown = new Rect(position.x + (position.width - 20), position.y + EditorGUIUtility.singleLineHeight, 20, EditorGUIUtility.singleLineHeight);
int preset = -1;
List<AnimationCurve> presets = new List<AnimationCurve>();
List<GUIContent> presetNames = new List<GUIContent>();
switch (property.FindPropertyRelative("intensityCurve").FindPropertyRelative("limitType").intValue)
{
case (0):
presets.Add(new AnimationCurve(new Keyframe(0.3f, 1), new Keyframe(0.34f, 0), new Keyframe(0, 1), new Keyframe(1, 0)));
presets.Add(new AnimationCurve(new Keyframe(0.3f, 0), new Keyframe(0.34f, 1), new Keyframe(0, 0), new Keyframe(1, 1)));
presets.Add(new AnimationCurve(new Keyframe(0.8f, 0), new Keyframe(1, 1), new Keyframe(0, 0)));
presets.Add(new AnimationCurve(new Keyframe(1, 1), new Keyframe(0, 0)));
presets.Add(new AnimationCurve(new Keyframe(1, 0.5f), new Keyframe(0.5f, 0), new Keyframe(0.8f, 1)));
presets.Add(new AnimationCurve(new Keyframe(1, 0), new Keyframe(0, 0), new Keyframe(0.5f, 1)));
presets.Add(new AnimationCurve(new Keyframe(1, 0), new Keyframe(0, 1)));
presetNames.Add(new GUIContent("Only below freezing"));
presetNames.Add(new GUIContent("Only above freezing"));
presetNames.Add(new GUIContent("Only above 80F"));
presetNames.Add(new GUIContent("More likely at hot tempratures"));
presetNames.Add(new GUIContent("More likely at warm tempratures"));
presetNames.Add(new GUIContent("More likely at cool tempratures"));
presetNames.Add(new GUIContent("More likely at freezing tempratures"));
break;
case (1):
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1, 3, 0)));
presets.Add(new AnimationCurve(new Keyframe(1, 0), new Keyframe(0, 1)));
presets.Add(new AnimationCurve(new Keyframe(1, 0), new Keyframe(0, 1, -3, -3)));
presetNames.Add(new GUIContent("More likely during high precipitation"));
presetNames.Add(new GUIContent("Most likely during high precipitation"));
presetNames.Add(new GUIContent("More likely during low precipitation"));
presetNames.Add(new GUIContent("Most likely during low precipitation"));
break;
case (2):
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0), new Keyframe(0.1f, 0), new Keyframe(0.2f, 1), new Keyframe(0.35f, 1), new Keyframe(0.45f, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0), new Keyframe(0.35f, 0), new Keyframe(0.45f, 1), new Keyframe(0.6f, 1), new Keyframe(0.7f, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0), new Keyframe(0.6f, 0), new Keyframe(0.7f, 1), new Keyframe(0.85f, 1), new Keyframe(0.95f, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 1), new Keyframe(0.1f, 0), new Keyframe(0.95f, 1), new Keyframe(1f, 1), new Keyframe(0.85f, 0)));
presetNames.Add(new GUIContent("More likely during spring"));
presetNames.Add(new GUIContent("Most likely during summer"));
presetNames.Add(new GUIContent("More likely during fall"));
presetNames.Add(new GUIContent("Most likely during winter"));
break;
case (3):
presets.Add(new AnimationCurve(new Keyframe(0, 1), new Keyframe(0.2f, 1), new Keyframe(0.25f, 0), new Keyframe(0.75f, 0), new Keyframe(0.8f, 1), new Keyframe(1, 1)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.2f, 0), new Keyframe(0.25f, 1), new Keyframe(0.75f, 1), new Keyframe(0.8f, 0), new Keyframe(1, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.18f, 0), new Keyframe(0.25f, 1), new Keyframe(0.35f, 0), new Keyframe(0.7f, 0), new Keyframe(0.75f, 1), new Keyframe(0.85f, 0), new Keyframe(1, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.70f, 0), new Keyframe(0.8f, 1), new Keyframe(0.85f, 0), new Keyframe(1, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.18f, 0), new Keyframe(0.22f, 1), new Keyframe(0.3f, 0), new Keyframe(1, 0)));
presetNames.Add(new GUIContent("More likely at night"));
presetNames.Add(new GUIContent("Most likely during the day"));
presetNames.Add(new GUIContent("More likely in the evening & morning"));
presetNames.Add(new GUIContent("More likely in the evening"));
presetNames.Add(new GUIContent("Most likely in the morning"));
break;
}
EditorGUI.PropertyField(titleRect, property.FindPropertyRelative("FX"), GUIContent.none);
EditorGUI.PropertyField(typeRect, property.FindPropertyRelative("intensityCurve").FindPropertyRelative("limitType"), GUIContent.none);
EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("intensityCurve").FindPropertyRelative("curve"), GUIContent.none);
preset = EditorGUI.Popup(dropdown, GUIContent.none, -1, presetNames.ToArray());
if (preset != -1)
property.FindPropertyRelative("intensityCurve").FindPropertyRelative("curve").animationCurveValue = presets[preset];
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUIUtility.singleLineHeight * 2;
}
}
[UnityEditor.CustomPropertyDrawer(typeof(TransitionTimeAttribute))]
public class TransitionTimeDrawer : PropertyDrawer
{
TransitionTimeAttribute _attribute;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (TransitionTimeAttribute)attribute;
int preset = -1;
EditorGUI.BeginProperty(position, label, property);
var unitRect = new Rect(position.x, position.y, position.width - 25, position.height);
var dropdown = new Rect(position.x + (position.width - 20), position.y, 20, position.height);
List<AnimationCurve> presets = new List<AnimationCurve>()
{
new AnimationCurve (new Keyframe(0, 0, 1, 1), new Keyframe (1, 1, 1, 1)),
new AnimationCurve (new Keyframe(0, 0, 0, 0), new Keyframe (1, 1, 2, -2)),
new AnimationCurve (new Keyframe(0, 0, 2, 2), new Keyframe (1, 1, 0, 0)),
new AnimationCurve (new Keyframe(0, 0, 0, 0), new Keyframe (1, 1, 3.25f, -3.25f)),
new AnimationCurve (new Keyframe(0, 0, 3.25f, 3.25f), new Keyframe (1, 1, 0, 0)),
new AnimationCurve (new Keyframe(0, 0, 0, 0), new Keyframe (1, 1, 0, 0)),
new AnimationCurve (new Keyframe(0, 0, 3, 3), new Keyframe (1, 1, 3, 3))
};
List<GUIContent> presetNames = new List<GUIContent>()
{
new GUIContent("Linear"),
new GUIContent("Exponential"),
new GUIContent("Inverse Exponential"),
new GUIContent("Steep Exponential"),
new GUIContent("Steep Inverse Exponential"),
new GUIContent("Smooth"),
new GUIContent("Slerped"),
};
EditorGUI.PropertyField(unitRect, property, label);
preset = EditorGUI.Popup(dropdown, GUIContent.none, -1, presetNames.ToArray());
if (preset != -1)
property.animationCurveValue = presets[preset];
EditorGUI.EndProperty();
}
}
[UnityEditor.CustomPropertyDrawer(typeof(WeatherRelationAttribute))]
public class WeightedWeatherDrawer : PropertyDrawer
{
WeatherRelationAttribute _attribute;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (WeatherRelationAttribute)attribute;
EditorGUI.BeginProperty(position, label, property);
var titleRect = new Rect(position.x, position.y, 150, position.height);
var unitRect = new Rect(position.x + 157, position.y, position.width - 155, position.height);
EditorGUI.PropertyField(titleRect, property.FindPropertyRelative("profile"), GUIContent.none);
EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("weight"), GUIContent.none);
EditorGUI.EndProperty();
}
}
#endif
public class CozyPropertyTypeAttribute : PropertyAttribute
{
public bool color;
public float min;
public float max;
public CozyPropertyTypeAttribute()
{
color = false;
}
public CozyPropertyTypeAttribute(bool isColorType)
{
color = isColorType;
}
public CozyPropertyTypeAttribute(bool isColorType, float min, float max)
{
color = isColorType;
this.min = min;
this.max = max;
}
}
public class FXAttribute : PropertyAttribute
{
public string title;
public FXAttribute()
{
title = "";
}
public FXAttribute(string _title)
{
title = _title;
}
}
public class OverrideRangeAttribute : PropertyAttribute
{
public float MinValue { get; private set; }
public float MaxValue { get; private set; }
public OverrideRangeAttribute(float minValue, float maxValue)
{
MinValue = minValue;
MaxValue = maxValue;
}
}
public class HideTitleAttribute : PropertyAttribute
{
public string title;
public float lines;
public HideTitleAttribute()
{
title = "";
lines = 1;
}
public HideTitleAttribute(float _lines)
{
title = "";
lines = _lines;
}
public HideTitleAttribute(string _title, float _lines)
{
title = _title;
lines = _lines;
}
}
public class DisplayHorizontallyAttribute : PropertyAttribute
{
public string key;
public DisplayHorizontallyAttribute(string _Key)
{
key = _Key;
}
}
public class MonthListAttribute : PropertyAttribute
{
public MonthListAttribute()
{
}
}
public class SetHeightAttribute : PropertyAttribute
{
public int lines;
public SetHeightAttribute()
{
lines = 1;
}
public SetHeightAttribute(int _lines)
{
lines = _lines;
}
}
public class FormatTimeAttribute : PropertyAttribute
{
public FormatTimeAttribute()
{
}
}
public class MeridiemTimeAttribute : PropertyAttribute
{
}
public class ModulatedPropertyAttribute : PropertyAttribute
{
public ModulatedPropertyAttribute()
{
}
}
public class TransitionTimeAttribute : PropertyAttribute
{
public TransitionTimeAttribute()
{
}
}
public class WeatherRelationAttribute : PropertyAttribute
{
public WeatherRelationAttribute()
{
}
}
public class MultiAudioAttribute : PropertyAttribute
{
public MultiAudioAttribute()
{
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 73ffe9c9d6d896e42bf565ed61cacedb
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/Utility/CustomProperty.cs
uploadId: 939148
@@ -0,0 +1,78 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy
{
public static class EditorUtilities
{
public static T[] GetAllInstances<T>() where T : ScriptableObject
{
#if UNITY_EDITOR
string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name); //FindAssets uses tags check documentation for more info
T[] a = new T[guids.Length];
for (int i = 0; i < guids.Length; i++) //probably could get optimized
{
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
a[i] = AssetDatabase.LoadAssetAtPath<T>(path);
}
return a;
#else
return null;
#endif
}
#if UNITY_EDITOR
public static GUIStyle FoldoutStyle => new GUIStyle(EditorStyles.toolbarButton)
{
fontStyle = FontStyle.Bold,
fontSize = 12,
padding = new RectOffset(15, 0, 0, 0),
alignment = TextAnchor.MiddleLeft,
margin = new RectOffset(5, 10, 5, 5),
fixedHeight = 30,
stretchWidth = true
// normal = new GUIStyleState()
// {
// scaledBackgrounds = EditorStyles.toolbarButton.onNormal.scaledBackgrounds
// }
};
#endif
public static List<Type> ResetModuleList()
{
List<Type> listOfMods = (
from domainAssembly in AppDomain.CurrentDomain.GetAssemblies()
from type in domainAssembly.GetTypes()
where typeof(CozyModule).IsAssignableFrom(type)
select type).ToList();
return listOfMods;
}
public static List<Type> ResetBiomeModulesList()
{
List<Type> listOfMods = (
from domainAssembly in AppDomain.CurrentDomain.GetAssemblies()
from type in domainAssembly.GetTypes()
where typeof(CozyModule).IsAssignableFrom(type) && type.GetInterfaces().Any(i => i == typeof(ICozyBiomeModule))
select type).ToList();
return listOfMods;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dc6bf20226bc1bc4dbad1fa1a48af08b
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/Utility/EditorUtilities.cs
uploadId: 939148
@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DistantLands.Cozy
{
[ExecuteAlways]
public class FXParent : MonoBehaviour
{
void OnEnable()
{
if (transform.parent == null)
DestroyImmediate(gameObject);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: cec496125454a684bb93d5662d04938e
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/Utility/FXParent.cs
uploadId: 939148
@@ -0,0 +1,56 @@
using UnityEngine;
namespace DistantLands.Utility
{
public class FreeCam : MonoBehaviour
{
public float normalSpeed = 5.0f;
public float fastSpeedMultiplier = 2.0f;
public float rotationSpeed = 2.0f;
private float currentSpeedMultiplier = 1.0f;
void Update()
{
HandleInput();
if (Input.GetKeyDown(KeyCode.Escape))
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else if (Input.GetMouseButtonDown(0))
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
void HandleInput()
{
// Toggle between normal and fast speed using the Shift key
currentSpeedMultiplier = Input.GetKey(KeyCode.LeftShift) ? fastSpeedMultiplier : 1.0f;
// Set current speed based on the multiplier
float currentSpeed = normalSpeed * currentSpeedMultiplier;
// Handle camera movement
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
float upDown = Input.GetKey(KeyCode.E) ? 1 : Input.GetKey(KeyCode.Q) ? -1 : 0;
Vector3 direction = new Vector3(horizontal, upDown, vertical).normalized;
Vector3 moveVector = transform.TransformDirection(direction) * currentSpeed * Time.deltaTime;
transform.Translate(moveVector, Space.World);
// Handle camera rotation
float mouseX = Input.GetAxis("Mouse X") * rotationSpeed;
float mouseY = -Input.GetAxis("Mouse Y") * rotationSpeed; // Invert Y-axis for more intuitive control
transform.Rotate(Vector3.up, mouseX, Space.World);
transform.Rotate(Vector3.right, mouseY, Space.Self);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 845a3aebe036f7440bd1b06082b5c4f4
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/Utility/FreeCam.cs
uploadId: 939148
@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DistantLands.Cozy
{
public interface ICozyEcosystem
{
public CozyEcosystem Ecosystem { get; set; }
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0b43c99a10d996e428817164bcc96aa1
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/Utility/ICozyEcosystem.cs
uploadId: 939148
@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DistantLands.Cozy
{
public class LightListener : MonoBehaviour
{
public Material onMat;
public Material offMat;
private new Light light;
private Renderer render;
public void TurnOnLight()
{
if (light == null)
light = GetComponent<Light>();
if (render == null)
render = GetComponent<Renderer>();
render.material = onMat;
light.enabled = true;
}
public void TurnOffLight()
{
if (light == null)
light = GetComponent<Light>();
if (render == null)
render = GetComponent<Renderer>();
render.material = offMat;
light.enabled = false;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0c9952fb2bff1e44f9a5734db795cc94
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/Utility/LightListener.cs
uploadId: 939148
@@ -0,0 +1,50 @@
using System;
using UnityEngine;
namespace DistantLands.Cozy
{
[Serializable]
public class MeridiemTime
{
public int hours;
public int minutes;
public int seconds;
public int milliseconds;
public float timeAsPercentage;
public MeridiemTime() { }
public MeridiemTime(int hour, int minute)
{
this.hours = hour;
minutes = minute;
// timeAsPercentage = (hour * 3600000f + minute * 60000f) / 86400000f;
}
public MeridiemTime(int hour, int minute, int second, int millisecond)
{
hours = hour;
minutes = minute;
seconds = second;
milliseconds = millisecond;
// timeAsPercentage = (hour * 3600000f + minute * 60000f + second * 1000f + millisecond) / 86400000f;
}
public static implicit operator MeridiemTime(float floatValue)
{
MeridiemTime time = new MeridiemTime();
time.hours = Mathf.FloorToInt(floatValue * 24f);
time.minutes = Mathf.FloorToInt(floatValue * 1440f % 60f);
time.seconds = Mathf.FloorToInt(floatValue * 86400f % 60f);
time.milliseconds = Mathf.FloorToInt(floatValue * 86400000f % 1000f);
return time;
}
public static implicit operator float(MeridiemTime time) => (time.hours * 3600000f + time.minutes * 60000f + time.seconds * 1000f + time.milliseconds) / 86400000f;
public static implicit operator DateTime(MeridiemTime time) => new DateTime(1, 1, 1, time.hours, time.minutes, time.seconds, time.milliseconds);
public static implicit operator string(MeridiemTime time) => $"{time.hours:D2}:{time.minutes:D2}";
public new string ToString() => $"{hours:D2}:{minutes:D2}";
public string FullString() => $"{hours:D2}:{minutes:D2}:{seconds:D2}:{milliseconds:D4}";
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7ef4d39c181f9fc4fb844d1fa58957ab
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/Utility/MeridiemTime.cs
uploadId: 939148
@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DistantLands.Cozy.Data;
namespace DistantLands.Cozy
{
public class RaiseOnWeatherTypeExample : MonoBehaviour
{
public EventFX weatherType;
void OnEnable()
{
weatherType.onCall += OnStart;
weatherType.onCall += OnStart;
}
void OnDisable()
{
weatherType.onCall -= OnStart;
weatherType.onEnd -= OnEnd;
}
public void OnStart()
{
//Place your code for when the Event FX profile is started here.
}
public void OnEnd()
{
//Place your code for when the Event FX profile is ended here.
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: bfc7db3cd702c0a4192d5430a263aa7f
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/Utility/RaiseOnWeatherTypeExample.cs
uploadId: 939148
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 364aa87bd22a86c489f337174c03109d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,28 @@
using System;
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy
{
[Serializable]
[CreateAssetMenu(menuName = "Distant Lands/Cozy/WRC/Boolean Chance", order = 361)]
public class BoolChanceEffector : CustomCozyChanceEffector
{
public bool toggle;
public override float GetChance()
{
return toggle ? 1 : 0;
}
}
#if UNITY_EDITOR
#endif
}
@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6a530ddd69bf2304d9f71d7c1037496a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 938090e55840a424d95b5b022c0da674, 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/Weighted Random
Chance/BoolChanceEffector.cs
uploadId: 939148
@@ -0,0 +1,241 @@
using System;
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy
{
[Serializable]
public class ChanceEffector
{
public enum LimitType { Temperature, Precipitation, YearPercentage, Time, AccumulatedWetness, AccumulatedSnow, Custom };
public LimitType limitType;
public AnimationCurve curve;
public CustomCozyChanceEffector customChanceEffector;
public float GetChance(float test)
{
return curve.Evaluate(test);
}
public float GetChance(CozyWeather weather)
{
switch (limitType)
{
case LimitType.Temperature:
if (weather.climateModule != null)
return curve.Evaluate(weather.climateModule.currentTemperature / 100);
else
return 1;
case LimitType.Precipitation:
if (weather.climateModule != null)
return curve.Evaluate(weather.climateModule.currentPrecipitation / 100);
else
return 1;
case LimitType.YearPercentage:
if (weather.timeModule != null)
return curve.Evaluate(weather.timeModule.yearPercentage);
else
return 1;
case LimitType.Time:
if (weather.timeModule != null)
return curve.Evaluate(weather.timeModule.currentTime);
else
return 1;
case LimitType.AccumulatedSnow:
if (weather.climateModule)
return curve.Evaluate(weather.climateModule.snowAmount);
else
return 1;
case LimitType.AccumulatedWetness:
if (weather.climateModule)
return curve.Evaluate(weather.climateModule.groundwaterAmount);
else
return 1;
case LimitType.Custom:
return customChanceEffector.GetChance();
default:
return 1;
}
}
public float GetChanceAtTime(CozyWeather weather, float time)
{
switch (limitType)
{
case LimitType.Temperature:
if (weather.climateModule != null)
return curve.Evaluate(weather.climateModule.GetTemperature(time) / 100);
else
return 1;
case LimitType.Precipitation:
if (weather.climateModule != null)
return curve.Evaluate(weather.climateModule.GetHumidity(time) / 100);
else
return 1;
case LimitType.YearPercentage:
if (weather.timeModule)
return curve.Evaluate(time / weather.timeModule.DaysPerYear % 1);
else
return 1;
case LimitType.Time:
return curve.Evaluate(time % 1);
case LimitType.AccumulatedSnow:
if (weather.climateModule)
return curve.Evaluate(weather.climateModule.groundwaterAmount);
else
return 1;
case LimitType.AccumulatedWetness:
if (weather.climateModule)
return curve.Evaluate(weather.climateModule.snowAmount);
else
return 1;
default:
return 1;
}
}
}
public class CustomCozyChanceEffector : ScriptableObject
{
public virtual float GetChance()
{
return 1;
}
}
#if UNITY_EDITOR
[UnityEditor.CustomPropertyDrawer(typeof(ChanceEffectorAttribute))]
[UnityEditor.CustomPropertyDrawer(typeof(ChanceEffector))]
public class ChanceEffectorDrawer : PropertyDrawer
{
ChanceEffectorAttribute _attribute;
public static Type[] customChanceEffectors;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
_attribute = (ChanceEffectorAttribute)attribute;
EditorGUI.BeginProperty(position, label, property);
var indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
var titleRect = new Rect(position.x, position.y, 100, position.height);
var unitRect = new Rect(position.x + 107, position.y, position.width - 135, position.height);
var dropdown = new Rect(position.x + (position.width - 20), position.y, 20, position.height);
if (property.FindPropertyRelative("limitType").intValue == 6)
{
titleRect = new Rect(position.x, position.y, 100, position.height);
unitRect = new Rect(position.x + 107, position.y, position.width - 135, position.height);
dropdown = new Rect(position.x + (position.width - 20), position.y, 20, position.height);
EditorGUI.PropertyField(titleRect, property.FindPropertyRelative("limitType"), GUIContent.none);
EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("customChanceEffector"), GUIContent.none);
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
return;
}
int preset = -1;
List<AnimationCurve> presets = new List<AnimationCurve>();
List<GUIContent> presetNames = new List<GUIContent>();
switch (property.FindPropertyRelative("limitType").intValue)
{
case (0):
presets.Add(new AnimationCurve(new Keyframe(0.3f, 1), new Keyframe(0.34f, 0), new Keyframe(0, 1), new Keyframe(1, 0)));
presets.Add(new AnimationCurve(new Keyframe(0.3f, 0), new Keyframe(0.34f, 1), new Keyframe(0, 0), new Keyframe(1, 1)));
presets.Add(new AnimationCurve(new Keyframe(0.8f, 0), new Keyframe(1, 1), new Keyframe(0, 0)));
presets.Add(new AnimationCurve(new Keyframe(1, 1), new Keyframe(0, 0)));
presets.Add(new AnimationCurve(new Keyframe(1, 0.5f), new Keyframe(0.5f, 0), new Keyframe(0.8f, 1)));
presets.Add(new AnimationCurve(new Keyframe(1, 0), new Keyframe(0, 0), new Keyframe(0.5f, 1)));
presets.Add(new AnimationCurve(new Keyframe(1, 0), new Keyframe(0, 1)));
presetNames.Add(new GUIContent("Only below freezing"));
presetNames.Add(new GUIContent("Only above freezing"));
presetNames.Add(new GUIContent("Only above 80F"));
presetNames.Add(new GUIContent("More likely at hot tempratures"));
presetNames.Add(new GUIContent("More likely at warm tempratures"));
presetNames.Add(new GUIContent("More likely at cool tempratures"));
presetNames.Add(new GUIContent("More likely at freezing tempratures"));
break;
case (1):
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1, 3, 0)));
presets.Add(new AnimationCurve(new Keyframe(1, 0), new Keyframe(0, 1)));
presets.Add(new AnimationCurve(new Keyframe(1, 0), new Keyframe(0, 1, -3, -3)));
presetNames.Add(new GUIContent("More likely during high precipitation"));
presetNames.Add(new GUIContent("Most likely during high precipitation"));
presetNames.Add(new GUIContent("More likely during low precipitation"));
presetNames.Add(new GUIContent("Most likely during low precipitation"));
break;
case (2):
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0), new Keyframe(0.1f, 0), new Keyframe(0.2f, 1), new Keyframe(0.35f, 1), new Keyframe(0.45f, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0), new Keyframe(0.35f, 0), new Keyframe(0.45f, 1), new Keyframe(0.6f, 1), new Keyframe(0.7f, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0), new Keyframe(0.6f, 0), new Keyframe(0.7f, 1), new Keyframe(0.85f, 1), new Keyframe(0.95f, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 1), new Keyframe(0.1f, 0), new Keyframe(0.95f, 1), new Keyframe(1f, 1), new Keyframe(0.85f, 0)));
presetNames.Add(new GUIContent("More likely during spring"));
presetNames.Add(new GUIContent("Most likely during summer"));
presetNames.Add(new GUIContent("More likely during fall"));
presetNames.Add(new GUIContent("Most likely during winter"));
break;
case (3):
presets.Add(new AnimationCurve(new Keyframe(0, 1), new Keyframe(0.2f, 1), new Keyframe(0.25f, 0), new Keyframe(0.75f, 0), new Keyframe(0.8f, 1), new Keyframe(1, 1)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.2f, 0), new Keyframe(0.25f, 1), new Keyframe(0.75f, 1), new Keyframe(0.8f, 0), new Keyframe(1, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.18f, 0), new Keyframe(0.25f, 1), new Keyframe(0.35f, 0), new Keyframe(0.7f, 0), new Keyframe(0.75f, 1), new Keyframe(0.85f, 0), new Keyframe(1, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.70f, 0), new Keyframe(0.8f, 1), new Keyframe(0.85f, 0), new Keyframe(1, 0)));
presets.Add(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.18f, 0), new Keyframe(0.22f, 1), new Keyframe(0.3f, 0), new Keyframe(1, 0)));
presetNames.Add(new GUIContent("More likely at night"));
presetNames.Add(new GUIContent("Most likely during the day"));
presetNames.Add(new GUIContent("More likely in the evening & morning"));
presetNames.Add(new GUIContent("More likely in the evening"));
presetNames.Add(new GUIContent("Most likely in the morning"));
break;
}
EditorGUI.PropertyField(titleRect, property.FindPropertyRelative("limitType"), GUIContent.none);
EditorGUI.PropertyField(unitRect, property.FindPropertyRelative("curve"), GUIContent.none);
preset = EditorGUI.Popup(dropdown, GUIContent.none, -1, presetNames.ToArray());
if (preset != -1)
property.FindPropertyRelative("curve").animationCurveValue = presets[preset];
preset = -1;
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
}
}
#endif
public class ChanceEffectorAttribute : PropertyAttribute
{
public ChanceEffectorAttribute()
{
}
}
}
@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6d94b8830bf79cc4c93e2ac45b35a0c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 938090e55840a424d95b5b022c0da674, 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/Weighted Random
Chance/ChanceEffector.cs
uploadId: 939148
@@ -0,0 +1,28 @@
using System;
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy
{
[Serializable]
[CreateAssetMenu(menuName = "Distant Lands/Cozy/WRC/Simple Chance", order = 361)]
public class SimpleChanceEffector : CustomCozyChanceEffector
{
public float chance;
public override float GetChance()
{
return chance;
}
}
#if UNITY_EDITOR
#endif
}
@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8b6a902bac87ebf4e9694b854b199519
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 938090e55840a424d95b5b022c0da674, 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/Weighted Random
Chance/SimpleChanceEffector.cs
uploadId: 939148
@@ -0,0 +1,140 @@
// Distant Lands 2025
// COZY: Stylized Weather 3
// All code included in this file is protected under the Unity Asset Store Eula
// Documentation provided here: https://distant-lands.gitbook.io/cozy-stylized-weather-documentation/how-it-works/weighted-random-values
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
namespace DistantLands.Cozy
{
[System.Serializable]
public class WeightedRandomChance
{
[Range(0, 1)]
public float baseChance = 1;
[Tooltip("Animation curves that increase or decrease chance based on time, temperature, etc.")]
public List<ChanceEffector> chanceEffectors = new List<ChanceEffector>();
public float GetChance() => GetChance(CozyWeather.instance);
public float GetChance(CozyWeather weather)
{
float i = baseChance;
foreach (ChanceEffector j in chanceEffectors)
if (j != null)
i *= j.GetChance(weather);
return Mathf.Max(i, 0);
}
public float GetChance(CozyWeather weather, float inTime)
{
float i = baseChance;
foreach (ChanceEffector j in chanceEffectors)
if (j != null)
i *= j.GetChanceAtTime(weather, inTime);
return Mathf.Max(i, 0);
}
public bool HasLimit(ChanceEffector.LimitType limit)
{
foreach (ChanceEffector effector in chanceEffectors)
{
if (effector.limitType == limit)
return true;
}
return false;
}
public float GetChance(ChanceEffector.LimitType limit, float test)
{
float i = baseChance;
foreach (ChanceEffector effector in chanceEffectors)
{
i *= effector.limitType == limit ? effector.GetChance(test) : 1;
}
return i;
}
public static implicit operator float(WeightedRandomChance chance)
{
return chance.GetChance();
}
}
#if UNITY_EDITOR
[UnityEditor.CustomPropertyDrawer(typeof(WeightedRandomChance))]
public class WeightedChanceDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
float height = EditorGUIUtility.singleLineHeight;
var labelRect = new Rect(position.x, position.y, 100, height);
var unitARect = new Rect(position.x + 100, position.y, position.width - 130, height);
var unitBRect = new Rect(position.width - 7, position.y, 25, height);
EditorGUI.BeginProperty(position, label, property);
EditorGUI.LabelField(labelRect, label);
EditorGUI.PropertyField(unitARect, property.FindPropertyRelative("baseChance"), GUIContent.none);
if (GUI.Button(unitBRect, "..."))
EditWeightedRandomInWindow.OpenWindow(property);
EditorGUI.EndProperty();
}
}
public class EditWeightedRandomInWindow : EditorWindow
{
public Vector2 scrollPos;
public SerializedProperty chance;
public static void OpenWindow(SerializedProperty chance)
{
EditWeightedRandomInWindow window = (EditWeightedRandomInWindow)GetWindow(typeof(EditWeightedRandomInWindow), true, $"Adjust Chance Effectors");
window.chance = chance;
window.minSize = new Vector2(200, 100);
window.Show();
}
private void OnGUI()
{
if (chance == null)
{
Close();
return;
}
EditorGUI.indentLevel = 1;
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
chance.serializedObject.Update();
EditorGUILayout.PropertyField(chance.FindPropertyRelative("baseChance"));
EditorGUILayout.PropertyField(chance.FindPropertyRelative("chanceEffectors"));
chance.serializedObject.ApplyModifiedProperties();
EditorGUILayout.EndScrollView();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Done"))
Close();
}
}
#endif
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1c46fb7b84a3ba9458445bbe9c551f1f
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/Utility/WeightedRandomChance.cs
uploadId: 939148