Beispiel #1
0
    protected override void ThreadFunction()
    {
        try
        {
            bool running = true;

            List <SimulateAreaJob> jobs = new List <SimulateAreaJob>();

            jobs.Clear();

            uint totalDevisions = _worldSimulationState.SimulationDevisions;
            uint stepsCompleted = 0;

            for (uint i = 0; i < totalDevisions; i++)
            {
                jobs.Add(SimulateStep(i, totalDevisions, () =>
                {
                    if (++stepsCompleted >= jobs.Count)
                    {
                        //TODO SImulate again
                        _worldSimulationState.StepSimulationState();
                        _worldSimulationStateService.SaveState(_worldSimulationState, _persistentDataPath);

                        SimulationJob _job = new SimulationJob(_worldDataAccess, _worldSimulationState, _worldSimulationStateService, _persistentDataPath);
                        _job.Start();
                    }
                }));
            }
        }
        catch (Exception e)
        {
            Debug.LogError("There was an error running SimulationJob \n" + e);
        }
    }