Fix exped FTL (#25823)

Also fixed some other stuff I noticed.
This commit is contained in:
metalgearsloth
2024-03-04 17:24:24 +11:00
committed by GitHub
parent 4b6e5deb59
commit c23b3d804e
6 changed files with 33 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ using Content.Shared.Shuttles.UI.MapObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.ResourceManagement; using Robust.Client.ResourceManagement;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
namespace Content.Client.Shuttles.Systems; namespace Content.Client.Shuttles.Systems;
@@ -39,6 +40,12 @@ public sealed partial class ShuttleSystem
return GetCoordinates(exclusion.Coordinates).ToMap(EntityManager, XformSystem); return GetCoordinates(exclusion.Coordinates).ToMap(EntityManager, XformSystem);
case GridMapObject grid: case GridMapObject grid:
var gridXform = Transform(grid.Entity); 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); Entity<PhysicsComponent?, TransformComponent?> gridEnt = (grid.Entity, null, gridXform);
return new MapCoordinates(Maps.GetGridPosition(gridEnt), gridXform.MapID); return new MapCoordinates(Maps.GetGridPosition(gridEnt), gridXform.MapID);
default: default:

View File

@@ -150,8 +150,12 @@ public sealed partial class MapScreen : BoxContainer
_ftlStyle.BackgroundColor = Color.FromHex("#B02E26"); _ftlStyle.BackgroundColor = Color.FromHex("#B02E26");
MapRadar.InFtl = false; MapRadar.InFtl = false;
break; break;
// Fallback in case no FTL state or the likes.
default: default:
throw new NotImplementedException(); SetFTLAllowed(false);
_ftlStyle.BackgroundColor = Color.FromHex("#B02E26");
MapRadar.InFtl = false;
break;
} }
if (IsFTLBlocked()) if (IsFTLBlocked())

View File

@@ -210,6 +210,10 @@ public sealed partial class ShuttleMapControl : BaseShuttleControl
foreach (var mapObj in mapObjects) 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 mapCoords = _shuttles.GetMapCoordinates(mapObj);
var relativePos = matty.Transform(mapCoords.Position); var relativePos = matty.Transform(mapCoords.Position);

View File

@@ -24,6 +24,7 @@ using Content.Shared.Random;
using Content.Shared.Salvage; using Content.Shared.Salvage;
using Content.Shared.Salvage.Expeditions; using Content.Shared.Salvage.Expeditions;
using Content.Shared.Salvage.Expeditions.Modifiers; using Content.Shared.Salvage.Expeditions.Modifiers;
using Content.Shared.Shuttles.Components;
using Content.Shared.Storage; using Content.Shared.Storage;
using Robust.Shared.Collections; using Robust.Shared.Collections;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -91,6 +92,8 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
MetaDataComponent? metadata = null; MetaDataComponent? metadata = null;
var grid = _entManager.EnsureComponent<MapGridComponent>(mapUid); var grid = _entManager.EnsureComponent<MapGridComponent>(mapUid);
var random = new Random(_missionParams.Seed); var random = new Random(_missionParams.Seed);
var destComp = _entManager.AddComponent<FTLDestinationComponent>(mapUid);
destComp.BeaconsOnly = true;
// Setup mission configs // Setup mission configs
// As we go through the config the rating will deplete so we'll go for most important to least important. // As we go through the config the rating will deplete so we'll go for most important to least important.

View File

@@ -54,7 +54,7 @@ public sealed partial class ShuttleConsoleSystem
var angle = args.Angle.Reduced(); var angle = args.Angle.Reduced();
var targetCoordinates = new EntityCoordinates(targetXform.MapUid!.Value, _transform.GetWorldPosition(targetXform)); 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) 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 targetCoordinates = new EntityCoordinates(mapUid, args.Coordinates.Position);
var angle = args.Angle.Reduced(); 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) private void GetBeacons(ref List<ShuttleBeaconObject>? beacons)
@@ -95,7 +95,7 @@ public sealed partial class ShuttleConsoleSystem
{ {
var query = AllEntityQuery<FTLExclusionComponent, TransformComponent>(); 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) if (!comp.Enabled)
continue; continue;
@@ -108,7 +108,7 @@ public sealed partial class ShuttleConsoleSystem
/// <summary> /// <summary>
/// Handles shuttle console FTLs. /// Handles shuttle console FTLs.
/// </summary> /// </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); var consoleUid = GetDroneConsole(ent.Owner);
@@ -136,7 +136,7 @@ public sealed partial class ShuttleConsoleSystem
List<ShuttleExclusionObject>? exclusions = null; List<ShuttleExclusionObject>? exclusions = null;
GetExclusions(ref exclusions); GetExclusions(ref exclusions);
if (!beacon && !_shuttle.FTLFree(shuttleUid.Value, targetCoordinates, targetAngle, exclusions)) if (!_shuttle.FTLFree(shuttleUid.Value, targetCoordinates, targetAngle, exclusions))
{ {
return; return;
} }

View File

@@ -36,7 +36,7 @@ public sealed partial class ShuttleSystem
public const float DefaultTravelTime = 20f; public const float DefaultTravelTime = 20f;
public const float DefaultArrivalTime = 5f; public const float DefaultArrivalTime = 5f;
private const float FTLCooldown = 10f; private const float FTLCooldown = 10f;
public const float FTLMassLimit = 100000f; public const float FTLMassLimit = 300f;
// I'm too lazy to make CVars. // I'm too lazy to make CVars.
@@ -68,9 +68,11 @@ public sealed partial class ShuttleSystem
private const int FTLProximityIterations = 3; private const int FTLProximityIterations = 3;
private readonly HashSet<EntityUid> _lookupEnts = new(); private readonly HashSet<EntityUid> _lookupEnts = new();
private readonly HashSet<EntityUid> _immuneEnts = new();
private EntityQuery<BodyComponent> _bodyQuery; private EntityQuery<BodyComponent> _bodyQuery;
private EntityQuery<BuckleComponent> _buckleQuery; private EntityQuery<BuckleComponent> _buckleQuery;
private EntityQuery<FTLBeaconComponent> _beaconQuery;
private EntityQuery<GhostComponent> _ghostQuery; private EntityQuery<GhostComponent> _ghostQuery;
private EntityQuery<PhysicsComponent> _physicsQuery; private EntityQuery<PhysicsComponent> _physicsQuery;
private EntityQuery<StatusEffectsComponent> _statusQuery; private EntityQuery<StatusEffectsComponent> _statusQuery;
@@ -81,6 +83,7 @@ public sealed partial class ShuttleSystem
SubscribeLocalEvent<StationPostInitEvent>(OnStationPostInit); SubscribeLocalEvent<StationPostInitEvent>(OnStationPostInit);
_bodyQuery = GetEntityQuery<BodyComponent>(); _bodyQuery = GetEntityQuery<BodyComponent>();
_buckleQuery = GetEntityQuery<BuckleComponent>(); _buckleQuery = GetEntityQuery<BuckleComponent>();
_beaconQuery = GetEntityQuery<FTLBeaconComponent>();
_ghostQuery = GetEntityQuery<GhostComponent>(); _ghostQuery = GetEntityQuery<GhostComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>(); _physicsQuery = GetEntityQuery<PhysicsComponent>();
_statusQuery = GetEntityQuery<StatusEffectsComponent>(); _statusQuery = GetEntityQuery<StatusEffectsComponent>();
@@ -206,7 +209,7 @@ public sealed partial class ShuttleSystem
return false; 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"); reason = Loc.GetString("shuttle-console-mass");
return false; return false;
@@ -822,7 +825,6 @@ public sealed partial class ShuttleSystem
// Flatten anything not parented to a grid. // Flatten anything not parented to a grid.
var transform = _physics.GetPhysicsTransform(uid, xform); var transform = _physics.GetPhysicsTransform(uid, xform);
var aabbs = new List<Box2>(manager.Fixtures.Count); var aabbs = new List<Box2>(manager.Fixtures.Count);
var immune = new HashSet<EntityUid>();
var tileSet = new List<(Vector2i, Tile)>(); var tileSet = new List<(Vector2i, Tile)>();
foreach (var fixture in manager.Fixtures.Values) foreach (var fixture in manager.Fixtures.Values)
@@ -842,16 +844,17 @@ public sealed partial class ShuttleSystem
tileSet.Clear(); tileSet.Clear();
_biomes.ReserveTiles(xform.MapUid.Value, aabb, tileSet); _biomes.ReserveTiles(xform.MapUid.Value, aabb, tileSet);
_lookupEnts.Clear(); _lookupEnts.Clear();
_immuneEnts.Clear();
_lookup.GetEntitiesIntersecting(xform.MapUid.Value, aabb, _lookupEnts, LookupFlags.Uncontained); _lookup.GetEntitiesIntersecting(xform.MapUid.Value, aabb, _lookupEnts, LookupFlags.Uncontained);
foreach (var ent in _lookupEnts) foreach (var ent in _lookupEnts)
{ {
if (ent == uid || immune.Contains(ent)) if (ent == uid || _immuneEnts.Contains(ent))
{ {
continue; continue;
} }
if (_ghostQuery.HasComponent(ent)) if (_ghostQuery.HasComponent(ent) || _beaconQuery.HasComponent(ent))
{ {
continue; continue;
} }
@@ -859,7 +862,7 @@ public sealed partial class ShuttleSystem
if (_bodyQuery.TryGetComponent(ent, out var mob)) if (_bodyQuery.TryGetComponent(ent, out var mob))
{ {
var gibs = _bobby.GibBody(ent, body: mob); var gibs = _bobby.GibBody(ent, body: mob);
immune.UnionWith(gibs); _immuneEnts.UnionWith(gibs);
continue; continue;
} }