]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Show how close bodies are to rotting (#23530)
authorGuillaume E <262623+quatre@users.noreply.github.com>
Wed, 10 Jan 2024 12:00:21 +0000 (13:00 +0100)
committerGitHub <noreply@github.com>
Wed, 10 Jan 2024 12:00:21 +0000 (23:00 +1100)
* Show how close bodies are to rotting

When examining a dead body, you will be able to see of close
it is to rotting.

 - "It still looks fresh.", in the first third of the pre-rot period
 - "It looks ripe.", in the second third
 - "It's starting to look bad.", in the last third

This could help players prioritize medical care.

* Alter the wording of the pre-rot indicator

* Use numeric rotting stages in FTL

---------

Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
Content.Server/Atmos/Rotting/RottingSystem.cs
Resources/Locale/en-US/disease/miasma.ftl

index db0815f3a67f83d6843d54ac886e9528ec00fff4..246758532a6e3b29ebf439308c588bc43dc96388 100644 (file)
@@ -32,6 +32,7 @@ public sealed class RottingSystem : EntitySystem
         SubscribeLocalEvent<PerishableComponent, MapInitEvent>(OnPerishableMapInit);
         SubscribeLocalEvent<PerishableComponent, EntityUnpausedEvent>(OnPerishableUnpaused);
         SubscribeLocalEvent<PerishableComponent, MobStateChangedEvent>(OnMobStateChanged);
+        SubscribeLocalEvent<PerishableComponent, ExaminedEvent>(OnPerishableExamined);
 
         SubscribeLocalEvent<RottingComponent, EntityUnpausedEvent>(OnRottingUnpaused);
         SubscribeLocalEvent<RottingComponent, ComponentShutdown>(OnShutdown);
@@ -122,6 +123,31 @@ public sealed class RottingSystem : EntitySystem
         tileMix?.AdjustMoles(Gas.Ammonia, molsToDump);
     }
 
+    private void OnPerishableExamined(Entity<PerishableComponent> perishable, ref ExaminedEvent args)
+    {
+        int maxStages = 3;
+        int stage = PerishStage(perishable, maxStages);
+        if (stage < 1 || stage > maxStages)
+        {
+            // We dont push an examined string if it hasen't started "perishing" or it's already rotting
+            return;
+        }
+
+        var description = "perishable-" + stage;
+        args.PushMarkup(Loc.GetString(description));
+    }
+
+    /// <summary>
+    /// Return an integer from 0 to maxStage representing how close to rotting an entity is. Used to
+    /// generate examine messages for items that are starting to rot.
+    /// </summary>
+    public int PerishStage(Entity<PerishableComponent> perishable, int maxStages)
+    {
+        if (perishable.Comp.RotAfter.TotalSeconds == 0 || perishable.Comp.RotAccumulator.TotalSeconds == 0)
+            return 0;
+        return (int)(1 + maxStages * perishable.Comp.RotAccumulator.TotalSeconds / perishable.Comp.RotAfter.TotalSeconds);
+    }
+
     private void OnExamined(EntityUid uid, RottingComponent component, ExaminedEvent args)
     {
         var stage = RotStage(uid, component);
index cc0c4117e5d458a7f809dbd1f14dba5549d0e647..06c96bc73d27d28796ea0dcf4300eaaf026e3255 100644 (file)
@@ -1,4 +1,7 @@
 ammonia-smell = Something smells pungent!
+perishable-1 = [color=green]It still looks fresh.[/color]
+perishable-2 = [color=orangered]It looks somewhat fresh.[/color]
+perishable-3 = [color=red]It doesn't look fresh anymore.[/color]
 rotting-rotting = [color=orange]It's rotting![/color]
 rotting-bloated = [color=orangered]It's bloated![/color]
 rotting-extremely-bloated = [color=red]It's extremely bloated![/color]