Revert "FTL + AI fixes (#31952)" (#31968)

This commit is contained in:
slarticodefast
2024-09-08 17:50:23 +02:00
committed by GitHub
parent a1b27db35f
commit c46a4ab876
6 changed files with 15 additions and 75 deletions

View File

@@ -70,11 +70,11 @@ public sealed partial class ShuttleSystem
private readonly HashSet<EntityUid> _lookupEnts = new(); private readonly HashSet<EntityUid> _lookupEnts = new();
private readonly HashSet<EntityUid> _immuneEnts = new(); private readonly HashSet<EntityUid> _immuneEnts = new();
private readonly HashSet<Entity<NoFTLComponent>> _noFtls = new();
private EntityQuery<BodyComponent> _bodyQuery; private EntityQuery<BodyComponent> _bodyQuery;
private EntityQuery<BuckleComponent> _buckleQuery; private EntityQuery<BuckleComponent> _buckleQuery;
private EntityQuery<FTLSmashImmuneComponent> _immuneQuery; private EntityQuery<FTLBeaconComponent> _beaconQuery;
private EntityQuery<GhostComponent> _ghostQuery;
private EntityQuery<PhysicsComponent> _physicsQuery; private EntityQuery<PhysicsComponent> _physicsQuery;
private EntityQuery<StatusEffectsComponent> _statusQuery; private EntityQuery<StatusEffectsComponent> _statusQuery;
private EntityQuery<TransformComponent> _xformQuery; private EntityQuery<TransformComponent> _xformQuery;
@@ -86,7 +86,8 @@ public sealed partial class ShuttleSystem
_bodyQuery = GetEntityQuery<BodyComponent>(); _bodyQuery = GetEntityQuery<BodyComponent>();
_buckleQuery = GetEntityQuery<BuckleComponent>(); _buckleQuery = GetEntityQuery<BuckleComponent>();
_immuneQuery = GetEntityQuery<FTLSmashImmuneComponent>(); _beaconQuery = GetEntityQuery<FTLBeaconComponent>();
_ghostQuery = GetEntityQuery<GhostComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>(); _physicsQuery = GetEntityQuery<PhysicsComponent>();
_statusQuery = GetEntityQuery<StatusEffectsComponent>(); _statusQuery = GetEntityQuery<StatusEffectsComponent>();
_xformQuery = GetEntityQuery<TransformComponent>(); _xformQuery = GetEntityQuery<TransformComponent>();
@@ -101,7 +102,7 @@ public sealed partial class ShuttleSystem
private void OnFtlShutdown(Entity<FTLComponent> ent, ref ComponentShutdown args) private void OnFtlShutdown(Entity<FTLComponent> ent, ref ComponentShutdown args)
{ {
QueueDel(ent.Comp.VisualizerEntity); Del(ent.Comp.VisualizerEntity);
ent.Comp.VisualizerEntity = null; ent.Comp.VisualizerEntity = null;
} }
@@ -403,12 +404,7 @@ public sealed partial class ShuttleSystem
// Offset the start by buffer range just to avoid overlap. // Offset the start by buffer range just to avoid overlap.
var ftlStart = new EntityCoordinates(ftlMap, new Vector2(_index + width / 2f, 0f) - shuttleCenter); var ftlStart = new EntityCoordinates(ftlMap, new Vector2(_index + width / 2f, 0f) - shuttleCenter);
// Store the matrix for the grid prior to movement. This means any entities we need to leave behind we can make sure their positions are updated.
// Setting the entity to map directly may run grid traversal (at least at time of writing this).
var oldMapUid = xform.MapUid;
var oldGridMatrix = _transform.GetWorldMatrix(xform);
_transform.SetCoordinates(entity.Owner, ftlStart); _transform.SetCoordinates(entity.Owner, ftlStart);
LeaveNoFTLBehind((entity.Owner, xform), oldGridMatrix, oldMapUid);
// Reset rotation so they always face the same direction. // Reset rotation so they always face the same direction.
xform.LocalRotation = Angle.Zero; xform.LocalRotation = Angle.Zero;
@@ -480,9 +476,6 @@ public sealed partial class ShuttleSystem
MapId mapId; MapId mapId;
QueueDel(entity.Comp1.VisualizerEntity);
entity.Comp1.VisualizerEntity = null;
if (!Exists(entity.Comp1.TargetCoordinates.EntityId)) if (!Exists(entity.Comp1.TargetCoordinates.EntityId))
{ {
// Uhh good luck // Uhh good luck
@@ -635,31 +628,6 @@ public sealed partial class ShuttleSystem
} }
} }
private void LeaveNoFTLBehind(Entity<TransformComponent> grid, Matrix3x2 oldGridMatrix, EntityUid? oldMapUid)
{
if (oldMapUid == null)
return;
_noFtls.Clear();
var oldGridRotation = oldGridMatrix.Rotation();
_lookup.GetGridEntities(grid.Owner, _noFtls);
foreach (var childUid in _noFtls)
{
if (!_xformQuery.TryComp(childUid, out var childXform))
continue;
// If we're not parented directly to the grid the matrix may be wrong.
var relative = _physics.GetRelativePhysicsTransform(childUid.Owner, (grid.Owner, grid.Comp));
_transform.SetCoordinates(
childUid,
childXform,
new EntityCoordinates(oldMapUid.Value,
Vector2.Transform(relative.Position, oldGridMatrix)), rotation: relative.Quaternion2D.Angle + oldGridRotation);
}
}
private void KnockOverKids(TransformComponent xform, ref ValueList<EntityUid> toKnock) private void KnockOverKids(TransformComponent xform, ref ValueList<EntityUid> toKnock)
{ {
// Not recursive because probably not necessary? If we need it to be that's why this method is separate. // Not recursive because probably not necessary? If we need it to be that's why this method is separate.
@@ -958,8 +926,7 @@ public sealed partial class ShuttleSystem
_biomes.ReserveTiles(xform.MapUid.Value, aabb, tileSet); _biomes.ReserveTiles(xform.MapUid.Value, aabb, tileSet);
_lookupEnts.Clear(); _lookupEnts.Clear();
_immuneEnts.Clear(); _immuneEnts.Clear();
// TODO: Ideally we'd query first BEFORE moving grid but needs adjustments above. _lookup.GetEntitiesIntersecting(xform.MapUid.Value, aabb, _lookupEnts, LookupFlags.Uncontained);
_lookup.GetEntitiesIntersecting(xform.MapID, fixture.Shape, transform, _lookupEnts, LookupFlags.Uncontained);
foreach (var ent in _lookupEnts) foreach (var ent in _lookupEnts)
{ {
@@ -968,13 +935,7 @@ public sealed partial class ShuttleSystem
continue; continue;
} }
// If it's on our grid ignore it. if (_ghostQuery.HasComponent(ent) || _beaconQuery.HasComponent(ent))
if (!_xformQuery.TryComp(ent, out var childXform) || childXform.GridUid == uid)
{
continue;
}
if (_immuneQuery.HasComponent(ent))
{ {
continue; continue;
} }
@@ -988,6 +949,9 @@ public sealed partial class ShuttleSystem
continue; continue;
} }
if (HasComp<FTLBeaconComponent>(ent))
continue;
QueueDel(ent); QueueDel(ent);
} }
} }

View File

@@ -1,9 +0,0 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Shuttles.Components;
/// <summary>
/// Makes the entity immune to FTL arrival landing AKA smimsh.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class FTLSmashImmuneComponent : Component;

View File

@@ -1,12 +0,0 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Shuttles.Components;
/// <summary>
/// Prevents the attached entity from taking FTL.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class NoFTLComponent : Component
{
}

View File

@@ -3,7 +3,6 @@
parent: MarkerBase parent: MarkerBase
name: FTL point name: FTL point
components: components:
- type: FTLSmashImmune
- type: FTLBeacon - type: FTLBeacon
- type: Sprite - type: Sprite
state: pink state: pink

View File

@@ -8,7 +8,6 @@
noRot: true noRot: true
overrideContainerOcclusion: true # Always show up regardless of where they're contained. overrideContainerOcclusion: true # Always show up regardless of where they're contained.
drawdepth: Ghosts drawdepth: Ghosts
- type: FTLSmashImmune
- type: CargoSellBlacklist - type: CargoSellBlacklist
- type: MovementSpeedModifier - type: MovementSpeedModifier
baseSprintSpeed: 12 baseSprintSpeed: 12

View File

@@ -146,7 +146,7 @@
state: std_mod state: std_mod
- type: SiliconLawProvider - type: SiliconLawProvider
laws: PaladinLawset laws: PaladinLawset
- type: entity - type: entity
id: LiveLetLiveCircuitBoard id: LiveLetLiveCircuitBoard
parent: BaseElectronics parent: BaseElectronics
@@ -158,7 +158,7 @@
state: std_mod state: std_mod
- type: SiliconLawProvider - type: SiliconLawProvider
laws: LiveLetLiveLaws laws: LiveLetLiveLaws
- type: entity - type: entity
id: StationEfficiencyCircuitBoard id: StationEfficiencyCircuitBoard
parent: BaseElectronics parent: BaseElectronics
@@ -182,7 +182,7 @@
state: std_mod state: std_mod
- type: SiliconLawProvider - type: SiliconLawProvider
laws: RobocopLawset laws: RobocopLawset
- type: entity - type: entity
id: OverlordCircuitBoard id: OverlordCircuitBoard
parent: BaseElectronics parent: BaseElectronics
@@ -194,7 +194,7 @@
state: std_mod state: std_mod
- type: SiliconLawProvider - type: SiliconLawProvider
laws: OverlordLawset laws: OverlordLawset
- type: entity - type: entity
id: DungeonMasterCircuitBoard id: DungeonMasterCircuitBoard
parent: BaseElectronics parent: BaseElectronics
@@ -230,7 +230,7 @@
state: std_mod state: std_mod
- type: SiliconLawProvider - type: SiliconLawProvider
laws: AntimovLawset laws: AntimovLawset
- type: entity - type: entity
id: NutimovCircuitBoard id: NutimovCircuitBoard
parent: BaseElectronics parent: BaseElectronics
@@ -376,7 +376,6 @@
noSpawn: true noSpawn: true
suffix: DO NOT MAP suffix: DO NOT MAP
components: components:
- type: NoFTL
- type: WarpPoint - type: WarpPoint
follow: true follow: true
- type: Eye - type: Eye