Prevent dead mobs from healing in beds (#8419)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@ using Content.Shared.Body.Components;
|
|||||||
using Content.Shared.Bed;
|
using Content.Shared.Bed;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Shared.Emag.Systems;
|
using Content.Shared.Emag.Systems;
|
||||||
|
using Content.Shared.MobState.Components;
|
||||||
|
|
||||||
namespace Content.Server.Bed
|
namespace Content.Server.Bed
|
||||||
{
|
{
|
||||||
@@ -39,21 +40,24 @@ namespace Content.Server.Bed
|
|||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|
||||||
foreach (var healingComp in EntityQuery<HealOnBuckleHealingComponent>(true))
|
foreach (var (_, bedComponent, strapComponent) in EntityQuery<HealOnBuckleHealingComponent, HealOnBuckleComponent, StrapComponent>())
|
||||||
{
|
{
|
||||||
var bed = healingComp.Owner;
|
|
||||||
var bedComponent = EntityManager.GetComponent<HealOnBuckleComponent>(bed);
|
|
||||||
var strapComponent = EntityManager.GetComponent<StrapComponent>(bed);
|
|
||||||
|
|
||||||
bedComponent.Accumulator += frameTime;
|
bedComponent.Accumulator += frameTime;
|
||||||
|
|
||||||
if (bedComponent.Accumulator < bedComponent.HealTime)
|
if (bedComponent.Accumulator < bedComponent.HealTime)
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
bedComponent.Accumulator -= bedComponent.HealTime;
|
bedComponent.Accumulator -= bedComponent.HealTime;
|
||||||
foreach (EntityUid healedEntity in strapComponent.BuckledEntities)
|
|
||||||
|
if (strapComponent.BuckledEntities.Count == 0) continue;
|
||||||
|
|
||||||
|
var mobStateQuery = GetEntityQuery<MobStateComponent>();
|
||||||
|
|
||||||
|
foreach (var healedEntity in strapComponent.BuckledEntities)
|
||||||
{
|
{
|
||||||
|
if (mobStateQuery.TryGetComponent(healedEntity, out var state) && state.IsDead())
|
||||||
|
continue;
|
||||||
|
|
||||||
_damageableSystem.TryChangeDamage(healedEntity, bedComponent.Damage, true);
|
_damageableSystem.TryChangeDamage(healedEntity, bedComponent.Damage, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,8 +94,8 @@ namespace Content.Server.Bed
|
|||||||
|
|
||||||
private void OnEmagged(EntityUid uid, StasisBedComponent component, GotEmaggedEvent args)
|
private void OnEmagged(EntityUid uid, StasisBedComponent component, GotEmaggedEvent args)
|
||||||
{
|
{
|
||||||
///Repeatable
|
// Repeatable
|
||||||
///Reset any metabolisms first so they receive the multiplier correctly
|
// Reset any metabolisms first so they receive the multiplier correctly
|
||||||
UpdateMetabolisms(uid, component, false);
|
UpdateMetabolisms(uid, component, false);
|
||||||
component.Multiplier = 1 / component.Multiplier;
|
component.Multiplier = 1 / component.Multiplier;
|
||||||
UpdateMetabolisms(uid, component, true);
|
UpdateMetabolisms(uid, component, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user