Table of Contents

Executable Events

Events are graph entry points. Flow supports named execution events, implementable C# methods, and typed Ceres events.

Execution Event

ExecutionEvent is a common event that can be used to trigger the execution of a FlowGraph instance.

Execution Event

You can double click the event node and rename it.

By default, ExecutionEvent without parameters can be created in search window.

ExecutionEvent with parameters can be created when you drag any port with type EventDelegate<>.

Drag delegate port

Action<> ports are also supported through implicit conversion.

Drag action port

Implementable Event

Implementable events can be defined on a container so C# can invoke graph behavior through the annotated method.

Following is an implementation example.

using Ceres.Flow;
using Ceres.Flow.Annotations;

public class FlowTest : FlowGraphObject /* Inherit from MonoBehaviour */
{
    [ImplementableEvent]
    public void Awake()
    {

    }

    [ImplementableEvent]
    public void PrintFloat(float data)
    {

    }

    [ImplementableEvent]
    public void ExecuteTest(string data)
    {

    }
}

Implementable Event

Custom Event

Custom executable events carry typed data between C# and Flow without requiring a matching container method.

Here is an implementation example:

using Ceres.Events;
using Ceres.Flow;
using Ceres.Flow.Annotations;
using UnityEngine;

[ExecutableEvent]
public class DamageBoxEvent: EventBase<DamageBoxEvent>
{
    public Collision Collision { get; private set; }

    [ExecutableEvent]
    public static DamageBoxEvent Create(Collision collision)
    {
        var evt = GetPooled();
        evt.Collision = collision;
        return evt;
    }
}

public class DamageBox: MonoBehaviour
{
    private void OnCollisionEnter(Collision other) 
    {
        using var evt = DamageBoxEvent.Create(other);
        GetComponentInParent<FlowGraphObject>().SendEvent(evt);
    }
}

Custom Event

The event type generates an implementation node. Marking the static factory also generates a node that creates the event. Public getters become output ports.

Implementation

Custom event nodes are generated from [ExecutableEvent] and use the Ceres event system for dispatch.