Open acdamiani opened 8 months ago
Ohhh my... Today I've had a hard nut to crack. Haha.
Have a look at this code (https://github.com/acdamiani/schema/blob/main/Runtime/Proc/ExecutableNode.cs#L178):
bool isSub = current.IsSubTreeOf(node);
bool isPriority = current.IsLowerPriority(node);
switch (c.abortsType)
{
case Conditional.AbortsType.Self when !isSub:
case Conditional.AbortsType.LowerPriority when !isPriority:
case Conditional.AbortsType.Both when !isPriority && !isSub:
continue;
}
bool status = c.Evaluate(conditionalMemory[id][j], context.agent);
status = c.invert ? !status : status;
if (!lastConditionalStatus.TryGetValue(j, out bool last)) last = status;
lastConditionalStatus[j] = status;
if (last == status) continue;
switch (c.abortsWhen)
{
case Conditional.AbortsWhen.OnSuccess when status:
case Conditional.AbortsWhen.OnFailure when !status:
case Conditional.AbortsWhen.Both:
return true;
}
These kind of double negations is not made for a human brain. :)
For instance:
I have a class that returns true if the enemy has Mana to fight. I want him to chase the player if there is no mana but abort the node if mana is back.
Sounds easy but the settings creates a knot in a humans head. Haha.
If you would create an if statement it would look like this:
if (!HasMana()) {
ChasePlayer();
} else if (AbortType == AbortType.Self && HasMana()) {
StopChasePlayer
}
I've create my own text for this Conditional to make it more clear. Maybe you could also do that by default? I know it's not easy because of the different wordings. Believe me, in German it would be hell on earth to standardize that. Haha.
The documentation currently only addresses Conditional aborts in passing. It would be worth it to expound upon what they are and how they work, since they are pretty important for any mildly complex behavior tree.