private void BuildTaskList(List <Network.PowerHistory> powerList, ref int index, PowerTaskList taskList) { while (index < powerList.Count) { Network.PowerHistory netPower = powerList[index]; Network.PowerType type = netPower.Type; if (type == Network.PowerType.ACTION_START) { if (!taskList.IsEmpty()) { this.EnqueueTaskList(taskList); } PowerTaskList item = new PowerTaskList(); item.SetSourceAction((Network.HistActionStart)netPower); PowerTaskList origin = taskList.GetOrigin(); if (origin.IsSourceActionOrigin()) { item.SetParent(origin); } this.m_previousStack.Push(item); index++; this.BuildTaskList(powerList, ref index, item); return; } if (type == Network.PowerType.ACTION_END) { taskList.SetEndAction((Network.HistActionEnd)netPower); if (this.m_previousStack.Count > 0) { this.m_previousStack.Pop(); this.EnqueueTaskList(taskList); return; } break; } taskList.CreateTask(netPower).DoRealTimeTask(powerList, index); index++; } if (!taskList.IsEmpty()) { this.EnqueueTaskList(taskList); } }