Advertisement
Darkhitori

Emerald AI/AIReachedDestination

Jan 16th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. namespace HutongGames.PlayMaker.Actions
  7. {
  8.     [ActionCategory("Emerald AI")]
  9.     [Tooltip(" ")]
  10.     public class EAI_AIReachedDestination : FsmStateAction
  11.     {
  12.         [RequiredField]
  13.         [CheckForComponent(typeof(Emerald_AI))]
  14.         public FsmOwnerDefault gameObject;
  15.        
  16.         [ActionSection("Return")]
  17.         [UIHint(UIHint.FsmBool)]
  18.         public FsmBool aIReachedDestination;
  19.  
  20.         public FsmBool everyFrame;
  21.  
  22.         Emerald_AI theScript;
  23.  
  24.  
  25.         public override void Reset()
  26.         {
  27.             gameObject = null;
  28.             aIReachedDestination = false;
  29.             everyFrame = true;
  30.         }
  31.        
  32.         public override void OnEnter()
  33.         {
  34.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  35.  
  36.             theScript = go.GetComponent<Emerald_AI>();
  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.             aIReachedDestination.Value = theScript.AIReachedDestination;            
  64.         }
  65.  
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement