Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
@@ -35,7 +32,7 @@ public sealed partial class DockingSystem
|
||||
if (dockable == null)
|
||||
continue;
|
||||
|
||||
TryDock(dockUid, dock, dockable.Owner, dockable);
|
||||
TryDock(dockUid, dock, dockable.Value);
|
||||
}
|
||||
|
||||
// Work out recent docks that have gone past their designated threshold.
|
||||
@@ -114,7 +111,8 @@ public sealed partial class DockingSystem
|
||||
var player = args.Session.AttachedEntity;
|
||||
|
||||
// TODO: Validation
|
||||
if (player == null || !TryComp<AutoDockComponent>(dork, out var comp)) return;
|
||||
if (player == null || !TryComp<AutoDockComponent>(dork, out var comp))
|
||||
return;
|
||||
|
||||
comp.Requesters.Remove(player.Value);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Shuttles.Components;
|
||||
@@ -140,6 +139,7 @@ public sealed partial class DockingSystem
|
||||
var isMap = HasComp<MapComponent>(targetGrid);
|
||||
|
||||
var validDockConfigs = new List<DockingConfig>();
|
||||
var grids = new List<Entity<MapGridComponent>>();
|
||||
if (shuttleDocks.Count > 0)
|
||||
{
|
||||
// We'll try all combinations of shuttle docks and see which one is most suitable
|
||||
@@ -174,8 +174,9 @@ public sealed partial class DockingSystem
|
||||
var dockedBounds = new Box2Rotated(shuttleAABB.Translated(spawnPosition.Position), targetAngle, spawnPosition.Position);
|
||||
|
||||
// Check if there's no intersecting grids (AKA oh god it's docking at cargo).
|
||||
if (_mapManager.FindGridsIntersecting(targetGridXform.MapID,
|
||||
dockedBounds).Any(o => o.Owner != targetGrid))
|
||||
grids.Clear();
|
||||
_mapManager.FindGridsIntersecting(targetGridXform.MapID, dockedBounds, ref grids);
|
||||
if (grids.Any(o => o.Owner != targetGrid))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Content.Shared.Doors;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
@@ -66,7 +67,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private DockingComponent? GetDockable(EntityUid uid, TransformComponent dockingXform)
|
||||
private Entity<DockingComponent>? GetDockable(EntityUid uid, TransformComponent dockingXform)
|
||||
{
|
||||
// Did you know Saltern is the most dockable station?
|
||||
|
||||
@@ -96,12 +97,14 @@ namespace Content.Server.Shuttles.Systems
|
||||
var enlargedAABB = aabb.Value.Enlarged(DockingRadius * 1.5f);
|
||||
|
||||
// Get any docking ports in range on other grids.
|
||||
foreach (var otherGrid in _mapManager.FindGridsIntersecting(dockingXform.MapID, enlargedAABB))
|
||||
var grids = new List<Entity<MapGridComponent>>();
|
||||
_mapManager.FindGridsIntersecting(dockingXform.MapID, enlargedAABB, ref grids);
|
||||
foreach (var otherGrid in grids)
|
||||
{
|
||||
if (otherGrid.Owner == dockingXform.GridUid)
|
||||
continue;
|
||||
|
||||
foreach (var ent in otherGrid.GetAnchoredEntities(enlargedAABB))
|
||||
foreach (var ent in otherGrid.Comp.GetAnchoredEntities(enlargedAABB))
|
||||
{
|
||||
if (!TryComp(ent, out DockingComponent? otherDocking) ||
|
||||
!otherDocking.Enabled ||
|
||||
@@ -129,7 +132,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
|
||||
// TODO: Need CollisionManager's GJK for accurate bounds
|
||||
// Realistically I want 2 fixtures anyway but I'll deal with that later.
|
||||
return otherDocking;
|
||||
return (ent, otherDocking);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -443,12 +446,12 @@ namespace Content.Server.Shuttles.Systems
|
||||
/// <summary>
|
||||
/// Attempts to dock 2 ports together and will return early if it's not possible.
|
||||
/// </summary>
|
||||
private void TryDock(EntityUid dockAUid, DockingComponent dockA, EntityUid dockBUid, DockingComponent dockB)
|
||||
private void TryDock(EntityUid dockAUid, DockingComponent dockA, Entity<DockingComponent> dockB)
|
||||
{
|
||||
if (!CanDock(dockAUid, dockBUid, dockA, dockB))
|
||||
if (!CanDock(dockAUid, dockB, dockA, dockB))
|
||||
return;
|
||||
|
||||
Dock(dockAUid, dockA, dockBUid, dockB);
|
||||
Dock(dockAUid, dockA, dockB, dockB);
|
||||
}
|
||||
|
||||
public void Undock(EntityUid dockUid, DockingComponent dock)
|
||||
|
||||
@@ -9,7 +9,6 @@ using Content.Shared.Popups;
|
||||
using Content.Shared.Shuttles.BUIStates;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Timer = Robust.Shared.Timing.Timer;
|
||||
@@ -258,16 +257,17 @@ public sealed partial class EmergencyShuttleSystem
|
||||
private void OnEmergencyRepeal(EntityUid uid, EmergencyShuttleConsoleComponent component, EmergencyShuttleRepealMessage args)
|
||||
{
|
||||
var player = args.Session.AttachedEntity;
|
||||
if (player == null) return;
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard.Owner, uid))
|
||||
if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard, uid))
|
||||
{
|
||||
_popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), player.Value, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: This is fucking bad
|
||||
if (!component.AuthorizedEntities.Remove(MetaData(idCard.Owner).EntityName))
|
||||
if (!component.AuthorizedEntities.Remove(MetaData(idCard).EntityName))
|
||||
return;
|
||||
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch REPEAL by {args.Session:user}");
|
||||
@@ -283,14 +283,14 @@ public sealed partial class EmergencyShuttleSystem
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard.Owner, uid))
|
||||
if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard, uid))
|
||||
{
|
||||
_popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), args.Session, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: This is fucking bad
|
||||
if (!component.AuthorizedEntities.Add(MetaData(idCard.Owner).EntityName))
|
||||
if (!component.AuthorizedEntities.Add(MetaData(idCard).EntityName))
|
||||
return;
|
||||
|
||||
_logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch AUTH by {args.Session:user}");
|
||||
|
||||
@@ -1,29 +1,26 @@
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Parallax;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.Events;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Parallax;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Content.Shared.StatusEffect;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
@@ -231,7 +228,7 @@ public sealed partial class ShuttleSystem
|
||||
component = AddComp<FTLComponent>(uid);
|
||||
component.State = FTLState.Starting;
|
||||
// TODO: Need BroadcastGrid to not be bad.
|
||||
SoundSystem.Play(_startupSound.GetSound(), Filter.Empty().AddInRange(Transform(uid).MapPosition, GetSoundRange(component.Owner)), _startupSound.Params);
|
||||
SoundSystem.Play(_startupSound.GetSound(), Filter.Empty().AddInRange(Transform(uid).MapPosition, GetSoundRange(uid)), _startupSound.Params);
|
||||
// Make sure the map is setup before we leave to avoid pop-in (e.g. parallax).
|
||||
SetupHyperspace();
|
||||
return true;
|
||||
@@ -608,16 +605,20 @@ public sealed partial class ShuttleSystem
|
||||
var iteration = 0;
|
||||
var lastCount = nearbyGrids.Count;
|
||||
var mapId = targetXform.MapID;
|
||||
var grids = new List<Entity<MapGridComponent>>();
|
||||
|
||||
while (iteration < FTLProximityIterations)
|
||||
{
|
||||
foreach (var grid in _mapManager.FindGridsIntersecting(mapId, targetAABB))
|
||||
grids.Clear();
|
||||
_mapManager.FindGridsIntersecting(mapId, targetAABB, ref grids);
|
||||
|
||||
foreach (var grid in grids)
|
||||
{
|
||||
if (!nearbyGrids.Add(grid.Owner))
|
||||
if (!nearbyGrids.Add(grid))
|
||||
continue;
|
||||
|
||||
targetAABB = targetAABB.Union(_transform.GetWorldMatrix(grid.Owner, xformQuery)
|
||||
.TransformBox(Comp<MapGridComponent>(grid.Owner).LocalAABB));
|
||||
targetAABB = targetAABB.Union(_transform.GetWorldMatrix(grid, xformQuery)
|
||||
.TransformBox(Comp<MapGridComponent>(grid).LocalAABB));
|
||||
}
|
||||
|
||||
// Can do proximity
|
||||
@@ -634,14 +635,15 @@ public sealed partial class ShuttleSystem
|
||||
if (iteration != FTLProximityIterations)
|
||||
continue;
|
||||
|
||||
foreach (var grid in _mapManager.GetAllGrids())
|
||||
var query = AllEntityQuery<MapGridComponent>();
|
||||
while (query.MoveNext(out var uid, out var grid))
|
||||
{
|
||||
// Don't add anymore as it is irrelevant, but that doesn't mean we need to re-do existing work.
|
||||
if (nearbyGrids.Contains(grid.Owner))
|
||||
if (nearbyGrids.Contains(uid))
|
||||
continue;
|
||||
|
||||
targetAABB = targetAABB.Union(_transform.GetWorldMatrix(grid.Owner, xformQuery)
|
||||
.TransformBox(Comp<MapGridComponent>(grid.Owner).LocalAABB));
|
||||
targetAABB = targetAABB.Union(_transform.GetWorldMatrix(uid, xformQuery)
|
||||
.TransformBox(Comp<MapGridComponent>(uid).LocalAABB));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -76,12 +76,14 @@ public sealed partial class ShuttleSystem
|
||||
protected override void UpdateIFFInterfaces(EntityUid gridUid, IFFComponent component)
|
||||
{
|
||||
base.UpdateIFFInterfaces(gridUid, component);
|
||||
foreach (var (comp, xform) in EntityQuery<IFFConsoleComponent, TransformComponent>(true))
|
||||
|
||||
var query = AllEntityQuery<IFFConsoleComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp, out var xform))
|
||||
{
|
||||
if (xform.GridUid != gridUid)
|
||||
continue;
|
||||
|
||||
_uiSystem.TrySetUiState(comp.Owner, IFFConsoleUiKey.Key, new IFFConsoleBoundUserInterfaceState()
|
||||
_uiSystem.TrySetUiState(uid, IFFConsoleUiKey.Key, new IFFConsoleBoundUserInterfaceState()
|
||||
{
|
||||
AllowedFlags = comp.AllowedFlags,
|
||||
Flags = component.Flags,
|
||||
|
||||
@@ -130,6 +130,15 @@ public sealed class ThrusterSystem : EntitySystem
|
||||
private void OnActivateThruster(EntityUid uid, ThrusterComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
component.Enabled ^= true;
|
||||
|
||||
if (!component.Enabled)
|
||||
{
|
||||
DisableThruster(uid, component);
|
||||
}
|
||||
else if (CanEnable(uid, component))
|
||||
{
|
||||
EnableThruster(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user