Fix center of mass mispredict when placing tiles (#37969)

fix COM mispredict
This commit is contained in:
slarticodefast
2025-06-01 06:39:45 +02:00
committed by GitHub
parent a241584919
commit e0ce82e1c7
2 changed files with 16 additions and 17 deletions

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Map.Components;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
namespace Content.Shared.Shuttles.Systems;
@@ -15,12 +16,15 @@ public abstract partial class SharedShuttleSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
[Dependency] protected readonly FixtureSystem Fixtures = default!;
[Dependency] protected readonly SharedMapSystem Maps = default!;
[Dependency] protected readonly SharedPhysicsSystem Physics = default!;
[Dependency] protected readonly SharedTransformSystem XformSystem = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public const float FTLRange = 256f;
public const float FTLBufferRange = 8f;
public const float TileDensityMultiplier = 0.5f;
private EntityQuery<MapGridComponent> _gridQuery;
private EntityQuery<PhysicsComponent> _physicsQuery;
@@ -31,11 +35,23 @@ public abstract partial class SharedShuttleSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FixturesComponent, GridFixtureChangeEvent>(OnGridFixtureChange);
_gridQuery = GetEntityQuery<MapGridComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
_xformQuery = GetEntityQuery<TransformComponent>();
}
private void OnGridFixtureChange(EntityUid uid, FixturesComponent manager, GridFixtureChangeEvent args)
{
foreach (var fixture in args.NewFixtures)
{
Physics.SetDensity(uid, fixture.Key, fixture.Value, TileDensityMultiplier, false, manager);
Fixtures.SetRestitution(uid, fixture.Key, fixture.Value, 0.1f, false, manager);
}
}
/// <summary>
/// Returns whether an entity can FTL to the specified map.
/// </summary>