Darkhitori

vShooterManager/OnDestroyWeapon

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