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

125 lines
3.5 KiB
C#

using System;
using System.Threading.Tasks;
using UnityEngine;
namespace DDD
{
public static class GameEvents
{
public static TimeScaleChangeEvent RequestTimeScaleChangeEvent = new();
public static FadeInEvent FadeInEvent = new();
public static FadeOutEvent FadeOutEvent = new();
public static OpenPopupUiEvent OpenPopupUiEvent = new();
public static ClosePopupUiEvent ClosePopupUiEvent = new();
public static ShowGlobalMessageEvent ShowGlobalMessageEvent = new();
public static ShowInteractionUiEvent ShowInteractionUiEvent = new();
public static HideInteractionUiEvent HideInteractionUiEvent = new();
public static InventoryChangedEvent InventoryChangedEvent = new();
public static SmartVariablesDirtyEvent SmartVariablesDirtyEvent = new();
}
public static class RestaurantEvents
{
public static ItemSlotSelectedEvent ItemSlotSelectedEvent = new();
public static TodayMenuAddedEvent TodayMenuAddedEvent = new();
public static TodayMenuRemovedEvent TodayMenuRemovedEvent = new();
}
// public static class VoyageEvents
// {
// // Some events...
// }
public class TimeScaleChangeEvent : IEvent
{
public object Requester;
public float NewTimeScale;
}
public class FadeInEvent : IEvent
{
public float Duration;
public TaskCompletionSource<bool> CompletionSource = new();
public Task WaitAsync() => CompletionSource.Task;
}
public class FadeOutEvent : IEvent
{
public float Duration;
public TaskCompletionSource<bool> CompletionSource = new();
public Task WaitAsync() => CompletionSource.Task;
}
public class ShowGlobalMessageEvent : IEvent
{
public string NewMessageKey;
public float ShowDuration;
public float FadeDuration;
public Color TextColor;
public int FontSize;
public void Set(string newMessageKey, float newShowDuration = 1f, float newFadeDuration = 0.5f, Color newTextColor = default, int fontSize = 44)
{
NewMessageKey = newMessageKey;
ShowDuration = newShowDuration;
FadeDuration = newFadeDuration;
TextColor = newTextColor == default ? Color.red : newTextColor;
FontSize = fontSize;
}
}
public class OpenPopupUiEvent : IEvent
{
public Type UiType;
public string NewMessageKey;
public Action OnConfirm;
public Action OnCancel;
public bool IsCancelButtonVisible;
}
public class ClosePopupUiEvent : IEvent
{
public Type UiType;
}
public class InventoryChangedEvent : IEvent
{
public string ItemId;
public int NewCount;
}
public class ShowInteractionUiEvent : IEvent
{
public bool CanInteract;
public string TextKey;
public float HoldProgress;
}
public class HideInteractionUiEvent : IEvent { }
public class SmartVariablesDirtyEvent : IEvent
{
public SmartVariablesDomain DomainFlags;
}
#region RestaurantInteractionEvents
public class ItemSlotSelectedEvent : IEvent
{
public ItemViewModel Model;
}
public class TodayMenuAddedEvent : IEvent {}
public class TodayMenuRemovedEvent : IEvent
{
public InventoryCategoryType InventoryCategoryType;
}
#endregion
}