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,8 +1,6 @@
using System.Linq;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Station.Systems;
using Content.Server.StationEvents.Components;
namespace Content.Server.StationEvents.Events;
@@ -14,7 +12,13 @@ public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRule
HashSet<EntityUid> stationsToNotify = new();
var mod = GetSeverityModifier();
var targetList = EntityQuery<SentienceTargetComponent>().ToList();
var targetList = new List<Entity<SentienceTargetComponent>>();
var query = EntityQueryEnumerator<SentienceTargetComponent>();
while (query.MoveNext(out var targetUid, out var target))
{
targetList.Add((targetUid, target));
}
RobustRandom.Shuffle(targetList);
var toMakeSentient = (int) (RobustRandom.Next(2, 5) * Math.Sqrt(mod));
@@ -25,12 +29,12 @@ public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRule
if (toMakeSentient-- == 0)
break;
RemComp<SentienceTargetComponent>(target.Owner);
var ghostRole = EnsureComp<GhostRoleComponent>(target.Owner);
EnsureComp<GhostTakeoverAvailableComponent>(target.Owner);
ghostRole.RoleName = MetaData(target.Owner).EntityName;
RemComp<SentienceTargetComponent>(target);
var ghostRole = EnsureComp<GhostRoleComponent>(target);
EnsureComp<GhostTakeoverAvailableComponent>(target);
ghostRole.RoleName = MetaData(target).EntityName;
ghostRole.RoleDescription = Loc.GetString("station-event-random-sentience-role-description", ("name", ghostRole.RoleName));
groups.Add(Loc.GetString(target.FlavorKind));
groups.Add(Loc.GetString(target.Comp.FlavorKind));
}
if (groups.Count == 0)
@@ -43,8 +47,9 @@ public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRule
foreach (var target in targetList)
{
var station = StationSystem.GetOwningStation(target.Owner);
if(station == null) continue;
var station = StationSystem.GetOwningStation(target);
if(station == null)
continue;
stationsToNotify.Add((EntityUid) station);
}
foreach (var station in stationsToNotify)