You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.1 KiB

using Entitas;
namespace CoreGame.Render
{
[Combat]
public class LifeBindMeComponent : IComponent, IReset
{
public CombatEntity owner;
internal readonly TArray<int> children = new(4);
public void AddChild(int eid, bool forceRefresh = true)
{
if (forceRefresh)
{
for (int i = children.Count - 1; i >= 0; i--)
{
var child = children[i];
if (Contexts.Combat.GetEntity(child) == null)
children.RemoveAt(i);
}
}
children.Add(eid);
}
public bool RemoveChild(int eid)
{
for (int i = 0; i < children.Count; i++)
{
if (children[i] == eid)
{
children.RemoveAt(i);
return true;
}
}
return false;
}
public void Reset()
{
children.Clear();
}
}
}