mirror of
https://github.com/DerTyp7/industrialize-unity.git
synced 2025-10-30 12:57:11 +01:00
35 lines
697 B
C#
35 lines
697 B
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public abstract class Dictionary<TEntryType> : MonoBehaviour
|
|
{
|
|
public List<TEntryType> entries = new List<TEntryType>();
|
|
|
|
public abstract TEntryType GetEntryById(string id);
|
|
|
|
public static Dictionary<TEntryType> instance { get; private set; }
|
|
|
|
protected virtual void Awake()
|
|
{
|
|
if (instance != null)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
instance = this;
|
|
}
|
|
}
|
|
|
|
public void Register(TEntryType entry)
|
|
{
|
|
entries.Add(entry);
|
|
}
|
|
|
|
public void Unregister(TEntryType entry)
|
|
{
|
|
entries.Remove(entry);
|
|
}
|
|
}
|