Cleaning house
This commit is contained in:
@@ -27,7 +27,7 @@ public abstract partial class Behavior : Docker
|
||||
/// <summary>
|
||||
/// Identifiers for Behaviors.
|
||||
/// </summary>
|
||||
public List<string> Tags;
|
||||
public HashSet<string> Tags;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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<Docker> Dockers => __QueryDockers();
|
||||
private ImmutableArray<Docker> __QueryDockers() {
|
||||
List<Docker> 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<Docker>(returnValue.ToArray());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Behavior Parent => __QueryParent();
|
||||
private Behavior __QueryParent() {
|
||||
if (Docker is Behavior behavior)
|
||||
return behavior;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Behavior[] Parents => __QueryParents();
|
||||
|
||||
|
||||
|
||||
|
||||
public ImmutableArray<Behavior> Parents => __QueryBehaviors();
|
||||
private ImmutableArray<Behavior> __QueryBehaviors() {
|
||||
List<Behavior> returnValue = [];
|
||||
Docker currentDocker = Docker;
|
||||
|
||||
while (!(currentDocker is Scene))
|
||||
if (currentDocker is Behavior behavior) {
|
||||
returnValue.Add(behavior);
|
||||
currentDocker = behavior.Docker;
|
||||
}
|
||||
return ImmutableArray.Create<Behavior>(returnValue.ToArray());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user