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 TrophyTweaks v1.0.1
TrophyTweaks.dll
Decompiled 13 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using ModHub; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TrophyTweaks")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("TrophyTweaks")] [assembly: AssemblyTitle("TrophyTweaks")] [assembly: AssemblyVersion("1.0.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TrophyTweaks { [HarmonyPatch] internal static class GenerateDropListPatch { private static FieldInfo _trophiesField; private static bool _trophiesSearched; private static MethodBase TargetMethod() { return AccessTools.Method(typeof(CharacterDrop), "GenerateDropList", (Type[])null, (Type[])null); } private static bool Prepare() { bool flag = TargetMethod() != null; if (!flag) { TrophyTweaksPlugin.LogError("CharacterDrop.GenerateDropList not found: trophy chances will not change on this game version."); } return flag; } private static void Prefix(CharacterDrop __instance, out List<KeyValuePair<Drop, float>> __state) { __state = null; try { TrophySettings active = TrophyTweaksPlugin.Active; if (active == null || !active.Enabled || (Object)(object)__instance == (Object)null || __instance.m_drops == null) { return; } Character component = ((Component)__instance).GetComponent<Character>(); int level = ((!((Object)(object)component != (Object)null)) ? 1 : Mathf.Max(1, component.GetLevel())); bool flag = (Object)(object)component != (Object)null && component.IsBoss(); foreach (Drop drop in __instance.m_drops) { if (drop == null || !TrophyCatalog.IsTrophy(drop.m_prefab)) { continue; } string name = ((Object)drop.m_prefab).name; float num = active.Compute(name, drop.m_chance, level, flag); if (active.FirstGuaranteed && (!flag || active.AffectBosses) && !LocalPlayerHasTrophy(name)) { num = 1f; } if (!(Mathf.Abs(num - drop.m_chance) < 1E-05f)) { if (__state == null) { __state = new List<KeyValuePair<Drop, float>>(); } __state.Add(new KeyValuePair<Drop, float>(drop, drop.m_chance)); drop.m_chance = num; } } } catch (Exception ex) { TrophyTweaksPlugin.LogError("Drop patch failed: " + ex); } } private static Exception Finalizer(Exception __exception, List<KeyValuePair<Drop, float>> __state) { if (__state != null) { foreach (KeyValuePair<Drop, float> item in __state) { item.Key.m_chance = item.Value; } } return __exception; } private static bool LocalPlayerHasTrophy(string trophy) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } if (!_trophiesSearched) { _trophiesSearched = true; _trophiesField = AccessTools.Field(typeof(Player), "m_trophies"); if (_trophiesField == null) { TrophyTweaksPlugin.LogWarning("Player.m_trophies not found: \"first trophy\" option is disabled."); } } if (_trophiesField == null) { return true; } return !(_trophiesField.GetValue(localPlayer) is ICollection<string> collection) || collection.Contains(trophy); } } internal static class Loc { private static int _lang; private static int _langFrame = -1; private static readonly Dictionary<string, string[]> Texts = new Dictionary<string, string[]> { { "tile", new string[3] { "Trophy", "Trophy", "Trophy" } }, { "tile_desc", new string[3] { "Trophy drop chance", "Шанс выпадения трофеев", "Шанс випадіння трофеїв" } }, { "title", new string[3] { "Trophies", "Трофеи", "Трофеї" } }, { "general", new string[3] { "General settings", "Общие настройки", "Загальні налаштування" } }, { "search", new string[3] { "Search...", "Поиск...", "Пошук..." } }, { "enabled", new string[3] { "Mod enabled", "Мод включён", "Мод увімкнено" } }, { "how", new string[3] { "How to change the chance", "Как менять шанс", "Як змінювати шанс" } }, { "mode_mult", new string[3] { "Multiply the vanilla chance", "Умножать ванильный шанс", "Множити ванільний шанс" } }, { "multiplier", new string[3] { "Multiplier", "Множитель", "Множник" } }, { "mode_fixed", new string[3] { "Same chance for all trophies", "Один шанс для всех трофеев", "Однаковий шанс для всіх трофеїв" } }, { "chance", new string[3] { "Chance", "Шанс", "Шанс" } }, { "hint_mult", new string[3] { "Each trophy drops with its vanilla chance × multiplier. ×1 = vanilla.", "Каждый трофей падает с ванильным шансом × множитель. ×1 = как в ванилле.", "Кожен трофей падає з ванільним шансом × множник. ×1 = як у ванілі." } }, { "hint_fixed", new string[3] { "Every trophy drops with this chance, whatever the vanilla one is.", "Каждый трофей падает с этим шансом, независимо от ванильного.", "Кожен трофей падає з цим шансом, незалежно від ванільного." } }, { "extra", new string[3] { "Extra", "Дополнительно", "Додатково" } }, { "star_bonus", new string[3] { "Bonus per star", "Бонус за звезду", "Бонус за зірку" } }, { "first", new string[3] { "First trophy of each kind: 100%", "Первый трофей каждого вида — 100%", "Перший трофей кожного виду — 100%" } }, { "bosses", new string[3] { "Also change boss trophies", "Менять шанс и у боссов", "Змінювати шанс і в босів" } }, { "hint_own", new string[3] { "To set a chance for one trophy, pick it in the list on the left.", "Свой шанс для отдельного трофея: выбери его в списке слева.", "Власний шанс для окремого трофея: вибери його у списку ліворуч." } }, { "hint_first", new string[3] { "\"First trophy\" works when you don't have that trophy yet and the mob's death is processed by your game (usually a mob you fight nearby).", "«Первый трофей» срабатывает, если у тебя ещё нет этого трофея и смерть моба обрабатывает твоя игра (обычно это моб, с которым ты дерёшься рядом).", "«Перший трофей» спрацьовує, якщо в тебе ще немає цього трофея і смерть моба обробляє твоя гра (зазвичай це моб, з яким ти б'єшся поруч)." } }, { "hint_pity", new string[3] { "The vanilla guarantee counter (patch 1.0.20) keeps working on top of these chances.", "Ванильный счётчик гарантии (патч 1.0.20) продолжает работать поверх этих шансов.", "Ванільний лічильник гарантії (патч 1.0.20) і далі працює поверх цих шансів." } }, { "dropped_by", new string[3] { "Dropped by", "Кто роняет", "Хто впускає" } }, { "vanilla_now", new string[3] { "vanilla {0}, now {1}", "ванилла {0}, сейчас {1}", "ваніла {0}, зараз {1}" } }, { "stars", new string[3] { "1 star: {0} 2 stars: {1}", "1 звезда: {0} 2 звезды: {1}", "1 зірка: {0} 2 зірки: {1}" } }, { "own_chance", new string[3] { "Own chance for this trophy", "Свой шанс для этого трофея", "Власний шанс для цього трофея" } }, { "boss_note", new string[3] { "This is a boss trophy. It changes only if \"Also change boss trophies\" is on in the general settings.", "Это трофей босса. Он меняется, только если в общих настройках включено «Менять шанс и у боссов».", "Це трофей боса. Він змінюється, лише якщо в загальних налаштуваннях увімкнено «Змінювати шанс і в босів»." } }, { "disabled_note", new string[3] { "The mod is off: vanilla chances are used.", "Мод выключен: действуют ванильные шансы.", "Мод вимкнено: діють ванільні шанси." } }, { "vanilla", new string[3] { "All vanilla", "Всё как в ванилле", "Усе як у ванілі" } }, { "cancel", new string[3] { "Cancel", "Отменить", "Скасувати" } }, { "apply", new string[3] { "Apply", "Применить", "Застосувати" } }, { "readonly", new string[3] { "Server settings: only the host or an admin can change them.", "Настройки сервера: менять их может только хост или админ.", "Налаштування сервера: змінювати їх може лише хост або адмін." } }, { "server_nomod", new string[3] { "The server has no TrophyTweaks: these settings work only for you.", "На сервере нет TrophyTweaks: эти настройки действуют только для тебя.", "На сервері немає TrophyTweaks: ці налаштування діють лише для тебе." } }, { "saved", new string[3] { "Saved", "Сохранено", "Збережено" } }, { "sent", new string[3] { "Sent to the server", "Отправлено на сервер", "Надіслано на сервер" } }, { "send_fail", new string[3] { "Couldn't reach the server", "Не удалось связаться с сервером", "Не вдалося зв'язатися із сервером" } }, { "unsaved", new string[3] { "There are unsaved changes", "Есть несохранённые изменения", "Є незбережені зміни" } }, { "close_hint", new string[3] { "{0} / Esc — close", "{0} / Esc — закрыть", "{0} / Esc — закрити" } }, { "empty", new string[3] { "Nothing found", "Ничего не найдено", "Нічого не знайдено" } }, { "g_all", new string[3] { "All", "Все", "Усі" } }, { "g_meadows", new string[3] { "Meadows", "Луга", "Луки" } }, { "g_blackforest", new string[3] { "Black Forest", "Чёрный лес", "Чорний ліс" } }, { "g_swamp", new string[3] { "Swamp", "Болото", "Болото" } }, { "g_mountains", new string[3] { "Mountains", "Горы", "Гори" } }, { "g_plains", new string[3] { "Plains", "Равнины", "Рівнини" } }, { "g_mistlands", new string[3] { "Mistlands", "Туманные земли", "Туманні землі" } }, { "g_ashlands", new string[3] { "Ashlands", "Пепельные земли", "Попелясті землі" } }, { "g_deepnorth", new string[3] { "Deep North", "Глубокий север", "Глибока північ" } }, { "g_ocean", new string[3] { "Ocean", "Океан", "Океан" } }, { "g_bosses", new string[3] { "Bosses", "Боссы", "Боси" } }, { "g_other", new string[3] { "Other", "Другое", "Інше" } } }; public static int Lang { get { if (_langFrame != Time.frameCount) { _langFrame = Time.frameCount; _lang = Detect(); } return _lang; } } private static int Detect() { try { string text = ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : null); if (text == "Russian") { return 1; } if (text == "Ukrainian") { return 2; } } catch { } return 0; } public static string T(string key) { if (!Texts.TryGetValue(key, out var value)) { return key; } int lang = Lang; return (lang < value.Length && !string.IsNullOrEmpty(value[lang])) ? value[lang] : value[0]; } public static string F(string key, params object[] args) { return string.Format(T(key), args); } public static string Game(string token) { if (string.IsNullOrEmpty(token)) { return token; } try { return (Localization.instance != null) ? Localization.instance.Localize(token) : token; } catch { return token; } } } internal static class Net { private const string RpcSync = "TrophyTweaks_Sync"; private const string RpcSet = "TrophyTweaks_Set"; public static TrophySettings ServerSettings; public static bool ServerSaysAdmin; public static bool IsServer => (Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer(); public static void Reset() { ServerSettings = null; ServerSaysAdmin = false; } public static void RegisterRpcs(ZNetPeer peer) { if (peer != null && peer.m_rpc != null) { peer.m_rpc.Register<ZPackage>("TrophyTweaks_Sync", (Action<ZRpc, ZPackage>)OnSync); peer.m_rpc.Register<ZPackage>("TrophyTweaks_Set", (Action<ZRpc, ZPackage>)OnSet); } } public static void SendTo(ZRpc rpc) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (rpc == null || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } try { ZPackage val = new ZPackage(); val.Write(1); TrophyTweaksPlugin.Local.Write(val); val.Write(HubNet.IsAdmin(HubNet.FindPeer(rpc))); rpc.Invoke("TrophyTweaks_Sync", new object[1] { val }); } catch (Exception ex) { TrophyTweaksPlugin.LogError("Sync send failed: " + ex.Message); } } public static void Broadcast() { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer != null && peer.m_rpc != null) { SendTo(peer.m_rpc); } } } public static bool SendToServer(TrophySettings s) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown ZRpc val = HubNet.ServerRpc(); if (val == null) { return false; } ZPackage val2 = new ZPackage(); val2.Write(1); s.Write(val2); val.Invoke("TrophyTweaks_Set", new object[1] { val2 }); return true; } private static void OnSync(ZRpc rpc, ZPackage pkg) { if ((Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer()) { return; } try { int num = pkg.ReadInt(); if (num != 1) { TrophyTweaksPlugin.LogError("Server uses another TrophyTweaks version (sync format " + num + "). Update the mod on both sides."); return; } ServerSettings = TrophySettings.Read(pkg); ServerSaysAdmin = pkg.ReadBool(); TrophyTweaksPlugin.Log("Got settings from the server" + (ServerSaysAdmin ? " (you are admin)" : "")); TrophyMenu.OnActiveSettingsChanged(); } catch (Exception ex) { TrophyTweaksPlugin.LogError("Sync receive failed: " + ex.Message); } } private static void OnSet(ZRpc rpc, ZPackage pkg) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } try { ZNetPeer val = HubNet.FindPeer(rpc); if (!HubNet.IsAdmin(val)) { TrophyTweaksPlugin.LogWarning("Rejected settings change from a non-admin player" + ((val != null) ? (" (" + val.m_playerName + ")") : "")); SendTo(rpc); return; } int num = pkg.ReadInt(); if (num == 1) { TrophySettings s = TrophySettings.Read(pkg); TrophyTweaksPlugin.SaveLocal(s); TrophyTweaksPlugin.Log("Settings changed by admin " + ((val != null) ? val.m_playerName : "?")); Broadcast(); TrophyMenu.OnActiveSettingsChanged(); } } catch (Exception ex) { TrophyTweaksPlugin.LogError("Settings change failed: " + ex.Message); } } } [HarmonyPatch] internal static class ZNetNewConnectionPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ZNet), "OnNewConnection", (Type[])null, (Type[])null); } private static bool Prepare() { return TargetMethod() != null; } private static void Postfix(object[] __args) { if (__args != null && __args.Length != 0) { object obj = __args[0]; Net.RegisterRpcs((ZNetPeer)((obj is ZNetPeer) ? obj : null)); } } } [HarmonyPatch] internal static class ZNetPeerInfoPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ZNet), "RPC_PeerInfo", (Type[])null, (Type[])null); } private static bool Prepare() { return TargetMethod() != null; } private static void Postfix(ZNet __instance, object[] __args) { if (!((Object)(object)__instance == (Object)null) && __instance.IsServer() && __args != null && __args.Length != 0) { object obj = __args[0]; Net.SendTo((ZRpc)((obj is ZRpc) ? obj : null)); } } } [HarmonyPatch(typeof(ZNet), "Awake")] internal static class ZNetAwakePatch { private static void Postfix() { Net.Reset(); } } public enum TrophyGroup { All, Meadows, BlackForest, Swamp, Mountains, Plains, Mistlands, Ashlands, DeepNorth, Ocean, Bosses, Other } internal sealed class TrophySource { public string CreaturePrefab; public string CreatureName; public float BaseChance; public bool Boss; } internal sealed class TrophyEntry { public string Prefab; public string Name; public Sprite Icon; public TrophyGroup Group; public bool Boss; public readonly List<TrophySource> Sources = new List<TrophySource>(); public float MaxBase { get { float num = 0f; foreach (TrophySource source in Sources) { num = Mathf.Max(num, source.BaseChance); } return num; } } } internal static class TrophyCatalog { private static readonly Dictionary<string, bool> TrophyCache = new Dictionary<string, bool>(StringComparer.Ordinal); private static readonly Dictionary<string, TrophyGroup> KnownGroups = new Dictionary<string, TrophyGroup>(StringComparer.Ordinal) { { "TrophySkeleton", TrophyGroup.BlackForest }, { "TrophySkeletonPoison", TrophyGroup.BlackForest }, { "TrophyGhost", TrophyGroup.BlackForest }, { "TrophyFrostTroll", TrophyGroup.BlackForest }, { "TrophyBjorn", TrophyGroup.BlackForest }, { "TrophyDraugrElite", TrophyGroup.Swamp }, { "TrophyWraith", TrophyGroup.Swamp }, { "TrophyAbomination", TrophyGroup.Swamp }, { "TrophyLeech", TrophyGroup.Swamp }, { "TrophyCultist", TrophyGroup.Mountains }, { "TrophySGolem", TrophyGroup.Mountains }, { "TrophyUlv", TrophyGroup.Mountains }, { "TrophyBjornUndead", TrophyGroup.Plains }, { "TrophyDvergr", TrophyGroup.Mistlands }, { "TrophyFallenValkyrie", TrophyGroup.Ashlands }, { "TrophySerpent", TrophyGroup.Ocean } }; private static readonly KeyValuePair<int, TrophyGroup>[] BiomeOrder = new KeyValuePair<int, TrophyGroup>[9] { new KeyValuePair<int, TrophyGroup>(1, TrophyGroup.Meadows), new KeyValuePair<int, TrophyGroup>(8, TrophyGroup.BlackForest), new KeyValuePair<int, TrophyGroup>(2, TrophyGroup.Swamp), new KeyValuePair<int, TrophyGroup>(4, TrophyGroup.Mountains), new KeyValuePair<int, TrophyGroup>(16, TrophyGroup.Plains), new KeyValuePair<int, TrophyGroup>(512, TrophyGroup.Mistlands), new KeyValuePair<int, TrophyGroup>(32, TrophyGroup.Ashlands), new KeyValuePair<int, TrophyGroup>(64, TrophyGroup.DeepNorth), new KeyValuePair<int, TrophyGroup>(256, TrophyGroup.Ocean) }; public static bool IsTrophy(GameObject prefab) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 if ((Object)(object)prefab == (Object)null) { return false; } string name = ((Object)prefab).name; if (TrophyCache.TryGetValue(name, out var value)) { return value; } value = false; ItemDrop component = prefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null && component.m_itemData != null && component.m_itemData.m_shared != null) { value = (int)component.m_itemData.m_shared.m_itemType == 13; } TrophyCache[name] = value; return value; } public static string GroupKey(TrophyGroup g) { return g switch { TrophyGroup.All => "g_all", TrophyGroup.Meadows => "g_meadows", TrophyGroup.BlackForest => "g_blackforest", TrophyGroup.Swamp => "g_swamp", TrophyGroup.Mountains => "g_mountains", TrophyGroup.Plains => "g_plains", TrophyGroup.Mistlands => "g_mistlands", TrophyGroup.Ashlands => "g_ashlands", TrophyGroup.DeepNorth => "g_deepnorth", TrophyGroup.Ocean => "g_ocean", TrophyGroup.Bosses => "g_bosses", _ => "g_other", }; } public static List<TrophyEntry> Build() { List<TrophyEntry> list = new List<TrophyEntry>(); ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || instance.m_prefabs == null) { return list; } Dictionary<string, int> biomes = SpawnBiomes(instance); Dictionary<string, TrophyEntry> dictionary = new Dictionary<string, TrophyEntry>(StringComparer.Ordinal); foreach (GameObject prefab in instance.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } CharacterDrop component = prefab.GetComponent<CharacterDrop>(); if ((Object)(object)component == (Object)null || component.m_drops == null) { continue; } Character component2 = prefab.GetComponent<Character>(); string creatureName = (((Object)(object)component2 != (Object)null) ? Loc.Game(component2.m_name) : ((Object)prefab).name); bool flag = (Object)(object)component2 != (Object)null && component2.IsBoss(); foreach (Drop drop in component.m_drops) { if (drop == null || !IsTrophy(drop.m_prefab)) { continue; } if (!dictionary.TryGetValue(((Object)drop.m_prefab).name, out var value)) { value = new TrophyEntry { Prefab = ((Object)drop.m_prefab).name }; ItemDrop component3 = drop.m_prefab.GetComponent<ItemDrop>(); value.Name = Loc.Game(component3.m_itemData.m_shared.m_name); try { value.Icon = component3.m_itemData.GetIcon(); } catch { value.Icon = null; } dictionary[value.Prefab] = value; list.Add(value); } value.Boss |= flag; value.Sources.Add(new TrophySource { CreaturePrefab = ((Object)prefab).name, CreatureName = creatureName, BaseChance = drop.m_chance, Boss = flag }); } } foreach (TrophyEntry item in list) { item.Group = PickGroup(item, biomes); } list.Sort(delegate(TrophyEntry a, TrophyEntry b) { int num = a.Group.CompareTo(b.Group); return (num != 0) ? num : string.Compare(a.Name, b.Name, StringComparison.CurrentCultureIgnoreCase); }); return list; } private static TrophyGroup PickGroup(TrophyEntry e, Dictionary<string, int> biomes) { if (e.Boss) { return TrophyGroup.Bosses; } if (KnownGroups.TryGetValue(e.Prefab, out var value)) { return value; } int num = 0; foreach (TrophySource source in e.Sources) { if (biomes.TryGetValue(source.CreaturePrefab, out var value2)) { num |= value2; } } KeyValuePair<int, TrophyGroup>[] biomeOrder = BiomeOrder; for (int i = 0; i < biomeOrder.Length; i++) { KeyValuePair<int, TrophyGroup> keyValuePair = biomeOrder[i]; if ((num & keyValuePair.Key) != 0) { return keyValuePair.Value; } } return TrophyGroup.Other; } private static Dictionary<string, int> SpawnBiomes(ZNetScene scene) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected I4, but got Unknown Dictionary<string, int> dictionary = new Dictionary<string, int>(StringComparer.Ordinal); try { GameObject prefab = scene.GetPrefab("_ZoneCtrl"); SpawnSystem val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<SpawnSystem>() : null); if ((Object)(object)val == (Object)null || val.m_spawnLists == null) { return dictionary; } foreach (SpawnSystemList spawnList in val.m_spawnLists) { if ((Object)(object)spawnList == (Object)null || spawnList.m_spawners == null) { continue; } foreach (SpawnData spawner in spawnList.m_spawners) { if (spawner != null && !((Object)(object)spawner.m_prefab == (Object)null)) { dictionary.TryGetValue(((Object)spawner.m_prefab).name, out var value); dictionary[((Object)spawner.m_prefab).name] = value | spawner.m_biome; } } } } catch (Exception ex) { TrophyTweaksPlugin.LogWarning("Spawn lists not readable, biome tabs may be incomplete: " + ex.Message); } return dictionary; } } internal static class TrophyMenu { private const string InputOwner = "trophytweaks"; private const float LeftW = 360f; private const float RowH = 46f; private const float RowGap = 4f; private static TrophySettings _base; private static TrophySettings _draft; private static List<TrophyEntry> _catalog = new List<TrophyEntry>(); private static TrophyGroup _tab = TrophyGroup.All; private static string _search = ""; private static string _selected; private static Vector2 _listScroll; private static Vector2 _rightScroll; private static float _rightContentH = 400f; private static string _status; private static float _statusUntil; private static bool _stylesReady; private static GUIStyle _goldLabel; private static GUIStyle _goldCenter; private static GUIStyle _textCenter; private static GUIStyle _tabText; private static GUIStyle _tabTextOn; private static GUIStyle _rowName; private static GUIStyle _rowValue; private static GUIStyle _rowValueGold; private static GUIStyle _hint; private static GUIStyle _warn; private static GUIStyle _bigHeader; private static GUIStyle _valueBox; private static GUIStyle _valueBoxOff; private static readonly CultureInfo Inv = CultureInfo.InvariantCulture; private static Texture2D _px; public static bool IsOpen { get; private set; } public static void Open() { if (ModHubAPI.CanOpenMenu()) { try { _catalog = TrophyCatalog.Build(); } catch (Exception ex) { TrophyTweaksPlugin.LogError("Trophy list build failed: " + ex); _catalog = new List<TrophyEntry>(); } _base = TrophyTweaksPlugin.Active.Clone(); _draft = _base.Clone(); _status = null; if (_selected != null && Find(_selected) == null) { _selected = null; } IsOpen = true; ModHubAPI.SetInputBlock("trophytweaks", true); } } public static void Close() { if (IsOpen) { IsOpen = false; ModHubAPI.SetInputBlock("trophytweaks", false); } } public static void OnActiveSettingsChanged() { if (IsOpen && _draft != null) { bool flag = !_draft.SameAs(_base); _base = TrophyTweaksPlugin.Active.Clone(); if (!flag) { _draft = _base.Clone(); } } } public static void Draw() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen || _draft == null) { return; } Vector2 screen = HubUI.BeginScaled(); try { EnsureStyles(); DrawWindow(screen); } catch (Exception ex) { TrophyTweaksPlugin.LogError("Menu draw failed: " + ex); Close(); } finally { HubUI.EndScaled(); GUI.enabled = true; } } private static void EnsureStyles() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Expected O, but got Unknown if (!_stylesReady) { _stylesReady = true; _goldLabel = new GUIStyle(HubUI.LabelStyle); _goldLabel.normal.textColor = HubUI.GoldBright; _goldCenter = new GUIStyle(HubUI.LabelCenterStyle); _goldCenter.normal.textColor = HubUI.GoldBright; _goldCenter.fontStyle = (FontStyle)1; _goldCenter.fontSize = 16; _textCenter = new GUIStyle(HubUI.LabelCenterStyle); _textCenter.normal.textColor = HubUI.Text; _textCenter.fontSize = 16; _tabText = new GUIStyle(HubUI.LabelCenterStyle); _tabText.fontSize = 13; _tabText.clipping = (TextClipping)1; _tabText.wordWrap = false; _tabText.normal.textColor = HubUI.Text; _tabTextOn = new GUIStyle(_tabText); _tabTextOn.normal.textColor = HubUI.GoldBright; _tabTextOn.fontStyle = (FontStyle)1; _rowName = HubUI.NoWrap(new GUIStyle(HubUI.LabelStyle)); _rowName.clipping = (TextClipping)1; _rowValue = new GUIStyle(HubUI.LabelDimStyle); _rowValue.alignment = (TextAnchor)5; _rowValue.wordWrap = false; _rowValueGold = new GUIStyle(_rowValue); _rowValueGold.normal.textColor = HubUI.GoldBright; _rowValueGold.fontStyle = (FontStyle)1; _hint = new GUIStyle(HubUI.LabelDimStyle); _hint.wordWrap = true; _hint.alignment = (TextAnchor)0; _warn = new GUIStyle(_hint); _warn.normal.textColor = HubUI.Danger; _valueBox = new GUIStyle(HubUI.LabelCenterStyle); _valueBox.fontSize = 17; _valueBox.fontStyle = (FontStyle)1; _valueBox.wordWrap = false; _valueBox.normal.textColor = HubUI.GoldBright; _valueBoxOff = new GUIStyle(_valueBox); _valueBoxOff.normal.textColor = HubUI.TextDim; _bigHeader = new GUIStyle(HubUI.HeaderStyle); _bigHeader.fontSize = 24; _bigHeader.alignment = (TextAnchor)3; } } private static void DrawWindow(Vector2 screen) { //IL_0006: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min(1100f, screen.x - 40f); float num2 = Mathf.Min(760f, screen.y - 40f); Rect val = HubUI.Centered(screen, num, num2); HubUI.Window(val, Loc.T("title"), false); if (HubUI.CloseButton(val)) { Close(); return; } if (HubUI.Button(new Rect(((Rect)(ref val)).x + 22f, ((Rect)(ref val)).y + 22f, 30f, 30f), "<")) { Close(); ModHubAPI.OpenHub(); return; } bool canEdit = TrophyTweaksPlugin.CanEdit; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x + 36f, ((Rect)(ref val)).y + 86f, ((Rect)(ref val)).width - 72f, ((Rect)(ref val)).height - 86f - 100f); Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, 360f, ((Rect)(ref val2)).height); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref r)).xMax + 22f, ((Rect)(ref val2)).y, ((Rect)(ref val2)).xMax - ((Rect)(ref r)).xMax - 22f, ((Rect)(ref val2)).height); DrawLeft(r); GUI.Box(val3, GUIContent.none, HubUI.InnerFrameStyle); Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref val3)).x + 18f, ((Rect)(ref val3)).y + 14f, ((Rect)(ref val3)).width - 36f, ((Rect)(ref val3)).height - 28f); DrawRight(r2, canEdit); DrawBottom(val, canEdit); } private static void DrawLeft(Rect r) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; float y = ((Rect)(ref r)).y; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, 40f); bool flag = _selected == null; bool flag2 = ((Rect)(ref val)).Contains(current.mousePosition); HubUI.Slot(val, flag2, flag); GUI.Label(val, Loc.T("general"), (flag || flag2) ? _goldCenter : _textCenter); if (GUI.Button(val, GUIContent.none, GUIStyle.none)) { _selected = null; } y += 48f; List<KeyValuePair<TrophyGroup, int>> list = Tabs(); if (!HasTab(list, _tab)) { _tab = TrophyGroup.All; } float num = (((Rect)(ref r)).width - 8f) * 0.5f; Rect val2 = default(Rect); for (int i = 0; i < list.Count; i++) { ((Rect)(ref val2))..ctor(((Rect)(ref r)).x + (float)(i % 2) * (num + 8f), y + (float)(i / 2) * 36f, num, 30f); bool flag3 = list[i].Key == _tab; bool flag4 = ((Rect)(ref val2)).Contains(current.mousePosition); HubUI.Slot(val2, flag4, flag3); GUI.Label(new Rect(((Rect)(ref val2)).x + 4f, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width - 8f, ((Rect)(ref val2)).height), Loc.T(TrophyCatalog.GroupKey(list[i].Key)) + " (" + list[i].Value + ")", (flag3 || flag4) ? _tabTextOn : _tabText); if (GUI.Button(val2, GUIContent.none, GUIStyle.none)) { _tab = list[i].Key; _listScroll = Vector2.zero; } } y += (float)((list.Count + 1) / 2) * 36f + 4f; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, 32f); string text = _search ?? ""; _search = HubUI.TextField(val3, text) ?? ""; if (_search != text) { _listScroll = Vector2.zero; } if (_search.Length == 0) { GUI.Label(new Rect(((Rect)(ref val3)).x + 10f, ((Rect)(ref val3)).y, ((Rect)(ref val3)).width - 20f, ((Rect)(ref val3)).height), Loc.T("search"), HubUI.LabelDimStyle); } y += 40f; Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, ((Rect)(ref r)).yMax - y); List<TrophyEntry> list2 = Filtered(); if (list2.Count == 0) { GUI.Label(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y + 10f, ((Rect)(ref val4)).width, 30f), Loc.T("empty"), HubUI.LabelCenterStyle); return; } float num2 = (float)list2.Count * 50f; bool flag5 = num2 > ((Rect)(ref val4)).height; Rect val5 = default(Rect); ((Rect)(ref val5))..ctor(0f, 0f, ((Rect)(ref val4)).width - (flag5 ? 10f : 0f), num2); _listScroll = GUI.BeginScrollView(val4, _listScroll, val5, false, false, GUIStyle.none, GUIStyle.none); Vector2 mousePosition = Event.current.mousePosition; Rect val6 = default(Rect); for (int j = 0; j < list2.Count; j++) { ((Rect)(ref val6))..ctor(0f, (float)j * 50f, ((Rect)(ref val5)).width, 46f); if (!(((Rect)(ref val6)).yMax < _listScroll.y - 2f) && !(((Rect)(ref val6)).y > _listScroll.y + ((Rect)(ref val4)).height + 2f)) { TrophyEntry trophyEntry = list2[j]; bool flag6 = _selected == trophyEntry.Prefab; bool flag7 = ((Rect)(ref val6)).Contains(mousePosition); HubUI.Slot(val6, flag7, flag6); if ((Object)(object)trophyEntry.Icon != (Object)null) { HubUI.DrawSprite(new Rect(((Rect)(ref val6)).x + 6f, ((Rect)(ref val6)).y + 5f, 36f, 36f), trophyEntry.Icon); } GUI.Label(new Rect(((Rect)(ref val6)).x + 50f, ((Rect)(ref val6)).y, ((Rect)(ref val6)).width - 50f - 92f, ((Rect)(ref val6)).height), trophyEntry.Name, (flag6 || flag7) ? _goldLabel : _rowName); bool flag8 = _draft.Overrides.ContainsKey(trophyEntry.Prefab); GUI.Label(new Rect(((Rect)(ref val6)).xMax - 96f, ((Rect)(ref val6)).y, 88f, ((Rect)(ref val6)).height), ChanceText(trophyEntry, _draft, 1), flag8 ? _rowValueGold : _rowValue); if (GUI.Button(val6, GUIContent.none, GUIStyle.none)) { _selected = trophyEntry.Prefab; } } } GUI.EndScrollView(); ScrollBar(val4, _listScroll.y, num2); } private static void DrawRight(Rect r, bool canEdit) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) bool flag = _rightContentH > ((Rect)(ref r)).height; Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, ((Rect)(ref r)).width - (flag ? 12f : 0f), Mathf.Max(_rightContentH, ((Rect)(ref r)).height)); _rightScroll = GUI.BeginScrollView(r, _rightScroll, val, false, false, GUIStyle.none, GUIStyle.none); float y = 0f; float width = ((Rect)(ref val)).width; if (!canEdit) { y = Hint(Loc.T("readonly"), 0f, y, width, _warn) + 8f; } else if (TrophyTweaksPlugin.ServerWithoutMod) { y = Hint(Loc.T("server_nomod"), 0f, y, width, _warn) + 8f; } GUI.enabled = canEdit; TrophyEntry trophyEntry = ((_selected != null) ? Find(_selected) : null); if (trophyEntry == null) { _selected = null; y = DrawGeneral(width, y, canEdit); } else { y = DrawTrophy(trophyEntry, width, y, canEdit); } GUI.enabled = true; GUI.EndScrollView(); _rightContentH = y + 10f; ScrollBar(r, _rightScroll.y, _rightContentH); } private static float DrawGeneral(float w, float y, bool canEdit) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) HubUI.Header(new Rect(0f, y, w, 30f), Loc.T("general")); y += 38f; _draft.Enabled = HubUI.Toggle(new Rect(0f, y, w, 30f), _draft.Enabled, Loc.T("enabled")); y += 38f; if (!_draft.Enabled) { y = Hint(Loc.T("disabled_note"), 0f, y, w, _hint) + 6f; } Divider(w, ref y); HubUI.Header(new Rect(0f, y, w, 30f), Loc.T("how")); y += 36f; float num = (w - 10f) * 0.5f; if (Segment(new Rect(0f, y, num, 38f), Loc.T("mode_mult"), _draft.Mode == ChanceMode.Multiply)) { _draft.Mode = ChanceMode.Multiply; } if (Segment(new Rect(num + 10f, y, num, 38f), Loc.T("mode_fixed"), _draft.Mode == ChanceMode.Fixed)) { _draft.Mode = ChanceMode.Fixed; } y += 50f; if (_draft.Mode == ChanceMode.Multiply) { _draft.Multiplier = SliderRow(new Rect(0f, y, w, 34f), Loc.T("multiplier"), _draft.Multiplier, 0f, 10f, 0.5f, 0.1f, (float v) => "×" + v.ToString("0.0", Inv), 230f); y += 42f; y = Hint(Loc.T("hint_mult"), 0f, y, w, _hint) + 6f; } else { _draft.FixedChance = SliderRow(new Rect(0f, y, w, 34f), Loc.T("chance"), _draft.FixedChance, 0f, 100f, 1f, 0.5f, (float v) => Pct(v), 230f); y += 42f; y = Hint(Loc.T("hint_fixed"), 0f, y, w, _hint) + 6f; } Divider(w, ref y); HubUI.Header(new Rect(0f, y, w, 30f), Loc.T("extra")); y += 36f; _draft.StarBonus = SliderRow(new Rect(0f, y, w, 34f), Loc.T("star_bonus"), _draft.StarBonus, 0f, 100f, 5f, 1f, (float v) => "+" + v.ToString("0", Inv) + "%", 230f); y += 44f; _draft.FirstGuaranteed = HubUI.Toggle(new Rect(0f, y, w, 30f), _draft.FirstGuaranteed, Loc.T("first")); y += 36f; _draft.AffectBosses = HubUI.Toggle(new Rect(0f, y, w, 30f), _draft.AffectBosses, Loc.T("bosses")); y += 42f; GUI.enabled = true; y = Hint(Loc.T("hint_own"), 0f, y, w, _hint) + 4f; y = Hint(Loc.T("hint_first"), 0f, y, w, _hint) + 4f; y = Hint(Loc.T("hint_pity"), 0f, y, w, _hint); return y; } private static float DrawTrophy(TrophyEntry e, float w, float y, bool canEdit) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, y, 64f, 64f); HubUI.Slot(val, false, true); if ((Object)(object)e.Icon != (Object)null) { HubUI.DrawSprite(new Rect(((Rect)(ref val)).x + 6f, ((Rect)(ref val)).y + 6f, 52f, 52f), e.Icon); } GUI.Label(new Rect(78f, y + 2f, w - 78f, 34f), e.Name, _bigHeader); GUI.Label(new Rect(78f, y + 36f, w - 78f, 24f), e.Prefab + " · " + Loc.T(TrophyCatalog.GroupKey(e.Group)), HubUI.LabelDimStyle); y += 76f; Divider(w, ref y); HubUI.Header(new Rect(0f, y, w, 30f), Loc.T("dropped_by")); y += 34f; foreach (TrophySource source in e.Sources) { float num = _draft.Compute(e.Prefab, source.BaseChance, 1, source.Boss); GUI.Label(new Rect(0f, y, w * 0.45f, 26f), source.CreatureName, HubUI.LabelStyle); GUI.Label(new Rect(w * 0.45f, y, w * 0.55f, 26f), Loc.F("vanilla_now", Pct(source.BaseChance * 100f), Pct(num * 100f)), (Mathf.Abs(num - source.BaseChance) > 0.0001f) ? _rowValueGold : _rowValue); y += 28f; } if (_draft.StarBonus > 0f && _draft.Enabled && (!e.Boss || _draft.AffectBosses)) { float maxBase = e.MaxBase; string text = Pct(_draft.Compute(e.Prefab, maxBase, 2, e.Boss) * 100f); string text2 = Pct(_draft.Compute(e.Prefab, maxBase, 3, e.Boss) * 100f); GUI.Label(new Rect(0f, y, w, 24f), Loc.F("stars", text, text2), HubUI.LabelDimStyle); y += 28f; } y += 4f; Divider(w, ref y); float value; bool flag = _draft.Overrides.TryGetValue(e.Prefab, out value); bool flag2 = HubUI.Toggle(new Rect(0f, y, w, 30f), flag, Loc.T("own_chance")); if (flag2 && !flag) { value = Snap(_draft.Compute(e.Prefab, e.MaxBase, 1, boss: false, ignoreOverride: true) * 100f, 0.5f); _draft.Overrides[e.Prefab] = value; flag = true; } else if (!flag2 && flag) { _draft.Overrides.Remove(e.Prefab); flag = false; } y += 38f; GUI.enabled = canEdit && flag; float value2 = (flag ? value : (_draft.Compute(e.Prefab, e.MaxBase, 1, e.Boss, ignoreOverride: true) * 100f)); float value3 = SliderRow(new Rect(0f, y, w, 34f), Loc.T("chance"), value2, 0f, 100f, 1f, 0.5f, (float v) => Pct(v), 230f); if (flag) { _draft.Overrides[e.Prefab] = value3; } y += 46f; GUI.enabled = true; if (e.Boss && !_draft.AffectBosses) { y = Hint(Loc.T("boss_note"), 0f, y, w, _warn) + 4f; } if (!_draft.Enabled) { y = Hint(Loc.T("disabled_note"), 0f, y, w, _hint) + 4f; } GUI.enabled = canEdit; return y; } private static void DrawBottom(Rect win, bool canEdit) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) bool flag = !_draft.SameAs(_base); float num = 722f; float num2 = ((Rect)(ref win)).center.x - num * 0.5f; float num3 = ((Rect)(ref win)).yMax - 92f; GUI.enabled = canEdit; if (HubUI.Button(new Rect(num2, num3, 230f, 42f), Loc.T("vanilla"))) { _draft = TrophySettings.Vanilla(); } GUI.enabled = canEdit && flag; if (HubUI.Button(new Rect(num2 + 230f + 16f, num3, 230f, 42f), Loc.T("cancel"))) { _draft = _base.Clone(); } if (HubUI.Button(new Rect(num2 + 492f, num3, 230f, 42f), Loc.T("apply"))) { Apply(); } GUI.enabled = true; GUIStyle val = HubUI.LabelCenterStyle; string text; if (_status == null || !(Time.unscaledTime < _statusUntil)) { text = ((!(flag && canEdit)) ? Loc.F("close_hint", ModHubAPI.HubKey) : Loc.T("unsaved")); } else { text = _status; val = _goldCenter; } GUI.Label(new Rect(((Rect)(ref win)).x + 24f, ((Rect)(ref win)).yMax - 44f, ((Rect)(ref win)).width - 48f, 22f), text, val); } private static void Apply() { TrophySettings trophySettings = _draft.Clone(); if (Net.IsServer) { TrophyTweaksPlugin.SaveLocal(trophySettings); Net.Broadcast(); SetStatus(Loc.T("saved")); } else if (Net.ServerSettings != null) { SetStatus(Net.SendToServer(trophySettings) ? Loc.T("sent") : Loc.T("send_fail")); } else { TrophyTweaksPlugin.SaveLocal(trophySettings); SetStatus(Loc.T("saved")); } _base = trophySettings.Clone(); } private static void SetStatus(string text) { _status = text; _statusUntil = Time.unscaledTime + 3f; } private static float Hint(string text, float x, float y, float w, GUIStyle style) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) float num = style.CalcHeight(new GUIContent(text), w); GUI.Label(new Rect(x, y, w, num), text, style); return y + num; } private static void Divider(float w, ref float y) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003a: Unknown result type (might be due to invalid IL or missing references) y += 8f; Color goldDim = HubUI.GoldDim; Fill(new Rect(0f, y, w, 1f), new Color(goldDim.r, goldDim.g, goldDim.b, 0.7f)); y += 14f; } private static void Fill(Rect r, Color c) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_px == (Object)null) { _px = new Texture2D(1, 1, (TextureFormat)4, false); _px.SetPixel(0, 0, Color.white); _px.Apply(); ((Object)_px).hideFlags = (HideFlags)61; } Color color = GUI.color; GUI.color = new Color(c.r, c.g, c.b, c.a * color.a); GUI.DrawTexture(r, (Texture)(object)_px); GUI.color = color; } private static void ScrollBar(Rect area, float scroll, float contentH) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if (!(contentH <= ((Rect)(ref area)).height)) { float num = Mathf.Max(30f, ((Rect)(ref area)).height * ((Rect)(ref area)).height / contentH); float num2 = Mathf.Clamp01(scroll / (contentH - ((Rect)(ref area)).height)); Fill(new Rect(((Rect)(ref area)).xMax - 3f, ((Rect)(ref area)).y, 3f, ((Rect)(ref area)).height), new Color(0f, 0f, 0f, 0.35f)); Color gold = HubUI.Gold; Fill(new Rect(((Rect)(ref area)).xMax - 3f, ((Rect)(ref area)).y + num2 * (((Rect)(ref area)).height - num), 3f, num), new Color(gold.r, gold.g, gold.b, 0.8f)); } } private static bool Segment(Rect r, string text, bool active) { //IL_000f: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) bool flag = GUI.enabled && ((Rect)(ref r)).Contains(Event.current.mousePosition); HubUI.Slot(r, flag, active); GUI.Label(r, text, active ? _goldCenter : (flag ? _tabTextOn : _textCenter)); return GUI.Button(r, GUIContent.none, GUIStyle.none) && !active; } private static float SliderRow(Rect r, string label, float value, float min, float max, float buttonStep, float snap, Func<float, string> format, float labelW) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01bb: 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) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) float num = (GUI.enabled ? 1f : 0.45f); GUI.Label(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, labelW, ((Rect)(ref r)).height), label, HubUI.LabelStyle); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x + labelW, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 30f) * 0.5f, 30f, 30f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref r)).xMax - 92f, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 32f) * 0.5f, 92f, 32f); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref val2)).x - 12f - 30f, ((Rect)(ref val)).y, 30f, 30f); if (HubUI.Button(val, "-")) { value -= buttonStep; } if (HubUI.Button(val3, "+")) { value += buttonStep; } Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref val)).xMax + 16f, ((Rect)(ref r)).y + ((Rect)(ref r)).height * 0.5f - 3f, ((Rect)(ref val3)).x - 16f - (((Rect)(ref val)).xMax + 16f), 6f); float num2 = Mathf.InverseLerp(min, max, value); Color gold = HubUI.Gold; Fill(r2, new Color(0f, 0f, 0f, 0.6f * num)); Fill(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).y, ((Rect)(ref r2)).width * num2, ((Rect)(ref r2)).height), new Color(gold.r, gold.g, gold.b, num)); Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(((Rect)(ref r2)).x, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 18f) * 0.5f, ((Rect)(ref r2)).width, 18f); value = GUI.HorizontalSlider(val4, value, min, max, GUIStyle.none, HubUI.ThumbStyle); value = Mathf.Clamp(Snap(value, snap), min, max); HubUI.Slot(val2, false, GUI.enabled); GUI.Label(val2, format(value), GUI.enabled ? _valueBox : _valueBoxOff); return value; } private static float Snap(float v, float step) { return Mathf.Round(v / step) * step; } private static string Pct(float percent) { return percent.ToString((percent < 10f) ? "0.#" : "0", Inv) + "%"; } private static string ChanceText(TrophyEntry e, TrophySettings s, int level) { float num = 1f; float num2 = 0f; foreach (TrophySource source in e.Sources) { float num3 = s.Compute(e.Prefab, source.BaseChance, level, source.Boss); num = Mathf.Min(num, num3); num2 = Mathf.Max(num2, num3); } if (e.Sources.Count == 0) { return "-"; } return (Mathf.Abs(num2 - num) < 0.0001f) ? Pct(num2 * 100f) : (Pct(num * 100f) + "–" + Pct(num2 * 100f)); } private static TrophyEntry Find(string prefab) { foreach (TrophyEntry item in _catalog) { if (item.Prefab == prefab) { return item; } } return null; } private static bool Matches(TrophyEntry e) { if (string.IsNullOrEmpty(_search)) { return true; } string text = _search.Trim(); if (text.Length == 0) { return true; } if (e.Name != null && e.Name.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0) { return true; } if (e.Prefab.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } foreach (TrophySource source in e.Sources) { if (source.CreatureName != null && source.CreatureName.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0) { return true; } } return false; } private static List<TrophyEntry> Filtered() { List<TrophyEntry> list = new List<TrophyEntry>(); foreach (TrophyEntry item in _catalog) { if ((_tab == TrophyGroup.All || item.Group == _tab) && Matches(item)) { list.Add(item); } } return list; } private static List<KeyValuePair<TrophyGroup, int>> Tabs() { int[] array = new int[Enum.GetValues(typeof(TrophyGroup)).Length]; foreach (TrophyEntry item in _catalog) { if (Matches(item)) { array[(int)item.Group]++; array[0]++; } } List<KeyValuePair<TrophyGroup, int>> list = new List<KeyValuePair<TrophyGroup, int>>(); for (int i = 0; i < array.Length; i++) { TrophyGroup trophyGroup = (TrophyGroup)i; if (trophyGroup == TrophyGroup.All || array[i] > 0 || trophyGroup == _tab) { list.Add(new KeyValuePair<TrophyGroup, int>(trophyGroup, array[i])); } } return list; } private static bool HasTab(List<KeyValuePair<TrophyGroup, int>> tabs, TrophyGroup g) { foreach (KeyValuePair<TrophyGroup, int> tab in tabs) { if (tab.Key == g) { return true; } } return false; } } public enum ChanceMode { Multiply, Fixed } public sealed class TrophySettings { public const int NetFormat = 1; public bool Enabled = true; public ChanceMode Mode = ChanceMode.Multiply; public float Multiplier = 2f; public float FixedChance = 25f; public float StarBonus = 0f; public bool FirstGuaranteed = false; public bool AffectBosses = false; public Dictionary<string, float> Overrides = new Dictionary<string, float>(StringComparer.Ordinal); public static TrophySettings Vanilla() { return new TrophySettings { Enabled = true, Mode = ChanceMode.Multiply, Multiplier = 1f, FixedChance = 25f, StarBonus = 0f, FirstGuaranteed = false, AffectBosses = false }; } public TrophySettings Clone() { TrophySettings trophySettings = (TrophySettings)MemberwiseClone(); trophySettings.Overrides = new Dictionary<string, float>(Overrides, StringComparer.Ordinal); return trophySettings; } public bool SameAs(TrophySettings o) { if (o == null) { return false; } if (Enabled != o.Enabled || Mode != o.Mode || FirstGuaranteed != o.FirstGuaranteed || AffectBosses != o.AffectBosses) { return false; } if (!Near(Multiplier, o.Multiplier) || !Near(FixedChance, o.FixedChance) || !Near(StarBonus, o.StarBonus)) { return false; } if (Overrides.Count != o.Overrides.Count) { return false; } foreach (KeyValuePair<string, float> @override in Overrides) { if (!o.Overrides.TryGetValue(@override.Key, out var value) || !Near(value, @override.Value)) { return false; } } return true; } private static bool Near(float a, float b) { return Mathf.Abs(a - b) < 0.0001f; } public float Compute(string trophy, float baseChance, int level, bool boss, bool ignoreOverride = false) { if (!Enabled) { return baseChance; } if (boss && !AffectBosses) { return baseChance; } float value; float num = ((!ignoreOverride && trophy != null && Overrides.TryGetValue(trophy, out value)) ? (value / 100f) : ((Mode != ChanceMode.Fixed) ? (baseChance * Multiplier) : (FixedChance / 100f))); if (level > 1 && StarBonus > 0f) { num *= 1f + StarBonus / 100f * (float)(level - 1); } return Mathf.Clamp01(num); } public void Write(ZPackage pkg) { pkg.Write(Enabled); pkg.Write((int)Mode); pkg.Write(Multiplier); pkg.Write(FixedChance); pkg.Write(StarBonus); pkg.Write(FirstGuaranteed); pkg.Write(AffectBosses); pkg.Write(Overrides.Count); foreach (KeyValuePair<string, float> @override in Overrides) { pkg.Write(@override.Key); pkg.Write(@override.Value); } } public static TrophySettings Read(ZPackage pkg) { TrophySettings trophySettings = new TrophySettings(); trophySettings.Enabled = pkg.ReadBool(); trophySettings.Mode = (ChanceMode)pkg.ReadInt(); trophySettings.Multiplier = pkg.ReadSingle(); trophySettings.FixedChance = pkg.ReadSingle(); trophySettings.StarBonus = pkg.ReadSingle(); trophySettings.FirstGuaranteed = pkg.ReadBool(); trophySettings.AffectBosses = pkg.ReadBool(); int num = pkg.ReadInt(); for (int i = 0; i < num; i++) { string text = pkg.ReadString(); float value = pkg.ReadSingle(); if (!string.IsNullOrEmpty(text)) { trophySettings.Overrides[text] = value; } } return trophySettings; } public static string OverridesToString(Dictionary<string, float> map) { StringBuilder stringBuilder = new StringBuilder(); List<string> list = new List<string>(map.Keys); list.Sort(StringComparer.Ordinal); foreach (string item in list) { if (stringBuilder.Length > 0) { stringBuilder.Append(';'); } stringBuilder.Append(item).Append(':').Append(map[item].ToString("0.###", CultureInfo.InvariantCulture)); } return stringBuilder.ToString(); } public static Dictionary<string, float> ParseOverrides(string text) { Dictionary<string, float> dictionary = new Dictionary<string, float>(StringComparer.Ordinal); if (string.IsNullOrEmpty(text)) { return dictionary; } string[] array = text.Split(new char[2] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text2 in array) { int num = text2.IndexOf(':'); if (num > 0) { string text3 = text2.Substring(0, num).Trim(); if (text3.Length > 0 && float.TryParse(text2.Substring(num + 1).Trim().Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { dictionary[text3] = Mathf.Clamp(result, 0f, 100f); } } } return dictionary; } } [BepInPlugin("kaefchik.trophytweaks", "TrophyTweaks", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TrophyTweaksPlugin : BaseUnityPlugin { public const string GUID = "kaefchik.trophytweaks"; public const string NAME = "TrophyTweaks"; public const string VERSION = "1.0.1"; public const string HubId = "trophytweaks"; private static ManualLogSource _log; private static TrophyTweaksPlugin _instance; private static ConfigEntry<bool> _enabled; private static ConfigEntry<ChanceMode> _mode; private static ConfigEntry<float> _multiplier; private static ConfigEntry<float> _fixedChance; private static ConfigEntry<float> _starBonus; private static ConfigEntry<bool> _firstGuaranteed; private static ConfigEntry<bool> _affectBosses; private static ConfigEntry<string> _overrides; private static bool _saving; private Harmony _harmony; private HubEntry _hubEntry; private int _hubLang = -1; public static TrophySettings Local = new TrophySettings(); public static TrophySettings Active { get { if ((Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer() && Net.ServerSettings != null) { return Net.ServerSettings; } return Local; } } public static bool ServerWithoutMod => (Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer() && Net.ServerSettings == null; public static bool CanEdit { get { if ((Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer()) { return true; } if (Net.ServerSettings == null) { return true; } return Net.ServerSaysAdmin; } } private void Awake() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown _instance = this; _log = ((BaseUnityPlugin)this).Logger; _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Mod on/off. Off = vanilla trophy chances."); _mode = ((BaseUnityPlugin)this).Config.Bind<ChanceMode>("General", "Mode", ChanceMode.Multiply, "Multiply = vanilla chance x Multiplier. Fixed = FixedChance for every trophy."); _multiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Multiplier", 2f, new ConfigDescription("Multiplier for the vanilla chance (Mode = Multiply).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _fixedChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FixedChance", 25f, new ConfigDescription("Chance in percent for every trophy (Mode = Fixed).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); _starBonus = ((BaseUnityPlugin)this).Config.Bind<float>("General", "StarBonus", 0f, new ConfigDescription("Extra chance in percent of the current chance for every star of the mob.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); _firstGuaranteed = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FirstTrophyGuaranteed", false, "The first trophy of each kind always drops for a player who doesn't have it yet."); _affectBosses = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AffectBosses", false, "Also change boss trophies (vanilla bosses always drop them)."); _overrides = ((BaseUnityPlugin)this).Config.Bind<string>("Trophies", "Overrides", "", "Own chance per trophy in percent: TrophyBoar:50;TrophyDeer:100. Easier to edit in the ModHub menu."); Local = LoadLocal(); ((BaseUnityPlugin)this).Config.SettingChanged += OnConfigChanged; _harmony = new Harmony("kaefchik.trophytweaks"); _harmony.PatchAll(typeof(TrophyTweaksPlugin).Assembly); string text = Loc.T("tile"); Action action = TrophyMenu.Open; string text2 = Loc.T("tile_desc"); Action action2 = TrophyMenu.Close; _hubEntry = ModHubAPI.Register("trophytweaks", text, action, "TrophyDeer", (Sprite)null, (Color?)null, text2, 100, (Func<bool>)null, action2, (Func<bool>)(() => TrophyMenu.IsOpen)); Log("TrophyTweaks 1.0.1 loaded"); } private void Update() { if (_hubEntry != null && _hubLang != Loc.Lang) { _hubLang = Loc.Lang; _hubEntry.Title = Loc.T("tile"); _hubEntry.Description = Loc.T("tile_desc"); } if (TrophyMenu.IsOpen && ((Object)(object)Player.m_localPlayer == (Object)null || Input.GetKeyDown((KeyCode)27))) { TrophyMenu.Close(); } } private void OnGUI() { TrophyMenu.Draw(); } private void OnDestroy() { TrophyMenu.Close(); ((BaseUnityPlugin)this).Config.SettingChanged -= OnConfigChanged; try { ModHubAPI.Unregister("trophytweaks"); } catch { } if (_harmony != null) { _harmony.UnpatchSelf(); } } private static TrophySettings LoadLocal() { return new TrophySettings { Enabled = _enabled.Value, Mode = _mode.Value, Multiplier = Mathf.Clamp(_multiplier.Value, 0f, 10f), FixedChance = Mathf.Clamp(_fixedChance.Value, 0f, 100f), StarBonus = Mathf.Clamp(_starBonus.Value, 0f, 100f), FirstGuaranteed = _firstGuaranteed.Value, AffectBosses = _affectBosses.Value, Overrides = TrophySettings.ParseOverrides(_overrides.Value) }; } public static void SaveLocal(TrophySettings s) { if (!((Object)(object)_instance == (Object)null)) { _saving = true; try { ConfigFile config = ((BaseUnityPlugin)_instance).Config; bool saveOnConfigSet = config.SaveOnConfigSet; config.SaveOnConfigSet = false; _enabled.Value = s.Enabled; _mode.Value = s.Mode; _multiplier.Value = s.Multiplier; _fixedChance.Value = s.FixedChance; _starBonus.Value = s.StarBonus; _firstGuaranteed.Value = s.FirstGuaranteed; _affectBosses.Value = s.AffectBosses; _overrides.Value = TrophySettings.OverridesToString(s.Overrides); config.SaveOnConfigSet = saveOnConfigSet; config.Save(); } finally { _saving = false; } Local = s.Clone(); } } private void OnConfigChanged(object sender, SettingChangedEventArgs e) { if (!_saving) { Local = LoadLocal(); Net.Broadcast(); TrophyMenu.OnActiveSettingsChanged(); } } public static void Log(string msg) { if (_log != null) { _log.LogInfo((object)msg); } } public static void LogWarning(string msg) { if (_log != null) { _log.LogWarning((object)msg); } } public static void LogError(string msg) { if (_log != null) { _log.LogError((object)msg); } } } }