Fix standing-state collisions resetting (#7469)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,13 @@ namespace Content.Shared.Climbing
|
|||||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||||
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of fixtures that had vault-impassable prior to an entity being downed. Required when re-adding the
|
||||||
|
/// collision mask.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("vaultImpassableFixtures")]
|
||||||
|
public List<string> VaultImpassableFixtures = new();
|
||||||
|
|
||||||
protected bool IsOnClimbableThisFrame
|
protected bool IsOnClimbableThisFrame
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -78,17 +85,25 @@ namespace Content.Shared.Climbing
|
|||||||
// Hope the mob has one fixture
|
// Hope the mob has one fixture
|
||||||
if (!_entMan.TryGetComponent<FixturesComponent>(Owner, out var fixturesComponent) || fixturesComponent.Deleted) return;
|
if (!_entMan.TryGetComponent<FixturesComponent>(Owner, out var fixturesComponent) || fixturesComponent.Deleted) return;
|
||||||
|
|
||||||
foreach (var fixture in fixturesComponent.Fixtures.Values)
|
if (value)
|
||||||
{
|
{
|
||||||
if (value)
|
foreach (var (key, fixture) in fixturesComponent.Fixtures)
|
||||||
{
|
{
|
||||||
|
if ((fixture.CollisionMask & (int) CollisionGroup.VaultImpassable) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
VaultImpassableFixtures.Add(key);
|
||||||
fixture.CollisionMask &= ~(int) CollisionGroup.VaultImpassable;
|
fixture.CollisionMask &= ~(int) CollisionGroup.VaultImpassable;
|
||||||
}
|
}
|
||||||
else
|
return;
|
||||||
{
|
|
||||||
fixture.CollisionMask |= (int) CollisionGroup.VaultImpassable;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var key in VaultImpassableFixtures)
|
||||||
|
{
|
||||||
|
if (fixturesComponent.Fixtures.TryGetValue(key, out var fixture))
|
||||||
|
fixture.CollisionMask |= (int) CollisionGroup.VaultImpassable;
|
||||||
|
}
|
||||||
|
VaultImpassableFixtures.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Shared.Sound;
|
using Content.Shared.Sound;
|
||||||
using Robust.Shared.Analyzers;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Players;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Shared.Standing
|
namespace Content.Shared.Standing
|
||||||
{
|
{
|
||||||
@@ -18,10 +13,16 @@ namespace Content.Shared.Standing
|
|||||||
[DataField("downSoundCollection")]
|
[DataField("downSoundCollection")]
|
||||||
public SoundSpecifier DownSoundCollection { get; } = new SoundCollectionSpecifier("BodyFall");
|
public SoundSpecifier DownSoundCollection { get; } = new SoundCollectionSpecifier("BodyFall");
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
[DataField("standing")]
|
[DataField("standing")]
|
||||||
public bool Standing { get; set; } = true;
|
public bool Standing { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of fixtures that had vault-impassable prior to an entity being downed. Required when re-adding the
|
||||||
|
/// collision mask.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("vaultImpassableFixtures")]
|
||||||
|
public List<string> VaultImpassableFixtures = new();
|
||||||
|
|
||||||
public override ComponentState GetComponentState()
|
public override ComponentState GetComponentState()
|
||||||
{
|
{
|
||||||
return new StandingComponentState(Standing);
|
return new StandingComponentState(Standing);
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using System;
|
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Rotation;
|
using Content.Shared.Rotation;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
@@ -55,7 +52,7 @@ namespace Content.Shared.Standing
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
standingState.Standing = false;
|
standingState.Standing = false;
|
||||||
standingState.Dirty();
|
Dirty(standingState);
|
||||||
RaiseLocalEvent(uid, new DownedEvent(), false);
|
RaiseLocalEvent(uid, new DownedEvent(), false);
|
||||||
|
|
||||||
if (!_gameTiming.IsFirstTimePredicted)
|
if (!_gameTiming.IsFirstTimePredicted)
|
||||||
@@ -66,8 +63,12 @@ namespace Content.Shared.Standing
|
|||||||
|
|
||||||
if (TryComp(uid, out FixturesComponent? fixtureComponent))
|
if (TryComp(uid, out FixturesComponent? fixtureComponent))
|
||||||
{
|
{
|
||||||
foreach (var fixture in fixtureComponent.Fixtures.Values)
|
foreach (var (key, fixture) in fixtureComponent.Fixtures)
|
||||||
{
|
{
|
||||||
|
if ((fixture.CollisionMask & (int) CollisionGroup.VaultImpassable) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
standingState.VaultImpassableFixtures.Add(key);
|
||||||
fixture.CollisionMask &= ~(int) CollisionGroup.VaultImpassable;
|
fixture.CollisionMask &= ~(int) CollisionGroup.VaultImpassable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,11 +111,13 @@ namespace Content.Shared.Standing
|
|||||||
|
|
||||||
if (TryComp(uid, out FixturesComponent? fixtureComponent))
|
if (TryComp(uid, out FixturesComponent? fixtureComponent))
|
||||||
{
|
{
|
||||||
foreach (var fixture in fixtureComponent.Fixtures.Values)
|
foreach (var key in standingState.VaultImpassableFixtures)
|
||||||
{
|
{
|
||||||
fixture.CollisionMask |= (int) CollisionGroup.VaultImpassable;
|
if (fixtureComponent.Fixtures.TryGetValue(key, out var fixture))
|
||||||
|
fixture.CollisionMask |= (int) CollisionGroup.VaultImpassable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
standingState.VaultImpassableFixtures.Clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user