Added Furnance and smelting
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IGlobalUISectionController { }
|
||||
|
||||
public sealed class GlobalUIController : MonoBehaviour
|
||||
{
|
||||
public static GlobalUIController Instance { get; private set; }
|
||||
|
||||
private readonly HashSet<IGlobalUISectionController> sectionControllers = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
@@ -13,11 +18,43 @@ public sealed class GlobalUIController : MonoBehaviour
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
|
||||
foreach (MonoBehaviour behaviour in FindObjectsByType<MonoBehaviour>(
|
||||
FindObjectsInactive.Include,
|
||||
FindObjectsSortMode.None))
|
||||
{
|
||||
if (behaviour is IGlobalUISectionController controller)
|
||||
Register(controller);
|
||||
}
|
||||
}
|
||||
|
||||
public void Register(IGlobalUISectionController controller)
|
||||
{
|
||||
if (controller != null)
|
||||
sectionControllers.Add(controller);
|
||||
}
|
||||
|
||||
public void Unregister(IGlobalUISectionController controller)
|
||||
{
|
||||
if (controller != null)
|
||||
sectionControllers.Remove(controller);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetControllers<T>() where T : class, IGlobalUISectionController
|
||||
{
|
||||
foreach (IGlobalUISectionController controller in sectionControllers)
|
||||
{
|
||||
if (controller is T typedController)
|
||||
yield return typedController;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (Instance == this)
|
||||
{
|
||||
sectionControllers.Clear();
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user