Esempio n. 1
0
    /// <summary>
    /// Calculates number of SpawnItems per SpawnEvent, and the spawn grid size.
    /// Then give this information to the Spawn System.
    /// </summary>
    private void SetSpawnGridSize(BiomeConditions biome)
    {
        // SpawnChunkiness of 0 means one item per spawn event,
        // SpawnChunkiness of 1 means one spawnBagSize per spawn event,
        int spawnEventCount = (int)(1 + (biome.SpawnChunkiness * (spawnBagSize - 1)));

        // Assuming constant SpawnRateMultiplier, then SpawnChunkiness will not change overall density
        // Increase in SpawnRateMultiplier lowers the gridSize, which increases density
        // SpawnRateMultiplier of 2.0 will double the spawn density.
        int spawnGridSize = (int)(Constants.SPAWN_GRID_SIZE * Math.Sqrt(spawnEventCount)
                                  / Math.Sqrt(biome.SpawnRateMultiplier));

        spawnSystem.SetSpawnData(spawnEventCount, spawnGridSize, biome.SpawnRateMultiplier);
    }