Files
crystall-punk-14/Content.Server/MobState/States/NormalMobState.cs

38 lines
1.2 KiB
C#
Raw Normal View History

2022-01-05 00:19:23 -08:00
using System;
using Content.Shared.Alert;
ECS damageable (#4529) * ECS and damage Data * Comments and newlines * Added Comments * Make TryChangeDamageEvent immutable * Remove SetAllDamage event Use public SetAllDamage function instead * Undo destructible mistakes That was some shit code. * Rename DamageData to DamageSpecifier And misc small edits misc * Cache trigger prototypes. * Renaming destructible classes & functions * Revert "Cache trigger prototypes." This reverts commit 86bae15ba6616884dba75f552dfdfbe2d1fb6586. * Replace prototypes with prototype IDs. * Split damage.yml into individual files * move get/handle component state to system * Update HealthChange doc * Make godmode call Dirty() on damageable component * Add Initialize() to fix damage test * Make non-static * uncache resistance set prototype and trim DamageableComponentState * Remove unnecessary Dirty() calls during initialization * RemoveTryChangeDamageEvent * revert Dirty() * Fix MobState relying on DamageableComponent.Dirty() * Fix DisposalUnit Tests. These were previously failing, but because the async was not await-ed, this never raised the exception. After I fixed MobState component, this exception stopped happening and instead the assertions started being tested & failing * Disposal test 2: electric boogaloo * Fix typos/mistakes also add comments and fix spacing. * Use Uids instead of IEntity * fix merge * Comments, a merge issue, and making some damage ignore resistances * Extend DamageSpecifier and use it for DamageableComponent * fix master merge * Fix Disposal unit test. Again. Snapgrids were removed in master * Execute Exectute
2021-09-15 03:07:37 +10:00
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
2021-11-08 15:11:58 +01:00
using Content.Shared.MobState.Components;
2021-06-09 22:19:39 +02:00
using Content.Shared.MobState.State;
using Robust.Shared.GameObjects;
2021-06-09 22:19:39 +02:00
namespace Content.Server.MobState.States
{
public sealed class NormalMobState : SharedNormalMobState
{
2021-11-09 12:15:12 +01:00
public override void UpdateState(EntityUid entity, FixedPoint2 threshold, IEntityManager entityManager)
{
2021-11-09 12:15:12 +01:00
base.UpdateState(entity, threshold, entityManager);
2021-11-09 12:15:12 +01:00
if (!entityManager.TryGetComponent(entity, out DamageableComponent? damageable))
{
return;
}
2021-11-09 12:15:12 +01:00
if (!entityManager.TryGetComponent(entity, out MobStateComponent? stateComponent))
{
return;
}
short modifier = 0;
if (stateComponent.TryGetEarliestIncapacitatedState(threshold, out _, out var earliestThreshold))
{
modifier = (short) (damageable.TotalDamage / (earliestThreshold / 7f));
}
2022-01-05 00:19:23 -08:00
EntitySystem.Get<AlertsSystem>().ShowAlert(entity, AlertType.HumanHealth, modifier);
}
}
}