-using Content.Shared.Damage;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float StunBonus = 2f;
- /// <summary>
- /// Modifier for the amount of time it takes an entity to stand up if cuffed.
- /// </summary>
- [DataField]
- public float StandupMod = 5f;
-
- /// <summary>
- /// Modifier to the speed of an entity who is cuffed, does not stack with KnockedMovementMod
- /// </summary>
- [DataField]
- public float MovementMod = 1f;
-
- /// <summary>
- /// Modifier to the knocked down speed of an entity who is cuffed
- /// </summary>
- [DataField]
- public float KnockedMovementMod = 0.4f;
-
/// <summary>
/// Will the cuffs break when removed?
/// </summary>
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;
[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!;
[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);
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)
_adminLog.Add(LogType.Action, LogImpact.High,
$"{ToPrettyString(user):player} has cuffed {ToPrettyString(target):player}");
}
-
- if (!MathHelper.CloseTo(component.MovementMod, 1f))
- _move.RefreshMovementSpeedModifiers(target);
}
else
{
}
}
- /// <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>
shoved = true;
}
- if (!MathHelper.CloseTo(cuff.MovementMod, 1f))
- _move.RefreshMovementSpeedModifiers(target);
-
if (cuffable.CuffedHandCount == 0)
{
if (user != null)
using Content.Shared.Damage.Components;
using Content.Shared.Database;
using Content.Shared.DoAfter;
-using Content.Shared.Hands;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Input;
using Content.Shared.Movement.Events;
SubscribeLocalEvent<KnockedDownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshKnockedSpeed);
SubscribeLocalEvent<KnockedDownComponent, RefreshFrictionModifiersEvent>(OnRefreshFriction);
SubscribeLocalEvent<KnockedDownComponent, TileFrictionEvent>(OnKnockedTileFriction);
- SubscribeLocalEvent<KnockedDownComponent, DidEquipHandEvent>(OnHandEquipped);
- SubscribeLocalEvent<KnockedDownComponent, DidUnequipHandEvent>(OnHandUnequipped);
// DoAfter event subscriptions
SubscribeLocalEvent<KnockedDownComponent, TryStandDoAfterEvent>(OnStandDoAfter);
args.ModifyAcceleration(entity.Comp.FrictionModifier);
}
- private void OnHandEquipped(Entity<KnockedDownComponent> entity, ref DidEquipHandEvent args)
- {
- RefreshKnockedMovement(entity);
- }
-
- private void OnHandUnequipped(Entity<KnockedDownComponent> entity, ref DidUnequipHandEvent args)
- {
- RefreshKnockedMovement(entity);
- }
-
#endregion
}