Darkhitori

vMeleeManager/SetRightWeapon

Jan 14th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 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/vMeleeManager")]
  10.     [Tooltip(" ")]
  11.     public class vMM_SetRightWeapon : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vMeleeManager))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public enum SetRightWeapon
  18.         {
  19.             weaponObject,
  20.             weapon
  21.         }
  22.        
  23.         public SetRightWeapon methods;
  24.        
  25.         public FsmGameObject weaponObject;
  26.        
  27.         [ObjectType(typeof(vMeleeWeapon))]
  28.         public FsmObject weapon;
  29.        
  30.         public FsmBool everyFrame;
  31.  
  32.         vMeleeManager theScript;
  33.  
  34.         public override void Reset()
  35.         {
  36.             gameObject = null;
  37.             weaponObject = null;
  38.             weapon = null;
  39.             everyFrame = true;
  40.         }
  41.        
  42.         public override void OnEnter()
  43.         {
  44.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  45.  
  46.             theScript = go.GetComponent<vMeleeManager>();
  47.  
  48.  
  49.             if (!everyFrame.Value)
  50.             {
  51.                 DoTheMagic();
  52.                 Finish();
  53.             }
  54.  
  55.         }
  56.  
  57.         public override void OnUpdate()
  58.         {
  59.             if (everyFrame.Value)
  60.             {
  61.                 DoTheMagic();
  62.             }
  63.         }
  64.  
  65.         void DoTheMagic()
  66.         {
  67.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  68.             if (go == null)
  69.             {
  70.                 return;
  71.             }
  72.            
  73.             switch(methods)
  74.             {
  75.             case SetRightWeapon.weaponObject:
  76.                 theScript.SetRightWeapon(weaponObject.Value);
  77.                 break;
  78.             case SetRightWeapon.weapon:
  79.                 var vWeapon = weapon.Value as vMeleeWeapon;
  80.                 if(vWeapon == null)
  81.                 {
  82.                     return;
  83.                 }
  84.                 theScript.SetRightWeapon(vWeapon);
  85.                 break;
  86.             }
  87.                        
  88.         }
  89.  
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment