ProjectDDD/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs

110 lines
3.0 KiB
C#
Raw Normal View History

2025-07-21 07:56:12 +00:00
using System;
using System.Threading.Tasks;
using UnityEngine;
2025-07-17 08:15:40 +00:00
namespace DDD
{
2025-07-21 07:56:12 +00:00
// public static class GameEvents
// {
// public static RequestTimeScaleChangeEvent RequestTimeScaleChangeEvent = new();
// public static RequestShowGlobalMessageEvent RequestShowGlobalMessageEvent = new();
// public static InteractionEvent Interaction = new InteractionEvent();
// }
// public static class RestaurantEvents
// {
// // Some events...
// }
// public static class VoyageEvents
// {
// // Some events...
// }
public class TimeScaleChangeEvent : IEvent
2025-07-17 08:15:40 +00:00
{
2025-07-21 07:56:12 +00:00
public readonly object Requester;
public readonly float NewTimeScale;
public TimeScaleChangeEvent(object requester, float newTimeScale)
{
Requester = requester;
NewTimeScale = newTimeScale;
}
}
public class FadeInEvent : IEvent
{
public readonly float Duration;
public readonly TaskCompletionSource<bool> CompletionSource;
public FadeInEvent(float duration)
{
Duration = duration;
CompletionSource = new TaskCompletionSource<bool>();
}
public Task WaitAsync() => CompletionSource.Task;
}
public class FadeOutEvent : IEvent
{
public readonly float Duration;
public readonly TaskCompletionSource<bool> CompletionSource;
public FadeOutEvent(float duration)
{
Duration = duration;
CompletionSource = new TaskCompletionSource<bool>();
}
public Task WaitAsync() => CompletionSource.Task;
public static InventoryChangedEvent InventoryChangedEvent = new();
public static InteractionEvent Interaction = new();
2025-07-21 07:56:12 +00:00
}
public class ShowGlobalMessageEvent : IEvent
{
public readonly string NewMessageKey;
public readonly float ShowDuration;
public readonly float FadeDuration;
public ShowGlobalMessageEvent(string newMessageKey, float showDuration = 3f, float fadeDuration = 0.3f)
{
NewMessageKey = newMessageKey;
ShowDuration = showDuration;
FadeDuration = fadeDuration;
}
2025-07-17 08:15:40 +00:00
}
2025-07-21 07:56:12 +00:00
public class OpenScreenUiEvent : IEvent
{
public readonly Type UiType;
public OpenScreenUiEvent(Type uiType) => UiType = uiType;
}
public class CloseScreenUiEvent : IEvent
2025-07-17 08:15:40 +00:00
{
2025-07-21 07:56:12 +00:00
public readonly Type UiType;
public CloseScreenUiEvent(Type uiType) => UiType = uiType;
2025-07-17 08:15:40 +00:00
}
2025-07-21 07:56:12 +00:00
public class OpenPopupUiEvent : IEvent
{
public readonly Type UiType;
public OpenPopupUiEvent(Type uiType) => UiType = uiType;
}
public class ClosePopupUiEvent : IEvent
2025-07-17 08:15:40 +00:00
{
2025-07-21 07:56:12 +00:00
public readonly Type UiType;
public ClosePopupUiEvent(Type uiType) => UiType = uiType;
2025-07-17 08:15:40 +00:00
}
public class InteractionEvent : IEvent
{
public GameObject Causer;
public GameObject Target;
}
public class InventoryChangedEvent : IEvent { }
}