Made trash object delete its entity when collected
This commit is contained in:
@@ -154,4 +154,12 @@ public partial class EntityManager : Node
|
||||
|
||||
#endregion
|
||||
|
||||
public void RemoveEntity(Entity entity)
|
||||
{
|
||||
_allEntities.Remove(entity);
|
||||
if (entity is PositionalEntity positionalEntity)
|
||||
{
|
||||
positionalEntity.RemoveEntityNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using PositionalEntity = Babushka.scripts.CSharp.GameEntity.Entities.PositionalEntity;
|
||||
using Godot;
|
||||
using PositionalEntity = Babushka.scripts.CSharp.GameEntity.Entities.PositionalEntity;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Management;
|
||||
|
||||
@@ -11,4 +12,11 @@ public static class EntityManagerUtil
|
||||
|
||||
self.AddEntity(entity);
|
||||
}
|
||||
|
||||
public static bool IsValid<T>(this T? node) where T : GodotObject
|
||||
{
|
||||
return node != null
|
||||
&& GodotObject.IsInstanceValid(node)
|
||||
&& !node.IsQueuedForDeletion();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user