Exemplo n.º 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);
        }
    }
Exemplo n.º 2
0
    private IEnumerator SimulationCoroutine()
    {
        yield return(0);

        bool simulating = true;

        _job = new SimulationJob(_worldDataAccess, _state, _worldSimulationStateService, Application.persistentDataPath);
        _job.Start();

        while (!_job.IsDone)
        {
            yield return(0);
        }
    }