Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Darkhitori v1.0
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using MLSpace;
- namespace HutongGames.PlayMaker.Actions
- {
- [ActionCategory("CombatFramework/Trigger")]
- [Tooltip("Early exit conditions. ")]
- public class CF_condition : FsmStateAction
- {
- [RequiredField]
- [CheckForComponent(typeof(Trigger))]
- public FsmOwnerDefault gameObject;
- [ObjectType(typeof(TriggerManagement))]
- public FsmObject trigMan;
- [ActionSection("Return")]
- [UIHint(UIHint.FsmBool)]
- public FsmBool m_ConditionPassed;
- public FsmBool everyFrame;
- Trigger theScript;
- public override void Reset()
- {
- gameObject = null;
- trigMan = null;
- m_ConditionPassed = false;
- everyFrame = true;
- }
- public override void OnEnter()
- {
- var go = Fsm.GetOwnerDefaultTarget(gameObject);
- theScript = go.GetComponent<Trigger>();
- if (!everyFrame.Value)
- {
- DoTheMethod();
- Finish();
- }
- }
- public override void OnUpdate()
- {
- if (everyFrame.Value)
- {
- DoTheMethod();
- }
- }
- void DoTheMethod()
- {
- var go = Fsm.GetOwnerDefaultTarget(gameObject);
- if (go == null)
- {
- return;
- }
- var cTrig = trigMan.Value as TriggerManagement;
- if (cTrig == null)
- {
- return;
- }
- m_ConditionPassed.Value = theScript.condition(cTrig);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement