Crawling Part 1: The Knockdownening (#36881)

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: ScarKy0 <scarky0@onet.eu>
This commit is contained in:
Princess Cheeseballs
2025-07-19 16:54:42 -07:00
committed by GitHub
parent cfb0a95035
commit dec2d42a1d
60 changed files with 1595 additions and 220 deletions

View File

@@ -21,6 +21,7 @@ using Content.Shared.Inventory.VirtualItem;
using Content.Shared.Item;
using Content.Shared.Movement.Events;
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Movement.Systems;
using Content.Shared.Popups;
using Content.Shared.Pulling.Events;
using Content.Shared.Rejuvenate;
@@ -45,6 +46,7 @@ namespace Content.Shared.Cuffs
[Dependency] private readonly ISharedAdminLogManager _adminLog = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly MovementSpeedModifierSystem _move = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
@@ -56,10 +58,14 @@ namespace Content.Shared.Cuffs
[Dependency] private readonly UseDelaySystem _delay = default!;
[Dependency] private readonly SharedCombatModeSystem _combatMode = default!;
private EntityQuery<HandcuffComponent> _cuffQuery;
public override void Initialize()
{
base.Initialize();
_cuffQuery = GetEntityQuery<HandcuffComponent>();
SubscribeLocalEvent<CuffableComponent, HandCountChangedEvent>(OnHandCountChanged);
SubscribeLocalEvent<UncuffAttemptEvent>(OnUncuffAttempt);
@@ -89,6 +95,9 @@ namespace Content.Shared.Cuffs
SubscribeLocalEvent<HandcuffComponent, MeleeHitEvent>(OnCuffMeleeHit);
SubscribeLocalEvent<HandcuffComponent, AddCuffDoAfterEvent>(OnAddCuffDoAfter);
SubscribeLocalEvent<HandcuffComponent, VirtualItemDeletedEvent>(OnCuffVirtualItemDeleted);
SubscribeLocalEvent<CuffableComponent, GetStandUpTimeEvent>(OnCuffableStandupArgs);
SubscribeLocalEvent<CuffableComponent, KnockedDownRefreshEvent>(OnCuffableKnockdownRefresh);
SubscribeLocalEvent<CuffableComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeedModifiers);
}
private void CheckInteract(Entity<CuffableComponent> ent, ref InteractionAttemptEvent args)
@@ -366,6 +375,9 @@ namespace Content.Shared.Cuffs
_adminLog.Add(LogType.Action, LogImpact.High,
$"{ToPrettyString(user):player} has cuffed {ToPrettyString(target):player}");
}
if (!MathHelper.CloseTo(component.MovementMod, 1f))
_move.RefreshMovementSpeedModifiers(target);
}
else
{
@@ -420,6 +432,72 @@ namespace Content.Shared.Cuffs
}
}
/// <summary>
/// Takes longer to stand up when cuffed
/// </summary>
private void OnCuffableStandupArgs(Entity<CuffableComponent> ent, ref GetStandUpTimeEvent time)
{
if (!HasComp<KnockedDownComponent>(ent) || !IsCuffed(ent))
return;
var cuffs = GetAllCuffs(ent.Comp);
var mod = 1f;
if (cuffs.Count == 0)
return;
foreach (var cuff in cuffs)
{
if (!_cuffQuery.TryComp(cuff, out var comp))
continue;
// Get the worst modifier
mod = Math.Max(mod, comp.StandupMod);
}
time.DoAfterTime *= mod;
}
private void OnCuffableKnockdownRefresh(Entity<CuffableComponent> ent, ref KnockedDownRefreshEvent args)
{
var cuffs = GetAllCuffs(ent.Comp);
var mod = 1f;
if (cuffs.Count == 0)
return;
foreach (var cuff in cuffs)
{
if (!_cuffQuery.TryComp(cuff, out var comp))
continue;
// Get the worst modifier
mod = Math.Min(mod, comp.KnockedMovementMod);
}
args.SpeedModifier *= mod;
}
private void OnRefreshMovementSpeedModifiers(Entity<CuffableComponent> ent, ref RefreshMovementSpeedModifiersEvent args)
{
var cuffs = GetAllCuffs(ent.Comp);
var mod = 1f;
if (cuffs.Count == 0)
return;
foreach (var cuff in cuffs)
{
if (!_cuffQuery.TryComp(cuff, out var comp))
continue;
// Get the worst modifier
mod = Math.Min(mod, comp.MovementMod);
}
args.ModifySpeed(mod);
}
/// <summary>
/// Adds virtual cuff items to the user's hands.
/// </summary>
@@ -736,6 +814,9 @@ namespace Content.Shared.Cuffs
shoved = true;
}
if (!MathHelper.CloseTo(cuff.MovementMod, 1f))
_move.RefreshMovementSpeedModifiers(target);
if (cuffable.CuffedHandCount == 0)
{
if (user != null)