Darkhitori

vItemManager/EquipCurrentItemToArea

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