Invoke Node: Difference between revisions
Tayfunwiki (talk | contribs) No edit summary |
Tayfunwiki (talk | contribs) No edit summary |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<b>Description</b><div class="description" style="padding-left:35px;">[''' | <b>Description</b><div class="description" style="padding-left:35px;">This node executes all methods of the <span style="color:#bf7552">'''IResult'''</span> type that are marked with the <span style="color:#bf7552">['''IInvokeAttribute''']. </span></div> | ||
[[File:Invoke-1.gif|thumb|Invoke Node.gif]] | [[File:Invoke-1.gif|thumb|Invoke Node.gif]] | ||
[[File:Invoke-2.gif|thumb|Invoke Node.gif]] | [[File:Invoke-2.gif|thumb|Invoke Node.gif]] | ||
<syntaxhighlight lang="c#" line="1" start="1"> | <syntaxhighlight lang="c#" line="1" start="1"> | ||
using UnityEngine; | using UnityEngine; | ||
Line 10: | Line 9: | ||
public class Demo_Methods : MonoBehaviour | public class Demo_Methods : MonoBehaviour | ||
{ | { | ||
[ | [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>(); | ||
if (levelComponent != null) { | if (levelComponent != null) { | ||
levelComponent.LevelUp(); | levelComponent.LevelUp(); | ||
return IResult.True; | return IResult.True; // Level is Up. | ||
} | } | ||
return IResult.Null; | return IResult.Null; // LevelComponent not found. | ||
} | } | ||
[ | [IInvoke("Conspirator Level > 5")] | ||
private IResult LevelGreaterThanFive() { | private IResult LevelGreaterThanFive(Scheme scheme) { | ||
LevelComponent levelComponent = scheme.Conspirator.GetComponent<LevelComponent>(); | LevelComponent levelComponent = scheme.Conspirator.GetComponent<LevelComponent>(); | ||
if (levelComponent != null) { | if (levelComponent != null) { | ||
levelComponent. | if (levelComponent.Level > 5) { | ||
return IResult. | return IResult.True; // Level greater than 5 | ||
} | |||
return IResult.False; // Level lesser or equal than 5 | |||
} | } | ||
return IResult.Null; | return IResult.Null; // LevelComponent not found. | ||
} | } | ||
} | } | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight><blockquote>» The <span style="color:#bf7552">'''Invoke'''</span> node runs the <span style="color:#bf7552">'''Method'''</span> and continues the flow based on the <span style="color:#bf7552">'''returned'''</span> value.</blockquote> |
Latest revision as of 17:57, 9 February 2024
Description
This node executes all methods of the IResult type that are marked with the [IInvokeAttribute].
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.