Darkhitori

vEquipArea/RemoveItem

Jan 14th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 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/vEquipArea")]
  10.     [Tooltip(" ")]
  11.     public class vEA_RemoveItem : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vEquipArea))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public enum RemoveItem
  18.         {
  19.             no_parameters,
  20.             slot,
  21.             item
  22.         }
  23.        
  24.         public RemoveItem methods;
  25.        
  26.         [ObjectType(typeof(vEquipSlot))]
  27.         public FsmObject slot;
  28.        
  29.         [ObjectType(typeof(vItem))]
  30.         public FsmObject item;
  31.        
  32.         public FsmBool everyFrame;
  33.  
  34.         vEquipArea theScript;
  35.  
  36.  
  37.         public override void Reset()
  38.         {
  39.             gameObject = null;
  40.             methods =  RemoveItem.no_parameters;
  41.             slot = null;
  42.             item = null;
  43.             everyFrame = true;
  44.         }
  45.        
  46.         public override void OnEnter()
  47.         {
  48.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  49.  
  50.             theScript = go.GetComponent<vEquipArea>();
  51.  
  52.  
  53.             if (!everyFrame.Value)
  54.             {
  55.                 DoTheMagic();
  56.                 Finish();
  57.             }
  58.  
  59.         }
  60.  
  61.         public override void OnUpdate()
  62.         {
  63.             if (everyFrame.Value)
  64.             {
  65.                 DoTheMagic();
  66.             }
  67.         }
  68.  
  69.         void DoTheMagic()
  70.         {
  71.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  72.             if (go == null)
  73.             {
  74.                 return;
  75.             }
  76.            
  77.            
  78.             switch(methods)
  79.             {
  80.             case RemoveItem.no_parameters:
  81.                 theScript.RemoveItem();
  82.                 break;
  83.             case RemoveItem.slot:
  84.                 var vSlot = slot.Value as vEquipSlot;
  85.                 if (vSlot == null)
  86.                 {
  87.                     return;
  88.                 }
  89.                 theScript.RemoveItem(vSlot);
  90.                 break;
  91.             case RemoveItem.item:
  92.                 var vItem = item.Value as vItem;
  93.                 if (vItem == null)
  94.                 {
  95.                     return;
  96.                 }
  97.                 theScript.RemoveItem(vItem);
  98.                 break;
  99.             }
  100.            
  101.            
  102.         }
  103.  
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment