Files
crystall-punk-14/Content.Client/Dice/DiceSystem.cs

29 lines
812 B
C#
Raw Normal View History

2023-01-21 12:51:26 +13:00
using Content.Shared.Dice;
using Robust.Client.GameObjects;
namespace Content.Client.Dice;
public sealed class DiceSystem : SharedDiceSystem
{
public override void Initialize()
2023-01-21 12:51:26 +13:00
{
base.Initialize();
SubscribeLocalEvent<DiceComponent, AfterAutoHandleStateEvent>(OnDiceAfterHandleState);
}
private void OnDiceAfterHandleState(Entity<DiceComponent> entity, ref AfterAutoHandleStateEvent args)
{
if (!TryComp<SpriteComponent>(entity, out var sprite))
2023-01-21 12:51:26 +13:00
return;
// TODO maybe just move each die to its own RSI?
2023-01-21 12:51:26 +13:00
var state = sprite.LayerGetState(0).Name;
if (state == null)
return;
var prefix = state.Substring(0, state.IndexOf('_'));
sprite.LayerSetState(0, $"{prefix}_{entity.Comp.CurrentValue}");
2023-01-21 12:51:26 +13:00
}
}