Skip to content

Commit 9c46d2a

Browse files
committed
+ fix parent
1 parent 815ca7c commit 9c46d2a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/EntityMapper.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public void Add(EcsID parentId, EcsID childId)
5050
_parentsToChildren.Add(parentId, children);
5151

5252
_world.Set(parentId, new TChildrenComponent() { Value = children });
53-
_world.Add<TParentComponent>(parentId);
5453
}
5554

55+
_world.Add<TParentComponent>(childId);
5656
children.Add(childId);
5757
}
5858

@@ -71,6 +71,7 @@ private bool RemoveChild(EcsID childId)
7171
// update children list on parent
7272
if (_parentsToChildren.TryGetValue(parentId, out var children))
7373
{
74+
_world.Unset<TParentComponent>(childId);
7475
children.Remove(childId);
7576
if (children.Count == 0)
7677
RemoveParent(parentId);
@@ -94,6 +95,7 @@ private bool RemoveParent(EcsID parentId)
9495

9596
// if child is a parent, remove associated children too
9697
RemoveParent(id);
98+
_world.Unset<TParentComponent>(id);
9799
}
98100

99101
children.Clear();
@@ -129,7 +131,7 @@ internal RelationshipEntityMapper(World world) : base(world, CleanupPolicy.Delet
129131

130132
public sealed class NamingEntityMapper
131133
{
132-
private readonly Dictionary<string, EcsID> _names = new ();
134+
private readonly Dictionary<string, EcsID> _names = new();
133135
private readonly Dictionary<EcsID, string> _entitiesWithName = new();
134136
private readonly World _world;
135137

@@ -231,7 +233,7 @@ public struct Children : IChildrenComponent
231233

232234
private HashSet<EcsID> _value;
233235

234-
HashSet<ulong> IChildrenComponent.Value
236+
HashSet<ulong> IChildrenComponent.Value
235237
{
236238
readonly get => _value;
237239
set => _value = value;

0 commit comments

Comments
 (0)