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.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:

View 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())

View 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);

View 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.

View 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;
}

View 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;
}