Advertisement
Darkhitori

CF_AnyNpcInCombatInZone

Jan 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using MLSpace;
  6. using UnityEngine.AI;
  7.  
  8. namespace HutongGames.PlayMaker.Actions
  9. {
  10.     [ActionCategory("CombatFramework/NPCManager")]
  11.     [Tooltip("Provides info is any npc in combat in current zone. ")]
  12.     public class CF_AnyNpcInCombatInZone : FsmStateAction
  13.     {
  14.         [RequiredField]
  15.         [CheckForComponent(typeof(NPCManager))]
  16.         public FsmOwnerDefault gameObject;
  17.        
  18.         [ObjectType(typeof(NPCScript))]
  19.         public FsmObject caller;
  20.         [ActionSection("Return")]
  21.         [UIHint(UIHint.FsmBool)]
  22.         public FsmBool anyNpcInCombatInZone;
  23.        
  24.         public FsmBool everyFrame;
  25.  
  26.         NPCManager theScript;
  27.  
  28.  
  29.         public override void Reset()
  30.         {
  31.             gameObject = null;
  32.             caller = null;
  33.             anyNpcInCombatInZone = false;
  34.             everyFrame = true;
  35.         }
  36.        
  37.         public override void OnEnter()
  38.         {
  39.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  40.  
  41.             theScript = go.GetComponent<NPCManager>();
  42.  
  43.  
  44.             if (!everyFrame.Value)
  45.             {
  46.                 DoTheMethod();
  47.                 Finish();
  48.             }
  49.  
  50.         }
  51.  
  52.         public override void OnUpdate()
  53.         {
  54.             if (everyFrame.Value)
  55.             {
  56.                 DoTheMethod();
  57.             }
  58.         }
  59.  
  60.         void DoTheMethod()
  61.         {
  62.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  63.             if (go == null)
  64.             {
  65.                 return;
  66.             }
  67.             var cCaller = caller.Value as NPCScript;
  68.             if (cCaller == null)
  69.             {
  70.                 return;
  71.             }
  72.            
  73.             anyNpcInCombatInZone.Value = theScript.AnyNpcInCombatInZone(cCaller);            
  74.         }
  75.  
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement