Darkhitori

vHeadTrack/RemoveLookTarget

Jan 13th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 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(" ")]
  11.     public class vHT_RemoveLookTarget : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vHeadTrack))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public enum RemoveLookTarget
  18.         {
  19.             vLookTarget_lTarget,
  20.             Transform_target
  21.         }
  22.        
  23.         public RemoveLookTarget methods;
  24.        
  25.         [ObjectType(typeof(vLookTarget))]
  26.         public FsmObject lTarget;
  27.        
  28.         public FsmGameObject target;
  29.        
  30.         public FsmBool everyFrame;
  31.  
  32.         vHeadTrack theScript;
  33.  
  34.  
  35.         public override void Reset()
  36.         {
  37.             gameObject = null;
  38.             methods = RemoveLookTarget.vLookTarget_lTarget;
  39.             lTarget = null;
  40.             target = null;
  41.             everyFrame = true;
  42.         }
  43.        
  44.         public override void OnEnter()
  45.         {
  46.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  47.  
  48.             theScript = go.GetComponent<vHeadTrack>();
  49.  
  50.  
  51.             if (!everyFrame.Value)
  52.             {
  53.                 DoTheMagic();
  54.                 Finish();
  55.             }
  56.  
  57.         }
  58.  
  59.         public override void OnUpdate()
  60.         {
  61.             if (everyFrame.Value)
  62.             {
  63.                 DoTheMagic();
  64.             }
  65.         }
  66.  
  67.         void DoTheMagic()
  68.         {
  69.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  70.             if (go == null)
  71.             {
  72.                 return;
  73.             }
  74.            
  75.            
  76.             switch(methods)
  77.             {
  78.             case RemoveLookTarget.vLookTarget_lTarget:
  79.                 var vTarget = lTarget.Value as vLookTarget;
  80.                 if (vTarget == null)
  81.                 {
  82.                     return;
  83.                 }
  84.                 theScript.RemoveLookTarget(vTarget);
  85.                 break;
  86.             case RemoveLookTarget.Transform_target:
  87.                 theScript.RemoveLookTarget(target.Value.transform);
  88.                 break;
  89.             }
  90.                        
  91.         }
  92.  
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment