Darkhitori

vLockOnBehaviour/ChangeTarget

Jan 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector;
  6. using Invector.CharacterController;
  7.  
  8. namespace HutongGames.PlayMaker.Actions
  9. {
  10.     [ActionCategory("Invector/vLockOnBehaviour")]
  11.     [Tooltip("change the current target to next target of possibles target if exist more than 1 target in list ")]
  12.     public class vLOB_ChangeTarget : FsmStateAction
  13.     {
  14.         [RequiredField]
  15.         [CheckForComponent(typeof(vLockOnBehaviour))]
  16.         public FsmOwnerDefault gameObject;
  17.        
  18.         public FsmInt value;
  19.        
  20.         public FsmBool everyFrame;
  21.  
  22.         vLockOnBehaviour theScript;
  23.  
  24.  
  25.         public override void Reset()
  26.         {
  27.             gameObject = null;
  28.             value = null;
  29.             everyFrame = true;
  30.         }
  31.        
  32.         public override void OnEnter()
  33.         {
  34.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  35.  
  36.             theScript = go.GetComponent<vLockOnBehaviour>();
  37.  
  38.  
  39.             if (!everyFrame.Value)
  40.             {
  41.                 DoTheMagic();
  42.                 Finish();
  43.             }
  44.  
  45.         }
  46.  
  47.         public override void OnUpdate()
  48.         {
  49.             if (everyFrame.Value)
  50.             {
  51.                 DoTheMagic();
  52.             }
  53.         }
  54.  
  55.         void DoTheMagic()
  56.         {
  57.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  58.             if (go == null)
  59.             {
  60.                 return;
  61.             }
  62.            
  63.             theScript.ChangeTarget(value.Value);            
  64.         }
  65.  
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment