2020-07-07 00:20:07 +02:00
|
|
|
using Content.Client.GameObjects.Components.Strap;
|
2020-07-07 00:04:30 +02:00
|
|
|
using Content.Client.Interfaces.GameObjects.Components.Interaction;
|
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-07-17 10:43:10 +02:00
|
|
|
namespace Content.Client.GameObjects.Components.Buckle
|
2020-07-02 23:36:06 +02:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2020-07-07 00:04:30 +02:00
|
|
|
public class BuckleComponent : SharedBuckleComponent, IClientDraggable
|
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
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2020-07-07 00:04:30 +02:00
|
|
|
bool IClientDraggable.ClientCanDropOn(CanDropEventArgs eventArgs)
|
|
|
|
|
{
|
|
|
|
|
return eventArgs.Target.HasComponent<StrapComponent>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IClientDraggable.ClientCanDrag(CanDragEventArgs eventArgs)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-07-02 23:36:06 +02:00
|
|
|
}
|
|
|
|
|
}
|