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

@@ -196,7 +196,13 @@ public sealed class BluespaceLockerSystem : EntitySystem
if (component.BluespaceLinks.Count < component.MinBluespaceLinks)
{
// Get an shuffle the list of all EntityStorages
var storages = EntityQuery<EntityStorageComponent>().ToArray();
var storages = new List<Entity<EntityStorageComponent>>();
var query = EntityQueryEnumerator<EntityStorageComponent>();
while (query.MoveNext(out var uid, out var storage))
{
storages.Add((uid, storage));
}
_robustRandom.Shuffle(storages);
// Add valid candidates till MinBluespaceLinks is met

View File

@@ -1,10 +1,10 @@
using System.Linq;
using Content.Server.Storage.Components;
using Content.Shared.Audio;
using Content.Shared.Storage.Components;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Random;
using System.Linq;
using Content.Shared.Storage.Components;
namespace Content.Server.Storage.EntitySystems;
@@ -28,13 +28,19 @@ public sealed class CursedEntityStorageSystem : EntitySystem
if (storage.Open || storage.Contents.ContainedEntities.Count <= 0)
return;
var lockerQuery = EntityQuery<EntityStorageComponent>().ToList();
lockerQuery.Remove(storage);
var lockers = new List<Entity<EntityStorageComponent>>();
var query = EntityQueryEnumerator<EntityStorageComponent>();
while (query.MoveNext(out var storageUid, out var storageComp))
{
lockers.Add((storageUid, storageComp));
}
if (lockerQuery.Count == 0)
lockers.RemoveAll(e => e.Owner == uid);
if (lockers.Count == 0)
return;
var lockerEnt = _random.Pick(lockerQuery).Owner;
var lockerEnt = _random.Pick(lockers).Owner;
foreach (var entity in storage.Contents.ContainedEntities.ToArray())
{

View File

@@ -12,6 +12,7 @@ using Content.Shared.Storage.Components;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Tools.Systems;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
@@ -23,6 +24,7 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
[Dependency] private readonly ConstructionSystem _construction = default!;
[Dependency] private readonly AtmosphereSystem _atmos = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly MapSystem _mapSystem = default!;
public override void Initialize()
{
@@ -130,9 +132,9 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
{
var targetCoordinates = new EntityCoordinates(uid, component.EnteringOffset).ToMap(EntityManager, TransformSystem);
if (_map.TryFindGridAt(targetCoordinates, out _, out var grid))
if (_map.TryFindGridAt(targetCoordinates, out var gridId, out var grid))
{
return grid.GetTileRef(targetCoordinates);
return _mapSystem.GetTileRef(gridId, grid, targetCoordinates);
}
return null;

View File

@@ -1,11 +1,11 @@
using System.Linq;
using Content.Server.Storage.Components;
using Content.Shared.Database;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Storage;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.Random;
using System.Linq;
using Content.Shared.Storage;
namespace Content.Server.Storage.EntitySystems;
@@ -55,7 +55,7 @@ public sealed class PickRandomSystem : EntitySystem
var picked = _random.Pick(entities);
// if it fails to go into a hand of the user, will be on the storage
_container.AttachParentToContainerOrGrid(Transform(picked));
_container.AttachParentToContainerOrGrid((picked, Transform(picked)));
// TODO: try to put in hands, failing that put it on the storage
_hands.TryPickupAnyHand(user, picked);

View File

@@ -4,7 +4,6 @@ using Content.Server.Storage.Components;
using Content.Shared.Database;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction.Events;
using Content.Shared.Storage;
using Robust.Shared.Audio;
using Robust.Shared.Map;
using Robust.Shared.Player;
@@ -76,7 +75,7 @@ namespace Content.Server.Storage.EntitySystems
foreach (var proto in spawnEntities)
{
entityToPlaceInHands = Spawn(proto, coords);
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(component.Owner)} which spawned {ToPrettyString(entityToPlaceInHands.Value)}");
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(uid)} which spawned {ToPrettyString(entityToPlaceInHands.Value)}");
}
if (component.Sound != null)