Fix 3000 errors

This commit is contained in:
DrSmugleaf
2021-12-05 18:09:01 +01:00
parent 2bfec7ec62
commit 2a3b7d809d
569 changed files with 2979 additions and 3280 deletions

View File

@@ -30,10 +30,10 @@ namespace Content.Server.Construction
return;
// If the used entity doesn't have a tool, return early.
if (!EntityManager.TryGetComponent(args.UsedUid, out ToolComponent? usedTool))
if (!EntityManager.TryGetComponent(args.Used, out ToolComponent? usedTool))
return;
args.Handled = await TryToggleAnchor(uid, args.UserUid, args.UsedUid, anchorable, usingTool:usedTool);
args.Handled = await TryToggleAnchor(uid, args.User, args.Used, anchorable, usingTool:usedTool);
}
/// <summary>

View File

@@ -1,5 +1,4 @@
using Content.Server.Administration;
using Content.Server.Window;
using Content.Server.Power.Components;
using Content.Shared.Administration;
using Content.Shared.Construction;
@@ -24,19 +23,19 @@ namespace Content.Server.Construction.Commands
public void Execute(IConsoleShell shell, string argsOther, string[] args)
{
var player = shell.Player as IPlayerSession;
var entityManager = IoCManager.Resolve<IEntityManager>();
GridId gridId;
switch (args.Length)
{
case 0:
if (player?.AttachedEntity == null)
if (player?.AttachedEntity is not {Valid: true} playerEntity)
{
shell.WriteLine("Only a player can run this command.");
return;
}
gridId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity).GridID;
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridID;
break;
case 1:
if (!int.TryParse(args[0], out var id))
@@ -59,17 +58,16 @@ namespace Content.Server.Construction.Commands
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
if (!entityManager.EntityExists(grid.GridEntityId))
{
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
return;
}
var changed = 0;
foreach (var childUid in IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(gridEntity).ChildEntityUids)
foreach (var child in entityManager.GetComponent<TransformComponent>(grid.GridEntityId).ChildEntities)
{
if (!entityManager.TryGetEntity(childUid, out var childEntity))
if (!entityManager.EntityExists(child))
{
continue;
}
@@ -78,27 +76,27 @@ namespace Content.Server.Construction.Commands
// Occluders should only count if the state of it right now is enabled.
// This prevents issues with edge firelocks.
if (entityManager.TryGetComponent<OccluderComponent>(childUid, out var occluder))
if (entityManager.TryGetComponent<OccluderComponent>(child, out var occluder))
{
valid |= occluder.Enabled;
}
// low walls & grilles
valid |= IoCManager.Resolve<IEntityManager>().HasComponent<SharedCanBuildWindowOnTopComponent>(childEntity);
valid |= entityManager.HasComponent<SharedCanBuildWindowOnTopComponent>(child);
// cables
valid |= IoCManager.Resolve<IEntityManager>().HasComponent<CableComponent>(childEntity);
valid |= entityManager.HasComponent<CableComponent>(child);
// anything else that might need this forced
valid |= childEntity.HasTag("ForceFixRotations");
valid |= child.HasTag("ForceFixRotations");
// override
valid &= !childEntity.HasTag("ForceNoFixRotations");
valid &= !child.HasTag("ForceNoFixRotations");
if (!valid)
{
continue;
}
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(childEntity).LocalRotation != Angle.Zero)
if (entityManager.GetComponent<TransformComponent>(child).LocalRotation != Angle.Zero)
{
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(childEntity).LocalRotation = Angle.Zero;
entityManager.GetComponent<TransformComponent>(child).LocalRotation = Angle.Zero;
changed++;
}
}

View File

@@ -21,18 +21,19 @@ namespace Content.Server.Construction.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var entityManager = IoCManager.Resolve<IEntityManager>();
GridId gridId;
switch (args.Length)
{
case 0:
if (player?.AttachedEntity == null)
if (player?.AttachedEntity is not {Valid: true} playerEntity)
{
shell.WriteLine("Only a player can run this command.");
return;
}
gridId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity).GridID;
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridID;
break;
case 1:
if (!int.TryParse(args[0], out var id))
@@ -55,8 +56,7 @@ namespace Content.Server.Construction.Commands
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
if (!entityManager.EntityExists(grid.GridEntityId))
{
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
return;
@@ -65,16 +65,16 @@ namespace Content.Server.Construction.Commands
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var underplating = tileDefinitionManager["underplating"];
var underplatingTile = new Robust.Shared.Map.Tile(underplating.TileId);
var underplatingTile = new Tile(underplating.TileId);
var changed = 0;
foreach (var childUid in IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(gridEntity).ChildEntityUids)
foreach (var child in entityManager.GetComponent<TransformComponent>(grid.GridEntityId).ChildEntities)
{
if (!entityManager.TryGetEntity(childUid, out var childEntity))
if (!entityManager.EntityExists(child))
{
continue;
}
var prototype = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(childEntity).EntityPrototype;
var prototype = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(child).EntityPrototype;
while (true)
{
if (prototype?.Parent == null)
@@ -90,12 +90,12 @@ namespace Content.Server.Construction.Commands
continue;
}
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(childEntity).Anchored)
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(child).Anchored)
{
continue;
}
var tile = grid.GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(childEntity).Coordinates);
var tile = grid.GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(child).Coordinates);
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
if (tileDef.Name == "underplating")
@@ -103,7 +103,7 @@ namespace Content.Server.Construction.Commands
continue;
}
grid.SetTile(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(childEntity).Coordinates, underplatingTile);
grid.SetTile(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(child).Coordinates, underplatingTile);
changed++;
}

View File

@@ -1,5 +1,4 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Construction.Components;
using Content.Shared.Construction;
using JetBrains.Annotations;
@@ -59,7 +58,7 @@ namespace Content.Server.Construction.Completions
foreach (var ent in computerContainer.ContainedEntities.ToArray())
{
computerContainer.ForceRemove(ent);
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) ent);
IoCManager.Resolve<IEntityManager>().DeleteEntity(ent);
}
computerContainer.Insert(board);

View File

@@ -1,5 +1,4 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Shared.Construction;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
@@ -23,7 +22,7 @@ namespace Content.Server.Construction.Completions
foreach (var contained in container.ContainedEntities.ToArray())
{
if(container.Remove(contained))
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity((EntityUid) contained);
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(contained);
}
}
}

View File

@@ -4,7 +4,6 @@ using Content.Server.Stack;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Components
@@ -90,7 +89,7 @@ namespace Content.Server.Construction.Components
{
var stack = EntitySystem.Get<StackSystem>().Spawn(amount, stackType, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
if (!partContainer.Insert(IoCManager.Resolve<IEntityManager>().GetEntity(stack)))
if (!partContainer.Insert(stack))
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"}");
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using Content.Server.Stack;
using Content.Shared.Construction;
@@ -319,7 +318,7 @@ namespace Content.Server.Construction.Components
if (splitStack == null)
return false;
if(!_partContainer.Insert(IoCManager.Resolve<IEntityManager>().GetEntity(splitStack.Value)))
if(!_partContainer.Insert(splitStack.Value))
return false;
_materialProgress[type] += needed;

View File

@@ -4,14 +4,11 @@ using Content.Server.Stack;
using Content.Server.Tools;
using Content.Server.Tools.Components;
using Content.Shared.Interaction;
using Content.Shared.Stacks;
using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.ViewVariables;
namespace Content.Server.Construction.Components
{
@@ -61,7 +58,7 @@ namespace Content.Server.Construction.Components
// get last owner coordinates and delete it
var resultPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) Owner);
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner);
// spawn each result after refine
foreach (var result in _refineResult!)

View File

@@ -1,9 +1,7 @@
using System.Collections.Generic;
using Content.Server.Construction.Components;
using Content.Shared.Construction;
using Content.Shared.Construction.Prototypes;
using Content.Shared.Construction.Steps;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Robust.Server.Containers;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
@@ -166,8 +164,7 @@ namespace Content.Server.Construction
Resolve(uid, ref containerManager, false);
// We create the new entity.
IEntity tempQualifier = EntityManager.SpawnEntity(newEntity, transform.Coordinates);
var newUid = (EntityUid) tempQualifier;
var newUid = EntityManager.SpawnEntity(newEntity, transform.Coordinates);
// Construction transferring.
var newConstruction = EntityManager.EnsureComponent<ConstructionComponent>(newUid);

View File

@@ -43,13 +43,13 @@ namespace Content.Server.Construction
}
// LEGACY CODE. See warning at the top of the file!
private IEnumerable<IEntity> EnumerateNearby(IEntity user)
private IEnumerable<EntityUid> EnumerateNearby(EntityUid user)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands))
if (EntityManager.TryGetComponent(user, out HandsComponent? hands))
{
foreach (var itemComponent in hands?.GetAllHeldItems()!)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(itemComponent.Owner, out ServerStorageComponent? storage))
if (EntityManager.TryGetComponent(itemComponent.Owner, out ServerStorageComponent? storage))
{
foreach (var storedEntity in storage.StoredEntities!)
{
@@ -61,11 +61,11 @@ namespace Content.Server.Construction
}
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user!, out InventoryComponent? inventory))
if (EntityManager.TryGetComponent(user!, out InventoryComponent? inventory))
{
foreach (var held in inventory.GetAllHeldItems())
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(held, out ServerStorageComponent? storage))
if (EntityManager.TryGetComponent(held, out ServerStorageComponent? storage))
{
foreach (var storedEntity in storage.StoredEntities!)
{
@@ -84,7 +84,7 @@ namespace Content.Server.Construction
}
// LEGACY CODE. See warning at the top of the file!
private async Task<IEntity?> Construct(IEntity user, string materialContainer, ConstructionGraphPrototype graph, ConstructionGraphEdge edge, ConstructionGraphNode targetNode)
private async Task<EntityUid?> Construct(EntityUid user, string materialContainer, ConstructionGraphPrototype graph, ConstructionGraphEdge edge, ConstructionGraphNode targetNode)
{
// We need a place to hold our construction items!
var container = ContainerHelpers.EnsureContainer<Container>(user, materialContainer, out var existed);
@@ -164,17 +164,17 @@ namespace Content.Server.Construction
if (!materialStep.EntityValid(entity, out var stack))
continue;
var splitStack = _stackSystem.Split(entity, materialStep.Amount, user.ToCoordinates(), stack);
var splitStack = _stackSystem.Split(entity, materialStep.Amount, user.ToCoordinates(0, 0), stack);
if (splitStack == null)
continue;
if (string.IsNullOrEmpty(materialStep.Store))
{
if (!container.Insert(EntityManager.GetEntity(splitStack.Value)))
if (!container.Insert(splitStack.Value))
continue;
}
else if (!GetContainer(materialStep.Store).Insert(EntityManager.GetEntity(splitStack.Value)))
else if (!GetContainer(materialStep.Store).Insert(splitStack.Value))
continue;
handled = true;
@@ -235,10 +235,10 @@ namespace Content.Server.Construction
return null;
}
var newEntity = EntityManager.SpawnEntity(graph.Nodes[edge.Target].Entity, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).Coordinates);
var newEntity = EntityManager.SpawnEntity(graph.Nodes[edge.Target].Entity, EntityManager.GetComponent<TransformComponent>(user).Coordinates);
// Yes, this should throw if it's missing the component.
var construction = IoCManager.Resolve<IEntityManager>().GetComponent<ConstructionComponent>(newEntity);
var construction = EntityManager.GetComponent<ConstructionComponent>(newEntity);
// We attempt to set the pathfinding target.
SetPathfindingTarget(newEntity, targetNode.Name, construction);
@@ -285,9 +285,11 @@ namespace Content.Server.Construction
return;
}
if (!_prototypeManager.TryIndex(constructionPrototype.Graph, out ConstructionGraphPrototype? constructionGraph))
if (!_prototypeManager.TryIndex(constructionPrototype.Graph,
out ConstructionGraphPrototype? constructionGraph))
{
_sawmill.Error($"Invalid construction graph '{constructionPrototype.Graph}' in recipe '{ev.PrototypeName}'!");
_sawmill.Error(
$"Invalid construction graph '{constructionPrototype.Graph}' in recipe '{ev.PrototypeName}'!");
return;
}
@@ -295,25 +297,26 @@ namespace Content.Server.Construction
var targetNode = constructionGraph.Nodes[constructionPrototype.TargetNode];
var pathFind = constructionGraph.Path(startNode.Name, targetNode.Name);
var user = args.SenderSession.AttachedEntity;
if (args.SenderSession.AttachedEntity is not {Valid: true} user ||
!Get<ActionBlockerSystem>().CanInteract(user)) return;
if (user == null || !Get<ActionBlockerSystem>().CanInteract(user)) return;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands)) return;
if (!EntityManager.TryGetComponent(user, out HandsComponent? hands)) return;
foreach (var condition in constructionPrototype.Conditions)
{
if (!condition.Condition(user, user.ToCoordinates(), Direction.South))
if (!condition.Condition(user, user.ToCoordinates(0, 0), Direction.South))
return;
}
if(pathFind == null)
throw new InvalidDataException($"Can't find path from starting node to target node in construction! Recipe: {ev.PrototypeName}");
if (pathFind == null)
throw new InvalidDataException(
$"Can't find path from starting node to target node in construction! Recipe: {ev.PrototypeName}");
var edge = startNode.GetEdge(pathFind[0].Name);
if(edge == null)
throw new InvalidDataException($"Can't find edge from starting node to the next node in pathfinding! Recipe: {ev.PrototypeName}");
if (edge == null)
throw new InvalidDataException(
$"Can't find edge from starting node to the next node in pathfinding! Recipe: {ev.PrototypeName}");
// No support for conditions here!
@@ -326,9 +329,8 @@ namespace Content.Server.Construction
}
}
var item = await Construct(user, "item_construction", constructionGraph, edge, targetNode);
if(item != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(item, out ItemComponent? itemComp))
if (await Construct(user, "item_construction", constructionGraph, edge, targetNode) is {Valid: true} item &&
EntityManager.TryGetComponent(item, out ItemComponent? itemComp))
hands.PutInHandOrDrop(itemComp);
}
@@ -350,9 +352,7 @@ namespace Content.Server.Construction
return;
}
var user = args.SenderSession.AttachedEntity;
if (user == null)
if (args.SenderSession.AttachedEntity is not {Valid: true} user)
{
_sawmill.Error($"Client sent {nameof(TryStartStructureConstructionMessage)} with no attached entity!");
return;
@@ -397,9 +397,8 @@ namespace Content.Server.Construction
_beingBuilt[args.SenderSession].Remove(ev.Ack);
}
if (user == null
|| !Get<ActionBlockerSystem>().CanInteract(user)
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands) || hands.GetActiveHand == null
if (!Get<ActionBlockerSystem>().CanInteract(user)
|| !EntityManager.TryGetComponent(user, out HandsComponent? hands) || hands.GetActiveHand == null
|| !user.InRangeUnobstructed(ev.Location, ignoreInsideBlocker:constructionPrototype.CanBuildInImpassable))
{
Cleanup();
@@ -415,9 +414,8 @@ namespace Content.Server.Construction
throw new InvalidDataException($"Can't find edge from starting node to the next node in pathfinding! Recipe: {ev.PrototypeName}");
var valid = false;
var holding = hands.GetActiveHand?.Owner;
if (holding == null)
if (hands.GetActiveHand?.Owner is not {Valid: true} holding)
{
Cleanup();
return;
@@ -447,9 +445,8 @@ namespace Content.Server.Construction
return;
}
var structure = await Construct(user, (ev.Ack + constructionPrototype.GetHashCode()).ToString(), constructionGraph, edge, targetNode);
if (structure == null)
if (await Construct(user, (ev.Ack + constructionPrototype.GetHashCode()).ToString(), constructionGraph,
edge, targetNode) is not {Valid: true} structure)
{
Cleanup();
return;
@@ -457,13 +454,13 @@ namespace Content.Server.Construction
// We do this to be able to move the construction to its proper position in case it's anchored...
// Oh wow transform anchoring is amazing wow I love it!!!!
var wasAnchored = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(structure).Anchored;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(structure).Anchored = false;
var wasAnchored = EntityManager.GetComponent<TransformComponent>(structure).Anchored;
EntityManager.GetComponent<TransformComponent>(structure).Anchored = false;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(structure).Coordinates = ev.Location;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(structure).LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.Zero;
EntityManager.GetComponent<TransformComponent>(structure).Coordinates = ev.Location;
EntityManager.GetComponent<TransformComponent>(structure).LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.Zero;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(structure).Anchored = wasAnchored;
EntityManager.GetComponent<TransformComponent>(structure).Anchored = wasAnchored;
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack));

View File

@@ -273,7 +273,7 @@ namespace Content.Server.Construction
if (doAfterState == DoAfterState.Cancelled)
return HandleResult.False;
var insert = interactUsing.UsedUid;
var insert = interactUsing.Used;
// Since many things inherit this step, we delegate the "is this entity valid?" logic to them.
// While this is very OOP and I find it icky, I must admit that it simplifies the code here a lot.
@@ -312,7 +312,7 @@ namespace Content.Server.Construction
// we split the stack in two and insert the split stack.
if (insertStep is MaterialConstructionGraphStep materialInsertStep)
{
if (_stackSystem.Split(insert, materialInsertStep.Amount, EntityManager.GetComponent<TransformComponent>(interactUsing.UserUid).Coordinates) is not {} stack)
if (_stackSystem.Split(insert, materialInsertStep.Amount, EntityManager.GetComponent<TransformComponent>(interactUsing.User).Coordinates) is not {} stack)
return HandleResult.False;
insert = stack;
@@ -329,8 +329,7 @@ namespace Content.Server.Construction
construction.Containers.Add(store);
// The container doesn't necessarily need to exist, so we ensure it.
_containerSystem.EnsureContainer<Container>(uid, store)
.Insert(EntityManager.GetEntity(insert));
_containerSystem.EnsureContainer<Container>(uid, store).Insert(insert);
}
else
{