Fix TypedChildren shared across ContainerState.
This commit is contained in:
@@ -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<ContainerState>());
|
||||
target.TypedChildren[t].Add(s);
|
||||
List<ContainerState> tc;
|
||||
if (!parent.TypedChildren.TryGetValue(t, out tc))
|
||||
parent.TypedChildren.Add(t, tc = new List<ContainerState>());
|
||||
tc.Add(this);
|
||||
}
|
||||
|
||||
public ContainerState Clone(byte ct) {
|
||||
@@ -119,10 +121,11 @@ namespace Cryville.Crtr.Event {
|
||||
r.CachedValues = cvs;
|
||||
|
||||
r.Children = new Dictionary<EventContainer, ContainerState>();
|
||||
r.TypedChildren = new Dictionary<Type, List<ContainerState>>();
|
||||
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<EventContainer>();
|
||||
|
Reference in New Issue
Block a user