Darkhitori

vItemManager/ItemIsInSomeEquipArea

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