Skip to content

Commit

Permalink
fixed some oopsies with networking
Browse files Browse the repository at this point in the history
  • Loading branch information
gluesniffler committed Sep 20, 2024
1 parent 0d78a12 commit 5f82ac7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 3 additions & 6 deletions Content.Client/Standing/LayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<LayingDownComponent, MoveEvent>(OnMovementInput);
SubscribeNetworkEvent<DownedEvent>(OnDowned);
SubscribeNetworkEvent<DrawDownedEvent>(OnDowned);
SubscribeLocalEvent<LayingDownComponent, StoodEvent>(OnStood);

SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp);
Expand Down Expand Up @@ -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<SpriteComponent>(uid, out var sprite) || !TryComp<LayingDownComponent>(uid, out var component))
return;
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Standing/LayingDownComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
6 changes: 2 additions & 4 deletions Content.Shared/Standing/StandingStateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -165,6 +165,4 @@ public sealed class StoodEvent : EntityEventArgs { }
/// <summary>
/// Raised when an entity is not standing
/// </summary>

[Serializable, NetSerializable]
public sealed class DownedEvent : EntityEventArgs { }

0 comments on commit 5f82ac7

Please sign in to comment.