Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Map;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Client.Administration.UI.SpawnExplosion;
|
||||
|
||||
@@ -13,7 +15,6 @@ public sealed class ExplosionDebugOverlay : Overlay
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public Dictionary<int, List<Vector2i>>? SpaceTiles;
|
||||
public Dictionary<EntityUid, Dictionary<int, List<Vector2i>>> Tiles = new();
|
||||
@@ -61,14 +62,15 @@ public sealed class ExplosionDebugOverlay : Overlay
|
||||
var handle = args.ScreenHandle;
|
||||
Box2 gridBounds;
|
||||
var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
|
||||
var xformSystem = _entityManager.System<TransformSystem>();
|
||||
|
||||
foreach (var (gridId, tileSets) in Tiles)
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!_entityManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
||||
continue;
|
||||
|
||||
var gridXform = xformQuery.GetComponent(grid.Owner);
|
||||
var (_, _, matrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
|
||||
var gridXform = xformQuery.GetComponent(gridId);
|
||||
var (_, _, matrix, invMatrix) = xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery);
|
||||
gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(grid.TileSize * 2);
|
||||
DrawText(handle, gridBounds, matrix, tileSets, grid.TileSize);
|
||||
}
|
||||
@@ -114,9 +116,9 @@ public sealed class ExplosionDebugOverlay : Overlay
|
||||
}
|
||||
}
|
||||
|
||||
if (tileSets.ContainsKey(0))
|
||||
if (tileSets.TryGetValue(0, out var set))
|
||||
{
|
||||
var epicenter = tileSets[0].First();
|
||||
var epicenter = set.First();
|
||||
var worldCenter = transform.Transform((epicenter + Vector2Helpers.Half) * tileSize);
|
||||
var screenCenter = _eyeManager.WorldToScreen(worldCenter) + new Vector2(-24, -24);
|
||||
var text = $"{Intensity[0]:F2}\nΣ={TotalIntensity:F1}\nΔ={Slope:F1}";
|
||||
@@ -129,14 +131,15 @@ public sealed class ExplosionDebugOverlay : Overlay
|
||||
var handle = args.WorldHandle;
|
||||
Box2 gridBounds;
|
||||
var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
|
||||
var xformSystem = _entityManager.System<TransformSystem>();
|
||||
|
||||
foreach (var (gridId, tileSets) in Tiles)
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!_entityManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
||||
continue;
|
||||
|
||||
var gridXform = xformQuery.GetComponent(grid.Owner);
|
||||
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
|
||||
var gridXform = xformQuery.GetComponent(gridId);
|
||||
var (_, _, worldMatrix, invWorldMatrix) = xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery);
|
||||
gridBounds = invWorldMatrix.TransformBox(args.WorldBounds).Enlarged(grid.TileSize * 2);
|
||||
handle.SetTransform(worldMatrix);
|
||||
DrawTiles(handle, gridBounds, tileSets, SpaceTileSize);
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
@@ -17,16 +13,29 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
[UsedImplicitly]
|
||||
public sealed partial class AddAtmosWindow : DefaultWindow
|
||||
{
|
||||
private IEnumerable<MapGridComponent>? _data;
|
||||
[Dependency] private readonly IPlayerManager _players = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
private readonly List<Entity<MapGridComponent>> _data = new();
|
||||
|
||||
public AddAtmosWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
_data = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Owner != 0);
|
||||
foreach (var grid in _data)
|
||||
_data.Clear();
|
||||
|
||||
var player = _players.LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = _entities.GetComponentOrNull<TransformComponent>(player)?.GridUid;
|
||||
var query = IoCManager.Resolve<IEntityManager>().AllEntityQueryEnumerator<MapGridComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var grid))
|
||||
{
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridUid;
|
||||
GridOptions.AddItem($"{grid.Owner} {(playerGrid == grid.Owner ? " (Current)" : "")}");
|
||||
_data.Add((uid, grid));
|
||||
GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id);
|
||||
@@ -35,12 +44,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_data == null)
|
||||
return;
|
||||
var dataList = _data.ToList();
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
var selectedGrid = dataList[GridOptions.SelectedId].Owner;
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addatmos {entManager.GetNetEntity(selectedGrid)}");
|
||||
var selectedGrid = _data[GridOptions.SelectedId].Owner;
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addatmos {_entities.GetNetEntity(selectedGrid)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Station;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -40,13 +39,34 @@ public sealed partial class ObjectsTab : Control
|
||||
|
||||
private void RefreshObjectList(ObjectsTabSelection selection)
|
||||
{
|
||||
var entities = selection switch
|
||||
var entities = new List<EntityUid>();
|
||||
switch (selection)
|
||||
{
|
||||
ObjectsTabSelection.Stations => _entityManager.EntitySysManager.GetEntitySystem<StationSystem>().Stations.ToList(),
|
||||
ObjectsTabSelection.Grids => _entityManager.EntityQuery<MapGridComponent>(true).Select(x => x.Owner).ToList(),
|
||||
ObjectsTabSelection.Maps => _entityManager.EntityQuery<MapComponent>(true).Select(x => x.Owner).ToList(),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(selection), selection, null),
|
||||
};
|
||||
case ObjectsTabSelection.Stations:
|
||||
entities.AddRange(_entityManager.EntitySysManager.GetEntitySystem<StationSystem>().Stations);
|
||||
break;
|
||||
case ObjectsTabSelection.Grids:
|
||||
{
|
||||
var query = _entityManager.AllEntityQueryEnumerator<MapGridComponent>();
|
||||
while (query.MoveNext(out var uid, out _))
|
||||
{
|
||||
entities.Add(uid);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ObjectsTabSelection.Maps:
|
||||
{
|
||||
var query = _entityManager.AllEntityQueryEnumerator<MapComponent>();
|
||||
while (query.MoveNext(out var uid, out _))
|
||||
{
|
||||
entities.Add(uid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(selection), selection, null);
|
||||
}
|
||||
|
||||
foreach (var control in _objects)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user