Advertisement
Darkhitori

CF_deactivateZone

Jan 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 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/Scenegraph ")]
  10.     [Tooltip("Deactivate scene zone. ")]
  11.     public class CF_deactivateZone : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(Scenegraph))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         [ObjectType(typeof(SceneZone))]
  18.         public FsmObject zone;
  19.  
  20.         public FsmBool everyFrame;
  21.  
  22.         Scenegraph theScript;
  23.  
  24.  
  25.         public override void Reset()
  26.         {
  27.             gameObject = null;
  28.             everyFrame = true;
  29.         }
  30.        
  31.         public override void OnEnter()
  32.         {
  33.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  34.  
  35.             theScript = go.GetComponent<Scenegraph>();
  36.  
  37.  
  38.             if (!everyFrame.Value)
  39.             {
  40.                 DoTheMethod();
  41.                 Finish();
  42.             }
  43.  
  44.         }
  45.  
  46.         public override void OnUpdate()
  47.         {
  48.             if (everyFrame.Value)
  49.             {
  50.                 DoTheMethod();
  51.             }
  52.         }
  53.  
  54.         void DoTheMethod()
  55.         {
  56.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  57.             if (go == null)
  58.             {
  59.                 return;
  60.             }
  61.             var cZone = zone.Value as SceneZone;
  62.             if (cZone == null)
  63.             {
  64.                 return;
  65.             }
  66.  
  67.             theScript.deactivateZone(cZone);            
  68.         }
  69.  
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement