acdamiani / schema

Visual intelligence for the Unity game engine
https://schema-ai.com
MIT License
53 stars 4 forks source link

Missing OnNodeExit() Call on conditional node abort #23

Open ijisthee opened 8 months ago

ijisthee commented 8 months ago

Above https://github.com/acdamiani/schema/blob/3bc87e426f27b3d9b0ddf1a2db0cca4a578bd9a3/Runtime/Proc/ExecutableNode.cs#L320

action.OnNodeExit(nodeMemory[id], context.agent);

should be called.

If this does not happen, cleanup or update tasks cannot run if after a conditional evaluation the node is aborted.

ijisthee commented 7 months ago

@acdamiani Is this possible to fix or is the current way to do it by design and should not be done differently?

ijisthee commented 7 months ago

Here a proposal that works for me. Maybe you could find a better implementation:

if (context.last.index != index || forceConditionalEvaluation)
    run = DoConditionalStack(id, context);

if (!run)
{
    context.status = NodeStatus.Failure;
    if (context.node.node is Action actionToAbort)
    {
        actionToAbort.OnNodeExit(nodeMemory[id], context.agent);
    }

    return parent;
}
ijisthee commented 7 months ago

reviewed https://github.com/acdamiani/schema/pull/25