Max Nielsen
Member
I was trying to create a decorator that would collapse branches when entering/exiting, but I guess it break some stuff if used on a sequence with a conditional abort. Is there some way to use decorators like this that get triggered when a branch is started/ended? I've had that need several times now since I use a lot of external trees, for example if current branch is a profession that runs a production, stop production when branch ends, I do this now using my own repeater that triggers this logic OnEnd, but would be tidier with a decorator.
I tried putting it on top of each external behaviour here (each one is its own profession) since at play this becomes a huge mess of nodes, and it does collapse everything, but it breaks the logic somewhere.
Code:
using BehaviorDesigner.Runtime.Tasks;
[TaskDescription(@"Will collpase children when not active")]
public class Collapsable : Decorator
{
public override void OnAwake()
{
base.OnAwake();
NodeData.Collapsed = true;
}
public override void OnStart()
{
base.OnStart();
NodeData.Collapsed = false;
}
public override void OnEnd()
{
base.OnEnd();
NodeData.Collapsed = true;
}
}
I tried putting it on top of each external behaviour here (each one is its own profession) since at play this becomes a huge mess of nodes, and it does collapse everything, but it breaks the logic somewhere.