public void Execute() { IAIContext context = this._contextProvider.GetContext(this._ai.id); IAction action = this._ai.Select(context); bool flag = false; while (!flag) { ICompositeAction compositeAction = action as ICompositeAction; if (compositeAction == null) { IConnectorAction connectorAction = action as IConnectorAction; if (connectorAction != null) { action = connectorAction.Select(context); } else { flag = true; } } else if (!compositeAction.isConnector) { flag = true; } else { action.Execute(context); action = compositeAction.Select(context); } } if (this._activeAction != null && this._activeAction != action) { this._activeAction.Terminate(context); this._activeAction = action as IRequireTermination; } else if (this._activeAction == null) { this._activeAction = action as IRequireTermination; } if (action != null) { action.Execute(context); } }
public static bool ExecuteOnce(this IUtilityAI ai, IAIContext context) { IAction action = ai.Select(context); bool flag = false; bool flag1 = false; while (!flag) { ICompositeAction compositeAction = action as ICompositeAction; if (compositeAction != null) { action.Execute(context); action = compositeAction.Select(context); flag = action == null; flag1 = true; } else { IConnectorAction connectorAction = action as IConnectorAction; if (connectorAction != null) { action = connectorAction.Select(context); } else { flag = true; } } } if (action != null) { action.Execute(context); flag1 = true; } return(flag1); }