Remove IAfterInteract (#9715)
* remove gas analyzer iafterinteract * solution transfer + obsolete * cuffable * remove
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Content.Server.Cuffs.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedHandcuffComponent))]
|
||||
public sealed class HandcuffComponent : SharedHandcuffComponent, IAfterInteract
|
||||
public sealed class HandcuffComponent : SharedHandcuffComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
@@ -128,66 +128,17 @@ namespace Content.Server.Cuffs.Components
|
||||
/// <summary>
|
||||
/// Used to prevent DoAfter getting spammed.
|
||||
/// </summary>
|
||||
private bool _cuffing;
|
||||
public bool Cuffing;
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new HandcuffedComponentState(Broken ? BrokenState : string.Empty);
|
||||
}
|
||||
|
||||
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
if (_cuffing) return true;
|
||||
|
||||
if (eventArgs.Target is not {Valid: true} target ||
|
||||
!_entities.TryGetComponent<CuffableComponent?>(eventArgs.Target.Value, out var cuffed))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Broken)
|
||||
{
|
||||
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-cuffs-broken-error"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_entities.TryGetComponent<HandsComponent?>(target, out var hands))
|
||||
{
|
||||
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-target-has-no-hands-error",("targetName", eventArgs.Target)));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cuffed.CuffedHandCount >= hands.Count)
|
||||
{
|
||||
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-target-has-no-free-hands-error",("targetName", eventArgs.Target)));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!eventArgs.CanReach)
|
||||
{
|
||||
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-too-far-away-error"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (eventArgs.Target == eventArgs.User)
|
||||
{
|
||||
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-target-self"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-start-cuffing-target-message",("targetName", eventArgs.Target)));
|
||||
eventArgs.User.PopupMessage(target, Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", eventArgs.User)));
|
||||
}
|
||||
SoundSystem.Play(StartCuffSound.GetSound(), Filter.Pvs(Owner), Owner);
|
||||
|
||||
TryUpdateCuff(eventArgs.User, target, cuffed);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the cuffed state of an entity
|
||||
/// </summary>
|
||||
private async void TryUpdateCuff(EntityUid user, EntityUid target, CuffableComponent cuffs)
|
||||
public async void TryUpdateCuff(EntityUid user, EntityUid target, CuffableComponent cuffs)
|
||||
{
|
||||
var cuffTime = CuffTime;
|
||||
|
||||
@@ -205,11 +156,11 @@ namespace Content.Server.Cuffs.Components
|
||||
NeedHand = true
|
||||
};
|
||||
|
||||
_cuffing = true;
|
||||
Cuffing = true;
|
||||
|
||||
var result = await EntitySystem.Get<DoAfterSystem>().WaitDoAfter(doAfterEventArgs);
|
||||
|
||||
_cuffing = false;
|
||||
Cuffing = false;
|
||||
|
||||
if (result != DoAfterStatus.Cancelled)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user