Darkhitori

vItemManager/EquipItemToEquipArea

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