First Commit
This commit is contained in:
parent
7a32624ed1
commit
7565da4a9c
|
@ -0,0 +1,10 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Syntriax.Modules.Factory
|
||||||
|
{
|
||||||
|
public abstract class FactoryBase : MonoBehaviour, IFactory
|
||||||
|
{
|
||||||
|
public abstract void Initialize();
|
||||||
|
public abstract void Reset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f03dc034a54c734448dde62aa338c24e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Syntriax.Modules.Factory
|
||||||
|
{
|
||||||
|
public abstract class FactorySingleton<T> : MonoBehaviour, IFactory where T : Component, IFactory
|
||||||
|
{
|
||||||
|
public const string ParentName = "Factories";
|
||||||
|
private static T _instance = null;
|
||||||
|
public static T Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_instance == null)
|
||||||
|
{
|
||||||
|
GameObject factoriesGO = GameObject.Find(ParentName) ?? new GameObject(ParentName);
|
||||||
|
_instance = new GameObject(nameof(T)).AddComponent<T>();
|
||||||
|
_instance.transform.SetParent(factoriesGO.transform);
|
||||||
|
DontDestroyOnLoad(factoriesGO);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize() => Instance.Initialize();
|
||||||
|
public void Reset() => Instance.Reset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3541837e6dc3675418eaa6408d8c81cb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace Syntriax.Modules.Factory
|
||||||
|
{
|
||||||
|
public interface IFactory
|
||||||
|
{
|
||||||
|
public void Initialize();
|
||||||
|
public void Reset();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ae08bf6242ccc1941839a7c16f7037be
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f53b7b4487fd29d429404199725b6781
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue