From c23b3d804efc7f35cf6c56d872d8dd7fee82ece1 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:24:24 +1100 Subject: [PATCH] Fix exped FTL (#25823) Also fixed some other stuff I noticed. --- .../Shuttles/Systems/ShuttleSystem.Console.cs | 7 +++++++ Content.Client/Shuttles/UI/MapScreen.xaml.cs | 6 +++++- .../Shuttles/UI/ShuttleMapControl.xaml.cs | 4 ++++ Content.Server/Salvage/SpawnSalvageMissionJob.cs | 3 +++ .../Shuttles/Systems/ShuttleConsoleSystem.FTL.cs | 10 +++++----- .../Systems/ShuttleSystem.FasterThanLight.cs | 15 +++++++++------ 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs b/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs index 2d2886766d..c134b7157c 100644 --- a/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs +++ b/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs @@ -5,6 +5,7 @@ using Content.Shared.Shuttles.UI.MapObjects; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; using Robust.Shared.Map; +using Robust.Shared.Map.Components; using Robust.Shared.Physics.Components; namespace Content.Client.Shuttles.Systems; @@ -39,6 +40,12 @@ public sealed partial class ShuttleSystem return GetCoordinates(exclusion.Coordinates).ToMap(EntityManager, XformSystem); case GridMapObject grid: var gridXform = Transform(grid.Entity); + + if (HasComp(grid.Entity)) + { + return new MapCoordinates(gridXform.LocalPosition, gridXform.MapID); + } + Entity gridEnt = (grid.Entity, null, gridXform); return new MapCoordinates(Maps.GetGridPosition(gridEnt), gridXform.MapID); default: diff --git a/Content.Client/Shuttles/UI/MapScreen.xaml.cs b/Content.Client/Shuttles/UI/MapScreen.xaml.cs index 8287093f78..65a11d345d 100644 --- a/Content.Client/Shuttles/UI/MapScreen.xaml.cs +++ b/Content.Client/Shuttles/UI/MapScreen.xaml.cs @@ -150,8 +150,12 @@ public sealed partial class MapScreen : BoxContainer _ftlStyle.BackgroundColor = Color.FromHex("#B02E26"); MapRadar.InFtl = false; break; + // Fallback in case no FTL state or the likes. default: - throw new NotImplementedException(); + SetFTLAllowed(false); + _ftlStyle.BackgroundColor = Color.FromHex("#B02E26"); + MapRadar.InFtl = false; + break; } if (IsFTLBlocked()) diff --git a/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs b/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs index 5800af2d87..55ef55a6c7 100644 --- a/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs +++ b/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs @@ -210,6 +210,10 @@ public sealed partial class ShuttleMapControl : BaseShuttleControl foreach (var mapObj in mapObjects) { + // If it's a grid-map skip it. + if (mapObj is GridMapObject gridObj && EntManager.HasComponent(gridObj.Entity)) + continue; + var mapCoords = _shuttles.GetMapCoordinates(mapObj); var relativePos = matty.Transform(mapCoords.Position); diff --git a/Content.Server/Salvage/SpawnSalvageMissionJob.cs b/Content.Server/Salvage/SpawnSalvageMissionJob.cs index eb370aa112..2776db2283 100644 --- a/Content.Server/Salvage/SpawnSalvageMissionJob.cs +++ b/Content.Server/Salvage/SpawnSalvageMissionJob.cs @@ -24,6 +24,7 @@ using Content.Shared.Random; using Content.Shared.Salvage; using Content.Shared.Salvage.Expeditions; using Content.Shared.Salvage.Expeditions.Modifiers; +using Content.Shared.Shuttles.Components; using Content.Shared.Storage; using Robust.Shared.Collections; using Robust.Shared.Map; @@ -91,6 +92,8 @@ public sealed class SpawnSalvageMissionJob : Job MetaDataComponent? metadata = null; var grid = _entManager.EnsureComponent(mapUid); var random = new Random(_missionParams.Seed); + var destComp = _entManager.AddComponent(mapUid); + destComp.BeaconsOnly = true; // Setup mission configs // As we go through the config the rating will deplete so we'll go for most important to least important. diff --git a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs index ba188896b1..7606d190a4 100644 --- a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs +++ b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs @@ -54,7 +54,7 @@ public sealed partial class ShuttleConsoleSystem var angle = args.Angle.Reduced(); var targetCoordinates = new EntityCoordinates(targetXform.MapUid!.Value, _transform.GetWorldPosition(targetXform)); - ConsoleFTL(ent, true, targetCoordinates, angle, targetXform.MapID); + ConsoleFTL(ent, targetCoordinates, angle, targetXform.MapID); } private void OnPositionFTLMessage(Entity entity, ref ShuttleConsoleFTLPositionMessage args) @@ -69,7 +69,7 @@ public sealed partial class ShuttleConsoleSystem var targetCoordinates = new EntityCoordinates(mapUid, args.Coordinates.Position); var angle = args.Angle.Reduced(); - ConsoleFTL(entity, false, targetCoordinates, angle, args.Coordinates.MapId); + ConsoleFTL(entity, targetCoordinates, angle, args.Coordinates.MapId); } private void GetBeacons(ref List? beacons) @@ -95,7 +95,7 @@ public sealed partial class ShuttleConsoleSystem { var query = AllEntityQuery(); - while (query.MoveNext(out var uid, out var comp, out var xform)) + while (query.MoveNext(out var comp, out var xform)) { if (!comp.Enabled) continue; @@ -108,7 +108,7 @@ public sealed partial class ShuttleConsoleSystem /// /// Handles shuttle console FTLs. /// - private void ConsoleFTL(Entity ent, bool beacon, EntityCoordinates targetCoordinates, Angle targetAngle, MapId targetMap) + private void ConsoleFTL(Entity ent, EntityCoordinates targetCoordinates, Angle targetAngle, MapId targetMap) { var consoleUid = GetDroneConsole(ent.Owner); @@ -136,7 +136,7 @@ public sealed partial class ShuttleConsoleSystem List? exclusions = null; GetExclusions(ref exclusions); - if (!beacon && !_shuttle.FTLFree(shuttleUid.Value, targetCoordinates, targetAngle, exclusions)) + if (!_shuttle.FTLFree(shuttleUid.Value, targetCoordinates, targetAngle, exclusions)) { return; } diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index 07dfd1faf5..05bf7fc74d 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -36,7 +36,7 @@ public sealed partial class ShuttleSystem public const float DefaultTravelTime = 20f; public const float DefaultArrivalTime = 5f; private const float FTLCooldown = 10f; - public const float FTLMassLimit = 100000f; + public const float FTLMassLimit = 300f; // I'm too lazy to make CVars. @@ -68,9 +68,11 @@ public sealed partial class ShuttleSystem private const int FTLProximityIterations = 3; private readonly HashSet _lookupEnts = new(); + private readonly HashSet _immuneEnts = new(); private EntityQuery _bodyQuery; private EntityQuery _buckleQuery; + private EntityQuery _beaconQuery; private EntityQuery _ghostQuery; private EntityQuery _physicsQuery; private EntityQuery _statusQuery; @@ -81,6 +83,7 @@ public sealed partial class ShuttleSystem SubscribeLocalEvent(OnStationPostInit); _bodyQuery = GetEntityQuery(); _buckleQuery = GetEntityQuery(); + _beaconQuery = GetEntityQuery(); _ghostQuery = GetEntityQuery(); _physicsQuery = GetEntityQuery(); _statusQuery = GetEntityQuery(); @@ -206,7 +209,7 @@ public sealed partial class ShuttleSystem return false; } - if (TryComp(shuttleUid, out PhysicsComponent? shuttlePhysics) && shuttlePhysics.Mass > 300f) + if (TryComp(shuttleUid, out PhysicsComponent? shuttlePhysics) && shuttlePhysics.Mass > FTLMassLimit) { reason = Loc.GetString("shuttle-console-mass"); return false; @@ -822,7 +825,6 @@ public sealed partial class ShuttleSystem // Flatten anything not parented to a grid. var transform = _physics.GetPhysicsTransform(uid, xform); var aabbs = new List(manager.Fixtures.Count); - var immune = new HashSet(); var tileSet = new List<(Vector2i, Tile)>(); foreach (var fixture in manager.Fixtures.Values) @@ -842,16 +844,17 @@ public sealed partial class ShuttleSystem tileSet.Clear(); _biomes.ReserveTiles(xform.MapUid.Value, aabb, tileSet); _lookupEnts.Clear(); + _immuneEnts.Clear(); _lookup.GetEntitiesIntersecting(xform.MapUid.Value, aabb, _lookupEnts, LookupFlags.Uncontained); foreach (var ent in _lookupEnts) { - if (ent == uid || immune.Contains(ent)) + if (ent == uid || _immuneEnts.Contains(ent)) { continue; } - if (_ghostQuery.HasComponent(ent)) + if (_ghostQuery.HasComponent(ent) || _beaconQuery.HasComponent(ent)) { continue; } @@ -859,7 +862,7 @@ public sealed partial class ShuttleSystem if (_bodyQuery.TryGetComponent(ent, out var mob)) { var gibs = _bobby.GibBody(ent, body: mob); - immune.UnionWith(gibs); + _immuneEnts.UnionWith(gibs); continue; }