rotting meat (#18515)
Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ using Content.Server.Temperature.Components;
|
||||
using Content.Shared.Atmos.Miasma;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Rejuvenate;
|
||||
using Robust.Server.Containers;
|
||||
@@ -81,8 +82,8 @@ public sealed class RottingSystem : EntitySystem
|
||||
if (!Resolve(uid, ref perishable, false))
|
||||
return false;
|
||||
|
||||
// only dead things perish
|
||||
if (!_mobState.IsDead(uid))
|
||||
// only dead things or inanimate objects can rot
|
||||
if (TryComp<MobStateComponent>(uid, out var mobState) && !_mobState.IsDead(uid, mobState))
|
||||
return false;
|
||||
|
||||
if (_container.TryGetOuterContainer(uid, Transform(uid), out var container) &&
|
||||
@@ -119,10 +120,7 @@ public sealed class RottingSystem : EntitySystem
|
||||
|
||||
private void OnExamined(EntityUid uid, RottingComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (!TryComp<PerishableComponent>(uid, out var perishable))
|
||||
return;
|
||||
|
||||
var stage = (int) (component.TotalRotTime.TotalSeconds / perishable.RotAfter.TotalSeconds);
|
||||
var stage = RotStage(uid, component);
|
||||
var description = stage switch
|
||||
{
|
||||
>= 2 => "miasma-extremely-bloated",
|
||||
@@ -132,6 +130,17 @@ public sealed class RottingSystem : EntitySystem
|
||||
args.PushMarkup(Loc.GetString(description));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the rot stage, usually from 0 to 2 inclusive.
|
||||
/// </summary>
|
||||
public int RotStage(EntityUid uid, RottingComponent? comp = null, PerishableComponent? perishable = null)
|
||||
{
|
||||
if (!Resolve(uid, ref comp, ref perishable))
|
||||
return 0;
|
||||
|
||||
return (int) (comp.TotalRotTime.TotalSeconds / perishable.RotAfter.TotalSeconds);
|
||||
}
|
||||
|
||||
private void OnRejuvenate(EntityUid uid, RottingComponent component, RejuvenateEvent args)
|
||||
{
|
||||
RemCompDeferred<RottingComponent>(uid);
|
||||
@@ -183,6 +192,17 @@ public sealed class RottingSystem : EntitySystem
|
||||
_damageable.TryChangeDamage(uid, damage, true, false);
|
||||
}
|
||||
|
||||
if (TryComp<RotIntoComponent>(uid, out var rotInto))
|
||||
{
|
||||
var stage = RotStage(uid, rotting, perishable);
|
||||
if (stage >= rotInto.Stage)
|
||||
{
|
||||
Spawn(rotInto.Entity, xform.Coordinates);
|
||||
QueueDel(uid);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!TryComp<PhysicsComponent>(uid, out var physics))
|
||||
continue;
|
||||
// We need a way to get the mass of the mob alone without armor etc in the future
|
||||
|
||||
Reference in New Issue
Block a user