diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs index abc68543ff..bdbc7b3f5b 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs @@ -48,12 +48,12 @@ public sealed partial class ParticleAcceleratorSystem return; var gridUid = xform.GridUid; - if (gridUid == null || gridUid != xform.ParentUid || !_mapManager.TryGetGrid(gridUid, out var grid)) + if (gridUid == null || gridUid != xform.ParentUid || !TryComp(gridUid, out var grid)) return; // Find fuel chamber first by scanning cardinals. var fuelQuery = GetEntityQuery(); - foreach (var adjacent in grid.GetCardinalNeighborCells(xform.Coordinates)) + foreach (var adjacent in _mapSystem.GetCardinalNeighborCells(gridUid.Value, grid, xform.Coordinates)) { if (fuelQuery.HasComponent(adjacent) && partQuery.TryGetComponent(adjacent, out var partState) @@ -75,21 +75,23 @@ public sealed partial class ParticleAcceleratorSystem // You'll have to take my word for it that that breaks everything, yeah? controller.CurrentlyRescanning = true; - // Align ourselves to match fuel chamber orientation. - // This means that if you mess up the orientation of the control box it's not a big deal, - // because the sprite is far from obvious about the orientation. + // Automatically rotate the control box sprite to face the fuel chamber var fuelXform = xformQuery.GetComponent(controller.FuelChamber!.Value); - var rotation = fuelXform.LocalRotation; - _transformSystem.SetLocalRotation(uid, rotation, xform); + var fuelDir = (fuelXform.LocalPosition - xform.LocalPosition).GetDir(); + _transformSystem.SetLocalRotation(uid, fuelDir.ToAngle(), xform); // Calculate offsets for each of the parts of the PA. // These are all done relative to the fuel chamber BC that is basically the center of the machine. - var positionFuelChamber = grid.TileIndicesFor(fuelXform.Coordinates); // // - var positionEndCap = positionFuelChamber + (Vector2i) rotation.RotateVec(new Vector2(0, 1)); // n // n: End Cap - var positionPowerBox = positionFuelChamber + (Vector2i) rotation.RotateVec(new Vector2(0, -1)); // CF // C: Control Box, F: Fuel Chamber - var positionPortEmitter = positionFuelChamber + (Vector2i) rotation.RotateVec(new Vector2(1, -2)); // P // P: Power Box - var positionForeEmitter = positionFuelChamber + (Vector2i) rotation.RotateVec(new Vector2(0, -2)); // EEE // E: Emitter (Starboard, Fore, Port) - var positionStarboardEmitter = positionFuelChamber + (Vector2i) rotation.RotateVec(new Vector2(-1, -2)); // // + var rotation = fuelXform.LocalRotation; + var offsetVect = rotation.GetCardinalDir().ToIntVec(); + var orthoOffsetVect = new Vector2i(-offsetVect.Y, offsetVect.X); + + var positionFuelChamber = _mapSystem.TileIndicesFor(gridUid!.Value, grid, fuelXform.Coordinates); // n // n: End Cap + var positionEndCap = positionFuelChamber - offsetVect; // CF // C: Control Box, F: Fuel Chamber + var positionPowerBox = positionFuelChamber + offsetVect; // P // P: Power Box + var positionPortEmitter = positionFuelChamber + offsetVect * 2 + orthoOffsetVect; // EEE // E: Emitter (Starboard, Fore, Port) + var positionForeEmitter = positionFuelChamber + offsetVect * 2; + var positionStarboardEmitter = positionFuelChamber + offsetVect * 2 - orthoOffsetVect; ScanPart(gridUid!.Value, positionEndCap, rotation, out controller.EndCap, out var _, grid); ScanPart(gridUid!.Value, positionPowerBox, rotation, out controller.PowerBox, out var _, grid); @@ -137,7 +139,7 @@ public sealed partial class ParticleAcceleratorSystem } var compQuery = GetEntityQuery(); - foreach (var entity in grid.GetAnchoredEntities(coordinates)) + foreach (var entity in _mapSystem.GetAnchoredEntities(uid, grid, coordinates)) { if (compQuery.TryGetComponent(entity, out comp) && TryComp(entity, out var partState) && partState.Master == null diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.cs index c50e054281..ddc7e2a083 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.cs @@ -21,6 +21,7 @@ public sealed partial class ParticleAcceleratorSystem : EntitySystem [Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; + [Dependency] private readonly MapSystem _mapSystem = default!; public override void Initialize() { diff --git a/Resources/Textures/Structures/Power/Generation/PA/control_box.rsi/completed.png b/Resources/Textures/Structures/Power/Generation/PA/control_box.rsi/completed.png index 0636a46df9..932eed803e 100644 Binary files a/Resources/Textures/Structures/Power/Generation/PA/control_box.rsi/completed.png and b/Resources/Textures/Structures/Power/Generation/PA/control_box.rsi/completed.png differ diff --git a/Resources/Textures/Structures/Power/Generation/PA/control_box.rsi/wired.png b/Resources/Textures/Structures/Power/Generation/PA/control_box.rsi/wired.png index 6e0409e9cf..6e4a695d76 100644 Binary files a/Resources/Textures/Structures/Power/Generation/PA/control_box.rsi/wired.png and b/Resources/Textures/Structures/Power/Generation/PA/control_box.rsi/wired.png differ