Content ecs containers (#22484)
This commit is contained in:
@@ -54,7 +54,7 @@ public sealed partial class BuildMech : IGraphAction
|
||||
return;
|
||||
}
|
||||
|
||||
container.Remove(cell);
|
||||
containerSystem.Remove(cell, container);
|
||||
|
||||
var transform = entityManager.GetComponent<TransformComponent>(uid);
|
||||
var mech = entityManager.SpawnEntity(MechPrototype, transform.Coordinates);
|
||||
@@ -62,7 +62,7 @@ public sealed partial class BuildMech : IGraphAction
|
||||
if (entityManager.TryGetComponent<MechComponent>(mech, out var mechComp) && mechComp.BatterySlot.ContainedEntity == null)
|
||||
{
|
||||
mechSys.InsertBattery(mech, cell, mechComp, batteryComponent);
|
||||
mechComp.BatterySlot.Insert(cell);
|
||||
containerSystem.Insert(cell, mechComp.BatterySlot);
|
||||
}
|
||||
|
||||
var entChangeEv = new ConstructionChangeEntityEvent(mech, uid);
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Content.Server.Construction.Completions
|
||||
|
||||
foreach (var contained in container.ContainedEntities.ToArray())
|
||||
{
|
||||
if(container.Remove(contained))
|
||||
if(containerSys.Remove(contained, container))
|
||||
entityManager.QueueDeleteEntity(contained);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace Content.Server.Construction.Completions
|
||||
|
||||
foreach (var contained in from.ContainedEntities.ToArray())
|
||||
{
|
||||
if (from.Remove(contained))
|
||||
to.Insert(contained);
|
||||
if (containerSystem.Remove(contained, from))
|
||||
containerSystem.Insert(contained, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Server.Construction.Completions
|
||||
var coordinates = entityManager.GetComponent<TransformComponent>(uid).Coordinates;
|
||||
for (var i = 0; i < Amount; i++)
|
||||
{
|
||||
container.Insert(entityManager.SpawnEntity(Prototype, coordinates));
|
||||
containerSystem.Insert(entityManager.SpawnEntity(Prototype, coordinates), container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public sealed partial class ConstructionSystem
|
||||
|
||||
var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(ent).Coordinates);
|
||||
|
||||
if (!container.Insert(board))
|
||||
if (!_container.Insert(board, container))
|
||||
Log.Warning($"Couldn't insert board {board} to computer {ent}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,8 +388,8 @@ namespace Content.Server.Construction
|
||||
for (var i = ourContainer.ContainedEntities.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var entity = ourContainer.ContainedEntities[i];
|
||||
ourContainer.ForceRemove(entity);
|
||||
otherContainer.Insert(entity);
|
||||
_container.Remove(entity, ourContainer, reparent: false, force: true);
|
||||
_container.Insert(entity, otherContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,14 +133,14 @@ namespace Content.Server.Construction
|
||||
{
|
||||
foreach (var entity in container.ContainedEntities.ToArray())
|
||||
{
|
||||
container.Remove(entity);
|
||||
_container.Remove(entity, container);
|
||||
}
|
||||
|
||||
foreach (var cont in containers.Values)
|
||||
{
|
||||
foreach (var entity in cont.ContainedEntities.ToArray())
|
||||
{
|
||||
cont.Remove(entity);
|
||||
_container.Remove(entity, cont);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,10 +150,10 @@ namespace Content.Server.Construction
|
||||
|
||||
void ShutdownContainers()
|
||||
{
|
||||
container.Shutdown();
|
||||
_container.ShutdownContainer(container);
|
||||
foreach (var c in containers.Values.ToArray())
|
||||
{
|
||||
c.Shutdown();
|
||||
_container.ShutdownContainer(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,10 +188,10 @@ namespace Content.Server.Construction
|
||||
|
||||
if (string.IsNullOrEmpty(materialStep.Store))
|
||||
{
|
||||
if (!container.Insert(splitStack.Value))
|
||||
if (!_container.Insert(splitStack.Value, container))
|
||||
continue;
|
||||
}
|
||||
else if (!GetContainer(materialStep.Store).Insert(splitStack.Value))
|
||||
else if (!_container.Insert(splitStack.Value, GetContainer(materialStep.Store)))
|
||||
continue;
|
||||
|
||||
handled = true;
|
||||
@@ -217,10 +217,10 @@ namespace Content.Server.Construction
|
||||
|
||||
if (string.IsNullOrEmpty(arbitraryStep.Store))
|
||||
{
|
||||
if (!container.Insert(entity))
|
||||
if (!_container.Insert(entity, container))
|
||||
continue;
|
||||
}
|
||||
else if (!GetContainer(arbitraryStep.Store).Insert(entity))
|
||||
else if (!_container.Insert(entity, GetContainer(arbitraryStep.Store)))
|
||||
continue;
|
||||
|
||||
handled = true;
|
||||
@@ -284,8 +284,8 @@ namespace Content.Server.Construction
|
||||
|
||||
foreach (var entity in cont.ContainedEntities.ToArray())
|
||||
{
|
||||
cont.ForceRemove(entity);
|
||||
newCont.Insert(entity);
|
||||
_container.Remove(entity, cont, reparent: false, force: true);
|
||||
_container.Insert(entity, newCont);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace Content.Server.Construction
|
||||
construction.Containers.Add(store);
|
||||
|
||||
// The container doesn't necessarily need to exist, so we ensure it.
|
||||
_container.EnsureContainer<Container>(uid, store).Insert(insert);
|
||||
_container.Insert(insert, _container.EnsureContainer<Container>(uid, store));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -125,7 +125,7 @@ public sealed partial class ConstructionSystem
|
||||
|
||||
var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(uid).Coordinates);
|
||||
|
||||
if (!component.BoardContainer.Insert(board))
|
||||
if (!_container.Insert(board, component.BoardContainer))
|
||||
{
|
||||
throw new Exception($"Couldn't insert board with prototype {component.BoardPrototype} to machine with prototype {MetaData(uid).EntityPrototype?.ID ?? "N/A"}!");
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public sealed partial class ConstructionSystem
|
||||
{
|
||||
var p = EntityManager.SpawnEntity(partProto.StockPartPrototype, xform.Coordinates);
|
||||
|
||||
if (!partContainer.Insert(p))
|
||||
if (!_container.Insert(p, partContainer))
|
||||
throw new Exception($"Couldn't insert machine part of type {part} to machine with prototype {partProto.StockPartPrototype ?? "N/A"}!");
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public sealed partial class ConstructionSystem
|
||||
{
|
||||
var stack = _stackSystem.Spawn(amount, stackType, Transform(uid).Coordinates);
|
||||
|
||||
if (!partContainer.Insert(stack))
|
||||
if (!_container.Insert(stack, partContainer))
|
||||
throw new Exception($"Couldn't insert machine material of type {stackType} to machine with prototype {MetaData(uid).EntityPrototype?.ID ?? "N/A"}");
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public sealed partial class ConstructionSystem
|
||||
{
|
||||
var c = EntityManager.SpawnEntity(info.DefaultPrototype, Transform(uid).Coordinates);
|
||||
|
||||
if(!partContainer.Insert(c))
|
||||
if(!_container.Insert(c, partContainer))
|
||||
throw new Exception($"Couldn't insert machine component part with default prototype '{compName}' to machine with prototype {MetaData(uid).EntityPrototype?.ID ?? "N/A"}");
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public sealed partial class ConstructionSystem
|
||||
{
|
||||
var c = EntityManager.SpawnEntity(info.DefaultPrototype, Transform(uid).Coordinates);
|
||||
|
||||
if(!partContainer.Insert(c))
|
||||
if(!_container.Insert(c, partContainer))
|
||||
throw new Exception($"Couldn't insert machine component part with default prototype '{tagName}' to machine with prototype {MetaData(uid).EntityPrototype?.ID ?? "N/A"}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
if (!component.PartContainer.Insert(args.Used))
|
||||
if (!_container.Insert(args.Used, component.PartContainer))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
if (!component.PartContainer.Insert(args.Used))
|
||||
if (!_container.Insert(args.Used, component.PartContainer))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
if (!_container.TryRemoveFromContainer(used))
|
||||
return false;
|
||||
|
||||
if (!component.BoardContainer.Insert(used))
|
||||
if (!_container.Insert(used, component.BoardContainer))
|
||||
return true;
|
||||
|
||||
ResetProgressAndRequirements(component, machineBoard);
|
||||
@@ -181,7 +181,7 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
if (!_container.TryRemoveFromContainer(used))
|
||||
return false;
|
||||
|
||||
if (!component.PartContainer.Insert(used))
|
||||
if (!_container.Insert(used, component.PartContainer))
|
||||
return true;
|
||||
|
||||
component.Progress[machinePart.PartType]++;
|
||||
@@ -212,7 +212,7 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
if (!_container.TryRemoveFromContainer(used))
|
||||
return false;
|
||||
|
||||
if (!component.PartContainer.Insert(used))
|
||||
if (!_container.Insert(used, component.PartContainer))
|
||||
return true;
|
||||
|
||||
component.MaterialProgress[type] += count;
|
||||
@@ -224,7 +224,7 @@ public sealed class MachineFrameSystem : EntitySystem
|
||||
if (splitStack == null)
|
||||
return false;
|
||||
|
||||
if (!component.PartContainer.Insert(splitStack.Value))
|
||||
if (!_container.Insert(splitStack.Value, component.PartContainer))
|
||||
return true;
|
||||
|
||||
component.MaterialProgress[type] += needed;
|
||||
|
||||
@@ -91,7 +91,7 @@ public sealed class PartExchangerSystem : EntitySystem
|
||||
}
|
||||
foreach (var part in updatedParts)
|
||||
{
|
||||
machine.PartContainer.Insert(part.part, EntityManager);
|
||||
_container.Insert(part.part, machine.PartContainer);
|
||||
machineParts.Remove(part);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public sealed class PartExchangerSystem : EntitySystem
|
||||
if (!machine.Requirements.ContainsKey(part.PartType))
|
||||
continue;
|
||||
|
||||
machine.PartContainer.Insert(partEnt, EntityManager);
|
||||
_container.Insert(partEnt, machine.PartContainer);
|
||||
machine.Progress[part.PartType]++;
|
||||
machineParts.Remove(pair);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user