diff --git a/Polonium.csproj b/Polonium.csproj
index 4fb5015..e79af31 100644
--- a/Polonium.csproj
+++ b/Polonium.csproj
@@ -41,7 +41,7 @@
-
+
@@ -66,7 +66,6 @@
-
diff --git a/src/Agents/Knowledge.cs b/src/Agents/Knowledge.cs
index bf20ff6..cd0aa6a 100644
--- a/src/Agents/Knowledge.cs
+++ b/src/Agents/Knowledge.cs
@@ -1,18 +1,18 @@
using Godot;
using Polonium.Interfaces;
using Polonium.MessageManager;
-using Polonium.Resources;
+using Polonium.Resources.FramePatches;
namespace Polonium.Agents;
public abstract partial class Knowledge : Node, IMessageClient
{
- public abstract void UpdateKnowledge(KnowledgePatch update);
+ public abstract void UpdateKnowledge(FramePatch update);
public string PostCode { get; set; }
public virtual void ReceiveMessage(PoloniumMessage msg)
{
- if(msg is KnowledgePatch update)
+ if(msg is FramePatch update)
UpdateKnowledge(update);
}
diff --git a/src/Agents/KnowledgeRender.cs b/src/Agents/KnowledgeRender.cs
index 1447dde..41a1976 100644
--- a/src/Agents/KnowledgeRender.cs
+++ b/src/Agents/KnowledgeRender.cs
@@ -1,17 +1,16 @@
using Godot;
using Polonium.Interfaces;
using Polonium.MessageManager;
-using Polonium.Resources;
-
+using Polonium.Resources.FramePatches;
namespace Polonium.Agents;
public abstract partial class KnowledgeRender : Node, IMessageClient
{
- public abstract void RenderKnowledgePatch(KnowledgePatch update);
+ public abstract void RenderKnowledgePatch(FramePatch update);
public string PostCode { get; set; }
public virtual void ReceiveMessage(PoloniumMessage msg)
{
- if(msg is KnowledgePatch p)
+ if(msg is FramePatch p)
RenderKnowledgePatch(p);
}
diff --git a/src/Attributes/AutoPatch.cs b/src/Attributes/AutoPatch.cs
new file mode 100644
index 0000000..e26a8ce
--- /dev/null
+++ b/src/Attributes/AutoPatch.cs
@@ -0,0 +1,6 @@
+namespace Polonium.Attributes;
+[AttributeUsage(AttributeTargets.Interface)]
+public class AutoPatch : Attribute
+{
+
+}
diff --git a/src/Attributes/PatchableProperty.cs b/src/Attributes/PatchableProperty.cs
new file mode 100644
index 0000000..5a32191
--- /dev/null
+++ b/src/Attributes/PatchableProperty.cs
@@ -0,0 +1,6 @@
+namespace Polonium.Attributes;
+[AttributeUsage(AttributeTargets.Property)]
+public class PatchableProperty : Attribute
+{
+
+}
diff --git a/src/DataStructures/PatchableItems/PatchableDictionary.cs b/src/DataStructures/PatchableItems/PatchableDictionary.cs
new file mode 100644
index 0000000..f4fb7b9
--- /dev/null
+++ b/src/DataStructures/PatchableItems/PatchableDictionary.cs
@@ -0,0 +1,31 @@
+using System.Collections;
+
+namespace Polonium.DataStructures.PatchableItems;
+
+public class PatchableDictionary : IEnumerable>
+{
+ public Dictionary Data { get; set; } = new();
+ public int Count => Data.Count;
+ public void Add(TKey key, TValue value) => Data.Add(key, value);
+ public void Remove(TKey key) => Data.Remove(key);
+ public void Clear() => Data.Clear();
+ public bool ContainsKey(TKey key) => Data.ContainsKey(key);
+ public bool TryGetValue(TKey key, out TValue value) => Data.TryGetValue(key, out value);
+ public bool ContainsValue(TValue value) => Data.ContainsValue(value);
+
+ public TValue this[TKey key]
+ {
+ get => Data[key];
+ set => Data[key] = value;
+ }
+ public IEnumerable Keys => Data.Keys;
+ public IEnumerable Values => Data.Values;
+
+ public UpdateMethods UpdateMethod { get; set; } = UpdateMethods.Update;
+ public delegate void CustomUpdatedEventHandler(Dictionary set);
+ public event CustomUpdatedEventHandler CustomUpdated;
+ public void CustomUpdate(Dictionary set) => CustomUpdated?.Invoke(set);
+ public IEnumerator> GetEnumerator() => Data.GetEnumerator();
+
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+}
diff --git a/src/DataStructures/PatchableItems/PatchableHashSet.cs b/src/DataStructures/PatchableItems/PatchableHashSet.cs
new file mode 100644
index 0000000..7aada00
--- /dev/null
+++ b/src/DataStructures/PatchableItems/PatchableHashSet.cs
@@ -0,0 +1,23 @@
+using System.Collections;
+
+namespace Polonium.DataStructures.PatchableItems;
+
+public class PatchableHashSet : IEnumerable
+{
+ public HashSet Data { get; set; } = new();
+ public void Add(T item) => Data.Add(item);
+ public void Remove(T item) => Data.Remove(item);
+ public void Clear() => Data.Clear();
+ public bool Contains(T item) => Data.Contains(item);
+ public int Count => Data.Count;
+
+
+ public UpdateMethods UpdateMethod { get; set; } = UpdateMethods.Update;
+ public delegate void CustomUpdatedEventHandler(HashSet set);
+ public event CustomUpdatedEventHandler CustomUpdated;
+ public void CustomUpdate(HashSet set) => CustomUpdated?.Invoke(set);
+
+ public IEnumerator GetEnumerator() => Data.GetEnumerator();
+
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+}
diff --git a/src/DataStructures/PatchableItems/UpdateMethods.cs b/src/DataStructures/PatchableItems/UpdateMethods.cs
new file mode 100644
index 0000000..9cc0663
--- /dev/null
+++ b/src/DataStructures/PatchableItems/UpdateMethods.cs
@@ -0,0 +1,9 @@
+namespace Polonium.DataStructures.PatchableItems;
+
+public enum UpdateMethods
+{
+ None = 0,
+ Update = 1,
+ Replace = 2,
+ Custom = 3,
+}
\ No newline at end of file
diff --git a/src/Interfaces/IKnowledge.cs b/src/Interfaces/IKnowledge.cs
new file mode 100644
index 0000000..bce734b
--- /dev/null
+++ b/src/Interfaces/IKnowledge.cs
@@ -0,0 +1,6 @@
+namespace Polonium.Interfaces;
+
+public interface IKnowledge : IPatchableFrame
+{
+
+}
\ No newline at end of file
diff --git a/src/Interfaces/IPatchableFrame.cs b/src/Interfaces/IPatchableFrame.cs
new file mode 100644
index 0000000..663a21c
--- /dev/null
+++ b/src/Interfaces/IPatchableFrame.cs
@@ -0,0 +1,5 @@
+namespace Polonium.Interfaces;
+
+public interface IPatchableFrame
+{
+}
diff --git a/src/Resources/ActionBody.cs b/src/Resources/ActionBody.cs
deleted file mode 100644
index 1bc28d9..0000000
--- a/src/Resources/ActionBody.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Godot;
-
-namespace Polonium.Resources;
-
-public abstract partial class ActionBody : Resource
-{
- public StringName ActionName { get; set; }
-
-}
diff --git a/src/Resources/FramePatches/FramePatch.cs b/src/Resources/FramePatches/FramePatch.cs
new file mode 100644
index 0000000..0ab4182
--- /dev/null
+++ b/src/Resources/FramePatches/FramePatch.cs
@@ -0,0 +1,9 @@
+using Polonium.Interfaces;
+using Polonium.MessageManager;
+
+namespace Polonium.Resources.FramePatches;
+
+public abstract partial class FramePatch : PoloniumMessage
+{
+ public abstract void Patch(IPatchableFrame receiver);
+}
\ No newline at end of file
diff --git a/src/Resources/FramePatches/FramePatchCollection.cs b/src/Resources/FramePatches/FramePatchCollection.cs
new file mode 100644
index 0000000..9313f58
--- /dev/null
+++ b/src/Resources/FramePatches/FramePatchCollection.cs
@@ -0,0 +1,13 @@
+using Polonium.Interfaces;
+
+namespace Polonium.Resources.FramePatches;
+
+public partial class FramePatchCollection : FramePatches.FramePatch
+{
+ public HashSet Updates { get; set; } = new();
+ public override void Patch(IPatchableFrame receiver)
+ {
+ foreach (FramePatches.FramePatch p in Updates)
+ p.Patch(receiver);
+ }
+}
diff --git a/src/Resources/FramePatches/Generic/DictionaryFramePatch.cs b/src/Resources/FramePatches/Generic/DictionaryFramePatch.cs
new file mode 100644
index 0000000..cd008d2
--- /dev/null
+++ b/src/Resources/FramePatches/Generic/DictionaryFramePatch.cs
@@ -0,0 +1,21 @@
+
+namespace Polonium.Resources.FramePatches.Generic;
+
+public abstract partial class DictionaryFramePatch : FramePatch
+{
+ public Dictionary Updates { get; set; } = new ();
+
+ public Dictionary Filter(HashSet filter)
+ {
+ Dictionary res = new();
+ foreach (TKey key in filter)
+ {
+ if (!Updates.ContainsKey(key))
+ continue;
+ res[key] = Updates[key];
+ }
+
+ return res;
+ }
+}
+
diff --git a/src/Resources/FramePatches/Generic/FramePatch.cs b/src/Resources/FramePatches/Generic/FramePatch.cs
new file mode 100644
index 0000000..b753294
--- /dev/null
+++ b/src/Resources/FramePatches/Generic/FramePatch.cs
@@ -0,0 +1,7 @@
+namespace Polonium.Resources.FramePatches.Generic;
+
+public abstract partial class FramePatch : FramePatch
+{
+ public TUpdate Updates { get; set; } = default(TUpdate);
+
+}
diff --git a/src/Resources/FramePatches/Generic/HashSetFramePatch.cs b/src/Resources/FramePatches/Generic/HashSetFramePatch.cs
new file mode 100644
index 0000000..3e04502
--- /dev/null
+++ b/src/Resources/FramePatches/Generic/HashSetFramePatch.cs
@@ -0,0 +1,6 @@
+namespace Polonium.Resources.FramePatches.Generic;
+
+public abstract partial class HashSetFramePatch : FramePatch
+{
+ public HashSet Updates { get; set; } = new ();
+}
\ No newline at end of file
diff --git a/src/Resources/FramePatches/IndexedFramePatchCollection.cs b/src/Resources/FramePatches/IndexedFramePatchCollection.cs
new file mode 100644
index 0000000..cd32559
--- /dev/null
+++ b/src/Resources/FramePatches/IndexedFramePatchCollection.cs
@@ -0,0 +1,14 @@
+using Polonium.Interfaces;
+
+namespace Polonium.Resources.FramePatches;
+
+public partial class IndexedFramePatchCollection : FramePatches.FramePatch
+{
+ public Dictionary Updates { get; set; } = new();
+
+ public override void Patch(IPatchableFrame receiver)
+ {
+ foreach (FramePatches.FramePatch p in Updates.Values)
+ p.Patch(receiver);
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/KnowledgePatch.cs b/src/Resources/KnowledgePatch.cs
deleted file mode 100644
index 1789799..0000000
--- a/src/Resources/KnowledgePatch.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using Polonium.MessageManager;
-
-namespace Polonium.Resources;
-
-public abstract partial class KnowledgePatch : PoloniumMessage
-{
-
-}
\ No newline at end of file