private RuntimeTask GetRuntimeTask(Task task) { RuntimeTask value = null; if (_runtimeTasks.ContainsKey(task)) { value = _runtimeTasks[task]; } return(value); }
private void FinishTask() { if (_aliveBehavior is Task) { RuntimeTask rt = GetRuntimeTask(_aliveBehavior as Task); #if UNITY_EDITOR rt.closed = true; #endif rt.OnFinish(); } }
private void OnTaskUpdate(float dt) { if (m_currentRuntimeTask != null) { if (m_currentRuntimeTask.OnUpdate() == eBTStatus.Success) { m_currentRuntimeTask = null; FinishExecute(true); } } }
private void StartTask(Node node) { _aliveBehavior = node; if (node is Task) { RuntimeTask rt = GetRuntimeTask(_aliveBehavior as Task); #if UNITY_EDITOR rt.closed = false; #endif rt.OnStart(); m_currentRuntimeTask = rt; } }
private void InitializeTask(Task task) { RuntimeTask rt = null; //if (task is Wait) // rt = Initialize_Wait(task); //else { if (task.targetScript == null) { Debug.LogError(string.Format("{0} : task.targetScript = null", task.Name)); return; } rt = new RuntimeTask(task, task.targetMethod); MonoBehaviour comp = GetEqualTypeComponent(task.targetScript.GetType()) as MonoBehaviour; if (comp == null) { comp = gameObject.AddComponent(task.targetScript.GetType()) as MonoBehaviour; IBTAI ibtai = comp as IBTAI; ibtai.InitializeAI(); } if (task.isCoroutine) { rt.comp = comp; } else { Func <eBTStatus> tempFunc = Delegate.CreateDelegate(typeof(Func <eBTStatus>), comp, task.targetMethod) as Func <eBTStatus>; rt.taskFunc = tempFunc; } } _runtimeTasks.Add(task, rt); }