Stunnable New Status and Cleanup (#38618)

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
This commit is contained in:
Princess Cheeseballs
2025-07-21 10:22:11 -07:00
committed by GitHub
parent 2b2b9b11b8
commit e85bc1bb8c
56 changed files with 620 additions and 316 deletions

View File

@@ -8,9 +8,12 @@ using Content.Shared.Damage.Events;
using Content.Shared.Database;
using Content.Shared.Effects;
using Content.Shared.FixedPoint;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Projectiles;
using Content.Shared.Rejuvenate;
using Content.Shared.Rounding;
using Content.Shared.StatusEffectNew;
using Content.Shared.Stunnable;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee.Events;
@@ -20,6 +23,7 @@ using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
@@ -27,15 +31,19 @@ namespace Content.Shared.Damage.Systems;
public abstract partial class SharedStaminaSystem : EntitySystem
{
public static readonly EntProtoId StaminaLow = "StatusEffectStaminaLow";
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] protected readonly IGameTiming Timing = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly MetaDataSystem _metadata = default!;
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
[Dependency] protected readonly SharedStunSystem StunSystem = default!;
[Dependency] private readonly MovementModStatusSystem _movementMod = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
[Dependency] private readonly StatusEffectsSystem _status = default!;
[Dependency] protected readonly SharedStunSystem StunSystem = default!;
/// <summary>
/// How much of a buffer is there between the stun duration and when stuns can be re-applied.
@@ -113,8 +121,9 @@ public abstract partial class SharedStaminaSystem : EntitySystem
}
entity.Comp.StaminaDamage = 0;
AdjustSlowdown(entity.Owner);
AdjustStatus(entity.Owner);
RemComp<ActiveStaminaComponent>(entity);
_status.TryRemoveStatusEffect(entity, StaminaLow);
UpdateStaminaVisuals(entity);
Dirty(entity);
}
@@ -284,7 +293,7 @@ public abstract partial class SharedStaminaSystem : EntitySystem
component.NextUpdate = nextUpdate;
}
AdjustSlowdown(uid);
AdjustStatus(uid);
UpdateStaminaVisuals((uid, component));
@@ -292,6 +301,7 @@ public abstract partial class SharedStaminaSystem : EntitySystem
if (component.AfterCritical && oldDamage > component.StaminaDamage && component.StaminaDamage <= 0f)
{
component.AfterCritical = false; // Since the recovery from the crit has been completed, we are no longer 'after crit'
_status.TryRemoveStatusEffect(uid, StaminaLow);
}
if (!component.Critical)
@@ -384,7 +394,7 @@ public abstract partial class SharedStaminaSystem : EntitySystem
component.Critical = true;
component.StaminaDamage = component.CritThreshold;
if (StunSystem.TryParalyze(uid, component.StunTime, true))
if (StunSystem.TryUpdateParalyzeDuration(uid, component.StunTime))
StunSystem.TrySeeingStars(uid);
// Give them buffer before being able to be re-stunned
@@ -412,18 +422,19 @@ public abstract partial class SharedStaminaSystem : EntitySystem
}
/// <summary>
/// Adjusts the movement speed of an entity based on its current <see cref="StaminaComponent.StaminaDamage"/> value.
/// If the entity has a <see cref="SlowOnDamageComponent"/>, its custom damage-to-speed thresholds are used,
/// otherwise, a default set of thresholds is applied.
/// The method determines the closest applicable damage threshold below the crit limit and applies the corresponding
/// speed modifier using the stun system. If no threshold is met then the entity's speed is restored to normal.
/// Adjusts the modifiers of the <see cref="StaminaLow"/> status effect entity and applies relevant statuses.
/// System iterates through the <see cref="StaminaComponent.StunModifierThresholds"/> to find correct movement modifer.
/// This modifier is saved to the Stamina Low Status Effect entity's <see cref="MovementModStatusEffectComponent"/>.
/// </summary>
/// <param name="ent">Entity to update</param>
private void AdjustSlowdown(Entity<StaminaComponent?> ent)
private void AdjustStatus(Entity<StaminaComponent?> ent)
{
if (!Resolve(ent, ref ent.Comp))
return;
if (!_status.TrySetStatusEffectDuration(ent, StaminaLow, out var status))
return;
var closest = FixedPoint2.Zero;
// Iterate through the dictionary in the similar way as in Damage.SlowOnDamageSystem.OnRefreshMovespeed
@@ -435,7 +446,7 @@ public abstract partial class SharedStaminaSystem : EntitySystem
closest = thres.Key;
}
StunSystem.UpdateStunModifiers(ent, ent.Comp.StunModifierThresholds[closest]);
_movementMod.TryUpdateMovementStatus(ent.Owner, status.Value, ent.Comp.StunModifierThresholds[closest]);
}
[Serializable, NetSerializable]