Microwave recipes now uses stacktype id instead of entity prototype id for stacked entities (#28225)

This commit is contained in:
blueDev2
2024-06-04 13:12:01 -04:00
committed by GitHub
parent 627187988e
commit 0e93d13cb7
2 changed files with 58 additions and 12 deletions

View File

@@ -35,6 +35,7 @@ using Robust.Shared.Player;
using System.Linq; using System.Linq;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Content.Shared.Stacks;
namespace Content.Server.Kitchen.EntitySystems namespace Content.Server.Kitchen.EntitySystems
{ {
@@ -58,6 +59,8 @@ namespace Content.Server.Kitchen.EntitySystems
[Dependency] private readonly UserInterfaceSystem _userInterface = default!; [Dependency] private readonly UserInterfaceSystem _userInterface = default!;
[Dependency] private readonly HandsSystem _handsSystem = default!; [Dependency] private readonly HandsSystem _handsSystem = default!;
[Dependency] private readonly SharedItemSystem _item = default!; [Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly SharedStackSystem _stack = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[ValidatePrototypeId<EntityPrototype>] [ValidatePrototypeId<EntityPrototype>]
private const string MalfunctionSpark = "Spark"; private const string MalfunctionSpark = "Spark";
@@ -199,16 +202,41 @@ namespace Content.Server.Kitchen.EntitySystems
{ {
foreach (var item in component.Storage.ContainedEntities) foreach (var item in component.Storage.ContainedEntities)
{ {
var metaData = MetaData(item); string? itemID = null;
if (metaData.EntityPrototype == null)
// If an entity has a stack component, use the stacktype instead of prototype id
if (TryComp<StackComponent>(item, out var stackComp))
{
itemID = _prototype.Index<StackPrototype>(stackComp.StackTypeId).Spawn;
}
else
{
var metaData = MetaData(item);
if (metaData.EntityPrototype == null)
{
continue;
}
itemID = metaData.EntityPrototype.ID;
}
if (itemID != recipeSolid.Key)
{ {
continue; continue;
} }
if (metaData.EntityPrototype.ID == recipeSolid.Key) if (stackComp is not null)
{
if (stackComp.Count == 1)
{
_container.Remove(item, component.Storage);
}
_stack.Use(item, 1, stackComp);
break;
}
else
{ {
_container.Remove(item, component.Storage); _container.Remove(item, component.Storage);
EntityManager.DeleteEntity(item); Del(item);
break; break;
} }
} }
@@ -448,17 +476,35 @@ namespace Content.Server.Kitchen.EntitySystems
AddComp<ActivelyMicrowavedComponent>(item); AddComp<ActivelyMicrowavedComponent>(item);
var metaData = MetaData(item); //this simply begs for cooking refactor string? solidID = null;
if (metaData.EntityPrototype == null) int amountToAdd = 1;
continue;
if (solidsDict.ContainsKey(metaData.EntityPrototype.ID)) // If a microwave recipe uses a stacked item, use the default stack prototype id instead of prototype id
if (TryComp<StackComponent>(item, out var stackComp))
{ {
solidsDict[metaData.EntityPrototype.ID]++; solidID = _prototype.Index<StackPrototype>(stackComp.StackTypeId).Spawn;
amountToAdd = stackComp.Count;
} }
else else
{ {
solidsDict.Add(metaData.EntityPrototype.ID, 1); var metaData = MetaData(item); //this simply begs for cooking refactor
if (metaData.EntityPrototype is not null)
solidID = metaData.EntityPrototype.ID;
}
if (solidID is null)
{
continue;
}
if (solidsDict.ContainsKey(solidID))
{
solidsDict[solidID] += amountToAdd;
}
else
{
solidsDict.Add(solidID, amountToAdd);
} }
if (!TryComp<SolutionContainerManagerComponent>(item, out var solMan)) if (!TryComp<SolutionContainerManagerComponent>(item, out var solMan))

View File

@@ -13,7 +13,7 @@
time: 10 time: 10
solids: solids:
FoodPoppy: 1 FoodPoppy: 1
Brutepack: 1 Brutepack: 10
MaterialCloth1: 1 MaterialCloth1: 1
reagents: reagents:
TranexamicAcid: 20 TranexamicAcid: 20
@@ -26,7 +26,7 @@
time: 10 time: 10
solids: solids:
FoodAloe: 1 FoodAloe: 1
Ointment: 1 Ointment: 10
MaterialCloth1: 1 MaterialCloth1: 1
reagents: reagents:
Sigynate: 20 Sigynate: 20