Microwave rework (#6470)

This commit is contained in:
mirrorcult
2022-02-12 17:53:54 -07:00
committed by GitHub
parent be853b2529
commit 9adfde9ee3
16 changed files with 243 additions and 196 deletions

View File

@@ -42,11 +42,6 @@ namespace Content.Client.Kitchen.UI
SendMessage(new MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex])); SendMessage(new MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex]));
}; };
_menu.IngredientsListReagents.OnItemSelected += args =>
{
SendMessage(new MicrowaveVaporizeReagentIndexedMessage(_reagents[args.ItemIndex]));
};
_menu.OnCookTimeSelected += (args,buttonIndex) => _menu.OnCookTimeSelected += (args,buttonIndex) =>
{ {
var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button ; var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button ;
@@ -77,7 +72,7 @@ namespace Content.Client.Kitchen.UI
} }
_menu?.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy); _menu?.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy);
RefreshContentsDisplay(cState.ReagentQuantities, cState.ContainedSolids); RefreshContentsDisplay(cState.ContainedSolids);
if (_menu == null) return; if (_menu == null) return;
@@ -90,22 +85,12 @@ namespace Content.Client.Kitchen.UI
("time", cookTime)); ("time", cookTime));
} }
private void RefreshContentsDisplay(Solution.ReagentQuantity[] reagents, EntityUid[] containedSolids) private void RefreshContentsDisplay(EntityUid[] containedSolids)
{ {
_reagents.Clear(); _reagents.Clear();
if (_menu == null) return; if (_menu == null) return;
_menu.IngredientsListReagents.Clear();
for (var i = 0; i < reagents.Length; i++)
{
if (!_prototypeManager.TryIndex(reagents[i].ReagentId, out ReagentPrototype? proto)) continue;
var reagentAdded = _menu.IngredientsListReagents.AddItem($"{reagents[i].Quantity} {proto.Name}");
var reagentIndex = _menu.IngredientsListReagents.IndexOf(reagentAdded);
_reagents.Add(reagentIndex, reagents[i]);
}
_solids.Clear(); _solids.Clear();
_menu.IngredientsList.Clear(); _menu.IngredientsList.Clear();
foreach (var entity in containedSolids) foreach (var entity in containedSolids)

View File

@@ -4,16 +4,6 @@
SetSize="512 256" SetSize="512 256"
MinSize="512 256"> MinSize="512 256">
<BoxContainer Orientation="Horizontal"> <BoxContainer Orientation="Horizontal">
<ItemList Name="IngredientsListReagents"
Access="Public"
VerticalExpand="True"
HorizontalExpand="True"
SelectMode="Button"
SizeFlagsStretchRatio="2"
MinSize="100 128">
<!-- Ingredient reagents are added here by code -->
</ItemList>
<Control MinSize="0 5" />
<ItemList Name="IngredientsList" <ItemList Name="IngredientsList"
Access="Public" Access="Public"
VerticalExpand="True" VerticalExpand="True"

View File

@@ -57,6 +57,8 @@ namespace Content.IntegrationTests.Tests.Chemistry
.TryAddReagent(beaker, component, id, reactant.Amount, out var quantity)); .TryAddReagent(beaker, component, id, reactant.Amount, out var quantity));
Assert.That(reactant.Amount, Is.EqualTo(quantity)); Assert.That(reactant.Amount, Is.EqualTo(quantity));
} }
EntitySystem.Get<SolutionContainerSystem>().SetTemperature(beaker, component, reactionPrototype.MinimumTemperature);
}); });
await server.WaitIdleAsync(); await server.WaitIdleAsync();

View File

@@ -3,21 +3,32 @@ using Content.Shared.Inventory;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Kitchen.Components;
using Content.Server.Popups;
using Content.Shared.Access;
using Content.Shared.Access.Components; using Content.Shared.Access.Components;
using Content.Shared.Access.Systems; using Content.Shared.Access.Systems;
using Content.Shared.PDA; using Content.Shared.PDA;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Access.Systems namespace Content.Server.Access.Systems
{ {
public class IdCardSystem : SharedIdCardSystem public class IdCardSystem : SharedIdCardSystem
{ {
[Dependency] private readonly InventorySystem _inventorySystem = default!; [Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<IdCardComponent, ComponentInit>(OnInit); SubscribeLocalEvent<IdCardComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<IdCardComponent, BeingMicrowavedEvent>(OnMicrowaved);
} }
private void OnInit(EntityUid uid, IdCardComponent id, ComponentInit args) private void OnInit(EntityUid uid, IdCardComponent id, ComponentInit args)
@@ -26,6 +37,29 @@ namespace Content.Server.Access.Systems
UpdateEntityName(uid, id); UpdateEntityName(uid, id);
} }
private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowavedEvent args)
{
if (TryComp<AccessComponent>(uid, out var access))
{
// If they're unlucky, brick their ID
if (_random.Prob(0.25f))
{
_popupSystem.PopupEntity(Loc.GetString("id-card-component-microwave-bricked", ("id", uid)),
uid, Filter.Pvs(uid));
access.Tags.Clear();
}
else
{
_popupSystem.PopupEntity(Loc.GetString("id-card-component-microwave-safe", ("id", uid)),
uid, Filter.Pvs(uid));
}
// Give them a wonderful new access to compensate for everything
var random = _random.Pick(_prototypeManager.EnumeratePrototypes<AccessLevelPrototype>().ToArray());
access.Tags.Add(random.ID);
}
}
public bool TryChangeJobTitle(EntityUid uid, string jobTitle, IdCardComponent? id = null) public bool TryChangeJobTitle(EntityUid uid, string jobTitle, IdCardComponent? id = null)
{ {
if (!Resolve(uid, ref id)) if (!Resolve(uid, ref id))

View File

@@ -1,18 +1,18 @@
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.Act; using Content.Server.Act;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems; using Content.Server.Chemistry.EntitySystems;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Popups; using Content.Server.Popups;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.Acts; using Content.Shared.Acts;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.Body.Part; using Content.Shared.Body.Part;
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Item; using Content.Shared.Item;
@@ -21,15 +21,11 @@ using Content.Shared.Kitchen.Components;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Power; using Content.Shared.Power;
using Content.Shared.Sound; using Content.Shared.Sound;
using Content.Shared.Tag;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Kitchen.Components namespace Content.Server.Kitchen.Components
{ {
@@ -56,6 +52,8 @@ namespace Content.Server.Kitchen.Components
[DataField("clickSound")] [DataField("clickSound")]
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
public SoundSpecifier ItemBreakSound = new SoundPathSpecifier("/Audio/Effects/clang.ogg");
#endregion YAMLSERIALIZE #endregion YAMLSERIALIZE
[ViewVariables] private bool _busy = false; [ViewVariables] private bool _busy = false;
@@ -68,11 +66,15 @@ namespace Content.Server.Kitchen.Components
/// </summary> /// </summary>
[ViewVariables] private uint _currentCookTimerTime = 1; [ViewVariables] private uint _currentCookTimerTime = 1;
/// <summary>
/// The max temperature that this microwave can heat objects to.
/// </summary>
[DataField("temperatureUpperThreshold")]
public float TemperatureUpperThreshold = 373.15f;
private bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered; private bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
private bool HasContents => EntitySystem.Get<SolutionContainerSystem>() private bool HasContents => _storage.ContainedEntities.Count > 0;
.TryGetSolution(Owner, SolutionName, out var solution) &&
(solution.Contents.Count > 0 || _storage.ContainedEntities.Count > 0);
private bool _uiDirty = true; private bool _uiDirty = true;
private bool _lostPower; private bool _lostPower;
@@ -84,7 +86,6 @@ namespace Content.Server.Kitchen.Components
} }
private Container _storage = default!; private Container _storage = default!;
private const string SolutionName = "microwave";
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(MicrowaveUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(MicrowaveUiKey.Key);
@@ -94,8 +95,6 @@ namespace Content.Server.Kitchen.Components
_currentCookTimerTime = _cookTimeDefault; _currentCookTimerTime = _cookTimeDefault;
EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, SolutionName);
_storage = ContainerHelpers.EnsureContainer<Container>(Owner, "microwave_entity_container", _storage = ContainerHelpers.EnsureContainer<Container>(Owner, "microwave_entity_container",
out _); out _);
@@ -120,7 +119,6 @@ namespace Content.Server.Kitchen.Components
case MicrowaveEjectMessage: case MicrowaveEjectMessage:
if (HasContents) if (HasContents)
{ {
VaporizeReagents();
EjectSolids(); EjectSolids();
ClickSound(); ClickSound();
_uiDirty = true; _uiDirty = true;
@@ -134,17 +132,8 @@ namespace Content.Server.Kitchen.Components
ClickSound(); ClickSound();
_uiDirty = true; _uiDirty = true;
} }
break; break;
case MicrowaveVaporizeReagentIndexedMessage msg:
if (HasContents)
{
VaporizeReagentQuantity(msg.ReagentQuantity);
ClickSound();
_uiDirty = true;
}
break;
case MicrowaveSelectCookTimeMessage msg: case MicrowaveSelectCookTimeMessage msg:
_currentCookTimeButtonIndex = msg.ButtonIndex; _currentCookTimeButtonIndex = msg.ButtonIndex;
_currentCookTimerTime = msg.NewCookTime; _currentCookTimerTime = msg.NewCookTime;
@@ -166,7 +155,6 @@ namespace Content.Server.Kitchen.Components
{ {
//we lost power while we were cooking/busy! //we lost power while we were cooking/busy!
_lostPower = true; _lostPower = true;
VaporizeReagents();
EjectSolids(); EjectSolids();
_busy = false; _busy = false;
_uiDirty = true; _uiDirty = true;
@@ -177,18 +165,15 @@ namespace Content.Server.Kitchen.Components
SetAppearance(MicrowaveVisualState.Broken); SetAppearance(MicrowaveVisualState.Broken);
//we broke while we were cooking/busy! //we broke while we were cooking/busy!
_lostPower = true; _lostPower = true;
VaporizeReagents();
EjectSolids(); EjectSolids();
_busy = false; _busy = false;
_uiDirty = true; _uiDirty = true;
} }
if (_uiDirty && EntitySystem.Get<SolutionContainerSystem>() if (_uiDirty)
.TryGetSolution(Owner, SolutionName, out var solution))
{ {
UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState
( (
solution.Contents.ToArray(),
_storage.ContainedEntities.Select(item => item).ToArray(), _storage.ContainedEntities.Select(item => item).ToArray(),
_busy, _busy,
_currentCookTimeButtonIndex, _currentCookTimeButtonIndex,
@@ -249,41 +234,6 @@ namespace Content.Server.Kitchen.Components
return false; return false;
} }
if (_entities.TryGetComponent<SolutionTransferComponent?>(itemEntity, out var attackPourable))
{
var solutionsSystem = EntitySystem.Get<SolutionContainerSystem>();
if (!solutionsSystem.TryGetDrainableSolution(itemEntity, out var attackSolution))
{
return false;
}
if (!solutionsSystem.TryGetSolution(Owner, SolutionName, out var solution))
{
return false;
}
//Get transfer amount. May be smaller than _transferAmount if not enough room
var realTransferAmount = FixedPoint2.Min(attackPourable.TransferAmount, solution.AvailableVolume);
if (realTransferAmount <= 0) //Special message if container is full
{
Owner.PopupMessage(eventArgs.User,
Loc.GetString("microwave-component-interact-using-container-full"));
return false;
}
//Move units from attackSolution to targetSolution
var removedSolution = EntitySystem.Get<SolutionContainerSystem>()
.Drain(itemEntity, attackSolution, realTransferAmount);
if (!EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(Owner, solution, removedSolution))
{
return false;
}
Owner.PopupMessage(eventArgs.User, Loc.GetString("microwave-component-interact-using-transfer-success",
("amount", removedSolution.TotalVolume)));
return true;
}
if (!_entities.TryGetComponent(itemEntity, typeof(SharedItemComponent), out var food)) if (!_entities.TryGetComponent(itemEntity, typeof(SharedItemComponent), out var food))
{ {
Owner.PopupMessage(eventArgs.User, "microwave-component-interact-using-transfer-fail"); Owner.PopupMessage(eventArgs.User, "microwave-component-interact-using-transfer-fail");
@@ -308,8 +258,36 @@ namespace Content.Server.Kitchen.Components
_busy = true; _busy = true;
// Convert storage into Dictionary of ingredients // Convert storage into Dictionary of ingredients
var solidsDict = new Dictionary<string, int>(); var solidsDict = new Dictionary<string, int>();
var reagentDict = new Dictionary<string, FixedPoint2>();
foreach (var item in _storage.ContainedEntities) foreach (var item in _storage.ContainedEntities)
{ {
// special behavior when being microwaved ;)
var ev = new BeingMicrowavedEvent(Owner);
_entities.EventBus.RaiseLocalEvent(item, ev, false);
if (ev.Handled)
return;
var tagSys = EntitySystem.Get<TagSystem>();
if (tagSys.HasTag(item, "MicrowaveMachineUnsafe")
|| tagSys.HasTag(item, "Metal"))
{
// destroy microwave
_broken = true;
SetAppearance(MicrowaveVisualState.Broken);
SoundSystem.Play(Filter.Pvs(Owner), ItemBreakSound.GetSound(), Owner);
return;
}
if (tagSys.HasTag(item, "MicrowaveSelfUnsafe")
|| tagSys.HasTag(item, "Plastic"))
{
_entities.SpawnEntity(_badRecipeName,
_entities.GetComponent<TransformComponent>(Owner).Coordinates);
_entities.QueueDeleteEntity(item);
}
var metaData = _entities.GetComponent<MetaDataComponent>(item); var metaData = _entities.GetComponent<MetaDataComponent>(item);
if (metaData.EntityPrototype == null) if (metaData.EntityPrototype == null)
{ {
@@ -324,29 +302,32 @@ namespace Content.Server.Kitchen.Components
{ {
solidsDict.Add(metaData.EntityPrototype.ID, 1); solidsDict.Add(metaData.EntityPrototype.ID, 1);
} }
}
var failState = MicrowaveSuccessState.RecipeFail; if (!_entities.TryGetComponent<SolutionContainerManagerComponent>(item, out var solMan))
foreach (var id in solidsDict.Keys)
{
if (_recipeManager.SolidAppears(id))
{
continue; continue;
}
failState = MicrowaveSuccessState.UnwantedForeignObject; foreach (var (_, solution) in solMan.Solutions)
break; {
foreach (var reagent in solution.Contents)
{
if (reagentDict.ContainsKey(reagent.ReagentId))
reagentDict[reagent.ReagentId] += reagent.Quantity;
else
reagentDict.Add(reagent.ReagentId, reagent.Quantity);
}
}
} }
// Check recipes // Check recipes
FoodRecipePrototype? recipeToCook = null; FoodRecipePrototype? recipeToCook = null;
foreach (var r in _recipeManager.Recipes.Where(r => foreach (var r in _recipeManager.Recipes.Where(r =>
CanSatisfyRecipe(r, solidsDict) == MicrowaveSuccessState.RecipePass)) CanSatisfyRecipe(r, solidsDict, reagentDict)))
{ {
recipeToCook = r; recipeToCook = r;
} }
SetAppearance(MicrowaveVisualState.Cooking); SetAppearance(MicrowaveVisualState.Cooking);
var time = _currentCookTimerTime * _cookTimeMultiplier;
SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default); SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default);
Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), () => Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), () =>
{ {
@@ -355,26 +336,17 @@ namespace Content.Server.Kitchen.Components
return; return;
} }
if (failState == MicrowaveSuccessState.UnwantedForeignObject) AddTemperature(time);
{
VaporizeReagents();
EjectSolids();
}
else
{
if (recipeToCook != null) if (recipeToCook != null)
{ {
SubtractContents(recipeToCook); SubtractContents(recipeToCook);
_entities.SpawnEntity(recipeToCook.Result, _entities.GetComponent<TransformComponent>(Owner).Coordinates); _entities.SpawnEntity(recipeToCook.Result,
} _entities.GetComponent<TransformComponent>(Owner).Coordinates);
else
{
VaporizeReagents();
VaporizeSolids();
_entities.SpawnEntity(_badRecipeName, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
}
} }
EjectSolids();
SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner, SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner,
AudioParams.Default.WithVolume(-1f)); AudioParams.Default.WithVolume(-1f));
@@ -387,30 +359,31 @@ namespace Content.Server.Kitchen.Components
_uiDirty = true; _uiDirty = true;
} }
private void VaporizeReagents() /// <summary>
/// Adds temperature to every item in the microwave,
/// based on the time it took to microwave.
/// </summary>
/// <param name="time">The time on the microwave, in seconds.</param>
public void AddTemperature(float time)
{ {
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
foreach (var entity in _storage.ContainedEntities)
{ {
EntitySystem.Get<SolutionContainerSystem>().RemoveAllSolution(Owner, solution); if (_entities.TryGetComponent(entity, out TemperatureComponent? temp))
} {
EntitySystem.Get<TemperatureSystem>().ChangeHeat(entity, time / 10, false, temp);
} }
private void VaporizeReagentQuantity(Solution.ReagentQuantity reagentQuantity) if (_entities.TryGetComponent(entity, out SolutionContainerManagerComponent? solutions))
{ {
if (EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) foreach (var (_, solution) in solutions.Solutions)
{ {
EntitySystem.Get<SolutionContainerSystem>() if (solution.Temperature > TemperatureUpperThreshold)
.TryRemoveReagent(Owner, solution, reagentQuantity.ReagentId, reagentQuantity.Quantity); continue;
}
}
private void VaporizeSolids() solutionContainerSystem.AddThermalEnergy(entity, solution, time / 10);
{ }
for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--) }
{
var item = _storage.ContainedEntities.ElementAt(i);
_storage.Remove(item);
_entities.DeleteEntity(item);
} }
} }
@@ -432,16 +405,42 @@ namespace Content.Server.Kitchen.Components
private void SubtractContents(FoodRecipePrototype recipe) private void SubtractContents(FoodRecipePrototype recipe)
{ {
var solutionUid = Owner; var totalReagentsToRemove = new Dictionary<string, FixedPoint2>(recipe.IngredientsReagents);
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
// this is spaghetti ngl
foreach (var item in _storage.ContainedEntities)
{ {
return; if (!_entities.TryGetComponent<SolutionContainerManagerComponent>(item, out var solMan))
continue;
// go over every solution
foreach (var (_, solution) in solMan.Solutions)
{
foreach (var (reagent, _) in recipe.IngredientsReagents)
{
// removed everything
if (!totalReagentsToRemove.ContainsKey(reagent))
continue;
if (!solution.ContainsReagent(reagent))
continue;
var quant = solution.GetReagentQuantity(reagent);
if (quant >= totalReagentsToRemove[reagent])
{
quant = totalReagentsToRemove[reagent];
totalReagentsToRemove.Remove(reagent);
}
else
{
totalReagentsToRemove[reagent] -= quant;
} }
foreach (var recipeReagent in recipe.IngredientsReagents) solutionContainerSystem.TryRemoveReagent(item, solution, reagent, quant);
{ }
EntitySystem.Get<SolutionContainerSystem>() }
.TryRemoveReagent(solutionUid, solution, recipeReagent.Key, FixedPoint2.New(recipeReagent.Value));
} }
foreach (var recipeSolid in recipe.IngredientsSolids) foreach (var recipeSolid in recipe.IngredientsSolids)
@@ -467,45 +466,32 @@ namespace Content.Server.Kitchen.Components
} }
} }
private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary<string, int> solids) private bool CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary<string, int> solids, Dictionary<string, FixedPoint2> reagents)
{ {
if (_currentCookTimerTime != recipe.CookTime) if (_currentCookTimerTime != recipe.CookTime)
{ {
return MicrowaveSuccessState.RecipeFail; return false;
}
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
{
return MicrowaveSuccessState.RecipeFail;
}
foreach (var reagent in recipe.IngredientsReagents)
{
if (!solution.ContainsReagent(reagent.Key, out var amount))
{
return MicrowaveSuccessState.RecipeFail;
}
if (amount.Int() < reagent.Value)
{
return MicrowaveSuccessState.RecipeFail;
}
} }
foreach (var solid in recipe.IngredientsSolids) foreach (var solid in recipe.IngredientsSolids)
{ {
if (!solids.ContainsKey(solid.Key)) if (!solids.ContainsKey(solid.Key))
{ return false;
return MicrowaveSuccessState.RecipeFail;
}
if (solids[solid.Key] < solid.Value) if (solids[solid.Key] < solid.Value)
{ return false;
return MicrowaveSuccessState.RecipeFail;
}
} }
return MicrowaveSuccessState.RecipePass; foreach (var reagent in recipe.IngredientsReagents)
{
if (!reagents.ContainsKey(reagent.Key))
return false;
if (reagents[reagent.Key] < reagent.Value)
return false;
}
return true;
} }
private void ClickSound() private void ClickSound()
@@ -563,4 +549,14 @@ namespace Content.Server.Kitchen.Components
return SuicideKind.Heat; return SuicideKind.Heat;
} }
} }
public class BeingMicrowavedEvent : HandledEntityEventArgs
{
public EntityUid Microwave;
public BeingMicrowavedEvent(EntityUid microwave)
{
Microwave = microwave;
}
}
} }

View File

@@ -1,10 +0,0 @@
namespace Content.Server.Kitchen.Components
{
public enum MicrowaveSuccessState
{
RecipePass,
RecipeFail,
UnwantedForeignObject
}
}

View File

@@ -13,6 +13,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Content.Server.Kitchen.Components;
namespace Content.Server.PowerCell; namespace Content.Server.PowerCell;
@@ -31,6 +32,26 @@ public class PowerCellSystem : SharedPowerCellSystem
SubscribeLocalEvent<PowerCellComponent, SolutionChangedEvent>(OnSolutionChange); SubscribeLocalEvent<PowerCellComponent, SolutionChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined); SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined);
// funny
SubscribeLocalEvent<PowerCellSlotComponent, BeingMicrowavedEvent>(OnSlotMicrowaved);
SubscribeLocalEvent<BatteryComponent, BeingMicrowavedEvent>(OnMicrowaved);
}
private void OnSlotMicrowaved(EntityUid uid, PowerCellSlotComponent component, BeingMicrowavedEvent args)
{
if (component.CellSlot.Item == null)
return;
RaiseLocalEvent(component.CellSlot.Item.Value, args, false);
}
private void OnMicrowaved(EntityUid uid, BatteryComponent component, BeingMicrowavedEvent args)
{
args.Handled = true;
// What the fuck are you doing???
Explode(uid, component);
} }
private void OnChargeChanged(EntityUid uid, PowerCellComponent component, ChargeChangedEvent args) private void OnChargeChanged(EntityUid uid, PowerCellComponent component, ChargeChangedEvent args)

View File

@@ -63,16 +63,14 @@ namespace Content.Shared.Kitchen.Components
[NetSerializable, Serializable] [NetSerializable, Serializable]
public class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState public class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState
{ {
public Solution.ReagentQuantity[] ReagentQuantities;
public EntityUid[] ContainedSolids; public EntityUid[] ContainedSolids;
public bool IsMicrowaveBusy; public bool IsMicrowaveBusy;
public int ActiveButtonIndex; public int ActiveButtonIndex;
public uint CurrentCookTime; public uint CurrentCookTime;
public MicrowaveUpdateUserInterfaceState(Solution.ReagentQuantity[] reagents, EntityUid[] containedSolids, public MicrowaveUpdateUserInterfaceState(EntityUid[] containedSolids,
bool isMicrowaveBusy, int activeButtonIndex, uint currentCookTime) bool isMicrowaveBusy, int activeButtonIndex, uint currentCookTime)
{ {
ReagentQuantities = reagents;
ContainedSolids = containedSolids; ContainedSolids = containedSolids;
IsMicrowaveBusy = isMicrowaveBusy; IsMicrowaveBusy = isMicrowaveBusy;
ActiveButtonIndex = activeButtonIndex; ActiveButtonIndex = activeButtonIndex;

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
@@ -22,11 +23,11 @@ namespace Content.Shared.Kitchen
[DataField("name")] [DataField("name")]
private string _name = string.Empty; private string _name = string.Empty;
[DataField("reagents", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<uint, ReagentPrototype>))] [DataField("reagents", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<FixedPoint2, ReagentPrototype>))]
private readonly Dictionary<string, uint> _ingsReagents = new(); private readonly Dictionary<string, FixedPoint2> _ingsReagents = new();
[DataField("solids", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<uint, EntityPrototype>))] [DataField("solids", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, EntityPrototype>))]
private readonly Dictionary<string, uint> _ingsSolids = new (); private readonly Dictionary<string, FixedPoint2> _ingsSolids = new ();
[DataField("result", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] [DataField("result", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Result { get; } = string.Empty; public string Result { get; } = string.Empty;
@@ -36,7 +37,7 @@ namespace Content.Shared.Kitchen
public string Name => Loc.GetString(_name); public string Name => Loc.GetString(_name);
public IReadOnlyDictionary<string, uint> IngredientsReagents => _ingsReagents; public IReadOnlyDictionary<string, FixedPoint2> IngredientsReagents => _ingsReagents;
public IReadOnlyDictionary<string, uint> IngredientsSolids => _ingsSolids; public IReadOnlyDictionary<string, FixedPoint2> IngredientsSolids => _ingsSolids;
} }
} }

View File

@@ -3,3 +3,5 @@
access-id-card-component-owner-name-job-title-text = {$originalOwnerName}{$jobSuffix} access-id-card-component-owner-name-job-title-text = {$originalOwnerName}{$jobSuffix}
access-id-card-component-owner-full-name-job-title-text = {$fullName}'s ID card{$jobSuffix} access-id-card-component-owner-full-name-job-title-text = {$fullName}'s ID card{$jobSuffix}
id-card-component-microwave-bricked = {$id}'s circuits sizzle!
id-card-component-microwave-safe = {$id}'s circuits make a weird noise.

View File

@@ -13,6 +13,7 @@
- type: Tag - type: Tag
tags: tags:
- Sheet - Sheet
- Metal
- type: entity - type: entity
parent: SheetMetalBase parent: SheetMetalBase

View File

@@ -121,6 +121,9 @@
name: plastic name: plastic
suffix: Full suffix: Full
components: components:
- type: Tag
tags:
- Plastic
- type: Material - type: Material
materials: materials:
- Plastic - Plastic

View File

@@ -20,6 +20,7 @@
- type: Tag - type: Tag
tags: tags:
- Hoe - Hoe
- Metal
- type: Sprite - type: Sprite
state: fork state: fork
- type: Utensil - type: Utensil
@@ -40,6 +41,8 @@
types: types:
- Fork - Fork
breakChance: 0.20 breakChance: 0.20
- type: Tag
tags: [ Plastic ]
- type: entity - type: entity
parent: UtensilBase parent: UtensilBase
@@ -47,6 +50,9 @@
name: spoon name: spoon
description: There is no spoon. description: There is no spoon.
components: components:
- type: Tag
tags:
- Metal
- type: Sprite - type: Sprite
state: spoon state: spoon
- type: Item - type: Item
@@ -61,6 +67,9 @@
name: plastic spoon name: plastic spoon
description: There is no spoon. description: There is no spoon.
components: components:
- type: Tag
tags:
- Plastic
- type: Sprite - type: Sprite
state: plastic_spoon state: plastic_spoon
- type: Item - type: Item
@@ -77,6 +86,9 @@
name: plastic knife name: plastic knife
description: That's not a knife. This is a knife. description: That's not a knife. This is a knife.
components: components:
- type: Tag
tags:
- Plastic
- type: Sprite - type: Sprite
state: plastic_knife state: plastic_knife
- type: Item - type: Item

View File

@@ -26,10 +26,9 @@
bounds: "-0.3,-0.16,0.3,0.16" bounds: "-0.3,-0.16,0.3,0.16"
mass: 25 mass: 25
layer: layer:
- MobMask - SmallImpassable
- Opaque
mask: mask:
- MobMask - VaultImpassable
- type: Sprite - type: Sprite
netsync: false netsync: false
sprite: Structures/Machines/microwave.rsi sprite: Structures/Machines/microwave.rsi

View File

@@ -554,6 +554,7 @@
- type: reaction - type: reaction
id: HotRamen id: HotRamen
minTemp: 323.15
reactants: reactants:
DryRamen: DryRamen:
amount: 3 amount: 3

View File

@@ -189,6 +189,15 @@
- type: Tag - type: Tag
id: Matchstick id: Matchstick
- type: Tag
id: Metal
- type: Tag
id: MicrowaveMachineUnsafe
- type: Tag
id: MicrowaveSelfUnsafe
- type: Tag - type: Tag
id: MonkeyCube id: MonkeyCube
@@ -207,6 +216,9 @@
- type: Tag - type: Tag
id: PercussionInstrument id: PercussionInstrument
- type: Tag
id: Plastic
- type: Tag - type: Tag
id: Pill id: Pill