Advertisement
Darkhitori

vThrowCollectable/UpdateThrowObj

Jan 14th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 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/vThrowCollectable")]
  10.     [Tooltip(" ")]
  11.     public class vTC_UpdateThrowObj : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vThrowCollectable))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         [ObjectType(typeof(Rigidbody))]
  18.         public FsmObject throwObj;
  19.        
  20.         public FsmBool everyFrame;
  21.  
  22.         vThrowCollectable 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<vThrowCollectable>();
  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.             var vThrow = throwObj.Value as Rigidbody;
  62.             if (vThrow == null)
  63.             {
  64.                 return;
  65.             }
  66.            
  67.             theScript.UpdateThrowObj(vThrow);            
  68.         }
  69.  
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement