public void Execute(AtmosSimulation simulation) { var cell = simulation.currentState[pos.x, pos.y]; cell.isWall = false; simulation.currentState[pos.x, pos.y] = cell; }
public void ChangeGasMix(GasMix newGasMix) { AtmosSimulation.RemovalAllGasOverlays(this); GasMix = newGasMix; AtmosSimulation.GasVisualEffects(this); }
public IEnumerator MakeStep(AtmosSimulation sim) { var currentChunks = sim.currentState.Chunks.ToArray(); var nextChunks = sim.nextState.Chunks.ToArray(); // First generate wind map windJobs.Clear(); for (int i = 0; i < currentChunks.Length; i++) { var job = new WindJob() { currentState = currentChunks[i], nextState = nextChunks[i] }; var jobHandle = job.Schedule(); windJobs.Add(jobHandle); } // Wait until wind jobs finished while (windJobs.Count((j) => !j.IsCompleted) > 0) { yield return(null); } // Now apply wind applyWindJobs.Clear(); for (int i = 0; i < currentChunks.Length; i++) { var job = new ApplyWindJob() { currentState = currentChunks[i], nextState = nextChunks[i] }; var jobHandle = job.Schedule(); applyWindJobs.Add(jobHandle); } // Wait until apply jobs finished while (applyWindJobs.Count((j) => !j.IsCompleted) > 0) { yield return(null); } /*new CalculateTotalPressureJob() * { * grid = sim.currentState * }.Execute();*/ // Swap the buffer var temp = sim.currentState; sim.currentState = sim.nextState; sim.nextState = temp; }
public void Execute(AtmosSimulation simulation) { var grid = simulation.currentState; if (!grid.HasCell(pos.x, pos.y)) { var newCell = new AtmosCell() { isWall = true }; grid.AddCell(pos.x, pos.y, newCell); simulation.currentState = grid; } else { var cell = simulation.currentState[pos.x, pos.y]; cell.isWall = true; simulation.currentState[pos.x, pos.y] = cell; } }
public void Execute(AtmosSimulation simulation) { var grid = simulation.currentState; if (!grid.HasCell(pos.x, pos.y)) { var newCell = new AtmosCell() { isWall = false, pressure = ammount }; grid.AddCell(pos.x, pos.y, newCell); simulation.currentState = grid; } else { var cell = simulation.currentState[pos.x, pos.y]; cell.pressure += ammount; simulation.currentState[pos.x, pos.y] = cell; } }
public IEnumerator MakeStep(AtmosSimulation sim) { var currentChunks = sim.currentState.Chunks.ToArray(); var nextChunks = sim.nextState.Chunks.ToArray(); /*var copyJob = new CopyJob() * { * currentState = sim.currentState, * nextState = sim.nextState * }*/ lastJob = default(JobHandle); for (int i = 0; i < currentChunks.Length; i++) { var job = new EqualisationJob() { nextState = currentChunks[i] }; lastJob = job.Schedule(lastJob); } /*lastJob = new CalculateTotalPressureJob() * { * grid = sim.currentState * }.Schedule(lastJob);*/ while (!lastJob.IsCompleted) { yield return(null); } /*var temp = sim.currentState; * sim.currentState = sim.nextState; * sim.nextState = temp;*/ }
static AtmosThread() { simulation = new AtmosSimulation(); }
static AtmosThread() { simulation = new AtmosSimulation(); sampler = CustomSampler.Create("AtmosphericsStep"); }
static AtmosThread() { simulation = new AtmosSimulation(); new Thread(Run).Start(); }
public void Execute(AtmosSimulation simulation) { simulation.currentState.AddCell(pos.x, pos.y, new AtmosCell()); }
// Start is called before the first frame update void Start() { simulation = AtmosSimulation.FromTilemap(tilemapVisual, chunkSize); StartCoroutine(simulation.SimulationRoutine()); }