Darkhitori

vHeadTrack/SetLookTarget

Jan 13th, 2018
91
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.CharacterController;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("Invector/vHeadTrack")]
  10.     [Tooltip("Set vLookTarget. Set Simple target ")]
  11.     public class vHT_SetLookTarget : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vHeadTrack))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public enum SetLookTarget
  18.         {
  19.             lTarget_priority,
  20.             target
  21.         }
  22.        
  23.         public SetLookTarget methods;
  24.        
  25.         [ObjectType(typeof(vLookTarget))]
  26.         public FsmObject lTarget;
  27.        
  28.         public FsmGameObject target;
  29.        
  30.         public FsmBool priority;
  31.        
  32.         public FsmBool everyFrame;
  33.  
  34.         vHeadTrack theScript;
  35.  
  36.  
  37.         public override void Reset()
  38.         {
  39.             gameObject = null;
  40.             methods =  SetLookTarget.lTarget_priority;
  41.             lTarget = null;
  42.             target = null;
  43.             priority = false;
  44.             everyFrame = true;
  45.         }
  46.        
  47.         public override void OnEnter()
  48.         {
  49.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  50.  
  51.             theScript = go.GetComponent<vHeadTrack>();
  52.  
  53.  
  54.             if (!everyFrame.Value)
  55.             {
  56.                 DoTheMagic();
  57.                 Finish();
  58.             }
  59.  
  60.         }
  61.  
  62.         public override void OnUpdate()
  63.         {
  64.             if (everyFrame.Value)
  65.             {
  66.                 DoTheMagic();
  67.             }
  68.         }
  69.  
  70.         void DoTheMagic()
  71.         {
  72.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  73.             if (go == null)
  74.             {
  75.                 return;
  76.             }
  77.            
  78.            
  79.             switch(methods)
  80.             {
  81.             case  SetLookTarget.lTarget_priority:
  82.                 var vTarget = lTarget.Value as vLookTarget;
  83.                 if (vTarget == null)
  84.                 {
  85.                     return;
  86.                 }
  87.                 theScript.SetLookTarget(vTarget, priority.Value);
  88.                 break;
  89.             case  SetLookTarget.target:
  90.                 theScript.SetLookTarget(target.Value.transform);
  91.                 break;
  92.             }
  93.                        
  94.         }
  95.  
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment