mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-15 03:31:44 +01:00
[HOTFIX] Stop players from clipping through Windoors (#39564)
* Don't have standing state edit soft fixtures? * Bugfix * Cherry pick acquired --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
committed by
Princess Cheeseballs
parent
936831bfe0
commit
661fc00a1f
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Climbing.Events;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Movement.Systems;
|
||||
@@ -25,6 +26,7 @@ public sealed class StandingStateSystem : EntitySystem
|
||||
SubscribeLocalEvent<StandingStateComponent, AttemptMobTargetCollideEvent>(OnMobTargetCollide);
|
||||
SubscribeLocalEvent<StandingStateComponent, RefreshFrictionModifiersEvent>(OnRefreshFrictionModifiers);
|
||||
SubscribeLocalEvent<StandingStateComponent, TileFrictionEvent>(OnTileFriction);
|
||||
SubscribeLocalEvent<StandingStateComponent, EndClimbEvent>(OnEndClimb);
|
||||
}
|
||||
|
||||
private void OnMobTargetCollide(Entity<StandingStateComponent> ent, ref AttemptMobTargetCollideEvent args)
|
||||
@@ -58,6 +60,15 @@ public sealed class StandingStateSystem : EntitySystem
|
||||
args.Modifier *= entity.Comp.DownFrictionMod;
|
||||
}
|
||||
|
||||
private void OnEndClimb(Entity<StandingStateComponent> entity, ref EndClimbEvent args)
|
||||
{
|
||||
if (entity.Comp.Standing)
|
||||
return;
|
||||
|
||||
// Currently only Climbing also edits fixtures layers like this so this is fine for now.
|
||||
ChangeLayers(entity);
|
||||
}
|
||||
|
||||
public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null)
|
||||
{
|
||||
if (!Resolve(uid, ref standingState, false))
|
||||
@@ -111,17 +122,7 @@ public sealed class StandingStateSystem : EntitySystem
|
||||
_appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Horizontal, appearance);
|
||||
|
||||
// Change collision masks to allow going under certain entities like flaps and tables
|
||||
if (TryComp(uid, out FixturesComponent? fixtureComponent))
|
||||
{
|
||||
foreach (var (key, fixture) in fixtureComponent.Fixtures)
|
||||
{
|
||||
if ((fixture.CollisionMask & StandingCollisionLayer) == 0)
|
||||
continue;
|
||||
|
||||
standingState.ChangedFixtures.Add(key);
|
||||
_physics.SetCollisionMask(uid, key, fixture, fixture.CollisionMask & ~StandingCollisionLayer, manager: fixtureComponent);
|
||||
}
|
||||
}
|
||||
ChangeLayers((uid, standingState));
|
||||
|
||||
// check if component was just added or streamed to client
|
||||
// if true, no need to play sound - mob was down before player could seen that
|
||||
@@ -166,18 +167,44 @@ public sealed class StandingStateSystem : EntitySystem
|
||||
|
||||
_appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Vertical, appearance);
|
||||
|
||||
if (TryComp(uid, out FixturesComponent? fixtureComponent))
|
||||
{
|
||||
foreach (var key in standingState.ChangedFixtures)
|
||||
{
|
||||
if (fixtureComponent.Fixtures.TryGetValue(key, out var fixture))
|
||||
_physics.SetCollisionMask(uid, key, fixture, fixture.CollisionMask | StandingCollisionLayer, fixtureComponent);
|
||||
}
|
||||
}
|
||||
standingState.ChangedFixtures.Clear();
|
||||
RevertLayers((uid, standingState));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: This should be moved to a PhysicsModifierSystem which raises events so multiple systems can modify fixtures at once
|
||||
private void ChangeLayers(Entity<StandingStateComponent, FixturesComponent?> entity)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp2, false))
|
||||
return;
|
||||
|
||||
foreach (var (key, fixture) in entity.Comp2.Fixtures)
|
||||
{
|
||||
if ((fixture.CollisionMask & StandingCollisionLayer) == 0 || !fixture.Hard)
|
||||
continue;
|
||||
|
||||
entity.Comp1.ChangedFixtures.Add(key);
|
||||
_physics.SetCollisionMask(entity, key, fixture, fixture.CollisionMask & ~StandingCollisionLayer, manager: entity.Comp2);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This should be moved to a PhysicsModifierSystem which raises events so multiple systems can modify fixtures at once
|
||||
private void RevertLayers(Entity<StandingStateComponent, FixturesComponent?> entity)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp2, false))
|
||||
{
|
||||
entity.Comp1.ChangedFixtures.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var key in entity.Comp1.ChangedFixtures)
|
||||
{
|
||||
if (entity.Comp2.Fixtures.TryGetValue(key, out var fixture) && fixture.Hard)
|
||||
_physics.SetCollisionMask(entity, key, fixture, fixture.CollisionMask | StandingCollisionLayer, entity.Comp2);
|
||||
}
|
||||
|
||||
entity.Comp1.ChangedFixtures.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
|
||||
Reference in New Issue
Block a user