private static void AddCustomData(string classId, LootDistributionData.SrcData customSrcData, Dictionary <string, LootDistributionData.SrcData> srcDistribution, Dictionary <BiomeType, LootDistributionData.DstData> dstDistribution)
        {
            srcDistribution.Add(classId, customSrcData);

            List <LootDistributionData.BiomeData> distribution = customSrcData.distribution;

            if (distribution != null)
            {
                for (int i = 0; i < distribution.Count; i++)
                {
                    LootDistributionData.BiomeData biomeData = distribution[i];
                    BiomeType biome       = biomeData.biome;
                    int       count       = biomeData.count;
                    float     probability = biomeData.probability;

                    if (!dstDistribution.TryGetValue(biome, out LootDistributionData.DstData dstData))
                    {
                        dstData = new LootDistributionData.DstData
                        {
                            prefabs = new List <LootDistributionData.PrefabData>()
                        };
                        dstDistribution.Add(biome, dstData);
                    }

                    var prefabData = new LootDistributionData.PrefabData
                    {
                        classId     = classId,
                        count       = count,
                        probability = probability
                    };
                    dstData.prefabs.Add(prefabData);
                }
            }
        }
        private static void EditExistingData(string classId, LootDistributionData.SrcData existingData, LootDistributionData.SrcData changes, Dictionary <BiomeType, LootDistributionData.DstData> dstData)
        {
            foreach (LootDistributionData.BiomeData customBiomeDist in changes.distribution)
            {
                bool foundBiome = false;

                for (int i = 0; i < existingData.distribution.Count; i++)
                {
                    LootDistributionData.BiomeData biomeDist = existingData.distribution[i];

                    if (customBiomeDist.biome == biomeDist.biome)
                    {
                        biomeDist.count       = customBiomeDist.count;
                        biomeDist.probability = customBiomeDist.probability;

                        foundBiome = true;
                    }
                }

                if (!foundBiome)
                {
                    existingData.distribution.Add(customBiomeDist);
                }

                if (!dstData.TryGetValue(customBiomeDist.biome, out LootDistributionData.DstData biomeDistData))
                {
                    biomeDistData = new LootDistributionData.DstData
                    {
                        prefabs = new List <LootDistributionData.PrefabData>()
                    };
                    dstData.Add(customBiomeDist.biome, biomeDistData);
                }

                bool foundPrefab = false;

                for (int j = 0; j < biomeDistData.prefabs.Count; j++)
                {
                    LootDistributionData.PrefabData prefabData = biomeDistData.prefabs[j];

                    if (prefabData.classId == classId)
                    {
                        prefabData.count       = customBiomeDist.count;
                        prefabData.probability = customBiomeDist.probability;

                        foundPrefab = true;
                    }
                }

                if (!foundPrefab)
                {
                    biomeDistData.prefabs.Add(new LootDistributionData.PrefabData()
                    {
                        classId     = classId,
                        count       = customBiomeDist.count,
                        probability = customBiomeDist.probability
                    });
                }
            }
        }
        void ILootDistributionHandler.EditLootDistributionData(string classId, BiomeType biome, float probability, int count)
        {
            if (!LootDistributionPatcher.CustomSrcData.TryGetValue(classId, out LootDistributionData.SrcData srcData))
            {
                LootDistributionPatcher.CustomSrcData[classId] = (srcData = new LootDistributionData.SrcData());

                var biomeDistribution = new List <LootDistributionData.BiomeData>
                {
                    new LootDistributionData.BiomeData()
                    {
                        biome       = biome,
                        probability = probability,
                        count       = count
                    }
                };

                srcData.distribution = biomeDistribution;

                return;
            }

            for (int i = 0; i < srcData.distribution.Count; i++)
            {
                LootDistributionData.BiomeData distribution = srcData.distribution[i];

                if (distribution.biome == biome)
                {
                    distribution.count       = count;
                    distribution.probability = probability;

                    return;
                }
            }

            // If we reached this point, that means the srcData is present, but the biome in the distribution is not.
            // Lets add it manually.
            srcData.distribution.Add(new LootDistributionData.BiomeData()
            {
                biome       = biome,
                probability = probability,
                count       = count
            });
        }