From 5f82ac7d981b1b06d7ddbf2a1d74efe8b512b76a Mon Sep 17 00:00:00 2001 From: gluesniffler Date: Fri, 20 Sep 2024 03:27:58 -0400 Subject: [PATCH] fixed some oopsies with networking --- Content.Client/Standing/LayingDownSystem.cs | 9 +++------ Content.Shared/Standing/LayingDownComponent.cs | 6 ++++++ Content.Shared/Standing/StandingStateSystem.cs | 6 ++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Content.Client/Standing/LayingDownSystem.cs b/Content.Client/Standing/LayingDownSystem.cs index 8b8b51ff7d..1a928d7a1c 100644 --- a/Content.Client/Standing/LayingDownSystem.cs +++ b/Content.Client/Standing/LayingDownSystem.cs @@ -21,7 +21,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnMovementInput); - SubscribeNetworkEvent(OnDowned); + SubscribeNetworkEvent(OnDowned); SubscribeLocalEvent(OnStood); SubscribeNetworkEvent(OnCheckAutoGetUp); @@ -51,12 +51,9 @@ private void OnMovementInput(EntityUid uid, LayingDownComponent component, MoveE sprite.Rotation = Angle.FromDegrees(90); } - private void OnDowned(DownedEvent ev, EntitySessionEventArgs args) + private void OnDowned(DrawDownedEvent args) { - if (!args.SenderSession.AttachedEntity.HasValue) - return; - - var uid = args.SenderSession.AttachedEntity.Value; + var uid = GetEntity(args.Uid); if (!TryComp(uid, out var sprite) || !TryComp(uid, out var component)) return; diff --git a/Content.Shared/Standing/LayingDownComponent.cs b/Content.Shared/Standing/LayingDownComponent.cs index 2b15e4ee0d..363c6f1598 100644 --- a/Content.Shared/Standing/LayingDownComponent.cs +++ b/Content.Shared/Standing/LayingDownComponent.cs @@ -27,3 +27,9 @@ public sealed class CheckAutoGetUpEvent(NetEntity user) : CancellableEntityEvent { public NetEntity User = user; } + +[Serializable, NetSerializable] +public sealed class DrawDownedEvent(NetEntity uid) : EntityEventArgs +{ + public NetEntity Uid = uid; +} diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 8fb9bf5344..724c71fabd 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -69,8 +69,8 @@ public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true RaiseLocalEvent(uid, new DownedEvent(), false); // Raising this event will lower the entity's draw depth to the same as a small mob. - if (_config.GetCVar(CCVars.CrawlUnderTables)) - RaiseNetworkEvent(new DownedEvent(), uid); + if (!_config.GetCVar(CCVars.CrawlUnderTables)) + RaiseNetworkEvent(new DrawDownedEvent(GetNetEntity(uid))); // Seemed like the best place to put it _appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Horizontal, appearance); @@ -165,6 +165,4 @@ public sealed class StoodEvent : EntityEventArgs { } /// /// Raised when an entity is not standing /// - -[Serializable, NetSerializable] public sealed class DownedEvent : EntityEventArgs { }