public override bool Walk(CallExpression node) { if (node.Target is MemberExpression memberExpression && memberExpression.Target is NameExpression callTargetNameExpression && _conditionVars.Contains(callTargetNameExpression.Name)) { var methodName = memberExpression.Name; var args = node.Args; if (methodName == "AddHook" && args[0].Expression is NameExpression dispTypeNameExpr && args[2].Expression is NameExpression callbackFunctionNameExpr) { var dispatcherTypeStr = PythonConstants.Constants[dispTypeNameExpr.Name]; var dispatcherType = Enum.Parse <DispatcherType>(dispatcherTypeStr.Substring("DispatcherType.".Length)); var functionName = callbackFunctionNameExpr.Name; if (CallbackFunctions.TryGetValue(functionName, out var callbackFunc)) { callbackFunc.UsedForDispatchers.Add(dispatcherType); } else { CallbackFunctions[functionName] = new ConditionCallback { Name = functionName, UsedForDispatchers = { dispatcherType } }; } } } return(false); }
public override bool Execute(BehaviourMachine machine, INode parentNode) { base.Execute(machine, parentNode); var result = ConditionCallback?.Invoke(machine, this) ?? false; if (result) { return(ChildNode.Execute(machine, this)); } return(false); }