using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using HarmonyLibs; using ItemManager; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using PieceManager; using ServerSync; using SoftReferenceableAssets; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Events; 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("GlitnirExtras")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("GlitnirExtras")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("E74EB49A-461D-48EA-85BC-F462D60C98C4")] [assembly: AssemblyFileVersion("0.2.4")] [assembly: AssemblyCompany("Marlthon")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.4.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<2c2b37f2-4fe6-43dc-90e8-09daa4768d0e>Embedded] internal sealed class <2c2b37f2-4fe6-43dc-90e8-09daa4768d0e>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<2c2b37f2-4fe6-43dc-90e8-09daa4768d0e>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <59e54660-477e-4155-b69c-03f874f45362>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <59e54660-477e-4155-b69c-03f874f45362>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <59e54660-477e-4155-b69c-03f874f45362>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<2c2b37f2-4fe6-43dc-90e8-09daa4768d0e>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <078054c1-564a-4161-8211-76ade1a53f34>NullableContextAttribute : Attribute { public readonly byte Flag; public <078054c1-564a-4161-8211-76ade1a53f34>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace GlitnirExtras { [HarmonyPatch(typeof(SE_Rested), "GetNearbyComfortPieces")] public static class SE_Rested_GetNearbyComfortPieces_Patch { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<59e54660-477e-4155-b69c-03f874f45362>Nullable(1)] private CodeInstruction <>2__current; private int <>l__initialThreadId; [<59e54660-477e-4155-b69c-03f874f45362>Nullable(new byte[] { 0, 1 })] private IEnumerable instructions; [<59e54660-477e-4155-b69c-03f874f45362>Nullable(new byte[] { 0, 1 })] public IEnumerable <>3__instructions; [<59e54660-477e-4155-b69c-03f874f45362>Nullable(new byte[] { 0, 1 })] private IEnumerator <>s__1; private CodeInstruction 5__2; CodeInstruction IEnumerator.Current { [DebuggerHidden] [return: <59e54660-477e-4155-b69c-03f874f45362>Nullable(1)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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(); } } <>s__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; 5__2 = null; break; } if (<>s__1.MoveNext()) { 5__2 = <>s__1.Current; if (5__2.opcode == OpCodes.Ldc_R4 && (float)5__2.operand == 10f) { 5__2.operand = 20f; } <>2__current = 5__2; <>1__state = 1; return true; } <>m__Finally1(); <>s__1 = null; 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; if (<>s__1 != null) { <>s__1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] [IteratorStateMachine(typeof(d__0))] private static IEnumerable Transpiler(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2) { <>3__instructions = instructions }; } } [HarmonyPatch(typeof(EffectArea), "Awake")] [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] public static class EffectArea_Awake_Patch { private static void Postfix(EffectArea __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if ((__instance.m_type & 1) > 0) { UpdateFireEffectRadius(__instance, 20f); } } private static void UpdateFireEffectRadius(EffectArea area, float newRadius) { SphereCollider component = ((Component)area).GetComponent(); if ((Object)(object)component != (Object)null) { component.radius = newRadius; } } } [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] public static class Patch_PvPBiome { [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(0)] public enum BiomeMode { PvE, PvP } [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(0)] [HarmonyPatch] private static class Patch_PlayerUpdate { [HarmonyPatch(typeof(Player), "Update")] [HarmonyPatch(typeof(InventoryGui), "UpdateCharacterStats")] [HarmonyPostfix] public static void Postfix() { if (Object.op_Implicit((Object)(object)ZNetScene.instance) && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)InventoryGui.instance)) { bool pvp = GetCurrentBiomeMode() == BiomeMode.PvP; ((Selectable)InventoryGui.instance.m_pvp).interactable = false; ApplyWithDelay(pvp); } } } private static ConfigEntry _meadows; private static ConfigEntry _blackForest; private static ConfigEntry _swamp; private static ConfigEntry _mountain; private static ConfigEntry _plains; private static ConfigEntry _ocean; private static ConfigEntry _mistlands; private static ConfigEntry _ashLands; private static ConfigEntry _deepNorth; private static ConfigEntry _delay; private static ConfigEntry _msgPvP; private static ConfigEntry _msgPvE; private static ConfigEntry _msgPvPTitleColor; private static ConfigEntry _msgPvPBodyColor; private static ConfigEntry _msgPvETitleColor; private static ConfigEntry _msgPvEBodyColor; private static ConfigEntry _msgPvPTitle; private static ConfigEntry _msgPvETitle; private static bool? _lastPvPState; public static void InitConfig(GlitnirExtrasPlugin plugin) { _meadows = plugin.config("PvP por Bioma", "Meadows", BiomeMode.PvE, "Prados — PvP ou PvE"); _blackForest = plugin.config("PvP por Bioma", "BlackForest", BiomeMode.PvE, "Floresta Negra — PvP ou PvE"); _swamp = plugin.config("PvP por Bioma", "Swamp", BiomeMode.PvE, "Pântano — PvP ou PvE"); _mountain = plugin.config("PvP por Bioma", "Mountain", BiomeMode.PvE, "Montanha — PvP ou PvE"); _plains = plugin.config("PvP por Bioma", "Plains", BiomeMode.PvE, "Planícies — PvP ou PvE"); _ocean = plugin.config("PvP por Bioma", "Ocean", BiomeMode.PvE, "Oceano — PvP ou PvE"); _mistlands = plugin.config("PvP por Bioma", "Mistlands", BiomeMode.PvE, "Mistlands — PvP ou PvE"); _ashLands = plugin.config("PvP por Bioma", "AshLands", BiomeMode.PvE, "AshLands — PvP ou PvE"); _deepNorth = plugin.config("PvP por Bioma", "DeepNorth", BiomeMode.PvE, "Deep North — PvP ou PvE"); _delay = plugin.config("PvP por Bioma", "DelaySeconds", 0f, "Segundos de espera antes de aplicar a regra ao entrar num novo bioma (0 = imediato)"); _msgPvPTitle = plugin.config("PvP por Bioma", "MessagePvPTitle", "ÁREA PVP", "Título da mensagem PvP"); _msgPvPTitleColor = plugin.config("PvP por Bioma", "MessagePvPTitleColor", "#FF0000", "Cor do título da mensagem PvP (hex)"); _msgPvP = plugin.config("PvP por Bioma", "MessagePvP", "Você entrou em um bioma PvP!", "Mensagem ao entrar em bioma PvP"); _msgPvPBodyColor = plugin.config("PvP por Bioma", "MessagePvPBodyColor", "#FFFF00", "Cor do corpo da mensagem PvP (hex)"); _msgPvETitle = plugin.config("PvP por Bioma", "MessagePvETitle", "ÁREA PVE", "Título da mensagem PvE"); _msgPvETitleColor = plugin.config("PvP por Bioma", "MessagePvETitleColor", "#00FF00", "Cor do título da mensagem PvE (hex, true)"); _msgPvE = plugin.config("PvP por Bioma", "MessagePvE", "Você entrou em um bioma PvE!", "Mensagem ao entrar em bioma PvE"); _msgPvEBodyColor = plugin.config("PvP por Bioma", "MessagePvEBodyColor", "#FFFF00", "Cor do corpo da mensagem PvE (hex)"); } private static BiomeMode GetCurrentBiomeMode() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_002b: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected I4, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)EnvMan.instance)) { return BiomeMode.PvE; } Biome currentBiome = EnvMan.instance.GetCurrentBiome(); if (1 == 0) { } BiomeMode result; if ((int)currentBiome <= 16) { switch (currentBiome - 1) { case 0: goto IL_0084; case 1: goto IL_009e; case 3: goto IL_00ab; case 2: goto IL_00f9; } if ((int)currentBiome != 8) { if ((int)currentBiome != 16) { goto IL_00f9; } result = _plains.Value; } else { result = _blackForest.Value; } } else if ((int)currentBiome <= 64) { if ((int)currentBiome != 32) { if ((int)currentBiome != 64) { goto IL_00f9; } result = _deepNorth.Value; } else { result = _ashLands.Value; } } else if ((int)currentBiome != 256) { if ((int)currentBiome != 512) { goto IL_00f9; } result = _mistlands.Value; } else { result = _ocean.Value; } goto IL_00fd; IL_009e: result = _swamp.Value; goto IL_00fd; IL_00fd: if (1 == 0) { } return result; IL_00f9: result = BiomeMode.PvE; goto IL_00fd; IL_00ab: result = _mountain.Value; goto IL_00fd; IL_0084: result = _meadows.Value; goto IL_00fd; } private static async Task ApplyWithDelay(bool pvp) { int ms = (int)(Math.Max(0f, _delay.Value) * 1000f); if (ms > 0) { await Task.Delay(ms); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)InventoryGui.instance) && (!_lastPvPState.HasValue || _lastPvPState.Value != pvp)) { Player.m_localPlayer.SetPVP(pvp); InventoryGui.instance.m_pvp.isOn = pvp; _lastPvPState = pvp; ShowMessage(pvp); } } private static void ShowMessage(bool pvp) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { string value; string value2; string value3; string value4; if (pvp) { value = _msgPvPTitle.Value; value2 = _msgPvPTitleColor.Value; value3 = _msgPvPBodyColor.Value; value4 = _msgPvP.Value; } else { value = _msgPvETitle.Value; value2 = _msgPvETitleColor.Value; value3 = _msgPvEBodyColor.Value; value4 = _msgPvE.Value; } string text = "" + value + "\n" + value4 + ""; ((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null); } } } [HarmonyPatch(typeof(Smelter), "Awake")] public static class Smelter_Awake_Patch { [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] private static void Postfix(Smelter __instance) { switch (__instance.m_name) { case "$piece_smelter": case "$piece_blastfurnace": case "$piece_eitrrefinery": __instance.m_maxOre = 100; __instance.m_maxFuel = 200; break; case "$piece_charcoalkiln": __instance.m_maxOre = 200; break; case "$piece_windmill": case "$piece_spinningwheel": __instance.m_maxOre = 100; break; case "$piece_bathtub": __instance.m_maxFuel = 50; break; } } } [BepInPlugin("marlthon.GlitnirExtras", "GlitnirExtras", "0.2.4")] [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] public class GlitnirExtrasPlugin : BaseUnityPlugin { [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(0)] private class ConfigurationManagerAttributes { public bool? Browsable = false; } internal const string ModName = "GlitnirExtras"; internal const string ModVersion = "0.2.4"; internal const string Author = "marlthon"; private const string ModGUID = "marlthon.GlitnirExtras"; private static string ConfigFileName = "marlthon.GlitnirExtras.cfg"; private static string ConfigFileFullPath; private readonly Harmony _harmony = new Harmony("marlthon.GlitnirExtras"); public static readonly ManualLogSource GlitnirExtras; private static readonly ConfigSync ConfigSync; private static ConfigEntry _serverConfigLocked; public static bool IsLocalPlayerAdmin() { return ConfigSync != null && ConfigSync.IsAdmin; } public void Awake() { HarmonyCore.Instance.Init("GlitnirExtras"); HarmonyCore.Instance.Ciano("Marlthon Mods"); HarmonyCore.Instance.Verde("Download more mods at marlthon.com"); _serverConfigLocked = config("General", "Force Server Config", value: true, "Force Server Config"); ConfigSync.AddLockingConfigEntry(_serverConfigLocked); Patch_PvPBiome.InitConfig(this); Patch_Base.InitConfig(this); Patch_ItemBalance.InitConfig(this); Patch_Clock.InitConfig(this); Patch_Workbench.InitConfig(this); Patch_Container.InitConfig(this); Patch_DeleteItem.InitConfig(this); MenuQuickJoin.InitConfig(this); Item item = new Item("mar_glitnirextras", "Glitnir_ADMCape"); item.Name.English("Glitnir Adm Cape"); item.Name.Portuguese_Brazilian("Capa de ADM Glitnir."); item.Description.English("ADM Glitnir Server Cover."); item.Description.Portuguese_Brazilian("Capa de uso exclusivo dos Adms Glitnir Server."); item.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item2 = new Item("mar_glitnirextras", "GlitnirCoin"); item2.Name.English("Glitnir Coin"); item2.Name.Portuguese_Brazilian("Glitnir Coin"); item2.Description.English("Official Currency of Glitnir Server"); item2.Description.Portuguese_Brazilian("Moeda Oficial do Glitnir Server"); item2.Configurable = Configurability.Disabled; Item item3 = new Item("mar_glitnirextras", "GlitnirBloodCoin"); item3.Name.English("Glitnir Blood Coin"); item3.Name.Portuguese_Brazilian("Moeda Sangrenta Glitnir"); item3.Description.English("Official Blood Currency of Glitnir Server"); item3.Description.Portuguese_Brazilian("Moeda Sangrenta do Glitnir Server"); item3.Configurable = Configurability.Disabled; BuildPiece buildPiece = new BuildPiece("mar_glitnirextras", "GlitnirBanner"); buildPiece.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece.Category.Set("Glitnir"); buildPiece.SpecialProperties.AdminOnly = false; buildPiece.Name.Portuguese_Brazilian("Banner Glitnir"); buildPiece.Name.English("Glitnir Banner"); buildPiece.Description.Portuguese_Brazilian("Banner Glitnir"); buildPiece.Description.English("Glitnir Banner"); buildPiece.RequiredItems.Add("SwordCheat", 1, recover: false); BuildPiece buildPiece2 = new BuildPiece("mar_glitnirextras", "GlitnirBannerPole"); buildPiece2.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece2.Category.Set("Glitnir"); buildPiece2.SpecialProperties.AdminOnly = false; buildPiece2.Name.Portuguese_Brazilian("Estandarte Glitnir 1"); buildPiece2.Name.English("Glitnir Banner Pole 1"); buildPiece2.Description.Portuguese_Brazilian("Estandarte Glitnir 1"); buildPiece2.Description.English("Glitnir Banner Pole 1"); buildPiece2.RequiredItems.Add("SwordCheat", 1, recover: false); BuildPiece buildPiece3 = new BuildPiece("mar_glitnirextras", "GlitnirBannerPole2"); buildPiece3.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece3.Category.Set("Glitnir"); buildPiece3.SpecialProperties.AdminOnly = false; buildPiece3.Name.Portuguese_Brazilian("Estandarte Glitnir 2"); buildPiece3.Name.English("Glitnir Banner Pole 2"); buildPiece3.Description.Portuguese_Brazilian("Estandarte Glitnir 2"); buildPiece3.Description.English("Glitnir Banner Pole 2"); buildPiece3.RequiredItems.Add("SwordCheat", 1, recover: false); BuildPiece buildPiece4 = new BuildPiece("mar_glitnirextras", "GlitnirFlag"); buildPiece4.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece4.Category.Set("Glitnir"); buildPiece4.SpecialProperties.AdminOnly = false; buildPiece4.Name.Portuguese_Brazilian("Bandeira Glitnir"); buildPiece4.Name.English("Glitnir Flag"); buildPiece4.Description.Portuguese_Brazilian("Bandeira Glitnir"); buildPiece4.Description.English("Glitnir Flag"); buildPiece4.RequiredItems.Add("SwordCheat", 1, recover: false); BuildPiece buildPiece5 = new BuildPiece("mar_glitnirextras", "Piece_NizeraX"); buildPiece5.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece5.Category.Set("Glitnir"); buildPiece5.SpecialProperties.AdminOnly = false; buildPiece5.Name.Portuguese_Brazilian("NizeraX"); buildPiece5.Name.English("NizeraX"); buildPiece5.Description.Portuguese_Brazilian("NizeraX"); buildPiece5.Description.English("NizeraX"); buildPiece5.RequiredItems.Add("SwordCheat", 1, recover: false); GameObject val = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_blacksmith"); GameObject val2 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_butcher1"); GameObject val3 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_butcher2"); GameObject val4 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_craftsman"); GameObject val5 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_farmer_01"); GameObject val6 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_guard_idle_01"); GameObject val7 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_guard_idle_02"); GameObject val8 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_guard_idle_03"); GameObject val9 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_guard_patrol_01"); GameObject val10 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_guard_patrol_02"); GameObject val11 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_guard_patrol_03"); GameObject val12 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_hunter"); GameObject val13 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_king_idle"); GameObject val14 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_kingthrone"); GameObject val15 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_laborer_idle"); GameObject val16 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_laborer_walk"); GameObject val17 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_lumberjack1"); GameObject val18 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_lumberjack2"); GameObject val19 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_mage"); GameObject val20 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_miner1"); GameObject val21 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_miner2"); GameObject val22 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_miner3"); GameObject val23 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_monk"); GameObject val24 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_peasant_idle01"); GameObject val25 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_peasant_idle02"); GameObject val26 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_peasant_idle03"); GameObject val27 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_peasant_idle04"); GameObject val28 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_peasant_walk01"); GameObject val29 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_peasant_walk02"); GameObject val30 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_peasant_walk03"); GameObject val31 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_peasant_walk04"); GameObject val32 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_trader1_idle"); GameObject val33 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_trader1_walk"); GameObject val34 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_trader2_idle"); GameObject val35 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_trader2_walk"); GameObject val36 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_warrior"); GameObject val37 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_womanwar_01"); GameObject val38 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_womanwar_02"); GameObject val39 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_womanwar_03"); GameObject val40 = PiecePrefabManager.RegisterPrefab("mar_glitnirextras", "ms_npc_noticeboard"); PrefabManager.RegisterPrefab("mar_glitnirextras", "sfx_build_hammer_metal_glitnirextras"); PrefabManager.RegisterPrefab("mar_glitnirextras", "sfx_build_hammer_wood_glitnirextras"); PrefabManager.RegisterPrefab("mar_glitnirextras", "sfx_build_hammer_wood_nizeraextras"); PrefabManager.RegisterPrefab("mar_glitnirextras", "sfx_wood_destroyed_glitnirextras"); PrefabManager.RegisterPrefab("mar_glitnirextras", "vfx_Place_wood_pole_glitnirextras"); PrefabManager.RegisterPrefab("mar_glitnirextras", "vfx_Place_wood_pole_nizeraextras"); PrefabManager.RegisterPrefab("mar_glitnirextras", "vfx_SawDust_glitnirextras"); PrefabManager.RegisterPrefab("mar_glitnirextras", "vfx_SawDust_nizeraextras"); SetupWatcher(); _harmony.PatchAll(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { GlitnirExtras.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { GlitnirExtras.LogError((object)("There was an issue loading your " + ConfigFileName)); GlitnirExtras.LogError((object)"Please check your config entries for spelling and format!"); } } public ConfigEntry config<[<59e54660-477e-4155-b69c-03f874f45362>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry val2 = ((BaseUnityPlugin)this).Config.Bind(group, name, value, val); SyncedConfigEntry syncedConfigEntry = ConfigSync.AddConfigEntry(val2); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val2; } public ConfigEntry config<[<59e54660-477e-4155-b69c-03f874f45362>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty()), synchronizedSetting); } static GlitnirExtrasPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; GlitnirExtras = Logger.CreateLogSource("GlitnirExtras"); ConfigSync = new ConfigSync("marlthon.GlitnirExtras") { DisplayName = "GlitnirExtras", CurrentVersion = "0.2.4", MinimumRequiredVersion = "0.2.4", ModRequired = true }; _serverConfigLocked = null; } } [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] [HarmonyPatch] public static class Patch_Base { private static ConfigEntry CarryWeightBase; private static ConfigEntry MegingjordBonus; private static ConfigEntry BuildDistance; private static ConfigEntry AutoPickupRange; private static ConfigEntry InteractDistance; private static bool _appliedRuntimeTuningOnce; private const string MegingjordPrefab = "BeltStrength"; private const string MegingjordToken = "$item_beltstrength"; private const float VanillaCarryBase = 300f; private const float VanillaMegiBonus = 150f; public static void InitConfig(GlitnirExtrasPlugin plugin) { CarryWeightBase = plugin.config("BaseTweaks", "CarryWeightBase", 300f, "Base carry weight for the player."); MegingjordBonus = plugin.config("BaseTweaks", "MegingjordBonus", 150f, "Carry weight bonus given by Megingjord."); BuildDistance = plugin.config("BaseTweaks", "BuildDistance", 5f, "Max distance to place pieces (build range)."); AutoPickupRange = plugin.config("BaseTweaks", "AutoPickupRange", 2f, "Auto-pickup item radius."); InteractDistance = plugin.config("BaseTweaks", "InteractDistance", 2.5f, "Interaction distance for use/open."); } [HarmonyPatch(typeof(Player), "GetMaxCarryWeight")] [HarmonyPostfix] private static void Player_GetMaxCarryWeight_Postfix(Player __instance, ref float __result) { float num = CarryWeightBase.Value - 300f; __result += num; if (HasMegingjordEquipped(__instance)) { float num2 = MegingjordBonus.Value - 150f; __result += num2; } } [HarmonyPatch(typeof(Player), "Awake")] [HarmonyPostfix] private static void Player_Awake_Postfix(Player __instance) { TrySetFloatField(__instance, new string[3] { "m_maxPlaceDistance", "m_buildDistance", "m_placeDistance" }, BuildDistance.Value); TrySetFloatField(__instance, new string[2] { "m_autoPickupRange", "m_autoPickupDistance" }, AutoPickupRange.Value); TrySetFloatField(__instance, new string[2] { "m_maxInteractDistance", "m_interactDistance" }, InteractDistance.Value); if (!_appliedRuntimeTuningOnce && (Object)(object)Player.m_localPlayer == (Object)(object)__instance) { _appliedRuntimeTuningOnce = true; ((Character)Player.m_localPlayer).Message((MessageType)1, $"CarryWeight base: {CarryWeightBase.Value:0.#} | Megingjord: {MegingjordBonus.Value:0.#}", 0, (Sprite)null); ((Character)Player.m_localPlayer).Message((MessageType)1, $"Build distance: {BuildDistance.Value:0.#} | Auto-pickup: {AutoPickupRange.Value:0.#} | Interact: {InteractDistance.Value:0.#}", 0, (Sprite)null); } } private static bool HasMegingjordEquipped(Player player) { if ((Object)(object)player == (Object)null) { return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } List allItems = inventory.GetAllItems(); foreach (ItemData item in allItems) { if (item != null && item.m_equipped) { if ((Object)(object)item.m_dropPrefab != (Object)null && ((Object)item.m_dropPrefab).name == "BeltStrength") { return true; } if (!string.IsNullOrEmpty(item.m_shared?.m_name) && string.Equals(item.m_shared.m_name, "$item_beltstrength", StringComparison.OrdinalIgnoreCase)) { return true; } if (!string.IsNullOrEmpty(item.m_shared?.m_name) && item.m_shared.m_name.IndexOf("belt", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } } return false; } private static void TrySetFloatField(object instance, string[] candidateFieldNames, float value) { Type type = instance.GetType(); foreach (string text in candidateFieldNames) { FieldInfo fieldInfo = AccessTools.Field(type, text); if (fieldInfo != null && fieldInfo.FieldType == typeof(float)) { fieldInfo.SetValue(instance, value); break; } } } } [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] [HarmonyPatch] public static class Patch_Clock { private static ConfigEntry ClockEnabled; private static ConfigEntry ClockUpdateInterval; private static ConfigEntry ClockFontSize; private static ConfigEntry ShowRealTime; private static ConfigEntry RealTimeUse24H; private static ConfigEntry RealTimeFontSize; private static float _nextUpdateTime; private static GameObject _clockRoot; private static TextMeshProUGUI _timeText; private static TextMeshProUGUI _realText; private const float ROOT_OFFSET_Y = -60f; private const float ROOT_WIDTH = 600f; private const float ROOT_HEIGHT = 120f; public static void InitConfig(GlitnirExtrasPlugin plugin) { ClockEnabled = plugin.config("Clock", "ClockEnabled", value: true, "Show the in-game clock."); ClockUpdateInterval = plugin.config("Clock", "ClockUpdateInterval", 1f, "Seconds between updates."); ClockFontSize = plugin.config("Clock", "ClockFontSize", 40, "Font size for the in-game clock."); ShowRealTime = plugin.config("Clock", "ShowRealTime", value: true, "Show the real-world time below the in-game clock."); RealTimeUse24H = plugin.config("Clock", "RealTimeUse24H", value: true, "Use 24-hour time format for real-world time."); RealTimeFontSize = plugin.config("Clock", "RealTimeFontSize", 28, "Font size for the real-world time text."); } [HarmonyPostfix] [HarmonyPatch(typeof(Hud), "Update")] private static void Hud_Update_Postfix(Hud __instance) { if (!ClockEnabled.Value) { if ((Object)(object)_clockRoot != (Object)null) { Object.Destroy((Object)(object)_clockRoot); } return; } if ((Object)(object)_clockRoot == (Object)null) { CreateClock(__instance); } if (!(Time.unscaledTime < _nextUpdateTime)) { _nextUpdateTime = Time.unscaledTime + Mathf.Max(0.2f, ClockUpdateInterval.Value); UpdateClockTexts(); } } private static void CreateClock(Hud hud) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_004a: 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_0063: 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_00d6: 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_014e: 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) _clockRoot = new GameObject("MarlthonClockRoot"); _clockRoot.transform.SetParent(hud.m_rootObject.transform, false); RectTransform val = _clockRoot.AddComponent(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 1f); val.anchorMax = val2; val.anchorMin = val2; val.anchoredPosition = new Vector2(0f, -60f); val.sizeDelta = new Vector2(600f, 120f); TMP_FontAsset font = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)([<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(0)] (TMP_FontAsset f) => ((Object)f).name.ToLower().Contains("norsebold"))) ?? TMP_Settings.defaultFontAsset; _timeText = CreateTMP("ClockTime", font, ClockFontSize.Value, new Color(1f, 0.85f, 0.2f)); ((TMP_Text)_timeText).alignment = (TextAlignmentOptions)514; ((TMP_Text)_timeText).transform.SetParent(_clockRoot.transform, false); ((TMP_Text)_timeText).rectTransform.anchoredPosition = new Vector2(0f, 10f); _realText = CreateTMP("ClockReal", font, RealTimeFontSize.Value, new Color(0.8f, 0.8f, 0.8f)); ((TMP_Text)_realText).alignment = (TextAlignmentOptions)514; ((TMP_Text)_realText).transform.SetParent(_clockRoot.transform, false); ((TMP_Text)_realText).rectTransform.anchoredPosition = new Vector2(0f, -30f); } private static TextMeshProUGUI CreateTMP(string name, TMP_FontAsset font, int size, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002a: 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_0059: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); TextMeshProUGUI val2 = val.AddComponent(); ((TMP_Text)val2).font = font ?? TMP_Settings.defaultFontAsset; ((TMP_Text)val2).fontSize = size; ((Graphic)val2).color = color; ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; ((TMP_Text)val2).enableWordWrapping = false; ((TMP_Text)val2).richText = true; Material val3 = new Material(((TMP_Text)val2).fontSharedMaterial); val3.SetFloat("_OutlineWidth", 0.1f); val3.SetColor("_OutlineColor", new Color(0f, 0f, 0f, 0.6f)); ((TMP_Text)val2).fontSharedMaterial = val3; return val2; } private static void UpdateClockTexts() { if (!((Object)(object)EnvMan.instance == (Object)null)) { float num = EnvMan.instance.GetDay(); float dayFraction = EnvMan.instance.GetDayFraction(); int num2 = Mathf.FloorToInt(dayFraction * 24f); int num3 = Mathf.FloorToInt((dayFraction * 24f - (float)num2) * 60f); ((TMP_Text)_timeText).text = $"Dia {num} - {num2:00}:{num3:00}"; if (ShowRealTime.Value) { DateTime now = DateTime.Now; string text = (RealTimeUse24H.Value ? now.ToString("HH:mm") : now.ToString("hh:mm tt")); ((TMP_Text)_realText).text = "Vida Real: " + text + ""; } else { ((TMP_Text)_realText).text = ""; } } } } [HarmonyPatch] [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] public static class Patch_Container { private static ConfigEntry ChestControl; private static ConfigEntry PrivateRows; private static ConfigEntry PrivateCols; private static ConfigEntry WoodRows; private static ConfigEntry WoodCols; private static ConfigEntry IronRows; private static ConfigEntry IronCols; private static ConfigEntry BlackmetalRows; private static ConfigEntry BlackmetalCols; private static ConfigEntry BarrelRows; private static ConfigEntry BarrelCols; public static void InitConfig(GlitnirExtrasPlugin plugin) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown ChestControl = plugin.config("ContainerControl", "EnableChestControl", value: true, "Enable server control over vanilla chest sizes (private, wood, iron, blackmetal, barrel)."); PrivateRows = plugin.config("Chests", "PrivateChestRows", 2, new ConfigDescription("Rows for personal chest (piece_chest_private)", (AcceptableValueBase)(object)new AcceptableValueRange(2, 20), Array.Empty())); PrivateCols = plugin.config("Chests", "PrivateChestCols", 3, new ConfigDescription("Cols for personal chest (piece_chest_private)", (AcceptableValueBase)(object)new AcceptableValueRange(3, 8), Array.Empty())); WoodRows = plugin.config("Chests", "WoodChestRows", 2, new ConfigDescription("Rows for wood chest (piece_chest_wood)", (AcceptableValueBase)(object)new AcceptableValueRange(2, 10), Array.Empty())); WoodCols = plugin.config("Chests", "WoodChestCols", 5, new ConfigDescription("Cols for wood chest (piece_chest_wood)", (AcceptableValueBase)(object)new AcceptableValueRange(5, 8), Array.Empty())); IronRows = plugin.config("Chests", "IronChestRows", 4, new ConfigDescription("Rows for iron chest (piece_chest)", (AcceptableValueBase)(object)new AcceptableValueRange(2, 20), Array.Empty())); IronCols = plugin.config("Chests", "IronChestCols", 6, new ConfigDescription("Cols for iron chest (piece_chest)", (AcceptableValueBase)(object)new AcceptableValueRange(3, 8), Array.Empty())); BlackmetalRows = plugin.config("Chests", "BlackmetalChestRows", 4, new ConfigDescription("Rows for blackmetal chest (piece_chest_blackmetal)", (AcceptableValueBase)(object)new AcceptableValueRange(3, 20), Array.Empty())); BlackmetalCols = plugin.config("Chests", "BlackmetalChestCols", 8, new ConfigDescription("Cols for blackmetal chest (piece_chest_blackmetal)", (AcceptableValueBase)(object)new AcceptableValueRange(6, 8), Array.Empty())); BarrelRows = plugin.config("Chests", "BarrelChestRows", 3, new ConfigDescription("Rows for barrel chest (piece_chest_barrel)", (AcceptableValueBase)(object)new AcceptableValueRange(2, 10), Array.Empty())); BarrelCols = plugin.config("Chests", "BarrelChestCols", 3, new ConfigDescription("Cols for barrel chest (piece_chest_barrel)", (AcceptableValueBase)(object)new AcceptableValueRange(3, 8), Array.Empty())); SubscribeChanges(); } private static void SubscribeChanges() { Watch(ChestControl); Watch(PrivateRows); Watch(PrivateCols); Watch(WoodRows); Watch(WoodCols); Watch(IronRows); Watch(IronCols); Watch(BlackmetalRows); Watch(BlackmetalCols); Watch(BarrelRows); Watch(BarrelCols); static void Watch([<59e54660-477e-4155-b69c-03f874f45362>Nullable(new byte[] { 1, 0 })] ConfigEntry entry) { if (entry != null) { entry.SettingChanged += [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(0)] (object _, EventArgs _) => { UpdateAllChests(); }; } } } [HarmonyPostfix] [HarmonyPatch(typeof(Container), "Awake")] private static void Container_Awake_Postfix(Container __instance) { TryResize(__instance); } [HarmonyPatch(typeof(Container), "Interact")] [HarmonyPrefix] private static void Container_Interact_Prefix(Container __instance, Humanoid character, bool hold, bool alt) { TryResize(__instance); } private static void TryResize(Container container) { if (!ChestControl.Value || (Object)(object)container == (Object)null || ((Object)container).name.StartsWith("Treasure")) { return; } ZNetView nview = container.m_nview; if ((Object)(object)nview == (Object)null || !nview.IsValid() || nview.GetZDO().GetLong(StringExtensionMethods.GetStableHashCode("creator"), 0L) == 0) { return; } Inventory inventory = container.GetInventory(); if (inventory != null) { switch (((Object)((Component)container).transform.root).name.Trim().Replace("(Clone)", "")) { case "piece_chest_private": inventory.m_height = PrivateRows.Value; inventory.m_width = PrivateCols.Value; break; case "piece_chest_wood": inventory.m_height = WoodRows.Value; inventory.m_width = WoodCols.Value; break; case "piece_chest": inventory.m_height = IronRows.Value; inventory.m_width = IronCols.Value; break; case "piece_chest_blackmetal": inventory.m_height = BlackmetalRows.Value; inventory.m_width = BlackmetalCols.Value; break; case "piece_chest_barrel": inventory.m_height = BarrelRows.Value; inventory.m_width = BarrelCols.Value; break; } } } private static void UpdateAllChests() { if (!ChestControl.Value) { return; } Container[] array = Resources.FindObjectsOfTypeAll(); foreach (Container val in array) { if (!((Object)(object)val == (Object)null) && !((Object)val).name.StartsWith("Treasure")) { ZNetView nview = val.m_nview; if (!((Object)(object)nview == (Object)null) && nview.IsValid() && nview.GetZDO().GetLong(StringExtensionMethods.GetStableHashCode("creator"), 0L) != 0) { TryResize(val); } } } GlitnirExtrasPlugin.GlitnirExtras.LogInfo((object)"[SagaHeim/Container] Chest sizes updated."); } } [HarmonyPatch] [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] public static class Patch_DeleteItem { private static ConfigEntry DeleteKey; public static void InitConfig(GlitnirExtrasPlugin plugin) { DeleteKey = plugin.config("DeleteItem", "DeleteKey", (KeyCode)127, "Key used to delete the selected item in the inventory (default: Delete)"); } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Update")] private static void PlayerUpdate_Postfix(Player __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !((Object)(object)InventoryGui.instance == (Object)null) && Input.GetKeyDown(DeleteKey.Value)) { TryDeleteSelectedItem(); } } private static void TryDeleteSelectedItem() { InventoryGui instance = InventoryGui.instance; object? value = AccessTools.Field(typeof(InventoryGui), "m_dragItem").GetValue(instance); ItemData val = (ItemData)((value is ItemData) ? value : null); object? value2 = AccessTools.Field(typeof(InventoryGui), "m_dragInventory").GetValue(instance); Inventory val2 = (Inventory)((value2 is Inventory) ? value2 : null); object? value3 = AccessTools.Field(typeof(InventoryGui), "m_dragGo").GetValue(instance); GameObject val3 = (GameObject)((value3 is GameObject) ? value3 : null); if (val == null || val2 == null) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, "No item selected.", 0, (Sprite)null); } return; } if (val.m_equipped) { Player localPlayer2 = Player.m_localPlayer; if (localPlayer2 != null) { ((Character)localPlayer2).Message((MessageType)1, "Cannot delete equipped item!", 0, (Sprite)null); } return; } val2.RemoveItem(val); if ((Object)(object)val3 != (Object)null) { Object.Destroy((Object)(object)val3); } AccessTools.Field(typeof(InventoryGui), "m_dragGo").SetValue(instance, null); AccessTools.Field(typeof(InventoryGui), "m_dragItem").SetValue(instance, null); AccessTools.Field(typeof(InventoryGui), "m_dragInventory").SetValue(instance, null); Player localPlayer3 = Player.m_localPlayer; if (localPlayer3 != null) { ((Character)localPlayer3).Message((MessageType)1, "Deleted: " + val.m_shared.m_name, 0, (Sprite)null); } instance.m_playerGrid.UpdateInventory(((Humanoid)Player.m_localPlayer).GetInventory(), Player.m_localPlayer, (ItemData)null); } } [HarmonyPatch] [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] public static class Patch_ItemBalance { private static ConfigEntry GlobalWeightMultiplier; private static ConfigEntry GlobalStackMultiplier; private static ConfigEntry CoinWeight; private static ConfigEntry CoinStackMax; private static ConfigEntry EnableFloatingItems; private static ConfigEntry NoFloatItems; private static readonly HashSet _patchedShared = new HashSet(); private static readonly HashSet NoFloatSet = new HashSet(); public static void InitConfig(GlitnirExtrasPlugin plugin) { GlobalWeightMultiplier = plugin.config("ItemBalance", "GlobalWeightMultiplier", 1f, "Multiplier applied to item weight."); GlobalStackMultiplier = plugin.config("ItemBalance", "GlobalStackMultiplier", 1f, "Multiplier applied to item max stack size."); CoinWeight = plugin.config("ItemBalance", "CoinWeight", 0.01f, "Weight of a single coin."); CoinStackMax = plugin.config("ItemBalance", "CoinStackMax", 9999, "Max stack size for coins."); EnableFloatingItems = plugin.config("FloatingItems", "EnableFloatingItems", value: true, "If true, dropped items will float on water."); NoFloatItems = plugin.config("FloatingItems", "NoFloatItems", "Obsidian,BlackMetalScrap,IronScrap,CopperOre,TinOre,SilverOre,FlametalOre,BlackMetal,Iron,Copper,Tin,Silver,Flametal,Crystal,Chitin,SurtlingCore,Eitr,Softtissue,Tar,StoneBlock,SharpeningStone,DragonEgg", "Comma-separated prefab names that should NOT float."); RebuildNoFloatList(); } private static void RebuildNoFloatList() { NoFloatSet.Clear(); string[] array = NoFloatItems.Value.Split(new char[1] { ',' }); foreach (string text in array) { if (!string.IsNullOrWhiteSpace(text)) { NoFloatSet.Add(text.Trim().ToLowerInvariant()); } } } [HarmonyPatch(typeof(ItemDrop), "Awake")] [HarmonyPostfix] private static void ItemDrop_Awake_Postfix(ItemDrop __instance) { if (GlobalWeightMultiplier == null || (Object)(object)__instance == (Object)null) { return; } SharedData val = __instance.m_itemData?.m_shared; if (val == null || _patchedShared.Contains(val)) { return; } _patchedShared.Add(val); string text = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "").ToLowerInvariant(); string text2 = (val.m_name ?? "").ToLowerInvariant(); if (text == "coins" || text2.Contains("coin")) { val.m_weight = Mathf.Max(0.0001f, CoinWeight.Value); val.m_maxStackSize = Mathf.Clamp(CoinStackMax.Value, 1, 999999); return; } if (!Mathf.Approximately(GlobalWeightMultiplier.Value, 1f)) { val.m_weight = Mathf.Max(0.0001f, val.m_weight * GlobalWeightMultiplier.Value); } if (!Mathf.Approximately(GlobalStackMultiplier.Value, 1f) && val.m_maxStackSize > 1) { val.m_maxStackSize = Mathf.Clamp((int)((float)val.m_maxStackSize * GlobalStackMultiplier.Value), 1, 999999); } } [HarmonyPatch(typeof(ItemDrop), "Start")] [HarmonyPostfix] private static void ItemDrop_Start_Postfix(ItemDrop __instance) { if (!EnableFloatingItems.Value || (Object)(object)__instance == (Object)null || !Object.op_Implicit((Object)(object)__instance.m_nview) || !__instance.m_nview.IsValid()) { return; } string item = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "").ToLowerInvariant(); if (!NoFloatSet.Contains(item) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { Floating val = ((Component)__instance).gameObject.AddComponent(); val.m_waterLevelOffset = 0.5f; val.m_forceDistance = 1f; val.m_force = 0.5f; val.m_balanceForceFraction = 0.02f; val.m_damping = 0.05f; Rigidbody component = ((Component)__instance).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { component = ((Component)__instance).gameObject.AddComponent(); component.mass = 0.5f; component.linearDamping = 0.1f; component.angularDamping = 0.05f; } } } } [<59e54660-477e-4155-b69c-03f874f45362>Nullable(0)] [<078054c1-564a-4161-8211-76ade1a53f34>NullableContext(1)] [HarmonyPatch] internal static class MenuQuickJoin { public static ConfigEntry Enabled = null; public static ConfigEntry ButtonText = null; public static ConfigEntry IP = null; public static ConfigEntry Port = null; public static ConfigEntry Password = null; private static readonly Color VikingsGreen = new Color(0.55f, 1f, 0.55f, 1f); public static void InitConfig(GlitnirExtrasPlugin plugin) { Enabled = plugin.config("Menu Quick Join", "Enabled", value: true, "Ativa ou desativa o botão de entrada rápida.", synchronizedSetting: false); ButtonText = plugin.config("Menu Quick Join", "Button Text", "Glitnir Server", "Texto exibido no botão do menu.", synchronizedSetting: false); IP = plugin.config("Menu Quick Join", "Server IP", "177.54.147.114", "IP do servidor para conexão.", synchronizedSetting: false); Port = plugin.config("Menu Quick Join", "Server Port", 24444, "Porta do servidor.", synchronizedSetting: false); Password = plugin.config("Menu Quick Join", "Server Password", "12457800", "Senha do servidor.", synchronizedSetting: false); } [HarmonyPatch(typeof(FejdStartup), "SetupGui")] [HarmonyPostfix] private static void SetupGui_Postfix(FejdStartup __instance) { if (Enabled != null && Enabled.Value) { TryApply(__instance); } } private static void TryApply(FejdStartup fs) { //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown if ((Object)(object)fs == (Object)null || (Object)(object)fs.m_menuList == (Object)null || fs.m_menuList.GetComponentsInChildren