Remove 700 usages of Component.Owner (#21100)

This commit is contained in:
DrSmugleaf
2023-10-19 12:34:31 -07:00
committed by GitHub
parent 5825ffb95c
commit f560f88eb5
261 changed files with 2291 additions and 2036 deletions

View File

@@ -1,7 +1,5 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.Administration;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.Administration;
using JetBrains.Annotations;
using Robust.Shared.Console;
@@ -42,14 +40,14 @@ namespace Content.Server.Nuke.Commands
return CompletionResult.Empty;
}
var stations = _entityManager
.EntityQuery<StationDataComponent>()
.Select(stationData =>
{
var meta = _entityManager.GetComponent<MetaDataComponent>(stationData.Owner);
var stations = new List<CompletionOption>();
var query = _entityManager.EntityQueryEnumerator<StationDataComponent>();
while (query.MoveNext(out var uid, out var stationData))
{
var meta = _entityManager.GetComponent<MetaDataComponent>(uid);
return new CompletionOption(stationData.Owner.ToString(), meta.EntityName);
});
stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
}
return CompletionResult.FromHintOptions(stations, null);
}

View File

@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Chat.Systems;
using Content.Server.Fax;
using Content.Server.Paper;
@@ -103,9 +102,16 @@ namespace Content.Server.Nuke
var codesMessage = new FormattedMessage();
// Find the first nuke that matches the passed location.
var query = EntityQuery<NukeComponent>().ToList();
_random.Shuffle(query);
foreach (var nuke in query)
var nukes = new List<Entity<NukeComponent>>();
var query = EntityQueryEnumerator<NukeComponent>();
while (query.MoveNext(out var nukeUid, out var nuke))
{
nukes.Add((nukeUid, nuke));
}
_random.Shuffle(nukes);
foreach (var (nukeUid, nuke) in nukes)
{
if (!onlyCurrentStation &&
(owningStation == null &&
@@ -116,7 +122,7 @@ namespace Content.Server.Nuke
}
codesMessage.PushNewline();
codesMessage.AddMarkup(Loc.GetString("nuke-codes-list", ("name", MetaData(nuke.Owner).EntityName), ("code", nuke.Code)));
codesMessage.AddMarkup(Loc.GetString("nuke-codes-list", ("name", MetaData(nukeUid).EntityName), ("code", nuke.Code)));
break;
}