add: registry pass through
This commit is contained in:
6
src/Attributes/RegistryPassThrough.cs
Normal file
6
src/Attributes/RegistryPassThrough.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Polonium.Attributes;
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class RegistryPassThrough(bool getterOnly = false) : Attribute
|
||||
{
|
||||
public bool GetterOnly { get; set; } = getterOnly;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user