2021-12-03 11:15:41 -08:00
|
|
|
using Content.Shared.Buckle.Components;
|
2020-07-04 01:28:06 +02:00
|
|
|
using Robust.Client.GameObjects;
|
2020-07-02 23:36:06 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 14:17:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-07-02 23:36:06 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Buckle
|
2020-07-02 23:36:06 +02:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2021-01-11 22:14:01 +11:00
|
|
|
[ComponentReference(typeof(SharedBuckleComponent))]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed 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
|
|
|
|
2021-12-03 11:15:41 -08:00
|
|
|
public override bool TryBuckle(EntityUid user, EntityUid to)
|
2020-10-14 15:24:07 +02:00
|
|
|
{
|
|
|
|
|
// TODO: Prediction
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-16 01:42:03 -07:00
|
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
2020-07-02 23:36:06 +02:00
|
|
|
{
|
2020-11-26 14:33:31 +01:00
|
|
|
if (curState is not BuckleComponentState buckle)
|
2020-07-02 23:36:06 +02:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_buckled = buckle.Buckled;
|
2020-12-18 20:12:53 +01:00
|
|
|
LastEntityBuckledTo = buckle.LastEntityBuckledTo;
|
|
|
|
|
DontCollide = buckle.DontCollide;
|
2021-12-05 18:09:01 +01:00
|
|
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SpriteComponent? ownerSprite))
|
2020-07-04 01:28:06 +02:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_buckled && buckle.DrawDepth.HasValue)
|
|
|
|
|
{
|
|
|
|
|
_originalDrawDepth ??= ownerSprite.DrawDepth;
|
|
|
|
|
ownerSprite.DrawDepth = buckle.DrawDepth.Value;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 11:51:14 +01:00
|
|
|
if (_originalDrawDepth.HasValue && !buckle.DrawDepth.HasValue)
|
2020-07-04 01:28:06 +02:00
|
|
|
{
|
|
|
|
|
ownerSprite.DrawDepth = _originalDrawDepth.Value;
|
|
|
|
|
_originalDrawDepth = null;
|
|
|
|
|
}
|
2020-07-02 23:36:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|