Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions Content.Client/Standing/LayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override void Initialize()

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

SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp);
}
Expand Down Expand Up @@ -54,24 +54,21 @@ private void OnMovementInput(EntityUid uid, LayingDownComponent component, MoveE
private void OnDowned(DrawDownedEvent args)
{
var uid = GetEntity(args.Uid);

if (!TryComp<SpriteComponent>(uid, out var sprite)
if (!TryComp<SpriteComponent>(uid, out var sprite)
|| !TryComp<LayingDownComponent>(uid, out var component))
return;

if (!component.OriginalDrawDepth.HasValue)
component.OriginalDrawDepth = sprite.DrawDepth;

sprite.DrawDepth = (int) DrawDepth.SmallMobs;
sprite.DrawDepth = component.CrawlingDrawDepth;
}

private void OnStood(EntityUid uid, LayingDownComponent component, StoodEvent args)
private void OnStood(DrawStoodEvent args)
{
if (!TryComp<SpriteComponent>(uid, out var sprite)
|| !component.OriginalDrawDepth.HasValue)
var uid = GetEntity(args.Uid);
if (!TryComp<SpriteComponent>(uid, out var sprite)
|| !TryComp<LayingDownComponent>(uid, out var component))
return;

sprite.DrawDepth = component.OriginalDrawDepth.Value;
sprite.DrawDepth = component.NormalDrawDepth;
}

private void OnCheckAutoGetUp(CheckAutoGetUpEvent ev, EntitySessionEventArgs args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override bool Perform(InteractionArgs args, InteractionVerbPrototype prot
if (state.CurrentState == StandingState.Lying && MakeStanding)
return stateSystem.Stand(args.Target);
else if (state.CurrentState == StandingState.Standing && MakeLaying)
return stateSystem.Down(args.Target);
return stateSystem.Down(args.Target, setDrawDepth: true);

return false;
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ private void OnStateEnteredSubscribers(EntityUid target, MobStateComponent compo
_appearance.SetData(target, MobStateVisuals.State, MobState.Alive);
break;
case MobState.Critical:
_standing.Down(target);
_standing.Down(target, setDrawDepth: true);
_appearance.SetData(target, MobStateVisuals.State, MobState.Critical);
break;
case MobState.Dead:
EnsureComp<CollisionWakeComponent>(target);
_standing.Down(target);
_standing.Down(target, setDrawDepth: true);

if (_standing.IsDown(target) && TryComp<PhysicsComponent>(target, out var physics))
{
Expand Down
12 changes: 11 additions & 1 deletion Content.Shared/Standing/LayingDownComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Content.Shared.DrawDepth;

namespace Content.Shared.Standing;

Expand All @@ -16,7 +17,10 @@ public sealed partial class LayingDownComponent : Component
public bool AutoGetUp;

[DataField, AutoNetworkedField]
public int? OriginalDrawDepth { get; set; }
public int NormalDrawDepth = (int) DrawDepth.DrawDepth.Mobs;

[DataField, AutoNetworkedField]
public int CrawlingDrawDepth = (int) DrawDepth.DrawDepth.SmallMobs;
}

[Serializable, NetSerializable]
Expand All @@ -33,3 +37,9 @@ public sealed class DrawDownedEvent(NetEntity uid) : EntityEventArgs
{
public NetEntity Uid = uid;
}

[Serializable, NetSerializable]
public sealed class DrawStoodEvent(NetEntity uid) : EntityEventArgs
{
public NetEntity Uid = uid;
}
2 changes: 1 addition & 1 deletion Content.Shared/Standing/SharedLayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public bool TryLieDown(EntityUid uid, LayingDownComponent? layingDown = null, St
return false;
}

_standing.Down(uid, true, behavior != DropHeldItemsBehavior.NoDrop, standingState);
_standing.Down(uid, true, behavior != DropHeldItemsBehavior.NoDrop, standingState, setDrawDepth: true);
return true;
}
}
Expand Down
9 changes: 7 additions & 2 deletions Content.Shared/Standing/StandingStateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null)
public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true,
StandingStateComponent? standingState = null,
AppearanceComponent? appearance = null,
HandsComponent? hands = null)
HandsComponent? hands = null,
bool setDrawDepth = false)
{
// TODO: This should actually log missing comps...
if (!Resolve(uid, ref standingState, false))
Expand Down Expand Up @@ -69,7 +70,7 @@ 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))
if (_config.GetCVar(CCVars.CrawlUnderTables) && setDrawDepth)
RaiseNetworkEvent(new DrawDownedEvent(GetNetEntity(uid)));

// Seemed like the best place to put it
Expand Down Expand Up @@ -128,6 +129,10 @@ public bool Stand(EntityUid uid,
Dirty(uid, standingState);
RaiseLocalEvent(uid, new StoodEvent(), false);

// Raising this event will increase the entity's draw depth to a normal mob's.
if (_config.GetCVar(CCVars.CrawlUnderTables))
RaiseNetworkEvent(new DrawStoodEvent(GetNetEntity(uid)));

_appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Vertical, appearance);

if (TryComp(uid, out FixturesComponent? fixtureComponent))
Expand Down