]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add plant metabolism effects to chemical guidebook (#28038)
authorFlesh <62557990+PolterTzi@users.noreply.github.com>
Sun, 19 May 2024 23:01:44 +0000 (01:01 +0200)
committerGitHub <noreply@github.com>
Sun, 19 May 2024 23:01:44 +0000 (17:01 -0600)
* draft one of plant metabolism guidebook

* loc fix?

* add attributes loc

* fix loc syntax

* improved appearance

* last commit was undercooked, my bad

* last commit was still undercooked, my worse

* last commit was even still undercooked, my worst

* Addressed comments?

* Fix newlines

* Hopefully this works

* Cleanup, I think

* 2xs

22 files changed:
Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml
Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustAttribute.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustHealth.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustMutationLevel.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustMutationMod.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustNutrition.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustPests.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustToxins.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustWater.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAdjustWeeds.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantAffectGrowth.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantCryoxadone.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantDiethylamine.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/PlantPhalanximine.cs
Content.Server/Chemistry/ReagentEffects/PlantMetabolism/RobustHarvest.cs
Content.Shared/Chemistry/Reagent/ReagentPrototype.cs
Resources/Locale/en-US/guidebook/chemistry/core.ftl
Resources/Locale/en-US/guidebook/chemistry/effects.ftl
Resources/Locale/en-US/guidebook/chemistry/plant-attributes.ftl [new file with mode: 0644]
Resources/Locale/en-US/metabolism/metabolism-groups.ftl
Resources/Prototypes/Chemistry/metabolism_groups.yml

index f46e319abeb5c7ed30a43e9bcef222b09acd1aad..73a17e9bcc9e950639dc3fbe39a3e5ed7215ce6f 100644 (file)
                     </CollapsibleBody>
                 </Collapsible>
             </BoxContainer>
+            <BoxContainer Name="PlantMetabolismsContainer" HorizontalExpand="True">
+                <Collapsible>
+                    <CollapsibleHeading Title="{Loc 'guidebook-reagent-plant-metabolisms-header'}"/>
+                    <CollapsibleBody>
+                        <BoxContainer Name="PlantMetabolismsDescriptionContainer"
+                                      Orientation="Vertical"
+                                      Margin="10 0 10 0"
+                                      HorizontalExpand="True"/>
+                    </CollapsibleBody>
+                </Collapsible>
+            </BoxContainer>
             <BoxContainer Margin="10 5 10 10" HorizontalExpand="True">
                 <!-- The troublemaker !-->
                 <RichTextLabel Name="ReagentDescription" HorizontalAlignment="Left"/>
index 537494933bc4796baf14ab1c3c32d54d65d8091f..87931bf845599402cf560b76e329d618c0b343f2 100644 (file)
@@ -157,6 +157,39 @@ public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag, ISea
         }
         #endregion
 
+        #region PlantMetabolisms
+        if (_chemistryGuideData.ReagentGuideRegistry.TryGetValue(reagent.ID, out var guideEntryRegistryPlant) &&
+            guideEntryRegistryPlant.PlantMetabolisms != null &&
+            guideEntryRegistryPlant.PlantMetabolisms.Count > 0)
+        {
+            PlantMetabolismsDescriptionContainer.Children.Clear();
+            var metabolismLabel = new RichTextLabel();
+            metabolismLabel.SetMarkup(Loc.GetString("guidebook-reagent-plant-metabolisms-rate"));
+            var descriptionLabel = new RichTextLabel
+            {
+                Margin = new Thickness(25, 0, 10, 0)
+            };
+            var descMsg = new FormattedMessage();
+            var descriptionsCount = guideEntryRegistryPlant.PlantMetabolisms.Count;
+            var i = 0;
+            foreach (var effectString in guideEntryRegistryPlant.PlantMetabolisms)
+            {
+                descMsg.AddMarkup(effectString);
+                i++;
+                if (i < descriptionsCount)
+                    descMsg.PushNewline();
+            }
+            descriptionLabel.SetMessage(descMsg);
+
+            PlantMetabolismsDescriptionContainer.AddChild(metabolismLabel);
+            PlantMetabolismsDescriptionContainer.AddChild(descriptionLabel);
+        }
+        else
+        {
+            PlantMetabolismsContainer.Visible = false;
+        }
+        #endregion
+
         GenerateSources(reagent);
 
         FormattedMessage description = new();
index f43b4828f932848fcb9b6a6a09850b080c722563..80c5ca5cf2b915324d9e0cad412d2c723e8a034e 100644 (file)
@@ -15,6 +15,18 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
         [DataField]
         public float Prob { get; protected set; } = 1; // = (80);
 
+        /// <summary>
+        /// Localisation key for the name of the adjusted attribute. Used for guidebook descriptions.
+        /// </summary>
+        [DataField]
+        public abstract string GuidebookAttributeName { get; set; }
+
+        /// <summary>
+        /// Whether the attribute in question is a good thing. Used for guidebook descriptions to determine the color of the number.
+        /// </summary>
+        [DataField]
+        public virtual bool GuidebookIsAttributePositive { get; protected set; } = true;
+
         /// <summary>
         ///     Checks if the plant holder can metabolize the reagent or not. Checks if it has an alive plant by default.
         /// </summary>
@@ -40,6 +52,18 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
             return !(Prob <= 0f) && IoCManager.Resolve<IRobustRandom>().Prob(Prob);
         }
 
-        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
+        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
+        {
+            string color;
+            if (GuidebookIsAttributePositive ^ Amount < 0.0)
+            {
+                color = "green";
+            }
+            else
+            {
+                color = "red";
+            }
+            return Loc.GetString("reagent-effect-guidebook-plant-attribute", ("attribute", Loc.GetString(GuidebookAttributeName)), ("amount", Amount.ToString("0.00")), ("colorName", color), ("chance", Probability));
+        }
     }
 }
index f03464469ebffc2ab41a06b5662d6ac3437821a8..af74c17de77111fb69e24231c579bc4908ad35f7 100644 (file)
@@ -5,6 +5,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
 {
     public sealed partial class PlantAdjustHealth : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-health";
+
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
index 8c8d04765a231df895046596c5cc05fd03db7acf..cf0983bc5107d6e9e13ffec86ec49a189a06f5ef 100644 (file)
@@ -4,6 +4,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
 {
     public sealed partial class PlantAdjustMutationLevel : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-mutation-level";
+
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
index af4a00a044e7e115a90b3974fc34f2da3f408b8e..b43e88538860b6d9a5c6f5d00baf02e7b2cc2078 100644 (file)
@@ -6,6 +6,8 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
     [UsedImplicitly]
     public sealed partial class PlantAdjustMutationMod : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-mutation-mod";
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
index 900121412e84425f30c1f36d8f4683c8bbad4ccb..68bb59870dee14f16229c746805f21e4880c7e1e 100644 (file)
@@ -7,6 +7,8 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
     [UsedImplicitly]
     public sealed partial class PlantAdjustNutrition : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-nutrition";
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager, mustHaveAlivePlant: false))
index 27729b4b2ca741a08808d9b640d27947cb7575e2..9e9787d030d1a3cddac6c3d8112ee07090b9d080 100644 (file)
@@ -6,6 +6,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
     [UsedImplicitly]
     public sealed partial class PlantAdjustPests : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-pests";
+        public override bool GuidebookIsAttributePositive { get; protected set; } = false;
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
index 35130238ad5bf28f339d69d150894ed73e5e8e6b..2279f74910557f1958fe4a7efad54c18904b40d4 100644 (file)
@@ -6,6 +6,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
     [UsedImplicitly]
     public sealed partial class PlantAdjustToxins : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-toxins";
+        public override bool GuidebookIsAttributePositive { get; protected set; } = false;
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
index 71b4670dc651b2156b946b9bb26060eda28622be..a1c184d3b7a15e45a8a433a111011ea9fca14a58 100644 (file)
@@ -7,6 +7,8 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
     [UsedImplicitly]
     public sealed partial class PlantAdjustWater : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-water";
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager, mustHaveAlivePlant: false))
index 6184b95adb8e0a3d2406c531c3e22edd7780aa34..82958e97a1c3c87d53d1b57a1d24b58039ddd456 100644 (file)
@@ -6,6 +6,9 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
     [UsedImplicitly]
     public sealed partial class PlantAdjustWeeds : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-weeds";
+        public override bool GuidebookIsAttributePositive { get; protected set; } = false;
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
index 54ec628fdc93288169617839e49f25a3d90ffbdc..e92b1954c07b8cf3eea083cc5060c99bc8e16b91 100644 (file)
@@ -7,6 +7,8 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
     [UsedImplicitly]
     public sealed partial class PlantAffectGrowth : PlantAdjustAttribute
     {
+        public override string GuidebookAttributeName { get; set; } = "plant-attribute-growth";
+
         public override void Effect(ReagentEffectArgs args)
         {
             if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
index 83a5f56e592424f91bd32573d8647915522ba234..55a7e5c97bbe6beb1dc88fe3427ef7229830b508 100644 (file)
@@ -28,6 +28,6 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
             plantHolderComp.ForceUpdate = true;
         }
 
-        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
+        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-cryoxadone", ("chance", Probability));
     }
 }
index 23cb436d2f10ab11920ece2384b0108564d39299..c98f0be78cb7e6b2493f07963d48fc25e9342751 100644 (file)
@@ -36,6 +36,6 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
             }
         }
 
-        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
+        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-diethylamine", ("chance", Probability));
     }
 }
index c0640d7fc04cfc1182036d25e1519797f239d5e5..7aaca63b7dc533986930b48195ab14859d61b26a 100644 (file)
@@ -19,6 +19,6 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
             plantHolderComp.Seed.Viable = true;
         }
 
-        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
+        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-phalanximine", ("chance", Probability));
     }
 }
index 990a5a5003f39064ca17e38ecff58eef2ce3ba70..4a01cdf51f50b65945feb7b99c7c66e964817c0f 100644 (file)
@@ -49,6 +49,6 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
             }
         }
 
-        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
+        protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-robust-harvest", ("seedlesstreshold", PotencySeedlessThreshold), ("limit", PotencyLimit), ("increase", PotencyIncrease), ("chance", Probability));
     }
 }
index 6095676b9e0a061783072d92135ad2096255d8b4..7e96332ebe97569de945d95286e9e8e1700047c7 100644 (file)
@@ -195,12 +195,22 @@ namespace Content.Shared.Chemistry.Reagent
 
         public Dictionary<ProtoId<MetabolismGroupPrototype>, ReagentEffectsGuideEntry>? GuideEntries;
 
+        public List<string>? PlantMetabolisms = null;
+
         public ReagentGuideEntry(ReagentPrototype proto, IPrototypeManager prototype, IEntitySystemManager entSys)
         {
             ReagentPrototype = proto.ID;
             GuideEntries = proto.Metabolisms?
                 .Select(x => (x.Key, x.Value.MakeGuideEntry(prototype, entSys)))
                 .ToDictionary(x => x.Key, x => x.Item2);
+            if (proto.PlantMetabolisms.Count > 0)
+            {
+                PlantMetabolisms = new List<string> (proto.PlantMetabolisms
+                    .Select(x => x.GuidebookEffectDescription(prototype, entSys))
+                    .Where(x => x is not null)
+                    .Select(x => x!)
+                    .ToArray());
+            }
         }
     }
 
index 5179915e050482bb0b7a607226ff3fcc6ee03acc..2ffb0b2be23189c361a273e7edc7071634f2b16d 100644 (file)
@@ -15,6 +15,8 @@ guidebook-reagent-sources-ent-wrapper = [bold]{$name}[/bold] \[1\]
 guidebook-reagent-sources-gas-wrapper = [bold]{$name} (gas)[/bold] \[1\]
 guidebook-reagent-effects-header = Effects
 guidebook-reagent-effects-metabolism-group-rate = [bold]{$group}[/bold] [color=gray]({$rate} units per second)[/color]
+guidebook-reagent-plant-metabolisms-header = Plant Metabolism
+guidebook-reagent-plant-metabolisms-rate = [bold]Plant Metabolism[/bold] [color=gray](1 unit every 3 seconds as base)[/color]
 guidebook-reagent-physical-description = [italic]Seems to be {$description}.[/italic]
 guidebook-reagent-recipes-mix-info = {$minTemp ->
     [0] {$hasMax ->
index 5b449cd520a67ff0822285c03466917b49c091d3..5579c95e9df661e7a20c7ccef2284da8bbd24073 100644 (file)
@@ -339,7 +339,7 @@ reagent-effect-guidebook-innoculate-zombie-infection =
         *[other] cure
     } an ongoing zombie infection, and provides immunity to future infections
 
-reagent-effect-guidebook-reduce-rotting = 
+reagent-effect-guidebook-reduce-rotting =
     { $chance ->
         [1] Regenerates
         *[other] regenerate
@@ -350,3 +350,33 @@ reagent-effect-guidebook-missing =
         [1] Causes
         *[other] cause
     } an unknown effect as nobody has written this effect yet
+
+reagent-effect-guidebook-plant-attribute =
+    { $chance ->
+        [1] Adjusts
+        *[other] adjust
+    } {$attribute} by [color={$colorName}]{$amount}[/color]
+
+reagent-effect-guidebook-plant-cryoxadone =
+    { $chance ->
+        [1] Ages back
+        *[other] age back
+    } the plant, depending on the plant's age and time to grow
+
+reagent-effect-guidebook-plant-phalanximine =
+    { $chance ->
+        [1] Makes
+        *[other] make
+    } a plant not viable due to mutation viable again
+
+reagent-effect-guidebook-plant-diethylamine =
+    { $chance ->
+        [1] Increases
+        *[other] increase
+    } the plant's lifespan and/or base health with 10% chance for each.
+
+reagent-effect-guidebook-plant-robust-harvest =
+    { $chance ->
+        [1] Increases
+        *[other] increase
+    } the plant's potency by {$increase} up to a maximum of {$limit}. Causes the plant to lose its seeds once the potency reaches {$seedlesstreshold}. Trying to add potency over {$limit} may cause decrease in yield at a 10% chance.
diff --git a/Resources/Locale/en-US/guidebook/chemistry/plant-attributes.ftl b/Resources/Locale/en-US/guidebook/chemistry/plant-attributes.ftl
new file mode 100644 (file)
index 0000000..2575221
--- /dev/null
@@ -0,0 +1,9 @@
+plant-attribute-growth = age
+plant-attribute-water = water level
+plant-attribute-weeds = weeds level
+plant-attribute-toxins = toxins level
+plant-attribute-nutrition = nutrition level
+plant-attribute-mutation-level = mutation level
+plant-attribute-pests = pests level
+plant-attribute-mutation-mod = mutation modifier
+plant-attribute-health = health
index 404d0fc786880af37a6f0c22aae13b2745ac2016..b9bd477fbb60c6a5613d5fb6bea60584131e4ea5 100644 (file)
@@ -5,3 +5,4 @@ metabolism-group-alcohol = Alcohol
 metabolism-group-food = Food
 metabolism-group-drink = Drink
 metabolism-group-gas = Gas
+metabolism-group-plant-metabolisms = Plant Metabolism
index b2035671af049b857299e04ffe629ec0e6dfe723..1cc1f19311d78e77309b94f2bd8ebe5ffd0f29c9 100644 (file)
@@ -27,3 +27,8 @@
 - type: metabolismGroup
   id: Gas
   name: metabolism-group-gas
+
+# Dummy for the guide
+- type: metabolismGroup
+  id: PlantMetabolisms
+  name: metabolism-group-plant-metabolisms