Skip to content

Commit

Permalink
Fix allcomps test
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth committed Aug 23, 2024
1 parent 7871572 commit e6a8305
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Robust.Shared/Physics/Systems/FixturesChangeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ public sealed class FixturesChangeSystem : EntitySystem
[Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;

private EntityQuery<FixturesComponent> _fixturesQuery;
private EntityQuery<PhysicsComponent> _physicsQuery;

public override void Initialize()
{
base.Initialize();
_fixturesQuery = GetEntityQuery<FixturesComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<FixturesChangeComponent, ComponentStartup>(OnChangeStartup);
SubscribeLocalEvent<FixturesChangeComponent, ComponentShutdown>(OnChangeShutdown);
}

private void OnChangeStartup(Entity<FixturesChangeComponent> ent, ref ComponentStartup args)
{
if (!_physicsQuery.TryComp(ent, out var physics) || !_fixturesQuery.TryComp(ent, out var fixtures))
return;

foreach (var (id, fixture) in ent.Comp.Fixtures)
{
_fixtures.TryCreateFixture(ent.Owner,
Expand All @@ -28,11 +36,13 @@ private void OnChangeStartup(Entity<FixturesChangeComponent> ent, ref ComponentS
fixture.CollisionLayer,
fixture.CollisionMask,
fixture.Friction,
fixture.Restitution);
fixture.Restitution,
manager: fixtures,
body: physics);
}

// TODO: Fixture creation should be handling this.
_physics.WakeBody(ent.Owner);
_physics.WakeBody(ent.Owner, manager: fixtures, body: physics);
}

private void OnChangeShutdown(Entity<FixturesChangeComponent> ent, ref ComponentShutdown args)
Expand Down

0 comments on commit e6a8305

Please sign in to comment.