mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* 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
30 lines
935 B
C#
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}");
|
|
}
|
|
}
|