27 lines
825 B
C#
27 lines
825 B
C#
using Content.Shared.Dice;
|
|
using Content.Shared.Popups;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Dice;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class DiceSystem : SharedDiceSystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
|
|
public override void Roll(EntityUid uid, DiceComponent? die = null)
|
|
{
|
|
if (!Resolve(uid, ref die))
|
|
return;
|
|
|
|
var roll = _random.Next(1, die.Sides);
|
|
SetCurrentSide(uid, roll, die);
|
|
|
|
_popup.PopupEntity(Loc.GetString("dice-component-on-roll-land", ("die", uid), ("currentSide", die.CurrentValue)), uid);
|
|
_audio.PlayPvs(die.Sound, uid);
|
|
}
|
|
}
|