From 4a20a3e8399aec133ba053f07e5963b4d38de83c Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sun, 30 Oct 2022 03:14:20 -0400 Subject: [PATCH] adds machine upgrades for microwave (#12010) --- .../Kitchen/Components/MicrowaveComponent.cs | 10 ++++++++-- .../Kitchen/EntitySystems/MicrowaveSystem.cs | 9 ++++++++- .../Devices/Circuitboards/Machine/production.yml | 2 +- .../Entities/Structures/Machines/microwave.yml | 3 +++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 1a613aad15..726da379bf 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Construction.Prototypes; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.Prototypes; @@ -8,8 +9,13 @@ namespace Content.Server.Kitchen.Components [RegisterComponent] public sealed class MicrowaveComponent : Component { - [DataField("cookTimeMultiplier")] - public int CookTimeMultiplier = 1; //For upgrades and stuff I guess? don't ask me. + [DataField("cookTimeMultiplier"), ViewVariables(VVAccess.ReadWrite)] + public float CookTimeMultiplier = 1; + [DataField("machinePartCookTimeMultiplier", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string MachinePartCookTimeMultiplier = "Laser"; + [DataField("cookTimeScalingConstant")] + public float CookTimeScalingConstant = 0.5f; + [DataField("failureResult", customTypeSerializer: typeof(PrototypeIdSerializer))] public string BadRecipeEntityId = "FoodBadRecipe"; diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 05dda98cd3..6355b378d7 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -53,6 +53,7 @@ namespace Content.Server.Kitchen.EntitySystems SubscribeLocalEvent(OnBreak); SubscribeLocalEvent(OnPowerChanged); SubscribeLocalEvent(OnSuicide); + SubscribeLocalEvent(OnRefreshParts); SubscribeLocalEvent((u,c,_) => Wzhzhzh(u,c)); SubscribeLocalEvent(OnEjectMessage); @@ -269,6 +270,12 @@ namespace Content.Server.Kitchen.EntitySystems UpdateUserInterfaceState(uid, component); } + private void OnRefreshParts(EntityUid uid, MicrowaveComponent component, RefreshPartsEvent args) + { + var cookRating = args.PartRatings[component.MachinePartCookTimeMultiplier]; + component.CookTimeMultiplier = MathF.Pow(component.CookTimeScalingConstant, cookRating - 1); + } + public void UpdateUserInterfaceState(EntityUid uid, MicrowaveComponent component) { var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key); @@ -371,7 +378,7 @@ namespace Content.Server.Kitchen.EntitySystems _audio.PlayPvs(component.StartCookingSound, uid); var activeComp = AddComp(uid); //microwave is now cooking activeComp.CookTimeRemaining = component.CurrentCookTimerTime * component.CookTimeMultiplier; - activeComp.TotalTime = component.CurrentCookTimerTime * component.CookTimeMultiplier; + activeComp.TotalTime = component.CurrentCookTimerTime; //this doesn't scale so that we can have the "actual" time activeComp.PortionedRecipe = portionedRecipe; UpdateUserInterfaceState(uid, component); } diff --git a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml index e2297d924e..0ef1403436 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml @@ -484,7 +484,7 @@ - type: MachineBoard prototype: KitchenMicrowave requirements: - MatterBin: 1 + Capacitor: 1 Laser: 1 materialRequirements: Glass: 2 diff --git a/Resources/Prototypes/Entities/Structures/Machines/microwave.yml b/Resources/Prototypes/Entities/Structures/Machines/microwave.yml index bdef9b808b..64ad1d560d 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/microwave.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/microwave.yml @@ -59,6 +59,9 @@ acts: ["Breakage"] - type: ApcPowerReceiver powerLoad: 400 + - type: UpgradePowerDraw + powerDrawMultiplier: 0.75 + scaling: Exponential - type: Machine board: MicrowaveMachineCircuitboard - type: ContainerContainer