Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of UlvriksWorldUpdate v0.2.1
plugins\UWU.dll
Decompiled 7 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Splatform; using TMPro; using UWU.Behaviors; using UWU.Commands; using UWU.Common; using UWU.Extensions; using UWU.Features; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("UWU")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("UWU")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.2.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.1.0")] namespace UWU { [BepInPlugin("com.ulvrikironpaw.uwu", "Ulvrik's World Update", "0.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class UWUMod : BaseUnityPlugin { [HarmonyPatch(typeof(ZNet), "Awake")] public static class ZNet_Awake_Patch { private static void Postfix() { RPCManager.RegisterRPCs(); } } private static bool isConfigured = false; private static FeatureBehaviour[] features = new FeatureBehaviour[0]; private static GameObject featureHost; private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (isConfigured) { return; } isConfigured = true; Harmony.CreateAndPatchAll(typeof(ZNet_Awake_Patch), (string)null); featureHost = new GameObject("Features_UWU"); Object.DontDestroyOnLoad((Object)(object)featureHost); features = CreateFeatures(); FeatureBehaviour[] array = features; foreach (FeatureBehaviour featureBehaviour in array) { try { featureBehaviour.Configure(((BaseUnityPlugin)this).Config); } catch (Exception ex) { Logger.LogError((object)ex); } } } private static FeatureBehaviour[] CreateFeatures() { return new FeatureBehaviour[12] { CreateFeature<BoatyMcBoatfaceFeature>(), CreateFeature<ModerBoatingFeature>(), CreateFeature<NotMyShipFeature>(), CreateFeature<PaddleFasterFeature>(), CreateFeature<SailFasterFeature>(), CreateFeature<SailingGraceFeature>(), CreateFeature<ShipBonkiesFeature>(), CreateFeature<ShipNameplateFeature>(), CreateFeature<ShipPinFeature>(), CreateFeature<ShipRenameFeature>(), CreateFeature<MoodifierFeature>(), CreateFeature<SpeedometerFeature>() }; } private static T CreateFeature<T>() where T : FeatureBehaviour { return featureHost.AddComponent<T>(); } } } namespace UWU.Features { internal class BoatyMcBoatfaceFeature : FeatureBehaviour { private static BoatyMcBoatfaceFeature instance; private static readonly string[] Prefixes = new string[72] { "Amber", "Ash", "Axe", "Battle", "Bear", "Black", "Blaze", "Blood", "Bone", "Brave", "Bright", "Cinder", "Cold", "Crow", "Dark", "Dawn", "Death", "Deep", "Drake", "Dusk", "Eagle", "Ember", "Fire", "Flame", "Frost", "Ghost", "Giant", "Glory", "Gore", "Grim", "Hard", "Hawk", "Ice", "Iron", "Ironfist", "Lone", "Long", "Mighty", "Mist", "Moon", "Night", "Oak", "Odin", "Old", "One", "Pale", "Rage", "Raven", "Red", "Rock", "Rune", "Sea", "Shadow", "Silent", "Skald", "Skull", "Snow", "Steel", "Stone", "Storm", "Strong", "Sun", "Swift", "Thor", "Thunder", "True", "Valkyr", "Wild", "Wind", "Wolf", "Wyrm", "Young" }; private static readonly string[] Suffixes = new string[72] { "bane", "beard", "bearer", "binder", "biter", "blade", "blaze", "blood", "breaker", "burner", "caller", "claw", "cleaver", "crusher", "dance", "doom", "drinker", "eater", "eye", "fang", "fist", "flame", "flayer", "foe", "foot", "forger", "friend", "fury", "gaze", "glare", "grim", "guard", "hand", "heart", "helm", "horn", "howler", "hunter", "lash", "maiden", "mark", "mast", "mauler", "maw", "moon", "rage", "reader", "rider", "roamer", "roar", "runner", "sail", "sailor", "scar", "seeker", "shade", "shaper", "shield", "singer", "slayer", "smasher", "smith", "song", "soul", "spell", "storm", "voice", "walker", "warden", "warrior", "watcher", "weaver" }; protected override string Name => "BoatyMcBoatface"; protected override string Category => "Sailing"; protected override string Description => "Automatically give ships names on creation."; protected override bool EnabledByDefault => true; internal BoatyMcBoatfaceFeature() { instance = this; } protected override void OnPatch(Harmony harmony) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Ship), "Start", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(BoatyMcBoatfaceFeature), "Ship_Start_Patch", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void Ship_Start_Patch(Ship __instance) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner()) { ZDO zDO = component.GetZDO(); if (zDO != null && Utility.IsNullOrWhiteSpace(NameCache.GetCustomLabelFromZDO(zDO))) { string label = GenerateStableName(zDO.m_uid); RPCManager.RenameObject(zDO, label); } } } private static string GenerateStableName(ZDOID id) { long num = ((ZDOID)(ref id)).UserID ^ ((ZDOID)(ref id)).ID; Random random = new Random((int)(num & 0xFFFFFFFFu) ^ (int)(num >> 32)); string text = Prefixes[random.Next(Prefixes.Length)]; string text2 = Suffixes[random.Next(Suffixes.Length)]; if (text.ToLower() == text2.ToLower()) { return text + " " + StringExtensions.CapitalizeFirstLetter(text2); } return text + text2; } } internal sealed class ModerBoatingFeature : FeatureBehaviour { private const float maxTime = 5f; private float updateTimer = 5f; private StatusEffect modifiedModerEffect; protected override string Name => "ModerBoating"; protected override string Category => "Sailing"; protected override string Description => "Permanently applies the Moder buff"; protected override bool EnabledByDefault => false; protected override void OnPatch(Harmony harmony) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(StatusEffect), "Setup", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ModerBoatingFeature), "StatusEffect_Setup_Prefix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } protected override void OnUnpatch() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan != null) { sEMan.RemoveStatusEffect(modifiedModerEffect, false); } } } private void FixedUpdate() { updateTimer += Time.deltaTime; if (updateTimer < 5f) { return; } updateTimer = 0f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan != null) { StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect("GP_Moder".GetHashCode()); if ((Object)(object)statusEffect != (Object)null && !sEMan.HaveStatusEffect("GP_Moder".GetHashCode())) { modifiedModerEffect = statusEffect.Clone(); modifiedModerEffect.m_ttl = 0f; modifiedModerEffect.m_isNew = false; sEMan.AddStatusEffect(modifiedModerEffect, false, 0, 0f); } } } private static bool StatusEffect_Setup_Prefix(StatusEffect __instance, Character character) { if (__instance.m_name == "$se_moder_name") { __instance.m_character = character; return false; } return true; } } internal class MoodifierFeature : FeatureBehaviour { private bool weatherConfigured; protected override string Name => "Moodifier"; protected override string Category => "Weather"; protected override string Description => "Modifies weather patterns to set the mood"; protected override bool EnabledByDefault => false; protected override void OnConfigure(ConfigFile config) { CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new StringCommand("UWUWeather", "Attempts to change the local weather to the specified weather name", adminOnly: true, isCheat: true, delegate { EnvMan instance = EnvMan.instance; return ((instance == null) ? null : instance.GetCurrentEnvironment()?.m_name) ?? "???"; }, delegate(string envName) { EnvMan.instance?.SetEnvironment_UWU(envName); })); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new VoidCommand("UWUListWeather", "Lists all known weather environments", adminOnly: true, isCheat: true, delegate { EnvMan.instance?.PrintEnvironments_UWU(); })); } private void FixedUpdate() { if (!weatherConfigured && !((Object)(object)EnvMan.instance == (Object)null)) { weatherConfigured = true; Environments.AddCustomEnvironments(EnvMan.instance); ConfigureWeather(EnvMan.instance); } } private static void ConfigureWeather(EnvMan instance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_007c: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Biome, WeatherEntry[]> weatherOverride in GetWeatherOverrides()) { Biome biome = weatherOverride.Key; WeatherEntry[] value = weatherOverride.Value; if (!value.Any()) { Logger.LogWarning((object)$"No overrides for {biome}. Skipping"); continue; } BiomeEnvSetup val = instance.m_biomes.Find((BiomeEnvSetup it) => it.m_biome == biome); if (val == null) { Logger.LogWarning((object)$"Could not find biome: {biome}"); continue; } List<EnvEntry> environments = val.m_environments; WeatherEntry[] array = value; foreach (WeatherEntry weatherEntry in array) { string envName = weatherEntry.Name; EnvSetup env = instance.m_environments.Find((EnvSetup e) => e.m_name.Equals(envName, StringComparison.OrdinalIgnoreCase)); if (env == null) { Logger.LogWarning((object)("Environment '" + envName + "' not found!")); continue; } EnvEntry val2 = environments.Find((EnvEntry it) => it.m_env == env); if (val2 == null) { environments.Add(new EnvEntry { m_env = env, m_weight = weatherEntry.Weight }); } else { val2.m_weight = weatherEntry.Weight; } Logger.LogInfo((object)$"Added '{envName}' to {biome} biome weather pool."); } } } private static IDictionary<Biome, WeatherEntry[]> GetWeatherOverrides() { Dictionary<Biome, WeatherEntry[]> dictionary = new Dictionary<Biome, WeatherEntry[]>(); dictionary.Add((Biome)1, new WeatherEntry[8] { new WeatherEntry { Name = "Clear", Weight = 3.5f }, new WeatherEntry { Name = "Heath clear", Weight = 0.8f }, new WeatherEntry { Name = "LightRain", Weight = 0.8f }, new WeatherEntry { Name = "Eikthyr", Weight = 0.2f }, new WeatherEntry { Name = "Misty", Weight = 0.2f }, new WeatherEntry { Name = "Overcast_UWU", Weight = 0.5f }, new WeatherEntry { Name = "Rain", Weight = 0.4f }, new WeatherEntry { Name = "ThunderStorm", Weight = 0.2f } }); dictionary.Add((Biome)8, new WeatherEntry[9] { new WeatherEntry { Name = "DeepForest Mist", Weight = 2.5f }, new WeatherEntry { Name = "EtherealMist_UWU", Weight = 0.4f }, new WeatherEntry { Name = "LightRain", Weight = 0.2f }, new WeatherEntry { Name = "Mistlands_rain", Weight = 0.1f }, new WeatherEntry { Name = "Misty", Weight = 0.2f }, new WeatherEntry { Name = "Overcast_UWU", Weight = 0.4f }, new WeatherEntry { Name = "Rain", Weight = 0.2f }, new WeatherEntry { Name = "ThunderStorm", Weight = 0.3f }, new WeatherEntry { Name = "nofogts", Weight = 0.3f } }); dictionary.Add((Biome)2, new WeatherEntry[10] { new WeatherEntry { Name = "DeepForest Mist", Weight = 1f }, new WeatherEntry { Name = "LightRain", Weight = 0.6f }, new WeatherEntry { Name = "Mistlands_rain", Weight = 0.3f }, new WeatherEntry { Name = "Misty", Weight = 1.2f }, new WeatherEntry { Name = "Overcast_UWU", Weight = 1f }, new WeatherEntry { Name = "Rain", Weight = 0.4f }, new WeatherEntry { Name = "Bonemass", Weight = 0.8f }, new WeatherEntry { Name = "SwampRain", Weight = 0.4f }, new WeatherEntry { Name = "ThunderStorm", Weight = 0.4f }, new WeatherEntry { Name = "nofogts", Weight = 0.4f } }); dictionary.Add((Biome)4, new WeatherEntry[6] { new WeatherEntry { Name = "Clear", Weight = 1f }, new WeatherEntry { Name = "FrostFog_UWU", Weight = 1f }, new WeatherEntry { Name = "OvercastSnow_UWU", Weight = 1.5f }, new WeatherEntry { Name = "Snow", Weight = 3f }, new WeatherEntry { Name = "SnowStorm", Weight = 1.2f }, new WeatherEntry { Name = "Twilight_SnowStorm", Weight = 0.6f } }); dictionary.Add((Biome)16, new WeatherEntry[8] { new WeatherEntry { Name = "DustStorm_UWU", Weight = 0.2f }, new WeatherEntry { Name = "GoldenDusk_UWU", Weight = 0.6f }, new WeatherEntry { Name = "Heath clear", Weight = 3.5f }, new WeatherEntry { Name = "LightRain", Weight = 0.8f }, new WeatherEntry { Name = "Eikthyr", Weight = 0.2f }, new WeatherEntry { Name = "Misty", Weight = 0.4f }, new WeatherEntry { Name = "Overcast_UWU", Weight = 0.5f }, new WeatherEntry { Name = "ThunderStorm", Weight = 0.2f } }); dictionary.Add((Biome)256, new WeatherEntry[10] { new WeatherEntry { Name = "Clear", Weight = 2.6f }, new WeatherEntry { Name = "EtherealMist_UWU", Weight = 0.3f }, new WeatherEntry { Name = "LightRain", Weight = 0.6f }, new WeatherEntry { Name = "Misty", Weight = 0.1f }, new WeatherEntry { Name = "Mistlands_thunder", Weight = 0.1f }, new WeatherEntry { Name = "Overcast_UWU", Weight = 1.2f }, new WeatherEntry { Name = "Rain", Weight = 0.4f }, new WeatherEntry { Name = "SeaSquall_UWU", Weight = 0.5f }, new WeatherEntry { Name = "ThunderStorm", Weight = 0.3f }, new WeatherEntry { Name = "nofogts", Weight = 0.3f } }); dictionary.Add((Biome)512, new WeatherEntry[8] { new WeatherEntry { Name = "Clear", Weight = 1f }, new WeatherEntry { Name = "EtherealMist_UWU", Weight = 0.4f }, new WeatherEntry { Name = "Eikthyr", Weight = 0.2f }, new WeatherEntry { Name = "Mistlands_clear", Weight = 1f }, new WeatherEntry { Name = "Mistlands_rain", Weight = 0.15f }, new WeatherEntry { Name = "Mistlands_thunder", Weight = 0.2f }, new WeatherEntry { Name = "Overcast_UWU", Weight = 0.3f }, new WeatherEntry { Name = "Rain", Weight = 0.15f } }); return dictionary; } } internal class WeatherEntry { internal string Name { get; set; } internal float Weight { get; set; } } internal sealed class NotMyShipFeature : FeatureBehaviour { protected override string Name => "NotMyShip"; protected override string Category => "Sailing"; protected override string Description => "Aggression toward ships will be reduced while no player is aboard"; protected override void OnPatch(Harmony harmony) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(BaseAI), "CanSenseTarget", new Type[1] { typeof(Character) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(NotMyShipFeature), "BaseAI_CanSenseTarget_Postfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void BaseAI_CanSenseTarget_Postfix(Character target, ref bool __result) { if (__result && !((Object)(object)target == (Object)null)) { Ship component = ((Component)target).GetComponent<Ship>(); if (!((Object)(object)component == (Object)null)) { __result = component.HasPlayerOnboard(); } } } } internal sealed class PaddleFasterFeature : FeatureBehaviour { private struct Ship_CustomFixedUpdate_State { internal float initialBackwardForce; } private static PaddleFasterFeature instance; private float forceBackward = 1.1f; private float forceForward = 1.2f; protected override string Name => "PaddleFaster"; protected override string Category => "Sailing"; protected override string Description => "Makes paddling forward/backward about twice as fast"; internal PaddleFasterFeature() { instance = this; } protected override void OnConfigure(ConfigFile config) { CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FloatCommand("UWUPaddleForce", "Changes the rate of paddling. Toggle PaddleFaster to reset.", adminOnly: true, isCheat: true, () => forceBackward, delegate(float value) { forceBackward = value; forceForward = value; })); } protected override void OnPatch(Harmony harmony) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Ship), "CustomFixedUpdate", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(PaddleFasterFeature), "Ship_CustomFixedUpdate_Prefix", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(PaddleFasterFeature), "Ship_CustomFixedUpdate_Postfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void Ship_CustomFixedUpdate_Prefix(Ship __instance, out Ship_CustomFixedUpdate_State __state) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 __state = new Ship_CustomFixedUpdate_State { initialBackwardForce = __instance.m_backwardForce }; Speed speed_UWU = __instance.GetSpeed_UWU(); float num = __instance.m_backwardForce * 1.5f; float num2 = (((int)speed_UWU != 1) ? instance.forceForward : instance.forceBackward); __instance.m_backwardForce = num * num2; } private static void Ship_CustomFixedUpdate_Postfix(Ship __instance, Ship_CustomFixedUpdate_State __state) { __instance.m_backwardForce = __state.initialBackwardForce; } } internal sealed class SailFasterFeature : FeatureBehaviour { private struct Ship_CustomFixedUpdate_State { internal float initialSailForceFactor; } private static SailFasterFeature instance; private const float MAST_COEFFICIENT_DEFAULT = 1f; private float MAST_COEFFICIENT_HALF = 1.1f; private float MAST_COEFFICIENT_FULL = 1.2f; protected override string Name => "SailFaster"; protected override string Category => "Sailing"; protected override string Description => "Makes ship sail speed about 75% faster."; internal SailFasterFeature() { instance = this; } protected override void OnConfigure(ConfigFile config) { CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FloatCommand("UWUMCHalf", "For debugging, The multiplier of sailforce when at half mast", adminOnly: true, isCheat: true, () => MAST_COEFFICIENT_HALF, delegate(float value) { MAST_COEFFICIENT_HALF = value; })); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FloatCommand("UWUMCFull", "For debugging, The multiplier of sailforce when at full mast", adminOnly: true, isCheat: true, () => MAST_COEFFICIENT_FULL, delegate(float value) { MAST_COEFFICIENT_FULL = value; })); } protected override void OnPatch(Harmony harmony) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Ship), "CustomFixedUpdate", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(SailFasterFeature), "Ship_CustomFixedUpdate_Prefix", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(SailFasterFeature), "Ship_CustomFixedUpdate_Postfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void Ship_CustomFixedUpdate_Prefix(Ship __instance, out Ship_CustomFixedUpdate_State __state) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 __state = new Ship_CustomFixedUpdate_State { initialSailForceFactor = __instance.m_sailForceFactor }; Speed speed_UWU = __instance.GetSpeed_UWU(); float num = __instance.m_sailForceFactor * 1.8f; float num2 = (((int)speed_UWU == 3) ? instance.MAST_COEFFICIENT_HALF : (((int)speed_UWU != 4) ? 1f : instance.MAST_COEFFICIENT_FULL)); __instance.m_sailForceFactor = num * num2; } private static void Ship_CustomFixedUpdate_Postfix(Ship __instance, Ship_CustomFixedUpdate_State __state) { __instance.m_sailForceFactor = __state.initialSailForceFactor; } } internal sealed class SailingGraceFeature : FeatureBehaviour { private static SailingGraceFeature instance; private float headwindReductionMin = 5.8f; private float headwindReductionMax = 7.2f; protected override string Name => "SailingGrace"; protected override string Category => "Sailing"; protected override string Description => "Significantly reduces the penalty for headwinds"; internal SailingGraceFeature() { instance = this; } protected override void OnConfigure(ConfigFile config) { CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FloatCommand("UWUHWRMin", "For debugging, the factor to reduce speed when at the minimum headwind", adminOnly: true, isCheat: true, () => headwindReductionMin, delegate(float value) { headwindReductionMin = value; })); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FloatCommand("UWUHWRMax", "For debugging, the factor to reduce speed when at the maximum headwind", adminOnly: true, isCheat: true, () => headwindReductionMax, delegate(float value) { headwindReductionMax = value; })); } protected override void OnPatch(Harmony harmony) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Ship), "GetSailForce", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(SailingGraceFeature), "Ship_GetSailForce_Prefix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool Ship_GetSailForce_Prefix(Ship __instance, float sailSize, ref Vector3 __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) //IL_00b8: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 windDir = EnvMan.instance.GetWindDir(); float num = Vector3.Angle(windDir, ((Component)__instance).transform.forward); Vector3 val; if (num > 135f && num < 225f) { float num2 = Mathf.Abs(num - 180f) / 45f; float num3 = Mathf.Lerp(instance.headwindReductionMax, instance.headwindReductionMin, num2); val = Vector3.Normalize(((Component)__instance).transform.forward) * (__instance.m_sailForceFactor * sailSize / num3); } else { float num4 = Mathf.Lerp(0.25f, 1f, EnvMan.instance.GetWindIntensity()); float num5 = __instance.GetWindAngleFactor() * num4; val = Vector3.Normalize(windDir + ((Component)__instance).transform.forward) * (num5 * __instance.m_sailForceFactor * sailSize); } Traverse obj = Traverse.Create((object)__instance); Traverse<Vector3> val2 = obj.Field<Vector3>("m_sailForce"); Traverse<Vector3> val3 = obj.Field<Vector3>("m_windChangeVelocity"); Vector3 value = val3.Value; Vector3 val4 = Vector3.SmoothDamp(val2.Value, val, ref value, 1f, 99f); val3.Value = value; val2.Value = val4; __result = val4; return false; } } internal sealed class ShipBonkiesFeature : FeatureBehaviour { protected override string Name => "ShipBonkies"; protected override string Category => "Sailing"; protected override string Description => "Hammer destructs ships for full refund when no player is aboard"; protected override void OnPatch(Harmony harmony) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Player), "RemovePiece", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ShipBonkiesFeature), "Player_RemovePiece_Prefix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool Player_RemovePiece_Prefix(ref bool __result) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (__result) { return true; } if ((Object)(object)Player.m_localPlayer == (Object)null) { return true; } int num = 268451840; RaycastHit val = default(RaycastHit); if (!Physics.Raycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, ref val, 10f, num)) { return true; } Ship componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Ship>(); if ((Object)(object)componentInParent == (Object)null) { return true; } if (componentInParent.HasPlayerOnboard()) { UserHud.Alert("Exit boat and try again"); __result = false; return false; } WearNTear component = ((Component)componentInParent).GetComponent<WearNTear>(); if ((Object)(object)component == (Object)null) { __result = false; return false; } component.Remove(false); __result = true; return false; } } internal class ShipNameplateFeature : FeatureBehaviour { private const float scanInterval = 5f; private float scanTimer = 5f; protected override string Name => "ShipNameplates"; protected override string Category => "Sailing"; protected override string Description => "Adds nameplates to boats"; protected override bool EnabledByDefault => true; private void FixedUpdate() { scanTimer += Time.deltaTime; if (scanTimer < 5f) { return; } scanTimer = 0f; foreach (Ship item in ObjectUtils.EmumerateInstanceOfType<Ship>()) { Nameplate.DecorateIfNecessary((MonoBehaviour)(object)item); } } protected override void OnUnpatch() { foreach (Ship item in ObjectUtils.EmumerateInstanceOfType<Ship>()) { Nameplate.RemoveNameplates((MonoBehaviour)(object)item); } scanTimer = 5f; } } internal sealed class ShipPinFeature : FeatureBehaviour { private class SailPinData { internal PinData PinData { get; set; } internal bool IsIconSetup { get; set; } = true; } private const float ICON_SCALE = 1.35f; private const float scanInterval = 5f; private const float updateInterval = 0.17f; private readonly Dictionary<ZDO, SailPinData> SailPins = new Dictionary<ZDO, SailPinData>(); private float scanTimer; private float updateTimer; protected override string Name => "ShipPin"; protected override string Category => "Sailing"; protected override string Description => "Tracks ships on the map"; private void FixedUpdate() { if (!((Object)(object)Minimap.instance == (Object)null)) { scanTimer += Time.deltaTime; if (scanTimer >= 5f) { scanTimer = 0f; RescanShips(); } updateTimer += Time.deltaTime; if (updateTimer >= 0.17f) { updateTimer = 0f; UpdateSailPins(); } } } protected override void OnUnpatch() { RemoveSailPins(); } private void RemoveSailPins() { foreach (SailPinData value in SailPins.Values) { Minimap.instance.RemovePin(value.PinData); } SailPins.Clear(); } private void RescanShips() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) List<ZDO> list = ObjectUtils.EnumerateZDOsOfTypeByPosition<Ship>().ToList(); foreach (ZDO item in list) { if (!SailPins.ContainsKey(item)) { Sprite buildIconFromZDO = IconUtils.GetBuildIconFromZDO(item); string labelFromZDO = NameCache.GetLabelFromZDO(item); PinData val = Minimap.instance.AddPin(item.GetPosition(), (PinType)(((Object)(object)buildIconFromZDO == (Object)null) ? 3 : 8), labelFromZDO, false, false, 0L, default(PlatformUserID)); if ((Object)(object)buildIconFromZDO != (Object)null) { val.m_icon = buildIconFromZDO; } SailPins[item] = new SailPinData { PinData = val }; } } foreach (KeyValuePair<ZDO, SailPinData> item2 in SailPins.ToList()) { ZDO key = item2.Key; if (!list.Contains(key)) { SailPinData value = item2.Value; Minimap.instance.RemovePin(value.PinData); SailPins.Remove(key); } } } private void UpdateSailPins() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0076: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<ZDO, SailPinData> sailPin in SailPins) { ZDO key = sailPin.Key; SailPinData value = sailPin.Value; if (value.IsIconSetup) { Image val = value.PinData?.m_iconElement; if ((Object)(object)val != (Object)null) { RectTransform rectTransform = ((Graphic)val).rectTransform; Vector3 localScale = ((Transform)rectTransform).localScale; localScale.x = 1.35f; localScale.y = 1.35f; ((Transform)rectTransform).localScale = localScale; value.IsIconSetup = true; } } value.PinData.m_name = NameCache.GetLabelFromZDO(key); value.PinData.m_pos = key.GetPosition(); } } } internal class ShipRenameFeature : FeatureBehaviour { protected static ShipRenameFeature instance; private ConfigEntry<KeyboardShortcut> RenameShortcut; protected override string Name => "ShipRename"; protected override string Category => "Sailing"; protected override string Description => "Allows renaming ships"; protected override bool EnabledByDefault => true; internal ShipRenameFeature() { instance = this; } protected override void OnConfigure(ConfigFile config) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) RenameShortcut = config.Bind<KeyboardShortcut>("Sailing", "ShipRenameKey", new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), "Key used for renaming ships"); } protected override void OnPatch(Harmony harmony) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(ShipControlls), "GetHoverText", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ShipRenameFeature), "ShipControlls_GetHoverText_Postfix", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void ShipControlls_GetHoverText_Postfix(ShipControlls __instance, ref string __result) { //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_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_0074: 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) KeyboardShortcut value = instance.RenameShortcut.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey; string text = ((object)(KeyCode)(ref mainKey)).ToString(); __result = NameCache.GetLabelFromObject((MonoBehaviour)(object)__instance.m_ship) + "\n\n" + __result + "\n[<color=yellow><b>" + text + "</b></color>] Rename"; value = instance.RenameShortcut.Value; if (!((KeyboardShortcut)(ref value)).IsDown() || UserHud.IsDialogOpen()) { return; } Ship ship = __instance.m_ship; if ((Object)(object)ship == (Object)null) { return; } ZNetView zNetView = ObjectUtils.GetZNetView((MonoBehaviour)(object)ship); if ((Object)(object)zNetView == (Object)null || !zNetView.IsValid()) { return; } ZDO zdo = zNetView.GetZDO(); if (zdo != null) { string initialValue = NameCache.GetLabelFromZNetView(zNetView) ?? ""; UserHud.Confirm("Rename ship", initialValue, delegate(string newTitle) { RPCManager.RenameObject(zdo, newTitle); UserHud.Alert("Ship renamed to " + newTitle); }); } } } internal sealed class SpeedometerFeature : FeatureBehaviour { private const float maxTime = 0.25f; private float currentSpeed; private float updateTimer; protected override string Name => "Speedometer"; protected override string Category => "Sailing"; protected override string Description => "If enabled, a speedometer will appear on the screen"; protected override bool EnabledByDefault => false; private void OnGUI() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle { fontSize = 32, alignment = (TextAnchor)4 }; val.normal.textColor = Color.white; string text = $"{currentSpeed:F1} m/s"; Rect val2 = new Rect(10f, 10f, 144f, 40f); GUI.backgroundColor = new Color(0f, 0f, 0f, 0.5f); GUI.Box(val2, GUIContent.none); GUI.Label(val2, text, val); } private void FixedUpdate() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { updateTimer += Time.deltaTime; if (!(updateTimer < 0.25f)) { updateTimer = 0f; Vector3 velocity = ((Character)localPlayer).GetVelocity(); currentSpeed = ((Vector3)(ref velocity)).magnitude; } } } } } namespace UWU.Extensions { internal static class EnvManExtensions { private static readonly Action<EnvMan, string> QueueEnvironmentDelegate; static EnvManExtensions() { QueueEnvironmentDelegate = AccessTools.MethodDelegate<Action<EnvMan, string>>(typeof(EnvMan).GetMethod("QueueEnvironment", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null), (object)null, true); } internal static void QueueEnvironment_UWU(this EnvMan self, string envName) { QueueEnvironmentDelegate(self, envName); } internal static void PrintEnvironments_UWU(this EnvMan self) { List<EnvSetup> environments = self.m_environments; if (environments == null || environments.Count == 0) { Console.instance.Print("[UWU] No environments found!"); return; } Console.instance.Print("[UWU] --- Known Weather Environments ---"); foreach (EnvSetup item in environments.OrderBy((EnvSetup it) => it.m_name)) { string text = ""; if (item.m_isFreezing) { text += " ❄\ufe0f"; } if (item.m_isCold && !item.m_isFreezing) { text += " \ud83e\uddca"; } if (item.m_isWet) { text += " \ud83d\udca7"; } Console.instance.Print("[UWU] • " + item.m_name + text); } } internal static void PrintBiomeEnvironmentConfig(this EnvMan self) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)self == (Object)null) { Logger.LogWarning((object)"[UWU] EnvMan not initialized yet!"); return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("=== UWU Biome Weather Overview ==="); foreach (BiomeEnvSetup biome in self.m_biomes) { if (biome == null || biome.m_environments == null || biome.m_environments.Count == 0) { continue; } float num = biome.m_environments.Sum((EnvEntry e) => e.m_weight); stringBuilder.AppendLine($"\nBiome: {biome.m_biome}"); foreach (EnvEntry environment in biome.m_environments) { string arg = environment.m_env?.m_name ?? "(null)"; float num2 = environment.m_weight / num * 100f; stringBuilder.AppendLine($" - {arg}: {environment.m_weight:F2} weight → {num2:F1}%"); } } Logger.LogInfo((object)stringBuilder.ToString()); } internal static void SetEnvironment_UWU(this EnvMan envMan, string envName) { string nameToLower = envName.ToLowerInvariant(); List<EnvSetup> list = envMan.m_environments.FindAll((EnvSetup e) => e.m_name.ToLowerInvariant().Contains(nameToLower)); if (list.Count < 1) { Console.instance.Print("No environment named '" + envName + "' found!"); return; } if (list.Count == 1) { string name = list[0].m_name; envMan.QueueEnvironment_UWU(name); Console.instance.Print("UWU: Weather set to '" + name + "' \ud83d\udca8"); return; } EnvSetup val = ((IEnumerable<EnvSetup>)list).FirstOrDefault((Func<EnvSetup, bool>)((EnvSetup it) => it.m_name.ToLowerInvariant() == nameToLower)); if (val != null) { envMan.QueueEnvironment_UWU(val.m_name); Console.instance.Print("UWU: Weather set to '" + val.m_name + "' \ud83d\udca8"); return; } foreach (EnvSetup item in list.OrderBy((EnvSetup it) => it.m_name)) { Console.instance.Print("[UWU] • " + item.m_name); } Console.instance.Print("Too many matching environments. Be specific"); } } internal static class ShipExtensions { private static readonly Func<Ship, bool> HaveControllingPlayerDelegate; private static readonly FieldRef<Ship, Speed> m_speedRef; static ShipExtensions() { m_speedRef = AccessTools.FieldRefAccess<Ship, Speed>("m_speed"); HaveControllingPlayerDelegate = AccessTools.MethodDelegate<Func<Ship, bool>>(typeof(Ship).GetMethod("HaveControllingPlayer", BindingFlags.Instance | BindingFlags.NonPublic), (object)null, true); } internal static bool GetControllingPlayer_UWU(this Ship ship) { return HaveControllingPlayerDelegate(ship); } internal static Speed GetSpeed_UWU(this Ship ship) { return m_speedRef.Invoke(ship); } } internal static class ZDOManExtensions { private static readonly FieldRef<ZDOMan, Dictionary<ZDOID, ZDO>> ObjectsByIdRef = AccessTools.FieldRefAccess<ZDOMan, Dictionary<ZDOID, ZDO>>("m_objectsByID"); private static readonly FieldRef<ZDOMan, List<ZDOID>> DestroySendListRef = AccessTools.FieldRefAccess<ZDOMan, List<ZDOID>>("m_destroySendList"); public static Dictionary<ZDOID, ZDO> GetObjectsById_UWU(this ZDOMan zdoMan) { return ObjectsByIdRef.Invoke(zdoMan); } public static List<ZDOID> GetDestroyedSendList_UWU(this ZDOMan zdoMan) { return DestroySendListRef.Invoke(zdoMan); } } internal static class ZNetSceneExtensions { private static readonly FieldRef<ZNetScene, Dictionary<ZDO, ZNetView>> Instances = AccessTools.FieldRefAccess<ZNetScene, Dictionary<ZDO, ZNetView>>("m_instances"); public static Dictionary<ZDO, ZNetView> GetInstances_UWU(this ZNetScene zNetScene) { return Instances.Invoke(zNetScene); } } } namespace UWU.Common { internal class CustomProperties { internal const string CUSTOM_LABEL_PROPERTY = "uwulabel"; } internal class EnvId { internal const string AshlandsAshrain = "Ashlands_ashrain"; internal const string AshlandsMisty = "Ashlands_misty"; internal const string AshlandsCinderRain = "Ashlands_CinderRain"; internal const string AshlandsStorm = "Ashlands_Storm"; internal const string AshlandsSeaStorm = "Ashlands_SeaStorm"; internal const string BlackForestMist = "DeepForest Mist"; internal const string Clear = "Clear"; internal const string Crypt = "Crypt"; internal const string LightRain = "LightRain"; internal const string MeadowsBoss = "Eikthyr"; internal const string MistlandsClear = "Mistlands_clear"; internal const string MistlandsRain = "Mistlands_rain"; internal const string MistlandsThunder = "Mistlands_thunder"; internal const string Misty = "Misty"; internal const string PlainsClear = "Heath clear"; internal const string Rain = "Rain"; internal const string Snow = "Snow"; internal const string SnowStorm = "SnowStorm"; internal const string SwampBoss = "Bonemass"; internal const string SwampRain = "SwampRain"; internal const string BlackForestBoss = "GDKing"; internal const string Ghosts = "Ghosts"; internal const string PlainsBoss = "GoblinKing"; internal const string MistlandsCrypt = "InfectedMine"; internal const string MistlandsBoss = "Queen"; internal const string Thunderstorm = "ThunderStorm"; internal const string ThunderStormNoFog = "nofogts"; internal const string TwilightClear = "Twilight_Clear"; internal const string TwilightSnow = "Twilight_Snow"; internal const string TwilightSnowStorm = "Twilight_SnowStorm"; internal const string Overcast = "Overcast_UWU"; internal const string OvercastSnow = "OvercastSnow_UWU"; internal const string FrostFog = "FrostFog_UWU"; internal const string GoldenDusk = "GoldenDusk_UWU"; internal const string DustStorm = "DustStorm_UWU"; internal const string SeaSquall = "SeaSquall_UWU"; internal const string EtherealMist = "EtherealMist_UWU"; } internal class IconUtils { private static readonly Dictionary<string, Sprite> iconCache = new Dictionary<string, Sprite>(); internal static Sprite GetBuildIconFromString(string pieceName) { if (iconCache.TryGetValue(pieceName, out var value)) { return value; } GameObject val = ((IEnumerable<GameObject>)PieceManager.Instance.GetPieceTable("Hammer")?.m_pieces).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => ((Object)p).name.Contains(pieceName))); if (!Object.op_Implicit((Object)(object)val)) { Logger.LogError((object)("Could not find piece with name containing '" + pieceName + "'")); return null; } value = val.GetComponent<Piece>()?.m_icon; iconCache[pieceName] = value; return value; } internal static Sprite GetBuildIconFromZDO(ZDO zdo) { string nameFromZDO = NameCache.GetNameFromZDO(zdo); if (string.IsNullOrWhiteSpace(nameFromZDO)) { return null; } nameFromZDO = nameFromZDO.Replace("(Clone)", "").Trim(); return GetBuildIconFromString(nameFromZDO); } } internal class Manifest { public const string PluginGUID = "com.ulvrikironpaw.uwu"; public const string PluginName = "Ulvrik's World Update"; public const string PluginVersion = "0.2.1"; } internal class NameCache { private static readonly Dictionary<int, string> nameCache; static NameCache() { nameCache = new Dictionary<int, string>(); PrefabManager.OnPrefabsRegistered += delegate { nameCache.Clear(); }; } internal static string GetPrefabName(int prefabHash) { if (nameCache.TryGetValue(prefabHash, out var value)) { return value; } ZNetScene instance = ZNetScene.instance; object obj; if (instance == null) { obj = null; } else { GameObject prefab = instance.GetPrefab(prefabHash); obj = ((prefab != null) ? ((Object)prefab).name : null); } if (obj == null) { obj = ""; } value = (string)obj; if (value == "") { return "(unknown prefab)"; } nameCache.Add(prefabHash, value); return value; } internal static string GetLabel(int prefabHash) { return ApplyNameOverrides(GetPrefabName(prefabHash)); } internal static string GetLabelFromObject(MonoBehaviour behavior) { ZNetView zNetView = ObjectUtils.GetZNetView(behavior); if ((Object)(object)zNetView == (Object)null) { return "(unknown ZNetView)"; } return GetLabelFromZNetView(zNetView); } internal static string GetLabelFromZNetView(ZNetView netView) { ZDO zDO = netView.GetZDO(); if (zDO == null) { return "(unknown ZDO)"; } return GetLabelFromZDO(zDO); } internal static string GetLabelFromZDO(ZDO zdo) { string customLabelFromZDO = GetCustomLabelFromZDO(zdo); if (!string.IsNullOrWhiteSpace(customLabelFromZDO)) { return customLabelFromZDO; } int prefab = zdo.GetPrefab(); if (prefab == 0) { return "(unknown Prefab)"; } return GetLabel(prefab); } internal static string GetNameFromZDO(ZDO zdo) { return GetPrefabName(zdo.GetPrefab()); } internal static string GetCustomLabelFromZDO(ZDO zdo) { return zdo.GetString("uwulabel", "") ?? ""; } private static string ApplyNameOverrides(string prefabName) { if (string.IsNullOrWhiteSpace(prefabName)) { return "(unknown object name)"; } string text = prefabName.ToLowerInvariant(); if (!(text == "vikingship")) { if (text == "vikingship_ashlands") { return "Drakkar"; } return prefabName; } return "Longship"; } } internal class ObjectUtils { [CompilerGenerated] private sealed class <EmumerateInstanceOfType>d__3<T> : IEnumerable<T>, IEnumerable, IEnumerator<T>, IDisposable, IEnumerator where T : MonoBehaviour { private int <>1__state; private T <>2__current; private int <>l__initialThreadId; private Dictionary<ZDO, ZNetView>.ValueCollection.Enumerator <>7__wrap1; T IEnumerator<T>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EmumerateInstanceOfType>d__3(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = default(Dictionary<ZDO, ZNetView>.ValueCollection.Enumerator); <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; PrefabCache<T>.Build(); ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return false; } Dictionary<ZDO, ZNetView> instances_UWU = instance.GetInstances_UWU(); <>7__wrap1 = instances_UWU.Values.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { ZNetView current = <>7__wrap1.Current; if ((Object)(object)current == (Object)null) { continue; } ZDO zDO = current.GetZDO(); if (zDO != null && PrefabCache<T>.Contains(zDO.GetPrefab())) { T component = ((Component)current).GetComponent<T>(); if ((Object)(object)component != (Object)null) { <>2__current = component; <>1__state = 1; return true; } } } <>m__Finally1(); <>7__wrap1 = default(Dictionary<ZDO, ZNetView>.ValueCollection.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<T> IEnumerable<T>.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new <EmumerateInstanceOfType>d__3<T>(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<T>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <EnumerateLoadedZDOsOfType>d__2<T> : IEnumerable<ZDO>, IEnumerable, IEnumerator<ZDO>, IDisposable, IEnumerator where T : MonoBehaviour { private int <>1__state; private ZDO <>2__current; private int <>l__initialThreadId; private Dictionary<ZDO, ZNetView>.ValueCollection.Enumerator <>7__wrap1; ZDO IEnumerator<ZDO>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EnumerateLoadedZDOsOfType>d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = default(Dictionary<ZDO, ZNetView>.ValueCollection.Enumerator); <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; PrefabCache<T>.Build(); ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return false; } Dictionary<ZDO, ZNetView> instances_UWU = instance.GetInstances_UWU(); <>7__wrap1 = instances_UWU.Values.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { ZNetView current = <>7__wrap1.Current; if (!((Object)(object)current == (Object)null)) { ZDO zDO = current.GetZDO(); if (zDO != null && PrefabCache<T>.Contains(zDO.GetPrefab())) { <>2__current = zDO; <>1__state = 1; return true; } } } <>m__Finally1(); <>7__wrap1 = default(Dictionary<ZDO, ZNetView>.ValueCollection.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<ZDO> IEnumerable<ZDO>.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new <EnumerateLoadedZDOsOfType>d__2<T>(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<ZDO>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <EnumerateZDOsOfType>d__0<T> : IEnumerable<ZDO>, IEnumerable, IEnumerator<ZDO>, IDisposable, IEnumerator where T : MonoBehaviour { private int <>1__state; private ZDO <>2__current; private int <>l__initialThreadId; private HashSet<ZDOID> <destroyedSet>5__2; private Dictionary<ZDOID, ZDO>.ValueCollection.Enumerator <>7__wrap2; ZDO IEnumerator<ZDO>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EnumerateZDOsOfType>d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <destroyedSet>5__2 = null; <>7__wrap2 = default(Dictionary<ZDOID, ZDO>.ValueCollection.Enumerator); <>1__state = -2; } private bool MoveNext() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; PrefabCache<T>.Build(); ZDOMan instance = ZDOMan.instance; if (instance == null) { return false; } Dictionary<ZDOID, ZDO> objectsById_UWU = instance.GetObjectsById_UWU(); if (objectsById_UWU == null || objectsById_UWU.Count == 0) { return false; } List<ZDOID> destroyedSendList_UWU = instance.GetDestroyedSendList_UWU(); <destroyedSet>5__2 = ((destroyedSendList_UWU == null || destroyedSendList_UWU.Count == 0) ? null : new HashSet<ZDOID>(destroyedSendList_UWU)); <>7__wrap2 = objectsById_UWU.Values.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (<>7__wrap2.MoveNext()) { ZDO current = <>7__wrap2.Current; int prefab = current.GetPrefab(); if (prefab != 0 && PrefabCache<T>.Contains(prefab) && (<destroyedSet>5__2 == null || !<destroyedSet>5__2.Contains(current.m_uid))) { <>2__current = current; <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap2 = default(Dictionary<ZDOID, ZDO>.ValueCollection.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<ZDO> IEnumerable<ZDO>.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new <EnumerateZDOsOfType>d__0<T>(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<ZDO>)this).GetEnumerator(); } } [IteratorStateMachine(typeof(<EnumerateZDOsOfType>d__0<>))] internal static IEnumerable<ZDO> EnumerateZDOsOfType<T>() where T : MonoBehaviour { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EnumerateZDOsOfType>d__0<T>(-2); } internal static IEnumerable<ZDO> EnumerateZDOsOfTypeByPosition<T>() where T : MonoBehaviour { return from zdo in EnumerateZDOsOfType<T>() orderby zdo.GetPosition().z descending, zdo.GetPosition().x select zdo; } [IteratorStateMachine(typeof(<EnumerateLoadedZDOsOfType>d__2<>))] internal static IEnumerable<ZDO> EnumerateLoadedZDOsOfType<T>() where T : MonoBehaviour { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EnumerateLoadedZDOsOfType>d__2<T>(-2); } [IteratorStateMachine(typeof(<EmumerateInstanceOfType>d__3<>))] internal static IEnumerable<T> EmumerateInstanceOfType<T>() where T : MonoBehaviour { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EmumerateInstanceOfType>d__3<T>(-2); } internal static ZNetView GetZNetView(MonoBehaviour behavior) { return ((Component)behavior).gameObject.GetComponent<ZNetView>(); } } internal static class PhysicsUtils { internal static Vector3 GetTopCenterPoint(Transform attachTransform) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) Renderer[] componentsInChildren = ((Component)attachTransform).GetComponentsInChildren<Renderer>(); if (componentsInChildren.Length == 0) { return attachTransform.position; } Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } return new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).center.z); } } internal static class PrefabCache<T> { private static HashSet<int> hashcodeCache; private static bool isBuilt; static PrefabCache() { hashcodeCache = new HashSet<int>(); isBuilt = false; PrefabManager.OnPrefabsRegistered += delegate { Build(forceRebuild: true); }; } internal static bool Build(bool forceRebuild = false) { if (isBuilt && !forceRebuild) { return true; } ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return false; } HashSet<int> hashSet = new HashSet<int>(); Dictionary<int, string> dictionary = new Dictionary<int, string>(); new Dictionary<int, string>(); foreach (GameObject prefab in instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null) && prefab.GetComponent<T>() != null) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); hashSet.Add(stableHashCode); dictionary[stableHashCode] = ((Object)prefab).name; } } isBuilt = true; hashcodeCache = hashSet; return true; } internal static bool Contains(int prefabHash) { if (!isBuilt) { Build(); } return hashcodeCache.Contains(prefabHash); } } internal static class RPCManager { private const string SET_OBJECT_LABEL_NAME = "UWU_PerformRename"; private static bool isRegistered; internal static void RegisterRPCs() { if (!isRegistered) { Logger.LogDebug((object)"Registering RPCs"); ZRoutedRpc.instance.Register<ZPackage>("UWU_PerformRename", (Action<long, ZPackage>)RPC_ServerReceiveRename); isRegistered = true; } } internal static void RenameObject(MonoBehaviour target, string label) { RenameObject(((Component)target).GetComponent<ZNetView>(), label); } internal static void RenameObject(ZNetView zNetView, string label) { if (!((Object)(object)zNetView == (Object)null)) { ZDO zDO = zNetView.GetZDO(); if (zDO != null) { RenameObject(zDO, label); } } } internal static void RenameObject(ZDO target, string label) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (target != null) { MutateZDO(target, "uwulabel", label, ZNet.instance.IsServer()); long serverPeerID = ZRoutedRpc.instance.GetServerPeerID(); if (serverPeerID == 0L) { Logger.LogWarning((object)"No server peer"); return; } ZPackage val = new ZPackage(); val.Write(target.m_uid); val.Write(label); Logger.LogInfo((object)"Sending RPC: UWU_PerformRename"); ZRoutedRpc.instance.InvokeRoutedRPC(serverPeerID, "UWU_PerformRename", new object[1] { val }); } } private static void RPC_ServerReceiveRename(long sender, ZPackage package) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) ZDOID val = package.ReadZDOID(); string value = package.ReadString(); ZDO zDO = ZDOMan.instance.GetZDO(val); if (zDO != null) { Logger.LogInfo((object)$"Received RPC to {((ZDOID)(ref zDO.m_uid)).UserID} {((ZDOID)(ref zDO.m_uid)).ID}"); MutateZDO(zDO, "uwulabel", value, forceSync: false); } } private static void MutateZDO(ZDO target, string property, string value, bool forceSync) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) target.Set(property, value); if (forceSync) { ZDOMan.instance.ForceSendZDO(target.m_uid); } } } internal class UserHud { internal static void Alert(string message) { MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, message, 0, (Sprite)null, false); } } internal static bool IsDialogOpen() { return TextInput.IsVisible(); } internal static void Confirm(string title, string initialValue, Action<string> onComplete) { TextDialogMediator textDialogMediator = new TextDialogMediator(); textDialogMediator.SetText(initialValue); textDialogMediator.OnComplete = onComplete; TextInput.instance.RequestText((TextReceiver)(object)textDialogMediator, title, 24); } } internal class TextDialogMediator : TextReceiver { private string text = ""; internal Action<string> OnComplete { get; set; } public string GetText() { return text; } public void SetText(string text) { this.text = text; OnComplete?.Invoke(text); } } internal enum ValheimLayer { Default = 0, TransparentFX = 1, IgnoreRaycast = 2, Water = 4, UI = 5, Effect = 8, Character = 9, Piece = 10, Terrain = 11, Item = 12, Ghost = 13, CharacterTrigger = 14, StaticSolid = 15, PieceNonsolid = 16, CharacterGhost = 17, Hitbox = 18, Skybox = 19, DefaultSmall = 20, WaterVolume = 21, Weapon = 22, Blocker = 23, Pathblocker = 24, Viewblock = 25, CharacterNet = 26, CharacterNoenv = 27, Vehicle = 28, Smoke = 31 } } namespace UWU.Commands { internal class BoolCommand : ConsoleCommand { private readonly Func<bool> getValue; private readonly Action<bool> setValue; private readonly bool adminOnly; private readonly string name; private readonly string help; private readonly bool isCheat; public override string Name => name; public override string Help => help; public override bool IsCheat => isCheat; internal BoolCommand(string name, string help, bool adminOnly, bool isCheat, Func<bool> getValue, Action<bool> setValue) { this.name = name; this.help = help; this.adminOnly = adminOnly; this.isCheat = isCheat; this.getValue = getValue; this.setValue = setValue; } public override List<string> CommandOptionList() { return new List<string>(); } public override void Run(string[] args) { if (adminOnly && !SynchronizationManager.Instance.PlayerIsAdmin) { Console.instance.Print(((ConsoleCommand)this).Name + " can only be set by an Admin"); return; } if (args.Length == 0) { Console.instance.Print($"{((ConsoleCommand)this).Name} is {getValue()}"); return; } string text = args[0].ToLower(); if (!(text == "true")) { if (text == "false") { setValue(obj: false); Console.instance.Print($"{((ConsoleCommand)this).Name} set to {false}"); } else { Console.instance.Print(((ConsoleCommand)this).Name + " not set. Invalid value"); } } else { setValue(obj: true); Console.instance.Print($"{((ConsoleCommand)this).Name} set to {true}"); } } } internal class FloatCommand : ConsoleCommand { private readonly Func<float> getValue; private readonly Action<float> setValue; private readonly bool adminOnly; private readonly string name; private readonly string help; private readonly bool isCheat; public override string Name => name; public override string Help => help; public override bool IsCheat => isCheat; internal FloatCommand(string name, string help, bool adminOnly, bool isCheat, Func<float> getValue, Action<float> setValue) { this.name = name; this.help = help; this.adminOnly = adminOnly; this.isCheat = isCheat; this.getValue = getValue; this.setValue = setValue; } public override List<string> CommandOptionList() { return new List<string>(); } public override void Run(string[] args) { if (adminOnly && !SynchronizationManager.Instance.PlayerIsAdmin) { Console.instance.Print(((ConsoleCommand)this).Name + " can only be set by an Admin"); return; } if (args.Length == 0) { Console.instance.Print($"{((ConsoleCommand)this).Name} is {getValue()}"); return; } try { float num = float.Parse(args[0]); setValue(num); Console.instance.Print($"{((ConsoleCommand)this).Name} set to {num}"); } catch { Console.instance.Print(((ConsoleCommand)this).Name + " not set. Invalid value"); } } } internal class StringCommand : ConsoleCommand { private readonly Func<string> getValue; private readonly Action<string> setValue; private readonly bool adminOnly; private readonly string name; private readonly string help; private readonly bool isCheat; public override string Name => name; public override string Help => help; public override bool IsCheat => isCheat; internal StringCommand(string name, string help, bool adminOnly, bool isCheat, Func<string> getValue, Action<string> setValue) { this.name = name; this.help = help; this.adminOnly = adminOnly; this.isCheat = isCheat; this.getValue = getValue; this.setValue = setValue; } public override List<string> CommandOptionList() { return new List<string>(); } public override void Run(string[] args) { if (adminOnly && !SynchronizationManager.Instance.PlayerIsAdmin) { Console.instance.Print(((ConsoleCommand)this).Name + " can only be set by an Admin"); return; } if (args.Length == 0) { Console.instance.Print(((ConsoleCommand)this).Name + " is " + getValue()); return; } string text = args[0]; setValue(text); Console.instance.Print(((ConsoleCommand)this).Name + " set to " + text); } } internal class VoidCommand : ConsoleCommand { private readonly Action<string[]> action; private readonly bool adminOnly; private readonly string name; private readonly string help; private readonly bool isCheat; public override string Name => name; public override string Help => help; public override bool IsCheat => isCheat; internal VoidCommand(string name, string help, bool adminOnly, bool isCheat, Action<string[]> action) { this.name = name; this.help = help; this.adminOnly = adminOnly; this.isCheat = isCheat; this.action = action; } public override List<string> CommandOptionList() { return new List<string>(); } public override void Run(string[] args) { if (adminOnly && !SynchronizationManager.Instance.PlayerIsAdmin) { Console.instance.Print(((ConsoleCommand)this).Name + " can only be run by an Admin"); } else { action(args); } } } } namespace UWU.Behaviors { internal class Environments { [CompilerGenerated] private sealed class <GetUnregistedEnvironments>d__1 : IEnumerable<EnvSetup>, IEnumerable, IEnumerator<EnvSetup>, IDisposable, IEnumerator { private int <>1__state; private EnvSetup <>2__current; private int <>l__initialThreadId; private EnvMan instance; public EnvMan <>3__instance; EnvSetup IEnumerator<EnvSetup>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GetUnregistedEnvironments>d__1(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = CreateOvercastEnvironment(instance); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = CreateOvercastSnowEnvironment(instance); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = CreateFrostFogEnvironment(instance); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = CreateGoldenDuskEnvironment(instance); <>1__state = 4; return true; case 4: <>1__state = -1; <>2__current = CreateDustStormEnvironment(instance); <>1__state = 5; return true; case 5: <>1__state = -1; <>2__current = CreateSeaSquallEnvironment(instance); <>1__state = 6; return true; case 6: <>1__state = -1; <>2__current = CreateEtherealMistEnvironment(instance); <>1__state = 7; return true; case 7: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<EnvSetup> IEnumerable<EnvSetup>.GetEnumerator() { <GetUnregistedEnvironments>d__1 <GetUnregistedEnvironments>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <GetUnregistedEnvironments>d__ = this; } else { <GetUnregistedEnvironments>d__ = new <GetUnregistedEnvironments>d__1(0); } <GetUnregistedEnvironments>d__.instance = <>3__instance; return <GetUnregistedEnvironments>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<EnvSetup>)this).GetEnumerator(); } } internal static void AddCustomEnvironments(EnvMan instance) { foreach (EnvSetup unregistedEnvironment in GetUnregistedEnvironments(instance)) { if (unregistedEnvironment != null) { instance.m_environments.Add(unregistedEnvironment); Logger.LogInfo((object)("Added new environment: " + unregistedEnvironment.m_name)); } } } [IteratorStateMachine(typeof(<GetUnregistedEnvironments>d__1))] private static IEnumerable<EnvSetup> GetUnregistedEnvironments(EnvMan instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GetUnregistedEnvironments>d__1(-2) { <>3__instance = instance }; } private static EnvSetup CreateOvercastEnvironment(EnvMan instance) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0156: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) if (instance.m_environments.Any((EnvSetup it) => it.m_name == "Overcast_UWU")) { return null; } EnvSetup val = instance.m_environments.Find((EnvSetup e) => e.m_name == "Rain"); if (val == null) { Logger.LogWarning((object)"Could not find base environment 'Rain'!"); return null; } EnvSetup val2 = instance.m_environments.Find((EnvSetup e) => e.m_name == "Clear"); if (val2 == null) { Logger.LogWarning((object)"Could not find base environment 'Clear'!"); return null; } EnvSetup obj = val.Clone(); obj.m_name = "Overcast_UWU"; obj.m_rainCloudAlpha = 0.5f; obj.m_fogDensityDay = 0.002f; obj.m_fogDensityNight = 0.005f; obj.m_windMin = 0.1f; obj.m_windMax = 0.25f; obj.m_rainCloudAlpha = 0.35f; obj.m_isWet = false; obj.m_alwaysDark = false; obj.m_fogColorDay = new Color(0.65f, 0.65f, 0.68f, 1f); obj.m_fogColorEvening = new Color(0.55f, 0.55f, 0.6f, 1f); obj.m_fogColorNight = new Color(0.4f, 0.4f, 0.45f, 1f); obj.m_fogColorSunDay = new Color(0.8f, 0.8f, 0.85f, 1f); obj.m_ambientLoop = val2.m_ambientLoop; obj.m_psystems = (GameObject[])(((object)val2.m_psystems?.ToArray()) ?? ((object)new GameObject[0])); return obj; } private static EnvSetup CreateOvercastSnowEnvironment(EnvMan instance) { //IL_0101: 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) //IL_0120: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) if (instance.m_environments.Any((EnvSetup it) => it.m_name == "OvercastSnow_UWU")) { return null; } EnvSetup val = instance.m_environments.Find((EnvSetup e) => e.m_name == "Snow") ?? instance.m_environments.Find((EnvSetup e) => e.m_name == "SnowStorm"); if (val == null) { Logger.LogWarning((object)"Could not find base environment 'Snow' or 'SnowStorm'!"); return null; } EnvSetup obj = val.Clone(); obj.m_name = "OvercastSnow_UWU"; obj.m_rainCloudAlpha = 0.4f; obj.m_fogDensityDay = 0.003f; obj.m_fogDensityNight = 0.006f; obj.m_windMin = 0.05f; obj.m_windMax = 0.2f; obj.m_isWet = false; obj.m_isFreezing = true; obj.m_fogColorDay = new Color(0.75f, 0.75f, 0.8f, 1f); obj.m_fogColorEvening = new Color(0.65f, 0.65f, 0.7f, 1f); obj.m_fogColorNight = new Color(0.5f, 0.5f, 0.55f, 1f); obj.m_fogColorSunDay = new Color(0.8f, 0.8f, 0.85f, 1f); obj.m_sunColorDay = new Color(0.9f, 0.9f, 1f, 1f); return obj; } private static EnvSetup CreateFrostFogEnvironment(EnvMan instance) { //IL_00de: 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_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_011c: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) if (instance.m_environments.Any((EnvSetup it) => it.m_name == "FrostFog_UWU")) { return null; } EnvSetup val = instance.m_environments.Find((EnvSetup e) => e.m_name == "Snow"); if (val == null) { Logger.LogWarning((object)"Could not find base environment 'Snow'!"); return null; } EnvSetup obj = val.Clone(); obj.m_name = "FrostFog_UWU"; obj.m_rainCloudAlpha = 0.2f; obj.m_fogDensityDay = 0.006f; obj.m_fogDensityNight = 0.012f; obj.m_windMin = 0f; obj.m_windMax = 0.1f; obj.m_isWet = false; obj.m_isFreezing = true; obj.m_psystems = Array.Empty<GameObject>(); obj.m_fogColorDay = new Color(0.7f, 0.8f, 0.9f, 1f); obj.m_fogColorEvening = new Color(0.6f, 0.7f, 0.8f, 1f); obj.m_fogColorNight = new Color(0.45f, 0.5f, 0.55f, 1f); obj.m_fogColorSunDay = new Color(0.9f, 0.95f, 1f, 1f); obj.m_sunColorDay = new Color(0.8f, 0.85f, 1f, 1f); return obj; } private static EnvSetup CreateGoldenDuskEnvironment(EnvMan instance) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00f0: Unknown result type (might be due to invalid IL or missing references) if (instance.m_environments.Any((EnvSetup it) => it.m_name == "GoldenDusk_UWU")) { return null; } EnvSetup val = instance.m_environments.Find((EnvSetup e) => e.m_name == "Heath clear"); if (val == null) { Logger.LogWarning((object)"Could not find base environment 'Heath clear'!"); return null; } EnvSetup obj = val.Clone(); obj.m_name = "GoldenDusk_UWU"; obj.m_fogColorDay = new Color(1f, 0.85f, 0.6f, 1f); obj.m_fogColorEvening = new Color(1f, 0.7f, 0.4f, 1f); obj.m_fogColorNight = new Color(0.4f, 0.3f, 0.25f, 1f); obj.m_fogColorSunDay = new Color(1.1f, 0.9f, 0.7f, 1f); obj.m_fogDensityDay = 0.0015f; obj.m_fogDensityNight = 0.0025f; obj.m_lightIntensityDay = 1.1f; obj.m_lightIntensityNight = 0.8f; obj.m_windMin = 0.05f; obj.m_windMax = 0.2f; obj.m_rainCloudAlpha = 0.15f; obj.m_isWet = false; obj.m_isColdAtNight = true; return obj; } private static EnvSetup CreateSeaSquallEnvironment(EnvMan instance) { //IL_00af: 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_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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) if (instance.m_environments.Any((EnvSetup it) => it.m_name == "SeaSquall_UWU")) { return null; } EnvSetup val = instance.m_environments.Find((EnvSetup e) => e.m_name == "ThunderStorm"); if (val == null) { Logger.LogWarning((object)"Could not find base environment 'ThunderStorm'!"); return null; } EnvSetup obj = val.Clone(); obj.m_name = "SeaSquall_UWU"; obj.m_rainCloudAlpha = 0.85f; obj.m_fogDensityDay = 0.03f; obj.m_fogDensityNight = 0.045f; obj.m_fogColorDay = new Color(0.25f, 0.3f, 0.35f, 1f); obj.m_fogColorNight = new Color(0.1f, 0.12f, 0.15f, 1f); obj.m_ambColorDay = new Color(0.35f, 0.35f, 0.4f, 1f); obj.m_ambColorNight = new Color(0.15f, 0.18f, 0.22f, 1f); obj.m_windMin = 0.8f; obj.m_windMax = 1.4f; obj.m_rainCloudAlpha = 0.8f; obj.m_isWet = true; obj.m_isCold = true; obj.m_alwaysDark = true; return obj; } private static EnvSetup CreateDustStormEnvironment(EnvMan instance) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00f0: Unknown result type (might be due to invalid IL or missing references) if (instance.m_environments.Any((EnvSetup it) => it.m_name == "DustStorm_UWU")) { return null; } EnvSetup val = instance.m_environments.Find((EnvSetup e) => e.m_name == "ThunderStorm"); if (val == null) { Logger.LogWarning((object)"Could not find base environment 'ThunderStorm'!"); return null; } EnvSetup obj = val.Clone(); obj.m_name = "DustStorm_UWU"; obj.m_fogColorDay = new Color(0.8f, 0.7f, 0.5f, 1f); obj.m_fogColorEvening = new Color(0.7f, 0.55f, 0.35f, 1f); obj.m_fogColorNight = new Color(0.4f, 0.3f, 0.2f, 1f); obj.m_fogColorSunDay = new Color(1f, 0.85f, 0.55f, 1f); obj.m_fogDensityDay = 0.01f; obj.m_fogDensityNight = 0.012f; obj.m_windMin = 0.4f; obj.m_windMax = 0.7f; obj.m_isWet = false; obj.m_rainCloudAlpha = 0.4f; obj.m_psystems = (GameObject[])(object)new GameObject[0]; obj.m_lightIntensityDay = 0.7f; obj.m_lightIntensityNight = 0.6f; return obj; } private static EnvSetup CreateEtherealMistEnvironment(EnvMan instance) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (instance.m_environments.Any((EnvSetup it) => it.m_name == "EtherealMist_UWU")) { return null; } EnvSetup val = instance.m_environments.Find((EnvSetup e) => e.m_name == "Mistlands_clear"); if (val == null) { Logger.LogWarning((object)"Base environment 'Mistlands_clear' not found!"); return null; } EnvSetup obj = val.Clone(); obj.m_name = "EtherealMist_UWU"; obj.m_fogDensityDay = 0.015f; obj.m_fogDensityNight = 0.02f; obj.m_fogColorDay = new Color(0.65f, 0.7f, 0.8f, 1f); obj.m_fogColorNight = new Color(0.45f, 0.5f, 0.6f, 1f); obj.m_fogColorSunDay = new Color(0.8f, 0.85f, 0.9f, 1f); obj.m_windMin = 0.05f; obj.m_windMax = 0.15f; return obj; } } internal abstract class FeatureBehaviour : MonoBehaviour { private readonly Harmony harmony; protected ConfigEntry<bool> FeatureEnabled { get; set; } protected abstract string Name { get; } protected abstract string Category { get; } protected abstract string Description { get; } protected virtual bool EnabledByDefault => true; protected virtual bool Synced => true; protected FeatureBehaviour() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown harmony = new Harmony("com.ulvrikironpaw.uwu." + Name.ToLower()); } protected virtual void OnConfigure(ConfigFile config) { } protected virtual void OnPatch(Harmony harmony) { } protected virtual void OnUnpatch() { } internal void Configure(ConfigFile config) { FeatureEnabled = ConfigFileExtensions.BindConfig<bool>(config, Category, Name, EnabledByDefault, Description, Synced, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); ((Behaviour)this).enabled = FeatureEnabled.Value; CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new BoolCommand("UWU" + Name, "Enables or disables the UWU" + Name + " option", Synced, isCheat: true, () => FeatureEnabled.Value, delegate(bool value) { FeatureEnabled.Value = value; })); FeatureEnabled.SettingChanged += delegate { Logger.LogInfo((object)(harmony.Id + " settings has changed to " + FeatureEnabled.Value)); if (FeatureEnabled.Value) { Patch(); } else { Unpatch(); } ((Behaviour)this).enabled = FeatureEnabled.Value; }; OnConfigure(config); if (FeatureEnabled.Value) { Patch(); } } private void Patch() { OnPatch(harmony); Logger.LogInfo((object)(harmony.Id + " is applied")); } private void Unpatch() { harmony.UnpatchSelf(); OnUnpatch(); Logger.LogInfo((object)(harmony.Id + " is unapplied")); } } internal class Nameplate : MonoBehaviour { [CompilerGenerated] private sealed class <Start>d__3 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Nameplate <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Start>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0097: 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) //IL_00d3: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; Nameplate nameplate = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; nameplate.textMeshPro = ((Component)nameplate).gameObject.AddComponent<TextMeshPro>(); ((TMP_Text)nameplate.textMeshPro).font = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name == "Valheim-Norse")); ((TMP_Text)nameplate.textMeshPro).fontStyle = (FontStyles)1; ((TMP_Text)nameplate.textMeshPro).fontSize = 9f; ((Graphic)nameplate.textMeshPro).color = new Color(1f, 1f, 1f); ((TMP_Text)nameplate.textMeshPro).alignment = (TextAlignmentOptions)514; ((TMP_Text)nameplate.textMeshPro).enableAutoSizing = false; Material val3 = new Material(((TMP_Asset)((TMP_Text)nameplate.textMeshPro).font).material); val3.EnableKeyword("OUTLINE_ON"); val3.SetColor("_OutlineColor", new Color(0f, 0f, 0.3f, 1f)); val3.SetFloat("_OutlineWidth", 0.085f); ((TMP_Text)nameplate.textMeshPro).fontMaterial = val3; <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; } case 1: { <>1__state = -1; Transform val; if (nameplate.target is Ship) { Transform transform = ((Component)nameplate.target).transform; object obj = ((transform != null) ? transform.Find("ship/visual/mast/pillar") : null); if (obj == null) { Transform transform2 = ((Component)nameplate.target).transform; obj = ((transform2 != null) ? transform2.Find("ship/visual/Mast/mast") : null); if (obj == null) { Transform transform3 = ((Component)nameplate.target).transform; obj = ((transform3 != null) ? transform3.Find("ship/mast") : null); } } val = (Transform)obj; } else { val = null; } Transform val2 = val; if ((Object)(object)val2 == (Object)null) { Logger.LogInfo((object)("Unable to find nameplate anchor for " + NameCache.GetLabelFromObject(nameplate.target) + ", falling back to transform")); val2 = ((Component)nameplate.target).transform; } if ((Object)(object)val2 == (Object)null) { return false; } Vector3 topCenterPoint = PhysicsUtils.GetTopCenterPoint(val2); nameplate.parentObject.transform.position = topCenterPoint + Vector3.up * 0.5f; nameplate.parentObject.transform.SetParent(((Component)nameplate.target).transform, true); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal MonoBehaviour target; internal GameObject parentObject; private TextMeshPro textMeshPro; [IteratorStateMachine(typeof(<Start>d__3))] private IEnumerator Start() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Start>d__3(0) { <>4__this = this }; } private void LateUpdate() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Camera.main == (Object)null || (Object)(object)target == (Object)null || (Object)(object)textMeshPro == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } MonoBehaviour obj = target; Ship val = (Ship)(object)((obj is Ship) ? obj : null); if (val != null) { bool num = (Object)(object)localPlayer.GetControlledShip() == (Object)(object)val || (Object)(object)((Character)localPlayer).GetStandingOnShip() == (Object)(object)val; bool controllingPlayer_UWU = val.GetControllingPlayer_UWU(); bool flag = !num || !controllingPlayer_UWU; ((Behaviour)textMeshPro).enabled = flag; if (!flag) { return; } } Vector3 val2 = ((Component)this).transform.position - ((Component)Camera.main).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.001f) { ((Component)this).transform.rotation = Quaternion.LookRotation(val2); } string labelFromObject = NameCache.GetLabelFromObject(target); ((TMP_Text)textMeshPro).text = (string.IsNullOrWhiteSpace(labelFromObject) ? "" : labelFromObject.Trim()); } internal static void RemoveNameplates(MonoBehaviour target) { Nameplate component = ((Component)target).gameObject.GetComponent<Nameplate>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } internal static void DecorateIfNecessary(MonoBehaviour target) { if ((Object)(object)((Component)target).GetComponentInChildren<Nameplate>() == (Object)null) { Decorate(target); } } internal static void Decorate(MonoBehaviour target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(); val.transform.localScale = Vector3.one; Nameplate nameplate = val.AddComponent<Nameplate>(); nameplate.target = target; nameplate.parentObject = val; } } }