CatStation/Content.Client/Dice/DiceSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

30 lines
935 B
C#

using Content.Shared.Dice;
using Robust.Client.GameObjects;
namespace Content.Client.Dice;
public sealed partial class DiceSystem : SharedDiceSystem
{
[Dependency] private SpriteSystem _sprite = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DiceComponent, AfterAutoHandleStateEvent>(OnDiceAfterHandleState);
}
private void OnDiceAfterHandleState(Entity<DiceComponent> entity, ref AfterAutoHandleStateEvent args)
{
if (!TryComp<SpriteComponent>(entity, out var sprite))
return;
// TODO maybe just move each die to its own RSI?
var state = _sprite.LayerGetRsiState((entity.Owner, sprite), 0).Name;
if (state == null)
return;
var prefix = state.Substring(0, state.IndexOf('_'));
_sprite.LayerSetRsiState((entity.Owner, sprite), 0, $"{prefix}_{entity.Comp.CurrentValue}");
}
}