private void SubmitToEngine(int playerIndex, List <Cmd> commandsToSubmit)
        {
            if (commandsToSubmit.Count == 1)
            {
                ITaskEngine taskEngine = m_engine.GetClientTaskEngine(playerIndex);
                taskEngine.TerminateAll();

                m_engine.Submit(playerIndex, commandsToSubmit[0]);

                //Render hit;
            }
            else if (commandsToSubmit.Count > 1)
            {
                CompositeCmd cmd = new CompositeCmd
                {
                    Commands = commandsToSubmit.ToArray()
                };

                ITaskEngine taskEngine = m_engine.GetClientTaskEngine(playerIndex);
                taskEngine.TerminateAll();

                m_engine.Submit(playerIndex, cmd);
            }
            else
            {
                Debug.LogWarning("No commands to submit");
            }
        }
        public IEnumerator FindPathClientSidePreprocessingTest()
        {
            BeginTest(TestEnv0, 4, 0, () => {
                MapRoot map = Dependencies.Map.Map;
                IMatchEngineCli matchEngineCli = Dependencies.MatchEngine;

                const int playerId          = 3;
                Coordinate[] coords         = map.FindDataOfType((int)KnownVoxelTypes.Eater, playerId);
                VoxelData data              = map.Get(coords[0]);
                Coordinate targetCoordinate = coords[0].Add(-1, -1);
                MovementCmd moveCmd         = new MovementCmd(CmdCode.Move, data.UnitOrAssetIndex, 0);
                moveCmd.Coordinates         = new[] { coords[0], targetCoordinate };

                MatchEngineCliEvent <long, CommandsBundle> eventHandler = null;
                eventHandler = (e, tick, commandsBundle) =>
                {
                    if (commandsBundle.TasksStateInfo != null)
                    {
                        TaskStateInfo taskStateInfo = commandsBundle.TasksStateInfo[0];
                        Assert.AreEqual(taskStateInfo.PlayerId, playerId);

                        if (taskStateInfo.State == TaskState.Completed)
                        {
                            matchEngineCli.ExecuteCommands -= eventHandler;

                            Coordinate[] newCoords = map.FindDataOfType((int)KnownVoxelTypes.Eater, playerId);
                            Assert.AreEqual(targetCoordinate, newCoords[0]);

                            EndTest();
                        }
                        else
                        {
                            Assert.AreEqual(TaskState.Active, taskStateInfo.State);
                        }
                    }
                };
                matchEngineCli.ExecuteCommands += eventHandler;

                TaskInfo taskInfo = new TaskInfo(moveCmd);
                taskInfo.RequiresClientSidePreprocessing = true;
                matchEngineCli.GetClientTaskEngine(playerId).GenerateIdentitifers(taskInfo);
                matchEngineCli.Submit(playerId, new TaskCmd(SerializedTask.FromTaskInfo(taskInfo)));
            });

            yield return(Run());
        }
Пример #3
0
 public void Submit(int playerId, Cmd cmd)
 {
     m_engine.Submit(playerId, cmd);
 }