From 8c81312c0c4c29ea89b275a160b196611c5b907b Mon Sep 17 00:00:00 2001 From: Ygg01 Date: Tue, 2 Nov 2021 05:20:14 +0100 Subject: [PATCH] Extractible tweak - Allow grinding and juicing (#5112) --- .../Components/ExtractableComponent.cs | 6 ++--- .../EntitySystems/ReagentGrinderSystem.cs | 19 +++++++++++----- .../Prototypes/Body/Mechanisms/human.yml | 2 +- .../Prototypes/Entities/Mobs/NPCs/animals.yml | 2 +- .../Objects/Consumable/Food/produce.yml | 22 +++++++++---------- .../Objects/Materials/Sheets/other.yml | 2 +- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Content.Server/Kitchen/Components/ExtractableComponent.cs b/Content.Server/Kitchen/Components/ExtractableComponent.cs index bd47e8898e..2d03ccce12 100644 --- a/Content.Server/Kitchen/Components/ExtractableComponent.cs +++ b/Content.Server/Kitchen/Components/ExtractableComponent.cs @@ -17,11 +17,11 @@ namespace Content.Server.Kitchen.Components public override string Name => "Extractable"; [ViewVariables] - [DataField("result")] - public Solution ResultSolution = new(); + [DataField("juiceSolution")] + public Solution? JuiceSolution; [ViewVariables] - [DataField("extractableSolution")] + [DataField("grindableSolutionName")] public string? GrindableSolution; } } diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index 8691fa569c..21ed28daf0 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -20,6 +20,7 @@ using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; +using Robust.Shared.Log; using Robust.Shared.Player; using Robust.Shared.Utility; @@ -227,8 +228,9 @@ namespace Content.Server.Kitchen.EntitySystems { if (canJuice || !entity.TryGetComponent(out ExtractableComponent? component)) continue; - canJuice = component.GrindableSolution == null; - canGrind = component.GrindableSolution != null; + canJuice = component.JuiceSolution != null; + canGrind = component.GrindableSolution != null + && _solutionsSystem.TryGetSolution(entity.Uid, component.GrindableSolution, out _); } } @@ -332,7 +334,12 @@ namespace Content.Server.Kitchen.EntitySystems { foreach (var item in component.Chamber.ContainedEntities.ToList()) { - if (!item.TryGetComponent(out var juiceMe)) continue; + if (!item.TryGetComponent(out var juiceMe) + || juiceMe.JuiceSolution == null) + { + Logger.Warning("Couldn't find a juice solution on entityUid:{0}", item.Uid); + continue; + } var juiceEvent = new ExtractableScalingEvent(); // default of scalar is always 1.0 if (item.HasComponent()) { @@ -340,10 +347,10 @@ namespace Content.Server.Kitchen.EntitySystems } if (component.HeldBeaker.CurrentVolume + - juiceMe.ResultSolution.TotalVolume * juiceEvent.Scalar > + juiceMe.JuiceSolution.TotalVolume * juiceEvent.Scalar > component.HeldBeaker.MaxVolume) continue; - juiceMe.ResultSolution.ScaleSolution(juiceEvent.Scalar); - _solutionsSystem.TryAddSolution(beakerEntity.Uid, component.HeldBeaker, juiceMe.ResultSolution); + juiceMe.JuiceSolution.ScaleSolution(juiceEvent.Scalar); + _solutionsSystem.TryAddSolution(beakerEntity.Uid, component.HeldBeaker, juiceMe.JuiceSolution); item.Delete(); } diff --git a/Resources/Prototypes/Body/Mechanisms/human.yml b/Resources/Prototypes/Body/Mechanisms/human.yml index a77022fb8f..d665fe6351 100644 --- a/Resources/Prototypes/Body/Mechanisms/human.yml +++ b/Resources/Prototypes/Body/Mechanisms/human.yml @@ -9,7 +9,7 @@ - type: Mechanism - type: Food - type: Extractable - extractableSolution: extractableSolution + grindableSolutionName: organ - type: SolutionContainerManager solutions: organ: diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index 390f9c595b..70d0420881 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -385,7 +385,7 @@ # a mob is dead or something idk - type: Food - type: Extractable - extractableSolution: food + grindableSolutionName: food - type: SolutionContainerManager solutions: food: diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml index b639355804..f3519288d1 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml @@ -11,7 +11,7 @@ state: produce - type: Produce - type: Extractable - extractableSolution: food + grindableSolutionName: food # For produce that can be immediately eaten @@ -26,7 +26,6 @@ state: produce - type: Produce - type: Extractable - extractableSolution: food # Subclasses @@ -64,7 +63,7 @@ - type: Produce seed: oat - type: Extractable - result: + juiceSolution: reagents: - ReagentId: MilkOat Quantity: 5 @@ -123,7 +122,7 @@ - type: Produce seed: banana - type: Extractable - result: + juiceSolution: reagents: - ReagentId: JuiceBanana Quantity: 10 @@ -181,7 +180,7 @@ - type: Produce seed: carrots - type: Extractable - result: + juiceSolution: reagents: - ReagentId: JuiceCarrot Quantity: 10 @@ -204,7 +203,7 @@ - type: Produce seed: lemon - type: Extractable - result: + juiceSolution: reagents: - ReagentId: JuiceLime Quantity: 10 @@ -227,7 +226,7 @@ - type: Produce seed: pineapple - type: Extractable - result: + juiceSolution: reagents: - ReagentId: JuicePineapple Quantity: 10 @@ -269,7 +268,8 @@ - type: Produce seed: tomato - type: Extractable - result: + grindableSolutionName: food + juiceSolution: reagents: - ReagentId: JuiceTomato Quantity: 10 @@ -364,7 +364,7 @@ - type: Produce seed: apple - type: Extractable - result: + juiceSolution: reagents: - ReagentId: JuiceApple Quantity: 10 @@ -477,7 +477,7 @@ netsync: false state: slice - type: Extractable - extractableSolution: food + grindableSolutionName: food - type: entity name: pineapple slice @@ -488,7 +488,7 @@ - type: Sprite sprite: Objects/Specific/Hydroponics/pineapple.rsi - type: Extractable - result: + juiceSolution: reagents: - ReagentId: JuicePineapple Quantity: 2 diff --git a/Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml b/Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml index cb4ef340d9..83f137ed4f 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml @@ -93,7 +93,7 @@ - plasma_2 - plasma_3 - type: Extractable - extractableSolution: plasma + grindableSolutionName: plasma - type: SolutionContainerManager solutions: plasma: