diff --git a/Awperative/Kernel/Behavior/Core.cs b/Awperative/Kernel/Behavior/Core.cs
index 4a1e67e..01629ca 100644
--- a/Awperative/Kernel/Behavior/Core.cs
+++ b/Awperative/Kernel/Behavior/Core.cs
@@ -27,7 +27,7 @@ public abstract partial class Behavior : Docker
///
/// Identifiers for Behaviors.
///
- public List Tags;
+ public HashSet Tags;
diff --git a/Awperative/Kernel/Behavior/Utility.cs b/Awperative/Kernel/Behavior/Utility.cs
index be1b0f8..952a711 100644
--- a/Awperative/Kernel/Behavior/Utility.cs
+++ b/Awperative/Kernel/Behavior/Utility.cs
@@ -1,9 +1,13 @@
using System.Collections.Generic;
+using System.Collections.Immutable;
namespace Awperative;
public abstract partial class Behavior : Docker
{
+
+
+
public Scene Scene => __QueryScene();
private Scene __QueryScene() {
if (Docker is Scene scene) return scene;
@@ -11,29 +15,54 @@ public abstract partial class Behavior : Docker
return null;
}
+
+
+
+
- public Docker[] Dockers => __QueryDockers();
-
- private Docker[] __QueryDockers()
- {
+ public ImmutableArray Dockers => __QueryDockers();
+ private ImmutableArray __QueryDockers() {
List returnValue = [];
-
Docker currentDocker = Docker;
while (!(currentDocker is Scene))
- {
- if (currentDocker is Behavior behavior)
- {
- returnValue.Add(behavior);
+ if (currentDocker is Behavior behavior) {
+ returnValue.Add(currentDocker);
currentDocker = behavior.Docker;
}
- }
-
returnValue.Add(currentDocker);
- return returnValue.ToArray();
+ return ImmutableArray.Create(returnValue.ToArray());
+ }
+
+
+
+
+
+ public Behavior Parent => __QueryParent();
+ private Behavior __QueryParent() {
+ if (Docker is Behavior behavior)
+ return behavior;
+ return null;
}
- public Behavior[] Parents => __QueryParents();
+
+
+
+
+ public ImmutableArray Parents => __QueryBehaviors();
+ private ImmutableArray __QueryBehaviors() {
+ List returnValue = [];
+ Docker currentDocker = Docker;
+
+ while (!(currentDocker is Scene))
+ if (currentDocker is Behavior behavior) {
+ returnValue.Add(behavior);
+ currentDocker = behavior.Docker;
+ }
+ return ImmutableArray.Create(returnValue.ToArray());
+ }
+
+
}
\ No newline at end of file
diff --git a/Awperative/Kernel/Docker/Behaviors.cs b/Awperative/Kernel/Docker/Behaviors.cs
index d395788..2cc95cf 100644
--- a/Awperative/Kernel/Docker/Behaviors.cs
+++ b/Awperative/Kernel/Docker/Behaviors.cs
@@ -9,6 +9,7 @@ public abstract partial class Docker
internal HashSet _behaviors = [];
+ internal void Add(Behavior behavior) => _behaviors.Add(behavior);
public Behavior Add() where Generic : Behavior => Add([]);
public Behavior Add(object[] __args) where Generic : Behavior {
if(typeof(Generic).GetConstructor((Type[]) __args) == null) { Debug.LogError("Component does not contain a valid constructor"); return null; };
@@ -24,8 +25,16 @@ public abstract partial class Docker
}catch { Debug.LogError("Failed to create component"); return null; }
}
-
-
+
+
+ public void Transfer(Behavior __behavior, Docker __docker) {
+ if (!_behaviors.Contains(__behavior)) { Debug.LogError("Docker does not have ownership of Behavior"); return; }
+
+ __docker.Add(__behavior);
+ _behaviors.Remove(__behavior);
+
+ __behavior.Docker = __docker;
+ }