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;
                    }
                }
            }
        }
        internal static void PostPatch()
        {
            foreach (KeyValuePair <string, float> kvp in Main.config.BatteryValues)
            {
                TechType tt = TechTypeUtils.GetTechType(kvp.Key);
                if (tt == TechType.None)
                {
                    Log.LogError($"No valid TechType found for string '{kvp.Key}'");
                }
                else
                {
                    Log.LogDebug($"Loading TechType {tt} with customised battery capacity of {kvp.Value}");
                    //if (typedBatteryValues == null)
                    //	typedBatteryValues = new Dictionary<TechType, float>();

                    typedBatteryValues[tt] = kvp.Value;
                }
            }
        }
Beispiel #3
0
 public void PostPatch()
 {
     /* Enable the Storage Module. It's only useful for the Exosuit, but it still works, and it can turn the Exosuit's storage locker from "useless" to "useful", so I don't know why UWE disabled it.
      *
      * This block of code became unnecessary with the Seaworthy update, late Feb 2021, which re-enabled the Storage Module. The above comment has been retained for historical purposes.
      *
      * var storageModuleData = new RecipeData()
      * {
      *      craftAmount = 1,
      *      Ingredients = new List<Ingredient>()
      *              {
      *                      new Ingredient(TechType.Lithium, 1),
      *                      new Ingredient(TechType.Titanium, 1)
      *              }
      * };
      *
      * LanguageHandler.SetTechTypeName(TechType.VehicleStorageModule, "Vehicle Storage Module");
      * LanguageHandler.SetTechTypeTooltip(TechType.VehicleStorageModule, "A small storage locker. Expands Exosuit storage capacity.");
      * CraftDataHandler.SetTechData(TechType.VehicleStorageModule, storageModuleData);
      * CraftTreeHandler.AddCraftingNode(CraftTree.Type.SeamothUpgrades, TechType.VehicleStorageModule, new string[] { "ExosuitModules" });
      * CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, TechType.VehicleStorageModule, new string[] { "Upgrades", "ExosuitUpgrades" });
      * KnownTechHandler.SetAnalysisTechEntry(TechType.Exosuit, new TechType[] { TechType.VehicleStorageModule });*/
     foreach (string s in stringBlacklist)
     {
         TechType tt = TechTypeUtils.GetTechType(s);
         if (tt != TechType.None)
         {
             if (!StorageBlacklist.Contains(tt))
             {
                 StorageBlacklist.Add(tt);
             }
         }
         else
         {
             Logger.Log(Logger.Level.Debug, $"Could not find TechType for string '{s}' in blacklist. Is associated mod installed?");
         }
     }
 }
        /*public static DWStorageConfigNonSML LoadConfig(string LoadPath)
         * {
         *      DWStorageConfigNonSML config = new DWStorageConfigNonSML();
         *
         *      if (FileUtils.FileExists(LoadPath))
         *      {
         *              using (var reader = new StreamReader(LoadPath))
         *              {
         *                      var serializer = new JsonSerializer();
         *                      config = serializer.Deserialize(reader, typeof(DWStorageConfigNonSML)) as DWStorageConfigNonSML;
         *              }
         *      }
         *      return config;
         * }*/


        public void Init()
        {
            bool bUpdated = false;

            if (StorageSizes == null || StorageSizes.Count < 1)
            {
                StorageSizes = new Dictionary <string, Vector2int>(defaultStorageSizes, System.StringComparer.OrdinalIgnoreCase);
                bUpdated     = true;
            }

            /*if (LifepodLockerSize.x < 1 || LifepodLockerSize.y < 1)
             * {
             *      LifepodLockerSize = defaultLifepodLockerSize;
             *      bUpdated = true;
             * }
             *
             * if (ExosuitConfig.IsNull())
             * {
             *      ExosuitConfig = defaultExosuitConfig;
             *      bUpdated = true;
             * }
             *
             * if (BioreactorSize.x < 1 || BioreactorSize.y < 1)
             * {
             *      BioreactorSize = defaultBioReactorSize;
             *      bUpdated = true;
             * }
             *
             * if (InventorySize.x < 1 || InventorySize.y < 1)
             * {
             *      InventorySize = defaultInventorySize;
             *      bUpdated = true;
             * }*/

            // defaultLifepodLockerInventory is empty by default, so we actually want to act if it's not.
            if (defaultLifepodLockerInventory.Count > 0)
            {
                defaultLifepodLockerInventoryTypes.Clear();                 // Doesn't hurt to be sure.
                foreach (string s in defaultLifepodLockerInventory)
                {
                    TechType tt = TechTypeUtils.GetTechType(s);
                    if (tt != TechType.None)
                    {
                        defaultLifepodLockerInventoryTypes.Add(tt);
                    }
                    else
                    {
                        Log.LogWarning($"Could not parse string '{s}' as TechType in defaultLifepodLockerInventory");
                    }
                }
            }

            // Likewise for defaultBlueprintsToUnlock
            if (defaultBlueprintsToUnlock.Count > 0)
            {
                unlockedBlueprints.Clear();
                foreach (string s in defaultBlueprintsToUnlock)
                {
                    TechType tt = TechTypeUtils.GetTechType(s);
                    if (tt != TechType.None)
                    {
                        if (unlockedBlueprints.TryGetValue(tt, out int c))
                        {
                            c++;
                            Log.LogWarning($"Entry {s} in defaultBlueprintsToUnlock appears more than once; entry has been found {c} times so far");
                            unlockedBlueprints[tt] = c;
                        }
                        else
                        {
                            SMLHelper.V2.Handlers.KnownTechHandler.UnlockOnStart(tt);
                            unlockedBlueprints[tt] = 1;
                        }
                    }
                    else
                    {
                        Log.LogWarning($"Could not parse string {s} as TechType in defaultBlueprintsToUnlock");
                    }
                }
            }

            if (bUpdated)
            {
                Save();
            }
#if !RELEASE
            Log.LogDebug(bUpdated ? "Some values reset to defaults" : "All values present and correct");
#endif
        }
        public void Init()
        {
            bool bUpdated = false;

            if (bManualRefill)
            {
                Log.LogDebug($"Config.Init(): Adding tab node for oxygen tank refills");
                CraftTreeHandler.AddTabNode(CraftTree.Type.Fabricator, "TankRefill", "Tank Refills", SpriteManager.Get(TechType.DoubleTank), new string[] { "Personal" });
            }
            if (CapacityOverrides == null || CapacityOverrides.Count < 1)
            {
                CapacityOverrides = new Dictionary <string, float>();
                bUpdated          = true;
            }

            foreach (KeyValuePair <string, float> kvp in CapacityOverrides)
            {
                TechType tt = TechTypeUtils.GetTechType(kvp.Key);
                if (tt == TechType.None)
                {
#if !RELEASE
                    Logger.Log(Logger.Level.Debug, $"Failed to load TechType for string '{kvp.Key}'");
#endif
                    continue;
                }

                SetCapacityOverride(tt, kvp.Value, false, false, false);
            }

            if (manualCapacityOverrides == null || manualCapacityOverrides.Count < 1)
            {
                manualCapacityOverrides = new Dictionary <string, float>();
                bUpdated = true;
            }

            foreach (KeyValuePair <string, float> kvp in manualCapacityOverrides)
            {
                TechType tt = TechTypeUtils.GetTechType(kvp.Key);
                if (tt == TechType.None)
                {
#if !RELEASE
                    Logger.Log(Logger.Level.Debug, $"Failed to load TechType for string '{kvp.Key}'");
#endif
                    continue;
                }

                SetCapacityOverride(tt, kvp.Value, false, false, true);
            }

            if (bUpdated)
            {
                Save();
#if !RELEASE
                Logger.Log(Logger.Level.Debug, "Some values reset to defaults");
#endif
            }
            else
            {
#if !RELEASE
                Logger.Log(Logger.Level.Debug, "All values present and correct");
#endif
            }
        }