Darkhitori

vItemManager/ItemIsInSpecificEquipPoint

Jan 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 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("Check if item is equipped in specific EquipPoint ")]
  11.     public class vIM_ItemIsInSpecificEquipPoint : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vItemManager))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public enum ItemIsInSpecificEquipPoint
  18.         {
  19.             id_equipPointName,
  20.             itemName_equipPointName
  21.         }
  22.        
  23.         public ItemIsInSpecificEquipPoint methods;
  24.        
  25.         public FsmInt id;
  26.        
  27.         public FsmString itemName;
  28.        
  29.         public FsmString equipPointName;
  30.        
  31.         [ActionSection("Return")]
  32.         [UIHint(UIHint.FsmBool)]
  33.         public FsmBool itemIsInSpecificEquipPoint;
  34.        
  35.         public FsmBool everyFrame;
  36.  
  37.         vItemManager theScript;
  38.        
  39.         public override void Reset()
  40.         {
  41.             gameObject = null;
  42.             methods = ItemIsInSpecificEquipPoint.id_equipPointName;
  43.             id = null;
  44.             itemName = "";
  45.             equipPointName = "";
  46.             itemIsInSpecificEquipPoint = false;
  47.             everyFrame = true;
  48.         }
  49.        
  50.         public override void OnEnter()
  51.         {
  52.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  53.  
  54.             theScript = go.GetComponent<vItemManager>();
  55.  
  56.  
  57.             if (!everyFrame.Value)
  58.             {
  59.                 DoTheMagic();
  60.                 Finish();
  61.             }
  62.  
  63.         }
  64.  
  65.         public override void OnUpdate()
  66.         {
  67.             if (everyFrame.Value)
  68.             {
  69.                 DoTheMagic();
  70.             }
  71.         }
  72.  
  73.         void DoTheMagic()
  74.         {
  75.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  76.             if (go == null)
  77.             {
  78.                 return;
  79.             }
  80.            
  81.             switch(methods)
  82.             {
  83.             case ItemIsInSpecificEquipPoint.id_equipPointName:
  84.                 itemIsInSpecificEquipPoint.Value = theScript.ItemIsInSpecificEquipPoint(id.Value, equipPointName.Value);
  85.                 break;
  86.             case ItemIsInSpecificEquipPoint.itemName_equipPointName:
  87.                 itemIsInSpecificEquipPoint.Value = theScript.ItemIsInSpecificEquipPoint(itemName.Value, equipPointName.Value);
  88.                 break;
  89.             }
  90.            
  91.            
  92.                
  93.         }
  94.  
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment