Advertisement
Darkhitori

vExplosive/RemoveParent

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