add: Item Manager
This commit is contained in:
@@ -8,6 +8,7 @@ using Polonium.Attributes;
|
||||
using Polonium;
|
||||
using Polonium.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using Polonium.Agents;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
public static partial class GlobalRegistry
|
||||
@@ -28,21 +29,18 @@ public static partial class GlobalRegistry
|
||||
|
||||
public static class Asset<T> where T : Node
|
||||
{
|
||||
private static readonly Queue<T> Pool = new();
|
||||
// ReSharper disable once StaticMemberInGenericType
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Global
|
||||
public static PackedScene Scene { get; set; }
|
||||
private static T Instance => Scene.Instantiate<T>();
|
||||
public static T Get() => Pool.Count > 0 ? Pool.Dequeue() : Instance;
|
||||
|
||||
public static void Return(T obj)
|
||||
{
|
||||
if(Pool.Count < 10)
|
||||
Pool.Enqueue(obj);
|
||||
else
|
||||
obj.QueueFree();
|
||||
}
|
||||
public static PackedScene Scene => PoloniumRegistry.Asset<T>.Scene;
|
||||
public static T Get() => PoloniumRegistry.Asset<T>.Get();
|
||||
public static void Return(T obj) => PoloniumRegistry.Asset<T>.Return(obj);
|
||||
}
|
||||
|
||||
public static partial class Action<TAction> where TAction : AgentAction
|
||||
{
|
||||
public static string Name => PoloniumRegistry.Action<TAction>.Name;
|
||||
}
|
||||
|
||||
public static PoloniumRegistry PoloniumRegistry => PoloniumRegistry.Instance;
|
||||
public static bool Paused { get; set; }
|
||||
public static void Prepare() => PoloniumRegistry.Prepare();
|
||||
|
||||
Reference in New Issue
Block a user