adds machine upgrades for microwave (#12010)

This commit is contained in:
Nemanja
2022-10-30 03:14:20 -04:00
committed by GitHub
parent 099d829cf3
commit 4a20a3e839
4 changed files with 20 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
using Content.Shared.Construction.Prototypes;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -8,8 +9,13 @@ namespace Content.Server.Kitchen.Components
[RegisterComponent] [RegisterComponent]
public sealed class MicrowaveComponent : Component public sealed class MicrowaveComponent : Component
{ {
[DataField("cookTimeMultiplier")] [DataField("cookTimeMultiplier"), ViewVariables(VVAccess.ReadWrite)]
public int CookTimeMultiplier = 1; //For upgrades and stuff I guess? don't ask me. public float CookTimeMultiplier = 1;
[DataField("machinePartCookTimeMultiplier", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
public string MachinePartCookTimeMultiplier = "Laser";
[DataField("cookTimeScalingConstant")]
public float CookTimeScalingConstant = 0.5f;
[DataField("failureResult", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] [DataField("failureResult", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string BadRecipeEntityId = "FoodBadRecipe"; public string BadRecipeEntityId = "FoodBadRecipe";

View File

@@ -53,6 +53,7 @@ namespace Content.Server.Kitchen.EntitySystems
SubscribeLocalEvent<MicrowaveComponent, BreakageEventArgs>(OnBreak); SubscribeLocalEvent<MicrowaveComponent, BreakageEventArgs>(OnBreak);
SubscribeLocalEvent<MicrowaveComponent, PowerChangedEvent>(OnPowerChanged); SubscribeLocalEvent<MicrowaveComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<MicrowaveComponent, SuicideEvent>(OnSuicide); SubscribeLocalEvent<MicrowaveComponent, SuicideEvent>(OnSuicide);
SubscribeLocalEvent<MicrowaveComponent, RefreshPartsEvent>(OnRefreshParts);
SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u,c,_) => Wzhzhzh(u,c)); SubscribeLocalEvent<MicrowaveComponent, MicrowaveStartCookMessage>((u,c,_) => Wzhzhzh(u,c));
SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage); SubscribeLocalEvent<MicrowaveComponent, MicrowaveEjectMessage>(OnEjectMessage);
@@ -269,6 +270,12 @@ namespace Content.Server.Kitchen.EntitySystems
UpdateUserInterfaceState(uid, component); 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) public void UpdateUserInterfaceState(EntityUid uid, MicrowaveComponent component)
{ {
var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key); var ui = _userInterface.GetUiOrNull(uid, MicrowaveUiKey.Key);
@@ -371,7 +378,7 @@ namespace Content.Server.Kitchen.EntitySystems
_audio.PlayPvs(component.StartCookingSound, uid); _audio.PlayPvs(component.StartCookingSound, uid);
var activeComp = AddComp<ActiveMicrowaveComponent>(uid); //microwave is now cooking var activeComp = AddComp<ActiveMicrowaveComponent>(uid); //microwave is now cooking
activeComp.CookTimeRemaining = component.CurrentCookTimerTime * component.CookTimeMultiplier; 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; activeComp.PortionedRecipe = portionedRecipe;
UpdateUserInterfaceState(uid, component); UpdateUserInterfaceState(uid, component);
} }

View File

@@ -484,7 +484,7 @@
- type: MachineBoard - type: MachineBoard
prototype: KitchenMicrowave prototype: KitchenMicrowave
requirements: requirements:
MatterBin: 1 Capacitor: 1
Laser: 1 Laser: 1
materialRequirements: materialRequirements:
Glass: 2 Glass: 2

View File

@@ -59,6 +59,9 @@
acts: ["Breakage"] acts: ["Breakage"]
- type: ApcPowerReceiver - type: ApcPowerReceiver
powerLoad: 400 powerLoad: 400
- type: UpgradePowerDraw
powerDrawMultiplier: 0.75
scaling: Exponential
- type: Machine - type: Machine
board: MicrowaveMachineCircuitboard board: MicrowaveMachineCircuitboard
- type: ContainerContainer - type: ContainerContainer