Invoke Node: Difference between revisions

From Intrigues Wiki
No edit summary
No edit summary
Line 9: Line 9:
     public class Demo_Methods : MonoBehaviour
     public class Demo_Methods : MonoBehaviour
     {
     {
         [Scheme("Conspirator Level Up")]
         [IInvoke("Conspirator Level Up")]
         private IResult LevelUp(Scheme scheme) {
         private IResult LevelUp(Scheme scheme) {
             LevelComponent levelComponent = scheme.Conspirator.GetComponent<LevelComponent>();
             LevelComponent levelComponent = scheme.Conspirator.GetComponent<LevelComponent>();
Line 19: Line 19:
         }
         }
          
          
         [Scheme("Conspirator Level > 5")]
         [IInvoke("Conspirator Level > 5")]
         private IResult LevelGreaterThanFive(Scheme scheme) {
         private IResult LevelGreaterThanFive(Scheme scheme) {
             LevelComponent levelComponent = scheme.Conspirator.GetComponent<LevelComponent>();
             LevelComponent levelComponent = scheme.Conspirator.GetComponent<LevelComponent>();

Revision as of 17:56, 9 February 2024

Description

This node executes all methods of the IResult type that are marked with the [SchemeAttribute].
Invoke Node.gif
Invoke Node.gif
using UnityEngine;

namespace Nullframes.Intrigues.Demo
{
    public class Demo_Methods : MonoBehaviour
    {
        [IInvoke("Conspirator Level Up")]
        private IResult LevelUp(Scheme scheme) {
            LevelComponent levelComponent = scheme.Conspirator.GetComponent<LevelComponent>();
            if (levelComponent != null) {
                levelComponent.LevelUp();
                return IResult.True; // Level is Up.
            }
            return IResult.Null; // LevelComponent not found.
        }
        
        [IInvoke("Conspirator Level > 5")]
        private IResult LevelGreaterThanFive(Scheme scheme) {
            LevelComponent levelComponent = scheme.Conspirator.GetComponent<LevelComponent>();
            if (levelComponent != null) {
                if (levelComponent.Level > 5) {
                    return IResult.True; // Level greater than 5
                }
                return IResult.False; // Level lesser or equal than 5
            }
            return IResult.Null; // LevelComponent not found.
        }
    }
}

» The Invoke node runs the Method and continues the flow based on the returned value.