35 lines
903 B
C#
35 lines
903 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.MainGame
|
|
{
|
|
public interface IGameElement
|
|
{
|
|
public static readonly Dictionary<Guid, IGameElement> Instances = new Dictionary<Guid, IGameElement>();
|
|
|
|
public Guid elementID { get; set; }
|
|
|
|
public void Initialize()
|
|
{
|
|
elementID = Guid.NewGuid();
|
|
|
|
if (!Instances.ContainsKey(this.elementID))
|
|
{
|
|
Instances.Add(this.elementID, this);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning($"GameElement with ID {this.elementID} is already registered.");
|
|
}
|
|
}
|
|
|
|
public void Unregister()
|
|
{
|
|
if (Instances.ContainsKey(this.elementID))
|
|
{
|
|
Instances.Remove(this.elementID);
|
|
}
|
|
}
|
|
}
|
|
} |