Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.Resist;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
@@ -18,13 +17,17 @@ public sealed class BluespaceLockerRule : StationEventSystem<BluespaceLockerRule
|
||||
{
|
||||
base.Started(uid, component, gameRule, args);
|
||||
|
||||
var targets = EntityQuery<EntityStorageComponent, ResistLockerComponent>().ToList();
|
||||
var targets = new List<EntityUid>();
|
||||
var query = EntityQueryEnumerator<EntityStorageComponent, ResistLockerComponent>();
|
||||
while (query.MoveNext(out var storageUid, out _, out _))
|
||||
{
|
||||
targets.Add(storageUid);
|
||||
}
|
||||
|
||||
RobustRandom.Shuffle(targets);
|
||||
|
||||
foreach (var target in targets)
|
||||
foreach (var potentialLink in targets)
|
||||
{
|
||||
var potentialLink = target.Item1.Owner;
|
||||
|
||||
if (HasComp<AccessReaderComponent>(potentialLink) ||
|
||||
HasComp<BluespaceLockerComponent>(potentialLink) ||
|
||||
!HasComp<StationMemberComponent>(potentialLink.ToCoordinates().GetGridUid(EntityManager)))
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System.Linq;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
@@ -29,12 +27,13 @@ public sealed class BreakerFlipRule : StationEventSystem<BreakerFlipRuleComponen
|
||||
if (!TryGetRandomStation(out var chosenStation))
|
||||
return;
|
||||
|
||||
var stationApcs = new List<ApcComponent>();
|
||||
foreach (var (apc, transform) in EntityQuery<ApcComponent, TransformComponent>())
|
||||
var stationApcs = new List<Entity<ApcComponent>>();
|
||||
var query = EntityQueryEnumerator<ApcComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var apcUid, out var apc, out var xform))
|
||||
{
|
||||
if (apc.MainBreakerEnabled && CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == chosenStation)
|
||||
if (apc.MainBreakerEnabled && CompOrNull<StationMemberComponent>(xform.GridUid)?.Station == chosenStation)
|
||||
{
|
||||
stationApcs.Add(apc);
|
||||
stationApcs.Add((apcUid, apc));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +45,7 @@ public sealed class BreakerFlipRule : StationEventSystem<BreakerFlipRuleComponen
|
||||
|
||||
for (var i = 0; i < toDisable; i++)
|
||||
{
|
||||
_apcSystem.ApcToggleBreaker(stationApcs[i].Owner, stationApcs[i]);
|
||||
_apcSystem.ApcToggleBreaker(stationApcs[i], stationApcs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Numerics;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Robust.Shared.Spawners;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
|
||||
using Robust.Shared.Spawners;
|
||||
|
||||
namespace Content.Server.StationEvents.Events
|
||||
{
|
||||
@@ -43,9 +43,13 @@ namespace Content.Server.StationEvents.Events
|
||||
Box2? playableArea = null;
|
||||
var mapId = GameTicker.DefaultMap;
|
||||
|
||||
foreach (var grid in MapManager.GetAllMapGrids(mapId))
|
||||
var query = AllEntityQuery<MapGridComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var gridId, out _, out var xform))
|
||||
{
|
||||
var aabb = _physics.GetWorldAABB(grid.Owner);
|
||||
if (xform.MapID != mapId)
|
||||
continue;
|
||||
|
||||
var aabb = _physics.GetWorldAABB(gridId);
|
||||
playableArea = playableArea?.Union(aabb) ?? aabb;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using System.Threading;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Threading;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Timer = Robust.Shared.Timing.Timer;
|
||||
using System.Linq;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.StationEvents.Components;
|
||||
|
||||
namespace Content.Server.StationEvents.Events
|
||||
{
|
||||
@@ -26,10 +24,11 @@ namespace Content.Server.StationEvents.Events
|
||||
if (!TryGetRandomStation(out var chosenStation))
|
||||
return;
|
||||
|
||||
foreach (var (apc, transform) in EntityQuery<ApcComponent, TransformComponent>(true))
|
||||
var query = AllEntityQuery<ApcComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var apcUid ,out var apc, out var transform))
|
||||
{
|
||||
if (apc.MainBreakerEnabled && CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == chosenStation)
|
||||
component.Powered.Add(apc.Owner);
|
||||
component.Powered.Add(apcUid);
|
||||
}
|
||||
|
||||
RobustRandom.Shuffle(component.Powered);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user