Inline UID

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 15:53:09 +01:00
parent 2654775bf0
commit 5cd42c9ad6
803 changed files with 3613 additions and 3577 deletions

View File

@@ -32,14 +32,14 @@ namespace Content.Server.Construction.Components
{
foreach (var entity in _partContainer.ContainedEntities)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MachinePartComponent?>(entity.Uid, out var machinePart))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MachinePartComponent?>(entity, out var machinePart))
yield return machinePart;
}
}
public void RefreshParts()
{
foreach (var refreshable in IoCManager.Resolve<IEntityManager>().GetComponents<IRefreshParts>(Owner.Uid))
foreach (var refreshable in IoCManager.Resolve<IEntityManager>().GetComponents<IRefreshParts>(Owner))
{
refreshable.RefreshParts(GetAllParts());
}
@@ -63,14 +63,14 @@ namespace Content.Server.Construction.Components
return;
}
var board = entityManager.SpawnEntity(BoardPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
var board = entityManager.SpawnEntity(BoardPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
if (!_boardContainer.Insert(board))
{
throw new Exception($"Couldn't insert board with prototype {BoardPrototype} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}!");
throw new Exception($"Couldn't insert board with prototype {BoardPrototype} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityPrototype?.ID ?? "N/A"}!");
}
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<MachineBoardComponent?>(board.Uid, out var machineBoard))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<MachineBoardComponent?>(board, out var machineBoard))
{
throw new Exception($"Entity with prototype {BoardPrototype} doesn't have a {nameof(MachineBoardComponent)}!");
}
@@ -79,29 +79,29 @@ namespace Content.Server.Construction.Components
{
for (var i = 0; i < amount; i++)
{
var p = entityManager.SpawnEntity(MachinePartComponent.Prototypes[part], IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
var p = entityManager.SpawnEntity(MachinePartComponent.Prototypes[part], IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
if (!partContainer.Insert(p))
throw new Exception($"Couldn't insert machine part of type {part} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}!");
throw new Exception($"Couldn't insert machine part of type {part} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityPrototype?.ID ?? "N/A"}!");
}
}
foreach (var (stackType, amount) in machineBoard.MaterialRequirements)
{
var stack = EntitySystem.Get<StackSystem>().Spawn(amount, stackType, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
var stack = EntitySystem.Get<StackSystem>().Spawn(amount, stackType, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
if (!partContainer.Insert(IoCManager.Resolve<IEntityManager>().GetEntity(stack)))
throw new Exception($"Couldn't insert machine material of type {stackType} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}");
throw new Exception($"Couldn't insert machine material of type {stackType} to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityPrototype?.ID ?? "N/A"}");
}
foreach (var (compName, info) in machineBoard.ComponentRequirements)
{
for (var i = 0; i < info.Amount; i++)
{
var c = entityManager.SpawnEntity(info.DefaultPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
var c = entityManager.SpawnEntity(info.DefaultPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
if(!partContainer.Insert(c))
throw new Exception($"Couldn't insert machine component part with default prototype '{compName}' to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}");
throw new Exception($"Couldn't insert machine component part with default prototype '{compName}' to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityPrototype?.ID ?? "N/A"}");
}
}
@@ -109,10 +109,10 @@ namespace Content.Server.Construction.Components
{
for (var i = 0; i < info.Amount; i++)
{
var c = entityManager.SpawnEntity(info.DefaultPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
var c = entityManager.SpawnEntity(info.DefaultPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
if(!partContainer.Insert(c))
throw new Exception($"Couldn't insert machine component part with default prototype '{tagName}' to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityPrototype?.ID ?? "N/A"}");
throw new Exception($"Couldn't insert machine component part with default prototype '{tagName}' to machine with prototype {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityPrototype?.ID ?? "N/A"}");
}
}
}

View File

@@ -122,7 +122,7 @@ namespace Content.Server.Construction.Components
RegenerateProgress();
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ConstructionComponent?>(Owner.Uid, out var construction))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ConstructionComponent?>(Owner, out var construction))
{
// Attempt to set pathfinding to the machine node...
EntitySystem.Get<ConstructionSystem>().SetPathfindingTarget(OwnerUid, "machine", construction);
@@ -168,7 +168,7 @@ namespace Content.Server.Construction.Components
if (!HasBoard)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out appearance))
{
appearance.SetData(MachineFrameVisuals.State, 1);
}
@@ -187,10 +187,10 @@ namespace Content.Server.Construction.Components
var board = _boardContainer.ContainedEntities[0];
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<MachineBoardComponent?>(board.Uid, out var machineBoard))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<MachineBoardComponent?>(board, out var machineBoard))
return;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out appearance))
{
appearance.SetData(MachineFrameVisuals.State, 2);
}
@@ -199,7 +199,7 @@ namespace Content.Server.Construction.Components
foreach (var part in _partContainer.ContainedEntities)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MachinePartComponent?>(part.Uid, out var machinePart))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MachinePartComponent?>(part, out var machinePart))
{
// Check this is part of the requirements...
if (!Requirements.ContainsKey(machinePart.PartType))
@@ -211,7 +211,7 @@ namespace Content.Server.Construction.Components
_progress[machinePart.PartType]++;
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(part.Uid, out var stack))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(part, out var stack))
{
var type = stack.StackTypeId;
// Check this is part of the requirements...
@@ -229,7 +229,7 @@ namespace Content.Server.Construction.Components
{
var registration = _componentFactory.GetRegistration(compName);
if (!IoCManager.Resolve<IEntityManager>().HasComponent(part.Uid, registration.Type))
if (!IoCManager.Resolve<IEntityManager>().HasComponent(part, registration.Type))
continue;
if (!_componentProgress.ContainsKey(compName))
@@ -254,7 +254,7 @@ namespace Content.Server.Construction.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{
if (!HasBoard && IoCManager.Resolve<IEntityManager>().TryGetComponent<MachineBoardComponent?>(eventArgs.Using.Uid, out var machineBoard))
if (!HasBoard && IoCManager.Resolve<IEntityManager>().TryGetComponent<MachineBoardComponent?>(eventArgs.Using, out var machineBoard))
{
if (eventArgs.Using.TryRemoveFromContainer())
{
@@ -264,12 +264,12 @@ namespace Content.Server.Construction.Components
// Setup requirements and progress...
ResetProgressAndRequirements(machineBoard);
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(Owner.Uid, out var appearance))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<AppearanceComponent?>(Owner, out var appearance))
{
appearance.SetData(MachineFrameVisuals.State, 2);
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ConstructionComponent? construction))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ConstructionComponent? construction))
{
// So prying the components off works correctly.
EntitySystem.Get<ConstructionSystem>().ResetEdge(OwnerUid, construction);
@@ -280,7 +280,7 @@ namespace Content.Server.Construction.Components
}
else if (HasBoard)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MachinePartComponent?>(eventArgs.Using.Uid, out var machinePart))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MachinePartComponent?>(eventArgs.Using, out var machinePart))
{
if (!Requirements.ContainsKey(machinePart.PartType))
return false;
@@ -293,7 +293,7 @@ namespace Content.Server.Construction.Components
}
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(eventArgs.Using.Uid, out var stack))
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(eventArgs.Using, out var stack))
{
var type = stack.StackTypeId;
if (!MaterialRequirements.ContainsKey(type))
@@ -314,7 +314,7 @@ namespace Content.Server.Construction.Components
return true;
}
var splitStack = EntitySystem.Get<StackSystem>().Split(eventArgs.Using.Uid, needed, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, stack);
var splitStack = EntitySystem.Get<StackSystem>().Split(eventArgs.Using, needed, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, stack);
if (splitStack == null)
return false;
@@ -333,7 +333,7 @@ namespace Content.Server.Construction.Components
var registration = _componentFactory.GetRegistration(compName);
if (!IoCManager.Resolve<IEntityManager>().HasComponent(eventArgs.Using.Uid, registration.Type))
if (!IoCManager.Resolve<IEntityManager>().HasComponent(eventArgs.Using, registration.Type))
continue;
if (!eventArgs.Using.TryRemoveFromContainer() || !_partContainer.Insert(eventArgs.Using)) continue;

View File

@@ -41,7 +41,7 @@ namespace Content.Server.Construction.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{
// check if object is welder
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Using.Uid, out ToolComponent? tool))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(eventArgs.Using, out ToolComponent? tool))
return false;
// check if someone is already welding object
@@ -52,7 +52,7 @@ namespace Content.Server.Construction.Components
var toolSystem = EntitySystem.Get<ToolSystem>();
if (!await toolSystem.UseTool(eventArgs.Using.Uid, eventArgs.User.Uid, Owner.Uid, _refineFuel, _refineTime, _qualityNeeded))
if (!await toolSystem.UseTool(eventArgs.Using, eventArgs.User, Owner, _refineFuel, _refineTime, _qualityNeeded))
{
// failed to veld - abort refine
_beingWelded = false;
@@ -60,8 +60,8 @@ namespace Content.Server.Construction.Components
}
// get last owner coordinates and delete it
var resultPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates;
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
var resultPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) Owner);
// spawn each result after refine
foreach (var result in _refineResult!)
@@ -70,8 +70,8 @@ namespace Content.Server.Construction.Components
// TODO: If something has a stack... Just use a prototype with a single thing in the stack.
// This is not a good way to do it.
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(droppedEnt.Uid, out var stack))
EntitySystem.Get<StackSystem>().SetCount(droppedEnt.Uid,1, stack);
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<StackComponent?>(droppedEnt, out var stack))
EntitySystem.Get<StackSystem>().SetCount(droppedEnt,1, stack);
}
return true;