Assembly Definition & Improvements

This commit is contained in:
Syntriax 2022-11-21 13:48:58 +03:00
parent 7565da4a9c
commit 49b1bcd578
4 changed files with 19 additions and 5 deletions

View File

@ -2,7 +2,7 @@ using UnityEngine;
namespace Syntriax.Modules.Factory
{
public abstract class FactorySingleton<T> : MonoBehaviour, IFactory where T : Component, IFactory
public abstract class FactorySingleton<T> : MonoBehaviour where T : FactoryBase
{
public const string ParentName = "Factories";
private static T _instance = null;
@ -13,7 +13,7 @@ namespace Syntriax.Modules.Factory
if (_instance == null)
{
GameObject factoriesGO = GameObject.Find(ParentName) ?? new GameObject(ParentName);
_instance = new GameObject(nameof(T)).AddComponent<T>();
_instance = new GameObject(typeof(T).Name).AddComponent<T>();
_instance.transform.SetParent(factoriesGO.transform);
DontDestroyOnLoad(factoriesGO);
}
@ -21,8 +21,5 @@ namespace Syntriax.Modules.Factory
return _instance;
}
}
public void Initialize() => Instance.Initialize();
public void Reset() => Instance.Reset();
}
}

View File

@ -2,7 +2,14 @@ namespace Syntriax.Modules.Factory
{
public interface IFactory
{
/// <summary>
/// Initializes the <see cref="IFactory"/>
/// </summary>
public void Initialize();
/// <summary>
/// Resets the <see cref="IFactory"/>
/// </summary>
public void Reset();
}
}

View File

@ -0,0 +1,3 @@
{
"name": "Syntriax.Modules.Factory"
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d4c952ed5f59c5a449cda1b0080ed841
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: