* 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>
29 lines
812 B
C#
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}");
|
|
}
|
|
}
|