Advertisement
Darkhitori

CF_addToZone

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