Advertisement
Darkhitori

vShooterWeapon/OnUnequip

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