Decompiled source of MarsarahTweaks v1.0.1
MarsarahTweaks.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using MarsarahTweaks.Patches.Features; using MarsarahTweaks.Patches.Grind; using MarsarahTweaks.Patches.QOL; using MarsarahTweaks.Patches.UI; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("MarsarahTweaks")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MarsarahTweaks")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("831fc141-e3fa-4e67-9d2f-5e56cf6f3935")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace MarsarahTweaks { public static class ConfigManager { public static class ConfigSections { public const string Main = "1 - Main"; public const string GrindReduction = "2 - Grind Reduction (Synced with Server)"; public const string Features = "3 - Features (Synced with Server)"; public const string QOL = "4 - QOL (Synced with Server)"; public const string UI = "5 - UI (Synced with Server)"; } public struct ConfigMetadata { public string Name; public string Description; public ConfigMetadata(string name, string description) { Name = name; Description = description; } } public static class Configs { public static readonly ConfigMetadata ServerConfig = new ConfigMetadata("Lock Configuration", "If on, only server admins can change the configuration."); public static readonly ConfigMetadata DoubleBronzeCrafting = new ConfigMetadata("1 - Double Bronze Crafting", "Doubles the amount of crafted Bronze at the Forge"); public static readonly ConfigMetadata GearRecipeAmountsModifications = new ConfigMetadata("2 - Cheaper Gear Recipe Amounts", "Reduces costs for crafting and upgrading gear for metal. Balances other resources amounts"); public static readonly ConfigMetadata GearRecipeMaterialsModifications = new ConfigMetadata("3 - Alternate Gear Recipe Materials", "Modifies gear recipe materials for some items (more materials from current respective biomes)"); public static readonly ConfigMetadata BuildPieceAmountsModifications = new ConfigMetadata("4 - Cheaper Build Pieces Amounts", "Reduces costs for build pieces"); public static readonly ConfigMetadata BuildPieceMaterialsModifications = new ConfigMetadata("5 - Alternate Build Pieces Materials", "Modifies build pieces materials (This will move the Workbench Toolrack extension from Mountain to Swamp biome)"); public static readonly ConfigMetadata FoodAndMeadModifications = new ConfigMetadata("6 - Food And Mead Modifications", "Modifies food and mead recipes costs, crafted amounts and stacks. (Toggling mid-game requires CLIENT relog for food stacks)"); public static readonly ConfigMetadata LinenCapeModifications = new ConfigMetadata("01 - Early Linen Cape", "Renames the Linen Cape to Fine Cape, moves it to the Swamp biome, and adds poison resist to it. (Toggling mid-game requires CLIENT relog if the item is equipped)"); public static readonly ConfigMetadata GearSpeedModifications = new ConfigMetadata("02 - Gear Speed Modifications", "Removes speed penalty for heavy and mage armors; adds speed bonus to light armor. (Toggling mid-game requires CLIENT relog)"); public static readonly ConfigMetadata ForsakenPowersModifications = new ConfigMetadata("03 - Forsaken Powers Modifications", "Reduce Forsaken Powers cooldowns and increase durations (different for each power)"); public static readonly ConfigMetadata CharacterSpeedModifications = new ConfigMetadata("04 - Faster Character Speed", "Faster character jog, walk, swim and crouch speeds (run excluded)"); public static readonly ConfigMetadata StatusEffectsModifications = new ConfigMetadata("05 - Shorter Wet And Potion Cooldowns", "Wet effect and potions cooldown timers reduced"); public static readonly ConfigMetadata LessStaminaModifications = new ConfigMetadata("06 - Less Stamina Usage", "Stamina use of all actions is reduced by 15%"); public static readonly ConfigMetadata ExtraArmorStatsModifications = new ConfigMetadata("07 - Extra Armor Stats", "Heavy armor provides extra HP, light armor provides extra stamina, mage armor provides extra eitr"); public static readonly ConfigMetadata DeathRaiserModifications = new ConfigMetadata("08 - Better Death Raiser", "Adds a secondary attack that spawns archer skeletons. Primary attack will only spawn melee skeletons"); public static readonly ConfigMetadata DeathRaiserSummonsModifications = new ConfigMetadata("09 - Better Summoned Skeletons", "Increases summoned skeleton speed and add better looking gear according to Death Raiser level (stats not affected). (Toggling mid-game requires CLIENT relog for speed changes)"); public static readonly ConfigMetadata FrostStaffModifications = new ConfigMetadata("10 - Better Frost Staff Accuracy", "Improves Staff of Frost Accuracy"); public static readonly ConfigMetadata CrossbowsReloadModifications = new ConfigMetadata("11 - Reduced Crossbows Reload Time", "Crossbows Reload Time Reduced by 1s. (Toggling mid-game requires CLIENT relog)"); public static readonly ConfigMetadata AshlandsEnemiesModifications = new ConfigMetadata("12 - Less Ashlands Enemies", "Numbers and spawn chance reduced for Ashlands enemies. (Toggling mid-game requires reloading area)"); public static readonly ConfigMetadata GearUpgradeModifications = new ConfigMetadata("13 - Gear Upgrade Unlock", "Gear from Meadows, Black Forest, Mistlands and Ashlands can be upgraded to max level within their respective biomes"); public static readonly ConfigMetadata PermanentLightsModifications = new ConfigMetadata("14 - Permanent Lights", "Makes all light sources permanent, but the build costs of light source pieces use maximum amount of their respective fuel type"); public static readonly ConfigMetadata ClearMistlands = new ConfigMetadata("15 - Clear Mistlands", "Clear Mistlands mist after defeating the Queen. (Disabling mid-game requires CLIENT relog)"); public static readonly ConfigMetadata CraftableChain = new ConfigMetadata("16 - Craftable Chain", "Chain craftable at Black Forge"); public static readonly ConfigMetadata BrighterLanterns = new ConfigMetadata("17 - Brighter Lanterns", "Dvergr lanterns are brighter. (Toggling mid-game requires CLIENT relog or reloading area)"); public static readonly ConfigMetadata WeatherModifications = new ConfigMetadata("18 - Clearer Weather", "Reduces chance for mist and snowstorms in Meadows, Plains, Ocean and Mountains respectively. (Toggling mid-game requires CLIENT relog)"); public static readonly ConfigMetadata CreatureUnleveler = new ConfigMetadata("19 - Creature Unleveler By Boss", "Increases chance of creatures to spawn with a star or two after defeating their relevant biome boss"); public static readonly ConfigMetadata MinibossWeight = new ConfigMetadata("20 - Hildir Weight Rewards", "Increases base carry weight by 25 when turning in Hildir chests (for each chest). (Toggling mid-game requires CLIENT relog)"); public static readonly ConfigMetadata ExtensionsModifications = new ConfigMetadata("21 - Station Extensions Changes", "Decreases space requirement for workstation extensions and increases build distance to workstations (This does not increase workstation radius)"); public static readonly ConfigMetadata FleeAIModifications = new ConfigMetadata("22 - Stop Running Away", "Boars and Necks won't flee when alerted. (Toggling mid-game only affects new creatures)"); public static readonly ConfigMetadata ProgressionHalt = new ConfigMetadata("23 - Automatic Progression Halt", "Creatures and objects do not drop any items unless the previous biome boss has been defeated. (Toggling mid-game requires CLIENT relog or reloading area)"); public static readonly ConfigMetadata TrophyDropsModifications = new ConfigMetadata("24 - Better Trophy Drop Rates", "Increases trophy drop rate for the following creatures: Rancid Remains, Surtling, Draugr Elite, Wraith, Cultist, Fenring, Stone Golem, Deathsquito, Fuling Berserker, Tick, Dverger, Seeker Soldier, Charred Warlock"); public static readonly ConfigMetadata TougherShips = new ConfigMetadata("25 - Tougher Ships", "Increases Ships HP. Raft: 300 -> 400, Karve: 500 -> 650, Longship: 1000 -> 1250, Drakkar: 3000 -> 4000 (Toggling mid-game requires CLIENT relog or reloading area)"); public static readonly ConfigMetadata OtherModifications = new ConfigMetadata("26 - Other Section", "Tankard costs reduced and Iron Nails crafting output doubled"); public static readonly ConfigMetadata LighterMetalWeight = new ConfigMetadata("1 - Lighter Metal Weight", "All metal ore and bars weight decreased to 8. (Toggling mid-game requires CLIENT relog or reloading area)"); public static readonly ConfigMetadata LargerPickupArea = new ConfigMetadata("2 - Larger Pickup Area", "Item pickup area slightly increased"); public static readonly ConfigMetadata NoSkillLoss = new ConfigMetadata("3 - No Skill Levels Loss On Death", "Skills won't go down the current level upon death (progress in that skill is still lost). (Toggling mid-game requires CLIENT relog)"); public static readonly ConfigMetadata LargerBoatExploreRadius = new ConfigMetadata("4 - Larger Boat Explore Radius", "Double explore radius on a boat"); public static readonly ConfigMetadata BiggerWispRadius = new ConfigMetadata("5 - Bigger Wisp Radius", "Increases wisp radius"); public static readonly ConfigMetadata FriendlyBallistas = new ConfigMetadata("6 - Friendly Ballistas", "Ballistas won't target players and tame animals"); public static readonly ConfigMetadata LessFallDamage = new ConfigMetadata("7 - Less Fall Damage", "Fall damage reduced by 40%"); public static readonly ConfigMetadata FasterResourceDrops = new ConfigMetadata("8 - Faster Resource Drops", "Enemies drop resources faster when dying"); public static readonly ConfigMetadata FasterEquip = new ConfigMetadata("9 - Faster Equip", "Equipping weapons is instant. Armor equip timers reduced to 1s (from 1s/2s). (Toggling mid-game requires CLIENT relog)"); public static readonly ConfigMetadata UIMoreLoadingTips = new ConfigMetadata("01 - More Loading Tips", "More loading screen tips"); public static readonly ConfigMetadata UIInventoryWeightAndSlots = new ConfigMetadata("02 - Show Inventory Weight and Free Slots", "Shows inventory weight and free slots on the bottom left of the screen"); public static readonly ConfigMetadata UIEnemyDetector = new ConfigMetadata("03 - Show Enemy Detector", "Shows enemy detector on the bottom left of the screen"); public static readonly ConfigMetadata UIBoatSpeed = new ConfigMetadata("04 - Show Boat Speed", "Shows boat speed when using a boat on the bottom left of the screen"); public static readonly ConfigMetadata UITimeAndDay = new ConfigMetadata("05 - Show Time And Day", "Shows time and day above the minimap"); public static readonly ConfigMetadata UITimeAndDay24H = new ConfigMetadata("06 - Time - 24 Hour Format", "Use 24 Hour time format when Show Time And Day is enabled"); public static readonly ConfigMetadata UISmartBiome = new ConfigMetadata("07 - Smart Biome Indicator", "Shows smart biome text on minimap (colored according to worn armor relative to current biome)"); public static readonly ConfigMetadata UISummonCounter = new ConfigMetadata("08 - Show Summon Counter", "Shows number of summoned skeletons from the Dead Raiser"); public static readonly ConfigMetadata UIOnlinePlayers = new ConfigMetadata("09 - Show Online Players", "Shows online players on the bottom right of the screen (Not displayed if only one player is online)"); public static readonly ConfigMetadata UIOnlinePlayersUnderMinimap = new ConfigMetadata("10 - Show Online Players Under Minimap", "Shows online players under minimap instead of bottom right when Show Online Players is enabled"); } private static ConfigFile Config; private static readonly ConfigSync configSync = new ConfigSync("Marsarah.MarsarahTweaks") { DisplayName = "MarsarahTweaks", CurrentVersion = "1.0.1", MinimumRequiredVersion = "1.0.1" }; public static ConfigEntry<bool> ServerConfigLocked; public static ConfigEntry<bool> DoubleBronzeEnabled; public static ConfigEntry<bool> GearRecipeAmountsEnabled; public static ConfigEntry<bool> GearRecipeMaterialsEnabled; public static ConfigEntry<bool> BuildPieceAmountsEnabled; public static ConfigEntry<bool> BuildPieceMaterialsEnabled; public static ConfigEntry<bool> FoodAndMeadModificationsEnabled; public static ConfigEntry<bool> EarlyLinenCapeEnabled; public static ConfigEntry<bool> GearSpeedModifiersEnabled; public static ConfigEntry<bool> LongerForsakenPowersEnabled; public static ConfigEntry<bool> FasterCharacterSpeedEnabled; public static ConfigEntry<bool> ShorterStatusEffectsEnabled; public static ConfigEntry<bool> LessStaminaUsageEnabled; public static ConfigEntry<bool> ExtraArmorStatsEnabled; public static ConfigEntry<bool> BetterDeathRaiserEnabled; public static ConfigEntry<bool> BetterDeathRaiserSummonsEnabled; public static ConfigEntry<bool> BetterFrostStaffAccuracyEnabled; public static ConfigEntry<bool> ReducedCrossbowsReloadTimeEnabled; public static ConfigEntry<bool> LessAshlandsEnemiesEnabled; public static ConfigEntry<bool> GearUpgradeUnlockEnabled; public static ConfigEntry<bool> PermanentLightsEnabled; public static ConfigEntry<bool> ClearMistlandsEnabled; public static ConfigEntry<bool> CraftableChainEnabled; public static ConfigEntry<bool> BrighterLanternsEnabled; public static ConfigEntry<bool> ClearerWeatherEnabled; public static ConfigEntry<bool> CreatureUnlevelerEnabled; public static ConfigEntry<bool> MinibossWeightEnabled; public static ConfigEntry<bool> ExtensionsChangesEnabled; public static ConfigEntry<bool> NoFleeEnabled; public static ConfigEntry<bool> AutomaticProgressionHaltEnabled; public static ConfigEntry<bool> BetterTrophyDropsEnabled; public static ConfigEntry<bool> TougherShipsEnabled; public static ConfigEntry<bool> OtherEnabled; public static ConfigEntry<bool> LighterMetalWeightEnabled; public static ConfigEntry<bool> LargerPickupAreaEnabled; public static ConfigEntry<bool> NoSkillLowerOnDeathEnabled; public static ConfigEntry<bool> LargerBoatExploreRadiusEnabled; public static ConfigEntry<bool> BiggerWispRadiusEnabled; public static ConfigEntry<bool> FriendlyBallistasEnabled; public static ConfigEntry<bool> LessFallDamageEnabled; public static ConfigEntry<bool> FasterResourceDropsEnabled; public static ConfigEntry<bool> FasterEquipEnabled; public static ConfigEntry<bool> MoreLoadingTipsEnabled; public static ConfigEntry<bool> ShowInventoryWeightAndSlots; public static ConfigEntry<bool> ShowEnemyDetector; public static ConfigEntry<bool> ShowBoatSpeed; public static ConfigEntry<bool> ShowTimeAndDay; public static ConfigEntry<bool> TimeFormat24H; public static ConfigEntry<bool> ShowSmartBiome; public static ConfigEntry<bool> ShowSummonCounter; public static ConfigEntry<bool> ShowOnlinePlayers; public static ConfigEntry<bool> OnlinePlayersUnderMinimap; private static string ConfigFileName => "Marsarah.MarsarahTweaks.cfg"; private static string ConfigFileFullPath { get { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; return configPath + directorySeparatorChar + ConfigFileName; } } public static void Init(ConfigFile configFile) { Config = configFile; ServerConfigLocked = CreateConfig("1 - Main", Configs.ServerConfig.Name, defaultValue: true, Configs.ServerConfig.Description); configSync.AddLockingConfigEntry<bool>(ServerConfigLocked); DoubleBronzeEnabled = CreateConfig("2 - Grind Reduction (Synced with Server)", Configs.DoubleBronzeCrafting.Name, defaultValue: true, Configs.DoubleBronzeCrafting.Description); GearRecipeAmountsEnabled = CreateConfig("2 - Grind Reduction (Synced with Server)", Configs.GearRecipeAmountsModifications.Name, defaultValue: true, Configs.GearRecipeAmountsModifications.Description); GearRecipeMaterialsEnabled = CreateConfig("2 - Grind Reduction (Synced with Server)", Configs.GearRecipeMaterialsModifications.Name, defaultValue: true, Configs.GearRecipeMaterialsModifications.Description); BuildPieceAmountsEnabled = CreateConfig("2 - Grind Reduction (Synced with Server)", Configs.BuildPieceAmountsModifications.Name, defaultValue: true, Configs.BuildPieceAmountsModifications.Description); BuildPieceMaterialsEnabled = CreateConfig("2 - Grind Reduction (Synced with Server)", Configs.BuildPieceMaterialsModifications.Name, defaultValue: true, Configs.BuildPieceMaterialsModifications.Description); FoodAndMeadModificationsEnabled = CreateConfig("2 - Grind Reduction (Synced with Server)", Configs.FoodAndMeadModifications.Name, defaultValue: true, Configs.FoodAndMeadModifications.Description); EarlyLinenCapeEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.LinenCapeModifications.Name, defaultValue: true, Configs.LinenCapeModifications.Description); GearSpeedModifiersEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.GearSpeedModifications.Name, defaultValue: true, Configs.GearSpeedModifications.Description); LongerForsakenPowersEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.ForsakenPowersModifications.Name, defaultValue: true, Configs.ForsakenPowersModifications.Description); FasterCharacterSpeedEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.CharacterSpeedModifications.Name, defaultValue: true, Configs.CharacterSpeedModifications.Description); ShorterStatusEffectsEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.StatusEffectsModifications.Name, defaultValue: true, Configs.StatusEffectsModifications.Description); LessStaminaUsageEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.LessStaminaModifications.Name, defaultValue: true, Configs.LessStaminaModifications.Description); ExtraArmorStatsEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.ExtraArmorStatsModifications.Name, defaultValue: true, Configs.ExtraArmorStatsModifications.Description); BetterDeathRaiserEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.DeathRaiserModifications.Name, defaultValue: true, Configs.DeathRaiserModifications.Description); BetterDeathRaiserSummonsEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.DeathRaiserSummonsModifications.Name, defaultValue: true, Configs.DeathRaiserSummonsModifications.Description); BetterFrostStaffAccuracyEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.FrostStaffModifications.Name, defaultValue: true, Configs.FrostStaffModifications.Description); ReducedCrossbowsReloadTimeEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.CrossbowsReloadModifications.Name, defaultValue: true, Configs.CrossbowsReloadModifications.Description); LessAshlandsEnemiesEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.AshlandsEnemiesModifications.Name, defaultValue: true, Configs.AshlandsEnemiesModifications.Description); GearUpgradeUnlockEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.GearUpgradeModifications.Name, defaultValue: true, Configs.GearUpgradeModifications.Description); PermanentLightsEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.PermanentLightsModifications.Name, defaultValue: true, Configs.PermanentLightsModifications.Description); ClearMistlandsEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.ClearMistlands.Name, defaultValue: true, Configs.ClearMistlands.Description); CraftableChainEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.CraftableChain.Name, defaultValue: true, Configs.CraftableChain.Description); BrighterLanternsEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.BrighterLanterns.Name, defaultValue: true, Configs.BrighterLanterns.Description); ClearerWeatherEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.WeatherModifications.Name, defaultValue: true, Configs.WeatherModifications.Description); CreatureUnlevelerEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.CreatureUnleveler.Name, defaultValue: true, Configs.CreatureUnleveler.Description); MinibossWeightEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.MinibossWeight.Name, defaultValue: true, Configs.MinibossWeight.Description); ExtensionsChangesEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.ExtensionsModifications.Name, defaultValue: true, Configs.ExtensionsModifications.Description); NoFleeEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.FleeAIModifications.Name, defaultValue: true, Configs.FleeAIModifications.Description); AutomaticProgressionHaltEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.ProgressionHalt.Name, defaultValue: true, Configs.ProgressionHalt.Description); BetterTrophyDropsEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.TrophyDropsModifications.Name, defaultValue: true, Configs.TrophyDropsModifications.Description); TougherShipsEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.TougherShips.Name, defaultValue: true, Configs.TougherShips.Description); OtherEnabled = CreateConfig("3 - Features (Synced with Server)", Configs.OtherModifications.Name, defaultValue: true, Configs.OtherModifications.Description); LighterMetalWeightEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.LighterMetalWeight.Name, defaultValue: true, Configs.LighterMetalWeight.Description); LargerPickupAreaEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.LargerPickupArea.Name, defaultValue: true, Configs.LargerPickupArea.Description); NoSkillLowerOnDeathEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.NoSkillLoss.Name, defaultValue: true, Configs.NoSkillLoss.Description); LargerBoatExploreRadiusEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.LargerBoatExploreRadius.Name, defaultValue: true, Configs.LargerBoatExploreRadius.Description); BiggerWispRadiusEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.BiggerWispRadius.Name, defaultValue: true, Configs.BiggerWispRadius.Description); FriendlyBallistasEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.FriendlyBallistas.Name, defaultValue: true, Configs.FriendlyBallistas.Description); LessFallDamageEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.LessFallDamage.Name, defaultValue: true, Configs.LessFallDamage.Description); FasterResourceDropsEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.FasterResourceDrops.Name, defaultValue: true, Configs.FasterResourceDrops.Description); FasterEquipEnabled = CreateConfig("4 - QOL (Synced with Server)", Configs.FasterEquip.Name, defaultValue: true, Configs.FasterEquip.Description); MoreLoadingTipsEnabled = CreateConfig("5 - UI (Synced with Server)", Configs.UIMoreLoadingTips.Name, defaultValue: true, Configs.UIMoreLoadingTips.Description); ShowInventoryWeightAndSlots = CreateConfig("5 - UI (Synced with Server)", Configs.UIInventoryWeightAndSlots.Name, defaultValue: true, Configs.UIInventoryWeightAndSlots.Description); ShowEnemyDetector = CreateConfig("5 - UI (Synced with Server)", Configs.UIEnemyDetector.Name, defaultValue: true, Configs.UIEnemyDetector.Description); ShowBoatSpeed = CreateConfig("5 - UI (Synced with Server)", Configs.UIBoatSpeed.Name, defaultValue: true, Configs.UIBoatSpeed.Description); ShowTimeAndDay = CreateConfig("5 - UI (Synced with Server)", Configs.UITimeAndDay.Name, defaultValue: true, Configs.UITimeAndDay.Description); TimeFormat24H = CreateConfig("5 - UI (Synced with Server)", Configs.UITimeAndDay24H.Name, defaultValue: false, Configs.UITimeAndDay24H.Description); ShowSmartBiome = CreateConfig("5 - UI (Synced with Server)", Configs.UISmartBiome.Name, defaultValue: true, Configs.UISmartBiome.Description); ShowSummonCounter = CreateConfig("5 - UI (Synced with Server)", Configs.UISummonCounter.Name, defaultValue: true, Configs.UISummonCounter.Description); ShowOnlinePlayers = CreateConfig("5 - UI (Synced with Server)", Configs.UIOnlinePlayers.Name, defaultValue: true, Configs.UIOnlinePlayers.Description); OnlinePlayersUnderMinimap = CreateConfig("5 - UI (Synced with Server)", Configs.UIOnlinePlayersUnderMinimap.Name, defaultValue: true, Configs.UIOnlinePlayersUnderMinimap.Description); SetupWatcher(); } private static ConfigEntry<T> CreateConfig<T>(string group, string name, T defaultValue, string description, bool synchronizedSetting = true) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown ConfigEntry<T> val = Config.Bind<T>(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; val.SettingChanged += delegate { OnConfigChanged(name); }; return val; } private static void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName) { IncludeSubdirectories = true, SynchronizingObject = ThreadingHelper.SynchronizingObject, EnableRaisingEvents = true }; fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; } private static void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { Config.Reload(); } catch { MarsarahTweaks.MLog("There was an issue loading " + ConfigFileName); } } private static void OnConfigChanged(string configName) { Config.Save(); if ((Object)(object)ObjectDB.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null || (Object)(object)ZNet.instance == (Object)null) { return; } if (!ZNet.instance.IsDedicated()) { if (configName == Configs.DoubleBronzeCrafting.Name) { DoubleBronzeCrafting.UpdateDoubleBronzeCrafting(ObjectDB.instance, wasChanged: true); } else { string text = configName; if (text == Configs.GearRecipeAmountsModifications.Name) { GearRecipeChanges.UpdateGearRecipes(ObjectDB.instance, amountsWasChanged: true, materialsWasChanged: false); } else { string text2 = configName; if (text2 == Configs.GearRecipeMaterialsModifications.Name) { GearRecipeChanges.UpdateGearRecipes(ObjectDB.instance, amountsWasChanged: false, materialsWasChanged: true); } else { string text3 = configName; if (text3 == Configs.BuildPieceAmountsModifications.Name) { BuildPieceChanges.UpdateBuildPieces(ZNetScene.instance, amountsWasChanged: true, materialsWasChanged: false); } else { string text4 = configName; if (text4 == Configs.BuildPieceMaterialsModifications.Name) { BuildPieceChanges.UpdateBuildPieces(ZNetScene.instance, amountsWasChanged: false, materialsWasChanged: true); } else { string text5 = configName; if (text5 == Configs.FoodAndMeadModifications.Name) { FoodAndMeadChanges.UpdateFoodAndMead(ObjectDB.instance, wasModified: true); } else { string text6 = configName; if (text6 == Configs.LinenCapeModifications.Name) { GearRecipeChanges.UpdateLinenCapeRecipe(ObjectDB.instance, wasChanged: true); EarlyLinenCape.UpdateLinenCapeStats(wasChanged: true); } else { string text7 = configName; if (text7 == Configs.GearSpeedModifications.Name) { GearSpeedChanges.UpdateGearSpeed(ObjectDB.instance, wasChanged: true); } else { string text8 = configName; if (text8 == Configs.ForsakenPowersModifications.Name) { ForsakenPowersChanges.UpdateForsakenPowers(ObjectDB.instance, wasChanged: true); } else { string text9 = configName; if (text9 == Configs.CharacterSpeedModifications.Name) { if ((Object)(object)Player.m_localPlayer != (Object)null) { CharacterSpeedChanges.UpdateCharacterSpeed((Character)(object)Player.m_localPlayer, wasChanged: true); } } else { string text10 = configName; if (text10 == Configs.StatusEffectsModifications.Name) { StatusEffectChanges.UpdateStatusEffects(ObjectDB.instance, wasChanged: true); } else { string text11 = configName; if (text11 == Configs.GearUpgradeModifications.Name) { GearUpgradeChanges.UpdateGearRecipeUnlock(ObjectDB.instance, wasChanged: true); if (ShowSmartBiome.Value) { UISmartBiome.UpdateBiomeWeights(); } } else { string text12 = configName; if (text12 == Configs.PermanentLightsModifications.Name) { PermanentLightsChanges.UpdateLightBuildPiecesAmounts(ZNetScene.instance, wasChanged: true); } else { string text13 = configName; if (text13 == Configs.CraftableChain.Name) { CraftableChain.UpdateChainRecipe(ObjectDB.instance, wasChanged: true); } else { string text14 = configName; if (text14 == Configs.BrighterLanterns.Name) { BrighterLanterns.UpdateLanterns(ZNetScene.instance); } else { string text15 = configName; if (text15 == Configs.TougherShips.Name) { TougherShipsChanges.UpdateShipHP(ZNetScene.instance, wasChanged: true); } else { string text16 = configName; if (text16 == Configs.OtherModifications.Name) { OtherChanges.UpdateOthers(ObjectDB.instance, wasChanged: true); } else { string text17 = configName; if (text17 == Configs.LighterMetalWeight.Name) { LighterMetalWeight.UpdateLighterMetalWeight(ObjectDB.instance, wasChanged: true); } else { string text18 = configName; if (text18 == Configs.LargerPickupArea.Name) { if ((Object)(object)Player.m_localPlayer != (Object)null) { LargerPickupAreaChanges.UpdatePickupArea(Player.m_localPlayer, wasChanged: true); } } else { string text19 = configName; if (text19 == Configs.UIInventoryWeightAndSlots.Name) { UIController.UpdateUIPositions(); } else { string text20 = configName; if (text20 == Configs.UIEnemyDetector.Name) { UIController.UpdateUIPositions(); } else { string text21 = configName; if (text21 == Configs.UIBoatSpeed.Name) { UIController.UpdateUIPositions(); } else { string text22 = configName; if (text22 == Configs.UISmartBiome.Name) { UISmartBiome.UpdateBiomeWeights(); } } } } } } } } } } } } } } } } } } } } } } } } if (configName == Configs.AshlandsEnemiesModifications.Name) { SpawnSystem val = Object.FindObjectOfType<SpawnSystem>(); if (val != null) { AshlandsEnemiesChanges.UpdateAshlandsSpawns(val); } return; } string text23 = configName; if (text23 == Configs.CreatureUnleveler.Name) { SpawnSystem val2 = Object.FindObjectOfType<SpawnSystem>(); if (val2 != null) { CreatureUnleveler.ApplyCreatureLevelChanges(val2); } } } } [BepInPlugin("Marsarah.MarsarahTweaks", "MarsarahTweaks", "1.0.1")] public class MarsarahTweaks : BaseUnityPlugin { internal const string ModName = "MarsarahTweaks"; internal const string ModVersion = "1.0.1"; internal const string Author = "Marsarah"; public const string ModGUID = "Marsarah.MarsarahTweaks"; private static readonly bool showLogs; private readonly Harmony harmony = new Harmony("Marsarah.MarsarahTweaks"); private void Awake() { ConfigManager.Init(((BaseUnityPlugin)this).Config); UISmartBiome.UpdateBiomeWeights(); harmony.PatchAll(); } private void Update() { UIController.UpdateUIDisplay(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } public static void MLog(string log, bool header = false, bool footer = false) { if (showLogs) { if (header) { Debug.Log((object)"==================================================="); } Debug.Log((object)("[Marsarah Tweaks] : " + log)); if (footer) { Debug.Log((object)"==================================================="); } } } } } namespace MarsarahTweaks.Patches { public static class GlobalKeyChecker { [HarmonyPatch(typeof(ZoneSystem), "Update")] private class BossStatusUpdate_Patch { private static void Postfix(ZoneSystem __instance) { UpdateDefeatedStates(__instance); EikthyrDefeated = CheckGlobalKey("defeated_eikthyr"); ElderDefeated = CheckGlobalKey("defeated_gdking"); BonemassDefeated = CheckGlobalKey("defeated_bonemass"); ModerDefeated = CheckGlobalKey("defeated_dragon"); YagluthDefeated = CheckGlobalKey("defeated_goblinking"); QueenDefeated = CheckGlobalKey("defeated_queen"); FaderDefeated = CheckGlobalKey("defeated_fader"); BrennaDefeated = CheckGlobalKey("hildir1"); GeirrhafaDefeated = CheckGlobalKey("hildir2"); ThungrNZilDefeated = CheckGlobalKey("hildir3"); } } public static bool EikthyrDefeated = false; public static bool ElderDefeated = false; public static bool BonemassDefeated = false; public static bool ModerDefeated = false; public static bool YagluthDefeated = false; public static bool QueenDefeated = false; public static bool FaderDefeated = false; public static bool BrennaDefeated = false; public static bool GeirrhafaDefeated = false; public static bool ThungrNZilDefeated = false; private static readonly Dictionary<string, bool> globalKeyStates = new Dictionary<string, bool> { { "defeated_eikthyr", false }, { "defeated_gdking", false }, { "defeated_bonemass", false }, { "defeated_dragon", false }, { "defeated_goblinking", false }, { "defeated_queen", false }, { "defeated_fader", false }, { "hildir1", false }, { "hildir2", false }, { "hildir3", false } }; private static readonly Dictionary<string, string> bossToGlobalKey = new Dictionary<string, string> { { "Eikthyr", "defeated_eikthyr" }, { "The Elder", "defeated_gdking" }, { "Bonemass", "defeated_bonemass" }, { "Moder", "defeated_dragon" }, { "Yagluth", "defeated_goblinking" }, { "The Queen", "defeated_queen" }, { "Fader", "defeated_fader" }, { "Brenna", "hildir1" }, { "Geirrhafa", "hildir2" }, { "ThungrNZil", "hildir3" } }; private static void UpdateDefeatedStates(ZoneSystem zoneSystem) { List<string> globalKeys = zoneSystem.GetGlobalKeys(); foreach (string item in globalKeyStates.Keys.ToList()) { bool flag = globalKeys.Contains(item); if (globalKeyStates[item] != flag) { globalKeyStates[item] = flag; } } } private static bool CheckGlobalKey(string globalKey) { return globalKeyStates.ContainsKey(globalKey) && globalKeyStates[globalKey]; } public static bool IsBossDefeated(string boss) { if (bossToGlobalKey.TryGetValue(boss, out var value)) { return CheckGlobalKey(value); } MarsarahTweaks.MLog("[Warning] IsBossDefeated called with unknown boss: " + boss); return false; } } } namespace MarsarahTweaks.Patches.UI { internal class UIBoatSpeed : UIController { [HarmonyPatch(typeof(Ship), "GetSpeed")] private class ShowBoatSpeed_Patch { private static void Prefix(Ship __instance, ref Rigidbody ___m_body) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && ConfigManager.ShowBoatSpeed.Value) { if (Object.op_Implicit((Object)(object)__instance) && __instance.HasPlayerOnboard()) { boatSpeed = Vector3.Dot(___m_body.velocity, ((Component)__instance).transform.forward); } if (Traverse.Create((object)__instance).Method("HaveControllingPlayer", Array.Empty<object>()).GetValue<bool>()) { showBoatSpeedUI = true; } else { showBoatSpeedUI = false; } } } } [HarmonyPatch(typeof(Hud), "Update")] private static class BoatSpeedHUDUpdate_Patch { private static void Postfix(Hud __instance) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null) { return; } if (ConfigManager.ShowBoatSpeed.Value) { CreateUI(__instance); ((Behaviour)UIBoatText).enabled = showBoatSpeedUI && UIController.showUI; ((Behaviour)UIBoatTextTitle).enabled = showBoatSpeedUI && UIController.showUI; ((Behaviour)boatAreaBackground).enabled = showBoatSpeedUI && UIController.showUI; if (showBoatSpeedUI && UIController.showUI) { ((Graphic)UIBoatText).color = GetColorFromSpeed(boatSpeed); UIBoatTextTitle.text = "Boat speed"; UIBoatText.text = ((boatSpeed > 0f) ? ("F " + boatSpeed.ToString("0.00")) : ("R " + Math.Abs(boatSpeed).ToString("0.00"))); } } else { if ((Object)(object)UIBoatText != (Object)null) { ((Behaviour)UIBoatText).enabled = false; } if ((Object)(object)UIBoatTextTitle != (Object)null) { ((Behaviour)UIBoatTextTitle).enabled = false; } if ((Object)(object)boatAreaBackground != (Object)null) { ((Behaviour)boatAreaBackground).enabled = false; } } } private static void CreateUI(Hud hud) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)UIBoatText != (Object)null) || !((Object)(object)UIBoatTextTitle != (Object)null) || !((Object)(object)boatAreaBackground != (Object)null)) { int fontSize = 16; string fontName = "AveriaSansLibre-Bold"; Vector2 sizeDelta = default(Vector2); ((Vector2)(ref sizeDelta))..ctor(155f, 30f); UIBoatArea = new GameObject("BoatArea"); UIBoatArea.layer = 5; UIBoatArea.transform.SetParent(((Component)hud.m_healthPanel).transform); RectTransform val = UIBoatArea.AddComponent<RectTransform>(); val.anchorMin = new Vector2(1f, 1f); val.anchorMax = new Vector2(1f, 1f); val.anchoredPosition = new Vector2((ConfigManager.ShowInventoryWeightAndSlots.Value && ConfigManager.ShowEnemyDetector.Value) ? 203f : ((ConfigManager.ShowInventoryWeightAndSlots.Value || ConfigManager.ShowEnemyDetector.Value) ? 100f : (-40f)), -230f); val.sizeDelta = sizeDelta; UIBoatArea.transform.localScale = Vector3.one; Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground")); boatAreaBackground = UIBoatArea.AddComponent<Image>(); ((Graphic)boatAreaBackground).color = new Color(0f, 0f, 0f, 0.4f); boatAreaBackground.sprite = sprite; boatAreaBackground.type = (Type)1; ((Behaviour)boatAreaBackground).enabled = UIController.showUI; UIBoatTextTitle = UIController.CreateTextObject("BoatTextTitle", UIBoatArea, Color.white, fontName, fontSize, (TextAnchor)4, new Vector2(-25f, 0f), sizeDelta); UIBoatText = UIController.CreateTextObject("BoatText", UIBoatArea, Color.white, fontName, fontSize, (TextAnchor)4, new Vector2(45f, 0f), sizeDelta); } } private static Color GetColorFromSpeed(float speed) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (speed < 2.5f) { return Color.red; } if (speed < 5f) { return new Color(1f, 0.549019f, 0f); } if (speed < 7.5f) { return Color.yellow; } return Color.green; } } private static float boatSpeed; private static bool showBoatSpeedUI; internal static GameObject UIBoatArea; private static Text UIBoatText; private static Text UIBoatTextTitle; private static Image boatAreaBackground; } internal class UIController { public static bool showUI = true; public static void UpdateUIDisplay() { if (Input.GetKeyDown((KeyCode)277)) { showUI = !showUI; } } public static Text CreateTextObject(string name, GameObject parent, Color textColor, string fontName, int fontSize, TextAnchor alignment, Vector2 position, Vector2 sizeDelta) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.layer = 5; val.transform.SetParent(parent.transform); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchoredPosition = position; val2.sizeDelta = sizeDelta; ((Transform)val2).localScale = Vector3.one; Text val3 = val.AddComponent<Text>(); ((Graphic)val3).color = textColor; val3.font = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name == fontName)); val3.fontSize = fontSize; val3.alignment = alignment; Outline val4 = val.AddComponent<Outline>(); ((Shadow)val4).effectColor = Color.black; ((Shadow)val4).effectDistance = new Vector2(1f, -1f); ((Shadow)val4).useGraphicAlpha = true; ((MonoBehaviour)val4).useGUILayout = true; return val3; } public static void UpdateUIPositions() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) float num = -45f; float num2 = -230f; bool flag = (Object)(object)UIInventoryWeightAndSlots.UIInventoryArea != (Object)null && ConfigManager.ShowInventoryWeightAndSlots.Value; bool flag2 = (Object)(object)UIEnemyDetector.UIEnemyArea != (Object)null && ConfigManager.ShowEnemyDetector.Value; bool flag3 = (Object)(object)UIBoatSpeed.UIBoatArea != (Object)null && ConfigManager.ShowBoatSpeed.Value; if (flag) { num += 115f; if (!flag2 && flag3) { num += 30f; } } if (flag2) { UIEnemyDetector.UIEnemyArea.GetComponent<RectTransform>().anchoredPosition = new Vector2(num, num2); num += 133f; } if (flag3) { UIBoatSpeed.UIBoatArea.GetComponent<RectTransform>().anchoredPosition = new Vector2(num, num2); } } } internal class UIEnemyDetector : UIController { [HarmonyPatch(typeof(Player), "Update")] private class EnemyDetector_PlayerPatch { private static void Prefix(ref Player ___m_localPlayer) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)___m_localPlayer == (Object)null || !ConfigManager.ShowEnemyDetector.Value) { return; } int num = 0; int num2 = 0; List<Character> list = new List<Character>(); Character.GetCharactersInRange(((Component)___m_localPlayer).transform.position, 30f, list); foreach (Character item in list) { if ((int)item.GetFaction() == 10 && (Object)(object)item.GetBaseAI() != (Object)null && !item.GetBaseAI().IsAggravated()) { num2++; } if (item.m_name.ToString() == "Human" || item.m_name.ToString() == "$enemy_deer" || item.m_name.ToString() == "$enemy_hare" || item.m_name.ToString() == "$enemy_summonedroot" || item.IsTamed()) { num++; } } numEnemies = list.Count - num - num2; numEnemiesPassive = num2; } } [HarmonyPatch(typeof(Hud), "Update")] private class EnemyDetector_HUDUpdatePatch { private static void Postfix(Hud __instance) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null) { return; } if (ConfigManager.ShowEnemyDetector.Value) { CreateUI(__instance); ((Behaviour)UIEnemyText).enabled = UIController.showUI; ((Behaviour)enemyAreaBackground).enabled = UIController.showUI; if (UIController.showUI) { ((Graphic)UIEnemyText).color = GetColorFromNum(numEnemies); if (numEnemiesPassive > 0) { UIEnemyText.text = "Enemies " + numEnemies + " (" + numEnemiesPassive + ")"; } else { UIEnemyText.text = "Enemies " + numEnemies; } } } else { if ((Object)(object)UIEnemyText != (Object)null) { ((Behaviour)UIEnemyText).enabled = false; } if ((Object)(object)enemyAreaBackground != (Object)null) { ((Behaviour)enemyAreaBackground).enabled = false; } } } private static void CreateUI(Hud hud) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)UIEnemyText != (Object)null) || !((Object)(object)enemyAreaBackground != (Object)null)) { int fontSize = 16; string fontName = "AveriaSansLibre-Bold"; Vector2 sizeDelta = default(Vector2); ((Vector2)(ref sizeDelta))..ctor(100f, 30f); UIEnemyArea = new GameObject("EnemyArea"); UIEnemyArea.layer = 5; UIEnemyArea.transform.SetParent(((Component)hud.m_healthPanel).transform); RectTransform val = UIEnemyArea.AddComponent<RectTransform>(); val.anchorMin = new Vector2(1f, 1f); val.anchorMax = new Vector2(1f, 1f); val.anchoredPosition = new Vector2(ConfigManager.ShowInventoryWeightAndSlots.Value ? 70f : (-40f), -230f); val.sizeDelta = sizeDelta; UIEnemyArea.transform.localScale = Vector3.one; Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground")); enemyAreaBackground = UIEnemyArea.AddComponent<Image>(); ((Graphic)enemyAreaBackground).color = new Color(0f, 0f, 0f, 0.4f); enemyAreaBackground.sprite = sprite; enemyAreaBackground.type = (Type)1; ((Behaviour)enemyAreaBackground).enabled = UIController.showUI; UIEnemyText = UIController.CreateTextObject("EnemyText", UIEnemyArea, Color.white, fontName, fontSize, (TextAnchor)4, new Vector2(0f, 0f), sizeDelta); } } private static Color GetColorFromNum(int num) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (num < 3) { return Color.green; } if (num < 5) { return Color.yellow; } if (num < 7) { return new Color(1f, 0.549019f, 0f); } return Color.red; } } public static int numEnemies; public static int numEnemiesPassive; internal static GameObject UIEnemyArea; private static Text UIEnemyText; private static Image enemyAreaBackground; } internal class UIInventoryWeightAndSlots : UIController { [HarmonyPatch(typeof(Player), "Update")] private class InventoryWeightAndSlots_PlayerPatch { private static void Prefix(ref Player ___m_localPlayer) { if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)___m_localPlayer == (Object)null) && ConfigManager.ShowInventoryWeightAndSlots.Value) { currentWeight = ((Humanoid)___m_localPlayer).GetInventory().GetTotalWeight(); maxWeight = ___m_localPlayer.GetMaxCarryWeight(); freeSlots = ((Humanoid)___m_localPlayer).GetInventory().GetEmptySlots(); freeSlotsPercent = ((Humanoid)___m_localPlayer).GetInventory().SlotsUsedPercentage(); } } } [HarmonyPatch(typeof(Hud), "Update")] private class InventoryWeightAndSlots_HUDUpdatePatch { private static void Postfix(Hud __instance) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null) { return; } if (ConfigManager.ShowInventoryWeightAndSlots.Value) { CreateUI(__instance); ((Behaviour)UIWeightText).enabled = UIController.showUI; ((Behaviour)inventoryAreaBackground).enabled = UIController.showUI; if (UIController.showUI) { float percent = currentWeight * 100f / maxWeight; ((Graphic)UIWeightText).color = GetColorFromPercent(percent); UIWeightText.text = currentWeight.ToString("0.0") + "/" + maxWeight.ToString("0"); } ((Behaviour)UISlotText).enabled = UIController.showUI; ((Behaviour)inventoryAreaBackground).enabled = UIController.showUI; if (UIController.showUI) { ((Graphic)UISlotText).color = GetColorFromPercent(freeSlotsPercent); UISlotText.text = "(" + freeSlots + ")"; } } else { if ((Object)(object)UIWeightText != (Object)null) { ((Behaviour)UIWeightText).enabled = false; } if ((Object)(object)UISlotText != (Object)null) { ((Behaviour)UISlotText).enabled = false; } if ((Object)(object)inventoryAreaBackground != (Object)null) { ((Behaviour)inventoryAreaBackground).enabled = false; } } } private static void CreateUI(Hud hud) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)UIWeightText != (Object)null) || !((Object)(object)UISlotText != (Object)null) || !((Object)(object)inventoryAreaBackground != (Object)null)) { int fontSize = 16; string fontName = "AveriaSansLibre-Bold"; Vector2 sizeDelta = default(Vector2); ((Vector2)(ref sizeDelta))..ctor(115f, 30f); UIInventoryArea = new GameObject("InventoryArea"); UIInventoryArea.layer = 5; UIInventoryArea.transform.SetParent(((Component)hud.m_healthPanel).transform); RectTransform val = UIInventoryArea.AddComponent<RectTransform>(); val.anchorMin = new Vector2(1f, 1f); val.anchorMax = new Vector2(1f, 1f); val.anchoredPosition = new Vector2(-45f, -230f); val.sizeDelta = sizeDelta; UIInventoryArea.transform.localScale = Vector3.one; Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground")); inventoryAreaBackground = UIInventoryArea.AddComponent<Image>(); ((Graphic)inventoryAreaBackground).color = new Color(0f, 0f, 0f, 0.4f); inventoryAreaBackground.sprite = sprite; inventoryAreaBackground.type = (Type)1; ((Behaviour)inventoryAreaBackground).enabled = UIController.showUI; UIWeightText = UIController.CreateTextObject("WeightText", UIInventoryArea, Color.green, fontName, fontSize, (TextAnchor)3, new Vector2(5f, 0f), sizeDelta); UISlotText = UIController.CreateTextObject("SlotText", UIInventoryArea, Color.green, fontName, fontSize, (TextAnchor)5, new Vector2(-5f, 0f), sizeDelta); } } private static Color GetColorFromPercent(float percent) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (percent < 33f) { return Color.green; } if (percent < 66f) { return Color.yellow; } if (percent < 100f) { return new Color(1f, 0.549019f, 0f); } return Color.red; } } private static float currentWeight; private static float maxWeight; private static float freeSlots; private static float freeSlotsPercent; internal static GameObject UIInventoryArea; private static Text UIWeightText; private static Text UISlotText; private static Image inventoryAreaBackground; } internal class UILoadscreenTips { [HarmonyPatch(typeof(Localization), "SetupLanguage")] private class LoadingTips_Patch { private static void Postfix(Localization __instance, string language) { if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && __instance != null && ConfigManager.MoreLoadingTipsEnabled.Value) { localizationLanguage = language; } } } [HarmonyPatch(typeof(Hud), "Awake")] private class Loadscreens_HUDAwakePatch { private static void Postfix(Hud __instance) { if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)__instance == (Object)null) && ConfigManager.MoreLoadingTipsEnabled.Value) { loadingTipString = loadingTipStrings[Random.Range(0, loadingTipStrings.Count)]; } } } [HarmonyPatch(typeof(Hud), "UpdateBlackScreen")] private class ExtraLoadingTipsUpdate_Patch { private static void Postfix(Hud __instance) { if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)__instance == (Object)null) && ConfigManager.MoreLoadingTipsEnabled.Value && localizationLanguage == "English") { __instance.m_loadingTip.text = loadingTipString; } } } private static string loadingTipString; private static string localizationLanguage; private static readonly List<string> loadingTipStrings = new List<string> { "Weapons and armor can be crafted and upgraded using Workbenches or Forges.", "Eating food increases your health and stamina pools. Try to balance your three food slots accordingly.", "Crafting stations can be upgraded by building extenstions in their proximity.", "There are four principal crafting types: woodworking, masonry, smithing, and cooking.", "Enemies won't spawn near player built structures, such as crafting tables and camp fires.", "Sitting is the safest way to travel while on a boat.", "Upon your arrival in Valheim, try to find stones and branches on the ground to build your first weapon.", "Venturing outside at night is more dangerous. Be prepared if you plan to go out during that time.", "Hunting deer with a ranged weapon provides a good source of meat and skin.", "Build a rudimentary shelter as soon as possible, to refuge during your first nights. It can be used as a temporary home until you find a good spot for a better one.", "Different enemies are resistant to different damage types. If you see grey damage indicators when attacking, try changing the weapon.", "Claiming a bed after building it will set your spawn point to its location when dying.", "Attacking with knives and bows while sneaking confers a large damage bonus.", "Birds are a good source of feathers. They will stay close to the ground while the weather is bad.", "Weapons, armor, and tools can be repaired for free at a Workbench or Forge by interacting with the hammer icon while crafting.", "Some resources require better tools to harvest them.", "Being rested helps to regenerate stamina and health faster.", "Yellow damage numbers indicate a weakness, grey numbers indicate a resistance", "Use the hoe in combination with the pickaxe to flatten the ground. This will make it much easier to construct buildings.", "Build a cart to haul heavy goods over longer distances. Carts cannot go through portals.", "Boats are controlled by interacting with the steering oar.", "Defeating a Forsaken will drop items that will give you a general idea of what to do next.", "Cooking meat over a fire or eating fruit is a good way to get fed. Later on, they can be cooked using a cauldron.", "You can filter map pins by type by right clicking on them. (DPad Right)", "If no arrow has been manually selected when using a bow, arrows are automatically selected in ascending order beginning from the leftmost column and going right.", "Build a Fermenter to craft different potions from base meads. The right potion used at the right time and place can be the difference between life and death.", "Killing bee nests can provide the means to make your own honey.", "The more comfort items are installed in your home (e.g., fire, rugs, furniture, etc), the longer the rested bonus will be.", "When fighting a Forsaken, make sure you bring your best gear, food, and potions.", "All build pieces require a certain crafting station nearby (e.g., Workbench, Forge, Stonecutter). If you want to build outside their range, either move them closer or build new ones.", "Building paths and roads can make carying material with a cart a lot easier.", "Item stacks can be split using SHIFT + Left Click in chests or inventory.", "Item stacks can be fully transferred to/from containers by dragging or pressing CTRL + Left Click.", "If you run out of stamina while swimming, you will drown.", "The HUD can be toggled with the CTRL + F3 keys.", "Parying with a shield or weapon means blocking at the very last moment of an enemy attack before hitting you. If done right, the enemy will be staggered.", "Don't be afraid to retreat from a fight. It is better to come back to it prepared than naked.", "Sheathing or unsheathing equipped weapons and shields can be done by pressing R. Walking and runnng with unsheathed weapons will slow you down.", "Old buildings can be found throughout Valheim. They can be either renovated for shelter, or torn down for resources.", "Some animals can be tamed.", "Sitting next to a lit fire in any open space provides a level 1 rested bonus." }; } internal class UIOnlinePlayers : UIController { [HarmonyPatch(typeof(ZNet), "Update")] private class OnlinePartyIndicator_Patch { private static void Prefix(ref List<PlayerInfo> ___m_players) { if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && ConfigManager.ShowOnlinePlayers.Value && UIController.showUI && ___m_players.Count != 0) { playerInfoList = ___m_players; } } } [HarmonyPatch(typeof(Hud), "Update")] private class OnlinePlayers_HUDUpdatePatch { private static bool lastOnlinePlayersUnderMinimap = ConfigManager.OnlinePlayersUnderMinimap.Value; private static float UIPartyPlayerTextDistanceV = -25f; private static void Postfix(Hud __instance) { //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null) { return; } if (ConfigManager.ShowOnlinePlayers.Value) { CreateUI(__instance); if (ConfigManager.OnlinePlayersUnderMinimap.Value != lastOnlinePlayersUnderMinimap) { lastOnlinePlayersUnderMinimap = ConfigManager.OnlinePlayersUnderMinimap.Value; UpdatePartyUIPosition(__instance); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && (Object)(object)UIPartyArea != (Object)null) { bool flag = IsUIHidden(); bool flag2 = IsLoadScreenActive(__instance); if (flag && UIPartyArea.activeSelf) { UIPartyArea.SetActive(false); } else if (!flag) { if (flag2 && UIPartyArea.activeSelf) { UIPartyArea.SetActive(false); } else if (!flag2) { if (ConfigManager.OnlinePlayersUnderMinimap.Value) { bool activeInHierarchy = Minimap.instance.m_mapSmall.activeInHierarchy; if (activeInHierarchy && !UIPartyArea.activeSelf) { UIPartyArea.SetActive(true); } else if (!activeInHierarchy && UIPartyArea.activeSelf) { UIPartyArea.SetActive(false); } } else if (!UIPartyArea.activeSelf) { UIPartyArea.SetActive(true); } } } } int num = ((playerInfoList.Count <= numOnlinePlayerSlots - 1) ? playerInfoList.Count : (numOnlinePlayerSlots - 1)); bool flag3 = playerInfoList.Count == 1; if (!ConfigManager.OnlinePlayersUnderMinimap.Value) { for (int i = 0; i < numOnlinePlayerSlots; i++) { if (i < num && !flag3) { ((Behaviour)UIPlayerTexts[i]).enabled = UIController.showUI && !Chat.instance.IsChatDialogWindowVisible(); if (UIController.showUI) { ((Graphic)UIPlayerTexts[i]).color = Color.white; UIPlayerTexts[i].text = playerInfoList[i].m_name; } } else if (i == num && !flag3) { ((Behaviour)UIPlayerTexts[i]).enabled = UIController.showUI && !Chat.instance.IsChatDialogWindowVisible(); if (UIController.showUI) { ((Graphic)UIPlayerTexts[i]).color = Color.green; UIPlayerTexts[i].text = "Online:"; } } else { ((Graphic)UIPlayerTexts[i]).color = Color.white; UIPlayerTexts[i].text = ""; } } } else { if (flag3) { return; } ((Behaviour)UIPlayerTexts[0]).enabled = UIController.showUI && Minimap.instance.m_mapSmall.activeInHierarchy; if (UIController.showUI) { ((Graphic)UIPlayerTexts[0]).color = Color.green; UIPlayerTexts[0].text = "Online:"; } for (int j = 1; j < numOnlinePlayerSlots; j++) { if (j <= num) { ((Behaviour)UIPlayerTexts[j]).enabled = UIController.showUI && Minimap.instance.m_mapSmall.activeInHierarchy; if (UIController.showUI) { ((Graphic)UIPlayerTexts[j]).color = Color.white; UIPlayerTexts[j].text = playerInfoList[j - 1].m_name; } } else { ((Graphic)UIPlayerTexts[j]).color = Color.white; UIPlayerTexts[j].text = ""; } } } return; } foreach (Text uIPlayerText in UIPlayerTexts) { if ((Object)(object)uIPlayerText != (Object)null) { ((Behaviour)uIPlayerText).enabled = false; } } } private static void CreateUI(Hud hud) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) if (UIPlayerTexts.Count <= 0 || !UIPlayerTexts.All((Text t) => (Object)(object)t != (Object)null)) { int fontSize = 16; string fontName = "AveriaSansLibre-Bold"; Vector2 sizeDelta = default(Vector2); ((Vector2)(ref sizeDelta))..ctor(120f, 30f); UIPartyArea = new GameObject("PartyArea"); UIPartyArea.SetActive(false); UIPartyArea.layer = 5; if (!ConfigManager.OnlinePlayersUnderMinimap.Value) { UIPartyArea.transform.SetParent(hud.m_rootObject.transform.parent); } else { UIPartyArea.transform.SetParent(hud.m_rootObject.transform); } RectTransform val = UIPartyArea.AddComponent<RectTransform>(); if (!ConfigManager.OnlinePlayersUnderMinimap.Value) { val.anchorMin = new Vector2(1f, 0f); val.anchorMax = new Vector2(1f, 0f); val.pivot = new Vector2(1f, 0f); val.anchoredPosition = new Vector2(-20f, 70f); } else { val.anchorMin = new Vector2(1f, 1f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(0.5f, 0.5f); val.anchoredPosition = new Vector2(-170f, -255f); } val.sizeDelta = sizeDelta; UIPartyArea.transform.localScale = Vector3.one; List<GameObject> list = new List<GameObject>(); UIPlayerTexts.Clear(); list.Clear(); for (int i = 0; i < numOnlinePlayerSlots; i++) { TextAnchor alignment = (TextAnchor)(ConfigManager.OnlinePlayersUnderMinimap.Value ? 3 : 5); Vector2 position = (ConfigManager.OnlinePlayersUnderMinimap.Value ? new Vector2(0f, UIPartyPlayerTextDistanceV * (float)i) : new Vector2(0f, (0f - UIPartyPlayerTextDistanceV) * (float)i)); Text val2 = UIController.CreateTextObject($"PartyText_{i}", UIPartyArea, Color.white, fontName, fontSize, alignment, position, sizeDelta); UIPlayerTexts.Add(val2); list.Add(((Component)val2).gameObject); } } } private static void UpdatePartyUIPosition(Hud hud) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) MarsarahTweaks.MLog("[Info] UpdatePartyUICalled"); if ((Object)(object)UIPartyArea == (Object)null) { return; } if (!ConfigManager.OnlinePlayersUnderMinimap.Value) { UIPartyArea.transform.SetParent(hud.m_rootObject.transform.parent, false); } else { UIPartyArea.transform.SetParent(hud.m_rootObject.transform, false); } RectTransform component = UIPartyArea.GetComponent<RectTransform>(); if (!ConfigManager.OnlinePlayersUnderMinimap.Value) { component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 0f); component.pivot = new Vector2(1f, 0f); component.anchoredPosition = new Vector2(-20f, 70f); } else { component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = new Vector2(-170f, -255f); } for (int i = 0; i < UIPlayerTexts.Count; i++) { Text val = UIPlayerTexts[i]; if ((Object)(object)val != (Object)null) { RectTransform component2 = ((Component)val).GetComponent<RectTransform>(); val.alignment = (TextAnchor)(ConfigManager.OnlinePlayersUnderMinimap.Value ? 3 : 5); component2.anchoredPosition = (ConfigManager.OnlinePlayersUnderMinimap.Value ? new Vector2(0f, UIPartyPlayerTextDistanceV * (float)i) : new Vector2(0f, (0f - UIPartyPlayerTextDistanceV) * (float)i)); } } } private static bool IsLoadScreenActive(Hud hud) { return Object.op_Implicit((Object)(object)Hud.instance) && Object.op_Implicit((Object)(object)hud.m_loadingScreen) && ((Component)hud.m_loadingScreen).gameObject.activeSelf; } private static bool IsUIHidden() { return Hud.IsUserHidden(); } } private static List<PlayerInfo> playerInfoList = new List<PlayerInfo>(); private static int numOnlinePlayerSlots = 21; private static GameObject UIPartyArea; private static List<Text> UIPlayerTexts = new List<Text>(); } internal class UISmartBiome : UIController { private struct BiomeWeights { public int _min; public int _max; public BiomeWeights(int min, int max) { _min = min; _max = max; } } [HarmonyPatch(typeof(Player), "Update")] private class SmartBiome_PlayerPatch { private static void Prefix(ref Player ___m_localPlayer) { if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)___m_localPlayer == (Object)null || !ConfigManager.ShowSmartBiome.Value || !UIController.showUI) { return; } playerArmor = ((Character)___m_localPlayer).GetBodyArmor(); Inventory inventory = ((Humanoid)___m_localPlayer).GetInventory(); List<ItemData> equippedItems = inventory.GetEquippedItems(); foreach (ItemData item in equippedItems) { if (armorWeightsDict.ContainsKey(item.m_shared.m_name)) { if (!equippedArmorWeightsDict.ContainsKey(item.m_shared.m_name)) { equippedArmorWeightsDict.Add(item.m_shared.m_name, armorWeightsDict[item.m_shared.m_name] + item.m_quality - 1); } else { equippedArmorWeightsDict[item.m_shared.m_name] = armorWeightsDict[item.m_shared.m_name] + item.m_quality - 1; } } } List<string> list = new List<string>(); foreach (KeyValuePair<string, int> item2 in equippedArmorWeightsDict) { bool flag = false; foreach (ItemData item3 in equippedItems) { if (item3.m_shared.m_name == item2.Key) { flag = true; break; } } if (!flag) { list.Add(item2.Key); } } foreach (string item4 in list) { equippedArmorWeightsDict.Remove(item4); } } } [HarmonyPatch(typeof(Minimap), "UpdateBiome")] private class MoveBiomeMinimapText_Patch { private static void Prefix(ref Text ___m_biomeNameSmall, ref Player player) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) { if (ConfigManager.ShowSmartBiome.Value && UIController.showUI) { ((Behaviour)___m_biomeNameSmall).enabled = false; Biome currentBiome = player.GetCurrentBiome(); UISmartBiome.currentBiome = ((object)(Biome)(ref currentBiome)).ToString(); } else { ((Behaviour)___m_biomeNameSmall).enabled = true; } } } } [HarmonyPatch(typeof(Hud), "Update")] private class SmartBiome_HUDUpdatePatch { private static void Postfix(Hud __instance) { //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null) { return; } if (ConfigManager.ShowSmartBiome.Value) { CreateUI(__instance); ((Behaviour)UIBiomeText).enabled = UIController.showUI && Minimap.instance.m_mapSmall.activeInHierarchy; if (!UIController.showUI || !Minimap.instance.m_mapSmall.activeInHierarchy) { return; } if (currentBiome != null && biomeWeightsDict.ContainsKey(currentBiome)) { playerArmorWeight = 0; foreach (KeyValuePair<string, int> item in equippedArmorWeightsDict) { playerArmorWeight += item.Value; } float num = biomeWeightsDict[currentBiome]._min; float num2 = biomeWeightsDict[currentBiome]._max; float num3 = num2 - num; float num4 = (float)playerArmorWeight - num; float percent = num4 * 100f / num3; ((Graphic)UIBiomeText).color = GetColorFromPercent(percent); } else { ((Graphic)UIBiomeText).color = Color.white; } UIBiomeText.text = ((currentBiome == "BlackForest") ? "Black forest" : ((currentBiome == "AshLands") ? "Ashlands" : currentBiome)); } else if ((Object)(object)UIBiomeText != (Object)null) { ((Behaviour)UIBiomeText).enabled = false; } } private static void CreateUI(Hud hud) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)UIBiomeText != (Object)null)) { int fontSize = 16; string fontName = "AveriaSansLibre-Bold"; Vector2 sizeDelta = default(Vector2); ((Vector2)(ref sizeDelta))..ctor(150f, 30f); GameObject val = new GameObject("BiomeArea"); val.layer = 5; val.transform.SetParent(hud.m_rootObject.transform); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = new Vector2(1f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.anchoredPosition = new Vector2(-125f, -55f); val2.sizeDelta = sizeDelta; val.transform.localScale = Vector3.one; UIBiomeText = UIController.CreateTextObject("BiomeText", val, Color.white, fontName, fontSize, (TextAnchor)5, new Vector2(0f, 0f), sizeDelta); } } private static Color GetColorFromPercent(float percent) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (percent < 0f) { return new Color(0.298039f, 0f, 0.6f); } if (percent < 25f) { return Color.red; } if (percent < 75f) { return new Color(1f, 0.549019f, 0f); } if (percent < 100f) { return Color.yellow; } return Color.green; } } private static float playerArmor; private static int playerArmorWeight; private static string currentBiome = null; private static Text UIBiomeText; private static readonly Dictionary<string, BiomeWeights> defaultBiomeWeights = new Dictionary<string, BiomeWeights> { { "Meadows", new BiomeWeights(1, 11) }, { "BlackForest", new BiomeWeights(11, 24) }, { "Swamp", new BiomeWeights(24, 37) }, { "Mountain", new BiomeWeights(33, 46) }, { "Plains", new BiomeWeights(42, 55) }, { "Mistlands", new BiomeWeights(51, 60) }, { "AshLands", new BiomeWeights(60, 69) } }; private static readonly Dictionary<string, BiomeWeights> unlockedBiomeWeights = new Dictionary<string, BiomeWeights> { { "Meadows", new BiomeWeights(1, 15) }, { "BlackForest", new BiomeWeights(11, 28) }, { "Swamp", new BiomeWeights(24, 37) }, { "Mountain", new BiomeWeights(33, 46) }, { "Plains", new BiomeWeights(42, 55) }, { "Mistlands", new BiomeWeights(51, 64) }, { "AshLands", new BiomeWeights(60, 73) } }; private static Dictionary<string, BiomeWeights> biomeWeightsDict = defaultBiomeWeights; private static Dictionary<string, int> armorWeightsDict = new Dictionary<string, int> { { "$item_cape_deerhide", 1 }, { "$item_cape_trollhide", 1 }, { "$item_cape_linen", 1 }, { "$item_cape_wolf", 1 }, { "$item_cape_lox", 1 }, { "$item_cape_feather", 1 }, { "$item_cape_ash", 1 }, { "$item_cape_asksvin", 1 }, { "$item_chest_rags", 1 }, { "$item_legs_rags", 1 }, { "$item_helmet_leather", 2 }, { "$item_chest_leather", 2 }, { "$item_legs_leather", 2 }, { "$item_helmet_trollleather", 5 }, { "$item_chest_trollleather", 5 }, { "$item_legs_trollleather", 5 }, { "$item_helmet_bronze", 5 }, { "$item_chest_bronze", 5 }, { "$item_legs_bronze", 5 }, { "$item_helmet_root", 8 }, { "$item_chest_root", 8 }, { "$item_legs_root", 8 }, { "$item_helmet_iron", 8 }, { "$item_chest_iron", 8 }, { "$item_legs_iron", 8 }, { "$item_helmet_fenris", 11 }, { "$item_chest_fenris", 11 }, { "$item_legs_fenris", 11 }, { "$item_helmet_drake", 11 }, { "$item_chest_wolf", 11 }, { "$item_legs_wolf", 11 }, { "$item_helmet_padded", 14 }, { "$item_chest_pcuirass", 14 }, { "$item_legs_pgreaves", 14 }, { "$item_helmet_mage", 17 }, { "$item_chest_mage", 17 }, { "$item_legs_mage", 17 }, { "$item_helmet_carapace", 17 }, { "$item_chest_carapace", 17 }, { "$item_legs_carapace", 17 }, { "$item_helmet_mage_ashlands", 20 }, { "$item_chest_mage_ashlands", 20 }, { "$item_legs_mage_ashlands", 20 }, { "$item_helmet_medium_ashlands", 20 }, { "$item_chest_medium_ashlands", 20 }, { "$item_legs_medium_ashlands", 20 }, { "$item_helmet_flametal", 20 }, { "$item_chest_flametal", 20 }, { "$item_legs_flametal", 20 } }; private static Dictionary<string, int> equippedArmorWeightsDict = new Dictionary<string, int>(); public static void UpdateBiomeWeights() { biomeWeightsDict = (ConfigManager.GearUpgradeUnlockEnabled.Value ? unlockedBiomeWeights : defaultBiomeWeights); } } internal class UISummonCounter : UIController { [HarmonyPatch(typeof(Player), "Update")] private class SummonCounters_PlayerPatch { private static void Prefix(ref Player ___m_localPlayer) { if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)___m_localPlayer == (Object)null || !ConfigManager.ShowSummonCounter.Value || !UIController.showUI) { return; } List<Character> allCharacters = Character.GetAllCharacters(); int num = 0; foreach (Character item in allCharacters) { if (!item.IsTamed()) { continue; } MonsterAI component = ((Component)item).GetComponent<MonsterAI>(); if (!((Object)(object)component != (Object)null)) { continue; } GameObject followTarget = component.GetFollowTarget(); if ((Object)(object)followTarget != (Object)null) { Player component2 = followTarget.GetComponent<Player>(); if ((Object)(object)component2 != (Object)null && component2.GetPlayerName() == ___m_localPlayer.GetPlayerName() && ((Object)item).name.Contains("Skeleton_Friendly")) { num++; } } } numSummons = num; } } [HarmonyPatch(typeof(Hud), "Update")] private class SummonCounter_HUDUpdatePatch { private static void Postfix(Hud __instance) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null) { return; } if (ConfigManager.ShowSummonCounter.Value) { CreateUI(__instance); ((Behaviour)UISummonsText).enabled = UIController.showUI && numSummons != 0; ((Behaviour)summonsAreaBackground).enabled = UIController.showUI && numSummons != 0; if (UIController.showUI) { if (numSummons != 0) { ((Graphic)UISummonsText).color = GetColorFromNum(numSummons); UISummonsText.text = "Summons " + numSummons; } else { UISummonsText.text = ""; } } } else { if ((Object)(object)UISummonsText != (Object)null) { ((Behaviour)UISummonsText).enabled = false; } if ((Object)(object)summonsAreaBackground != (Object)null) { ((Behaviour)summonsAreaBackground).enabled = false; } } } private static void CreateUI(Hud hud) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)UISummonsText != (Object)null) || !((Object)(object)summonsAreaBackground != (Object)null)) { int fontSize = 16; string fontName = "AveriaSansLibre-Bold"; Vector2 sizeDelta = default(Vector2); ((Vector2)(ref sizeDelta))..ctor(100f, 30f); GameObject val = new GameObject("SummonsArea"); val.layer = 5; val.transform.SetParent(((Component)hud.m_healthPanel).transform); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = new Vector2(1f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.anchoredPosition = new Vector2(63f, -85f); val2.sizeDelta = sizeDelta; val.transform.localScale = Vector3.one; Sprite sprite = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite tempSprite) => ((Object)tempSprite).name == "InputFieldBackground")); summonsAreaBackground = val.AddComponent<Image>(); ((Graphic)summonsAreaBackground).color = new Color(0f, 0f, 0f, 0.4f); summonsAreaBackground.sprite = sprite; summonsAreaBackground.type = (Type)1; ((Behaviour)summonsAreaBackground).enabled = UIController.showUI; UISummonsText = UIController.CreateTextObject("SummonsText", val, Color.white, fontName, fontSize, (TextAnchor)4, new Vector2(0f, 0f), sizeDelta); } } private static Color GetColorFromNum(int num) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (num < 2) { return new Color(1f, 0.549019f, 0f); } if (num == 2) { return Color.yellow; } if (num >= 3) { return Color.green; } return Color.white; } } public static int numSummons; private static Text UISummonsText; private static Image summonsAreaBackground; } internal class UITimeAndDay : UIController { [HarmonyPatch(typeof(EnvMan), "Update")] private class TimeAndDay_EnvManPatch { private static void Prefix(EnvMan __instance, ref float ___m_smoothDayFraction) { if ((!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) && !((Object)(object)__instance == (Object)null) && ConfigManager.ShowTimeAndDay.Value) { currentDay = Traverse.Create((object)EnvMan.instance).Method("GetCurrentDay", Array.Empty<object>()).GetValue<int>(); if (!ConfigManager.TimeFormat24H.Value) { dayString = GetStringFromFraction(___m_smoothDayFraction); return; } int num = (int)(___m_smoothDayFraction * 24f); int num2 = (int)((___m_smoothDayFraction * 24f - (float)num) * 60f); string text = ((num < 10) ? ("0" + num) : num.ToString()); string text2 = ((num2 < 10) ? ("0" + num2) : num2.ToString()); dayString = "Time " + text + ":" + text2; } } private static string GetStringFromFraction(float dayFraction) { if (dayFraction < 0.2f) { return "Night"; } if (dayFraction < 0.25f) { return "Dawn"; } if (dayFraction < 0.33f) { return "Morning"; } if (dayFraction < 0.5f) { return "Day"; } if (dayFraction < 0.66f) { return "Afternoon"; } if (dayFraction < 0.75f) { return "Evening"; } if (dayFraction < 0.8f) { return "Dusk"; } return "Night"; } } [HarmonyPatch(typeof(Hud), "Update")] private class TimeAndDay_HUDUpdatePatch { private static void Postfix(Hud __instance) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated()) || (Object)(object)__instance == (Object)null) { return; } if (ConfigManager.ShowTimeAndDay.Value) { CreateUI(__instance); ((Behaviour)UITimeText).enabled = UIController.showUI && Minimap.instance.m_mapSmall.activeInHierarchy; ((Behaviour)UIDayText).enabled = UIController.showUI && Minimap.instance.m_mapSmall.activeInHierarchy; if (UIController.showUI && Minimap.instance.m_mapSmall.activeInHierarchy) { ((Graphic)UITimeText).color = GetColorFromString(dayString); ((Graphic)UIDayText).color = Color.white; UITimeText.text = dayString; UIDayText.text = "Day " + currentDay; } } else { if ((Object)(object)UITimeText != (Object)null) { ((Behaviour)UITimeText).enabled = false; } if ((Object)(object)UIDayText != (Object)null) { ((Behaviour)UIDayText).enabled = false; } } } private static void CreateUI(Hud hud) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)UITimeText != (Object)null) || !((Object)(object)UIDayText != (Object)null)) { int fontSize = 16; string fontName = "AveriaSansLibre-Bold"; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(200f, 30f); GameObject val2 = new GameObject("TimeArea"); val2.layer = 5; val2.transform.SetParent(hud.m_rootObject.transform); RectTransform val3 = val2.AddComponent<RectTransform>(); val3.anchorMin = new Vector2(1f, 1f); val3.anchorMax = new Vector2(1f, 1f); val3.anchoredPosition = new Vector2(-140f, -25f); val3.sizeDelta = val; val2.transform.localScale = Vector3.one; val.x /= 2f; UITimeText = UIController.CreateTextObject("TimeText", val2, Color.white, fontName, fontSize, (TextAnchor)5, new Vector2(40f, 0f), val); UIDayText = UIController.CreateTextObject("DayText", val2, Color.white, fontName, fontSize, (TextAnchor)3, new Vector2(-40f, 0f), val); } } private static Color GetColorFromString(string word) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) return (Color)(word switch { "Night" => Color.red, "Dawn" => new Color(1f, 0.549019f, 0f), "Dusk" => new Color(1f, 0.549019f, 0f), "Morning" => Color.yellow, "Evening" => Color.yellow, "Day" => Color.green, "Afternoon" => Color.green, _ => Color.white, }); } } public static string dayString; public static int currentDay; private static Text UITimeText; private static Text UIDayText; } } namespace MarsarahTweaks.Patches.Grind { internal class BuildPieceChanges { [HarmonyPatch(typeof(ZNetScene), "Awake")] private class BuildPiecesModifications_Patch { private static void Postfix(ref ZNetScene __instance) { if (!((Object)(object)__instance == (Object)null) && (!((Obje