add: Item Manager

This commit is contained in:
h z
2025-02-28 08:49:32 +00:00
parent e90f701bd5
commit d2f0ab8153
21 changed files with 648 additions and 24 deletions

View File

@@ -32,6 +32,39 @@ public class PoloniumRegistry
// ReSharper disable once CollectionNeverQueried.Global
[RegistryPassThrough(true)]
public HashSet<ITimeConsumer> TimeConsumers { get; } = new();
public static class Action<TAction>
where TAction : AgentAction
{
// ReSharper disable once StaticMemberInGenericType
public static string Name { get; set; }
}
public static class SkinRegistry<TSkin>
where TSkin : Polonium.SkinManagers.Skin
{
// ReSharper disable once StaticMemberInGenericType
public static Color[] PaletteRoots { get; set; }
// ReSharper disable once StaticMemberInGenericType
public static Dictionary<Color, Color[]> PaletteMap { get; set; }
}
public static class Asset<TAsset>
where TAsset : Node
{
private static readonly Queue<TAsset> Pool = new();
public static PackedScene Scene { get; set; }
private static TAsset Instance => Scene.Instantiate<TAsset>();
public static TAsset Get() => Pool.Count > 0 ? Pool.Dequeue() : Instance;
public static void Return(TAsset asset)
{
if (Pool.Count < 10)
Pool.Enqueue(asset);
else
asset.QueueFree();
}
}
}