using System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Localization; using UnityEngine.Localization.Settings; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace SuperCreatures; [BepInPlugin("com.howToFish.supercreatures", "SuperCreatures", "1.0.0")] public class SuperCreaturesPlugin : BaseUnityPlugin { private Harmony _harmony; public static SuperCreaturesPlugin Instance { get; private set; } public static ManualLogSource Log => ((Object)(object)Instance != (Object)null) ? ((BaseUnityPlugin)Instance).Logger : null; public static ConfigEntry ModEnabled { get; private set; } public static ConfigEntry SuperCreatureChance { get; private set; } public static ConfigEntry AlwaysSuper { get; private set; } public static ConfigEntry AllowBosses { get; private set; } public static bool IsRussian { get { //IL_001a: 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) try { if ((Object)(object)LocalizationSettings.SelectedLocale != (Object)null) { LocaleIdentifier identifier = LocalizationSettings.SelectedLocale.Identifier; string code = ((LocaleIdentifier)(ref identifier)).Code; if (!string.IsNullOrEmpty(code) && code.IndexOf("ru", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } } catch { } try { if (LocalizationManager.CurLanguage == 11) { return true; } } catch { } return false; } } public static string GetText(string en, string ru) { return IsRussian ? ru : en; } private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown Instance = this; ModEnabled = ((BaseUnityPlugin)this).Config.Bind("1. General", "Enabled", true, "Enable/Disable the mod. / Включить или выключить модификацию."); SuperCreatureChance = ((BaseUnityPlugin)this).Config.Bind("2. Chances", "SuperCreatureChance", 50, new ConfigDescription("Chance in percentage (0 - 100%) for caught fish to spawn as Super/Drip. / Шанс в процентах (0 - 100%) на супер-рыбу.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), new object[0])); AlwaysSuper = ((BaseUnityPlugin)this).Config.Bind("2. Chances", "AlwaysSuper", false, "Guarantee 100% Super/Drip variant for every catch. / Гарантировать 100% супер-рыбу на каждый улов."); AllowBosses = ((BaseUnityPlugin)this).Config.Bind("2. Chances", "AllowBosses", false, "Allow Bosses and Mini-Bosses to roll as Drip variants. / Разрешить боссам также становиться Drip-сущностями."); _harmony = new Harmony("com.howToFish.supercreatures"); _harmony.PatchAll(); if (Log != null) { string text = GetText(string.Format("{0} v{1} initialized successfully!", "SuperCreatures", "1.0.0"), string.Format("{0} v{1} успешно запущен!", "SuperCreatures", "1.0.0")); Log.LogInfo((object)text); } } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } } public static class PluginInfo { public const string PLUGIN_GUID = "com.howToFish.supercreatures"; public const string PLUGIN_NAME = "SuperCreatures"; public const string PLUGIN_VERSION = "1.0.0"; } [HarmonyPatch(typeof(CreatureManager))] public static class CreatureManagerPatch { private static readonly FieldInfo ShinyChanceField = AccessTools.Field(typeof(CreatureManager), "_shinyCreatureChance"); private static void UpdateShinyChance(CreatureManager instance) { if (!((Object)(object)instance == (Object)null) && !(ShinyChanceField == null)) { int num = (SuperCreaturesPlugin.AlwaysSuper.Value ? 100 : SuperCreaturesPlugin.SuperCreatureChance.Value); ShinyChanceField.SetValue(instance, num); } } [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake_Postfix(CreatureManager __instance) { if (SuperCreaturesPlugin.ModEnabled.Value) { UpdateShinyChance(__instance); int num = (SuperCreaturesPlugin.AlwaysSuper.Value ? 100 : SuperCreaturesPlugin.SuperCreatureChance.Value); if (SuperCreaturesPlugin.Log != null) { string text = SuperCreaturesPlugin.GetText($"[SuperCreatures] CreatureManager started. Super/Drip chance set to {num}%.", $"[SuperCreatures] Менеджер существ запущен. Шанс Супер/Drip рыбы установлен на {num}%."); SuperCreaturesPlugin.Log.LogInfo((object)text); } } } [HarmonyPatch("HookItem")] [HarmonyPrefix] public static void HookItem_Prefix(CreatureManager __instance, Item itemPrefab, Bait bait) { if (SuperCreaturesPlugin.ModEnabled.Value) { UpdateShinyChance(__instance); } } [HarmonyPostfix] [HarmonyPatch("HookItem")] public static void HookItem_Postfix(CreatureManager __instance, Item itemPrefab, Bait bait) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 if (!SuperCreaturesPlugin.ModEnabled.Value || !SuperCreaturesPlugin.AllowBosses.Value) { return; } Item val = (((Object)(object)bait != (Object)null) ? bait.ServerItemOnBait : null); if (!((Object)(object)val != (Object)null) || !((Object)(object)val.Creature != (Object)null) || (int)val.Creature.BossType == 0) { return; } int num = (SuperCreaturesPlugin.AlwaysSuper.Value ? 100 : SuperCreaturesPlugin.SuperCreatureChance.Value); if (Random.Range(0, 100) < num) { val.Creature.SetDrip(); if (SuperCreaturesPlugin.Log != null) { string text = SuperCreaturesPlugin.GetText($"[SuperCreatures] Boss creature {((Object)val).name} became a SUPER (Drip) entity!", $"[SuperCreatures] Босс {((Object)val).name} стал СУПЕР (Drip) сущностью!"); SuperCreaturesPlugin.Log.LogInfo((object)text); } } } }