Exemplo n.º 1
0
        private WorldEntityInfo GetEntityInfo()
        {
            WorldEntityInfo newEntityInfo;

            if (WorldEntityDatabase.TryGetInfo(CraftData.GetClassIdForTechType(TechType.Seamoth), out WorldEntityInfo entityInfo))
            {
                newEntityInfo = new WorldEntityInfo()
                {
                    cellLevel  = entityInfo.cellLevel,
                    classId    = this.ClassID,
                    localScale = entityInfo.localScale,
                    prefabZUp  = entityInfo.prefabZUp,
                    slotType   = entityInfo.slotType,
                    techType   = this.TechType
                };

                return(newEntityInfo);
            }

            newEntityInfo = new WorldEntityInfo()
            {
                cellLevel  = LargeWorldEntity.CellLevel.Global,
                classId    = this.ClassID,
                localScale = Vector3.one,
                prefabZUp  = false,
                slotType   = EntitySlot.Type.Medium,
                techType   = this.TechType
            };

            return(newEntityInfo);
        }
Exemplo n.º 2
0
        public void Load()
        {
            var assembly = Assembly.GetExecutingAssembly();

            new Harmony($"DaWrecka_{assembly.GetName().Name}").PatchAll(assembly);
            foreach (string s in new HashSet <string>()
            {
                "Gravsphere", "GravTrapMk2"
            })
            {
                TechType tt = TechTypeUtils.GetTechType(s);
                if (tt == TechType.None)
                {
                    Log.LogWarning($"Could not retrieve TechType for string {s}");
                }
                else
                {
                    var classid = CraftData.GetClassIdForTechType(TechType.Gravsphere);
                    if (WorldEntityDatabase.TryGetInfo(classid, out var worldEntityInfo))
                    {
                        worldEntityInfo.cellLevel = LargeWorldEntity.CellLevel.Global;

                        WorldEntityDatabase.main.infos[classid] = worldEntityInfo;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static void Load()
        {
            Harmony.CreateAndPatchAll(assembly, $"MrPurple6411_{assembly.GetName().Name}");
            var classid = CraftData.GetClassIdForTechType(TechType.TimeCapsule);

            if (WorldEntityDatabase.TryGetInfo(classid, out var worldEntityInfo))
            {
                worldEntityInfo.cellLevel = LargeWorldEntity.CellLevel.VeryFar;

                WorldEntityDatabase.main.infos[classid] = worldEntityInfo;
            }
        }
        public static bool Prefix(CellManager __instance, IEntitySlot slot, ref EntitySlot.Filler __result)
        {
            int  num    = 0;
            bool flag   = __instance.spawner == null;
            bool result = true;

            if (flag)
            {
                __result = default;
                result   = false;
            }
            else if (!slot.IsCreatureSlot() && Config.ToggleValue)
            {
                while (string.IsNullOrEmpty(__result.classId) && num < Config.SliderValue)
                {
                    num++;
                    __result = __instance.spawner.GetPrefabForSlot(slot, true);
                    if (!string.IsNullOrEmpty(__result.classId))
                    {
                        WorldEntityInfo wei;
                        if (WorldEntityDatabase.TryGetInfo(__result.classId, out wei))
                        {
                            if (wei.techType == TechType.TimeCapsule)
                            {
                                ErrorMessage.AddWarning("!!!!!Time Capsule Spawned!!!!!");
                            }
                        }
                    }
                }
                ;
                result = false;
            }
            else if (slot.IsCreatureSlot() && Config.ToggleValue)
            {
                __result = __instance.spawner.GetPrefabForSlot(slot, true);
                WorldEntityInfo wei;
                if (!string.IsNullOrEmpty(__result.classId))
                {
                    if (WorldEntityDatabase.TryGetInfo(__result.classId, out wei))
                    {
                        if (wei.techType == TechType.ReaperLeviathan)
                        {
                            ErrorMessage.AddWarning("!!!!!WARNING Reaper Leviathan WARNING!!!!!");
                        }
                    }
                }
                result = false;
            }
            return(result);
        }
Exemplo n.º 5
0
        private static void EnsureDefaultDistributions()
        {
            if (!File.Exists(DefaultDistributions))
            {
                PrefabDatabase.LoadPrefabDatabase(SNUtils.prefabDatabaseFilename);
            }
            {
                SortedDictionary <string, List <BiomeData> > defaultDistributions = new SortedDictionary <string, List <BiomeData> >();
                LootDistributionData data = LootDistributionData.Load("Balance/EntityDistributions");
                foreach (KeyValuePair <string, SrcData> pair in data.srcDistribution)
                {
                    if (WorldEntityDatabase.TryGetInfo(pair.Key, out WorldEntityInfo info))
                    {
                        if (info.techType != TechType.None)
                        {
                            defaultDistributions[info.techType.AsString()] = pair.Value.distribution;
                        }
                    }
                }

                using (StreamWriter writer = new StreamWriter(DefaultDistributions))
                {
                    writer.Write(JsonConvert.SerializeObject(defaultDistributions, Formatting.Indented, new JsonConverter[] {
                        new StringEnumConverter()
                        {
#if SUBNAUTICA_STABLE
                            CamelCaseText = true,
#else
                            NamingStrategy = new CamelCaseNamingStrategy(),
#endif
                            AllowIntegerValues = true
                        },

                        new TechTypeConverter()
                    }));
                }
            }
        }
        public static void Postfix(CellManager __instance, IEntitySlot slot, ref EntitySlot.Filler __result)
        {
            int num = 0;

            if (__instance.spawner != null && !slot.IsCreatureSlot() && Main.config.ResourceMultiplier > 1)
            {
                while (string.IsNullOrEmpty(__result.classId) && num < Main.config.ResourceMultiplier)
                {
                    EntitySlot.Filler found = __instance.spawner.GetPrefabForSlot(slot, true);
                    if (!string.IsNullOrEmpty(found.classId) &&
                        WorldEntityDatabase.TryGetInfo(found.classId, out WorldEntityInfo entityInfo) &&
                        entityInfo.techType != TechType.None &&
                        !Main.config.Blacklist.Contains(entityInfo.techType.AsString()))
                    {
                        if (Main.config.WhiteList.Count == 0 || Main.config.WhiteList.Contains(entityInfo.techType.AsString()))
                        {
                            __result = found;
                        }
                    }
                    num++;
                }
            }
        }
Exemplo n.º 7
0
        public static void Load()
        {
            LootDistributionData data       = LootDistributionData.Load("Balance/EntityDistributions");
            List <TechType>      Drillables = Enum.GetValues(typeof(TechType)).OfType <TechType>().Where((tt) => tt.AsString().Contains("Drillable")).ToList();

            data.GetPrefabData(CraftData.GetClassIdForTechType(TechType.DrillableUranium), out SrcData UraniumData);
            foreach (TechType techType in Drillables)
            {
                string classId = CraftData.GetClassIdForTechType(techType);

                if (CraftData.GetPrefabForTechType(techType, false) == null)
                {
                    continue;
                }

                if (WorldEntityDatabase.TryGetInfo(classId, out WorldEntityInfo info))
                {
                    if (!data.GetPrefabData(classId, out SrcData srcData))
                    {
                        SMLHelper.V2.Handler.LootDistributionHandler.AddLootDistributionData(classId, UraniumData);
                    }
                }
            }
        }
Exemplo n.º 8
0
        private static void InventoryAndWaterParkSetup()
        {
            // Setting a name for the Rockgrub
            LanguageHandler.SetTechTypeName(TechType.Rockgrub, "Rockgrub");
            // Setting a Tooltip for the Rockgrub
            LanguageHandler.SetTechTypeTooltip(TechType.Rockgrub, "A small, luminescent scavenger");

            // Setting a Sprite for the Rockgrub
            Sprite rockgrub = ImageUtils.LoadSpriteFromFile(Path.Combine(AssetsFolder, "RockGrub.png"));

            if (rockgrub != null)
            {
                SpriteHandler.RegisterSprite(TechType.Rockgrub, rockgrub);
            }
            // Setting Rockgrub's size in the Inventory
            CraftDataHandler.SetItemSize(TechType.Rockgrub, new Vector2int(1, 1));
            // Setting WPC Parameters for Rockgrub so it can grow and breed normaly
            WaterParkCreature.waterParkCreatureParameters[TechType.Rockgrub] = new WaterParkCreatureParameters(0.03f, 0.7f, 1f, 1f);
            // Setting Fuel value for the Rockgrub
            BioReactorHandler.SetBioReactorCharge(TechType.Rockgrub, 350f);
            // Totally origina.. *cough* taken from MrPurple's CYS code
            #region BiomeData stuff
            Dictionary <TechType, List <BiomeData> > rockgrubBiomeData = new Dictionary <TechType, List <BiomeData> >()
            {
                {
                    TechType.Rockgrub,
                    new List <BiomeData>()
                    {
                        new BiomeData()
                        {
                            biome       = BiomeType.SafeShallows_CaveSpecial,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.GrassyPlateaus_CaveCeiling,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.MushroomForest_CaveRecess,
                            count       = 5,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.MushroomForest_CaveSpecial,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.MushroomForest_GiantTreeInteriorRecess,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.MushroomForest_GiantTreeInteriorSpecial,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.KooshZone_CaveWall,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.SparseReef_DeepWall,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.GrassyPlateaus_CaveCeiling,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Dunes_Rock,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Dunes_SandPlateau,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Dunes_CaveCeiling,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Dunes_CaveWall,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Mountains_CaveWall,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.GrassyPlateaus_CaveFloor,
                            count       = 4,
                            probability = 1f
                        },
                    }
                }
            };
            foreach (KeyValuePair <TechType, List <BiomeData> > pair in rockgrubBiomeData)
            {
                string classId = CraftData.GetClassIdForTechType(pair.Key) ?? pair.Key.AsString();
                if (PrefabDatabase.TryGetPrefabFilename(classId, out string prefabpath))
                {
                    if (!WorldEntityDatabase.TryGetInfo(classId, out WorldEntityInfo info))
                    {
                        info = new WorldEntityInfo()
                        {
                            cellLevel  = LargeWorldEntity.CellLevel.Medium,
                            classId    = classId,
                            localScale = UnityEngine.Vector3.one,
                            prefabZUp  = false,
                            slotType   = EntitySlot.Type.Medium,
                            techType   = pair.Key
                        };
                    }
                    WorldEntityDatabaseHandler.AddCustomInfo(classId, info);
                }
                SrcData data = new SrcData()
                {
                    prefabPath = prefabpath, distribution = pair.Value
                };
                LootDistributionHandler.AddLootDistributionData(classId, data);
            }
            #endregion
        }
Exemplo n.º 9
0
        public static Dictionary <BiomeType, List <TechType> > GetAllBiomesData()
        {
            Dictionary <BiomeType, List <TechType> > biomeLoot = new Dictionary <BiomeType, List <TechType> >();

            foreach (BiomeType biomeType in Enum.GetValues(typeof(BiomeType)))
            {
                if (Mod.LootDistributionData == null)
                {
                    QuickLogger.Debug("LootDistributionData is null");
                    return(null);
                }

                if (!Mod.LootDistributionData.GetBiomeLoot(biomeType, out LootDistributionData.DstData data))
                {
                    QuickLogger.Debug("DstData is null");
                    continue;
                }

                foreach (LootDistributionData.PrefabData prefabData in data.prefabs)
                {
                    if (prefabData.classId.ToLower() != "none")
                    {
                        if (WorldEntityDatabase.TryGetInfo(prefabData.classId, out WorldEntityInfo wei))
                        {
                            if (wei == null)
                            {
                                QuickLogger.Debug("WorldEntityInfo is null");
                                continue;
                            }

                            if (Resources.Contains(wei.techType))
                            {
                                if (!biomeLoot.ContainsKey(biomeType))
                                {
                                    biomeLoot[biomeType] = new List <TechType>();
                                }

                                biomeLoot[biomeType].Add(wei.techType);

                                QuickLogger.Debug($"Added Resource: {wei.techType} in biome {biomeType}");
                            }
                        }
                    }
                }


                var tempDictionary = new Dictionary <BiomeType, List <TechType> >();

                foreach (KeyValuePair <BiomeType, List <TechType> > pair in biomeLoot)
                {
                    var loot = new List <TechType>();
                    foreach (TechType techType in pair.Value)
                    {
                        if (techType.ToString().EndsWith("Chunk", StringComparison.OrdinalIgnoreCase) ||
                            techType.ToString().StartsWith("Drillable", StringComparison.OrdinalIgnoreCase))
                        {
                            GetResourceForSpecial(techType, loot);
                        }
                        else
                        {
                            loot.Add(techType);
                        }
                    }

                    tempDictionary.Add(pair.Key, loot.Distinct().ToList());
                }

                var newList = new Dictionary <string, List <string> >();

                foreach (KeyValuePair <BiomeType, List <TechType> > biomeData in tempDictionary)
                {
                    var name = biomeData.Key.AsString(true).Split('_')[0];
                    if (!newList.ContainsKey(name))
                    {
                        var g = new List <string>();

                        foreach (var techType in biomeData.Value)
                        {
                            g.Add(techType.AsString());
                        }
                        newList.Add(name, g);
                    }
                    else
                    {
                        foreach (TechType techType in biomeData.Value)
                        {
                            if (!newList[name].Contains(techType.AsString()))
                            {
                                newList[name].Add(techType.AsString());
                            }

                            if (!_allOres.Contains(techType))
                            {
                                _allOres.Add(techType);
                            }
                        }
                    }
                }

                //string json = JsonConvert.SerializeObject(newList, Formatting.Indented);
                //File.WriteAllText("Output_Formatted_TechTypeAsString.json", json);

                //string json = JsonConvert.SerializeObject(biomeLoot, Formatting.Indented);
                //File.WriteAllText("Output.json",json);
            }

            return(biomeLoot);
        }
Exemplo n.º 10
0
        internal static List <TechType> FindBiomeLoot(Transform tr, string currentBiome)
        {
            Dictionary <BiomeType, List <TechType> > biomeLoot = new Dictionary <BiomeType, List <TechType> >();

            var loot = new List <TechType>();

            foreach (BiomeType biomeType in Enum.GetValues(typeof(BiomeType)))
            {
                if (tr == null)
                {
                    QuickLogger.Debug("FindBiomeLoot: Transform cannot be null");
                    return(null);
                }


                if (string.IsNullOrEmpty(currentBiome))
                {
                    QuickLogger.Error($"No biome found!");
                    return(null);
                }

                //QuickLogger.Debug($"Biome Found: {currentBiome}");

                FindMatchingBiome(currentBiome, out var matchingBiome);

                if (biomeType.AsString().StartsWith(matchingBiome, StringComparison.OrdinalIgnoreCase))
                {
                    if (Mod.LootDistributionData == null)
                    {
                        QuickLogger.Debug("LootDistributionData is null");
                        return(null);
                    }

                    if (!Mod.LootDistributionData.GetBiomeLoot(biomeType, out LootDistributionData.DstData data))
                    {
                        QuickLogger.Debug("DstData is null");
                        continue;
                    }

                    foreach (LootDistributionData.PrefabData prefabData in data.prefabs)
                    {
                        if (prefabData.classId.ToLower() != "none")
                        {
                            if (WorldEntityDatabase.TryGetInfo(prefabData.classId, out WorldEntityInfo wei))
                            {
                                if (wei == null)
                                {
                                    QuickLogger.Debug("WorldEntityInfo is null");
                                    continue;
                                }

                                if (Resources.Contains(wei.techType))
                                {
                                    if (!biomeLoot.ContainsKey(biomeType))
                                    {
                                        biomeLoot[biomeType] = new List <TechType>();
                                    }

                                    biomeLoot[biomeType].Add(wei.techType);

                                    QuickLogger.Debug($"Added Resource: {wei.techType} in biome {biomeType}");
                                }
                            }
                        }
                    }
                }
            }

            foreach (KeyValuePair <BiomeType, List <TechType> > pair in biomeLoot)
            {
                foreach (TechType techType in pair.Value)
                {
                    if (techType.ToString().EndsWith("Chunk", StringComparison.OrdinalIgnoreCase) ||
                        techType.ToString().StartsWith("Drillable", StringComparison.OrdinalIgnoreCase))
                    {
                        GetResourceForSpecial(techType, loot);
                    }
                    else
                    {
                        loot.Add(techType);
                    }

                    loot = loot.Distinct().ToList();
                }
            }

            var lootWithAdditions = AdditionalLoot(loot, currentBiome);

            return(lootWithAdditions);
        }
Exemplo n.º 11
0
        public static bool Prefix(LootDistributionData __instance, BiomeType biome, ref bool __result, out LootDistributionData.DstData data)
        {
            if (customDSTDistribution.Count == 0 || Config.RegenSpawns)
            {
                Config.techProbability = new SortedList <string, float>();
                customDSTDistribution  = new SortedDictionary <BiomeType, LootDistributionData.DstData>();
                foreach (BiomeType bio in Enum.GetValues(typeof(BiomeType)))
                {
                    string x = bio.AsString().Split('_').GetLast <string>();
                    techs = new SortedDictionary <TechType, LootDistributionData.PrefabData>();
                    if (__instance.dstDistribution.ContainsKey(bio))
                    {
                        if (!Config.resetDefaults)
                        {
                            foreach (TechType type in Enum.GetValues(typeof(TechType)))
                            {
                                string tech0 = TechTypeExtensions.GetOrFallback(Language.main, type, type) + "| " + bio.AsString().Split('_')[0];
                                if (PlayerPrefs.HasKey(tech0 + ":TechProbability"))
                                {
                                    Config.techProbability[tech0] = PlayerPrefs.GetFloat(tech0 + ":TechProbability");
                                }
                            }
                        }
                        customDSTDistribution[bio]         = new LootDistributionData.DstData();
                        customDSTDistribution[bio].prefabs = new List <LootDistributionData.PrefabData>();

                        foreach (BiomeType b in Enum.GetValues(typeof(BiomeType)))
                        {
                            if (Config.Randomization && __instance.dstDistribution.TryGetValue(b, out var d))
                            {
                                foreach (LootDistributionData.PrefabData prefabData in d.prefabs)
                                {
                                    if (prefabData.classId.ToLower() != "none")
                                    {
                                        WorldEntityInfo wei;
                                        if (WorldEntityDatabase.TryGetInfo(prefabData.classId, out wei) && prefabData.probability > 0 && prefabData.probability < 1)
                                        {
                                            if (!bio.AsString().Contains("Fragment") && wei.slotType == EntitySlot.Type.Creature)
                                            {
                                                if (wei.techType == TechType.ReaperLeviathan)
                                                {
                                                    bool check = false;
                                                    foreach (LootDistributionData.PrefabData prefab in __instance.dstDistribution[bio].prefabs)
                                                    {
                                                        WorldEntityInfo wei2;
                                                        if (WorldEntityDatabase.TryGetInfo(prefab.classId, out wei2))
                                                        {
                                                            if (wei2.techType == TechType.Sandshark ||
                                                                wei2.techType == TechType.BoneShark ||
                                                                wei2.techType == TechType.SpineEel ||
                                                                wei2.techType == TechType.Shocker ||
                                                                wei2.techType == TechType.CrabSquid ||
                                                                wei2.techType == TechType.LavaLizard ||
                                                                wei2.techType == TechType.WarperSpawner)
                                                            {
                                                                check = true;
                                                            }
                                                        }
                                                    }
                                                    if (check)
                                                    {
                                                        if (!techs.ContainsKey(wei.techType))
                                                        {
                                                            if (Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                                            {
                                                                prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 1000;
                                                                techs[wei.techType]    = prefabData;
                                                                customDSTDistribution[bio].prefabs.Add(prefabData);
                                                                continue;
                                                            }
                                                            else
                                                            {
                                                                techs[wei.techType]    = prefabData;
                                                                prefabData.probability = 0.0025f;
                                                                Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 1000;
                                                                customDSTDistribution[bio].prefabs.Add(prefabData);
                                                                continue;
                                                            }
                                                        }
                                                    }
                                                }
                                                if (wei.techType == TechType.Shocker || wei.techType == TechType.CrabSquid || wei.techType == TechType.WarperSpawner)
                                                {
                                                    bool check = false;
                                                    foreach (LootDistributionData.PrefabData prefab in __instance.dstDistribution[bio].prefabs)
                                                    {
                                                        WorldEntityInfo wei2;
                                                        if (WorldEntityDatabase.TryGetInfo(prefab.classId, out wei2))
                                                        {
                                                            if (wei2.techType == TechType.Sandshark ||
                                                                wei2.techType == TechType.BoneShark ||
                                                                wei2.techType == TechType.SpineEel ||
                                                                wei2.techType == TechType.Shocker ||
                                                                wei2.techType == TechType.CrabSquid ||
                                                                wei2.techType == TechType.Crabsnake ||
                                                                wei2.techType == TechType.LavaLizard)
                                                            {
                                                                check = true;
                                                            }
                                                        }
                                                    }
                                                    if (check)
                                                    {
                                                        if (!techs.ContainsKey(wei.techType))
                                                        {
                                                            if (Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                                            {
                                                                prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 100;
                                                                techs[wei.techType]    = prefabData;
                                                                customDSTDistribution[bio].prefabs.Add(prefabData);
                                                                continue;
                                                            }
                                                            else
                                                            {
                                                                Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                                techs[wei.techType] = prefabData;
                                                                customDSTDistribution[bio].prefabs.Add(prefabData);
                                                                continue;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (((techs[wei.techType].probability > prefabData.probability && prefabData.count >= techs[wei.techType].count) || (techs[wei.techType].probability >= prefabData.probability && prefabData.count > techs[wei.techType].count)) &&
                                                                prefabData.probability > 0 &&
                                                                prefabData.probability < 1 &&
                                                                prefabData.count > 0)
                                                            {
                                                                Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                                techs[wei.techType] = prefabData;
                                                                customDSTDistribution[bio].prefabs.Add(prefabData);
                                                                continue;
                                                            }
                                                        }
                                                    }
                                                }
                                                if (wei.techType == TechType.Mesmer)
                                                {
                                                    bool check = false;
                                                    foreach (LootDistributionData.PrefabData prefab in __instance.dstDistribution[bio].prefabs)
                                                    {
                                                        WorldEntityInfo wei2;
                                                        if (WorldEntityDatabase.TryGetInfo(prefabData.classId, out wei2))
                                                        {
                                                            if (BehaviourData.GetBehaviourType(wei2.techType) == BehaviourType.SmallFish ||
                                                                wei2.techType == TechType.Peeper ||
                                                                wei2.techType == TechType.Mesmer)
                                                            {
                                                                check = true;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    if (check)
                                                    {
                                                        if (!techs.ContainsKey(wei.techType))
                                                        {
                                                            if (Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                                            {
                                                                prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 100;
                                                                techs[wei.techType]    = prefabData;
                                                                customDSTDistribution[bio].prefabs.Add(prefabData);
                                                                continue;
                                                            }
                                                            else
                                                            {
                                                                Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                                techs[wei.techType] = prefabData;
                                                                customDSTDistribution[bio].prefabs.Add(prefabData);
                                                                continue;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (((techs[wei.techType].probability > prefabData.probability && prefabData.count >= techs[wei.techType].count) || (techs[wei.techType].probability >= prefabData.probability && prefabData.count > techs[wei.techType].count)) &&
                                                                prefabData.probability > 0 &&
                                                                prefabData.probability < 1 &&
                                                                prefabData.count > 0)
                                                            {
                                                                Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                                techs[wei.techType] = prefabData;
                                                                customDSTDistribution[bio].prefabs.Add(prefabData);
                                                                continue;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else if (wei.techType != TechType.None && !bio.AsString().Contains("Fragment") && wei.techType.AsString().Contains("Chunk"))
                                            {
                                                bool check = false;
                                                foreach (LootDistributionData.PrefabData prefab in __instance.dstDistribution[bio].prefabs)
                                                {
                                                    WorldEntityInfo wei2;
                                                    if (WorldEntityDatabase.TryGetInfo(prefab.classId, out wei2))
                                                    {
                                                        if (wei2.techType == TechType.LimestoneChunk ||
                                                            wei2.techType == TechType.SandstoneChunk ||
                                                            wei2.techType == TechType.ShaleChunk)
                                                        {
                                                            check = true;
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (check)
                                                {
                                                    if (!techs.ContainsKey(wei.techType))
                                                    {
                                                        if (Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                                        {
                                                            prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 100;
                                                            techs[wei.techType]    = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                        else
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (((techs[wei.techType].probability > prefabData.probability && prefabData.count >= techs[wei.techType].count) || (techs[wei.techType].probability >= prefabData.probability && prefabData.count > techs[wei.techType].count)) &&
                                                            prefabData.probability > 0 &&
                                                            prefabData.probability < 1 &&
                                                            prefabData.count > 0)
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (wei.techType != TechType.None && !bio.AsString().Contains("Fragment") && (wei.techType == TechType.AluminumOxide ||
                                                                                                                               wei.techType == TechType.BloodOil ||
                                                                                                                               wei.techType == TechType.Sulphur ||
                                                                                                                               wei.techType == TechType.Diamond ||
                                                                                                                               wei.techType == TechType.Kyanite ||
                                                                                                                               wei.techType == TechType.Lead ||
                                                                                                                               wei.techType == TechType.Lithium ||
                                                                                                                               wei.techType == TechType.Magnetite ||
                                                                                                                               wei.techType == TechType.Nickel ||
                                                                                                                               wei.techType == TechType.Quartz ||
                                                                                                                               wei.techType == TechType.Silver))
                                            {
                                                bool check = false;
                                                foreach (LootDistributionData.PrefabData prefab in __instance.dstDistribution[bio].prefabs)
                                                {
                                                    WorldEntityInfo wei2;
                                                    if (WorldEntityDatabase.TryGetInfo(prefab.classId, out wei2))
                                                    {
                                                        if (wei2.techType == TechType.AluminumOxide ||
                                                            wei2.techType == TechType.BloodOil ||
                                                            wei2.techType == TechType.Sulphur ||
                                                            wei2.techType == TechType.Diamond ||
                                                            wei2.techType == TechType.Kyanite ||
                                                            wei2.techType == TechType.Lead ||
                                                            wei2.techType == TechType.Lithium ||
                                                            wei2.techType == TechType.Magnetite ||
                                                            wei2.techType == TechType.Nickel ||
                                                            wei2.techType == TechType.Salt ||
                                                            wei2.techType == TechType.Silver)
                                                        {
                                                            check = true;
                                                            break;
                                                        }
                                                    }
                                                }

                                                if (check)
                                                {
                                                    if (!techs.ContainsKey(wei.techType))
                                                    {
                                                        if (Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                                        {
                                                            prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 100;
                                                            techs[wei.techType]    = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                        else
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (((techs[wei.techType].probability > prefabData.probability && prefabData.count >= techs[wei.techType].count) || (techs[wei.techType].probability >= prefabData.probability && prefabData.count > techs[wei.techType].count)) &&
                                                            prefabData.probability > 0 &&
                                                            prefabData.probability < 1 &&
                                                            prefabData.count > 0)
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (wei.techType != TechType.None && !bio.AsString().Contains("Fragment") && wei.techType.AsString().Contains("Drillable"))
                                            {
                                                bool check = false;
                                                foreach (LootDistributionData.PrefabData prefab in __instance.dstDistribution[bio].prefabs)
                                                {
                                                    WorldEntityInfo wei2;
                                                    if (WorldEntityDatabase.TryGetInfo(prefab.classId, out wei2))
                                                    {
                                                        if (wei2.techType.AsString().Contains("Drillable"))
                                                        {
                                                            check = true;
                                                            break;
                                                        }
                                                    }
                                                }

                                                if (check)
                                                {
                                                    if (!techs.ContainsKey(wei.techType))
                                                    {
                                                        if (Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                                        {
                                                            prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 100;
                                                            techs[wei.techType]    = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                        else
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (((techs[wei.techType].probability > prefabData.probability && prefabData.count >= techs[wei.techType].count) || (techs[wei.techType].probability >= prefabData.probability && prefabData.count > techs[wei.techType].count)) &&
                                                            prefabData.probability > 0 &&
                                                            prefabData.probability < 1 &&
                                                            prefabData.count > 0)
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (((!bio.AsString().Contains("Fragment") &&
                                                       !b.AsString().Contains("Fragment")) || (bio.AsString().Contains("Fragment") &&
                                                                                               b.AsString().Contains("Fragment"))) &&
                                                     wei.techType.AsString().Contains("Fragment"))
                                            {
                                                bool check = false;
                                                foreach (LootDistributionData.PrefabData prefab in __instance.dstDistribution[bio].prefabs)
                                                {
                                                    WorldEntityInfo wei2;
                                                    if (WorldEntityDatabase.TryGetInfo(prefab.classId, out wei2))
                                                    {
                                                        if (wei2.techType.AsString().Contains("Fragment"))
                                                        {
                                                            check = true;
                                                            break;
                                                        }
                                                    }
                                                }

                                                if (check)
                                                {
                                                    if (!techs.ContainsKey(wei.techType))
                                                    {
                                                        if (Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                                        {
                                                            prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 100;
                                                            techs[wei.techType]    = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                        else
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (((techs[wei.techType].probability > prefabData.probability && prefabData.count >= techs[wei.techType].count) || (techs[wei.techType].probability >= prefabData.probability && prefabData.count > techs[wei.techType].count)) &&
                                                            prefabData.probability > 0 &&
                                                            prefabData.probability < 1 &&
                                                            prefabData.count > 0 &&
                                                            !bio.AsString().Contains("Fragment") &&
                                                            !b.AsString().Contains("Fragment"))
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (!bio.AsString().Contains("Fragment") && wei.techType == TechType.TimeCapsule)
                                            {
                                                bool check = false;
                                                foreach (LootDistributionData.PrefabData prefab in __instance.dstDistribution[b].prefabs)
                                                {
                                                    WorldEntityInfo wei2;
                                                    if (WorldEntityDatabase.TryGetInfo(prefab.classId, out wei2))
                                                    {
                                                        if (wei2.techType.AsString().Contains("Fragment"))
                                                        {
                                                            check = true;
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (check)
                                                {
                                                    if (!techs.ContainsKey(wei.techType))
                                                    {
                                                        if (Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                                        {
                                                            prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 1000;
                                                            techs[wei.techType]    = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                        else
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 1000;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (((techs[wei.techType].probability > prefabData.probability && prefabData.count >= techs[wei.techType].count) || (techs[wei.techType].probability >= prefabData.probability && prefabData.count > techs[wei.techType].count)) &&
                                                            prefabData.probability > 0 &&
                                                            prefabData.probability < 1 &&
                                                            prefabData.count > 0)
                                                        {
                                                            Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 1000;
                                                            techs[wei.techType] = prefabData;
                                                            customDSTDistribution[bio].prefabs.Add(prefabData);
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        foreach (LootDistributionData.PrefabData prefabData in __instance.dstDistribution[bio].prefabs)
                        {
                            WorldEntityInfo wei;
                            if (WorldEntityDatabase.TryGetInfo(prefabData.classId, out wei) && prefabData.probability > 0 && prefabData.probability < 1)
                            {
                                if (wei.techType != TechType.None)
                                {
                                    if (!Config.techProbability.ContainsKey(TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]))
                                    {
                                        Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] = prefabData.probability * 100;
                                        techs[wei.techType] = prefabData;
                                        customDSTDistribution[bio].prefabs.Add(prefabData);
                                        continue;
                                    }
                                    else
                                    {
                                        prefabData.probability = Config.techProbability[TechTypeExtensions.GetOrFallback(Language.main, wei.techType, wei.techType) + "| " + bio.AsString().Split('_')[0]] / 100;
                                        techs[wei.techType]    = prefabData;
                                        customDSTDistribution[bio].prefabs.Add(prefabData);
                                        continue;
                                    }
                                }
                                else
                                {
                                    customDSTDistribution[bio].prefabs.Add(prefabData);
                                    continue;
                                }
                            }
                            else
                            {
                                customDSTDistribution[bio].prefabs.Add(prefabData);
                            }
                        }
                    }
                }
                if (Config.RegenSpawns)
                {
                    Config.resetDefaults = false;
                    Config.RegenSpawns   = false;
                    IngameMenu.main.Open();
                    IngameMenu.main.ChangeSubscreen("Options");
                }
            }

            __result = customDSTDistribution.TryGetValue(biome, out data);
            return(!(__result));
        }
Exemplo n.º 12
0
        internal static IEnumerator PostPatchCoroutine()
        {
            foreach (TechType tt in new HashSet <TechType>()
            {
                TechType.Exosuit,
#if SUBNAUTICA_STABLE
                TechType.Seamoth,
                TechType.Cyclops,
#elif BELOWZERO
                TechType.SeaTruck,
                TechType.Hoverbike
#endif
            })
            {
                CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(tt);
                yield return(task);

                GameObject prefab = task.GetResult();
                if (prefab != null)
                {
                    LiveMixin mixin = prefab.GetComponent <LiveMixin>();
                    if (mixin?.data != null)
                    {
                        Main.defaultHealth.Add(tt, mixin.data.maxHealth);
                        Log.LogDebug($"For TechType {tt.AsString()}, got default health of {mixin.data.maxHealth}");
                    }
                    else
                    {
                        Log.LogDebug($"Failed to get LiveMixin for TechType {tt.AsString()}");
                    }
                }
                else
                {
                    Log.LogDebug($"Failed to get prefab for TechType {tt.AsString()}");
                }
            }

            foreach (TechType tt in new HashSet <TechType>()
            {
                TechType.DrillableAluminiumOxide,
                TechType.DrillableCopper,
                TechType.DrillableDiamond,
                TechType.DrillableGold,
                TechType.DrillableKyanite,
                TechType.DrillableLead,
                TechType.DrillableLithium,
                TechType.DrillableMagnetite,
                TechType.DrillableMercury,
                TechType.DrillableNickel,
                TechType.DrillableQuartz,
                TechType.DrillableSalt,
                TechType.DrillableSilver,
                TechType.DrillableSulphur,
                TechType.DrillableTitanium,
                TechType.DrillableUranium
            })
            {
                Log.LogInfo($"Fixing Cell Level for TechType {tt.AsString()}");
                var classid = CraftData.GetClassIdForTechType(tt);
                if (WorldEntityDatabase.TryGetInfo(classid, out var worldEntityInfo))
                {
                    worldEntityInfo.cellLevel = LargeWorldEntity.CellLevel.VeryFar;

                    WorldEntityDatabase.main.infos[classid] = worldEntityInfo;
                }

                CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(tt);
                yield return(task);

                GameObject prefab = task.GetResult();
                if (prefab != null)
                {
                    LargeWorldEntity lwe = prefab.GetComponent <LargeWorldEntity>();
                    if (lwe != null)
                    {
                        lwe.cellLevel = LargeWorldEntity.CellLevel.VeryFar;
                        Log.LogDebug($"CellLevel for TechType {tt.AsString()} updated to Far");
                    }
                    else
                    {
                        Log.LogWarning($"Could not find LargeWorldEntity component in prefab for TechType {tt.AsString()}");
                    }
#if SUBNAUTICA_STABLE
                    // Since we're here, make kyanite less troll-tastic.
                    Drillable drillable = prefab.GetComponent <Drillable>();
                    if (drillable != null && drillable.kChanceToSpawnResources < DWConstants.newKyaniteChance)
                    {
                        drillable.kChanceToSpawnResources = DWConstants.newKyaniteChance;
                    }
#endif
                }
                else
                {
                    Log.LogWarning($"Could not get prefab for TechType {tt.AsString()}");
                }
            }

            yield break;
        }