diff --git a/Content.Client/GameObjects/Components/Mobs/BuckleComponent.cs b/Content.Client/GameObjects/Components/Mobs/BuckleComponent.cs index e22b23c0d0..2442fd0d6d 100644 --- a/Content.Client/GameObjects/Components/Mobs/BuckleComponent.cs +++ b/Content.Client/GameObjects/Components/Mobs/BuckleComponent.cs @@ -1,5 +1,7 @@ using Content.Shared.GameObjects.Components.Mobs; +using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.Maths; namespace Content.Client.GameObjects.Components.Mobs { @@ -7,6 +9,7 @@ namespace Content.Client.GameObjects.Components.Mobs public class BuckleComponent : SharedBuckleComponent { private bool _buckled; + private int? _originalDrawDepth; public override void HandleComponentState(ComponentState curState, ComponentState nextState) { @@ -16,6 +19,24 @@ namespace Content.Client.GameObjects.Components.Mobs } _buckled = buckle.Buckled; + + if (!Owner.TryGetComponent(out SpriteComponent ownerSprite)) + { + return; + } + + if (_buckled && buckle.DrawDepth.HasValue) + { + _originalDrawDepth ??= ownerSprite.DrawDepth; + ownerSprite.DrawDepth = buckle.DrawDepth.Value; + return; + } + + if (!_buckled && _originalDrawDepth.HasValue) + { + ownerSprite.DrawDepth = _originalDrawDepth.Value; + _originalDrawDepth = null; + } } protected override bool Buckled => _buckled; diff --git a/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs b/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs index 2e82254ad8..2d54202acc 100644 --- a/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs @@ -14,6 +14,7 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; @@ -286,7 +287,16 @@ namespace Content.Server.GameObjects.Components.Mobs public override ComponentState GetComponentState() { - return new BuckleComponentState(Buckled); + int? drawDepth = null; + + if (BuckledTo != null && + Owner.Transform.WorldRotation.GetCardinalDir() == Direction.North && + BuckledTo.Owner.TryGetComponent(out SpriteComponent strapSprite)) + { + drawDepth = strapSprite.DrawDepth - 1; + } + + return new BuckleComponentState(Buckled, drawDepth); } bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) diff --git a/Content.Shared/GameObjects/Components/Mobs/SharedBuckleComponent.cs b/Content.Shared/GameObjects/Components/Mobs/SharedBuckleComponent.cs index e475b01896..7cb6b760f7 100644 --- a/Content.Shared/GameObjects/Components/Mobs/SharedBuckleComponent.cs +++ b/Content.Shared/GameObjects/Components/Mobs/SharedBuckleComponent.cs @@ -31,12 +31,14 @@ namespace Content.Shared.GameObjects.Components.Mobs [Serializable, NetSerializable] protected sealed class BuckleComponentState : ComponentState { - public BuckleComponentState(bool buckled) : base(ContentNetIDs.BUCKLE) + public BuckleComponentState(bool buckled, int? drawDepth) : base(ContentNetIDs.BUCKLE) { Buckled = buckled; + DrawDepth = drawDepth; } public bool Buckled { get; } + public int? DrawDepth; } [Serializable, NetSerializable] diff --git a/Resources/Prototypes/Entities/Mobs/human.yml b/Resources/Prototypes/Entities/Mobs/human.yml index de07a0f463..222da62c39 100644 --- a/Resources/Prototypes/Entities/Mobs/human.yml +++ b/Resources/Prototypes/Entities/Mobs/human.yml @@ -254,4 +254,3 @@ - type: SpeciesVisualizer2D - type: HumanoidAppearance - \ No newline at end of file