Darkhitori

vWaypoint/GetSubPoint

Jan 14th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("Invector/vWaypoint")]
  10.     [Tooltip(" ")]
  11.     public class vWP_GetSubPoint : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vWaypoint))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmInt index;
  18.        
  19.         [ActionSection("Return")]
  20.         [UIHint(UIHint.FsmVector3)]
  21.         public FsmVector3 getSubPoint;
  22.        
  23.         public FsmBool everyFrame;
  24.  
  25.         vWaypoint theScript;
  26.  
  27.         public override void Reset()
  28.         {
  29.             gameObject = null;
  30.             index = null;
  31.             getSubPoint = new Vector3(0,0,0);
  32.             everyFrame = true;
  33.         }
  34.        
  35.         public override void OnEnter()
  36.         {
  37.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  38.  
  39.             theScript = go.GetComponent<vWaypoint>();
  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.            
  66.             getSubPoint.Value = theScript.GetSubPoint(index.Value);            
  67.         }
  68.  
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment