49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using PashaBibko.Pacore.Attributes;
|
|
using UnityEngine;
|
|
|
|
namespace Fruitomation.Global
|
|
{
|
|
public enum GameState
|
|
{
|
|
Simulation,
|
|
BuildingMenu,
|
|
Building,
|
|
UpgradeMenu,
|
|
Paused,
|
|
Default
|
|
}
|
|
|
|
[CreateInstanceOnStart] public class GameStateController : MonoBehaviour
|
|
{
|
|
private static GameStateController Instance;
|
|
|
|
[SerializeField, InspectorReadOnly("Game State")] private GameState InternalState;
|
|
public static GameState State
|
|
{
|
|
get => Instance.InternalState;
|
|
set
|
|
{
|
|
if (Instance.InternalState != value)
|
|
{
|
|
Debug.Log($"Changing state from [{Instance.InternalState}] to [{value}]");
|
|
Instance.InternalState = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static bool Is(GameState state) => State == state;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance is not null)
|
|
{
|
|
Debug.LogError("Cannot have multiple instances of [GameStateController]");
|
|
return;
|
|
}
|
|
|
|
InternalState = GameState.Default;
|
|
Instance = this;
|
|
}
|
|
}
|
|
}
|