Fix status effect prediction (#8475)
This commit is contained in:
@@ -8,12 +8,14 @@ using Robust.Shared.Physics;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Shared.Standing
|
||||
{
|
||||
public sealed class StandingStateSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly INetManager _netMan = default!;
|
||||
|
||||
// If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited.
|
||||
private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable;
|
||||
@@ -29,11 +31,12 @@ namespace Content.Shared.Standing
|
||||
if (args.Current is not StandingComponentState state) return;
|
||||
|
||||
component.Standing = state.Standing;
|
||||
component.ChangedFixtures = new(state.ChangedFixtures);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, StandingStateComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new StandingComponentState(component.Standing);
|
||||
args.State = new StandingComponentState(component.Standing, component.ChangedFixtures);
|
||||
}
|
||||
|
||||
public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null)
|
||||
@@ -78,9 +81,6 @@ namespace Content.Shared.Standing
|
||||
Dirty(standingState);
|
||||
RaiseLocalEvent(uid, new DownedEvent(), false);
|
||||
|
||||
if (!_gameTiming.IsFirstTimePredicted)
|
||||
return true;
|
||||
|
||||
// Seemed like the best place to put it
|
||||
appearance?.SetData(RotationVisuals.RotationState, RotationState.Horizontal);
|
||||
|
||||
@@ -97,9 +97,11 @@ namespace Content.Shared.Standing
|
||||
}
|
||||
}
|
||||
|
||||
// Currently shit is only downed by server but when it's predicted we can probably only play this on server / client
|
||||
// > no longer true with door crushing. There just needs to be a better way to handle audio prediction.
|
||||
if (playSound)
|
||||
if (!_gameTiming.IsFirstTimePredicted)
|
||||
return true;
|
||||
|
||||
// TODO audio prediction
|
||||
if (playSound && _netMan.IsServer)
|
||||
{
|
||||
SoundSystem.Play(standingState.DownSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.25f));
|
||||
}
|
||||
@@ -151,10 +153,12 @@ namespace Content.Shared.Standing
|
||||
private sealed class StandingComponentState : ComponentState
|
||||
{
|
||||
public bool Standing { get; }
|
||||
public List<string> ChangedFixtures { get; }
|
||||
|
||||
public StandingComponentState(bool standing)
|
||||
public StandingComponentState(bool standing, List<string> changedFixtures)
|
||||
{
|
||||
Standing = standing;
|
||||
ChangedFixtures = changedFixtures;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user