public RunningTaskInfo(TaskTemplateType type, IMatchUnitAssetView target, long taskId, float startTime) { Type = type; Target = target; TaskId = taskId; StartTime = startTime; }
private void SubmitTaskToClientTaskEngine(TaskTemplateType templateType, params TaskInfo[] defines) { m_playersBot.Init(); int playerIndex = m_gameState.LocalToPlayerIndex(m_localPlayerIndex); IMatchPlayerView playerView = m_gameState.GetPlayerView(playerIndex); long[] selection = m_unitSelection.GetSelection(playerIndex, playerIndex); for (int i = 0; i < selection.Length; ++i) { m_playersBot.SubmitTask(Time.realtimeSinceStartup, playerView.GetUnit(selection[i]), templateType, defines); } }
TaskInfo IBotSubmitTask.SubmitTask(float time, IMatchUnitAssetView unit, TaskTemplateType type, params TaskInfo[] parameters) { if (m_state.BusyUnits[(KnownVoxelTypes)unit.Data.Type].ContainsKey(unit.Id)) { throw new InvalidOperationException("unit " + unit.Id + " of type " + (KnownVoxelTypes)unit.Data.Type + " is busy"); } TaskInfo taskInfo = m_state.TaskTemplates[type].Acquire(); TaskInfo unitIdTask = TaskInfo.EvalExpression(ExpressionInfo.PrimitiveVal(unit.Id)); TaskInfo playerIdTask = TaskInfo.EvalExpression(ExpressionInfo.PrimitiveVal(m_playerView.Index)); taskInfo.Children[0] = unitIdTask; taskInfo.Children[1] = playerIdTask; int argsLength = parameters != null ? parameters.Length : 0; TaskInfo rootTask = taskInfo.Children[2 + argsLength]; if (rootTask == null || taskInfo.Children.Length <= argsLength + 1 || taskInfo.Children[argsLength + 1] != null) { throw new ArgumentException("wrong number of arguments for task template: " + type, "type"); } rootTask.Inputs[0].OutputTask = unitIdTask; rootTask.Inputs[1].OutputTask = playerIdTask; if (parameters != null) { for (int i = 0; i < parameters.Length; ++i) { TaskInfo define = parameters[i]; define.Inputs[0].ExtensionSocket = rootTask.Inputs[0]; define.Inputs[1].ExtensionSocket = rootTask.Inputs[1]; taskInfo.Children[2 + i] = define; taskInfo.Children[2 + parameters.Length].Inputs[2 + i].OutputTask = define; } } taskInfo.SetParents(); taskInfo.Initialize(m_playerView.Index); m_state.FreeUnits[(KnownVoxelTypes)unit.Data.Type].Remove(unit.Id); m_state.BusyUnits[(KnownVoxelTypes)unit.Data.Type].Add(unit.Id, unit); m_taskEngine.SubmitTask(taskInfo); RunningTaskInfo runningTaskInfo = new RunningTaskInfo(type, unit, taskInfo.TaskId, time); m_state.TaskIdToTask.Add(taskInfo.TaskId, runningTaskInfo); m_state.UnitIdToTask.Add(unit.Id, runningTaskInfo); return(taskInfo); }
void IBotSubmitTask.RegisterTask(TaskTemplateType type, SerializedTask serializedTask) { m_state.TaskTemplates[type] = new TaskInfoPool(() => { TaskInfo coreTaskInfo = SerializedTask.ToTaskInfo(serializedTask); return(TaskInfo.Procedure ( null, null, coreTaskInfo, TaskInfo.Return(ExpressionInfo.TaskStatus(coreTaskInfo)) )); }); }
private void Start() { LocalPlayerIndex = m_viewport.LocalPlayerIndex; int playerIndex = m_gameState.LocalToPlayerIndex(LocalPlayerIndex); m_cameraController = Dependencies.GameView.GetCameraController(LocalPlayerIndex); m_locationPicker = Dependencies.GameView.GetLocationPicker(LocalPlayerIndex); m_playersBot = MatchFactoryCli.CreateBotController(m_gameState.GetPlayer(playerIndex), m_engine.GetClientTaskEngine(playerIndex), new PlayerStrategy()); m_playersBot.Init(); SerializedTask[] taskTemplates = m_gameState.GetTaskTemplates(playerIndex); SerializedNamedTaskLaunchInfo[] taskTemplatesData = m_gameState.GetTaskTemplateData(playerIndex); for (int i = 0; i < taskTemplates.Length; ++i) { TaskTemplateType coreTaskType = taskTemplatesData[i].Type; m_playersBot.RegisterTask(coreTaskType, taskTemplates[i]); } }
public TaskInfo SubmitAssignment(float time, Guid groupId, IMatchUnitAssetView unit, int previewType, Coordinate previewCoordinate, TaskTemplateType type, params TaskInfo[] defines) { if (m_state.BusyUnits[(KnownVoxelTypes)unit.Data.Type].ContainsKey(unit.Id)) { throw new InvalidOperationException("unit " + unit.Id + " of type " + (KnownVoxelTypes)unit.Data.Type + " is busy"); } TaskInfo taskInfo = TaskInfo.Command(new CreateAssignmentCmd(unit.Id) { CreatePreview = true, PreviewType = previewType, PreviewCoordinate = previewCoordinate, GroupId = groupId, TaskLaunchInfo = new SerializedTaskLaunchInfo { Type = type, DeserializedParameters = defines }, }); taskInfo.SetParents(); taskInfo.Initialize(m_playerView.Index); m_state.FreeUnits[(KnownVoxelTypes)unit.Data.Type].Remove(unit.Id); m_state.BusyUnits[(KnownVoxelTypes)unit.Data.Type].Add(unit.Id, unit); m_taskEngine.SubmitTask(taskInfo); RunningTaskInfo runningTaskInfo = new RunningTaskInfo(TaskTemplateType.None, unit, taskInfo.TaskId, time); m_state.TaskIdToTask.Add(taskInfo.TaskId, runningTaskInfo); m_state.UnitIdToTask.Add(unit.Id, runningTaskInfo); return(taskInfo); }