public void redo() { if (current < _tasks.Count) { task = _tasks[current++]; task.execute(); } }
public void runFixedUpdateTasks() { for (int i = 0; i < fixedUpdateTasks.Count; i++) { Task task = (Task)fixedUpdateTasks[i]; if (task.execute()) { fixedUpdateTasks.Remove(task); } } }
public void runLateUpdateTasks() { for (int i = 0; i < lateUpdateTasks.Count; i++) { Task task = (Task)lateUpdateTasks[i]; try { if (task.execute()) { lateUpdateTasks.Remove(task); } } catch (System.Exception e) { ModMain.instance.log(e); lateUpdateTasks.RemoveAt(i); } } }
// Update is called once per frame void FixedUpdate() { bt.execute(); }
// Update is called once per frame void Update() { //Debug.LogError("Agent Brain Update " + currentPlanExecutionIndex + " " + numGlobalPathWaypoints); // TODO // while time is remaining // pick current highest priority task and execute it // evaluate the status of the task -- and depending on status, evaluate new priority and add it back. // TODO : can exexcute multiple tasks ? float maxTime = 1.0F; Task task = taskManager.getHighestPriorityTask(); if (task != null) { Debug.Log("Executing task " + task.taskName); task.execute(maxTime); } else { //Debug.Log ("task manager does not have task"); } // clearing curves curves[0] = new AnimationCurve(); curves[1] = new AnimationCurve(); curves[2] = new AnimationCurve(); curves[3] = new AnimationCurve(); endTime = 0.0f; // assigning curves //Debug.LogError("num global points " + numGlobalPathWaypoints + " num space time paths " + spaceTimePaths.Count + " grid tasks " + gridNavigationTasks.Count); for (int i = currentPlanExecutionIndex; i < Mathf.Min(currentPlanExecutionIndex + numGlobalPathWaypoints, spaceTimePaths.Count); i++) { // TODO CHECK HERE IF THE SPACE TIME PLAN IS CURRENTLY VALID OR NOT if (offMeshLinkWayPoint[i] == true) // this one is an off mesh link -- does not have a space time path { spaceTimePaths[i].Clear(); // TODO GET MOST RECENT POSITION FOR BETTER VIEWING spaceTimePaths[i].Add(gridNavigationTasks[i].startState); spaceTimePaths[i].Add(gridNavigationTasks[i].goalState); } else if (gridNavigationTasks[i].spaceTimePathStatus == false) // not an off mesh link and does not have a path { break; } endTime = AnimationCurveHelper.GetPlanAnimationCurve(spaceTimePaths[i], curves); //Debug.LogError("we populated the curve till " + endTime); } // TODO CHECK HERE IF WE ARE CURRENTLY CONTROLLED BY THE MESH LINK if (moveAutomatically == true) { if (stop == false) { ExecuteNextAction(Time.deltaTime); } else { currentState._time += Time.deltaTime; // THIS HAPPENS WHEN OFF MESH LINK HAS CONTROL } } else if (Input.GetKeyDown(KeyCode.A)) { ExecuteNextAction(0.2f); } // monitoring positions of agents in the polygon dictionary if (GlobalNavigator.usingDynamicNavigationMesh) { currentPolygonIndex = CentralizedManager.UpdatePolygonDictionary(currentState.getPosition(), currentPolygonIndex, null); } if (text != null) { string t = ""; t = t + "global path " + numGlobalPathWaypoints.ToString() + "\n"; t = t + "Current plan execution index : " + currentPlanExecutionIndex.ToString() + "\n"; t = t + "current state " + currentState.getPosition().ToString() + " " + currentState._time.ToString() + " " + currentState._speed.ToString() + " \n"; for (int i = 0; i < gridNavigationTasks.Count; i++) { t = t + offMeshLinkWayPoint[i].ToString() + " grid task " + i.ToString() + " " + gridNavigationTasks[i].taskPriority.ToString() + " " + gridNavigationTasks[i].startState.getPosition().ToString() + " " + gridNavigationTasks[i].startState._time.ToString() + " " + gridNavigationTasks[i].goalState.getPosition().ToString() + " " + gridNavigationTasks[i].goalState._time.ToString() + " " + localPaths[i].Count.ToString() + " " + spaceTimePaths[i].Count.ToString() + "\n"; } text.text = t; } // trying text mesh int timeLeftForGlobalGoal = Mathf.RoundToInt(goalState._time - currentState._time); int timeLeftForCurrentWaypoint; if (goalReached == false) { timeLeftForCurrentWaypoint = Mathf.RoundToInt(gridNavigationTasks[currentPlanExecutionIndex].goalState._time - currentState._time); } else { timeLeftForCurrentWaypoint = 0; } textMesh.text = timeLeftForGlobalGoal.ToString() + "/" + timeLeftForCurrentWaypoint.ToString(); }
public void addTask() { task.execute(); _tasks.Add(task); current++; }