Prevent dead mobs from healing in beds (#8419)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
themias 2022-05-24 22:31:15 -04:00 committed by GitHub
parent 16f7a4cd1a
commit 90e6cf063d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 10 deletions

View File

@ -7,6 +7,7 @@ using Content.Shared.Body.Components;
using Content.Shared.Bed;
using Content.Server.Power.Components;
using Content.Shared.Emag.Systems;
using Content.Shared.MobState.Components;
namespace Content.Server.Bed
{
@ -39,21 +40,24 @@ namespace Content.Server.Bed
{
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;
if (bedComponent.Accumulator < bedComponent.HealTime)
{
continue;
}
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);
}
}
@ -90,8 +94,8 @@ namespace Content.Server.Bed
private void OnEmagged(EntityUid uid, StasisBedComponent component, GotEmaggedEvent args)
{
///Repeatable
///Reset any metabolisms first so they receive the multiplier correctly
// Repeatable
// Reset any metabolisms first so they receive the multiplier correctly
UpdateMetabolisms(uid, component, false);
component.Multiplier = 1 / component.Multiplier;
UpdateMetabolisms(uid, component, true);