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

101 lines
2.1 KiB
C#
Raw Normal View History

2023-09-13 05:07:40 +00:00
// Distant Lands 2022.
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace DistantLands.Cozy.Data
{
[System.Serializable]
[CreateAssetMenu(menuName = "Distant Lands/Cozy/FX/Event FX", order = 361)]
public class EventFX : FXProfile
{
2024-01-03 06:34:33 +00:00
public CozyEventModule events;
2023-09-13 05:07:40 +00:00
2024-01-03 06:34:33 +00:00
public bool isPlaying;
2023-09-13 05:07:40 +00:00
public delegate void OnCall();
public event OnCall onCall;
public void RaiseOnCall()
{
2024-01-03 06:34:33 +00:00
onCall?.Invoke();
2023-09-13 05:07:40 +00:00
}
public delegate void OnEnd();
public event OnEnd onEnd;
public void RaiseOnEnd()
{
2024-01-03 06:34:33 +00:00
onEnd?.Invoke();
2023-09-13 05:07:40 +00:00
}
2024-01-03 06:34:33 +00:00
public void PlayEffect()
2023-09-13 05:07:40 +00:00
{
2024-01-03 06:34:33 +00:00
if (!isPlaying)
2023-09-13 05:07:40 +00:00
{
2024-01-03 06:34:33 +00:00
isPlaying = true;
onCall?.Invoke();
2023-09-13 05:07:40 +00:00
}
}
2024-01-03 06:34:33 +00:00
public override void PlayEffect(float weight)
2023-09-13 05:07:40 +00:00
{
2024-01-03 06:34:33 +00:00
if (weight > 0.5f)
2023-09-13 05:07:40 +00:00
PlayEffect();
else
StopEffect();
}
2024-01-03 06:34:33 +00:00
public void StopEffect()
2023-09-13 05:07:40 +00:00
{
2024-01-03 06:34:33 +00:00
if (isPlaying)
2023-09-13 05:07:40 +00:00
{
2024-01-03 06:34:33 +00:00
isPlaying = false;
onEnd?.Invoke();
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
base.InitializeEffect(weather);
2023-09-13 05:07:40 +00:00
2024-01-03 06:34:33 +00:00
if (!weatherSphere.GetModule<CozyEventModule>())
return false;
2023-09-13 05:07:40 +00:00
2024-01-03 06:34:33 +00:00
events = weatherSphere.GetModule<CozyEventModule>();
2023-09-13 05:07:40 +00:00
return true;
}
}
2024-01-03 06:34:33 +00:00
2023-09-13 05:07:40 +00:00
#if UNITY_EDITOR
[CustomEditor(typeof(EventFX))]
[CanEditMultipleObjects]
public class E_EventFX : E_FXProfile
{
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.HelpBox("No other properties to adjust! Set events in the Cozy Event Module!", MessageType.Info);
serializedObject.ApplyModifiedProperties();
}
public override void RenderInWindow(Rect pos)
{
}
public override float GetLineHeight()
{
return 0;
}
}
#endif
}