Advertisement
Darkhitori

vShooterWeapon/SetPrecision

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