From f890786734511d559ca0d9a0a9ba05a81a182526 Mon Sep 17 00:00:00 2001 From: Dvir <dvirf01@gmail.com> Date: Sat, 4 May 2024 02:12:07 +0300 Subject: [PATCH] Allow goblin to eat open mail only --- .../Body/Components/StomachComponent.cs | 12 +++--- .../Nutrition/Components/FoodComponent.cs | 3 +- .../Nutrition/EntitySystems/FoodSystem.cs | 40 +++++++++++++------ Content.Server/Nyanotrasen/Mail/MailSystem.cs | 3 ++ .../Objects/Specific/Mail/base_mail.yml | 2 +- 5 files changed, 39 insertions(+), 21 deletions(-) diff --git a/Content.Server/Body/Components/StomachComponent.cs b/Content.Server/Body/Components/StomachComponent.cs index 2c3e4a14cea..01aa15ee070 100644 --- a/Content.Server/Body/Components/StomachComponent.cs +++ b/Content.Server/Body/Components/StomachComponent.cs @@ -74,24 +74,24 @@ public ReagentDelta(ReagentQuantity reagentQuantity) /// Frontier - Used by goblin for fliping the food quility effects /// </summary> [DataField] - public bool ReverseFoodQuality; + public bool ReverseFoodQuality = false; /// <summary> - /// Frontier - Allow eating trash + /// Frontier - Allow eating mail TODO: Move this to a switch before fully added. /// </summary> [DataField] - public bool TrashDigestion; + public bool MailDigestion = false; /// <summary> /// Frontier - Allow eating fiber like food (Moth food) /// </summary> [DataField] - public bool FiberDigestion; + public bool FiberDigestion = false; /// <summary> - /// Frontier - Allow eating mail TODO: Move this to a switch before fully added. + /// Frontier - Allow eating trash /// </summary> [DataField] - public bool MailDigestion; + public bool TrashDigestion = false; } } diff --git a/Content.Server/Nutrition/Components/FoodComponent.cs b/Content.Server/Nutrition/Components/FoodComponent.cs index e6a44116b11..479dfc8beae 100644 --- a/Content.Server/Nutrition/Components/FoodComponent.cs +++ b/Content.Server/Nutrition/Components/FoodComponent.cs @@ -4,12 +4,13 @@ using Content.Shared.FixedPoint; using Robust.Shared.Audio; using Robust.Shared.Prototypes; +using Content.Server.Mail; // Frontier using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array; namespace Content.Server.Nutrition.Components; -[RegisterComponent, Access(typeof(FoodSystem))] +[RegisterComponent, Access(typeof(FoodSystem), typeof(MailSystem))] // Frontier public sealed partial class FoodComponent : Component { [DataField] diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index 8c99bf28465..427bf5567fe 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -273,7 +273,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg /// Frontier - Food quality system var foodQuality = entity.Comp.Quality; - //var showFlavors = true; // Frontier + var showFlavors = true; foreach (var quality in foodQuality) { @@ -289,7 +289,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg entity.Comp.FinalQuality = "Nasty"; else if (quality == "Toxin") entity.Comp.FinalQuality = "Toxin"; - else if (quality == "Trash") + else if ((quality == "Trash") || (quality == "Mail") || (quality == "Fiber")) entity.Comp.FinalQuality = "Trash"; if (reverseFoodQuality) @@ -312,8 +312,8 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg var damagingRegent = "Toxin"; var emoteId = "Laugh"; - //var msgNasty = Loc.GetString("food-system-nasty", ("used", args.Used), ("target", args.Target)); - //var msgToxin = Loc.GetString("food-system-toxin", ("used", args.Used), ("target", args.Target)); + var msgNasty = Loc.GetString("food-system-nasty", ("used", args.Used), ("target", args.Target)); + var msgToxin = Loc.GetString("food-system-toxin", ("used", args.Used), ("target", args.Target)); TryComp<BloodstreamComponent>(args.Target.Value, out var bloodStream); @@ -363,8 +363,8 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg { if (reverseFoodQuality) { - //showFlavors = false; // Frontier - //_popup.PopupEntity(msgNasty, args.Target.Value, args.User); + showFlavors = false; + _popup.PopupEntity(msgNasty, args.Target.Value, args.User); if (_solutionContainer.ResolveSolution(stomachToUse.Owner, stomachToUse.BodySolutionName, ref stomachToUse.Solution)) _solutionContainer.RemoveReagent(stomachToUse.Solution.Value, "Flavorol", FixedPoint2.New((int) transferAmount)); // Remove from body before it goes to blood @@ -378,8 +378,8 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg { if (reverseFoodQuality) { - //showFlavors = false; // Frontier - //_popup.PopupEntity(msgToxin, args.Target.Value, args.User); + showFlavors = false; + _popup.PopupEntity(msgToxin, args.Target.Value, args.User); if (_solutionContainer.ResolveSolution(stomachToUse.Owner, stomachToUse.BodySolutionName, ref stomachToUse.Solution)) _solutionContainer.RemoveReagent(stomachToUse.Solution.Value, "Flavorol", FixedPoint2.New((int) transferAmount)); // Remove from body before it goes to blood @@ -405,6 +405,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg _solutionContainer.TryAddReagent(bloodStream.ChemicalSolution.Value, speedRegent, FixedPoint2.New((int) transferAmount), out _); // Add to blood } } + /// Frontier - Food quality system end var flavors = args.FlavorMessage; @@ -412,7 +413,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg { var targetName = Identity.Entity(args.Target.Value, EntityManager); var userName = Identity.Entity(args.User, EntityManager); - //if (showFlavors) // Frontier + if (showFlavors) // Frontier _popup.PopupEntity(Loc.GetString("food-system-force-feed-success", ("user", userName), ("flavors", flavors)), entity.Owner, entity.Owner); _popup.PopupEntity(Loc.GetString("food-system-force-feed-success-user", ("target", targetName)), args.User, args.User); @@ -422,7 +423,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg } else { - //if (showFlavors) // Frontier + if (showFlavors) // Frontier _popup.PopupEntity(Loc.GetString(entity.Comp.EatMessage, ("food", entity.Owner), ("flavors", flavors)), args.User, args.User); // log successful voluntary eating @@ -553,10 +554,23 @@ private bool IsDigestibleBy(EntityUid food, FoodComponent component, List<(Stoma // Run through the mobs' stomachs foreach (var (comp, _) in stomachs) { - // Frontier - Allow trash eating - if (!comp.TrashDigestion && component.Quality.Contains("Trash")) + // Frontier - Food system hack job + var foodQuality = component.Quality; + var allowEating = true; + foreach (var quality in foodQuality) + { + if (!comp.MailDigestion && quality == "Mail") + allowEating = true; + else if (!comp.FiberDigestion && quality == "Fiber") + allowEating = true; + else if (!comp.TrashDigestion && quality == "Trash") + allowEating = true; + else + allowEating = false; + } + if (allowEating) return false; - // Frontier - Allow trash eating + // Frontier - Food system hack job // Find a stomach with a SpecialDigestible if (comp.SpecialDigestible == null) diff --git a/Content.Server/Nyanotrasen/Mail/MailSystem.cs b/Content.Server/Nyanotrasen/Mail/MailSystem.cs index ffb173acdf4..baff5801405 100644 --- a/Content.Server/Nyanotrasen/Mail/MailSystem.cs +++ b/Content.Server/Nyanotrasen/Mail/MailSystem.cs @@ -735,6 +735,9 @@ public void OpenMail(EntityUid uid, MailComponent? component = null, EntityUid? _handsSystem.PickupOrDrop(user, entity); } + if (TryComp<FoodComponent>(uid, out var food)) // Frontier + food.Quality = new string[] { "Mail", "Fiber", "Trash" }; + _tagSystem.AddTag(uid, "Trash"); _tagSystem.AddTag(uid, "Recyclable"); component.IsEnabled = false; diff --git a/Resources/Prototypes/Nyanotrasen/Entities/Objects/Specific/Mail/base_mail.yml b/Resources/Prototypes/Nyanotrasen/Entities/Objects/Specific/Mail/base_mail.yml index fd52b33e07d..a384ac9caad 100644 --- a/Resources/Prototypes/Nyanotrasen/Entities/Objects/Specific/Mail/base_mail.yml +++ b/Resources/Prototypes/Nyanotrasen/Entities/Objects/Specific/Mail/base_mail.yml @@ -95,7 +95,7 @@ Blunt: 10 - type: CargoSellBlacklist - type: Food # Frontier - quality: Trash # Frontier, New Food Quality System + quality: Mail # Frontier, New Food Quality System - type: SolutionContainerManager solutions: food: