From 901585d4bb9f945c5c804d414bcfefe775b5faf7 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Sun, 6 Apr 2025 10:57:22 +0300 Subject: [PATCH] fix: HierarchyObject not throwing any error when trying to set itself as parent --- Engine.Core/HierarchyObject.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Engine.Core/HierarchyObject.cs b/Engine.Core/HierarchyObject.cs index 93dab51..f6f9380 100644 --- a/Engine.Core/HierarchyObject.cs +++ b/Engine.Core/HierarchyObject.cs @@ -70,7 +70,10 @@ public class HierarchyObject : BaseEntity, IHierarchyObject public void SetParent(IHierarchyObject? parent) { - if (parent == this || Parent == parent) + if (parent == this) + throw new Exceptions.AssignException($"{Name} can not parent itself"); + + if (Parent == parent) return; IHierarchyObject? previousParent = Parent;