First Commit

This commit is contained in:
Syntriax 2022-11-21 13:33:46 +03:00
parent 7a32624ed1
commit 7565da4a9c
7 changed files with 86 additions and 0 deletions

10
FactoryBase.cs Normal file
View File

@ -0,0 +1,10 @@
using UnityEngine;
namespace Syntriax.Modules.Factory
{
public abstract class FactoryBase : MonoBehaviour, IFactory
{
public abstract void Initialize();
public abstract void Reset();
}
}

11
FactoryBase.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f03dc034a54c734448dde62aa338c24e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

28
FactorySingleton.cs Normal file
View File

@ -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();
}
}

11
FactorySingleton.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3541837e6dc3675418eaa6408d8c81cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
IFactory.cs Normal file
View File

@ -0,0 +1,8 @@
namespace Syntriax.Modules.Factory
{
public interface IFactory
{
public void Initialize();
public void Reset();
}
}

11
IFactory.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ae08bf6242ccc1941839a7c16f7037be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
README.md.meta Normal file
View File

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