Darkhitori

vLockOnBehaviour/isCharacterAlive

Jan 14th, 2018
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 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("Check if Current target(vCharacter) is Alive. Check if target is a vCharacter Alive ")]
  12.     public class vLOB_isCharacterAlive : FsmStateAction
  13.     {
  14.         [RequiredField]
  15.         [CheckForComponent(typeof(vLockOnBehaviour))]
  16.         public FsmOwnerDefault gameObject;
  17.        
  18.         public enum isCharacterAlive
  19.         {
  20.             no_parameters,
  21.             other
  22.         }
  23.        
  24.         public isCharacterAlive methods;
  25.        
  26.         [ObjectType(typeof(Transform))]
  27.         public FsmObject other;
  28.        
  29.         [ActionSection("Return")]
  30.         [UIHint(UIHint.FsmBool)]
  31.         public FsmBool characterAlive;
  32.        
  33.         public FsmBool everyFrame;
  34.  
  35.         vLockOnBehaviour theScript;
  36.  
  37.  
  38.         public override void Reset()
  39.         {
  40.             gameObject = null;
  41.             methods = isCharacterAlive.no_parameters;
  42.             other = null;
  43.             characterAlive = false;
  44.             everyFrame = true;
  45.         }
  46.        
  47.         public override void OnEnter()
  48.         {
  49.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  50.  
  51.             theScript = go.GetComponent<vLockOnBehaviour>();
  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.            
  80.             switch (methods)
  81.             {
  82.             case isCharacterAlive.no_parameters:
  83.                 characterAlive.Value = theScript.isCharacterAlive();
  84.                 break;
  85.             case isCharacterAlive.other:
  86.                 var vtrans = other.Value as Transform;
  87.                 if (vtrans == null)
  88.                 {
  89.                     return;
  90.                 }
  91.                 characterAlive.Value = theScript.isCharacterAlive(vtrans);
  92.                 break;
  93.             }
  94.                        
  95.         }
  96.  
  97.     }
  98. }
Add Comment
Please, Sign In to add comment