add: registry pass through

This commit is contained in:
h z
2025-02-19 17:09:07 +00:00
parent 2c32af6b42
commit d720b03480
6 changed files with 34 additions and 8 deletions

View File

@@ -0,0 +1,6 @@
namespace Polonium.Attributes;
[AttributeUsage(AttributeTargets.Property)]
public class RegistryPassThrough(bool getterOnly = false) : Attribute
{
public bool GetterOnly { get; set; } = getterOnly;
}

View File

@@ -1,5 +1,6 @@
using Godot;
using Polonium.Agents;
using Polonium.Attributes;
using Polonium.Interfaces;
using Polonium.Resources;
@@ -9,16 +10,22 @@ public class PoloniumRegistry
{
private static PoloniumRegistry InternalInstance { get; set; }
public static PoloniumRegistry Instance => InternalInstance ??= new PoloniumRegistry();
[RegistryPassThrough]
public Config Config { get; set; }
[RegistryPassThrough]
public Save Save { get; set; }
public static void Prepare()
{
DirAccess.MakeDirAbsolute("user://saves");
}
public Dictionary<string, Agent> Agents { get; set; } = new();
// ReSharper disable once CollectionNeverQueried.Global
[RegistryPassThrough(true)]
public Dictionary<string, Agent> Agents { get; } = new();
public HashSet<ITimeConsumer> TimeConsumers { get; set; } = new();
// ReSharper disable once CollectionNeverQueried.Global
[RegistryPassThrough(true)]
public HashSet<ITimeConsumer> TimeConsumers { get; } = new();
}