mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 08:07:28 +00:00
* Nubody (#42419) * Nubody * fix test fails * gibbing * lung test returns * doc comment * hand organ test * giblet test * yaml formatting * returning * relocate * trimming * re-smite * oops thusd tweak * arachnids have slower metabolism i guess * never mind the old behaviour is bad actually * rider whyyy * style changes and allat * fix collision --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * C# files done * Visual nubody (humanoid appearance refactor) (#42476) * initial visual nubody * oops overlay * im so pheeming rn * conversion... * tests * comeback of the underwear * oops eyes * blabbl * zeds * yaml linted * search and visible count constraints * reordering * preserve previously selected markings colors * fix test * some ui niceties * ordering * make DB changes backwards-compatible/downgrade-friendly * fix things again * fix migration * vulpkanin markings limit increase * wrapping * code cleanup and more code cleanup and more code cleanup and more code cleanup and * fix slop ports * better sampling API * make filter work + use the method i made for its intended purpose * fix test fails real quick * magic mirror cleanup, remove TODO * don't 0-init the organ profile data * remove deltastates --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Let vox eat trash again (#42503) * C# complete port * Getting closer * Harpy Nubody Port * Port Feroxi, Kitsune. Fix some yml typos and remove ipcs stuff * Port Oni * Port Rest, except Motorkind * Port Motorkind * Remove more surgery, restore too much deleted stuff * Fix Typos and change some organ names. Need to split eyes next * Harpy HAve Wings again * Some fixes, More Surgeyr Removal, Copying of eye organs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use correct Body imports * Markings Refactoring, Harpy Layering * Motorkind doesn't crash anymore. Some layer remappings. * Allow Organs to have Markings Displacements again. (#43604) * first shtep * readd markings support --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix STalk eyes and several layerings * Fix sexed organs (#42554) * Fix markings for several species, fit them for sexed organs and rename some files to fit them for it * Additional IPC-related removals * Vulpkanin eyes are now correct again * Fix Subtle Cultist Marks on species * Fix Asakim Sprites (sexed) and make CD imports work * Migration, error fixes, and Height * Fix humanoid profile voice being broken (#42550) Fix humanoid appearance voice being broken * Change Kitsune SexChanged Event to with ref * Fix asakim issue, Respirator fix * Simplify hands UI code (#42534) * Simplify hands UI code * i remembered about SortedHands in the component * minor cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Set size of Analyzer back to 350, Kitsune can't gib themselves no more. Migration * yml linter errors and an rudimentary onAdd Organ Functionality * Fixing it trying to remove nothing * midpoint migration * Why do you put so many organs everywhere * More missing prototypes * Migration of more organs * Forgot lungs * Move character preview handling into a specialized control (#41252) * Move character preview handling into a specialized control Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> * Restore job name that I accidentally removed from character picker buttons * Just resolve dependencies the standard way --------- Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Janet Blackquill <uhhadd@gmail.com> * Drop ICharacterProfile/ICharacterAppearance interfaces (#42661) * Ensure profile loading only returns valid species (#42842) (Stable merge) (#42865) Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> * Changes to make it work for us. * No more bald Harpy * OperatingTables instead of null * Adding Delta V Comments, commenting out instead of deleting * Fix broken Height Scale. * Remove HumanoidSilicon Mention * Did an error. Readded, uncommented. * Clean up Marking data structure, add tests for Zombie transformation (#42756) * Clean up Marking data structure, add tests for Zombie transformation * empty * AAAAAAAAAAAAAAAA --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix markings colour setting (#42771) * Fix: Markings Color For Downstream * Comment out A Leg. Remove Todo * Revert to original hidden species code --------- Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Co-authored-by: Absotively <jen@jenpollock.ca> Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Myra <vasilis@pikachu.systems>
307 lines
10 KiB
C#
307 lines
10 KiB
C#
using Content.Shared.CCVar;
|
|
using Content.Shared.Damage.Components;
|
|
using Content.Shared.Damage.Prototypes;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Inventory;
|
|
using Content.Shared.Radiation.Events;
|
|
using Content.Shared.Rejuvenate;
|
|
using Robust.Shared.GameStates;
|
|
|
|
namespace Content.Shared.Damage.Systems;
|
|
|
|
public sealed partial class DamageableSystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<DamageableComponent, ComponentInit>(DamageableInit);
|
|
SubscribeLocalEvent<DamageableComponent, ComponentHandleState>(DamageableHandleState);
|
|
SubscribeLocalEvent<DamageableComponent, ComponentGetState>(DamageableGetState);
|
|
SubscribeLocalEvent<DamageableComponent, OnIrradiatedEvent>(OnIrradiated);
|
|
SubscribeLocalEvent<DamageableComponent, RejuvenateEvent>(OnRejuvenate);
|
|
|
|
_appearanceQuery = GetEntityQuery<AppearanceComponent>();
|
|
_damageableQuery = GetEntityQuery<DamageableComponent>();
|
|
|
|
// Damage modifier CVars are updated and stored here to be queried in other systems.
|
|
// Note that certain modifiers requires reloading the guidebook.
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestAllDamageModifier,
|
|
value =>
|
|
{
|
|
UniversalAllDamageModifier = value;
|
|
_chemistryGuideData.ReloadAllReagentPrototypes();
|
|
_explosion.ReloadMap();
|
|
},
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestAllHealModifier,
|
|
value =>
|
|
{
|
|
UniversalAllHealModifier = value;
|
|
_chemistryGuideData.ReloadAllReagentPrototypes();
|
|
},
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestProjectileDamageModifier,
|
|
value => UniversalProjectileDamageModifier = value,
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestMeleeDamageModifier,
|
|
value => UniversalMeleeDamageModifier = value,
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestProjectileDamageModifier,
|
|
value => UniversalProjectileDamageModifier = value,
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestHitscanDamageModifier,
|
|
value => UniversalHitscanDamageModifier = value,
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestReagentDamageModifier,
|
|
value =>
|
|
{
|
|
UniversalReagentDamageModifier = value;
|
|
_chemistryGuideData.ReloadAllReagentPrototypes();
|
|
},
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestReagentHealModifier,
|
|
value =>
|
|
{
|
|
UniversalReagentHealModifier = value;
|
|
_chemistryGuideData.ReloadAllReagentPrototypes();
|
|
},
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestExplosionDamageModifier,
|
|
value =>
|
|
{
|
|
UniversalExplosionDamageModifier = value;
|
|
_explosion.ReloadMap();
|
|
},
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestThrownDamageModifier,
|
|
value => UniversalThrownDamageModifier = value,
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestTopicalsHealModifier,
|
|
value => UniversalTopicalsHealModifier = value,
|
|
true
|
|
);
|
|
Subs.CVar(
|
|
_config,
|
|
CCVars.PlaytestMobDamageModifier,
|
|
value => UniversalMobDamageModifier = value,
|
|
true
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialize a damageable component
|
|
/// </summary>
|
|
private void DamageableInit(Entity<DamageableComponent> ent, ref ComponentInit _)
|
|
{
|
|
if (
|
|
ent.Comp.DamageContainerID is null ||
|
|
!_prototypeManager.Resolve(ent.Comp.DamageContainerID, out var damageContainerPrototype)
|
|
)
|
|
{
|
|
// No DamageContainerPrototype was given. So we will allow the container to support all damage types
|
|
foreach (var type in _prototypeManager.EnumeratePrototypes<DamageTypePrototype>())
|
|
{
|
|
ent.Comp.Damage.DamageDict.TryAdd(type.ID, FixedPoint2.Zero);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Initialize damage dictionary, using the types and groups from the damage
|
|
// container prototype
|
|
foreach (var type in damageContainerPrototype.SupportedTypes)
|
|
{
|
|
ent.Comp.Damage.DamageDict.TryAdd(type, FixedPoint2.Zero);
|
|
}
|
|
|
|
foreach (var groupId in damageContainerPrototype.SupportedGroups)
|
|
{
|
|
var group = _prototypeManager.Index(groupId);
|
|
foreach (var type in group.DamageTypes)
|
|
{
|
|
ent.Comp.Damage.DamageDict.TryAdd(type, FixedPoint2.Zero);
|
|
}
|
|
}
|
|
}
|
|
|
|
ent.Comp.Damage.GetDamagePerGroup(_prototypeManager, ent.Comp.DamagePerGroup);
|
|
ent.Comp.TotalDamage = ent.Comp.Damage.GetTotal();
|
|
}
|
|
|
|
private void OnIrradiated(Entity<DamageableComponent> ent, ref OnIrradiatedEvent args)
|
|
{
|
|
var damageValue = FixedPoint2.New(args.TotalRads);
|
|
|
|
// Radiation should really just be a damage group instead of a list of types.
|
|
DamageSpecifier damage = new();
|
|
foreach (var typeId in ent.Comp.RadiationDamageTypeIDs)
|
|
{
|
|
damage.DamageDict.Add(typeId, damageValue);
|
|
}
|
|
|
|
ChangeDamage(ent.Owner, damage, interruptsDoAfters: false, origin: args.Origin);
|
|
}
|
|
|
|
private void OnRejuvenate(Entity<DamageableComponent> ent, ref RejuvenateEvent args)
|
|
{
|
|
// Do this so that the state changes when we set the damage
|
|
_mobThreshold.SetAllowRevives(ent, true);
|
|
ClearAllDamage(ent.AsNullable());
|
|
_mobThreshold.SetAllowRevives(ent, false);
|
|
}
|
|
|
|
private void DamageableHandleState(Entity<DamageableComponent> ent, ref ComponentHandleState args)
|
|
{
|
|
if (args.Current is not DamageableComponentState state)
|
|
return;
|
|
|
|
ent.Comp.DamageContainerID = state.DamageContainerId;
|
|
ent.Comp.DamageModifierSetId = state.ModifierSetId;
|
|
ent.Comp.HealthBarThreshold = state.HealthBarThreshold;
|
|
|
|
// Has the damage actually changed?
|
|
DamageSpecifier newDamage = new() { DamageDict = new Dictionary<string, FixedPoint2>(state.DamageDict) };
|
|
var delta = newDamage - ent.Comp.Damage;
|
|
delta.TrimZeros();
|
|
|
|
if (delta.Empty)
|
|
return;
|
|
|
|
ent.Comp.Damage = newDamage;
|
|
|
|
OnEntityDamageChanged(ent, delta);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised before damage is done, so stuff can cancel it if necessary.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public record struct BeforeDamageChangedEvent(DamageSpecifier Damage, EntityUid? Origin = null, bool Cancelled = false);
|
|
|
|
/// <summary>
|
|
/// Raised on an entity when damage is about to be dealt,
|
|
/// in case anything else needs to modify it other than the base
|
|
/// damageable component.
|
|
///
|
|
/// For example, armor.
|
|
/// </summary>
|
|
public sealed class DamageModifyEvent(DamageSpecifier damage, EntityUid? origin = null)
|
|
: EntityEventArgs, IInventoryRelayEvent
|
|
{
|
|
/// <inheritdoc/>
|
|
/// <remarks>
|
|
/// Whenever locational damage is a thing, this should just check only that bit of armor.
|
|
/// </remarks>
|
|
public SlotFlags TargetSlots => ~SlotFlags.POCKET;
|
|
|
|
/// <summary>
|
|
/// Contains the original damage, prior to any modifers.
|
|
/// </summary>
|
|
public readonly DamageSpecifier OriginalDamage = damage;
|
|
|
|
/// <summary>
|
|
/// Contains the damage after modifiers have been applied.
|
|
/// This is the damage that will be inflicted.
|
|
/// </summary>
|
|
public DamageSpecifier Damage = damage;
|
|
|
|
/// <summary>
|
|
/// Contains the entity which caused the damage, if any was responsible.
|
|
/// </summary>
|
|
public readonly EntityUid? Origin = origin;
|
|
}
|
|
|
|
public sealed class DamageChangedEvent : EntityEventArgs
|
|
{
|
|
/// <summary>
|
|
/// This is the component whose damage was changed.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Given that nearly every component that cares about a change in the damage, needs to know the
|
|
/// current damage values, directly passing this information prevents a lot of duplicate
|
|
/// Owner.TryGetComponent() calls.
|
|
/// </remarks>
|
|
public readonly DamageableComponent Damageable;
|
|
|
|
/// <summary>
|
|
/// The amount by which the damage has changed. If the damage was set directly to some number, this will be
|
|
/// null.
|
|
/// </summary>
|
|
public readonly DamageSpecifier? DamageDelta;
|
|
|
|
/// <summary>
|
|
/// Was any of the damage change dealing damage, or was it all healing?
|
|
/// </summary>
|
|
public readonly bool DamageIncreased;
|
|
|
|
/// <summary>
|
|
/// Does this event interrupt DoAfters?
|
|
/// Note: As provided in the constructor, this *does not* account for DamageIncreased.
|
|
/// As written into the event, this *does* account for DamageIncreased.
|
|
/// </summary>
|
|
public readonly bool InterruptsDoAfters;
|
|
|
|
/// <summary>
|
|
/// Contains the entity which caused the change in damage, if any was responsible.
|
|
/// </summary>
|
|
public readonly EntityUid? Origin;
|
|
|
|
public DamageChangedEvent(
|
|
DamageableComponent damageable,
|
|
DamageSpecifier? damageDelta,
|
|
bool interruptsDoAfters,
|
|
EntityUid? origin
|
|
)
|
|
{
|
|
Damageable = damageable;
|
|
DamageDelta = damageDelta;
|
|
Origin = origin;
|
|
|
|
if (DamageDelta is null)
|
|
return;
|
|
|
|
foreach (var damageChange in DamageDelta.DamageDict.Values)
|
|
{
|
|
if (damageChange <= 0)
|
|
continue;
|
|
|
|
DamageIncreased = true;
|
|
|
|
break;
|
|
}
|
|
|
|
InterruptsDoAfters = interruptsDoAfters && DamageIncreased;
|
|
}
|
|
}
|