]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix exped FTL (#25823)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Mon, 4 Mar 2024 06:24:24 +0000 (17:24 +1100)
committerGitHub <noreply@github.com>
Mon, 4 Mar 2024 06:24:24 +0000 (17:24 +1100)
Also fixed some other stuff I noticed.

Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs
Content.Client/Shuttles/UI/MapScreen.xaml.cs
Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs
Content.Server/Salvage/SpawnSalvageMissionJob.cs
Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs
Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs

index 2d2886766df7bf093fe43ac6e1be8fa3df7cd34a..c134b7157c45a24a9bfdc53fa0c0d11ddd316a46 100644 (file)
@@ -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<MapComponent>(grid.Entity))
+                {
+                    return new MapCoordinates(gridXform.LocalPosition, gridXform.MapID);
+                }
+
                 Entity<PhysicsComponent?, TransformComponent?> gridEnt = (grid.Entity, null, gridXform);
                 return new MapCoordinates(Maps.GetGridPosition(gridEnt), gridXform.MapID);
             default:
index 8287093f78e122403ee50f927f10b17446ff3819..65a11d345d71f1f4c078c2839c915d0ff160f5bc 100644 (file)
@@ -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())
index 5800af2d878d2b367fbd58ec50a171cb6395e6a7..55ef55a6c77d86b68695dfde0a7ca6a58d73e22d 100644 (file)
@@ -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<MapComponent>(gridObj.Entity))
+                continue;
+
             var mapCoords = _shuttles.GetMapCoordinates(mapObj);
 
             var relativePos = matty.Transform(mapCoords.Position);
index eb370aa1129f04a3d8835a55b8eb6093ad5bac42..2776db2283ac32ec34290aea4253119f057fae0e 100644 (file)
@@ -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<bool>
         MetaDataComponent? metadata = null;
         var grid = _entManager.EnsureComponent<MapGridComponent>(mapUid);
         var random = new Random(_missionParams.Seed);
+        var destComp = _entManager.AddComponent<FTLDestinationComponent>(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.
index ba188896b1d6e7a02a0e7a2c0f53a11132a988bb..7606d190a45c481d951508a47e1ee73a7e4afe65 100644 (file)
@@ -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<ShuttleConsoleComponent> 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<ShuttleBeaconObject>? beacons)
@@ -95,7 +95,7 @@ public sealed partial class ShuttleConsoleSystem
     {
         var query = AllEntityQuery<FTLExclusionComponent, TransformComponent>();
 
-        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
     /// <summary>
     /// Handles shuttle console FTLs.
     /// </summary>
-    private void ConsoleFTL(Entity<ShuttleConsoleComponent> ent, bool beacon, EntityCoordinates targetCoordinates, Angle targetAngle, MapId targetMap)
+    private void ConsoleFTL(Entity<ShuttleConsoleComponent> ent, EntityCoordinates targetCoordinates, Angle targetAngle, MapId targetMap)
     {
         var consoleUid = GetDroneConsole(ent.Owner);
 
@@ -136,7 +136,7 @@ public sealed partial class ShuttleConsoleSystem
         List<ShuttleExclusionObject>? exclusions = null;
         GetExclusions(ref exclusions);
 
-        if (!beacon && !_shuttle.FTLFree(shuttleUid.Value, targetCoordinates, targetAngle, exclusions))
+        if (!_shuttle.FTLFree(shuttleUid.Value, targetCoordinates, targetAngle, exclusions))
         {
             return;
         }
index 07dfd1faf599edc8f4c9f2213d05bb5ee1acbae8..05bf7fc74d82b92196de913848bbd299ba7611db 100644 (file)
@@ -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<EntityUid> _lookupEnts = new();
+    private readonly HashSet<EntityUid> _immuneEnts = new();
 
     private EntityQuery<BodyComponent> _bodyQuery;
     private EntityQuery<BuckleComponent> _buckleQuery;
+    private EntityQuery<FTLBeaconComponent> _beaconQuery;
     private EntityQuery<GhostComponent> _ghostQuery;
     private EntityQuery<PhysicsComponent> _physicsQuery;
     private EntityQuery<StatusEffectsComponent> _statusQuery;
@@ -81,6 +83,7 @@ public sealed partial class ShuttleSystem
         SubscribeLocalEvent<StationPostInitEvent>(OnStationPostInit);
         _bodyQuery = GetEntityQuery<BodyComponent>();
         _buckleQuery = GetEntityQuery<BuckleComponent>();
+        _beaconQuery = GetEntityQuery<FTLBeaconComponent>();
         _ghostQuery = GetEntityQuery<GhostComponent>();
         _physicsQuery = GetEntityQuery<PhysicsComponent>();
         _statusQuery = GetEntityQuery<StatusEffectsComponent>();
@@ -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<Box2>(manager.Fixtures.Count);
-        var immune = new HashSet<EntityUid>();
         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;
                 }