fix: IHierarchyObject.SetParent not entering the object into the IGameManager hierarchy fixed
This commit is contained in:
parent
6f425776cc
commit
1ee07b41f8
@ -78,6 +78,7 @@ public class GameManager : BaseEntity, IGameManager
|
|||||||
Remove(child);
|
Remove(child);
|
||||||
|
|
||||||
_hierarchyObjects.Remove(hierarchyObject);
|
_hierarchyObjects.Remove(hierarchyObject);
|
||||||
|
hierarchyObject.SetParent(null);
|
||||||
|
|
||||||
if (!hierarchyObject.ExitHierarchy())
|
if (!hierarchyObject.ExitHierarchy())
|
||||||
throw new Exception($"{hierarchyObject.Name} can't exit the hierarchy");
|
throw new Exception($"{hierarchyObject.Name} can't exit the hierarchy");
|
||||||
|
@ -62,8 +62,9 @@ public class HierarchyObject : BaseEntity, IHierarchyObject
|
|||||||
if (!IsInHierarchy || _gameManager is not IGameManager gameManager)
|
if (!IsInHierarchy || _gameManager is not IGameManager gameManager)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_gameManager = null!;
|
|
||||||
OnExitingHierarchy(gameManager);
|
OnExitingHierarchy(gameManager);
|
||||||
|
_gameManager = null!;
|
||||||
|
SetParent(null);
|
||||||
OnExitedHierarchy?.Invoke(this, gameManager);
|
OnExitedHierarchy?.Invoke(this, gameManager);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -87,6 +88,9 @@ public class HierarchyObject : BaseEntity, IHierarchyObject
|
|||||||
|
|
||||||
if (parent is not null)
|
if (parent is not null)
|
||||||
{
|
{
|
||||||
|
if (parent.IsInHierarchy && !IsInHierarchy)
|
||||||
|
parent.GameManager.Register(this);
|
||||||
|
|
||||||
parent.AddChild(this);
|
parent.AddChild(this);
|
||||||
parent.OnActiveChanged += OnParentActiveChanged;
|
parent.OnActiveChanged += OnParentActiveChanged;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user