コード例 #1
0
    //Implemented using particle deposition
    private void EruptVolcanos(List <Volcano> volcanos, int maxAge, int maxSearchRange, int maxElevationThreshold, int dropZoneRadius, float rockSize, float heightSimilarityEpsilon, bool updateCoords = false)
    {
        for (int v = 0; v < volcanos.Count; v++)
        {
            var vol = volcanos[v];
            //Increase age
            vol.Age++;
            //If it's at the end of it's lifetime, remove it from the list and return it to the volcano object pool
            if (vol.Age >= maxAge)
            {
                ObjectPooler.current.ReturnVolcanoToPool(vol);
                volcanos.RemoveAt(v);
            }
            else //otherwise, do eruption (particle deposition)
            {
                crustNodes = TerrainGeneration.ParticleDeposition(crustNodes, vol, rockSize, heightSimilarityEpsilon, dropZoneRadius, maxSearchRange, maxElevationThreshold);
            }

            if (updateCoords)
            {
                if (crustNodes[vol.X, vol.Z][0].Plate.CheckMoveX())
                {
                    vol.X = (vol.X + crustNodes[vol.X, vol.Z][0].Plate.XSpeed) % width;
                    if (vol.X < 0)
                    {
                        vol.X = width + vol.X;
                    }
                }

                if (crustNodes[vol.X, vol.Z][0].Plate.CheckMoveZ())
                {
                    vol.Z = (vol.Z + crustNodes[vol.X, vol.Z][0].Plate.ZSpeed) % height;
                    if (vol.Z < 0)
                    {
                        vol.Z = height + vol.Z;
                    }
                }
            }
        }
    }