Darkhitori

vItemManager/ContainItems

Jan 14th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 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 the list contains a certain count of items, or more ")]
  11.     public class vIM_ContainItems : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vItemManager))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public enum ContainItems
  18.         {
  19.             id_count,
  20.             itemName_count
  21.         }
  22.        
  23.         public ContainItems methods;
  24.        
  25.         public FsmInt id;
  26.        
  27.         public FsmString itemName;
  28.        
  29.         public FsmInt count;
  30.        
  31.         [ActionSection("Return")]
  32.         [UIHint(UIHint.FsmBool)]
  33.         public FsmBool containItems;
  34.        
  35.         public FsmBool everyFrame;
  36.  
  37.         vItemManager theScript;
  38.        
  39.         public override void Reset()
  40.         {
  41.             gameObject = null;
  42.             methods =  ContainItems.id_count;
  43.             id = null;
  44.             itemName = "";
  45.             count = null;
  46.             containItems = 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 ContainItems.id_count:
  84.                 containItems.Value = theScript.ContainItems(id.Value, count.Value);
  85.                 break;
  86.             case ContainItems.itemName_count:
  87.                 containItems.Value = theScript.ContainItems(itemName.Value, count.Value);
  88.                 break;
  89.             }
  90.            
  91.         }
  92.  
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment