Files
Delta-v/Content.Shared/Damage/Systems/DamageableSystem.cs
T
CorynandJanet Blackquill cb62b27fcf Nubody (2/3) - ShitMed removal (#5844)
* Reapply "Nubody Merge" (#5807)

This reverts commit d62f7cef10.

* Revert "Nubody Merge (#5670)"

This reverts commit b465cfb3fd.

* Revert "IPC fibers (#4968)"

This reverts commit c2b42211f0.

* Revert "IPC Polymorph fix (#4545)"

This reverts commit fa03d8c655.

* Revert "fix IPC not having humanoid emotes (#4445)"

This reverts commit 216fdf999f.

* Revert "ipc heat/cold (#4306)"

This reverts commit fafd5cf816.

* Revert "ipc cables (#4283)"

This reverts commit 54958039a1.

* Revert "feat: ipcs now have dynamic power draw based off movement speed (#3917)"

This reverts commit 71e8b7e64b.

* Revert "fix ipcs not being able to disarm (#3374)"

This reverts commit 764c4dcf54.

* Revert "make steel heal caustic for ipcs (#3206)"

This reverts commit 450ac82550.

* Revert "add missing ipc survival boxes (#3065)"

This reverts commit 888c9cdb00.

* Revert "make borgs use ipc repairing (#3064)"

This reverts commit f77a49dd0b.

* Revert "Update hud.yml to add ipcs to diagnostic hud (#3019)"

This reverts commit 7220643531.

* Revert "Tweak IPCs (#2979)"

This reverts commit 98b47476de.

* Revert "fix nukies ipc test fail (#2957)"

This reverts commit 4a1acbf863.

* Revert "fix ipc nukies not getting comms (#2884)"

This reverts commit 8a2254770e.

* Revert "fix ipc encryption key mispredict (#2879)"

This reverts commit f08726efc1.

* Revert "Merge pull request #2800 from Spielern/port-ipc"

This reverts commit 822fa4312c, reversing
changes made to fe4c23c702.

* Remove and Fix rest of IPC Hangons causing crashes

* Integration test Errors

* Expand migration file with removed IPC stuff

* IPC Leg was found and migrated to naught

* Revert "Merge pull request #2542 from deltanedas/shitmed-ops"

This reverts commit 83a8002922, reversing
changes made to baa89b0052.

* Revert "Set up surgical augments infrastructure & add tool panel augments (#3059)"

This reverts commit a40f0be6fd.

* Revert "Psionic Prosthetics (#4689)"

This reverts commit 2679bb238a.

* Revert "Add surgical cleanliness and sanitation (#2847)"

This reverts commit 64565ba4f7.

* Remove unremoved mentions

* Revert "Add autoclave to easily sanitize large amounts of items and faster (#2933)"

This reverts commit d0da90fa2e.

* Shit Med Removed

* Remove _ShitMed Folders and fix Errors in Console

* Add OrganAnimalBrain into the mirgraiton file

* Heads no Input Mover

* Monke

* Full migration file I guess

* oops

* shiv state fix

* Restore accidental deleted recipe

* Forgot one flt mention

* Fix more issues

* Comment out Damage Visual for motorkind for now

* Motorkind...

* Commenting stuff out for now

* thought there'd be more of this to gut

---------

Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
2026-05-21 20:27:04 -04:00

122 lines
5.1 KiB
C#

using System.Linq;
using Content.Shared.Chemistry;
using Content.Shared.Damage.Components;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Explosion.EntitySystems;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.GameStates;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Damage.Systems;
public sealed partial class DamageableSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly MobThresholdSystem _mobThreshold = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly SharedChemistryGuideDataSystem _chemistryGuideData = default!;
[Dependency] private readonly SharedExplosionSystem _explosion = default!;
private EntityQuery<AppearanceComponent> _appearanceQuery;
private EntityQuery<DamageableComponent> _damageableQuery;
public float UniversalAllDamageModifier { get; private set; } = 1f;
public float UniversalAllHealModifier { get; private set; } = 1f;
public float UniversalMeleeDamageModifier { get; private set; } = 1f;
public float UniversalProjectileDamageModifier { get; private set; } = 1f;
public float UniversalHitscanDamageModifier { get; private set; } = 1f;
public float UniversalReagentDamageModifier { get; private set; } = 1f;
public float UniversalReagentHealModifier { get; private set; } = 1f;
public float UniversalExplosionDamageModifier { get; private set; } = 1f;
public float UniversalThrownDamageModifier { get; private set; } = 1f;
public float UniversalTopicalsHealModifier { get; private set; } = 1f;
public float UniversalMobDamageModifier { get; private set; } = 1f;
/// <summary>
/// If the damage in a DamageableComponent was changed this function should be called.
/// </summary>
/// <remarks>
/// This updates cached damage information, flags the component as dirty, and raises a damage changed event.
/// The damage changed event is used by other systems, such as damage thresholds.
/// </remarks>
private void OnEntityDamageChanged(
Entity<DamageableComponent> ent,
DamageSpecifier? damageDelta = null,
bool interruptsDoAfters = true,
EntityUid? origin = null
)
{
ent.Comp.Damage.GetDamagePerGroup(_prototypeManager, ent.Comp.DamagePerGroup);
ent.Comp.TotalDamage = ent.Comp.Damage.GetTotal();
Dirty(ent);
if (damageDelta != null && _appearanceQuery.TryGetComponent(ent, out var appearance))
{
_appearance.SetData(
ent,
DamageVisualizerKeys.DamageUpdateGroups,
new DamageVisualizerGroupData(ent.Comp.DamagePerGroup.Keys.ToList()),
appearance
);
}
// TODO DAMAGE
// byref struct event.
RaiseLocalEvent(ent, new DamageChangedEvent(ent.Comp, damageDelta, interruptsDoAfters, origin));
}
private void DamageableGetState(Entity<DamageableComponent> ent, ref ComponentGetState args)
{
if (_netMan.IsServer)
{
args.State = new DamageableComponentState(
ent.Comp.Damage.DamageDict,
ent.Comp.DamageContainerID,
ent.Comp.DamageModifierSetId,
ent.Comp.HealthBarThreshold
);
// TODO BODY SYSTEM pass damage onto body system
// BOBBY WHEN? 😭
// BOBBY SOON 🫡
return;
}
// avoid mispredicting damage on newly spawned entities.
args.State = new DamageableComponentState(
ent.Comp.Damage.DamageDict.ShallowClone(),
ent.Comp.DamageContainerID,
ent.Comp.DamageModifierSetId,
ent.Comp.HealthBarThreshold
);
}
/// <summary>
/// Goes through an entity damage's and saves them inside a dictionary if the value is higher than 0
/// The dictionary is structured with a string for the name of the damage type, and a FixedPoint2 for the numeric damage value
/// </summary>
public Dictionary<ProtoId<DamageTypePrototype>, FixedPoint2> GetDamages(Dictionary<ProtoId<DamageGroupPrototype>, FixedPoint2> damagePerGroup, DamageSpecifier damage)
{
var damageTypes = new Dictionary<ProtoId<DamageTypePrototype>, FixedPoint2>();
foreach (var (damageGroupId, _) in damagePerGroup) //go through each group
{
var group = _prototypeManager.Index<DamageGroupPrototype>(damageGroupId); //get group
foreach (var type in group.DamageTypes) //go through each type inside that group
{
if (!damage.DamageDict.TryGetValue(type, out var damageValue) || damageValue == 0) //get value and make sure it isn't 0
continue;
damageTypes.Add(type, damageValue);
}
}
return damageTypes;
}
}