Skip to content

Commit

Permalink
фиксы синхронизации системы лежания
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Nov 23, 2024
1 parent 7a3d7a2 commit dbddd7d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
26 changes: 25 additions & 1 deletion Content.Client/Backmen/Standing/LayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,43 @@ public sealed class LayingDownSystem : SharedLayingDownSystem
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedRotationVisualsSystem _rotationVisuals = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<LayingDownComponent, MoveEvent>(OnMovementInput);
SubscribeLocalEvent<LayingDownComponent, AfterAutoHandleStateEvent>(OnChangeDraw);
SubscribeLocalEvent<StandingStateComponent,AfterAutoHandleStateEvent>(OnChangeStanding);

_cfg.OnValueChanged(CCVars.AutoGetUp, b => _autoGetUp = b, true);

//SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp);
}

private void OnChangeStanding(Entity<StandingStateComponent> ent, ref AfterAutoHandleStateEvent args)
{
if(_animation.HasRunningAnimation(ent, "rotate"))
return;

if (!TryComp<SpriteComponent>(ent, out var sprite))
{
return;
}

if (ent.Comp.Standing)
{
sprite.Rotation = Angle.Zero;
return;
}

if (sprite.Rotation != Angle.FromDegrees(270) && sprite.Rotation != Angle.FromDegrees(90))
{
sprite.Rotation = Angle.FromDegrees(270);
}
}

private void OnChangeDraw(Entity<LayingDownComponent> ent, ref AfterAutoHandleStateEvent args)
{
if(!TryComp<SpriteComponent>(ent, out var sprite))
Expand All @@ -44,7 +68,7 @@ private void OnChangeDraw(Entity<LayingDownComponent> ent, ref AfterAutoHandleSt
{
sprite.DrawDepth = (int) Shared.DrawDepth.DrawDepth.SmallMobs;
}
else if (!ent.Comp.DrawDowned)
else if (!ent.Comp.DrawDowned && sprite.DrawDepth == (int) Shared.DrawDepth.DrawDepth.SmallMobs)
{
sprite.DrawDepth = (int) Shared.DrawDepth.DrawDepth.Mobs;
}
Expand Down
14 changes: 6 additions & 8 deletions Content.Shared/Backmen/Standing/SharedLayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;

namespace Content.Shared.Backmen.Standing;

Expand All @@ -53,6 +54,7 @@ public abstract class SharedLayingDownSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;

[Dependency] private readonly IConfigurationManager _config = default!;

Expand Down Expand Up @@ -195,15 +197,10 @@ private void ToggleStanding(ICommonSession? session)
return;
}

if (_net.IsServer)
{
RaiseNetworkEvent(new ChangeLayingDownEvent(), Filter.Pvs(session.AttachedEntity.Value));
}
else
{
RaisePredictiveEvent(new ChangeLayingDownEvent());
}
if (!_timing.IsFirstTimePredicted)
return;

RaisePredictiveEvent(new ChangeLayingDownEvent());
}

public virtual void AutoGetUp(Entity<LayingDownComponent> ent)
Expand Down Expand Up @@ -339,6 +336,7 @@ standingState.CurrentState is not StandingState.Lying ||
return false;

standingState.CurrentState = StandingState.GettingUp;
Dirty(uid, standingState);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Standing/StandingStateComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

namespace Content.Shared.Standing;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
public sealed partial class StandingStateComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public SoundSpecifier DownSound { get; private set; } = new SoundCollectionSpecifier("BodyFall");

// BACKMEN EDIT START
[DataField, AutoNetworkedField]
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public StandingState CurrentState { get; set; } = StandingState.Standing;
// BACKMEN EDIT END

Expand Down

0 comments on commit dbddd7d

Please sign in to comment.