示例#1
0
 private void OnUncuffAttempt(UncuffAttemptEvent args)
 {
     if (args.Cancelled)
     {
         return;
     }
     if (!EntityManager.TryGetEntity(args.User, out var userEntity))
     {
         // Should this even be possible?
         args.Cancel();
         return;
     }
     // If the user is the target, special logic applies.
     // This is because the CanInteract blocking of the cuffs prevents self-uncuff.
     if (args.User == args.Target)
     {
         // This UncuffAttemptEvent check should probably be In MobStateSystem, not here?
         if (userEntity.TryGetComponent <IMobStateComponent>(out var state))
         {
             // Manually check this.
             if (state.IsIncapacitated())
             {
                 args.Cancel();
             }
         }
         else
         {
             // Uh... let it go through???
             // TODO CUFFABLE/STUN add UncuffAttemptEvent subscription to StunSystem
         }
     }
     else
     {
         // Check if the user can interact.
         if (!_actionBlockerSystem.CanInteract(userEntity))
         {
             args.Cancel();
         }
     }
     if (args.Cancelled)
     {
         _popupSystem.PopupEntity(Loc.GetString("cuffable-component-cannot-interact-message"), args.Target, Filter.Entities(userEntity.Uid));
     }
 }
 private void OnUncuffAttempt(UncuffAttemptEvent args)
 {
     if (args.Cancelled)
     {
         return;
     }
     if (!EntityManager.EntityExists(args.User))
     {
         // Should this even be possible?
         args.Cancel();
         return;
     }
     // If the user is the target, special logic applies.
     // This is because the CanInteract blocking of the cuffs prevents self-uncuff.
     if (args.User == args.Target)
     {
         // This UncuffAttemptEvent check should probably be In MobStateSystem, not here?
         if (EntityManager.TryGetComponent <MobStateComponent?>(args.User, out var state))
         {
             // Manually check this.
             if (state.IsIncapacitated())
             {
                 args.Cancel();
             }
         }
         else
         {
             // TODO Find a way for cuffable to check ActionBlockerSystem.CanInteract() without blocking itself
         }
     }
     else
     {
         // Check if the user can interact.
         if (!_actionBlockerSystem.CanInteract(args.User, args.Target))
         {
             args.Cancel();
         }
     }
     if (args.Cancelled)
     {
         _popupSystem.PopupEntity(Loc.GetString("cuffable-component-cannot-interact-message"), args.Target, Filter.Entities(args.User));
     }
 }