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>
This commit is contained in:
Plykiya
2025-02-14 07:46:25 -08:00
committed by GitHub
parent 63b9255e71
commit 862a2a744e
4 changed files with 45 additions and 65 deletions

View File

@@ -5,17 +5,24 @@ namespace Content.Client.Dice;
public sealed class DiceSystem : SharedDiceSystem
{
protected override void UpdateVisuals(EntityUid uid, DiceComponent? die = null)
public override void Initialize()
{
if (!Resolve(uid, ref die) || !TryComp(uid, out SpriteComponent? sprite))
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 diue to its own RSI?
// 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}_{die.CurrentValue}");
sprite.LayerSetState(0, $"{prefix}_{entity.Comp.CurrentValue}");
}
}