Files
tbd-station-14/Content.Client/Dice/DiceSystem.cs
Plykiya 862a2a744e Predicted dice rolls (#34863)
* Predicted dice rolls

* Removed server-side dice system, make Shared no longer abstract, move visual code to client-side system

* cleanup

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2025-02-14 16:46:25 +01:00

29 lines
812 B
C#

using Content.Shared.Dice;
using Robust.Client.GameObjects;
namespace Content.Client.Dice;
public sealed class DiceSystem : SharedDiceSystem
{
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.LayerGetState(0).Name;
if (state == null)
return;
var prefix = state.Substring(0, state.IndexOf('_'));
sprite.LayerSetState(0, $"{prefix}_{entity.Comp.CurrentValue}");
}
}