示例#1
0
    /// <summary>
    /// Set up full SpawnItems and MicrobeItems bags in the spawnSystem based on the counts dictionaries.
    /// </summary>
    private void SetFullSpawnBags()
    {
        spawnBagSize = 0;

        foreach (Compound compound in compoundCloudCounts.Keys)
        {
            spawnBagSize += compoundCloudCounts[compound];
            for (int i = 0; i < compoundCloudCounts[compound]; i++)
            {
                spawnSystem.AddSpawnItem(new CloudItem(compound, compoundAmounts[compound], CloudSpawner));
            }
        }

        foreach (ChunkConfiguration chunk in chunkCounts.Keys)
        {
            spawnBagSize += chunkCounts[chunk];
            foreach (var mesh in chunk.Meshes)
            {
                if (mesh.LoadedScene == null)
                {
                    throw new ArgumentException("configured chunk spawner has a mesh that has no scene loaded");
                }
            }

            for (int i = 0; i < chunkCounts[chunk]; i++)
            {
                spawnSystem.AddSpawnItem(new ChunkItem(chunk, ChunkSpawner));
            }
        }

        foreach (Species key in speciesCounts.Keys)
        {
            if (!(key is MicrobeSpecies))
            {
                continue;
            }

            MicrobeSpecies species = (MicrobeSpecies)key;
            spawnBagSize += speciesCounts[key];

            for (int i = 0; i < speciesCounts[key]; i++)
            {
                MicrobeItem microbeItem = new MicrobeItem(species, MicrobeSpawner);
                microbeItem.IsWanderer = false;
                spawnSystem.AddSpawnItem(microbeItem);

                MicrobeItem wanderMicrobeItem = new MicrobeItem(species, MicrobeSpawner);
                wanderMicrobeItem.IsWanderer = true;
                spawnSystem.AddMicrobeItem(wanderMicrobeItem);
            }
        }

        spawnSystem.SetMicrobeBagSize();
    }