Scripting
Everything is in the Fullscreen.LogicBlock2.Runtime namespace. Calls use Visual Script's Args, which carry the Source and Target.
Running a Block
csharp
using Fullscreen.LogicBlock2.Runtime;
using UnityEngine;
using VisualScript.Runtime;
public class Door : MonoBehaviour
{
[SerializeField] private InstructionBlock m_Open;
[SerializeField] private ConditionBlock m_CanOpen;
public async void Interact(GameObject player)
{
using Args args = Args.Get(this.gameObject, player); // Source, Target
if (!this.m_CanOpen.Check(args)) return;
await this.m_Open.Run(args);
}
}Calls made from code use each parameter's default value.
LogicBlock lists
LogicBlock methods take the list's id. Find it by name through Entries:
csharp
using System.Linq;
string chase = this.m_EnemyAI.Entries.First(entry => entry.Name == "Chase").Id;
await this.m_EnemyAI.Run(chase, args); // an Instructions list
bool canAttack = this.m_EnemyAI.Check(attackId, args); // a Conditions list
this.m_EnemyAI.Stop(chase, this.gameObject); // stop this object's Chase callsCalls with parameter fields in your own components
To call a Block with parameter values from your own script, use the same fields as Run Block. Call holds the Block (and list), and Arguments holds the parameter values. In the inspector they look and work exactly like Run Block's fields, prefab-style overrides included.
csharp
using Fullscreen.LogicBlock2.Runtime;
using UnityEngine;
using VisualScript.Runtime;
public class Spawner : MonoBehaviour
{
[SerializeField, CallKind(CallKind.Run)]
private Call m_Block = new Call();
[SerializeField]
private Arguments m_Parameters = new Arguments();
public async void Spawn(GameObject target)
{
using Args args = Args.Get(this.gameObject, target);
await this.m_Block.Run(args, this.m_Parameters.Items, this.gameObject, target, null);
}
}CallKindsets which Blocks the field accepts:Run(Instruction Blocks and Instructions lists),Check(Condition Blocks and Conditions lists) orStop(like Run, plus All Lists).- The
Argumentsfield finds itsCallby the field namem_Block. If yours is named differently, add[ArgumentsFor("m_YourField")]to theArgumentsfield.
API summary
| Type | Member |
|---|---|
InstructionBlock | Awaitable Run(Args args, IReadOnlyList<Argument> arguments = null, ICancelToken cancelToken = null) |
InstructionBlock | Awaitable Run(Args, IReadOnlyList<Argument>, GameObject source, GameObject target, ICancelToken) |
InstructionBlock | int Stop(GameObject source = null) stops this source's calls, or all calls when source is null; returns how many stopped |
InstructionBlock | Instructions Instructions |
ConditionBlock | bool Check(Args args, IReadOnlyList<Argument> arguments = null) |
ConditionBlock | bool Check(Args, IReadOnlyList<Argument>, GameObject source, GameObject target) |
ConditionBlock | Conditions Conditions, Conditions.Operation Operation |
LogicBlock | Awaitable Run(string listId, Args args, ...) (same overloads as above) |
LogicBlock | bool Check(string listId, Args args, ...) |
LogicBlock | int Stop(string listId, GameObject source = null) |
LogicBlock | IReadOnlyList<Entry> Entries, bool TryGetEntry<T>(string id, out T entry), string GetEntryName(string id) |
Block (base of all three) | Note Note, IReadOnlyList<Parameter> Parameters, bool TryGetParameter(string id, out Parameter parameter) |
Entry (a LogicBlock list) | string Id, string Name, Note Note; EntryInstructions.Instructions; EntryConditions.Conditions and .Operation |
Parameter | string Id, string Name, Value Default, string TypeName, Type DataType |
Call | Block Block, string EntryId, Run(...), Check(...), Stop(GameObject source, bool anySource), IsRunning(GameObject source, bool anySource) |
Runs | static bool IsRunning(Block block, string listId, GameObject source, bool anySource) |
Runs | static int Stop(Block block, string listId, GameObject source, bool anySource) |
Runs | Use "" as the list id for an Instruction Block, or to mean all lists of a LogicBlock. |
Keys | const int MAX_DEPTH (32) |