OldBlueWater/BlueWater/Assets/Distant Lands/Cozy Weather/Contents/Scripts/Data/FX/PrecipitationFX.cs

109 lines
2.9 KiB
C#
Raw Normal View History

2023-09-13 05:07:40 +00:00
// Distant Lands 2022.
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy.Data
{
[System.Serializable]
[CreateAssetMenu(menuName = "Distant Lands/Cozy/FX/Precipitation FX", order = 361)]
public class PrecipitationFX : FXProfile
{
[Range(0, 0.05f)]
public float rainAmount;
[Range(0, 0.05f)]
public float snowAmount;
public float weight;
CozyWeather weather;
2024-01-03 06:34:33 +00:00
CozyClimateModule climateModule;
2023-09-13 05:07:40 +00:00
public override void PlayEffect(float i)
{
2024-01-03 06:34:33 +00:00
if (!weather)
2023-09-13 05:07:40 +00:00
if (InitializeEffect(null) == false)
return;
2024-01-03 06:34:33 +00:00
climateModule.snowSpeed += snowAmount * Mathf.Clamp01(transitionTimeModifier.Evaluate(i));
climateModule.rainSpeed += rainAmount * Mathf.Clamp01(transitionTimeModifier.Evaluate(i));
2023-09-13 05:07:40 +00:00
}
2024-01-03 06:34:33 +00:00
public override bool InitializeEffect(CozyWeather weather)
2023-09-13 05:07:40 +00:00
{
2024-01-03 06:34:33 +00:00
weatherSphere = weather ? weather : CozyWeather.instance;
2023-09-13 05:07:40 +00:00
2024-01-03 06:34:33 +00:00
if (!weatherSphere.climateModule)
2023-09-13 05:07:40 +00:00
return false;
2024-01-03 06:34:33 +00:00
climateModule = weatherSphere.climateModule;
2023-09-13 05:07:40 +00:00
return true;
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(PrecipitationFX))]
[CanEditMultipleObjects]
public class E_PrecipitationFX : E_FXProfile
{
void OnEnable()
{
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty("rainAmount"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("snowAmount"));
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("transitionTimeModifier"));
serializedObject.ApplyModifiedProperties();
}
public override void RenderInWindow(Rect pos)
{
float space = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
var propPosA = new Rect(pos.x, pos.y + space, pos.width, EditorGUIUtility.singleLineHeight);
var propPosB = new Rect(pos.x, pos.y + space * 2, pos.width, EditorGUIUtility.singleLineHeight);
var propPosC = new Rect(pos.x, pos.y + space * 3, pos.width, EditorGUIUtility.singleLineHeight);
serializedObject.Update();
EditorGUI.PropertyField(propPosA, serializedObject.FindProperty("rainAmount"));
EditorGUI.PropertyField(propPosB, serializedObject.FindProperty("snowAmount"));
EditorGUI.PropertyField(propPosC, serializedObject.FindProperty("transitionTimeModifier"));
serializedObject.ApplyModifiedProperties();
}
public override float GetLineHeight()
{
return 3;
}
}
#endif
}