diff --git a/Assets/Cryville/Crtr/Event/ContainerState.cs b/Assets/Cryville/Crtr/Event/ContainerState.cs index 8ebbb57..69e3c18 100644 --- a/Assets/Cryville/Crtr/Event/ContainerState.cs +++ b/Assets/Cryville/Crtr/Event/ContainerState.cs @@ -87,7 +87,7 @@ namespace Cryville.Crtr.Event { Container = _ev; if (parent != null) { - AddChild(_ev, this, parent); + AddChild(_ev, parent); Parent = parent; } @@ -99,11 +99,13 @@ namespace Cryville.Crtr.Event { rootPrototype = this; } - static void AddChild(EventContainer c, ContainerState s, ContainerState target) { - target.Children.Add(c, s); + void AddChild(EventContainer c, ContainerState parent) { + parent.Children.Add(c, this); Type t = c.GetType(); - if (!target.TypedChildren.ContainsKey(t)) target.TypedChildren.Add(t, new List()); - target.TypedChildren[t].Add(s); + List tc; + if (!parent.TypedChildren.TryGetValue(t, out tc)) + parent.TypedChildren.Add(t, tc = new List()); + tc.Add(this); } public ContainerState Clone(byte ct) { @@ -119,10 +121,11 @@ namespace Cryville.Crtr.Event { r.CachedValues = cvs; r.Children = new Dictionary(); + r.TypedChildren = new Dictionary>(); foreach (var child in Children) { var cc = child.Value.Clone(ct); cc.Parent = r; - AddChild(child.Key, cc, r); + cc.AddChild(child.Key, r); } r.ActiveChildren = new HashSet();