Fix a buckled entity's sprite being drawn over the chair when looking up
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -254,4 +254,3 @@
|
||||
- type: SpeciesVisualizer2D
|
||||
|
||||
- type: HumanoidAppearance
|
||||
|
||||
Reference in New Issue
Block a user