Advertisement
Darkhitori

vEquipArea/OnSubmitSlot

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