2020-07-17 10:43:10 +02:00
|
|
|
using Content.Shared.GameObjects.Components.Buckle;
|
2020-07-04 01:28:06 +02:00
|
|
|
using Robust.Client.GameObjects;
|
2020-07-02 23:36:06 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-10-14 15:24:07 +02:00
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
2020-07-02 23:36:06 +02:00
|
|
|
|
2020-07-17 10:43:10 +02:00
|
|
|
namespace Content.Client.GameObjects.Components.Buckle
|
2020-07-02 23:36:06 +02:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2020-10-14 15:24:07 +02:00
|
|
|
public class BuckleComponent : SharedBuckleComponent
|
2020-07-02 23:36:06 +02:00
|
|
|
{
|
|
|
|
|
private bool _buckled;
|
2020-07-04 01:28:06 +02:00
|
|
|
private int? _originalDrawDepth;
|
2020-07-02 23:36:06 +02:00
|
|
|
|
2020-07-17 10:43:10 +02:00
|
|
|
public override bool Buckled => _buckled;
|
2020-07-02 23:36:06 +02:00
|
|
|
|
2020-10-14 15:24:07 +02:00
|
|
|
public override bool TryBuckle(IEntity user, IEntity to)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Prediction
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-02 23:36:06 +02:00
|
|
|
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
|
|
|
|
{
|
|
|
|
|
if (!(curState is BuckleComponentState buckle))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_buckled = buckle.Buckled;
|
2020-07-04 01:28:06 +02:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2020-07-02 23:36:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|