diff --git a/Content.Client/GameObjects/Components/Kitchen/MicrowaveBoundUserInterface.cs b/Content.Client/GameObjects/Components/Kitchen/MicrowaveBoundUserInterface.cs index 94fa205bb2..68ebf1b5e7 100644 --- a/Content.Client/GameObjects/Components/Kitchen/MicrowaveBoundUserInterface.cs +++ b/Content.Client/GameObjects/Components/Kitchen/MicrowaveBoundUserInterface.cs @@ -16,6 +16,10 @@ namespace Content.Client.GameObjects.Components.Kitchen { public class MicrowaveBoundUserInterface : BoundUserInterface { +#pragma warning disable 649 + [Dependency] private readonly IEntityManager _entityManager; + [Dependency] private readonly IPrototypeManager _prototypeManager; +#pragma warning restore 649 private MicrowaveMenu _menu; private Dictionary _solids = new Dictionary(); @@ -38,7 +42,7 @@ namespace Content.Client.GameObjects.Components.Kitchen _menu.OnCookTimeSelected += args => { var actualButton = args.Button as Button; - var newTime = (byte) int.Parse(actualButton.Text); + var newTime = (uint) int.Parse(actualButton.Text); _menu.VisualCookTime = newTime; SendMessage(new SharedMicrowaveComponent.MicrowaveSelectCookTimeMessage(newTime)); }; @@ -75,7 +79,7 @@ namespace Content.Client.GameObjects.Components.Kitchen _menu.IngredientsList.Clear(); foreach (var item in reagents) { - IoCManager.Resolve().TryIndex(item.ReagentId, out ReagentPrototype proto); + _prototypeManager.TryIndex(item.ReagentId, out ReagentPrototype proto); _menu.IngredientsList.AddItem($"{item.Quantity} {proto.Name}"); } @@ -83,7 +87,7 @@ namespace Content.Client.GameObjects.Components.Kitchen _solids.Clear(); foreach (var entityID in solids) { - var entity = IoCManager.Resolve().GetEntity(entityID); + var entity = _entityManager.GetEntity(entityID); if (entity.TryGetComponent(out IconComponent icon)) { diff --git a/Content.Client/GameObjects/Components/Kitchen/MicrowaveMenu.cs b/Content.Client/GameObjects/Components/Kitchen/MicrowaveMenu.cs index 1c7e2e8ce9..f267c30371 100644 --- a/Content.Client/GameObjects/Components/Kitchen/MicrowaveMenu.cs +++ b/Content.Client/GameObjects/Components/Kitchen/MicrowaveMenu.cs @@ -1,5 +1,6 @@ using System; using Robust.Client.Graphics.Drawing; +using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.Localization; @@ -15,7 +16,7 @@ namespace Content.Client.GameObjects.Components.Kitchen public event Action OnCookTimeSelected; - public byte VisualCookTime { get; set; } + public uint VisualCookTime = 1; public Button StartButton { get;} public Button EjectButton { get;} @@ -81,6 +82,13 @@ namespace Content.Client.GameObjects.Components.Kitchen buttonGridContainer.AddChild(StartButton); buttonGridContainer.AddChild(EjectButton); vSplit.AddChild(buttonGridContainer); + + //Padding + vSplit.AddChild(new Control + { + CustomMinimumSize = (0, 15), + SizeFlagsVertical = SizeFlags.Fill, + }); CookTimeButtonGroup = new ButtonGroup(); CookTimeButtonVbox = new VBoxContainer @@ -107,9 +115,12 @@ namespace Content.Client.GameObjects.Components.Kitchen index+=5; } + var cookTimeOneSecondButton = (Button)CookTimeButtonVbox.GetChild(0); + cookTimeOneSecondButton.Pressed = true; + _cookTimeInfoLabel = new Label { - Text = Loc.GetString("COOK TIME:"), + Text = Loc.GetString($"COOK TIME: {VisualCookTime}"), Align = Label.AlignMode.Center, Modulate = Color.White, SizeFlagsVertical = SizeFlags.ShrinkCenter @@ -120,18 +131,20 @@ namespace Content.Client.GameObjects.Components.Kitchen SizeFlagsVertical = SizeFlags.FillExpand, ModulateSelfOverride = Color.Red, CustomMinimumSize = (100, 128), - PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Black}, + PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.5f)}, Children = { + new VBoxContainer { Children = { + new PanelContainer { - PanelOverride = new StyleBoxFlat(){BackgroundColor = Color.Red.WithAlpha(0.2f)}, + PanelOverride = new StyleBoxFlat(){BackgroundColor = Color.Gray.WithAlpha(0.2f)}, Children = { @@ -162,6 +175,7 @@ namespace Content.Client.GameObjects.Components.Kitchen SizeFlagsHorizontal = SizeFlags.FillExpand, Children = { + innerTimerPanel }, }; diff --git a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs index db31904525..419c44dc30 100644 --- a/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs +++ b/Content.Server/GameObjects/Components/Kitchen/KitchenMicrowaveComponent.cs @@ -22,6 +22,8 @@ using Robust.Server.Interfaces.GameObjects; using Robust.Shared.Prototypes; using Robust.Shared.Localization; using Content.Server.Interfaces; +using Robust.Shared.Audio; +using YamlDotNet.Serialization.NodeTypeResolvers; namespace Content.Server.GameObjects.Components.Kitchen { @@ -57,7 +59,7 @@ namespace Content.Server.GameObjects.Components.Kitchen /// For right now, I don't think any recipe cook time should be greater than 60 seconds. /// [ViewVariables] - private byte _currentCookTimerTime { get; set; } + private uint _currentCookTimerTime { get; set; } = 1; #endregion private bool Powered => _powerDevice.Powered; @@ -109,7 +111,6 @@ namespace Content.Server.GameObjects.Components.Kitchen _solids = new Dictionary(); _solidsVisualList = new List(); _userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage; - } private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message) @@ -122,10 +123,7 @@ namespace Content.Server.GameObjects.Components.Kitchen switch (message.Message) { case MicrowaveStartCookMessage msg : - if (HasContents) - { - wzhzhzh(); - } + wzhzhzh(); break; case MicrowaveEjectMessage msg : @@ -133,6 +131,7 @@ namespace Content.Server.GameObjects.Components.Kitchen { VaporizeReagents(); EjectSolids(); + ClickSound(); UpdateUserInterface(); } @@ -142,12 +141,14 @@ namespace Content.Server.GameObjects.Components.Kitchen if (HasContents) { EjectSolidWithIndex(msg.EntityID); + ClickSound(); UpdateUserInterface(); } break; case MicrowaveSelectCookTimeMessage msg: _currentCookTimerTime = msg.newCookTime; + ClickSound(); UpdateUserInterface(); break; } @@ -166,7 +167,7 @@ namespace Content.Server.GameObjects.Components.Kitchen private void UpdateUserInterface() { _solidsVisualList.Clear(); - foreach(var item in _storage.ContainedEntities.ToList()) + foreach(var item in _storage.ContainedEntities) { _solidsVisualList.Add(item.Uid); } @@ -240,6 +241,11 @@ namespace Content.Server.GameObjects.Components.Kitchen //This is required. It's 'cook'. private void wzhzhzh() { + if (!HasContents) + { + return; + } + _busy = true; // Convert storage into Dictionary of ingredients _solids.Clear(); @@ -269,11 +275,11 @@ namespace Content.Server.GameObjects.Components.Kitchen var goodMeal = (recipeToCook != null) && - (_currentCookTimerTime == (byte)recipeToCook.CookTime) ? true : false; + (_currentCookTimerTime == (uint)recipeToCook.CookTime) ? true : false; SetAppearance(MicrowaveVisualState.Cooking); _audioSystem.Play(_startCookingSound); - Timer.Spawn(_currentCookTimerTime * _cookTimeMultiplier, () => + Timer.Spawn((int)(_currentCookTimerTime * _cookTimeMultiplier), () => { if (goodMeal) @@ -340,7 +346,7 @@ namespace Content.Server.GameObjects.Components.Kitchen { for (var i = 0; i < recipeSolid.Value; i++) { - foreach (var item in _storage.ContainedEntities.ToList()) + foreach (var item in _storage.ContainedEntities) { if (item.Prototype.ID == recipeSolid.Key) { @@ -384,6 +390,13 @@ namespace Content.Server.GameObjects.Components.Kitchen return true; } + + private void ClickSound() + { + + _audioSystem.Play("/Audio/machines/machine_switch.ogg", AudioParams.Default.WithVolume(-2f)); + + } } } diff --git a/Content.Shared/Kitchen/RecipeManager.cs b/Content.Shared/Kitchen/RecipeManager.cs index 454c21a440..5ac01ad64f 100644 --- a/Content.Shared/Kitchen/RecipeManager.cs +++ b/Content.Shared/Kitchen/RecipeManager.cs @@ -24,29 +24,17 @@ namespace Content.Shared.Kitchen Recipes.Sort(new RecipeComparer()); } - private class RecipeComparer : IComparer + private class RecipeComparer : Comparer { - int IComparer.Compare(FoodRecipePrototype x, FoodRecipePrototype y) + public override int Compare(FoodRecipePrototype x, FoodRecipePrototype y) { if (x == null || y == null) { return 0; } - - if (x.IngredientsReagents.Count < y.IngredientsReagents.Count) - { - return 1; - } - - if (x.IngredientsReagents.Count > y.IngredientsReagents.Count) - { - return -1; - } - - return 0; + + return -x.IngredientsReagents.Count.CompareTo(y.IngredientsReagents.Count); } - - } } } diff --git a/Content.Shared/Kitchen/SharedMicrowaveComponent.cs b/Content.Shared/Kitchen/SharedMicrowaveComponent.cs index d0615c7a75..5707172db1 100644 --- a/Content.Shared/Kitchen/SharedMicrowaveComponent.cs +++ b/Content.Shared/Kitchen/SharedMicrowaveComponent.cs @@ -44,10 +44,10 @@ namespace Content.Shared.Kitchen [Serializable, NetSerializable] public class MicrowaveSelectCookTimeMessage : BoundUserInterfaceMessage { - public byte newCookTime; - public MicrowaveSelectCookTimeMessage(byte newTime) + public uint newCookTime; + public MicrowaveSelectCookTimeMessage(uint inputTime) { - newCookTime = newTime; + newCookTime = inputTime; } } }