コード例 #1
0
    public void Execute(AtmosSimulation simulation)
    {
        var cell = simulation.currentState[pos.x, pos.y];

        cell.isWall = false;
        simulation.currentState[pos.x, pos.y] = cell;
    }
コード例 #2
0
ファイル: MetaDataNode.cs プロジェクト: AtnerNT/unitystation
    public void ChangeGasMix(GasMix newGasMix)
    {
        AtmosSimulation.RemovalAllGasOverlays(this);

        GasMix = newGasMix;

        AtmosSimulation.GasVisualEffects(this);
    }
コード例 #3
0
    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;
    }
コード例 #4
0
    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;
        }
    }
コード例 #5
0
    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;
        }
    }
コード例 #6
0
    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;*/
    }
コード例 #7
0
 static AtmosThread()
 {
     simulation = new AtmosSimulation();
 }
コード例 #8
0
 static AtmosThread()
 {
     simulation = new AtmosSimulation();
     sampler    = CustomSampler.Create("AtmosphericsStep");
 }
コード例 #9
0
 static AtmosThread()
 {
     simulation = new AtmosSimulation();
     new Thread(Run).Start();
 }
コード例 #10
0
 public void Execute(AtmosSimulation simulation)
 {
     simulation.currentState.AddCell(pos.x, pos.y, new AtmosCell());
 }
コード例 #11
0
 // Start is called before the first frame update
 void Start()
 {
     simulation = AtmosSimulation.FromTilemap(tilemapVisual, chunkSize);
     StartCoroutine(simulation.SimulationRoutine());
 }