Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -5,7 +5,7 @@ using Content.Shared.Construction;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Server.Construction.Commands
|
||||
{
|
||||
@@ -13,7 +13,6 @@ namespace Content.Server.Construction.Commands
|
||||
public sealed class FixRotationsCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
public string Command => "fixrotations";
|
||||
@@ -51,13 +50,13 @@ namespace Content.Server.Construction.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
||||
{
|
||||
shell.WriteError($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_entManager.EntityExists(grid.Owner))
|
||||
if (!_entManager.EntityExists(gridId))
|
||||
{
|
||||
shell.WriteError($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
return;
|
||||
@@ -66,7 +65,7 @@ namespace Content.Server.Construction.Commands
|
||||
var changed = 0;
|
||||
var tagSystem = _entManager.EntitySysManager.GetEntitySystem<TagSystem>();
|
||||
|
||||
foreach (var child in xformQuery.GetComponent(grid.Owner).ChildEntities)
|
||||
foreach (var child in xformQuery.GetComponent(gridId.Value).ChildEntities)
|
||||
{
|
||||
if (!_entManager.EntityExists(child))
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Server.Construction.Commands;
|
||||
|
||||
@@ -10,7 +11,6 @@ namespace Content.Server.Construction.Commands;
|
||||
sealed class TileReplaceCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDef = default!;
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
@@ -58,13 +58,13 @@ sealed class TileReplaceCommand : IConsoleCommand
|
||||
var tileA = _tileDef[tileIdA];
|
||||
var tileB = _tileDef[tileIdB];
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_entManager.EntityExists(grid.Owner))
|
||||
if (!_entManager.EntityExists(gridId))
|
||||
{
|
||||
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
return;
|
||||
|
||||
@@ -2,9 +2,11 @@ using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Server.Construction.Commands
|
||||
{
|
||||
@@ -12,7 +14,6 @@ namespace Content.Server.Construction.Commands
|
||||
sealed class TileWallsCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
|
||||
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
@@ -56,13 +57,13 @@ namespace Content.Server.Construction.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_entManager.EntityExists(grid.Owner))
|
||||
if (!_entManager.EntityExists(gridId))
|
||||
{
|
||||
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
return;
|
||||
@@ -72,7 +73,7 @@ namespace Content.Server.Construction.Commands
|
||||
var underplating = _tileDefManager[TilePrototypeId];
|
||||
var underplatingTile = new Tile(underplating.TileId);
|
||||
var changed = 0;
|
||||
foreach (var child in _entManager.GetComponent<TransformComponent>(grid.Owner).ChildEntities)
|
||||
foreach (var child in _entManager.GetComponent<TransformComponent>(gridId.Value).ChildEntities)
|
||||
{
|
||||
if (!_entManager.EntityExists(child))
|
||||
{
|
||||
@@ -91,7 +92,8 @@ namespace Content.Server.Construction.Commands
|
||||
continue;
|
||||
}
|
||||
|
||||
var tile = grid.GetTileRef(childTransform.Coordinates);
|
||||
var mapSystem = _entManager.System<MapSystem>();
|
||||
var tile = mapSystem.GetTileRef(gridId.Value, grid, childTransform.Coordinates);
|
||||
var tileDef = (ContentTileDefinition) _tileDefManager[tile.Tile.TypeId];
|
||||
|
||||
if (tileDef.ID == TilePrototypeId)
|
||||
|
||||
@@ -27,7 +27,7 @@ public sealed partial class ConstructionSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCompMapInit(EntityUid uid, ComputerComponent component, MapInitEvent args)
|
||||
private void OnCompMapInit(Entity<ComputerComponent> component, ref MapInitEvent args)
|
||||
{
|
||||
CreateComputerBoard(component);
|
||||
}
|
||||
@@ -42,25 +42,26 @@ public sealed partial class ConstructionSystem
|
||||
/// This exists so when you deconstruct computers that were serialized with the map,
|
||||
/// you can retrieve the computer board.
|
||||
/// </summary>
|
||||
private void CreateComputerBoard(ComputerComponent component)
|
||||
private void CreateComputerBoard(Entity<ComputerComponent> ent)
|
||||
{
|
||||
var component = ent.Comp;
|
||||
// Ensure that the construction component is aware of the board container.
|
||||
if (TryComp<ConstructionComponent>(component.Owner, out var construction))
|
||||
AddContainer(component.Owner, "board", construction);
|
||||
if (TryComp<ConstructionComponent>(ent, out var construction))
|
||||
AddContainer(ent, "board", construction);
|
||||
|
||||
// We don't do anything if this is null or empty.
|
||||
if (string.IsNullOrEmpty(component.BoardPrototype))
|
||||
return;
|
||||
|
||||
var container = _container.EnsureContainer<Container>(component.Owner, "board");
|
||||
var container = _container.EnsureContainer<Container>(ent, "board");
|
||||
|
||||
// We already contain a board. Note: We don't check if it's the right one!
|
||||
if (container.ContainedEntities.Count != 0)
|
||||
return;
|
||||
|
||||
var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(component.Owner).Coordinates);
|
||||
var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(ent).Coordinates);
|
||||
|
||||
if(!container.Insert(board))
|
||||
Logger.Warning($"Couldn't insert board {board} to computer {component.Owner}!");
|
||||
if (!container.Insert(board))
|
||||
Log.Warning($"Couldn't insert board {board} to computer {ent}!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,17 +44,18 @@ namespace Content.Server.Construction
|
||||
SubscribeLocalEvent<ConstructionComponent, ComponentStartup>(OnConstructionStartup);
|
||||
}
|
||||
|
||||
private void OnConstructionInit(EntityUid uid, ConstructionComponent construction, ComponentInit args)
|
||||
private void OnConstructionInit(Entity<ConstructionComponent> ent, ref ComponentInit args)
|
||||
{
|
||||
if (GetCurrentGraph(uid, construction) is not {} graph)
|
||||
var construction = ent.Comp;
|
||||
if (GetCurrentGraph(ent, construction) is not {} graph)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetNodeFromGraph(graph, construction.Node) is not {} node)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid node specified.");
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (GetEdgeFromNode(node, edgeIndex) is not {} currentEdge)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,11 +75,11 @@ namespace Content.Server.Construction
|
||||
{
|
||||
if (GetNodeFromGraph(graph, targetNodeId) is not { } targetNode)
|
||||
{
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
|
||||
_sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
UpdatePathfinding(uid, graph, node, targetNode, edge, construction);
|
||||
UpdatePathfinding(ent, graph, node, targetNode, edge, construction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user