Darkhitori

vMeleeManager/OnDefense

Jan 13th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 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/vMeleeManager")]
  10.     [Tooltip("Call Weapon Defense Events. ")]
  11.     public class vMM_OnDefense : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vMeleeManager))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmEvent sendEvent;
  18.        
  19.         public FsmBool everyFrame;
  20.  
  21.         vMeleeManager theScript;
  22.  
  23.         public override void Reset()
  24.         {
  25.             gameObject = null;
  26.             sendEvent = null;
  27.             everyFrame = true;
  28.         }
  29.        
  30.         public override void OnEnter()
  31.         {
  32.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  33.  
  34.             theScript = go.GetComponent<vMeleeManager>();
  35.  
  36.  
  37.             if (!everyFrame.Value)
  38.             {
  39.                 DoTheMagic();
  40.                 Finish();
  41.             }
  42.  
  43.         }
  44.  
  45.         public override void OnUpdate()
  46.         {
  47.             if (everyFrame.Value)
  48.             {
  49.                 DoTheMagic();
  50.             }
  51.         }
  52.  
  53.         void DoTheMagic()
  54.         {
  55.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  56.             if (go == null)
  57.             {
  58.                 return;
  59.             }
  60.            
  61.             theScript.OnDefense();
  62.             if(sendEvent == null)
  63.             {
  64.                 return;
  65.             }
  66.             else
  67.             {
  68.                 Fsm.Event(sendEvent);
  69.             }
  70.         }
  71.  
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment