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 Tweaks v1.2.3
plugins/Tweaks.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; 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; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("E74EB49A-461D-48EA-85BC-F462D60C98C4")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyProduct("Tweaks")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("Tweaks")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.2.3")] [assembly: AssemblyCompany("Radamanto")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.3.0")] [module: <f08405ff-a851-4a6b-95c0-fa6a7e14ddf4>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<20e0803f-ee84-4dcf-a781-aa92d47fd8dd>Embedded] internal sealed class <20e0803f-ee84-4dcf-a781-aa92d47fd8dd>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<20e0803f-ee84-4dcf-a781-aa92d47fd8dd>Embedded] [CompilerGenerated] internal sealed class <26038308-0667-4d67-809e-006db3876118>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <26038308-0667-4d67-809e-006db3876118>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <26038308-0667-4d67-809e-006db3876118>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<20e0803f-ee84-4dcf-a781-aa92d47fd8dd>Embedded] [CompilerGenerated] internal sealed class <6f684b40-7dd8-400b-a870-b737b348a108>NullableContextAttribute : Attribute { public readonly byte Flag; public <6f684b40-7dd8-400b-a870-b737b348a108>NullableContextAttribute(byte P_0) { Flag = P_0; } } [<20e0803f-ee84-4dcf-a781-aa92d47fd8dd>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <f08405ff-a851-4a6b-95c0-fa6a7e14ddf4>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <f08405ff-a851-4a6b-95c0-fa6a7e14ddf4>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Tweaks { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] internal static class ClockHud { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] [HarmonyPatch(typeof(Hud), "Awake")] private static class Patch_Hud_Awake { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(Hud __instance) { if (IsEnabled()) { EnsureUi(__instance); } } } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] [HarmonyPatch(typeof(Hud), "OnDestroy")] private static class Patch_Hud_OnDestroy { private static void Postfix() { Teardown(); } } [HarmonyPatch(typeof(Hud), "Update")] [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] private static class Patch_Hud_Update { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(Hud __instance) { if (!IsEnabled()) { if ((Object)(object)_root != (Object)null) { Teardown(); } } else { EnsureUi(__instance); Tick(Time.unscaledDeltaTime, __instance); } } } private const float TickInterval = 0.2f; private const string LabelColor = "FFD700"; private const string PartSeparator = " "; private const string DaySpriteName = "dia"; private const string NightSpriteName = "noite"; private const string DayToken = "$tweaks_clock_day"; private const string GameTimeToken = "$tweaks_clock_game_time"; private const string RealTimeToken = "$tweaks_clock_real_time"; private static readonly List<string> Parts = new List<string>(3); [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static GameObject _root; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static TextMeshProUGUI _text; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static Image _icon; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static RectTransform _iconRect; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static Sprite _daySprite; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static Sprite _nightSprite; private static bool _spritesLoaded; private static float _timer; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static string _lastLine; private static bool IsEnabled() { return TweaksPlugin.CE_ClockHud_Enabled.Value; } private static void EnsureUi(Hud hud) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00a2: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0123: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Expected O, but got Unknown //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_text != (Object)null) { EnsureFont(hud); return; } GameObject val = (((Object)(object)hud.m_rootObject != (Object)null) ? hud.m_rootObject : ((Component)hud).gameObject); if (!((Object)(object)val == (Object)null)) { _root = new GameObject("Tweaks_ClockHud", new Type[1] { typeof(RectTransform) }); _root.transform.SetParent(val.transform, false); RectTransform val2 = (RectTransform)_root.transform; val2.anchorMin = new Vector2(0.5f, 1f); val2.anchorMax = new Vector2(0.5f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.anchoredPosition = new Vector2(0f, -8f); val2.sizeDelta = new Vector2(900f, 72f); GameObject val3 = new GameObject("Container", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(_root.transform, false); RectTransform val4 = (RectTransform)val3.transform; val4.anchorMin = new Vector2(0.5f, 0.5f); val4.anchorMax = new Vector2(0.5f, 0.5f); val4.pivot = new Vector2(0.5f, 0.5f); val4.anchoredPosition = new Vector2(0f, -4f); val4.sizeDelta = new Vector2(900f, 72f); GameObject val5 = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val5.transform.SetParent(val3.transform, false); RectTransform val6 = (RectTransform)val5.transform; val6.anchorMin = new Vector2(0f, 0.5f); val6.anchorMax = new Vector2(1f, 1f); val6.pivot = new Vector2(0.5f, 1f); val6.anchoredPosition = Vector2.zero; val6.sizeDelta = new Vector2(0f, -8f); _text = val5.AddComponent<TextMeshProUGUI>(); ((Graphic)_text).raycastTarget = false; ((TMP_Text)_text).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)_text).alignment = (TextAlignmentOptions)258; ((TMP_Text)_text).fontSize = TweaksPlugin.CE_ClockHud_FontSize.Value; EnsureFont(hud); GameObject val7 = new GameObject("DayNightIcon", new Type[1] { typeof(RectTransform) }); val7.transform.SetParent(val3.transform, false); _iconRect = (RectTransform)val7.transform; _iconRect.anchorMin = new Vector2(0.5f, 0f); _iconRect.anchorMax = new Vector2(0.5f, 0f); _iconRect.pivot = new Vector2(0.5f, 0f); _iconRect.anchoredPosition = new Vector2(0f, 2f); _icon = val7.AddComponent<Image>(); ((Graphic)_icon).raycastTarget = false; ((Behaviour)_icon).enabled = false; ApplyIconSize(); _timer = 0.2f; _lastLine = null; } } private static void EnsureFont(Hud hud) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_text == (Object)null) && !((Object)(object)((TMP_Text)_text).font != (Object)null)) { TMP_FontAsset val = FindFont(hud); if (!((Object)(object)val == (Object)null)) { ((TMP_Text)_text).font = val; ((TMP_Text)_text).outlineWidth = 0.2f; ((TMP_Text)_text).outlineColor = Color32.op_Implicit(Color.black); } } } [return: <26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static TMP_FontAsset FindFont(Hud hud) { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance != (Object)null) { TMP_FontAsset val = GetFont(instance.m_playerName) ?? GetFont(instance.m_recipeName) ?? GetFont(instance.m_containerName) ?? GetFont(instance.m_craftingStationName); if ((Object)(object)val != (Object)null) { return val; } } Menu instance2 = Menu.instance; if ((Object)(object)instance2 != (Object)null) { TMP_FontAsset font = GetFont(instance2.lastSaveText); if ((Object)(object)font != (Object)null) { return font; } } return GetFont((TMP_Text)(object)hud.m_hoverName); } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(2)] private static TMP_FontAsset GetFont(TMP_Text text) { return ((Object)(object)text != (Object)null && (Object)(object)text.font != (Object)null) ? text.font : null; } private static void Teardown() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _text = null; _icon = null; _iconRect = null; _timer = 0f; _lastLine = null; } private static bool IsInWorld() { return (Object)(object)ZNetScene.instance != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null; } private static void Tick(float deltaTime, Hud hud) { if ((Object)(object)_text == (Object)null) { return; } EnsureFont(hud); if (!IsInWorld()) { return; } _timer += deltaTime; if (!(_timer < 0.2f)) { _timer = 0f; ((TMP_Text)_text).fontSize = TweaksPlugin.CE_ClockHud_FontSize.Value; string text = BuildLine(); if (!string.Equals(_lastLine, text, StringComparison.Ordinal)) { _lastLine = text; ((TMP_Text)_text).text = text; } ApplyIconSize(); UpdateIcon(); } } private static string BuildLine() { Parts.Clear(); EnvMan instance = EnvMan.instance; if (TweaksPlugin.CE_ClockHud_ShowDay.Value) { int num = (((Object)(object)instance != (Object)null) ? instance.GetCurrentDay() : 0); Parts.Add(string.Format("{0}: {1}", Label("$tweaks_clock_day"), num)); } if (TweaksPlugin.CE_ClockHud_ShowGameTime.Value) { string value = (((Object)(object)instance != (Object)null) ? FormatDayFraction(instance.GetDayFraction()) : "00:00"); Parts.Add(Label("$tweaks_clock_game_time") + ": " + MonoDigits(value)); } if (TweaksPlugin.CE_ClockHud_ShowRealTime.Value) { string value2 = DateTime.Now.ToString("HH:mm"); Parts.Add(Label("$tweaks_clock_real_time") + ": " + MonoDigits(value2)); } return (Parts.Count == 0) ? string.Empty : string.Join(" ", Parts); } private static string FormatDayFraction(float fraction) { int num = Mathf.FloorToInt(Mathf.Repeat(fraction, 1f) * 1440f) % 1440; return $"{num / 60:00}:{num % 60:00}"; } private static string Label(string token) { return "<color=#FFD700>" + Localization.instance.Localize(token) + "</color>"; } private static string MonoDigits(string value) { return "<mspace=0.42em>" + value + "</mspace>"; } private static void ApplyIconSize() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_iconRect == (Object)null)) { float value = TweaksPlugin.CE_ClockHud_IconSize.Value; _iconRect.sizeDelta = new Vector2(value, value); } } private static void UpdateIcon() { if ((Object)(object)_icon == (Object)null) { return; } Sprite val = null; if (TweaksPlugin.CE_ClockHud_ShowIcon.Value) { EnsureSprites(); if (EnvMan.IsDay()) { val = _daySprite; } else if (EnvMan.IsNight()) { val = _nightSprite; } } _icon.sprite = val; ((Behaviour)_icon).enabled = (Object)(object)val != (Object)null; } private static void EnsureSprites() { if (!_spritesLoaded) { _spritesLoaded = true; _daySprite = AssetLoader.GetSprite("dia"); _nightSprite = AssetLoader.GetSprite("noite"); } } } [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] internal static class SmallStatusEffect { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(2)] [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] private sealed class EntryCache { internal TMP_Text Name; internal string NameKey; [<26038308-0667-4d67-809e-006db3876118>Nullable(1)] internal string DisplayName = string.Empty; internal string IconText; [<26038308-0667-4d67-809e-006db3876118>Nullable(1)] internal string Text = string.Empty; } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] [HarmonyPatch(typeof(Hud), "UpdateStatusEffects", new Type[] { typeof(List<StatusEffect>) })] private static class Patch_Hud_UpdateStatusEffects { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(Hud __instance, List<StatusEffect> statusEffects) { Apply(statusEffects, __instance.m_statusEffects); } } private const int MaxRows = 5; private const float IconSize = 32f; private const float EntryWidth = 170f; private const float EntryHeight = 36f; private const float IconOffsetX = -4f; private const float TextGap = 8f; private const float CooldownSize = 16f; private const int FontSize = 14; private const string IconTextColor = "#ffb75c"; private static readonly Dictionary<RectTransform, EntryCache> Entries = new Dictionary<RectTransform, EntryCache>(); private static int _lastCount = -1; private static void Apply(List<StatusEffect> statusEffects, List<RectTransform> entries) { if (!TweaksPlugin.CE_SmallStatusEffect_Enabled.Value || statusEffects == null || entries == null) { return; } if (entries.Count != _lastCount) { Entries.Clear(); _lastCount = entries.Count; } int num = Math.Min(statusEffects.Count, entries.Count); for (int i = 0; i < num; i++) { StatusEffect val = statusEffects[i]; RectTransform val2 = entries[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { if (!Entries.TryGetValue(val2, out var value)) { value = Setup(val2, i); Entries[val2] = value; } UpdateName(value, val); } } } private static EntryCache Setup(RectTransform entry, int index) { //IL_0014: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) int num = index % 5; int num2 = index / 5; SetRect(entry, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-4f - (float)num2 * 170f, (float)(-num) * 36f), 170f, 36f); Transform obj = ((Transform)entry).Find("Icon"); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (val != null) { SetRect(val, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-4f, 0f), 32f, 32f); } Transform obj2 = ((Transform)entry).Find("Cooldown"); RectTransform val2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); if (val2 != null) { SetRect(val2, new Vector2(1f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-20f, -8f), 16f, 16f); } Transform val3 = ((Transform)entry).Find("TimeText"); if (val3 != null) { TMP_Text component = ((Component)val3).GetComponent<TMP_Text>(); if (component != null) { ((Behaviour)component).enabled = false; } } EntryCache entryCache = new EntryCache(); Transform obj3 = ((Transform)entry).Find("Name"); RectTransform val4 = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null); if (val4 != null) { TMP_Text component2 = ((Component)val4).GetComponent<TMP_Text>(); if (component2 != null) { float width = Mathf.Max(20f, 130f - Mathf.Abs(-4f)); ((Component)val4).gameObject.SetActive(true); SetRect(val4, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-44f, 0f), width, 36f); component2.alignment = (TextAlignmentOptions)4100; component2.fontSize = 14f; component2.richText = true; component2.textWrappingMode = (TextWrappingModes)0; component2.overflowMode = (TextOverflowModes)3; entryCache.Name = component2; } } return entryCache; } private static void SetRect(RectTransform rect, Vector2 anchor, Vector2 pivot, Vector2 position, float width, float height) { //IL_0002: 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_0012: 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) rect.anchorMin = anchor; rect.anchorMax = anchor; rect.pivot = pivot; rect.anchoredPosition = position; rect.SetSizeWithCurrentAnchors((Axis)0, width); rect.SetSizeWithCurrentAnchors((Axis)1, height); } private static void UpdateName(EntryCache cache, StatusEffect statusEffect) { if (!((Object)(object)cache.Name == (Object)null)) { bool flag = false; if (!string.Equals(cache.NameKey, statusEffect.m_name, StringComparison.Ordinal)) { cache.NameKey = statusEffect.m_name; cache.DisplayName = ((Localization.instance != null) ? Localization.instance.Localize(statusEffect.m_name) : statusEffect.m_name); flag = true; } string iconText = statusEffect.GetIconText(); if (!string.Equals(cache.IconText, iconText, StringComparison.Ordinal)) { cache.IconText = iconText; flag = true; } if (flag) { cache.Text = (string.IsNullOrEmpty(cache.IconText) ? cache.DisplayName : (cache.DisplayName + " <color=#ffb75c>" + cache.IconText + "</color>")); } cache.Name.text = cache.Text; } } } internal static class AutoPickupRange { [HarmonyPatch(typeof(Player), "AutoPickup")] private static class Patch_Player_AutoPickup { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Prefix(Player __instance) { __instance.m_autoPickupRange = GetRange(); } } private static float GetRange() { float value = TweaksPlugin.CE_AutoPickupRange.Value; return (float.IsNaN(value) || float.IsInfinity(value)) ? 2f : Mathf.Max(0f, value); } } internal static class PlayerTuning { private sealed class PreviousValues { private bool _baseApplied; private bool _eitrApplied; private bool _staminaApplied; private bool _reachApplied; private (float Health, float Weight) _base; private (float Regen, float Delay) _eitr; private (float Base, float Regen, float Delay) _stamina; private (float Build, float Interact) _reach; [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] internal void Apply(Player player, bool restore = false) { bool flag = !restore && TweaksPlugin.CE_PlayerBase_Enabled.Value; bool flag2 = !restore && TweaksPlugin.CE_Eitr_Enabled.Value; bool flag3 = !restore && TweaksPlugin.CE_Stamina_Enabled.Value; bool flag4 = flag || _baseApplied || flag2 || _eitrApplied || flag3 || _staminaApplied; if (flag) { if (!_baseApplied) { _base = (Health: player.m_baseHP, Weight: player.m_maxCarryWeight); } player.m_baseHP = TweaksPlugin.CE_PlayerBase_Health.Value; player.m_maxCarryWeight = TweaksPlugin.CE_PlayerBase_CarryWeight.Value; } else if (_baseApplied) { (player.m_baseHP, player.m_maxCarryWeight) = _base; } _baseApplied = flag; if (flag2) { if (!_eitrApplied) { _eitr = (Regen: player.m_eiterRegen, Delay: player.m_eitrRegenDelay); } player.m_eiterRegen = TweaksPlugin.CE_Eitr_Regen.Value; player.m_eitrRegenDelay = TweaksPlugin.CE_Eitr_RegenDelay.Value; } else if (_eitrApplied) { (player.m_eiterRegen, player.m_eitrRegenDelay) = _eitr; } _eitrApplied = flag2; if (flag3) { if (!_staminaApplied) { _stamina = (Base: player.m_baseStamina, Regen: player.m_staminaRegen, Delay: player.m_staminaRegenDelay); } player.m_baseStamina = TweaksPlugin.CE_Stamina_Base.Value; player.m_staminaRegen = TweaksPlugin.CE_Stamina_Regen.Value; player.m_staminaRegenDelay = TweaksPlugin.CE_Stamina_RegenDelay.Value; } else if (_staminaApplied) { (player.m_baseStamina, player.m_staminaRegen, player.m_staminaRegenDelay) = _stamina; } _staminaApplied = flag3; bool flag5 = !restore && TweaksPlugin.CE_PlayerReach_Enabled.Value; if (flag5) { if (!_reachApplied) { _reach = (Build: player.m_maxPlaceDistance, Interact: player.m_maxInteractDistance); } player.m_maxPlaceDistance = TweaksPlugin.CE_PlayerReach_BuildDistance.Value; player.m_maxInteractDistance = TweaksPlugin.CE_PlayerReach_InteractDistance.Value; } else if (_reachApplied) { (player.m_maxPlaceDistance, player.m_maxInteractDistance) = _reach; } _reachApplied = flag5; if (flag4 && (Object)(object)((Character)player).m_nview != (Object)null && ((Character)player).m_nview.IsValid() && ((Character)player).m_nview.IsOwner()) { float num = default(float); float num2 = default(float); float num3 = default(float); player.GetTotalFoodValue(ref num, ref num2, ref num3); player.SetMaxHealth(num, false); player.SetMaxStamina(num2, false); player.SetMaxEitr(num3, false); } } } [HarmonyPatch(typeof(Player), "Awake")] private static class Patch_Player_Awake { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] [HarmonyPriority(0)] private static void Postfix(Player __instance) { PreviousValues previousValues = new PreviousValues(); Players[__instance] = previousValues; previousValues.Apply(__instance); } } [HarmonyPatch(typeof(Player), "OnDestroy")] private static class Patch_Player_OnDestroy { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Prefix(Player __instance) { Players.Remove(__instance); } } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] private static class Patch_Player_GetTotalFoodValue { private static void Postfix(ref float eitr) { if (TweaksPlugin.CE_Eitr_Enabled.Value) { eitr += TweaksPlugin.CE_Eitr_Base.Value; } } } [HarmonyPatch(typeof(SE_Stats), "ModifyMaxCarryWeight")] private static class Patch_SE_Stats_ModifyMaxCarryWeight { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(SE_Stats __instance, ref float limit) { if (!TweaksPlugin.CE_PlayerBase_Enabled.Value || !(((StatusEffect)__instance).m_character is Player) || (Object)(object)ObjectDB.instance == (Object)null) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("BeltStrength"); if (!((Object)(object)itemPrefab == (Object)null)) { StatusEffect val = itemPrefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared?.m_equipStatusEffect; if (!((Object)(object)val == (Object)null) && val.NameHash() == ((StatusEffect)__instance).NameHash()) { limit = Mathf.Max(0f, limit - __instance.m_addMaxCarryWeight + TweaksPlugin.CE_PlayerBase_MegingjordBonus.Value); } } } } [HarmonyPatch(typeof(InventoryGui), "Show", new Type[] { typeof(Container), typeof(int) })] private static class Patch_InventoryGui_Show { private static void Postfix() { RefreshContainerRange(); } } [<26038308-0667-4d67-809e-006db3876118>Nullable(1)] private static readonly Dictionary<Player, PreviousValues> Players = new Dictionary<Player, PreviousValues>(); [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static InventoryGui _containerGui; private static float _containerCloseDistance; internal static void RefreshPlayers() { foreach (KeyValuePair<Player, PreviousValues> player in Players) { if ((Object)(object)player.Key != (Object)null) { player.Value.Apply(player.Key); } } RefreshContainerRange(); } internal static void RestoreAll() { foreach (KeyValuePair<Player, PreviousValues> player in Players) { if ((Object)(object)player.Key != (Object)null) { player.Value.Apply(player.Key, restore: true); } } Players.Clear(); RefreshContainerRange(restore: true); } private static void RefreshContainerRange(bool restore = false) { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null) { _containerGui = null; } else if (!restore && TweaksPlugin.CE_PlayerReach_Enabled.Value) { if ((Object)(object)_containerGui != (Object)(object)instance) { _containerGui = instance; _containerCloseDistance = instance.m_autoCloseDistance; } instance.m_autoCloseDistance = Mathf.Max(_containerCloseDistance, TweaksPlugin.CE_PlayerReach_InteractDistance.Value); } else if ((Object)(object)_containerGui == (Object)(object)instance) { instance.m_autoCloseDistance = _containerCloseDistance; _containerGui = null; } } } internal static class ComfortRange { [HarmonyPatch(typeof(SE_Rested), "GetNearbyComfortPieces")] private static class Patch_SE_Rested_GetNearbyComfortPieces { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldc_R4 && instruction.operand is float num && Mathf.Approximately(num, 10f)), (string)null) }); if (!val.IsValid) { TweaksPlugin.Log.LogWarning((object)"ComfortRange: comfort radius constant not found in SE_Rested.GetNearbyComfortPieces. Feature disabled."); return val.InstructionEnumeration(); } val.SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ComfortRange), "GetRadius", (Type[])null, (Type[])null))); return val.InstructionEnumeration(); } } private const float VanillaRadius = 10f; internal static float GetRadius() { if (!TweaksPlugin.CE_ComfortRange_Enabled.Value) { return 10f; } float value = TweaksPlugin.CE_ComfortRange_Radius.Value; if (float.IsNaN(value) || float.IsInfinity(value)) { return 10f; } return Mathf.Max(0f, value); } } internal static class ForcePlayerPins { [HarmonyPatch(typeof(Player), "OnSpawned")] private static class Patch_Player_OnSpawned { private static void Postfix() { Apply(); } } [HarmonyPatch(typeof(ZNet), "SetPublicReferencePosition")] private static class Patch_ZNet_SetPublicReferencePosition { private static void Prefix(ref bool pub) { if (IsForced()) { pub = true; } } } internal static void Initialize() { TweaksPlugin.CE_ForcePlayerPins_Enabled.SettingChanged += delegate { Apply(); }; } private static bool IsForced() { return TweaksPlugin.CE_ForcePlayerPins_Enabled.Value && !TweaksPlugin.IsAdminBypassActive(); } private static void Apply() { if (IsForced() && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)ZNet.instance == (Object)null)) { ZNet.instance.SetPublicReferencePosition(true); } } } internal static class SkillDeathLoss { [HarmonyPatch(typeof(Skills), "LowerAllSkills")] private static class Patch_Skills_LowerAllSkills { [HarmonyPriority(500)] private static bool Prefix(ref float factor) { if (!TryGetFactor(out var factor2)) { return true; } if (factor2 <= 0f) { return false; } factor = factor2; return true; } } private static bool TryGetFactor(out float factor) { factor = 0f; if (!TweaksPlugin.CE_SkillDeathLoss_Enabled.Value) { return false; } float value = TweaksPlugin.CE_SkillDeathLoss_Factor.Value; if (float.IsNaN(value) || float.IsInfinity(value)) { return false; } float num = Game.m_skillReductionRate; if (float.IsNaN(num) || float.IsInfinity(num) || num < 0f) { num = 1f; } factor = Mathf.Clamp01(Mathf.Clamp01(value) * num); return true; } } internal static class SkillGain { [HarmonyPatch(typeof(Skills), "RaiseSkill")] private static class Patch_Skills_RaiseSkill { private static void Prefix(SkillType skillType, ref float factor) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) factor *= GetMultiplier(skillType); } } [<26038308-0667-4d67-809e-006db3876118>Nullable(new byte[] { 1, 2 })] private static ConfigEntry<float>[] _multipliers = Array.Empty<ConfigEntry<float>>(); internal static void Initialize() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected I4, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (SkillType key in TweaksPlugin.CE_SkillGain.Keys) { num = Math.Max(num, key + 1); } _multipliers = new ConfigEntry<float>[num]; foreach (KeyValuePair<SkillType, ConfigEntry<float>> item in TweaksPlugin.CE_SkillGain) { _multipliers[item.Key] = item.Value; } } private static float GetMultiplier(SkillType skill) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Expected I4, but got Unknown int num = (int)skill; if (num < 0 || num >= _multipliers.Length) { return 1f; } ConfigEntry<float> val = _multipliers[num]; if (val == null) { return 1f; } float value = val.Value; return (float.IsNaN(value) || float.IsInfinity(value)) ? 1f : Mathf.Max(0f, value); } } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] internal static class Trash { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] [HarmonyPatch(typeof(InventoryGui), "Hide")] private static class Patch_InventoryGui_Hide { private static void Postfix() { CloseDialog(); } } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] [HarmonyPatch(typeof(InventoryGui), "UpdateItemDrag")] private static class Patch_InventoryGui_UpdateItemDrag { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(InventoryGui __instance) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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: Unknown result type (might be due to invalid IL or missing references) if (!TweaksPlugin.CE_TrashOnDel_Enabled.Value || IsDialogOpen) { return; } KeyCode value = TweaksPlugin.CE_TrashOnDel_Key.Value; if ((int)value != 0 && ZInput.GetKeyDown(value, true) && !((Object)(object)__instance.m_dragGo == (Object)null)) { ItemData dragItem = __instance.m_dragItem; Inventory dragInventory = __instance.m_dragInventory; int dragAmount = __instance.m_dragAmount; if (CanDelete(dragItem, dragInventory, dragAmount)) { RequestDelete(dragItem, dragInventory, dragAmount); } } } } [CompilerGenerated] private static class <>O { [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] public static UnityAction <0>__DeletePending; [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] public static UnityAction <1>__CloseDialog; } private const string DialogName = "TweaksTrashConfirm"; private const string TitleToken = "$tweaks_trash_title"; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static GameObject _dialog; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static ItemData _pendingItem; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static Inventory _pendingInventory; private static int _pendingAmount; private static bool IsDialogOpen => (Object)(object)_dialog != (Object)null; [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(2)] private static bool CanDelete(ItemData item, Inventory inventory, int amount) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || item == null || inventory == null || amount <= 0) { return false; } if (inventory != ((Humanoid)localPlayer).m_inventory || !inventory.ContainsItem(item)) { return false; } return TweaksPlugin.CE_TrashOnDel_AllowHotbar.Value || item.m_gridPos.y != 0; } private static void RequestDelete(ItemData item, Inventory inventory, int amount) { _pendingItem = item; _pendingInventory = inventory; _pendingAmount = amount; if (TweaksPlugin.CE_TrashOnDel_Confirm.Value) { ShowConfirmDialog(item, amount); } else { DeletePending(); } } private static void DeletePending() { ItemData pendingItem = _pendingItem; Inventory pendingInventory = _pendingInventory; int pendingAmount = _pendingAmount; CloseDialog(); InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance == (Object)null) && CanDelete(pendingItem, pendingInventory, pendingAmount)) { Player localPlayer = Player.m_localPlayer; ((Humanoid)localPlayer).RemoveEquipAction(pendingItem); ((Humanoid)localPlayer).UnequipItem(pendingItem, false); if (pendingAmount >= pendingItem.m_stack) { pendingInventory.RemoveItem(pendingItem); } else { pendingInventory.RemoveItem(pendingItem, pendingAmount); } instance.SetupDragItem((ItemData)null, (Inventory)null, 0); instance.UpdateCraftingPanel(false); } } private static void ShowConfirmDialog(ItemData item, int amount) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00dd: 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_00e8: Expected O, but got Unknown InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || IsDialogOpen) { return; } SplitDialog splitDialog = instance.m_splitDialog; if (!((Object)(object)splitDialog == (Object)null)) { SplitDialog val = Object.Instantiate<SplitDialog>(splitDialog, ((Component)instance).transform); _dialog = ((Component)val).gameObject; ((Object)_dialog).name = "TweaksTrashConfirm"; val.SetActive(true); ((Behaviour)val).enabled = false; ((UnityEventBase)val.m_splitOkButton.onClick).RemoveAllListeners(); ((UnityEventBase)val.m_splitCancelButton.onClick).RemoveAllListeners(); ButtonClickedEvent onClick = val.m_splitOkButton.onClick; object obj = <>O.<0>__DeletePending; if (obj == null) { UnityAction val2 = DeletePending; <>O.<0>__DeletePending = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); ButtonClickedEvent onClick2 = val.m_splitCancelButton.onClick; object obj2 = <>O.<1>__CloseDialog; if (obj2 == null) { UnityAction val3 = CloseDialog; <>O.<1>__CloseDialog = val3; obj2 = (object)val3; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); val.UpdateLimits(Mathf.Max(1, amount), false); ((Component)val.m_splitSlider).gameObject.SetActive(false); string text = ((Localization.instance != null) ? Localization.instance.Localize("$tweaks_trash_title") : "Trash"); val.UpdateIcon(item.GetIcon(), text); val.m_splitAmount.text = amount.ToString(); } } private static void CloseDialog() { if ((Object)(object)_dialog != (Object)null) { Object.Destroy((Object)(object)_dialog); } _dialog = null; _pendingItem = null; _pendingInventory = null; _pendingAmount = 0; } } [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] internal static class ProtectedZoneBossAltar { private const string BuildBlockedMessage = "$tweaks_bossaltar_build_blocked"; private const string TerrainBlockedMessage = "$tweaks_bossaltar_terrain_blocked"; private const int ClassificationCacheLimit = 512; private static readonly HashSet<string> BossLocationNames = new HashSet<string>(StringComparer.Ordinal) { "Eikthyrnir", "GDKing", "Bonemass", "Dragonqueen", "GoblinKing", "Mistlands_DvergrBossEntrance1", "FaderLocation", "DN_Bossroom" }; private static readonly Dictionary<Location, bool> Classification = new Dictionary<Location, bool>(); internal static bool IsBlocked(Vector3 point, float margin, out ProtectedZoneBlock block) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) block = default(ProtectedZoneBlock); if (!TweaksPlugin.CE_BossAltarsProtection_Enabled.Value) { return false; } float value = TweaksPlugin.CE_BossAltarsProtection_Radius.Value; if (value <= 0f) { return false; } float num = value + Mathf.Max(0f, margin); foreach (Location s_allLocation in Location.s_allLocations) { if ((Object)(object)s_allLocation == (Object)null || !IsBossAltar(s_allLocation) || Utils.DistanceXZ(((Component)s_allLocation).transform.position, point) > num) { continue; } block = new ProtectedZoneBlock(ProtectedZoneKind.BossAltar, "$tweaks_bossaltar_build_blocked", "$tweaks_bossaltar_terrain_blocked"); return true; } return false; } private static bool IsBossAltar(Location location) { if (Classification.TryGetValue(location, out var value)) { return value; } if (Classification.Count >= 512) { Classification.Clear(); } value = BossLocationNames.Contains(Utils.GetPrefabName(((Component)location).gameObject)); Classification[location] = value; return value; } } internal enum ProtectedZoneKind { BossAltar, Object } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] internal readonly struct ProtectedZoneBlock { internal readonly ProtectedZoneKind Kind; internal readonly string BuildMessage; internal readonly string TerrainMessage; internal ProtectedZoneBlock(ProtectedZoneKind kind, string buildMessage, string terrainMessage) { Kind = kind; BuildMessage = buildMessage; TerrainMessage = terrainMessage; } } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] internal static class ProtectedZoneManager { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] [HarmonyPatch(typeof(ZNetView), "Awake")] private static class Patch_ZNetView_Awake { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(ZNetView __instance) { ProtectedZoneObjects.RegisterView(__instance); } } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] [HarmonyPatch(typeof(ZNetView), "OnDestroy")] private static class Patch_ZNetView_OnDestroy { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Prefix(ZNetView __instance) { ProtectedZoneObjects.UnregisterView(__instance); } } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] private static class Patch_Player_UpdatePlacementGhost { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(Player __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && (int)__instance.m_placementStatus <= 0 && TryGetGhostBlock(__instance, out var _)) { __instance.m_placementStatus = (PlacementStatus)1; __instance.SetPlacementGhostValid(false); } } } [HarmonyPatch(typeof(Player), "TryPlacePiece")] [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] private static class Patch_Player_TryPlacePiece { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] [HarmonyPriority(600)] private static bool Prefix(Player __instance, ref bool __result) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (!TryGetGhostBlock(__instance, out var block)) { return true; } Show(block.BuildMessage); __result = false; return false; } } [HarmonyPatch(typeof(Attack), "SpawnOnHitTerrain")] [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] private static class Patch_Attack_SpawnOnHitTerrain { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static bool Prefix(Vector3 hitPoint, GameObject prefab, Character character, [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] ref GameObject __result) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab == (Object)null)) { Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { if (!TryGetTerrainRadius(prefab, out var radius)) { return true; } if (!TryGetBlock(hitPoint, radius, out var block)) { return true; } if ((Object)(object)val == (Object)(object)Player.m_localPlayer) { Show(block.TerrainMessage); } __result = null; return false; } } return true; } } private const string CloneSuffix = "(Clone)"; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static GameObject _marginGhost; private static float _marginGhostRadius; internal static bool TryGetBlock(Vector3 point, float margin, out ProtectedZoneBlock block) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) block = default(ProtectedZoneBlock); if (TweaksPlugin.IsAdminBypassActive()) { return false; } return ProtectedZoneBossAltar.IsBlocked(point, margin, out block) || ProtectedZoneObjects.IsBlocked(point, margin, out block); } internal static string Normalize(string name) { if (string.IsNullOrEmpty(name)) { return string.Empty; } return name.EndsWith("(Clone)", StringComparison.Ordinal) ? name.Substring(0, name.Length - "(Clone)".Length).TrimEnd(Array.Empty<char>()) : name; } internal static void ParseNames(HashSet<string> target, [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] string raw) { target.Clear(); if (string.IsNullOrWhiteSpace(raw)) { return; } string[] array = raw.Split(new char[1] { ',' }); foreach (string text in array) { string text2 = Normalize(text.Trim()); if (text2.Length > 0) { target.Add(text2); } } } private static bool TryGetTerrainRadius(GameObject go, out float radius) { TerrainOp componentInChildren = go.GetComponentInChildren<TerrainOp>(); if ((Object)(object)componentInChildren != (Object)null) { radius = componentInChildren.GetRadius(); return true; } TerrainModifier componentInChildren2 = go.GetComponentInChildren<TerrainModifier>(); if ((Object)(object)componentInChildren2 != (Object)null) { radius = componentInChildren2.GetRadius(); return true; } radius = 0f; return false; } private static float GetGhostMargin(GameObject ghost) { if ((Object)(object)ghost != (Object)(object)_marginGhost) { _marginGhost = ghost; _marginGhostRadius = (TryGetTerrainRadius(ghost, out var radius) ? radius : 0f); } return _marginGhostRadius; } private static bool TryGetGhostBlock(Player player, out ProtectedZoneBlock block) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) block = default(ProtectedZoneBlock); GameObject placementGhost = player.m_placementGhost; if ((Object)(object)placementGhost == (Object)null || !placementGhost.activeSelf) { return false; } return TryGetBlock(placementGhost.transform.position, GetGhostMargin(placementGhost), out block); } private static void Show(string message) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ((Character)localPlayer).Message((MessageType)2, message, 0, (Sprite)null, false); } } } [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] internal static class ProtectedZoneObjects { private const string BuildBlockedMessage = "$tweaks_protectedareaobjects_build_blocked"; private const string TerrainBlockedMessage = "$tweaks_protectedareaobjects_terrain_blocked"; private const int ClassificationCacheLimit = 512; private static readonly HashSet<string> LocationNames = new HashSet<string>(StringComparer.Ordinal); private static readonly HashSet<string> ViewNames = new HashSet<string>(StringComparer.Ordinal); private static readonly HashSet<int> ViewPrefabHashes = new HashSet<int>(); private static readonly Dictionary<Location, bool> LocationClassification = new Dictionary<Location, bool>(); private static readonly HashSet<ZNetView> ActiveViews = new HashSet<ZNetView>(); internal static void Initialize() { TweaksPlugin.CE_ProtectedAreaObjects_Locations.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { RefreshLocations(); }; TweaksPlugin.CE_ProtectedAreaObjects_Vegetations.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { RefreshViews(); }; RefreshLocations(); RefreshViews(); } internal static void RegisterView(ZNetView view) { if (ViewPrefabHashes.Count != 0 && !((Object)(object)view == (Object)null)) { ZDO zDO = view.GetZDO(); if (zDO != null && ViewPrefabHashes.Contains(zDO.GetPrefab())) { ActiveViews.Add(view); } } } internal static void UnregisterView(ZNetView view) { if (ActiveViews.Count > 0 && (Object)(object)view != (Object)null) { ActiveViews.Remove(view); } } internal static bool IsBlocked(Vector3 point, float margin, out ProtectedZoneBlock block) { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) block = default(ProtectedZoneBlock); if (!TweaksPlugin.CE_ProtectedAreaObjects_Enabled.Value) { return false; } if (LocationNames.Count == 0 && ActiveViews.Count == 0) { return false; } float value = TweaksPlugin.CE_ProtectedAreaObjects_Radius.Value; if (value <= 0f) { return false; } float num = value + Mathf.Max(0f, margin); if (LocationNames.Count > 0) { foreach (Location s_allLocation in Location.s_allLocations) { if ((Object)(object)s_allLocation != (Object)null && IsProtectedLocation(s_allLocation) && Utils.DistanceXZ(((Component)s_allLocation).transform.position, point) <= num) { return CreateBlock(out block); } } } foreach (ZNetView activeView in ActiveViews) { if ((Object)(object)activeView != (Object)null && Utils.DistanceXZ(((Component)activeView).transform.position, point) <= num) { return CreateBlock(out block); } } return false; } private static bool IsProtectedLocation(Location location) { if (LocationClassification.TryGetValue(location, out var value)) { return value; } if (LocationClassification.Count >= 512) { LocationClassification.Clear(); } value = LocationNames.Contains(Utils.GetPrefabName(((Component)location).gameObject)); LocationClassification[location] = value; return value; } private static bool CreateBlock(out ProtectedZoneBlock block) { block = new ProtectedZoneBlock(ProtectedZoneKind.Object, "$tweaks_protectedareaobjects_build_blocked", "$tweaks_protectedareaobjects_terrain_blocked"); return true; } private static void RefreshLocations() { ProtectedZoneManager.ParseNames(LocationNames, TweaksPlugin.CE_ProtectedAreaObjects_Locations.Value); LocationClassification.Clear(); } private static void RefreshViews() { ProtectedZoneManager.ParseNames(ViewNames, TweaksPlugin.CE_ProtectedAreaObjects_Vegetations.Value); ViewPrefabHashes.Clear(); foreach (string viewName in ViewNames) { ViewPrefabHashes.Add(StringExtensionMethods.GetStableHashCode(viewName)); } ActiveViews.Clear(); if (ViewPrefabHashes.Count != 0) { ZNetView[] array = Object.FindObjectsByType<ZNetView>((FindObjectsSortMode)0); foreach (ZNetView view in array) { RegisterView(view); } } } } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] internal static class AssetLoader { private const string ResourceName = "Tweaks.assets.rd_tweaks"; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static AssetBundle _bundle; private static bool _loadAttempted; [return: <26038308-0667-4d67-809e-006db3876118>Nullable(2)] internal static Sprite GetSprite(string name) { AssetBundle bundle = GetBundle(); if ((Object)(object)bundle == (Object)null) { return null; } try { Sprite val = bundle.LoadAsset<Sprite>(name); if ((Object)(object)val == (Object)null) { TweaksPlugin.Log.LogWarning((object)("Sprite '" + name + "' was not found in 'Tweaks.assets.rd_tweaks'.")); } return val; } catch (Exception ex) { TweaksPlugin.Log.LogWarning((object)("Failed to load sprite '" + name + "': " + ex.Message)); return null; } } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(2)] private static AssetBundle GetBundle() { if ((Object)(object)_bundle != (Object)null || _loadAttempted) { return _bundle; } _loadAttempted = true; try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Tweaks.assets.rd_tweaks"); if (stream == null) { TweaksPlugin.Log.LogWarning((object)"Embedded resource 'Tweaks.assets.rd_tweaks' was not found."); return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); _bundle = AssetBundle.LoadFromMemory(memoryStream.ToArray()); if ((Object)(object)_bundle == (Object)null) { TweaksPlugin.Log.LogWarning((object)"Asset bundle 'Tweaks.assets.rd_tweaks' could not be loaded."); } } catch (Exception ex) { TweaksPlugin.Log.LogWarning((object)("Failed to load asset bundle 'Tweaks.assets.rd_tweaks': " + ex.Message)); _bundle = null; } return _bundle; } } [BepInPlugin("radamanto.Tweaks", "Tweaks", "1.2.3")] [<26038308-0667-4d67-809e-006db3876118>Nullable(0)] [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] public class TweaksPlugin : BaseUnityPlugin { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] private sealed class ConfigurationManagerAttributes { public bool? Browsable = false; } internal static ConfigEntry<bool> CE_AdminBypass = null; internal static ConfigEntry<bool> CE_ForcePlayerPins_Enabled = null; internal static ConfigEntry<bool> CE_JoinMessage_Enabled = null; internal static ConfigEntry<string> CE_JoinMessage_Text = null; internal static ConfigEntry<bool> CE_Plants_IgnoreBiome = null; internal static ConfigEntry<bool> CE_AllFaction_Enabled = null; internal static ConfigEntry<Faction> CE_AllFaction_AnimalsVeg = null; internal static ConfigEntry<Faction> CE_AllFaction_ForestMonsters = null; internal static ConfigEntry<Faction> CE_AllFaction_Undead = null; internal static ConfigEntry<Faction> CE_AllFaction_Demon = null; internal static ConfigEntry<Faction> CE_AllFaction_MountainMonsters = null; internal static ConfigEntry<Faction> CE_AllFaction_SeaMonsters = null; internal static ConfigEntry<Faction> CE_AllFaction_PlainsMonsters = null; internal static ConfigEntry<Faction> CE_AllFaction_Boss = null; internal static ConfigEntry<Faction> CE_AllFaction_MistlandsMonsters = null; internal static ConfigEntry<Faction> CE_AllFaction_DeepNorth = null; internal static ConfigEntry<bool> CE_TrashOnDel_Enabled = null; internal static ConfigEntry<KeyCode> CE_TrashOnDel_Key = null; internal static ConfigEntry<bool> CE_TrashOnDel_Confirm = null; internal static ConfigEntry<bool> CE_TrashOnDel_AllowHotbar = null; internal static ConfigEntry<bool> CE_FloatItems_Enabled = null; internal static ConfigEntry<bool> CE_ClockHud_Enabled = null; internal static ConfigEntry<bool> CE_ClockHud_ShowDay = null; internal static ConfigEntry<bool> CE_ClockHud_ShowGameTime = null; internal static ConfigEntry<bool> CE_ClockHud_ShowRealTime = null; internal static ConfigEntry<int> CE_ClockHud_FontSize = null; internal static ConfigEntry<bool> CE_ClockHud_ShowIcon = null; internal static ConfigEntry<float> CE_ClockHud_IconSize = null; internal static ConfigEntry<float> CE_AutoPickupRange = null; internal static ConfigEntry<bool> CE_ComfortRange_Enabled = null; internal static ConfigEntry<float> CE_ComfortRange_Radius = null; internal static ConfigEntry<bool> CE_SkillDeathLoss_Enabled = null; internal static ConfigEntry<float> CE_SkillDeathLoss_Factor = null; internal static readonly Dictionary<SkillType, ConfigEntry<float>> CE_SkillGain = new Dictionary<SkillType, ConfigEntry<float>>(); internal static ConfigEntry<bool> CE_BossAltarsProtection_Enabled = null; internal static ConfigEntry<float> CE_BossAltarsProtection_Radius = null; internal static ConfigEntry<bool> CE_ProtectedAreaObjects_Enabled = null; internal static ConfigEntry<float> CE_ProtectedAreaObjects_Radius = null; internal static ConfigEntry<string> CE_ProtectedAreaObjects_Locations = null; internal static ConfigEntry<string> CE_ProtectedAreaObjects_Vegetations = null; internal static ConfigEntry<bool> CE_SmallStatusEffect_Enabled = null; internal static ConfigEntry<bool> CE_Workbench_AutoRepair = null; internal static ConfigEntry<float> CE_Workbench_BuildRadius = null; internal static ConfigEntry<float> CE_Workbench_PlayerBaseRadius = null; internal static ConfigEntry<bool> CE_Workbench_IgnoreRoof = null; internal static ConfigEntry<bool> CE_Workbench_IgnoreFire = null; internal static ConfigEntry<float> CE_Workbench_ExtensionRadius = null; internal static ConfigEntry<bool> CE_Structures_Enabled = null; internal static ConfigEntry<bool> CE_Structures_IgnoreSupport = null; internal static readonly Dictionary<MaterialType, ConfigEntry<float>> CE_StructureSupportLoss = new Dictionary<MaterialType, ConfigEntry<float>>(); internal static ConfigEntry<bool> CE_Vehicles_PreventBoatDamage = null; internal static ConfigEntry<bool> CE_Vehicles_PreventBoatWaterDamage = null; internal static ConfigEntry<bool> CE_Vehicles_PreventCartDamage = null; internal static ConfigEntry<bool> CE_Vehicles_PreventCartWaterDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_Enabled = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventRainDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventWaterDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventPlayerDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventCreatureDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventTamedDamage = null; internal static ConfigEntry<float> CE_StructuresDamage_PlayerReduction = null; internal static ConfigEntry<float> CE_StructuresDamage_CreatureReduction = null; internal static ConfigEntry<float> CE_StructuresDamage_TamedReduction = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventSnowDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventAshlandsDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventFireDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventImpactDamage = null; internal static ConfigEntry<bool> CE_StructuresDamage_PreventTreeDamage = null; internal static ConfigEntry<bool> CE_PlayerBase_Enabled = null; internal static ConfigEntry<float> CE_PlayerBase_Health = null; internal static ConfigEntry<float> CE_PlayerBase_CarryWeight = null; internal static ConfigEntry<float> CE_PlayerBase_MegingjordBonus = null; internal static ConfigEntry<bool> CE_Eitr_Enabled = null; internal static ConfigEntry<float> CE_Eitr_Base = null; internal static ConfigEntry<float> CE_Eitr_Regen = null; internal static ConfigEntry<float> CE_Eitr_RegenDelay = null; internal static ConfigEntry<bool> CE_Stamina_Enabled = null; internal static ConfigEntry<float> CE_Stamina_Base = null; internal static ConfigEntry<float> CE_Stamina_Regen = null; internal static ConfigEntry<float> CE_Stamina_RegenDelay = null; internal static ConfigEntry<bool> CE_PlayerReach_Enabled = null; internal static ConfigEntry<float> CE_PlayerReach_BuildDistance = null; internal static ConfigEntry<float> CE_PlayerReach_InteractDistance = null; internal static ConfigEntry<bool> CE_DayCycle_Enabled = null; internal static ConfigEntry<float> CE_DayCycle_DayRate = null; internal static ConfigEntry<bool> CE_SeedPrivacy_Enabled = null; internal static ConfigEntry<bool> CE_SeedPrivacy_AdminBypass = null; internal static ConfigEntry<bool> CE_SeedPrivacy_BlockPrintSeeds = null; internal static ConfigEntry<bool> CE_SeedPrivacy_HideSeedInPlayFab = null; [<26038308-0667-4d67-809e-006db3876118>Nullable(new byte[] { 1, 0, 1, 1 })] private static readonly (SkillType Skill, string Key, string Label)[] SkillGainDefinitions = new(SkillType, string, string)[24] { ((SkillType)1, "Swords", "Swords"), ((SkillType)2, "Knives", "Knives"), ((SkillType)3, "Clubs", "Clubs"), ((SkillType)4, "Polearms", "Polearms"), ((SkillType)5, "Spears", "Spears"), ((SkillType)6, "Blocking", "Blocking"), ((SkillType)7, "Axes", "Axes"), ((SkillType)8, "Bows", "Bows"), ((SkillType)14, "Crossbows", "Crossbows"), ((SkillType)11, "Unarmed", "Unarmed"), ((SkillType)9, "ElementalMagic", "Elemental Magic"), ((SkillType)10, "BloodMagic", "Blood Magic"), ((SkillType)12, "Pickaxes", "Pickaxes"), ((SkillType)13, "WoodCutting", "Wood Cutting"), ((SkillType)102, "Run", "Run"), ((SkillType)100, "Jump", "Jump"), ((SkillType)101, "Sneak", "Sneak"), ((SkillType)103, "Swim", "Swim"), ((SkillType)104, "Fishing", "Fishing"), ((SkillType)107, "Crafting", "Crafting"), ((SkillType)105, "Cooking", "Cooking"), ((SkillType)106, "Farming", "Farming"), ((SkillType)108, "Dodge", "Dodge"), ((SkillType)110, "Ride", "Ride") }; public const string ModGUID = "radamanto.Tweaks"; public const string ModName = "Tweaks"; public const string ModVersion = "1.2.3"; internal static ManualLogSource Log = null; private readonly Harmony _harmony = new Harmony("radamanto.Tweaks"); private const double ConfigReloadQuietSeconds = 0.75; private const int ConfigReloadAttempts = 3; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] internal static ConfigSync ConfigSync; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private static ConfigEntry<bool> _serverConfigLocked; [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] private FileSystemWatcher _configWatcher; private long _lastConfigWrite; private bool _reloadScheduled; private bool _watcherReady; private void BindConfig() { BindGeneral(); BindMapPins(); BindJoinMessage(); BindPlants(); BindFactionRemap(); BindTrash(); BindFloatItems(); BindClockHud(); BindAutoPickupRange(); BindComfortRange(); BindSkillDeathLoss(); BindSkillGain(); BindBossAltarsProtection(); BindProtectedAreaObjects(); BindSmallStatusEffect(); BindWorkbench(); BindStructures(); BindVehicles(); BindStructuresDamage(); BindPlayerTuning(); BindDayCycle(); BindSeedPrivacy(); } private void BindGeneral() { CE_AdminBypass = Cfg("01 - General", "01.01 - AdminBypass", defaultValue: true, "If true, admins bypass supported Tweaks restrictions."); } private void BindMapPins() { CE_ForcePlayerPins_Enabled = Cfg("02 - MapPins", "02.01 - ForceAllPlayersVisible", defaultValue: false, "Forces players to keep their public map position enabled."); } private void BindJoinMessage() { CE_JoinMessage_Enabled = Cfg("03 - JoinMessage", "03.01 - Enabled", defaultValue: false, "Enables the join message."); CE_JoinMessage_Text = Cfg("03 - JoinMessage", "03.02 - Text", "A player has arrived.", "Join message text."); } private void BindPlants() { CE_Plants_IgnoreBiome = Cfg("04 - Plants", "04.01 - IgnoreBiome", defaultValue: true, "Allows planting and growing crops and saplings in any biome."); } private void BindFactionRemap() { CE_AllFaction_Enabled = Cfg("05 - FactionRemap", "05.01 - Enabled", defaultValue: false, "Enables faction remapping for creatures."); CE_AllFaction_AnimalsVeg = Cfg<Faction>("05 - FactionRemap", "05.02 - AnimalsVegToFaction", (Faction)1, "Faction used for passive wildlife."); CE_AllFaction_ForestMonsters = Cfg<Faction>("05 - FactionRemap", "05.03 - ForestMonstersToFaction", (Faction)2, "Faction used for Black Forest creatures."); CE_AllFaction_Undead = Cfg<Faction>("05 - FactionRemap", "05.04 - UndeadToFaction", (Faction)3, "Faction used for undead creatures."); CE_AllFaction_Demon = Cfg<Faction>("05 - FactionRemap", "05.05 - DemonToFaction", (Faction)4, "Faction used for Demon creatures."); CE_AllFaction_MountainMonsters = Cfg<Faction>("05 - FactionRemap", "05.06 - MountainMonstersToFaction", (Faction)5, "Faction used for Mountain creatures."); CE_AllFaction_SeaMonsters = Cfg<Faction>("05 - FactionRemap", "05.07 - SeaMonstersToFaction", (Faction)6, "Faction used for ocean creatures."); CE_AllFaction_PlainsMonsters = Cfg<Faction>("05 - FactionRemap", "05.08 - PlainsMonstersToFaction", (Faction)7, "Faction used for Plains creatures."); CE_AllFaction_Boss = Cfg<Faction>("05 - FactionRemap", "05.09 - BossToFaction", (Faction)8, "Faction used for bosses."); CE_AllFaction_MistlandsMonsters = Cfg<Faction>("05 - FactionRemap", "05.10 - MistlandsMonstersToFaction", (Faction)9, "Faction used for Mistlands creatures."); CE_AllFaction_DeepNorth = Cfg<Faction>("05 - FactionRemap", "05.11 - DeepNorthToFaction", (Faction)13, "Faction used for Deep North creatures."); } private void BindTrash() { CE_TrashOnDel_Enabled = Cfg("06 - Trash", "06.01 - DeleteWithDelKey", defaultValue: true, "Allows deleting the dragged item using a key."); CE_TrashOnDel_Key = Cfg<KeyCode>("06 - Trash", "06.02 - DeleteKey", (KeyCode)127, "Key used to delete the dragged item.", synced: false); CE_TrashOnDel_Confirm = Cfg("06 - Trash", "06.03 - ConfirmDelete", defaultValue: false, "Asks for confirmation before deleting.", synced: false); CE_TrashOnDel_AllowHotbar = Cfg("06 - Trash", "06.04 - AllowDeleteHotbar", defaultValue: false, "Allows deleting items from the hotbar."); } private void BindFloatItems() { CE_FloatItems_Enabled = Cfg("07 - FloatItems", "07.01 - Enabled", defaultValue: true, "Makes dropped items float in water."); } private void BindClockHud() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown CE_ClockHud_Enabled = Cfg("08 - ClockHud", "08.01 - Enabled", defaultValue: true, "Shows a simple clock at the top center of the screen."); CE_ClockHud_ShowDay = Cfg("08 - ClockHud", "08.02 - ShowDay", defaultValue: true, "Shows the in-game day number.", synced: false); CE_ClockHud_ShowGameTime = Cfg("08 - ClockHud", "08.03 - ShowGameTime", defaultValue: true, "Shows the in-game time.", synced: false); CE_ClockHud_ShowRealTime = Cfg("08 - ClockHud", "08.04 - ShowRealTime", defaultValue: true, "Shows the real (system) time.", synced: false); CE_ClockHud_FontSize = Cfg("08 - ClockHud", "08.05 - FontSize", 28, "Clock font size.", synced: false, (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 48)); string[] array = new string[3] { "08.09 - ColorDay", "08.10 - ColorGameTime", "08.11 - ColorRealTime" }; foreach (string text in array) { ((BaseUnityPlugin)this).Config.Bind<string>("08 - ClockHud", text, string.Empty, (ConfigDescription)null); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("08 - ClockHud", text)); } CE_ClockHud_ShowIcon = Cfg("08 - ClockHud", "08.12 - ShowIcon", defaultValue: true, "Shows the day/night icon.", synced: false); CE_ClockHud_IconSize = Cfg("08 - ClockHud", "08.13 - IconSize", 34f, "Day/Night icon size in pixels.", synced: false, (AcceptableValueBase)(object)new AcceptableValueRange<float>(8f, 128f)); } private void BindAutoPickupRange() { CE_AutoPickupRange = Cfg("09 - AutoPickupRange", "09.01 - Range", 6f, "Auto-pickup radius (meters). Vanilla is 2.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f)); } private void BindComfortRange() { CE_ComfortRange_Enabled = Cfg("10 - ComfortRange", "10.01 - Enabled", defaultValue: true, "Enable global comfort search radius override."); CE_ComfortRange_Radius = Cfg("10 - ComfortRange", "10.02 - Radius", 25f, "Comfort search radius (meters). Vanilla is 10.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f)); } private void BindSkillDeathLoss() { CE_SkillDeathLoss_Enabled = Cfg("11 - SkillDeathLoss", "11.01 - Enabled", defaultValue: true, "If true, replaces the vanilla death skill loss factor. World modifiers (skill reduction rate / skill reset on death) are still respected."); CE_SkillDeathLoss_Factor = Cfg("11 - SkillDeathLoss", "11.02 - LossFactor", 0.05f, "Fraction of each skill level lost on death (0 to 1), multiplied by the world skill reduction modifier. Vanilla is 0.05 (5%). Set 0 to disable skill loss.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f)); } private void BindSkillGain() { //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_0035: Unknown result type (might be due to invalid IL or missing references) CE_SkillGain.Clear(); for (int i = 0; i < SkillGainDefinitions.Length; i++) { var (key, arg, text) = SkillGainDefinitions[i]; CE_SkillGain[key] = Cfg("12 - SkillGain", $"12.{i + 1:00} - {arg}", 1f, "Skill gain multiplier for " + text + ". Example: 0.75 = 75% of vanilla gain.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f)); } } private void BindBossAltarsProtection() { CE_BossAltarsProtection_Enabled = Cfg("13 - AltarsProtection", "13.01 - BossAltarsProtectionEnabled", defaultValue: true, "Enables protection around boss altars for building and terrain modification."); CE_BossAltarsProtection_Radius = Cfg("13 - AltarsProtection", "13.02 - BossAltarsProtectionRadius", 50f, "Protection radius around boss altars for building and terrain modification.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 500f)); } private void BindProtectedAreaObjects() { CE_ProtectedAreaObjects_Enabled = Cfg("14 - ProtectedAreaObjects", "14.01 - Enabled", defaultValue: true, "Enable protection around configured locations and vegetation/object prefabs."); CE_ProtectedAreaObjects_Radius = Cfg("14 - ProtectedAreaObjects", "14.02 - Radius", 25f, "Protection radius around configured locations and vegetation/object prefabs.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 500f)); CE_ProtectedAreaObjects_Locations = Cfg("14 - ProtectedAreaObjects", "14.03 - Locations", "", "Comma-separated Location names protected against building and terrain editing.\nExample: SunkenCrypt4,Crypt2,Crypt3,Crypt4,TrollCave02,MountainCave02,GoblinCamp2,Mistlands_Excavation1"); CE_ProtectedAreaObjects_Vegetations = Cfg("14 - ProtectedAreaObjects", "14.04 - Vegetations", "", "Comma-separated vegetation/object prefab names protected against building and terrain editing. Only prefabs with ZNetView are registered by this system.\nExample: rock4_copper,silvervein"); } private void BindSmallStatusEffect() { CE_SmallStatusEffect_Enabled = Cfg("15 - SmallStatusEffect", "15.01 - Enabled", defaultValue: true, "Enables compact status effect HUD layout."); } private void BindWorkbench() { CE_Workbench_AutoRepair = Cfg("16 - Workbench", "16.01 - AutoRepair", defaultValue: false, "Automatically repairs eligible inventory items when opening a crafting station. Uses the station's normal repair requirements and plays the repair effect once."); CE_Workbench_BuildRadius = Cfg("16 - Workbench", "16.02 - BuildRadius", 20f, "Base construction radius in meters for crafting stations. Extra range from station levels remains unchanged.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 650f)); CE_Workbench_PlayerBaseRadius = Cfg("16 - Workbench", "16.03 - PlayerBaseRadius", 20f, "Radius in meters of crafting stations' PlayerBase areas, which prevent normal enemy spawns. Does not change other base objects.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 650f)); CE_Workbench_IgnoreRoof = Cfg("16 - Workbench", "16.04 - IgnoreRoof", defaultValue: false, "Allows using crafting stations without a roof or shelter."); CE_Workbench_IgnoreFire = Cfg("16 - Workbench", "16.05 - IgnoreFire", defaultValue: false, "Allows using crafting stations without a nearby fire."); CE_Workbench_ExtensionRadius = Cfg("16 - Workbench", "16.06 - ExtensionRadius", 5f, "Maximum distance in meters between crafting stations and their upgrade extensions.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 650f)); CE_Workbench_BuildRadius.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { CraftingStations.RefreshRanges(); }; CE_Workbench_PlayerBaseRadius.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { CraftingStations.RefreshRanges(); }; CE_Workbench_ExtensionRadius.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { CraftingStations.RefreshRanges(); }; } private void BindStructures() { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) CE_Structures_Enabled = Cfg("17 - Structures", "17.01 - Enabled", defaultValue: false, "Enables structural support adjustments in this section. Damage and vehicle settings are independent."); CE_Structures_IgnoreSupport = Cfg("17 - Structures", "17.02 - IgnoreSupport", defaultValue: false, "Allows pieces to remain standing without structural support, including floating buildings. Does not prevent attack or weather damage."); (MaterialType, string)[] array = new(MaterialType, string)[9] { ((MaterialType)0, "Wood"), ((MaterialType)1, "Stone"), ((MaterialType)2, "Iron"), ((MaterialType)3, "HardWood"), ((MaterialType)4, "Marble"), ((MaterialType)5, "Ashstone"), ((MaterialType)6, "Ancient"), ((MaterialType)7, "Ice"), ((MaterialType)8, "Timberwood") }; for (int i = 0; i < array.Length; i++) { var (key, text) = array[i]; CE_StructureSupportLoss[key] = Cfg("17 - Structures", $"17.{i + 4:00} - {text}SupportLossReduction", 0f, "Percentage reduction of horizontal and vertical support loss for " + text + ". 0 keeps vanilla values; 100 removes loss over distance but still requires support unless IgnoreSupport is enabled.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f)); } } private void BindVehicles() { CE_Vehicles_PreventBoatDamage = Cfg("18 - Vehicles", "18.01 - PreventBoatDamage", defaultValue: false, "Prevents WearNTear damage to boats, including hits, collisions and wear. Also applies to modded boats using Ship."); CE_Vehicles_PreventBoatWaterDamage = Cfg("18 - Vehicles", "18.02 - PreventBoatWaterDamage", defaultValue: false, "Prevents boat water-impact damage and wear from submersion. Other damage remains enabled unless PreventBoatDamage is on."); CE_Vehicles_PreventCartDamage = Cfg("18 - Vehicles", "18.03 - PreventCartDamage", defaultValue: false, "Prevents WearNTear damage to carts, including hits and wear. Also applies to modded carts using Vagon."); CE_Vehicles_PreventCartWaterDamage = Cfg("18 - Vehicles", "18.04 - PreventCartWaterDamage", defaultValue: false, "Prevents cart wear caused by submersion. Rain, hits and other damage remain enabled unless PreventCartDamage is on."); } private void BindStructuresDamage() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown ((BaseUnityPlugin)this).Config.Bind<bool>("17 - Structures", "17.03 - PreventHitDamage", false, (ConfigDescription)null); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("17 - Structures", "17.03 - PreventHitDamage")); string[] array = new string[2] { "19.01 - PreventRainAndWaterWear", "19.02 - CustomRain" }; foreach (string text in array) { ((BaseUnityPlugin)this).Config.Bind<bool>("19 - WeatherDamage", text, false, (ConfigDescription)null); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("19 - WeatherDamage", text)); } string[] array2 = new string[3] { "19.03 - DamagePercent", "19.04 - IntervalSeconds", "19.05 - MinimumHealthPercent" }; foreach (string text2 in array2) { ((BaseUnityPlugin)this).Config.Bind<float>("19 - WeatherDamage", text2, 0f, (ConfigDescription)null); ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition("19 - WeatherDamage", text2)); } CE_StructuresDamage_Enabled = Cfg("19 - StructuresDamage", "19.01 - Enabled", defaultValue: true, "Enables the building damage controls below. Structural support and vehicles use their own settings."); CE_StructuresDamage_PreventRainDamage = Cfg("19 - StructuresDamage", "19.02 - PreventRainDamage", defaultValue: true, "Prevents normal rain wear on buildings placed by players. Requires Enabled."); CE_StructuresDamage_PreventWaterDamage = Cfg("19 - StructuresDamage", "19.03 - PreventWaterDamage", defaultValue: true, "Prevents submersion wear on buildings placed by players. Requires Enabled."); CE_StructuresDamage_PreventPlayerDamage = Cfg("19 - StructuresDamage", "19.04 - PreventPlayerDamage", defaultValue: true, "Enables player damage reduction on buildings placed by players, including attacks by the creator. Requires Enabled."); CE_StructuresDamage_PreventCreatureDamage = Cfg("19 - StructuresDamage", "19.05 - PreventCreatureDamage", defaultValue: true, "Enables wild creature damage reduction on buildings placed by players. Tamed creatures use their own setting. Requires Enabled."); CE_StructuresDamage_PreventTamedDamage = Cfg("19 - StructuresDamage", "19.11 - PreventTamedDamage", defaultValue: true, "Enables tamed creature damage reduction on buildings placed by players. Requires Enabled."); CE_StructuresDamage_PlayerReduction = Cfg("19 - StructuresDamage", "19.12 - PlayerDamageReduction", 100f, "Player damage reduction percentage, including the creator: 0 keeps normal damage; 100 blocks the attack. Requires Enabled and PreventPlayerDamage.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f)); CE_StructuresDamage_CreatureReduction = Cfg("19 - StructuresDamage", "19.13 - CreatureDamageReduction", 100f, "Wild creature damage reduction percentage: 0 keeps normal damage; 100 blocks the attack. Requires Enabled and PreventCreatureDamage.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f)); CE_StructuresDamage_TamedReduction = Cfg("19 - StructuresDamage", "19.14 - TamedDamageReduction", 100f, "Tamed creature damage reduction percentage: 0 keeps normal damage; 100 blocks the attack. Requires Enabled and PreventTamedDamage.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f)); CE_StructuresDamage_PreventSnowDamage = Cfg("19 - StructuresDamage", "19.06 - PreventSnowDamage", defaultValue: true, "Prevents accumulated snow damage to buildings placed by players, including when world rules enable snow damage for all materials. Snow visuals and structural support remain active. Requires Enabled."); CE_StructuresDamage_PreventAshlandsDamage = Cfg("19 - StructuresDamage", "19.07 - PreventAshlandsDamage", defaultValue: true, "Prevents environmental heat and lava damage to buildings placed by players in the Ashlands. Creature and player attacks use their own settings. Requires Enabled."); CE_StructuresDamage_PreventFireDamage = Cfg("19 - StructuresDamage", "19.08 - PreventFireDamage", defaultValue: true, "Prevents fire damage without an identified attacker to buildings placed by players. Other damage in the same hit remains active. Fire attacks from players or creatures use their own settings. Requires Enabled."); CE_StructuresDamage_PreventImpactDamage = Cfg("19 - StructuresDamage", "19.09 - PreventImpactDamage", defaultValue: true, "Prevents impacts from objects and mechanisms without an identified attacker, including vehicles, stalactites, turrets, catapults and drawbridges, from damaging buildings placed by players. Trees use PreventTreeDamage. Requires Enabled."); CE_StructuresDamage_PreventTreeDamage = Cfg("19 - StructuresDamage", "19.10 - PreventTreeDamage", defaultValue: true, "Prevents falling trees and rolling logs from damaging buildings placed by players. Requires Enabled."); } private void BindSeedPrivacy() { CE_SeedPrivacy_Enabled = Cfg("25 - SeedPrivacy", "25.01 - Enabled", defaultValue: false, "Enables the seed privacy controls below. These reduce exposure; clients still receive seed data required to generate the world."); CE_SeedPrivacy_AdminBypass = Cfg("25 - SeedPrivacy", "25.02 - AdminBypass", defaultValue: true, "Allows server administrators and the host to execute printseeds when its block is active. Independent of the general AdminBypass setting. Does not bypass PlayFab seed hiding."); CE_SeedPrivacy_BlockPrintSeeds = Cfg("25 - SeedPrivacy", "25.03 - BlockPrintSeeds", defaultValue: true, "Blocks execution of printseeds, which displays the world and loaded dungeon seeds. Administrators and the host can bypass this with AdminBypass. Requires Enabled."); CE_SeedPrivacy_HideSeedInPlayFab = Cfg("25 - SeedPrivacy", "25.04 - HideSeedInPlayFab", defaultValue: true, "Replaces the seed exposed in PlayFab/crossplay lobby metadata with Hidden. Applies when the lobby is created or refreshed; restart the server to apply immediately to an existing listing. Does not change world generation or connection data. Requires Enabled."); } private void BindDayCycle() { CE_DayCycle_Enabled = Cfg("24 - DayCycle", "24.01 - Enabled", defaultValue: false, "Enables custom day/night cycle duration. Changes apply immediately. Disabling restores the previous duration. Changing duration recalculates the displayed world day and time."); CE_DayCycle_DayRate = Cfg("24 - DayCycle", "24.02 - DayRate", 1f, "Day/night cycle speed relative to the original duration: 1 keeps it unchanged, 0.5 doubles its duration, 0.25 quadruples it. Preserves the day/night proportion. Requires Enabled.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f)); CE_DayCycle_Enabled.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { DayCycle.Refresh(); }; CE_DayCycle_DayRate.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { DayCycle.Refresh(); }; } private void BindPlayerTuning() { bool flag = MoveSetting<bool>("20 - PlayerBase", "20.01 - Enabled", fallback: false); float defaultValue = MoveSetting<float>("20 - PlayerBase", "20.02 - Health", 25f); float defaultValue2 = MoveSetting<float>("20 - PlayerBase", "20.03 - Stamina", 50f); float num = MoveSetting<float>("20 - PlayerBase", "20.04 - Eitr", 0f); float defaultValue3 = MoveSetting<float>("20 - PlayerBase", "20.05 - CarryWeight", 300f); float defaultValue4 = MoveSetting<float>("20 - PlayerBase", "20.06 - MegingjordBonus", 150f); CE_PlayerBase_Enabled = Cfg("20 - HealthAndWeight", "20.01 - Enabled", flag, "Enables base health, carry capacity and Megingjord settings. Food and other equipment bonuses remain additive. Disabling restores previous base values."); CE_PlayerBase_Health = Cfg("20 - HealthAndWeight", "20.02 - Health", defaultValue, "Base health before food bonuses.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100000f)); CE_PlayerBase_CarryWeight = Cfg("20 - HealthAndWeight", "20.03 - CarryWeight", defaultValue3, "Base carry capacity before status effects and the world's carry-weight modifier.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100000f)); CE_PlayerBase_MegingjordBonus = Cfg("20 - HealthAndWeight", "20.04 - MegingjordBonus", defaultValue4, "Carry capacity granted by Megingjord's equip effect. Other carry-weight effects remain unchanged.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100000f)); bool flag2 = MoveSetting<bool>("21 - Eitr", "21.01 - Enabled", fallback: false); float defaultValue5 = MoveSetting<float>("21 - Eitr", "21.02 - RegenPerSecond", 5f); float defaultValue6 = MoveSetting<float>("21 - Eitr", "21.03 - RegenDelaySeconds", 1f); CE_Eitr_Enabled = Cfg("21 - Eitr", "21.01 - Enabled", flag2 || (flag && num > 0f), "Enables base eitr and regeneration settings. Food and status-effect bonuses remain active. Disabling restores previous rates and removes this base eitr bonus."); CE_Eitr_Base = Cfg("21 - Eitr", "21.02 - Eitr", num, "Base eitr added to food bonuses.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100000f)); CE_Eitr_Regen = Cfg("21 - Eitr", "21.03 - RegenPerSecond", defaultValue5, "Base eitr regeneration per second before modifiers.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f)); CE_Eitr_RegenDelay = Cfg("21 - Eitr", "21.04 - RegenDelaySeconds", defaultValue6, "Delay before eitr regeneration starts.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f)); bool flag3 = MoveSetting<bool>("22 - Stamina", "22.01 - Enabled", fallback: false); float defaultValue7 = MoveSetting<float>("22 - Stamina", "22.09 - RegenPerSecond", 5f); float defaultValue8 = MoveSetting<float>("22 - Stamina", "22.10 - RegenDelaySeconds", 1f); string[] array = new string[7] { "22.02 - RunDrain", "22.03 - JumpCost", "22.04 - DodgeCost", "22.05 - SneakDrain", "22.06 - SwimMinSkillDrain", "22.07 - SwimMaxSkillDrain", "22.08 - EncumberedDrain" }; foreach (string key in array) { MoveSetting<float>("22 - Stamina", key, 0f); } CE_Stamina_Enabled = Cfg("22 - Stamina", "22.01 - Enabled", flag3 || flag, "Enables base stamina and regeneration settings. Food and status-effect bonuses remain active. Disabling restores previous base stamina and rates."); CE_Stamina_Base = Cfg("22 - Stamina", "22.02 - Stamina", defaultValue2, "Base stamina before food bonuses.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100000f)); CE_Stamina_Regen = Cfg("22 - Stamina", "22.03 - RegenPerSecond", defaultValue7, "Base stamina regeneration per second. Vanilla food, maximum-stamina and status-effect modifiers remain active.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f)); CE_Stamina_RegenDelay = Cfg("22 - Stamina", "22.04 - RegenDelaySeconds", defaultValue8, "Delay before stamina regeneration starts.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f)); CE_PlayerReach_Enabled = Cfg("23 - PlayerReach", "23.01 - Enabled", defaultValue: false, "Enables player placement and interaction distances. Station construction radii are separate. Disabling restores previous values."); CE_PlayerReach_BuildDistance = Cfg("23 - PlayerReach", "23.02 - BuildDistance", 5f, "Maximum placement distance in meters from the player. Does not expand crafting station coverage or bypass protected areas.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f)); CE_PlayerReach_InteractDistance = Cfg("23 - PlayerReach", "23.03 - InteractDistance", 5f, "Maximum interaction distance in meters. Containers remain open within at least this distance; access restrictions remain active.", synced: true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f)); ConfigEntry<bool>[] array2 = new ConfigEntry<bool>[4] { CE_PlayerBase_Enabled, CE_Eitr_Enabled, CE_Stamina_Enabled, CE_PlayerReach_Enabled }; foreach (ConfigEntry<bool> val in array2) { val.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { PlayerTuning.RefreshPlayers(); }; } ConfigEntry<float>[] array3 = new ConfigEntry<float>[11] { CE_PlayerBase_Health, CE_PlayerBase_CarryWeight, CE_PlayerBase_MegingjordBonus, CE_Eitr_Base, CE_Eitr_Regen, CE_Eitr_RegenDelay, CE_Stamina_Base, CE_Stamina_Regen, CE_Stamina_RegenDelay, CE_PlayerReach_BuildDistance, CE_PlayerReach_InteractDistance }; foreach (ConfigEntry<float> val2 in array3) { val2.SettingChanged += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, EventArgs _) => { PlayerTuning.RefreshPlayers(); }; } [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] T MoveSetting<T>([<26038308-0667-4d67-809e-006db3876118>Nullable(1)] string section, [<26038308-0667-4d67-809e-006db3876118>Nullable(1)] string text, T fallback) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown T value = ((BaseUnityPlugin)this).Config.Bind<T>(section, text, fallback, (ConfigDescription)null).Value; ((BaseUnityPlugin)this).Config.Remove(new ConfigDefinition(section, text)); return value; } } internal static bool IsLocalPlayerAdmin() { return ConfigSync != null && ConfigSync.IsAdmin; } internal static bool IsAdminBypassActive() { return CE_AdminBypass.Value && IsLocalPlayerAdmin(); } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Localizer.Load(); bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; try { SetupServerSync(); BindConfig(); } finally { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet; } ((BaseUnityPlugin)this).Config.Save(); SkillGain.Initialize(); FactionRemap.Initialize(); ForcePlayerPins.Initialize(); ProtectedZoneObjects.Initialize(); _harmony.PatchAll(); SetupConfigWatcher(); } private void OnDestroy() { DisposeConfigWatcher(); _harmony.UnpatchSelf(); PlayerTuning.RestoreAll(); DayCycle.Restore(); } private void SetupServerSync() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown ConfigSync = new ConfigSync(((BaseUnityPlugin)this).Info.Metadata.GUID) { DisplayName = ((BaseUnityPlugin)this).Info.Metadata.Name, CurrentVersion = ((BaseUnityPlugin)this).Info.Metadata.Version.ToString(), MinimumRequiredVersion = ((BaseUnityPlugin)this).Info.Metadata.Version.ToString(), ModRequired = true }; _serverConfigLocked = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - General", "LockConfiguration", true, new ConfigDescription("If true, the server locks synchronized configs.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false } })); ConfigSync.AddLockingConfigEntry<bool>(_serverConfigLocked); } private ConfigEntry<T> Cfg<[<26038308-0667-4d67-809e-006db3876118>Nullable(2)] T>(string section, string key, T defaultValue, string description, bool synced = true, [<26038308-0667-4d67-809e-006db3876118>Nullable(2)] AcceptableValueBase acceptableValues = null) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown if (ConfigSync == null) { throw new InvalidOperationException("ServerSync has not been initialized."); } string text = (synced ? " [Synced with Server]" : " [Not Synced with Server]"); ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, new ConfigDescription(description + text, acceptableValues, Array.Empty<object>())); ConfigSync.AddConfigEntry<T>(val).SynchronizedConfig = synced; return val; } private void SetupConfigWatcher() { try { DisposeConfigWatcher(); _configWatcher = new FileSystemWatcher(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath)) { IncludeSubdirectories = false, NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite), SynchronizingObject = ThreadingHelper.SynchronizingObject }; _configWatcher.Changed += OnConfigFileChanged; _configWatcher.Created += OnConfigFileChanged; _configWatcher.Renamed += OnConfigFileChanged; _configWatcher.Error += [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(0)] (object _, ErrorEventArgs args) => { Log.LogWarning((object)$"Configuration watcher failed: {args.GetException()}"); }; _watcherReady = true; _configWatcher.EnableRaisingEvents = true; } catch (Exception arg) { DisposeConfigWatcher(); Log.LogWarning((object)$"Automatic configuration reload is unavailable: {arg}"); } } private void DisposeConfigWatcher() { _watcherReady = false; _reloadScheduled = false; if (_configWatcher != null) { _configWatcher.EnableRaisingEvents = false; _configWatcher.Dispose(); _configWatcher = null; } } private void OnConfigFileChanged(object sender, FileSystemEventArgs args) { if (_watcherReady) { _lastConfigWrite = Stopwatch.GetTimestamp(); if (!_reloadScheduled) { _reloadScheduled = true; ((MonoBehaviour)this).StartCoroutine(ReloadConfigAfterQuietPeriod()); } } } private IEnumerator ReloadConfigAfterQuietPeriod() { try { for (int attempt = 1; attempt <= 3; attempt++) { if (!_watcherReady) { break; } while (_watcherReady && SecondsSinceLastWrite() < 0.75) { yield return null; } if (!_watcherReady || TryReloadConfig(attempt)) { break; } _lastConfigWrite = Stopwatch.GetTimestamp(); } } finally { _reloadScheduled = false; } } private bool TryReloadConfig(int attempt) { bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; try { ((BaseUnityPlugin)this).Config.Reload(); return true; } catch (IOException arg) { if (attempt >= 3) { Log.LogWarning((object)$"Configuration could not be read after {3} attempts: {arg}"); return true; } return false; } catch (Exception arg2) { Log.LogError((object)$"Configuration reload failed: {arg2}"); return true; } finally { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet; } } private double SecondsSinceLastWrite() { return (double)(Stopwatch.GetTimestamp() - _lastConfigWrite) / (double)Stopwatch.Frequency; } } internal static class FactionRemap { [HarmonyPatch(typeof(Character), "Awake")] private static class Patch_Character_Awake { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(Character __instance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (TweaksPlugin.CE_AllFaction_Enabled.Value && !((Object)(object)__instance == (Object)null)) { Apply(__instance, __instance.m_faction); } } } [HarmonyPatch(typeof(Character), "RPC_SetTamed")] private static class Patch_Character_RPC_SetTamed { [<6f684b40-7dd8-400b-a870-b737b348a108>NullableContext(1)] private static void Postfix(Character __instance) { //IL_002a: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (TweaksPlugin.CE_AllFaction_Enabled.Value && __instance.IsTamed() && TryGetPrefabFaction(__instance, out var faction) && __instance.m_faction == Resolve(faction)) { __instance.m_faction = faction; } } } [<26038308-0667-4d67-809e-006db3876118>Nullable(new byte[] { 1, 0, 1 })] private s