Show how close bodies are to rotting (#23530)
* 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>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user