Gas Thermo ECS (#6442)

This commit is contained in:
metalgearsloth
2022-02-07 13:10:43 +11:00
committed by GitHub
parent 133134d9cc
commit 03a5a71243
3 changed files with 64 additions and 43 deletions

View File

@@ -26,21 +26,25 @@ public sealed partial class ConstructionSystem
RefreshParts(component);
}
public IEnumerable<MachinePartComponent> GetAllParts(MachineComponent component)
public List<MachinePartComponent> GetAllParts(MachineComponent component)
{
var parts = new List<MachinePartComponent>();
foreach (var entity in component.PartContainer.ContainedEntities)
{
if (TryComp<MachinePartComponent?>(entity, out var machinePart))
yield return machinePart;
parts.Add(machinePart);
}
return parts;
}
public void RefreshParts(MachineComponent component)
{
foreach (var refreshable in EntityManager.GetComponents<IRefreshParts>(component.Owner))
EntityManager.EventBus.RaiseLocalEvent(component.Owner, new RefreshPartsEvent()
{
refreshable.RefreshParts(GetAllParts(component));
}
Parts = GetAllParts(component),
});
}
public void CreateBoardAndStockParts(MachineComponent component)
@@ -110,3 +114,8 @@ public sealed partial class ConstructionSystem
}
}
}
public sealed class RefreshPartsEvent : EntityEventArgs
{
public IReadOnlyList<MachinePartComponent> Parts = new List<MachinePartComponent>();
}