Darkhitori

vInput/GetDoubleButtonDown

Jan 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("Invector/vInput")]
  10.     [Tooltip("Get Double Button Down Check if button is pressed Within the defined time ")]
  11.     public class vI_GetDoubleButtonDown : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vInput))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmFloat inputTime;
  18.        
  19.         [ActionSection("Return")]
  20.         [UIHint(UIHint.FsmBool)]
  21.         public FsmBool doubleButtonDown;
  22.        
  23.         [ActionSection("Event")]
  24.         public FsmEvent sendEvent;
  25.        
  26.         public FsmBool everyFrame;
  27.  
  28.         GenericInput theScript;
  29.  
  30.  
  31.         public override void Reset()
  32.         {
  33.             gameObject = null;
  34.             inputTime = 1;
  35.             sendEvent = null;
  36.             doubleButtonDown = false;
  37.             everyFrame = true;
  38.         }
  39.        
  40.         public override void OnEnter()
  41.         {
  42.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  43.  
  44.             theScript = go.GetComponent<GenericInput>();
  45.  
  46.  
  47.             if (!everyFrame.Value)
  48.             {
  49.                 DoTheMagic();
  50.                 Finish();
  51.             }
  52.  
  53.         }
  54.  
  55.         public override void OnUpdate()
  56.         {
  57.             if (everyFrame.Value)
  58.             {
  59.                 DoTheMagic();
  60.             }
  61.         }
  62.  
  63.         void DoTheMagic()
  64.         {
  65.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  66.             if (go == null)
  67.             {
  68.                 return;
  69.             }
  70.  
  71.             doubleButtonDown.Value = theScript.GetDoubleButtonDown(inputTime.Value);
  72.             if (doubleButtonDown.Value)
  73.             {
  74.                 Fsm.Event(sendEvent);
  75.             }
  76.         }
  77.  
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment