2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Cuffs.Components;
|
2020-08-25 08:54:23 -04:00
|
|
|
|
using Robust.Client.GameObjects;
|
2020-09-13 14:23:52 +02:00
|
|
|
|
using Robust.Client.Graphics;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 14:17:01 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2020-08-25 08:54:23 -04:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Cuffs.Components
|
2020-08-25 08:54:23 -04:00
|
|
|
|
{
|
|
|
|
|
|
[RegisterComponent]
|
2021-02-06 03:11:21 +11:00
|
|
|
|
[ComponentReference(typeof(SharedHandcuffComponent))]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class HandcuffComponent : SharedHandcuffComponent
|
2020-08-25 08:54:23 -04:00
|
|
|
|
{
|
2021-02-06 03:11:21 +11:00
|
|
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
2020-08-25 08:54:23 -04:00
|
|
|
|
{
|
2020-11-26 14:33:31 +01:00
|
|
|
|
if (curState is not HandcuffedComponentState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-08-25 08:54:23 -04:00
|
|
|
|
|
2020-11-26 14:33:31 +01:00
|
|
|
|
if (state.IconState == string.Empty)
|
2020-08-25 08:54:23 -04:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-03 15:53:09 +01:00
|
|
|
|
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(Owner, out var sprite))
|
2020-08-25 08:54:23 -04:00
|
|
|
|
{
|
2020-11-26 14:33:31 +01:00
|
|
|
|
sprite.LayerSetState(0, new RSI.StateId(state.IconState)); // TODO: safety check to see if RSI contains the state?
|
2020-08-25 08:54:23 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|