Microwave rework (#6470)
This commit is contained in:
@@ -42,11 +42,6 @@ namespace Content.Client.Kitchen.UI
|
||||
SendMessage(new MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex]));
|
||||
};
|
||||
|
||||
_menu.IngredientsListReagents.OnItemSelected += args =>
|
||||
{
|
||||
SendMessage(new MicrowaveVaporizeReagentIndexedMessage(_reagents[args.ItemIndex]));
|
||||
};
|
||||
|
||||
_menu.OnCookTimeSelected += (args,buttonIndex) =>
|
||||
{
|
||||
var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button ;
|
||||
@@ -77,7 +72,7 @@ namespace Content.Client.Kitchen.UI
|
||||
}
|
||||
|
||||
_menu?.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy);
|
||||
RefreshContentsDisplay(cState.ReagentQuantities, cState.ContainedSolids);
|
||||
RefreshContentsDisplay(cState.ContainedSolids);
|
||||
|
||||
if (_menu == null) return;
|
||||
|
||||
@@ -90,22 +85,12 @@ namespace Content.Client.Kitchen.UI
|
||||
("time", cookTime));
|
||||
}
|
||||
|
||||
private void RefreshContentsDisplay(Solution.ReagentQuantity[] reagents, EntityUid[] containedSolids)
|
||||
private void RefreshContentsDisplay(EntityUid[] containedSolids)
|
||||
{
|
||||
_reagents.Clear();
|
||||
|
||||
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();
|
||||
_menu.IngredientsList.Clear();
|
||||
foreach (var entity in containedSolids)
|
||||
|
||||
@@ -4,16 +4,6 @@
|
||||
SetSize="512 256"
|
||||
MinSize="512 256">
|
||||
<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"
|
||||
Access="Public"
|
||||
VerticalExpand="True"
|
||||
|
||||
@@ -57,6 +57,8 @@ namespace Content.IntegrationTests.Tests.Chemistry
|
||||
.TryAddReagent(beaker, component, id, reactant.Amount, out var quantity));
|
||||
Assert.That(reactant.Amount, Is.EqualTo(quantity));
|
||||
}
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().SetTemperature(beaker, component, reactionPrototype.MinimumTemperature);
|
||||
});
|
||||
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -3,21 +3,32 @@ using Content.Shared.Inventory;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
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.Systems;
|
||||
using Content.Shared.PDA;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Access.Systems
|
||||
{
|
||||
public class IdCardSystem : SharedIdCardSystem
|
||||
{
|
||||
[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()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<IdCardComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<IdCardComponent, BeingMicrowavedEvent>(OnMicrowaved);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, IdCardComponent id, ComponentInit args)
|
||||
@@ -26,6 +37,29 @@ namespace Content.Server.Access.Systems
|
||||
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)
|
||||
{
|
||||
if (!Resolve(uid, ref id))
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Act;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Temperature.Components;
|
||||
using Content.Server.Temperature.Systems;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Item;
|
||||
@@ -21,15 +21,11 @@ using Content.Shared.Kitchen.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Kitchen.Components
|
||||
{
|
||||
@@ -56,6 +52,8 @@ namespace Content.Server.Kitchen.Components
|
||||
[DataField("clickSound")]
|
||||
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
|
||||
|
||||
public SoundSpecifier ItemBreakSound = new SoundPathSpecifier("/Audio/Effects/clang.ogg");
|
||||
|
||||
#endregion YAMLSERIALIZE
|
||||
|
||||
[ViewVariables] private bool _busy = false;
|
||||
@@ -68,11 +66,15 @@ namespace Content.Server.Kitchen.Components
|
||||
/// </summary>
|
||||
[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 HasContents => EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryGetSolution(Owner, SolutionName, out var solution) &&
|
||||
(solution.Contents.Count > 0 || _storage.ContainedEntities.Count > 0);
|
||||
private bool HasContents => _storage.ContainedEntities.Count > 0;
|
||||
|
||||
private bool _uiDirty = true;
|
||||
private bool _lostPower;
|
||||
@@ -84,7 +86,6 @@ namespace Content.Server.Kitchen.Components
|
||||
}
|
||||
|
||||
private Container _storage = default!;
|
||||
private const string SolutionName = "microwave";
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(MicrowaveUiKey.Key);
|
||||
|
||||
@@ -94,8 +95,6 @@ namespace Content.Server.Kitchen.Components
|
||||
|
||||
_currentCookTimerTime = _cookTimeDefault;
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, SolutionName);
|
||||
|
||||
_storage = ContainerHelpers.EnsureContainer<Container>(Owner, "microwave_entity_container",
|
||||
out _);
|
||||
|
||||
@@ -120,7 +119,6 @@ namespace Content.Server.Kitchen.Components
|
||||
case MicrowaveEjectMessage:
|
||||
if (HasContents)
|
||||
{
|
||||
VaporizeReagents();
|
||||
EjectSolids();
|
||||
ClickSound();
|
||||
_uiDirty = true;
|
||||
@@ -134,17 +132,8 @@ namespace Content.Server.Kitchen.Components
|
||||
ClickSound();
|
||||
_uiDirty = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case MicrowaveVaporizeReagentIndexedMessage msg:
|
||||
if (HasContents)
|
||||
{
|
||||
VaporizeReagentQuantity(msg.ReagentQuantity);
|
||||
ClickSound();
|
||||
_uiDirty = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case MicrowaveSelectCookTimeMessage msg:
|
||||
_currentCookTimeButtonIndex = msg.ButtonIndex;
|
||||
_currentCookTimerTime = msg.NewCookTime;
|
||||
@@ -166,7 +155,6 @@ namespace Content.Server.Kitchen.Components
|
||||
{
|
||||
//we lost power while we were cooking/busy!
|
||||
_lostPower = true;
|
||||
VaporizeReagents();
|
||||
EjectSolids();
|
||||
_busy = false;
|
||||
_uiDirty = true;
|
||||
@@ -177,18 +165,15 @@ namespace Content.Server.Kitchen.Components
|
||||
SetAppearance(MicrowaveVisualState.Broken);
|
||||
//we broke while we were cooking/busy!
|
||||
_lostPower = true;
|
||||
VaporizeReagents();
|
||||
EjectSolids();
|
||||
_busy = false;
|
||||
_uiDirty = true;
|
||||
}
|
||||
|
||||
if (_uiDirty && EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryGetSolution(Owner, SolutionName, out var solution))
|
||||
if (_uiDirty)
|
||||
{
|
||||
UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState
|
||||
(
|
||||
solution.Contents.ToArray(),
|
||||
_storage.ContainedEntities.Select(item => item).ToArray(),
|
||||
_busy,
|
||||
_currentCookTimeButtonIndex,
|
||||
@@ -249,41 +234,6 @@ namespace Content.Server.Kitchen.Components
|
||||
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))
|
||||
{
|
||||
Owner.PopupMessage(eventArgs.User, "microwave-component-interact-using-transfer-fail");
|
||||
@@ -308,8 +258,36 @@ namespace Content.Server.Kitchen.Components
|
||||
_busy = true;
|
||||
// Convert storage into Dictionary of ingredients
|
||||
var solidsDict = new Dictionary<string, int>();
|
||||
var reagentDict = new Dictionary<string, FixedPoint2>();
|
||||
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);
|
||||
if (metaData.EntityPrototype == null)
|
||||
{
|
||||
@@ -324,29 +302,32 @@ namespace Content.Server.Kitchen.Components
|
||||
{
|
||||
solidsDict.Add(metaData.EntityPrototype.ID, 1);
|
||||
}
|
||||
}
|
||||
|
||||
var failState = MicrowaveSuccessState.RecipeFail;
|
||||
foreach (var id in solidsDict.Keys)
|
||||
{
|
||||
if (_recipeManager.SolidAppears(id))
|
||||
{
|
||||
if (!_entities.TryGetComponent<SolutionContainerManagerComponent>(item, out var solMan))
|
||||
continue;
|
||||
}
|
||||
|
||||
failState = MicrowaveSuccessState.UnwantedForeignObject;
|
||||
break;
|
||||
foreach (var (_, solution) in solMan.Solutions)
|
||||
{
|
||||
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
|
||||
FoodRecipePrototype? recipeToCook = null;
|
||||
foreach (var r in _recipeManager.Recipes.Where(r =>
|
||||
CanSatisfyRecipe(r, solidsDict) == MicrowaveSuccessState.RecipePass))
|
||||
CanSatisfyRecipe(r, solidsDict, reagentDict)))
|
||||
{
|
||||
recipeToCook = r;
|
||||
}
|
||||
|
||||
SetAppearance(MicrowaveVisualState.Cooking);
|
||||
var time = _currentCookTimerTime * _cookTimeMultiplier;
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default);
|
||||
Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), () =>
|
||||
{
|
||||
@@ -355,26 +336,17 @@ namespace Content.Server.Kitchen.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (failState == MicrowaveSuccessState.UnwantedForeignObject)
|
||||
{
|
||||
VaporizeReagents();
|
||||
EjectSolids();
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTemperature(time);
|
||||
|
||||
if (recipeToCook != null)
|
||||
{
|
||||
SubtractContents(recipeToCook);
|
||||
_entities.SpawnEntity(recipeToCook.Result, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
}
|
||||
else
|
||||
{
|
||||
VaporizeReagents();
|
||||
VaporizeSolids();
|
||||
_entities.SpawnEntity(_badRecipeName, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
}
|
||||
_entities.SpawnEntity(recipeToCook.Result,
|
||||
_entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
}
|
||||
|
||||
EjectSolids();
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner,
|
||||
AudioParams.Default.WithVolume(-1f));
|
||||
|
||||
@@ -387,30 +359,31 @@ namespace Content.Server.Kitchen.Components
|
||||
_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>()
|
||||
.TryRemoveReagent(Owner, solution, reagentQuantity.ReagentId, reagentQuantity.Quantity);
|
||||
}
|
||||
}
|
||||
if (solution.Temperature > TemperatureUpperThreshold)
|
||||
continue;
|
||||
|
||||
private void VaporizeSolids()
|
||||
{
|
||||
for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var item = _storage.ContainedEntities.ElementAt(i);
|
||||
_storage.Remove(item);
|
||||
_entities.DeleteEntity(item);
|
||||
solutionContainerSystem.AddThermalEnergy(entity, solution, time / 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,16 +405,42 @@ namespace Content.Server.Kitchen.Components
|
||||
|
||||
private void SubtractContents(FoodRecipePrototype recipe)
|
||||
{
|
||||
var solutionUid = Owner;
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
var totalReagentsToRemove = new Dictionary<string, FixedPoint2>(recipe.IngredientsReagents);
|
||||
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)
|
||||
{
|
||||
EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryRemoveReagent(solutionUid, solution, recipeReagent.Key, FixedPoint2.New(recipeReagent.Value));
|
||||
solutionContainerSystem.TryRemoveReagent(item, solution, reagent, quant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return MicrowaveSuccessState.RecipeFail;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var solid in recipe.IngredientsSolids)
|
||||
{
|
||||
if (!solids.ContainsKey(solid.Key))
|
||||
{
|
||||
return MicrowaveSuccessState.RecipeFail;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (solids[solid.Key] < solid.Value)
|
||||
{
|
||||
return MicrowaveSuccessState.RecipeFail;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -563,4 +549,14 @@ namespace Content.Server.Kitchen.Components
|
||||
return SuicideKind.Heat;
|
||||
}
|
||||
}
|
||||
|
||||
public class BeingMicrowavedEvent : HandledEntityEventArgs
|
||||
{
|
||||
public EntityUid Microwave;
|
||||
|
||||
public BeingMicrowavedEvent(EntityUid microwave)
|
||||
{
|
||||
Microwave = microwave;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace Content.Server.Kitchen.Components
|
||||
{
|
||||
public enum MicrowaveSuccessState
|
||||
{
|
||||
RecipePass,
|
||||
RecipeFail,
|
||||
UnwantedForeignObject
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Kitchen.Components;
|
||||
|
||||
namespace Content.Server.PowerCell;
|
||||
|
||||
@@ -31,6 +32,26 @@ public class PowerCellSystem : SharedPowerCellSystem
|
||||
SubscribeLocalEvent<PowerCellComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||
|
||||
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)
|
||||
|
||||
@@ -63,16 +63,14 @@ namespace Content.Shared.Kitchen.Components
|
||||
[NetSerializable, Serializable]
|
||||
public class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public Solution.ReagentQuantity[] ReagentQuantities;
|
||||
public EntityUid[] ContainedSolids;
|
||||
public bool IsMicrowaveBusy;
|
||||
public int ActiveButtonIndex;
|
||||
public uint CurrentCookTime;
|
||||
|
||||
public MicrowaveUpdateUserInterfaceState(Solution.ReagentQuantity[] reagents, EntityUid[] containedSolids,
|
||||
public MicrowaveUpdateUserInterfaceState(EntityUid[] containedSolids,
|
||||
bool isMicrowaveBusy, int activeButtonIndex, uint currentCookTime)
|
||||
{
|
||||
ReagentQuantities = reagents;
|
||||
ContainedSolids = containedSolids;
|
||||
IsMicrowaveBusy = isMicrowaveBusy;
|
||||
ActiveButtonIndex = activeButtonIndex;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -22,11 +23,11 @@ namespace Content.Shared.Kitchen
|
||||
[DataField("name")]
|
||||
private string _name = string.Empty;
|
||||
|
||||
[DataField("reagents", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<uint, ReagentPrototype>))]
|
||||
private readonly Dictionary<string, uint> _ingsReagents = new();
|
||||
[DataField("reagents", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<FixedPoint2, ReagentPrototype>))]
|
||||
private readonly Dictionary<string, FixedPoint2> _ingsReagents = new();
|
||||
|
||||
[DataField("solids", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<uint, EntityPrototype>))]
|
||||
private readonly Dictionary<string, uint> _ingsSolids = new ();
|
||||
[DataField("solids", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, EntityPrototype>))]
|
||||
private readonly Dictionary<string, FixedPoint2> _ingsSolids = new ();
|
||||
|
||||
[DataField("result", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string Result { get; } = string.Empty;
|
||||
@@ -36,7 +37,7 @@ namespace Content.Shared.Kitchen
|
||||
|
||||
public string Name => Loc.GetString(_name);
|
||||
|
||||
public IReadOnlyDictionary<string, uint> IngredientsReagents => _ingsReagents;
|
||||
public IReadOnlyDictionary<string, uint> IngredientsSolids => _ingsSolids;
|
||||
public IReadOnlyDictionary<string, FixedPoint2> IngredientsReagents => _ingsReagents;
|
||||
public IReadOnlyDictionary<string, FixedPoint2> IngredientsSolids => _ingsSolids;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
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}
|
||||
|
||||
id-card-component-microwave-bricked = {$id}'s circuits sizzle!
|
||||
id-card-component-microwave-safe = {$id}'s circuits make a weird noise.
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
- type: Tag
|
||||
tags:
|
||||
- Sheet
|
||||
- Metal
|
||||
|
||||
- type: entity
|
||||
parent: SheetMetalBase
|
||||
|
||||
@@ -121,6 +121,9 @@
|
||||
name: plastic
|
||||
suffix: Full
|
||||
components:
|
||||
- type: Tag
|
||||
tags:
|
||||
- Plastic
|
||||
- type: Material
|
||||
materials:
|
||||
- Plastic
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
- type: Tag
|
||||
tags:
|
||||
- Hoe
|
||||
- Metal
|
||||
- type: Sprite
|
||||
state: fork
|
||||
- type: Utensil
|
||||
@@ -40,6 +41,8 @@
|
||||
types:
|
||||
- Fork
|
||||
breakChance: 0.20
|
||||
- type: Tag
|
||||
tags: [ Plastic ]
|
||||
|
||||
- type: entity
|
||||
parent: UtensilBase
|
||||
@@ -47,6 +50,9 @@
|
||||
name: spoon
|
||||
description: There is no spoon.
|
||||
components:
|
||||
- type: Tag
|
||||
tags:
|
||||
- Metal
|
||||
- type: Sprite
|
||||
state: spoon
|
||||
- type: Item
|
||||
@@ -61,6 +67,9 @@
|
||||
name: plastic spoon
|
||||
description: There is no spoon.
|
||||
components:
|
||||
- type: Tag
|
||||
tags:
|
||||
- Plastic
|
||||
- type: Sprite
|
||||
state: plastic_spoon
|
||||
- type: Item
|
||||
@@ -77,6 +86,9 @@
|
||||
name: plastic knife
|
||||
description: That's not a knife. This is a knife.
|
||||
components:
|
||||
- type: Tag
|
||||
tags:
|
||||
- Plastic
|
||||
- type: Sprite
|
||||
state: plastic_knife
|
||||
- type: Item
|
||||
|
||||
@@ -26,10 +26,9 @@
|
||||
bounds: "-0.3,-0.16,0.3,0.16"
|
||||
mass: 25
|
||||
layer:
|
||||
- MobMask
|
||||
- Opaque
|
||||
- SmallImpassable
|
||||
mask:
|
||||
- MobMask
|
||||
- VaultImpassable
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Structures/Machines/microwave.rsi
|
||||
|
||||
@@ -554,6 +554,7 @@
|
||||
|
||||
- type: reaction
|
||||
id: HotRamen
|
||||
minTemp: 323.15
|
||||
reactants:
|
||||
DryRamen:
|
||||
amount: 3
|
||||
|
||||
@@ -189,6 +189,15 @@
|
||||
- type: Tag
|
||||
id: Matchstick
|
||||
|
||||
- type: Tag
|
||||
id: Metal
|
||||
|
||||
- type: Tag
|
||||
id: MicrowaveMachineUnsafe
|
||||
|
||||
- type: Tag
|
||||
id: MicrowaveSelfUnsafe
|
||||
|
||||
- type: Tag
|
||||
id: MonkeyCube
|
||||
|
||||
@@ -207,6 +216,9 @@
|
||||
- type: Tag
|
||||
id: PercussionInstrument
|
||||
|
||||
- type: Tag
|
||||
id: Plastic
|
||||
|
||||
- type: Tag
|
||||
id: Pill
|
||||
|
||||
|
||||
Reference in New Issue
Block a user