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

@@ -330,13 +330,17 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
// we can only currently guarantee that NT stations are the only station to
// exist in the base game.
var eligible = EntityQuery<StationEventEligibleComponent, NpcFactionMemberComponent>()
.Where(x =>
_npcFaction.IsFactionHostile(component.Faction, x.Item2.Owner, x.Item2))
.Select(x => x.Item1.Owner)
.ToList();
var eligible = new List<Entity<StationEventEligibleComponent, NpcFactionMemberComponent>>();
var eligibleQuery = EntityQueryEnumerator<StationEventEligibleComponent, NpcFactionMemberComponent>();
while (eligibleQuery.MoveNext(out var eligibleUid, out var eligibleComp, out var member))
{
if (!_npcFaction.IsFactionFriendly(component.Faction, eligibleUid, member))
continue;
if (!eligible.Any())
eligible.Add((eligibleUid, eligibleComp, member));
}
if (eligible.Count == 0)
return;
component.TargetStation = _random.Pick(eligible);