Skip to content

Commit

Permalink
check if entity exists
Browse files Browse the repository at this point in the history
  • Loading branch information
andreakarasho committed Mar 9, 2024
1 parent 8889959 commit 04a7e7a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/TinyEcs.Plugins/Relationship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static void BindDeletion<T>(this World world) where T : struct
if (e.Has<Parent<T>>())
{
var first = e.Get<Relationship<T>>().First;
while (first != 0)
while (first != 0 && e.World.Exists(first))
{
var next = e.World.Get<Relationship<T>>(first).Next;
e.World.Delete(first);
Expand Down
2 changes: 1 addition & 1 deletion samples/MyBattleground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
e.AddChild<Chunk>(child2);
e.AddChild<Chunk>(child3);

child2.Delete();
//child2.Delete();

foreach (var childId in e.Children<Hierarchy>())
{
Expand Down

0 comments on commit 04a7e7a

Please sign in to comment.