From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/DefaultPool.cs | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Client/Assembly-CSharp/DefaultPool.cs (limited to 'Client/Assembly-CSharp/DefaultPool.cs') diff --git a/Client/Assembly-CSharp/DefaultPool.cs b/Client/Assembly-CSharp/DefaultPool.cs new file mode 100644 index 0000000..676c666 --- /dev/null +++ b/Client/Assembly-CSharp/DefaultPool.cs @@ -0,0 +1,82 @@ +using System; +using UnityEngine; + +public class DefaultPool : IObjectPool +{ + public override int InUse + { + get + { + return 0; + } + } + + public override int NotInUse + { + get + { + return 0; + } + } + + public static bool InstanceExists + { + get + { + return DefaultPool._instance; + } + } + + public static DefaultPool Instance + { + get + { + object @lock = DefaultPool._lock; + DefaultPool instance; + lock (@lock) + { + if (DefaultPool._instance == null) + { + DefaultPool._instance = UnityEngine.Object.FindObjectOfType(); + if (UnityEngine.Object.FindObjectsOfType().Length > 1) + { + Debug.LogError("[Singleton] Something went really wrong - there should never be more than 1 singleton! Reopening the scene might fix it."); + return DefaultPool._instance; + } + if (DefaultPool._instance == null) + { + GameObject gameObject = new GameObject(); + DefaultPool._instance = gameObject.AddComponent(); + gameObject.name = "(singleton) DefaultPool"; + } + } + instance = DefaultPool._instance; + } + return instance; + } + } + + private static DefaultPool _instance; + + private static object _lock = new object(); + + public void OnDestroy() + { + object @lock = DefaultPool._lock; + lock (@lock) + { + DefaultPool._instance = null; + } + } + + public override T Get() + { + throw new NotImplementedException(); + } + + public override void Reclaim(PoolableBehavior obj) + { + Debug.Log("Default Pool: Destroying this thing."); + UnityEngine.Object.Destroy(obj.gameObject); + } +} -- cgit v1.1-26-g67d0