Advertisement
Darkhitori

v2_5DPath/ConstraintPosition

Jan 14th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 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/v2_5DPath")]
  10.     [Tooltip(" ")]
  11.     public class v2_5DP_ConstraintPosition : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(v2_5DPath))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmVector3 pos;
  18.        
  19.         public FsmBool checkChangePoint;
  20.        
  21.         [ActionSection("Return")]
  22.         [UIHint(UIHint.FsmVector3)]
  23.         public FsmVector3 position;
  24.        
  25.         public FsmBool everyFrame;
  26.  
  27.         v2_5DPath theScript;
  28.  
  29.  
  30.         public override void Reset()
  31.         {
  32.             gameObject = null;
  33.             pos = new Vector3(0,0,0);
  34.             checkChangePoint = false;
  35.             position = new Vector3(0,0,0);
  36.             everyFrame = true;
  37.         }
  38.        
  39.         public override void OnEnter()
  40.         {
  41.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  42.  
  43.             theScript = go.GetComponent<v2_5DPath>();
  44.  
  45.  
  46.             if (!everyFrame.Value)
  47.             {
  48.                 DoTheMagic();
  49.                 Finish();
  50.             }
  51.  
  52.         }
  53.  
  54.         public override void OnUpdate()
  55.         {
  56.             if (everyFrame.Value)
  57.             {
  58.                 DoTheMagic();
  59.             }
  60.         }
  61.  
  62.         void DoTheMagic()
  63.         {
  64.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  65.             if (go == null)
  66.             {
  67.                 return;
  68.             }
  69.            
  70.             position.Value = theScript.ConstraintPosition(pos.Value, checkChangePoint.Value);            
  71.         }
  72.  
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement