Gas Thermo ECS (#6442)
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user