Advertisement
Darkhitori

vGameController/Spawn

Jan 12th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("Invector/vGameController")]
  10.     [Tooltip(" ")]
  11.     public class vC_Spawn : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vGameController))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public enum Spawn
  18.         {
  19.             no_parameters,
  20.             spawnPoint
  21.         }
  22.        
  23.         public Spawn methods;
  24.        
  25.         public FsmGameObject spawnPoint;
  26.        
  27.         public FsmBool everyFrame;
  28.  
  29.         vGameController theScript;
  30.  
  31.  
  32.         public override void Reset()
  33.         {
  34.             gameObject = null;
  35.             methods = Spawn.no_parameters;
  36.             spawnPoint = null;
  37.             everyFrame = true;
  38.         }
  39.        
  40.         public override void OnEnter()
  41.         {
  42.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  43.  
  44.             theScript = go.GetComponent<vGameController>();
  45.  
  46.  
  47.             if (!everyFrame.Value)
  48.             {
  49.                 DoTheMagic();
  50.                 Finish();
  51.             }
  52.  
  53.         }
  54.  
  55.         public override void OnUpdate()
  56.         {
  57.             if (everyFrame.Value)
  58.             {
  59.                 DoTheMagic();
  60.             }
  61.         }
  62.  
  63.         void DoTheMagic()
  64.         {
  65.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  66.             if (go == null)
  67.             {
  68.                 return;
  69.             }
  70.            
  71.             switch(methods)
  72.             {
  73.             case Spawn.no_parameters:
  74.                 theScript.Spawn();
  75.                 break;
  76.             case Spawn.spawnPoint:
  77.                 theScript.Spawn(spawnPoint.Value.transform);
  78.                 break;
  79.             }
  80.            
  81.                        
  82.         }
  83.  
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement