Fix center of mass mispredict when placing tiles (#37969)
fix COM mispredict
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user