From 1196b9e268db8be0231509eea8693a6ab92a2cef Mon Sep 17 00:00:00 2001 From: Sidzaru Date: Thu, 25 Dec 2025 19:59:41 +0300 Subject: [PATCH] hyperDice & arrowRoulette (#3291) Co-authored-by: Sidzaru --- Content.Client/Dice/DiceSystem.cs | 5 +- .../_Sunrise/Dice/ChangeDiceUserInterface.cs | 42 ++++++ .../_Sunrise/Dice/ChangeDiceWindow.cs | 38 ++++++ .../_Sunrise/Dice/ChangeDiceWindow.xaml | 12 ++ .../_Sunrise/Fun/SpinnableSystem.cs | 128 ++++++++++++++++++ Content.Shared/Dice/DiceComponent.cs | 18 ++- Content.Shared/Dice/SharedDiceSystem.cs | 26 +++- .../_Sunrise/Dice/SharedChangeDice.cs | 37 +++++ .../_Sunrise/Dice/SharedChangeDiceSystem.cs | 37 +++++ .../_Sunrise/Fun/SpinnableComponent.cs | 33 +++++ .../_sunrise/entities/objects/fun/dice.ftl | 4 + .../entities/objects/fun/spinArrow.ftl | 13 ++ .../_strings/_sunrise/dice/dice-component.ftl | 2 + .../_strings/_sunrise/ui/change-sides.ftl | 13 ++ .../ru-RU/_Sunrise/_strings/change-sides.ftl | 13 ++ .../_Sunrise/_strings/dice-component.ftl | 1 + .../_sunrise/entities/objects/fun/dice.ftl | 5 + .../entities/objects/fun/spinArrow.ftl | 11 ++ .../VendingMachines/Inventories/games.yml | 2 + .../Entities/Objects/Fun/dice_bag.yml | 1 + .../Entities/Objects/Fun/arrow_roulette.yml | 48 +++++++ .../_Sunrise/Entities/Objects/Fun/dice.yml | 36 +++++ .../_Sunrise/Objects/Fun/dice.rsi/icon.png | Bin 0 -> 16959 bytes .../_Sunrise/Objects/Fun/dice.rsi/meta.json | 14 ++ .../Fun/lucky_arrow.rsi/arrow_blue.png | Bin 0 -> 762 bytes .../Fun/lucky_arrow.rsi/arrow_blue1.png | Bin 0 -> 21138 bytes .../Objects/Fun/lucky_arrow.rsi/arrow_red.png | Bin 0 -> 764 bytes .../Fun/lucky_arrow.rsi/arrow_red2.png | Bin 0 -> 21147 bytes .../Objects/Fun/lucky_arrow.rsi/meta.json | 19 +++ .../inhand_left_blue.png | Bin 0 -> 19961 bytes .../inhand_left_red.png | Bin 0 -> 21177 bytes .../inhand_right_blue.png | Bin 0 -> 20062 bytes .../inhand_right_red.png | Bin 0 -> 21244 bytes .../Fun/lucky_arrow_inhand.rsi/meta.json | 27 ++++ 34 files changed, 581 insertions(+), 4 deletions(-) create mode 100644 Content.Client/_Sunrise/Dice/ChangeDiceUserInterface.cs create mode 100644 Content.Client/_Sunrise/Dice/ChangeDiceWindow.cs create mode 100644 Content.Client/_Sunrise/Dice/ChangeDiceWindow.xaml create mode 100644 Content.Server/_Sunrise/Fun/SpinnableSystem.cs create mode 100644 Content.Shared/_Sunrise/Dice/SharedChangeDice.cs create mode 100644 Content.Shared/_Sunrise/Dice/SharedChangeDiceSystem.cs create mode 100644 Content.Shared/_Sunrise/Fun/SpinnableComponent.cs create mode 100644 Resources/Locale/en-US/_prototypes/_sunrise/entities/objects/fun/dice.ftl create mode 100644 Resources/Locale/en-US/_prototypes/_sunrise/entities/objects/fun/spinArrow.ftl create mode 100644 Resources/Locale/en-US/_strings/_sunrise/dice/dice-component.ftl create mode 100644 Resources/Locale/en-US/_strings/_sunrise/ui/change-sides.ftl create mode 100644 Resources/Locale/ru-RU/_Sunrise/_strings/change-sides.ftl create mode 100644 Resources/Locale/ru-RU/_Sunrise/_strings/dice-component.ftl create mode 100644 Resources/Locale/ru-RU/_prototypes/_sunrise/entities/objects/fun/dice.ftl create mode 100644 Resources/Locale/ru-RU/_prototypes/_sunrise/entities/objects/fun/spinArrow.ftl create mode 100644 Resources/Prototypes/_Sunrise/Entities/Objects/Fun/arrow_roulette.yml create mode 100644 Resources/Prototypes/_Sunrise/Entities/Objects/Fun/dice.yml create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/dice.rsi/icon.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/dice.rsi/meta.json create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow.rsi/arrow_blue.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow.rsi/arrow_blue1.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow.rsi/arrow_red.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow.rsi/arrow_red2.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow.rsi/meta.json create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow_inhand.rsi/inhand_left_blue.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow_inhand.rsi/inhand_left_red.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow_inhand.rsi/inhand_right_blue.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow_inhand.rsi/inhand_right_red.png create mode 100644 Resources/Textures/_Sunrise/Objects/Fun/lucky_arrow_inhand.rsi/meta.json diff --git a/Content.Client/Dice/DiceSystem.cs b/Content.Client/Dice/DiceSystem.cs index 2de552f375..224f5e5b0c 100644 --- a/Content.Client/Dice/DiceSystem.cs +++ b/Content.Client/Dice/DiceSystem.cs @@ -23,7 +23,10 @@ public sealed class DiceSystem : SharedDiceSystem var state = _sprite.LayerGetRsiState((entity.Owner, sprite), 0).Name; if (state == null) return; - + // Sunrise-Edit + if (entity.Comp.IsNotStandardDice) + return; + // Sunrise-Edit-End var prefix = state.Substring(0, state.IndexOf('_')); _sprite.LayerSetRsiState((entity.Owner, sprite), 0, $"{prefix}_{entity.Comp.CurrentValue}"); } diff --git a/Content.Client/_Sunrise/Dice/ChangeDiceUserInterface.cs b/Content.Client/_Sunrise/Dice/ChangeDiceUserInterface.cs new file mode 100644 index 0000000000..d01d8afd66 --- /dev/null +++ b/Content.Client/_Sunrise/Dice/ChangeDiceUserInterface.cs @@ -0,0 +1,42 @@ +using Content.Shared._Sunrise.Dice; +using Content.Shared.FixedPoint; +using JetBrains.Annotations; +using Robust.Client.UserInterface; + +namespace Content.Client._Sunrise.Dice.UI +{ + [UsedImplicitly] + public sealed class ChangeDiceUserInterface : BoundUserInterface + { + [Dependency] private readonly ILogManager _logManager = default!; + private IEntityManager _entManager; + private EntityUid _owner; + [ViewVariables] + private ChangeDiceWindow? _window; + + public ChangeDiceUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + _owner = owner; + _entManager = IoCManager.Resolve(); + } + + protected override void Open() + { + base.Open(); + _window = this.CreateWindow(); + _window.OpenCentered(); + + _window.ApplyButton.OnPressed += _ => + { + if (int.TryParse(_window.AmountStartLineEdit.Text, out var x) && int.TryParse(_window.AmountEndLineEdit.Text, out var y)) + { + SendMessage(new ChangeDiceSetValueMessage(FixedPoint2.New(x), FixedPoint2.New(y))); + _window.Close(); + } + }; + } + } +} + + + diff --git a/Content.Client/_Sunrise/Dice/ChangeDiceWindow.cs b/Content.Client/_Sunrise/Dice/ChangeDiceWindow.cs new file mode 100644 index 0000000000..23b0c4a846 --- /dev/null +++ b/Content.Client/_Sunrise/Dice/ChangeDiceWindow.cs @@ -0,0 +1,38 @@ +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.CustomControls; +using Robust.Client.UserInterface.XAML; + +namespace Content.Client._Sunrise.Dice +{ + [GenerateTypedNameReferences] + public sealed partial class ChangeDiceWindow : DefaultWindow + { + public ChangeDiceWindow() + { + RobustXamlLoader.Load(this); + AmountStartLineEdit.OnTextChanged += OnValueChanged; + AmountEndLineEdit.OnTextChanged += OnValueChanged; + } + + private void OnValueChanged(LineEdit.LineEditEventArgs args) + { + if (int.TryParse(AmountStartLineEdit.Text, out var startAmount) && + int.TryParse(AmountEndLineEdit.Text, out var endAmount)) + { + if (startAmount < 1 || endAmount > 1000000 || endAmount < startAmount) + { + ApplyButton.Disabled = true; + } + else + { + ApplyButton.Disabled = false; + } + } + else + { + ApplyButton.Disabled = true; + } + } + } +} diff --git a/Content.Client/_Sunrise/Dice/ChangeDiceWindow.xaml b/Content.Client/_Sunrise/Dice/ChangeDiceWindow.xaml new file mode 100644 index 0000000000..dc41ea69ee --- /dev/null +++ b/Content.Client/_Sunrise/Dice/ChangeDiceWindow.xaml @@ -0,0 +1,12 @@ + + + + + + +