CatStation/Content.Client/Dice/DiceSystem.cs
Miguel4387 8f92040155
Coin tossing (#44622)
* Ported all I did inside forky to wizden

* Added new weighted coin to the uplink

* fixed the attributions license

* fixed the attributions license but this time for real

* fixed the attributions license but this time for real 2: electric boogaloo

* Changed diamond and gold tail sprites because I was dissatisfied with them

* dice bikeshed

* Changed gold coin tails sprite again, this time to one that makes more sense since I found out THAT ITS A HEAD WHAT THE HELL

* Minor review changes

* Oops All Yaml

* Removed the weighted coin from the uplink

* Fixed that fucking license that I hate

* Added attributions for the tails sprites

* Submodule

* Submodule for real

* Performed requested changes

---------

Co-authored-by: Whatstone <whatston3@gmail.com>
Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
Co-authored-by: AJCM-git <ajcm_mail@disroot.org>
2026-07-28 19:03:57 +00:00

25 lines
864 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!;
[SubscribeLocalEvent]
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?
// If this is ever done keep in mind coin flips also use this system
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}");
}
}