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 PuckosCarePackage v1.2.3
plugins/EinsteinCrew-PuckosCarePackage/Pucko-Bossbound/Bossbound.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace Pucko.Bossbound; internal sealed class StatDef { public string Id; public string Name; public string Unit; public float Cap; public StatDef(string id, string name, string unit, float cap) { Id = id; Name = name; Unit = unit; Cap = cap; } } internal sealed class BossSetup { public string Name; public string Key; public string Stat1; public string Stat2; public string Stat3; public bool On; public float Amount1; public float Amount2; public float Amount3; } internal static class BossMath { public const string None = "none"; public static readonly StatDef[] Stats = new StatDef[17] { new StatDef("none", "(empty slot)", "", 0f), new StatDef("hp", "Max health", "", 0f), new StatDef("sta", "Max stamina", "", 0f), new StatDef("eitr", "Max Eitr", "", 0f), new StatDef("carry", "Carry weight", "", 0f), new StatDef("staRegen", "Stamina regen", "%", 0f), new StatDef("hpRegen", "Health regen", "%", 0f), new StatDef("eitrRegen", "Eitr regen", "%", 0f), new StatDef("runUse", "Run stamina use, less", "%", 90f), new StatDef("jumpUse", "Jump stamina use, less", "%", 90f), new StatDef("swimUse", "Swim stamina use, less", "%", 90f), new StatDef("speed", "Move speed", "%", 0f), new StatDef("fall", "Fall damage taken, less", "%", 100f), new StatDef("dmg", "Damage dealt", "%", 0f), new StatDef("phys", "Physical damage taken, less", "%", 90f), new StatDef("elem", "Elemental damage taken, less", "%", 90f), new StatDef("adren", "Adrenaline gain", "%", 0f) }; public static string[] StatIds() { string[] array = new string[Stats.Length]; for (int i = 0; i < Stats.Length; i++) { array[i] = Stats[i].Id; } return array; } public static StatDef Find(string id) { if (id == null) { return null; } StatDef[] stats = Stats; foreach (StatDef statDef in stats) { if (string.Equals(statDef.Id, id, StringComparison.OrdinalIgnoreCase)) { return statDef; } } return null; } public static Dictionary<string, float> Totals(IList<BossSetup> bosses, Func<string, bool> defeated, float strengthPercent) { Dictionary<string, float> dictionary = new Dictionary<string, float>(); float num = Math.Max(0f, strengthPercent) / 100f; foreach (BossSetup boss in bosses) { if (boss != null && boss.On && !string.IsNullOrEmpty(boss.Key) && defeated(boss.Key)) { Add(dictionary, boss.Stat1, boss.Amount1 * num); Add(dictionary, boss.Stat2, boss.Amount2 * num); Add(dictionary, boss.Stat3, boss.Amount3 * num); } } StatDef[] stats = Stats; foreach (StatDef statDef in stats) { if (statDef.Cap > 0f && dictionary.TryGetValue(statDef.Id, out var value) && value > statDef.Cap) { dictionary[statDef.Id] = statDef.Cap; } } return dictionary; } private static void Add(Dictionary<string, float> t, string stat, float amount) { StatDef statDef = Find(stat); if (statDef != null && !(statDef.Id == "none") && !(amount <= 0f)) { t.TryGetValue(statDef.Id, out var value); t[statDef.Id] = value + amount; } } public static float Get(Dictionary<string, float> t, string id) { if (t == null || !t.TryGetValue(id, out var value)) { return 0f; } return value; } public static string Signature(Dictionary<string, float> t) { StringBuilder stringBuilder = new StringBuilder(); StatDef[] stats = Stats; foreach (StatDef statDef in stats) { float num = Get(t, statDef.Id); if (num > 0f) { stringBuilder.Append(statDef.Id).Append('=').Append(num.ToString("0.###", CultureInfo.InvariantCulture)) .Append(';'); } } return stringBuilder.ToString(); } public static string Describe(Dictionary<string, float> t) { StringBuilder stringBuilder = new StringBuilder(); StatDef[] stats = Stats; foreach (StatDef statDef in stats) { float num = Get(t, statDef.Id); if (!(num <= 0f)) { if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(statDef.Name).Append(' ').Append(num.ToString("0.#", CultureInfo.InvariantCulture)) .Append(statDef.Unit); } } if (stringBuilder.Length != 0) { return stringBuilder.ToString(); } return "none"; } } internal static class BuffGame { public const string SeName = "PuckoBossbound"; public static Dictionary<string, float> Active = new Dictionary<string, float>(); private static string _sig = ""; private static SE_Stats _template; private static float _timer; public static bool Defeated(string key) { ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance != (Object)null) { return instance.GetGlobalKey(key); } return false; } public static Dictionary<string, float> Compute() { if (!Cfg.Enabled.Value) { return new Dictionary<string, float>(); } return BossMath.Totals(Cfg.Setup(), Defeated, Cfg.Strength.Value); } public static void Fill(SE_Stats se, Dictionary<string, float> t) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) se.m_addMaxCarryWeight = BossMath.Get(t, "carry"); se.m_staminaRegenMultiplier = 1f + BossMath.Get(t, "staRegen") / 100f; se.m_healthRegenMultiplier = 1f + BossMath.Get(t, "hpRegen") / 100f; se.m_eitrRegenMultiplier = 1f + BossMath.Get(t, "eitrRegen") / 100f; se.m_runStaminaDrainModifier = (0f - BossMath.Get(t, "runUse")) / 100f; se.m_jumpStaminaUseModifier = (0f - BossMath.Get(t, "jumpUse")) / 100f; se.m_swimStaminaUseModifier = (0f - BossMath.Get(t, "swimUse")) / 100f; se.m_speedModifier = BossMath.Get(t, "speed") / 100f; se.m_fallDamageModifier = (0f - BossMath.Get(t, "fall")) / 100f; se.m_adrenalineModifier = BossMath.Get(t, "adren") / 100f; se.m_modifyAttackSkill = (SkillType)999; se.m_damageModifier = 1f + BossMath.Get(t, "dmg") / 100f; } private static SE_Stats Template() { if ((Object)(object)_template == (Object)null) { _template = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)_template).name = "PuckoBossbound"; ((StatusEffect)_template).m_name = "Bossbound"; ((StatusEffect)_template).m_icon = null; ((StatusEffect)_template).m_ttl = 0f; } return _template; } public static void Tick(Player p, float dt) { _timer -= dt; if (_timer > 0f) { return; } _timer = 2f; SEMan sEMan = ((Character)p).GetSEMan(); if (sEMan == null) { return; } Dictionary<string, float> dictionary = Compute(); string text = BossMath.Signature(dictionary); int stableHashCode = StringExtensionMethods.GetStableHashCode("PuckoBossbound"); bool flag = sEMan.HaveStatusEffect(stableHashCode); if (text == _sig && (flag || text.Length == 0)) { Active = dictionary; return; } Active = dictionary; if (!flag && text.Length > 0) { SE_Stats val = Template(); Fill(val, dictionary); sEMan.AddStatusEffect((StatusEffect)(object)val, false, 0, 0f, (short)(-1)); } StatusEffect statusEffect = sEMan.GetStatusEffect(stableHashCode); SE_Stats val2 = (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null); if ((Object)(object)val2 != (Object)null) { Fill(val2, dictionary); } if (text != _sig && Cfg.LogChanges.Value) { Plugin.Log.LogInfo((object)("Boss buffs now: " + BossMath.Describe(dictionary))); } _sig = text; } } internal static class Cfg { internal sealed class BossEntries { public string Name; public ConfigEntry<bool> On; public ConfigEntry<string> Key; public ConfigEntry<string> Stat1; public ConfigEntry<string> Stat2; public ConfigEntry<string> Stat3; public ConfigEntry<float> Amount1; public ConfigEntry<float> Amount2; public ConfigEntry<float> Amount3; } public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> LogChanges; public static ConfigEntry<float> Strength; public static readonly List<BossEntries> Bosses = new List<BossEntries>(); private static readonly object[][] Defaults = new object[7][] { new object[6] { "Eikthyr", "defeated_eikthyr", "hp", 5f, "runUse", 10f }, new object[6] { "The Elder", "defeated_gdking", "hp", 5f, "hpRegen", 10f }, new object[6] { "Bonemass", "defeated_bonemass", "hp", 10f, "staRegen", 10f }, new object[6] { "Moder", "defeated_dragon", "hp", 10f, "fall", 20f }, new object[6] { "Yagluth", "defeated_goblinking", "hp", 10f, "sta", 25f }, new object[6] { "The Queen", "defeated_queen", "eitr", 25f, "eitrRegen", 10f }, new object[6] { "Fader", "defeated_fader", "hp", 10f, "adren", 10f } }; private static ConfigurationManagerAttributes AdminTag(int order) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true, Order = order }; } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, string d, AcceptableValueBase range, int order) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d, range, new object[1] { AdminTag(order) })); } public static void Bind(ConfigFile c) { Enabled = Adm(c, "1 - General", "Enabled", v: true, "Defeated bosses give every player permanent buffs. Off: nothing is applied.", null, 20); Strength = Adm(c, "1 - General", "StrengthPercent", 100f, "Scales every buff below. 100 = the amounts as written, 50 = half of each.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f), 10); LogChanges = c.Bind<bool>("1 - General", "LogChanges", true, "Write a line to the BepInEx log whenever your active buffs change. Local only."); AcceptableValueList<string> range = new AcceptableValueList<string>(BossMath.StatIds()); AcceptableValueRange<float> range2 = new AcceptableValueRange<float>(0f, 500f); int num = 0; object[][] defaults = Defaults; foreach (object[] array in defaults) { num++; string s = num + " - " + (string)array[0]; BossEntries bossEntries = new BossEntries { Name = (string)array[0] }; bossEntries.On = Adm(c, s, "Active", v: true, "Switch this boss's buffs off without touching the amounts.", null, 60); bossEntries.Key = Adm(c, s, "WorldKey", (string)array[1], "The world key the game sets when this boss dies. Only change it for a modded boss. List the keys in game with the listkeys console command.", null, 50); bossEntries.Stat3 = Adm(c, s, "Buff3", "carry", "Third buff, same list.", (AcceptableValueBase)(object)range, 6); bossEntries.Amount3 = Adm(c, s, "Buff3Amount", 10f, "Amount of the third buff (default: +10 carry weight).", (AcceptableValueBase)(object)range2, 5); bossEntries.Stat1 = Adm(c, s, "Buff1", (string)array[2], "First buff. One of: " + string.Join(", ", BossMath.StatIds()) + ".", (AcceptableValueBase)(object)range, 40); bossEntries.Amount1 = Adm(c, s, "Buff1Amount", (float)array[3], "Amount of the first buff: points for hp, sta, eitr and carry; percent for the rest.", (AcceptableValueBase)(object)range2, 30); bossEntries.Stat2 = Adm(c, s, "Buff2", (string)array[4], "Second buff, same list.", (AcceptableValueBase)(object)range, 20); bossEntries.Amount2 = Adm(c, s, "Buff2Amount", (float)array[5], "Amount of the second buff.", (AcceptableValueBase)(object)range2, 10); Bosses.Add(bossEntries); } } public static List<BossSetup> Setup() { List<BossSetup> list = new List<BossSetup>(); foreach (BossEntries boss in Bosses) { list.Add(new BossSetup { Name = boss.Name, On = boss.On.Value, Key = boss.Key.Value, Stat1 = boss.Stat1.Value, Amount1 = boss.Amount1.Value, Stat2 = boss.Stat2.Value, Amount2 = boss.Amount2.Value, Stat3 = boss.Stat3.Value, Amount3 = boss.Amount3.Value }); } return list; } } [HarmonyPatch(typeof(Player), "Update")] internal static class Player_Update_Tick { private static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { BuffGame.Tick(__instance, Time.deltaTime); } } } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] internal static class Player_GetTotalFoodValue_Flat { private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { Dictionary<string, float> active = BuffGame.Active; hp += BossMath.Get(active, "hp"); stamina += BossMath.Get(active, "sta"); float num = BossMath.Get(active, "eitr"); if (num > 0f) { eitr += num; } } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] internal static class Character_RPC_Damage_Less { private static void Prefix(Character __instance, HitData hit) { if (hit != null && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { Dictionary<string, float> active = BuffGame.Active; float num = 1f - BossMath.Get(active, "phys") / 100f; float num2 = 1f - BossMath.Get(active, "elem") / 100f; if (num < 1f) { hit.m_damage.m_blunt *= num; hit.m_damage.m_slash *= num; hit.m_damage.m_pierce *= num; } if (num2 < 1f) { hit.m_damage.m_fire *= num2; hit.m_damage.m_frost *= num2; hit.m_damage.m_lightning *= num2; hit.m_damage.m_poison *= num2; hit.m_damage.m_spirit *= num2; } } } } [BepInPlugin("pucko.bossbound", "Bossbound", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "pucko.bossbound"; public const string NAME = "Bossbound"; public const string VERSION = "0.1.1"; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Cfg.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("pucko.bossbound"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"Bossbound 0.1.1 loaded"); } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } }
plugins/EinsteinCrew-PuckosCarePackage/Pucko-CombatEvolved/CombatEvolved.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace Pucko.CombatEvolved; internal struct Values { public float WindupStartFactor; public float WindupShape; public float HoldSeconds; public float StepDistance; public float StepSeconds; public float WindupFactor; public float StrikeFactor; public float StrikeSeconds; public float RecoveryFactor; public float StaminaFactor; public float DamageFactor; public float AdrenalineCost; public bool StepUntilHit; } internal static class Cfg { internal struct Cat { public string Key; public string Label; public int Hits; public bool Shield; } public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> LogDetails; public static ConfigEntry<bool> LogSwings; public static ConfigEntry<bool> VolEnabled; public static ConfigEntry<bool> SlopeEnabled; public static ConfigEntry<bool> LookAim; public static ConfigEntry<bool> SlopeFollow; public static ConfigEntry<bool> ShowVol; public static ConfigEntry<bool> ShowBounds; public static ConfigEntry<float> VolRange; public static ConfigEntry<float> VolWidth; public static ConfigEntry<float> VolArc; public static ConfigEntry<float> VolHeight; public static ConfigEntry<float> VolOffset; public static ConfigEntry<float> VolCharExtra; public static ConfigEntry<float> VolCharShift; public static ConfigEntry<float> MaxTiltUp; public static ConfigEntry<float> MaxTiltDown; public static ConfigEntry<float> LookUpPercent; public static ConfigEntry<float> LookDownPercent; public static ConfigEntry<float> SlopePercent; public static ConfigEntry<float> LockExtraRange; public static ConfigEntry<float> LockDeadZone; public static ConfigEntry<float> ShowSeconds; public static ConfigEntry<float> ShowBoundsRange; public static ConfigEntry<string> SoftLock; public static ConfigEntry<bool> HitStopCreaturesOnly; public static ConfigEntry<bool> ShakeEnabled; public static ConfigEntry<float> HitStopPercent; public static ConfigEntry<float> KillStopBonus; public static ConfigEntry<float> TargetFreeze; public static ConfigEntry<float> ShakeStrength; public static ConfigEntry<float> KnockbackPercent; public static ConfigEntry<float> StaggerPercent; public static ConfigEntry<float> NormalWindup; public static ConfigEntry<float> NormalStrike; public static ConfigEntry<float> NormalStrikeSecs; public static ConfigEntry<float> NormalRecovery; private static readonly Dictionary<string, ConfigEntry<float>> s_stopType = new Dictionary<string, ConfigEntry<float>>(); public static ConfigEntry<KeyboardShortcut> DebugKey; private static readonly Dictionary<string, ConfigEntry<float>> s_volType = new Dictionary<string, ConfigEntry<float>>(); public const string LockOff = "Off"; public const string LockAlways = "Always"; public const string LockNeeded = "When needed"; private static ConfigEntry<float>[] s_windupStart = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_ramp = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_hold = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_dist = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_secs = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_windup = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_strike = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_strikeSecs = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_recovery = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_stam = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_dmg = new ConfigEntry<float>[2]; private static ConfigEntry<float>[] s_adr = new ConfigEntry<float>[2]; private static ConfigEntry<string>[] s_stepTiming = new ConfigEntry<string>[2]; internal const string TimingFixed = "Fixed time"; internal const string TimingWindup = "Tied to the windup"; private static readonly Dictionary<string, ConfigEntry<int>> s_hit = new Dictionary<string, ConfigEntry<int>>(); private static readonly Dictionary<string, ConfigEntry<int>> s_hitShield = new Dictionary<string, ConfigEntry<int>>(); internal static readonly Cat[] Cats = new Cat[13] { new Cat { Key = "Sword", Label = "Sword (one-handed)", Hits = 3, Shield = true }, new Cat { Key = "Axe", Label = "Axe (one-handed)", Hits = 3, Shield = true }, new Cat { Key = "Club", Label = "Club / mace (one-handed)", Hits = 3, Shield = true }, new Cat { Key = "Knife", Label = "Knife (one-handed)", Hits = 3, Shield = true }, new Cat { Key = "Spear", Label = "Spear (one-handed)", Hits = 1, Shield = true }, new Cat { Key = "Atgeir", Label = "Atgeir (two-handed)", Hits = 3, Shield = false }, new Cat { Key = "Greatsword", Label = "Greatsword (two-handed)", Hits = 3, Shield = false }, new Cat { Key = "Battleaxe", Label = "Battleaxe (two-handed)", Hits = 3, Shield = false }, new Cat { Key = "DualAxes", Label = "Dual axes (two-handed)", Hits = 4, Shield = false }, new Cat { Key = "DualKnives", Label = "Dual knives", Hits = 3, Shield = false }, new Cat { Key = "Sledge", Label = "Sledge (two-handed)", Hits = 1, Shield = false }, new Cat { Key = "Pickaxe", Label = "Pickaxe (two-handed)", Hits = 1, Shield = false }, new Cat { Key = "Fists", Label = "Fists and claws", Hits = 2, Shield = false } }; private static ConfigurationManagerAttributes AdminTag(int order) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true, Order = order }; } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, string d, AcceptableValueBase range, int order) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d, range, new object[1] { AdminTag(order) })); } public static void Bind(ConfigFile c) { Enabled = Adm(c, "1 - General", "Enabled", v: true, "Sprint attack on or off. Off: the game's own combat, nothing changed.", null, 10); LogDetails = c.Bind<bool>("1 - General", "LogDetails", true, "Write a line to the BepInEx log for every sprint attack: weapon type, combo hit, how far you moved and how long it took. Useful while tuning; turn off when you are happy."); LogSwings = c.Bind<bool>("1 - General", "LogSwings", false, "Write a line to the BepInEx log for every melee swing (weapon type, volume, tilt used, hits). For tuning the hit volume and slope aim; off by default because it is one line per swing."); PoiseCfg.Bind(c); BindVolume(c); BindImpact(c); Group(c, 0, "2 - Sprint attack", ""); Group(c, 1, "3 - Sprint attack with a shield", " with a shield"); int num = 100; Cat[] cats = Cats; for (int i = 0; i < cats.Length; i++) { Cat cat = cats[i]; s_hit[cat.Key] = Adm(c, "4 - Combo hit used", cat.Key, 1, cat.Label + ": which hit of the weapon's combo the sprint attack is (1 = first swing, up to " + cat.Hits + "). 0 = no sprint attack with this weapon type. The following hits of the combo play as normal.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, cat.Hits), num--); } num = 100; cats = Cats; for (int i = 0; i < cats.Length; i++) { Cat cat2 = cats[i]; if (cat2.Shield) { s_hitShield[cat2.Key] = Adm(c, "5 - Combo hit used with a shield", cat2.Key, 1, cat2.Label + " with a shield in the other hand: which hit of the combo the sprint attack is (1 to " + cat2.Hits + "). 0 = no sprint attack with a shield for this weapon type.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, cat2.Hits), num--); } } } private static void BindVolume(ConfigFile c) { //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Expected O, but got Unknown //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Expected O, but got Unknown VolEnabled = Adm(c, "6 - Hit volume", "Enabled", v: true, "Scale the swing's hit volume (all melee swings of the local player). With every value at its default the game's own volume is used.", null, 100); VolRange = Adm(c, "6 - Hit volume", "RangePercent", 100f, "How far the swing reaches, in % of the weapon's own range.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 300f), 90); VolWidth = Adm(c, "6 - Hit volume", "WidthPercent", 100f, "How thick the swing is (the radius of the swept sphere), in % of the weapon's own.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 400f), 80); VolArc = Adm(c, "6 - Hit volume", "ArcPercent", 100f, "How wide the swing's arc is, in % of the weapon's own arc (capped at 360 degrees).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 400f), 70); VolHeight = Adm(c, "6 - Hit volume", "HeightShiftMeters", 0f, "Moves the swing's centre up (+) or down (-), in metres. The game's swings start about 0.8-1.5 m above the feet.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), 60); VolOffset = Adm(c, "6 - Hit volume", "SideShiftMeters", 0f, "Moves the swing's centre to the right (+) or left (-), in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), 50); VolCharExtra = Adm(c, "6 - Hit volume", "CreatureExtraWidthMeters", 0f, "Extra thickness of the swing against creatures only (not trees, rocks or buildings), in metres. The game has this setting built in, at 0 for every weapon. This is the way to make enemies easier to hit without touching their own colliders.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.5f), 40); VolCharShift = Adm(c, "6 - Hit volume", "CreatureCastShiftMeters", 0f, "Moves the swing's two extra creature-only checks (the low one and the high one that most weapons have) up (+) or down (-), in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), 30); int num = 100; Cat[] cats = Cats; for (int i = 0; i < cats.Length; i++) { Cat cat = cats[i]; s_volType[cat.Key] = Adm(c, "6b - Hit volume per weapon type", cat.Key, 100f, cat.Label + ": range, thickness and arc together, in % (on top of the settings above).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 300f), num--); } SlopeEnabled = Adm(c, "7 - Slope and vertical aim", "Enabled", v: true, "Tilt every melee swing up or down so it reaches enemies on slopes and at different heights. The game's own swings are all flat.", null, 100); MaxTiltUp = Adm(c, "7 - Slope and vertical aim", "MaxTiltUpDegrees", 30f, "The most the swing may tilt up, in degrees (limits look aim, slope follow and soft lock alike). Replaces MaxTiltDegrees of 0.3.x.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 70f), 92); MaxTiltDown = Adm(c, "7 - Slope and vertical aim", "MaxTiltDownDegrees", 30f, "The most the swing may tilt down, in degrees. Set separately from up, because looking down usually needs less than looking up.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 70f), 91); LookUpPercent = Adm(c, "7 - Slope and vertical aim", "LookAimUpPercent", 100f, "How strongly the swing follows the camera when you look up, in % (100 = the camera angle as is). Only the look aim; the tilt limit above still applies.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 200f), 85); LookDownPercent = Adm(c, "7 - Slope and vertical aim", "LookAimDownPercent", 100f, "How strongly the swing follows the camera when you look down, in %.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(25f, 200f), 84); LookAim = Adm(c, "7 - Slope and vertical aim", "LookAim", v: true, "The swing tilts toward where the camera looks (the game's own vertical-aim setting, which is 0 for every weapon).", null, 80); SlopeFollow = Adm(c, "7 - Slope and vertical aim", "SlopeFollow", v: true, "The swing tilts along the ground in front of you, so it stays parallel to a slope.", null, 70); SlopePercent = Adm(c, "7 - Slope and vertical aim", "SlopeFollowPercent", 100f, "How much of the ground's slope the swing follows, in %.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), 60); SoftLock = Adm(c, "7 - Slope and vertical aim", "SoftLock", "When needed", "Tilt the swing toward the nearest enemy in front of you. 'When needed': only when the enemy is at a clearly different height than the swing. 'Always': whenever there is one. It overrides the two settings above for that swing.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Off", "Always", "When needed" }), 50); LockExtraRange = Adm(c, "7 - Slope and vertical aim", "SoftLockExtraRangeMeters", 1f, "How far beyond the weapon's reach an enemy still counts for the soft lock, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f), 40); LockDeadZone = Adm(c, "7 - Slope and vertical aim", "SoftLockMinHeightDifferenceMeters", 0.6f, "For 'When needed': the enemy's centre must be at least this far above or below the swing's centre before the swing tilts toward it, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), 30); ShowVol = c.Bind<bool>("8 - Debug view", "ShowHitVolumes", false, "Draw each melee swing's hit volume in the world for a moment after the swing: green = hit a creature, orange = hit only scenery, red = hit nothing, yellow for the extra creature checks. Local only. For testing."); DebugKey = c.Bind<KeyboardShortcut>("8 - Debug view", "ToggleKey", new KeyboardShortcut((KeyCode)288, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Key that switches the hit volume display on and off."); ShowSeconds = c.Bind<float>("8 - Debug view", "SecondsShown", 2f, new ConfigDescription("How long each swing's volume stays visible, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 10f), Array.Empty<object>())); ShowBounds = c.Bind<bool>("8 - Debug view", "ShowEnemyBounds", true, "Also draw boxes around the colliders of creatures near you (white), what a swing can actually hit."); ShowBoundsRange = c.Bind<float>("8 - Debug view", "EnemyBoundsRangeMeters", 8f, new ConfigDescription("How near a creature must be to get its box drawn, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 30f), Array.Empty<object>())); } private static void BindImpact(ConfigFile c) { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown HitStopPercent = Adm(c, "9 - Impact feel", "HitStopPercent", 100f, "The short freeze of the attacker when a swing hits, in % of the game's own (0.15 s). 0 = no hit stop, 200 = twice as long. The game only freezes the attacker, never the target.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 400f), 100); HitStopCreaturesOnly = Adm(c, "9 - Impact feel", "HitStopOnlyOnCreatures", v: false, "Freeze only when the swing hit a creature, not when it hit a tree, rock or the ground.", null, 90); KillStopBonus = Adm(c, "9 - Impact feel", "KillHitStopBonusSeconds", 0f, "Extra freeze in seconds when the hit is likely to kill (its damage is at least the target's remaining health; resistances are not counted, so it is an estimate).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), 80); TargetFreeze = Adm(c, "9 - Impact feel", "TargetFreezeSeconds", 0f, "Freeze the target's animation too for this long on every hit, in seconds, so the blow lands on both of you. 0 = off. Applies to creatures you hit, on every player's screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.3f), 70); KnockbackPercent = Adm(c, "9 - Impact feel", "KnockbackPercent", 100f, "How hard your melee hits push targets, in % of the weapon's own.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f), 60); StaggerPercent = Adm(c, "9 - Impact feel", "StaggerPercent", 100f, "How much your melee hits build up stagger on targets, in % of the weapon's own.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f), 50); ShakeEnabled = c.Bind<bool>("9 - Impact feel", "HitShake", false, "Shake the camera a little when you land a hit. Local only; the game shakes the camera only when you are hit."); ShakeStrength = c.Bind<float>("9 - Impact feel", "HitShakeStrength", 0.5f, new ConfigDescription("How strong the hit shake is, relative to the game's own shake when you are hit. It grows with the share of the target's health the hit takes. 0 = none.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); NormalWindup = Adm(c, "9c - Normal swing speed", "WindupSpeedBonusPercent", 0f, "Speed of the windup of ordinary swings (not the sprint attack), in % faster (negative = slower). 0 = the game's own. Heavier weapons can be given a slower, more deliberate windup.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-50f, 100f), 40); NormalStrike = Adm(c, "9c - Normal swing speed", "StrikeSpeedBonusPercent", 0f, "Speed of the moment around the hit of ordinary swings, in %.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-50f, 100f), 30); NormalStrikeSecs = Adm(c, "9c - Normal swing speed", "StrikeSeconds", 0.15f, "How long the strike part lasts, in real seconds after the hit lands.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 20); NormalRecovery = Adm(c, "9c - Normal swing speed", "RecoverySpeedBonusPercent", 0f, "Speed of the recovery of ordinary swings (after the strike, until you can act again), in %. Negative = a longer recovery, which suits heavy weapons.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-50f, 100f), 10); int num = 100; Cat[] cats = Cats; for (int i = 0; i < cats.Length; i++) { Cat cat = cats[i]; s_stopType[cat.Key] = Adm(c, "9b - Hit stop per weapon type", cat.Key, 100f, cat.Label + ": hit stop in %, on top of the global setting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 400f), num--); } } public static float StopType(string cat) { if (!s_stopType.TryGetValue(cat ?? "", out var value)) { return 100f; } return value.Value; } public static bool NormalSpeedsOn() { if (NormalWindup.Value == 0f && NormalStrike.Value == 0f) { return NormalRecovery.Value != 0f; } return true; } public static Values NormalValues() { return new Values { WindupStartFactor = 1f + NormalWindup.Value / 100f, WindupShape = 1f, HoldSeconds = 0f, StepDistance = 0f, StepSeconds = 0.4f, WindupFactor = 1f + NormalWindup.Value / 100f, StrikeFactor = 1f + NormalStrike.Value / 100f, StrikeSeconds = NormalStrikeSecs.Value, RecoveryFactor = 1f + NormalRecovery.Value / 100f, StaminaFactor = 1f, DamageFactor = 1f, AdrenalineCost = 0f, StepUntilHit = false }; } internal static void SetVolType(string cat, float v) { s_volType[cat].Value = v; } public static float VolType(string cat) { if (!s_volType.TryGetValue(cat ?? "", out var value)) { return 100f; } return value.Value; } private static void Group(ConfigFile c, int i, string section, string suffix) { s_dist[i] = Adm(c, section, "StepDistance", 2.5f, "How far the quickstep carries you forward" + suffix + ", in metres. It is a fixed distance (it does not home in on the target). 0 = no step.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 8f), 50); s_secs[i] = Adm(c, section, "StepSeconds", 0.4f, "How long the quickstep lasts" + suffix + ", in seconds. The step starts fast and eases off. A short time with a long distance is a lunge; a longer time is a slide.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), 40); s_stepTiming[i] = Adm(c, section, "StepTiming", "Fixed time", "How long the quickstep lasts" + suffix + ". 'Fixed time': always StepSeconds. 'Tied to the windup': the step is spread over the weapon's windup and stops the moment the hit lands, so heavier weapons with a longer windup step for longer (the distance stays StepDistance; the mod learns each weapon's windup time from your swings, StepSeconds is only the first guess).", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Fixed time", "Tied to the windup" }), 36); s_windup[i] = Adm(c, section, "WindupSpeedBonusPercent", 30f, "How fast the windup plays" + suffix + " at its END, in % (negative = slower than normal): the part of the swing from the start until the weapon's hit lands. 30 = the windup takes about 23% less time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-60f, 100f), 34); s_windupStart[i] = Adm(c, section, "WindupStartSpeedBonusPercent", 30f, "How fast the windup plays" + suffix + " at its START, in % (negative = slower). The speed moves from this to WindupSpeedBonusPercent over the windup, so a slow start and a fast end gives a longer, building windup. Same as the end speed = a steady windup (as before).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-60f, 100f), 35); s_ramp[i] = Adm(c, section, "WindupRampShape", 1f, "How the windup speed moves from the start speed to the end speed" + suffix + ". 1 = steadily. Above 1 = stays near the start speed longer and picks up late. Below 1 = picks up early.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 4f), 37); s_hold[i] = Adm(c, section, "AttackHoldSeconds", 0f, "A pause between the windup and the strike" + suffix + " where the character holds the attack, in real seconds. 0 = none. Needs one earlier sprint attack with the weapon to know when its hit lands, so the first sprint attack with each weapon after a game start has no hold.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.6f), 38); s_strike[i] = Adm(c, section, "StrikeSpeedBonusPercent", 30f, "How much faster the strike plays" + suffix + ", in %: the moment around the hit, for StrikeSeconds after the weapon's hit lands.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), 33); s_strikeSecs[i] = Adm(c, section, "StrikeSeconds", 0.15f, "How long the strike part lasts" + suffix + ", in real seconds after the hit lands. After it, the recovery speed takes over.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 32); s_recovery[i] = Adm(c, section, "RecoverySpeedBonusPercent", 30f, "How much faster the recovery plays" + suffix + ", in %: everything after the strike, until you can act again. 0 = the same speed as a normal swing. Negative = a slower recovery (down to -50).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-50f, 100f), 31); s_stam[i] = Adm(c, section, "StaminaExtraPercent", 25f, "Extra stamina the sprint attack costs" + suffix + ", in % on top of the weapon's normal swing cost.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), 20); s_adr[i] = Adm(c, section, "AdrenalineCost", 15f, "Adrenaline the sprint attack costs" + suffix + ", taken from the adrenaline bar at the start of the swing (hit or miss), on top of the stamina. If the bar holds less than this, the swing is a normal attack. 0 = no adrenaline needed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), 15); s_dmg[i] = Adm(c, section, "DamageBonusPercent", 0f, "Extra damage of the sprint attack's hit" + suffix + ", in %. Default 0 = no extra damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), 10); } public static Values Get(bool shield) { int num = (shield ? 1 : 0); return new Values { StepDistance = s_dist[num].Value, StepSeconds = s_secs[num].Value, WindupStartFactor = 1f + s_windupStart[num].Value / 100f, WindupShape = s_ramp[num].Value, HoldSeconds = s_hold[num].Value, WindupFactor = 1f + s_windup[num].Value / 100f, StrikeFactor = 1f + s_strike[num].Value / 100f, StrikeSeconds = s_strikeSecs[num].Value, RecoveryFactor = 1f + s_recovery[num].Value / 100f, StepUntilHit = (s_stepTiming[num].Value == "Tied to the windup"), AdrenalineCost = s_adr[num].Value, StaminaFactor = 1f + s_stam[num].Value / 100f, DamageFactor = 1f + s_dmg[num].Value / 100f }; } public static int Hit(string cat, bool shield) { if ((shield ? s_hitShield : s_hit).TryGetValue(cat, out var value)) { return value.Value; } return 0; } } internal static class DebugView { private class Line { public LineRenderer R; public float Until; } private static readonly List<Line> s_lines = new List<Line>(); private static Material s_mat; private static bool s_matFailed; private static GameObject s_root; private static bool Ready() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown if (s_matFailed) { return false; } if ((Object)(object)s_root == (Object)null) { s_root = new GameObject("CombatEvolved_DebugView"); Object.DontDestroyOnLoad((Object)(object)s_root); } if ((Object)(object)s_mat == (Object)null) { Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Hidden/Internal-Colored") ?? Shader.Find("Unlit/Color"); if ((Object)(object)val == (Object)null) { s_matFailed = true; Plugin.Log.LogWarning((object)"Debug view: no usable line shader found, the display is switched off."); return false; } s_mat = new Material(val); s_mat.renderQueue = 4000; } return true; } private static void Add(IList<Vector3> pts, Color c, float width) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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) //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_0113: Unknown result type (might be due to invalid IL or missing references) Line line = null; for (int i = 0; i < s_lines.Count; i++) { if ((Object)(object)s_lines[i].R != (Object)null && !((Renderer)s_lines[i].R).enabled) { line = s_lines[i]; break; } } if (line == null) { GameObject val = new GameObject("l"); val.transform.SetParent(s_root.transform, false); LineRenderer val2 = val.AddComponent<LineRenderer>(); val2.useWorldSpace = true; ((Renderer)val2).sharedMaterial = s_mat; val2.numCapVertices = 0; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; line = new Line { R = val2 }; s_lines.Add(line); } LineRenderer r = line.R; Color startColor = (line.R.endColor = c); r.startColor = startColor; LineRenderer r2 = line.R; float startWidth = (line.R.endWidth = width); r2.startWidth = startWidth; line.R.positionCount = pts.Count; for (int j = 0; j < pts.Count; j++) { line.R.SetPosition(j, pts[j]); } ((Renderer)line.R).enabled = true; line.Until = Time.time + Cfg.ShowSeconds.Value; } internal static void Draw(Attack a, Vector3 origin, Vector3 dir, bool hit, bool hitCreature) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0151: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_024e: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: 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_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) if (!Ready()) { return; } Color c = (hitCreature ? new Color(0.2f, 1f, 0.2f, 1f) : (hit ? new Color(1f, 0.55f, 0.1f, 1f) : new Color(1f, 0.25f, 0.25f, 1f))); Color c2 = default(Color); ((Color)(ref c2))..ctor(1f, 0.9f, 0.1f, 1f); Color c3 = default(Color); ((Color)(ref c3))..ctor(0.2f, 0.9f, 1f, 1f); Transform transform = ((Component)Swing.Ch(a)).transform; bool vertical = (int)a.m_attackType == 1; int num = Math.Max(4, Math.Min(24, (int)(a.m_attackAngle / 4f))); Vector3[] array = (Vector3[])(object)new Vector3[num + 1]; Geo.Fan(origin, transform.right, transform.up, transform.forward, dir, a.m_attackRange, a.m_attackAngle, vertical, num, array); Add(array, c, 0.03f); Add((IList<Vector3>)(object)new Vector3[2] { origin, array[0] }, c, 0.02f); Add((IList<Vector3>)(object)new Vector3[2] { origin, array[num] }, c, 0.02f); Add((IList<Vector3>)(object)new Vector3[2] { origin, array[num / 2] }, c, 0.02f); if (a.m_attackRayWidthCharExtra > 0f || a.m_attackHeightChar1 != 0f || a.m_attackHeightChar2 != 0f) { float[] array2 = new float[2] { a.m_attackHeightChar1, a.m_attackHeightChar2 }; foreach (float num2 in array2) { Vector3[] pts = (Vector3[])(object)new Vector3[num + 1]; Geo.Fan(origin + transform.up * (num2 / 2f), transform.right, transform.up, transform.forward, dir, a.m_attackRange, a.m_attackAngle, vertical, num, pts); Add(pts, c2, 0.02f); } } Vector3 val = array[num / 2]; Vector3 val2 = Vector3.Cross(dir, Vector3.up); if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = transform.right; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.Cross(val2, dir); Vector3 normalized = ((Vector3)(ref val3)).normalized; float num3 = a.m_attackRayWidth + a.m_attackRayWidthCharExtra; Vector3[] array3 = (Vector3[])(object)new Vector3[25]; for (int j = 0; j <= 24; j++) { float num4 = (float)j * (float)Math.PI * 2f / 24f; array3[j] = val + (val2 * Mathf.Cos(num4) + normalized * Mathf.Sin(num4)) * a.m_attackRayWidth; } Add(array3, c3, 0.02f); if (a.m_attackRayWidthCharExtra > 0f) { Vector3[] array4 = (Vector3[])(object)new Vector3[25]; for (int k = 0; k <= 24; k++) { float num5 = (float)k * (float)Math.PI * 2f / 24f; array4[k] = val + (val2 * Mathf.Cos(num5) + normalized * Mathf.Sin(num5)) * num3; } Add(array4, c2, 0.02f); } if (Cfg.ShowBounds.Value) { DrawBounds(Swing.Ch(a)); } } private static void DrawBounds(Humanoid me) { //IL_003c: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) float value = Cfg.ShowBoundsRange.Value; foreach (Character allCharacter in Character.GetAllCharacters()) { if ((Object)(object)allCharacter == (Object)null || (object)allCharacter == me) { continue; } Vector3 val = ((Component)allCharacter).transform.position - ((Component)me).transform.position; if (((Vector3)(ref val)).sqrMagnitude > value * value) { continue; } Collider[] componentsInChildren = ((Component)allCharacter).GetComponentsInChildren<Collider>(); foreach (Collider val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && val2.enabled && !val2.isTrigger) { Box(val2.bounds, new Color(1f, 1f, 1f, 0.8f)); } } } } private static void Box(Bounds b, Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0024: Unknown result type (might be due to invalid IL or missing references) //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_0036: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) Vector3 min = ((Bounds)(ref b)).min; Vector3 max = ((Bounds)(ref b)).max; Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(min.x, min.y, min.z), new Vector3(max.x, min.y, min.z), new Vector3(max.x, min.y, max.z), new Vector3(min.x, min.y, max.z), new Vector3(min.x, max.y, min.z), new Vector3(max.x, max.y, min.z), new Vector3(max.x, max.y, max.z), new Vector3(min.x, max.y, max.z) }; Add((IList<Vector3>)(object)new Vector3[10] { array[0], array[1], array[2], array[3], array[0], array[4], array[5], array[6], array[7], array[4] }, c, 0.015f); Add((IList<Vector3>)(object)new Vector3[2] { array[1], array[5] }, c, 0.015f); Add((IList<Vector3>)(object)new Vector3[2] { array[2], array[6] }, c, 0.015f); Add((IList<Vector3>)(object)new Vector3[2] { array[3], array[7] }, c, 0.015f); } internal static void Tick() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = Cfg.DebugKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !Console.IsVisible()) { Cfg.ShowVol.Value = !Cfg.ShowVol.Value; if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, "CombatEvolved hit volumes " + (Cfg.ShowVol.Value ? "shown" : "hidden"), 0, (Sprite)null, false); } } if (s_lines.Count == 0) { return; } float time = Time.time; for (int i = 0; i < s_lines.Count; i++) { Line line = s_lines[i]; if ((Object)(object)line.R != (Object)null && ((Renderer)line.R).enabled && (time >= line.Until || !Cfg.ShowVol.Value)) { ((Renderer)line.R).enabled = false; } } } internal static void Clear() { s_lines.Clear(); if ((Object)(object)s_root != (Object)null) { Object.Destroy((Object)(object)s_root); } s_root = null; s_mat = null; } } internal static class Geo { private const float D2R = (float)Math.PI / 180f; public static float Clamp(float v, float lo, float hi) { if (!(v < lo)) { if (!(v > hi)) { return v; } return hi; } return lo; } public static float PitchOf(Vector3 d) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_003f: Unknown result type (might be due to invalid IL or missing references) float num = (float)Math.Sqrt(d.x * d.x + d.y * d.y + d.z * d.z); if (num < 1E-06f) { return 0f; } return (float)Math.Asin(Clamp(d.y / num, -1f, 1f)) / ((float)Math.PI / 180f); } public static float SlopePitch(Vector3 n, Vector3 f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0030: Unknown result type (might be due to invalid IL or missing references) if (n.y < 0.2f) { return 0f; } return (float)Math.Atan2(0f - (n.x * f.x + n.z * f.z), n.y) / ((float)Math.PI / 180f); } public static float PitchTo(float dy, float d) { return (float)Math.Atan2(dy, Math.Max(d, 0.01f)) / ((float)Math.PI / 180f); } public static Vector3 Dir(Vector3 f, float pitchDeg) { //IL_001e: 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_002f: Unknown result type (might be due to invalid IL or missing references) float num = (float)Math.Cos(pitchDeg * ((float)Math.PI / 180f)); float num2 = (float)Math.Sin(pitchDeg * ((float)Math.PI / 180f)); return new Vector3(f.x * num, num2, f.z * num); } public static float Horizontal(Vector3 a) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return (float)Math.Sqrt(a.x * a.x + a.z * a.z); } public static void Fan(Vector3 origin, Vector3 right, Vector3 up, Vector3 fwd, Vector3 dir, float range, float angle, bool vertical, int steps, Vector3[] pts) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) float num = Dot(dir, right); float num2 = Dot(dir, up); float num3 = Dot(dir, fwd); float num4 = angle / 2f; Vector3 val = default(Vector3); for (int i = 0; i <= steps; i++) { float num5 = (0f - num4 + angle * (float)i / (float)steps) * ((float)Math.PI / 180f); float num6 = (float)Math.Cos(num5); float num7 = (float)Math.Sin(num5); float num8 = num; float num9 = num2; float num10 = num3; if (!vertical) { num8 = num * num6 + num3 * num7; num10 = (0f - num) * num7 + num3 * num6; } else { num9 = num2 * num6 - num3 * num7; num10 = num2 * num7 + num3 * num6; } ((Vector3)(ref val))..ctor(right.x * num8 + up.x * num9 + fwd.x * num10, right.y * num8 + up.y * num9 + fwd.y * num10, right.z * num8 + up.z * num9 + fwd.z * num10); pts[i] = new Vector3(origin.x + val.x * range, origin.y + val.y * range, origin.z + val.z * range); } } private static float Dot(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) return a.x * b.x + a.y * b.y + a.z * b.z; } } [HarmonyPatch(typeof(Humanoid), "StartAttack")] internal static class P_StartAttack { internal static void Prefix(Humanoid __instance, bool secondaryAttack) { Sprint.Decide(__instance, secondaryAttack); } internal static void Postfix(Humanoid __instance, bool __result) { Sprint.Pend pending = Sprint.Pending; Sprint.Pending = null; if (pending != null) { if (__result && Sprint.Current != null && Sprint.CurrentAttackOf(__instance) == Sprint.Current) { Sprint.Begin(pending); } else { Sprint.End("attack did not start"); } } } } [HarmonyPatch(typeof(Attack), "Start")] internal static class P_AttackStart { internal static void Prefix(Attack __instance, Humanoid character, ItemData weapon, ref Attack previousAttack, ref float timeSinceLastAttack) { Sprint.Pend pending = Sprint.Pending; if (pending == null || (object)character != pending.Player) { return; } Sprint.Current = __instance; Sprint.Who = pending.Player; if (!pending.Normal && __instance.m_attackChainLevels > 1 && weapon != null && weapon.m_shared.m_attack != null) { int num = pending.Hit - 1; if (num > __instance.m_attackChainLevels - 1) { num = __instance.m_attackChainLevels - 1; } Attack val = weapon.m_shared.m_attack.Clone(); Sprint.SetNextChain(val, num); previousAttack = val; timeSinceLastAttack = 0f; } } internal static void Postfix(Attack __instance, bool __result) { if (!__result && Sprint.Current == __instance) { Sprint.Current = null; Sprint.Who = null; } if (__result && Swing.Local(Swing.Ch(__instance))) { Swing.ApplyVolume(__instance); Swing.ApplyImpact(__instance); } } } [HarmonyPatch(typeof(Attack), "GetAttackStamina")] internal static class P_Stamina { internal static void Postfix(Attack __instance, ref float __result) { if (__result > 0f && __instance == Sprint.Current) { __result *= Sprint.StaminaFactor; } } } [HarmonyPatch(typeof(Attack), "ModifyDamage")] internal static class P_Damage { internal static void Postfix(Attack __instance, HitData hitData) { if (__instance == Sprint.Current && Sprint.DamageFactor != 1f) { ((DamageTypes)(ref hitData.m_damage)).Modify(Sprint.DamageFactor); } } } [HarmonyPatch(typeof(Character), "UpdateWalking")] internal static class P_Step { internal static void Postfix(Character __instance, float dt) { if (Sprint.Stepping) { Sprint.StepTick(__instance, dt); } } } [HarmonyPatch(typeof(CharacterAnimEvent), "Speed")] internal static class P_AnimSpeed { private static readonly FieldInfo F = AccessTools.Field(typeof(CharacterAnimEvent), "m_character"); internal static void Prefix(CharacterAnimEvent __instance, ref float speedScale) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (Sprint.Current != null && !((Object)(Character)F.GetValue(__instance) != (Object)(object)Sprint.Who)) { speedScale *= Sprint.SpeedFactor; } } } [HarmonyPatch(typeof(Attack), "OnAttackTrigger")] internal static class P_Trigger { internal static void Prefix(Attack __instance) { if (__instance == Sprint.Current) { Sprint.OnTrigger(); } } } [HarmonyPatch(typeof(Attack), "OnAttackTrigger")] internal static class P_TriggerSwing { internal static void Prefix(Attack __instance) { Swing.TriggerBegin(__instance); } internal static Exception Finalizer(Attack __instance, Exception __exception) { Swing.TriggerEnd(__instance); return __exception; } } [HarmonyPatch(typeof(Character), "FreezeFrame")] internal static class P_Freeze { internal static bool Prefix(ref float duration) { return Swing.OnFreeze(ref duration); } } [HarmonyPatch(typeof(Character), "Damage")] internal static class P_CharDamage { internal static void Prefix(Character __instance, HitData hit) { Swing.OnDamage(__instance, hit); } } [HarmonyPatch(typeof(Attack), "GetMeleeAttackDir")] internal static class P_Dir { internal static void Postfix(Attack __instance, ref Vector3 attackDir) { Swing.Tilt(__instance, ref attackDir); } } [BepInPlugin("pucko.combatevolved", "CombatEvolved", "0.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "pucko.combatevolved"; public const string NAME = "CombatEvolved"; public const string VERSION = "0.4.0"; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Cfg.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("pucko.combatevolved"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"CombatEvolved 0.4.0 loaded"); } private void Update() { try { Sprint.Tick(); } catch (Exception ex) { Log.LogError((object)("Sprint attack update failed, switching the current swing off: " + ex)); Sprint.End("error"); } try { DebugView.Tick(); } catch (Exception ex2) { Log.LogError((object)("Debug view failed, switching it off: " + ex2.Message)); Cfg.ShowVol.Value = false; } } private void OnDestroy() { Sprint.End("unloaded"); try { DebugView.Clear(); } catch { } if (_harmony != null) { _harmony.UnpatchSelf(); } } } internal static class PoiseCfg { public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> ShowTooltip; public static ConfigEntry<bool> LogHits; public static ConfigEntry<float> Scale; public static ConfigEntry<float> Strength; public static ConfigEntry<float> TypeShare; public static ConfigEntry<float> ArmorFull; public static ConfigEntry<float> WHelmet; public static ConfigEntry<float> WChest; public static ConfigEntry<float> WLegs; public static ConfigEntry<float> PHeavy; public static ConfigEntry<float> PMedium; public static ConfigEntry<float> PLight; public static ConfigEntry<float> PMage; public static ConfigEntry<float> MaxKnock; public static ConfigEntry<float> MaxStagger; public static ConfigEntry<float> MaxBlocked; public static ConfigEntry<float> MaxParried; public static ConfigEntry<float> CeilKnock; public static ConfigEntry<float> CeilStagger; public static ConfigEntry<float> CeilBlocked; public static ConfigEntry<float> CeilParried; public static ConfigEntry<float> StartKnock; public static ConfigEntry<float> StartStagger; public static ConfigEntry<float> StartBlocked; public static ConfigEntry<float> StartParried; public static ConfigEntry<float> ShieldBlockPower; public static ConfigEntry<float> ShieldAdds; public static ConfigEntry<float> WeaponShare; public static ConfigEntry<float> ParryFlat; public static ConfigEntry<float> ParryUnderdog; public static ConfigEntry<float> ShapeKnock; public static ConfigEntry<float> ShapeStagger; public static ConfigEntry<float> ShapeBlocked; public static ConfigEntry<float> ShapeParried; public static ConfigEntry<float> DecayKnock; public static ConfigEntry<float> DecayStagger; public static ConfigEntry<float> DecayBlocked; public static ConfigEntry<float> DecayParried; private static ConfigurationManagerAttributes AdminTag(int order) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true, Order = order }; } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, string d, AcceptableValueBase range, int order) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d, range, new object[1] { AdminTag(order) })); } private static AcceptableValueRange<float> R(float a, float b) { return new AcceptableValueRange<float>(a, b); } public static void Bind(ConfigFile c) { Enabled = Adm(c, "10 - Poise (armor and knockback)", "PoiseEnabled", v: true, "Poise: heavier armor makes you harder to push and stagger. Off: the game's own knockback and stagger, nothing changed.", null, 10); ShowTooltip = c.Bind<bool>("10 - Poise (armor and knockback)", "ShowPoiseInTooltip", true, "Add a 'Poise: X' line to armor tooltips (and a line with what you wear now). Local display only."); LogHits = c.Bind<bool>("10 - Poise (armor and knockback)", "PoiseLogHits", false, "Write a line to the BepInEx log each time poise changes a hit: your poise, which kind of hit, and the factor used. For tuning."); Scale = Adm(c, "10b - Poise score", "ScalePercent", 54f, "Scales every poise score. 100 = the raw score (a full set of Deep North heavy armor is 100, a fully refined heavy set about 130). Lower it to make all gear count for less: at 54 a fully refined heavy set is about 70.", (AcceptableValueBase)(object)R(10f, 200f), 110); Strength = Adm(c, "10b - Poise score", "EffectStrengthPercent", 100f, "Master strength of all four effects. Multiplies the knockback and stagger reduction after the curves: 100 = as tuned, 50 = half the reduction, 0 = no effect, 200 = double (never more than 100% reduction). Handy for testing.", (AcceptableValueBase)(object)R(0f, 300f), 105); TypeShare = Adm(c, "10b - Poise score", "ClassShare", 70f, "How much of a piece's poise comes from its armor class (heavy, medium, light, mage). The rest comes from its armor value, so a refined piece is steadier than a plain one.", (AcceptableValueBase)(object)R(0f, 100f), 100); ArmorFull = Adm(c, "10b - Poise score", "ArmorValueForFull", 50f, "The armor value of one piece that counts as full armor-value poise.", (AcceptableValueBase)(object)R(10f, 200f), 90); WHelmet = Adm(c, "10b - Poise score", "HelmetWeight", 0.25f, "Share of the set's poise that comes from the helmet.", (AcceptableValueBase)(object)R(0f, 1f), 80); WChest = Adm(c, "10b - Poise score", "ChestWeight", 0.4f, "Share from the chest piece.", (AcceptableValueBase)(object)R(0f, 1f), 70); WLegs = Adm(c, "10b - Poise score", "LegsWeight", 0.35f, "Share from the legs.", (AcceptableValueBase)(object)R(0f, 1f), 60); PHeavy = Adm(c, "10c - Poise armor classes", "Heavy", 100f, "Class poise of heavy armor (bronze, iron, wolf, drake, padded, carapace, flametal, deep north heavy).", (AcceptableValueBase)(object)R(0f, 150f), 40); PMedium = Adm(c, "10c - Poise armor classes", "Medium", 50f, "Class poise of medium armor (root, lox, undead berserker, ashlands medium, deep north medium).", (AcceptableValueBase)(object)R(0f, 150f), 30); PLight = Adm(c, "10c - Poise armor classes", "Light", 25f, "Class poise of light armor (leather, troll leather, bear, fenring, rags).", (AcceptableValueBase)(object)R(0f, 150f), 20); PMage = Adm(c, "10c - Poise armor classes", "Mage", 5f, "Class poise of mage armor (cloth).", (AcceptableValueBase)(object)R(0f, 150f), 10); MaxKnock = Adm(c, "10d - Poise effects at poise 100", "UnblockedKnockbackReduction", 70f, "Percent less knockback from a hit you do not block, at poise 100.", (AcceptableValueBase)(object)R(0f, 100f), 50); MaxStagger = Adm(c, "10d - Poise effects at poise 100", "StaggerBuildupReduction", 60f, "Percent less stagger buildup from every hit, at poise 100.", (AcceptableValueBase)(object)R(0f, 100f), 40); MaxBlocked = Adm(c, "10d - Poise effects at poise 100", "BlockedKnockbackReduction", 80f, "Percent less knockback from a hit you block, at poise 100.", (AcceptableValueBase)(object)R(0f, 100f), 30); MaxParried = Adm(c, "10d - Poise effects at poise 100", "ParriedKnockbackReduction", 50f, "Percent less knockback from a hit you parry, at poise 100.", (AcceptableValueBase)(object)R(0f, 100f), 20); CeilKnock = Adm(c, "10d - Poise effects at poise 100", "UnblockedKnockbackCeiling", 90f, "Past the start point this reduction is approached and never reached. Never lower than the effect's own maximum. (Replaces the shared CeilingPercent of 0.3.x.)", (AcceptableValueBase)(object)R(0f, 100f), 14); CeilStagger = Adm(c, "10d - Poise effects at poise 100", "StaggerBuildupCeiling", 90f, "As above, for stagger buildup.", (AcceptableValueBase)(object)R(0f, 100f), 13); CeilBlocked = Adm(c, "10d - Poise effects at poise 100", "BlockedKnockbackCeiling", 90f, "As above, for blocked knockback.", (AcceptableValueBase)(object)R(0f, 100f), 12); CeilParried = Adm(c, "10d - Poise effects at poise 100", "ParriedKnockbackCeiling", 90f, "As above, for parried knockback.", (AcceptableValueBase)(object)R(0f, 100f), 11); ShapeKnock = Adm(c, "10e - Poise curve shape (0 to 100)", "UnblockedKnockbackShape", 0.7f, "1 = straight line, above 1 = most of the effect arrives late, below 1 = early.", (AcceptableValueBase)(object)R(0.3f, 3f), 40); ShapeStagger = Adm(c, "10e - Poise curve shape (0 to 100)", "StaggerBuildupShape", 0.8f, "As above, for stagger buildup.", (AcceptableValueBase)(object)R(0.3f, 3f), 30); ShapeBlocked = Adm(c, "10e - Poise curve shape (0 to 100)", "BlockedKnockbackShape", 0.6f, "As above, for blocked knockback.", (AcceptableValueBase)(object)R(0.3f, 3f), 20); ShapeParried = Adm(c, "10e - Poise curve shape (0 to 100)", "ParriedKnockbackShape", 0.9f, "As above, for parried knockback.", (AcceptableValueBase)(object)R(0.3f, 3f), 10); DecayKnock = Adm(c, "10f - Poise diminishing returns (over 100)", "UnblockedKnockbackSpeed", 50f, "Poise points over 100 it takes to cover about 63% of the way to the ceiling. Larger = slower.", (AcceptableValueBase)(object)R(10f, 300f), 40); DecayStagger = Adm(c, "10f - Poise diminishing returns (over 100)", "StaggerBuildupSpeed", 60f, "As above, for stagger buildup.", (AcceptableValueBase)(object)R(10f, 300f), 30); DecayBlocked = Adm(c, "10f - Poise diminishing returns (over 100)", "BlockedKnockbackSpeed", 30f, "As above, for blocked knockback.", (AcceptableValueBase)(object)R(10f, 300f), 20); DecayParried = Adm(c, "10f - Poise diminishing returns (over 100)", "ParriedKnockbackSpeed", 90f, "As above, for parried knockback.", (AcceptableValueBase)(object)R(10f, 300f), 10); StartKnock = Adm(c, "10g - Poise start of diminishing returns", "UnblockedKnockbackStart", 100f, "The poise where this effect reaches its maximum. Above it the gains slow down toward the ceiling. 100 = as in 0.3.x. Lower = diminishing returns begin earlier.", (AcceptableValueBase)(object)R(30f, 200f), 40); StartStagger = Adm(c, "10g - Poise start of diminishing returns", "StaggerBuildupStart", 100f, "As above, for stagger buildup.", (AcceptableValueBase)(object)R(30f, 200f), 30); StartBlocked = Adm(c, "10g - Poise start of diminishing returns", "BlockedKnockbackStart", 100f, "As above, for blocked knockback.", (AcceptableValueBase)(object)R(30f, 200f), 20); StartParried = Adm(c, "10g - Poise start of diminishing returns", "ParriedKnockbackStart", 100f, "As above, for parried knockback.", (AcceptableValueBase)(object)R(30f, 200f), 10); ShieldBlockPower = Adm(c, "10h - Poise from block power (blocked and parried hits only)", "BlockPowerForFullShield", 140f, "The block power that counts as one full shield. A blocker adds ShieldPoiseAdded * (its block power / this) to your set's poise on blocked and parried hits (and on the stagger a block causes), never on open hits.", (AcceptableValueBase)(object)R(40f, 300f), 50); ShieldAdds = Adm(c, "10h - Poise from block power (blocked and parried hits only)", "ShieldPoiseAdded", 0f, "Poise one full shield adds on blocked and parried hits. 0 = block power adds nothing (as in 0.3.x).", (AcceptableValueBase)(object)R(0f, 100f), 40); WeaponShare = Adm(c, "10h - Poise from block power (blocked and parried hits only)", "WeaponPoiseSharePercent", 50f, "A weapon used to block (a one-hander without a shield, a two-hander) adds this share of what a shield with the same block power would. 0 = only shields add poise.", (AcceptableValueBase)(object)R(0f, 100f), 30); ParryFlat = Adm(c, "10h - Poise from block power (blocked and parried hits only)", "ParryFlatPoise", 0f, "Extra poise on every parry, on top of the above.", (AcceptableValueBase)(object)R(0f, 60f), 20); ParryUnderdog = Adm(c, "10h - Poise from block power (blocked and parried hits only)", "ParryUnderdogPoise", 0f, "Extra poise on a parry that is full at set poise 0 and fades to nothing at poise 100, so light and medium armor gain most from a parry.", (AcceptableValueBase)(object)R(0f, 80f), 10); } public static float ClassValue(PoiseClass c) { return c switch { PoiseClass.Heavy => PHeavy.Value / 100f, PoiseClass.Medium => PMedium.Value / 100f, PoiseClass.Light => PLight.Value / 100f, _ => PMage.Value / 100f, }; } } internal struct ArmorPiece { public string Prefab; public int Slot; public float Move; public float Armor; } internal enum HitKind { Open, Blocked, Parried } internal static class PoiseGame { public static HitData LastHit; public static HitKind LastKind; private static readonly MethodInfo s_blocker = AccessTools.Method(typeof(Humanoid), "GetCurrentBlocker", (Type[])null, (Type[])null); private static readonly MethodInfo s_baseBlock = AccessTools.Method(typeof(ItemData), "GetBaseBlockPower", new Type[1] { typeof(int) }, (Type[])null); public static Humanoid InBlock; public static int InBlockFrame; public static float PieceValue(ArmorPiece p) { PoiseClass c = PoiseMath.ClassOf(p.Prefab, p.Slot, p.Move); return PoiseCfg.Scale.Value / 100f * PoiseMath.PiecePoise(PoiseCfg.ClassValue(c), p.Armor, PoiseCfg.TypeShare.Value / 100f, PoiseCfg.ArmorFull.Value); } public static float SetValue(IList<ArmorPiece> worn) { float helmet = 0f; float chest = 0f; float legs = 0f; foreach (ArmorPiece item in worn) { float num = PieceValue(item); if (item.Slot == 0) { helmet = num; } else if (item.Slot == 1) { chest = num; } else { legs = num; } } return PoiseMath.SetPoise(helmet, chest, legs, PoiseCfg.WHelmet.Value, PoiseCfg.WChest.Value, PoiseCfg.WLegs.Value); } public static float Factor(float poise, HitKind kind) { return PoiseMath.Clamp(1f - kind switch { HitKind.Blocked => PoiseMath.Effect(poise, PoiseCfg.MaxBlocked.Value / 100f, PoiseCfg.CeilBlocked.Value / 100f, PoiseCfg.ShapeBlocked.Value, PoiseCfg.DecayBlocked.Value, PoiseCfg.StartBlocked.Value), HitKind.Parried => PoiseMath.Effect(poise, PoiseCfg.MaxParried.Value / 100f, PoiseCfg.CeilParried.Value / 100f, PoiseCfg.ShapeParried.Value, PoiseCfg.DecayParried.Value, PoiseCfg.StartParried.Value), _ => PoiseMath.Effect(poise, PoiseCfg.MaxKnock.Value / 100f, PoiseCfg.CeilKnock.Value / 100f, PoiseCfg.ShapeKnock.Value, PoiseCfg.DecayKnock.Value, PoiseCfg.StartKnock.Value), } * PoiseCfg.Strength.Value / 100f, 0f, 1f); } public static float StaggerFactor(float poise) { return PoiseMath.Clamp(1f - PoiseMath.Effect(poise, PoiseCfg.MaxStagger.Value / 100f, PoiseCfg.CeilStagger.Value / 100f, PoiseCfg.ShapeStagger.Value, PoiseCfg.DecayStagger.Value, PoiseCfg.StartStagger.Value) * PoiseCfg.Strength.Value / 100f, 0f, 1f); } public static float BlockerAdd(float blockPower, bool isShield) { return PoiseMath.BlockPoise(blockPower, PoiseCfg.ShieldBlockPower.Value, PoiseCfg.ShieldAdds.Value, isShield ? 1f : (PoiseCfg.WeaponShare.Value / 100f)); } public static float PoiseFor(float setPoise, HitKind kind, float blockerAdd) { if (kind == HitKind.Open) { return setPoise; } float num = setPoise + blockerAdd; if (kind == HitKind.Parried) { num += PoiseMath.ParryPoise(setPoise, PoiseCfg.ParryFlat.Value, PoiseCfg.ParryUnderdog.Value); } return num; } public static ArmorPiece Of(ItemData it, float armor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 ItemType itemType = it.m_shared.m_itemType; return new ArmorPiece { Prefab = (((Object)(object)it.m_dropPrefab != (Object)null) ? ((Object)it.m_dropPrefab).name : null), Slot = (((int)itemType != 6) ? (((int)itemType == 7) ? 1 : 2) : 0), Move = it.m_shared.m_movementModifier, Armor = armor }; } public static bool IsArmor(ItemData it) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (it == null || it.m_shared == null) { return false; } ItemType itemType = it.m_shared.m_itemType; if ((int)itemType != 6 && (int)itemType != 7) { return (int)itemType == 11; } return true; } public static float Worn(Player p) { List<ArmorPiece> list = new List<ArmorPiece>(); foreach (ItemData equippedItem in ((Humanoid)p).GetInventory().GetEquippedItems()) { if (IsArmor(equippedItem)) { list.Add(Of(equippedItem, equippedItem.GetArmor())); } } return SetValue(list); } public static bool IsParry(Humanoid h, float blockTimer) { if (blockTimer < 0f || blockTimer >= 0.25f) { return false; } ItemData val = (ItemData)((s_blocker != null) ? /*isinst with value type is only supported in some contexts*/: null); if (val != null) { return val.m_shared.m_timedBlockBonus > 1f; } return false; } public static float BlockerAddOf(Humanoid h) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Invalid comparison between Unknown and I4 if (PoiseCfg.ShieldAdds.Value <= 0f && PoiseCfg.ParryFlat.Value <= 0f && PoiseCfg.ParryUnderdog.Value <= 0f) { return 0f; } ItemData val = (ItemData)((s_blocker != null) ? /*isinst with value type is only supported in some contexts*/: null); if (val == null || val.m_shared == null) { return 0f; } return BlockerAdd((s_baseBlock != null) ? ((float)s_baseBlock.Invoke(val, new object[1] { val.m_quality })) : val.m_shared.m_blockPower, (int)val.m_shared.m_itemType == 5); } public static bool BlockingNow(Humanoid h) { if (h != null && InBlock == h) { return InBlockFrame == Time.frameCount; } return false; } public static HitKind KindFor(HitData hit) { if (hit != LastHit) { return HitKind.Open; } return LastKind; } } internal enum PoiseClass { Heavy, Medium, Light, Mage } internal static class PoiseMath { private static readonly Dictionary<string, KeyValuePair<PoiseClass, int>> s_table = Build(new object[177] { "ArmorLeatherChest", PoiseClass.Light, 1, "ArmorLeatherLegs", PoiseClass.Light, 2, "ArmorRagsChest", PoiseClass.Light, 1, "ArmorRagsLegs", PoiseClass.Light, 2, "HelmetDNHeavy", PoiseClass.Heavy, 0, "HelmetLeather", PoiseClass.Light, 0, "ArmorBerserkerChest", PoiseClass.Light, 1, "ArmorBerserkerLegs", PoiseClass.Light, 2, "ArmorBronzeChest", PoiseClass.Heavy, 1, "ArmorBronzeLegs", PoiseClass.Heavy, 2, "ArmorTrollLeatherChest", PoiseClass.Light, 1, "ArmorTrollLeatherLegs", PoiseClass.Light, 2, "HelmetBronze", PoiseClass.Heavy, 0, "ArmorIronChest", PoiseClass.Heavy, 1, "ArmorIronLegs", PoiseClass.Heavy, 2, "ArmorRootChest", PoiseClass.Medium, 1, "ArmorRootLegs", PoiseClass.Medium, 2, "HelmetIron", PoiseClass.Heavy, 0, "ArmorFenringChest", PoiseClass.Light, 1, "ArmorFenringLegs", PoiseClass.Light, 2, "ArmorWolfChest", PoiseClass.Heavy, 1, "ArmorWolfLegs", PoiseClass.Heavy, 2, "HelmetDrake", PoiseClass.Heavy, 0, "ArmorBerserkerUndeadChest", PoiseClass.Medium, 1, "ArmorBerserkerUndeadLegs", PoiseClass.Medium, 2, "ArmorLoxChest", PoiseClass.Medium, 1, "ArmorLoxLegs", PoiseClass.Medium, 2, "ArmorPaddedCuirass", PoiseClass.Heavy, 1, "ArmorPaddedGreaves", PoiseClass.Heavy, 2, "HelmetPadded", PoiseClass.Heavy, 0, "ArmorCarapaceChest", PoiseClass.Heavy, 1, "ArmorCarapaceLegs", PoiseClass.Heavy, 2, "ArmorMageChest", PoiseClass.Mage, 1, "ArmorMageLegs", PoiseClass.Mage, 2, "HelmetBerserkerHood", PoiseClass.Light, 0, "HelmetBerserkerUndead", PoiseClass.Medium, 0, "HelmetCarapace", PoiseClass.Heavy, 0, "HelmetFenring", PoiseClass.Light, 0, "HelmetLox", PoiseClass.Medium, 0, "HelmetMage", PoiseClass.Mage, 0, "HelmetRoot", PoiseClass.Medium, 0, "HelmetTrollLeather", PoiseClass.Light, 0, "ArmorAshlandsMediumChest", PoiseClass.Medium, 1, "ArmorAshlandsMediumlegs", PoiseClass.Medium, 2, "ArmorFlametalChest", PoiseClass.Heavy, 1, "ArmorFlametalLegs", PoiseClass.Heavy, 2, "ArmorMageChest_Ashlands", PoiseClass.Mage, 1, "ArmorMageLegs_Ashlands", PoiseClass.Mage, 2, "HelmetAshlandsMediumHood", PoiseClass.Medium, 0, "HelmetFlametal", PoiseClass.Heavy, 0, "HelmetMage_Ashlands", PoiseClass.Mage, 0, "ArmorDeepNorthHeavyChest", PoiseClass.Heavy, 1, "ArmorDeepNorthHeavylegs", PoiseClass.Heavy, 2, "ArmorDeepNorthMageChest", PoiseClass.Mage, 1, "ArmorDeepNorthMagelegs", PoiseClass.Mage, 2, "ArmorDeepNorthMediumChest", PoiseClass.Medium, 1, "ArmorDeepNorthMediumlegs", PoiseClass.Medium, 2, "HelmetDNMage", PoiseClass.Mage, 0, "HelmetDNMediumHood", PoiseClass.Medium, 0 }); public static int KnownPieces => s_table.Count; private static Dictionary<string, KeyValuePair<PoiseClass, int>> Build(object[] flat) { Dictionary<string, KeyValuePair<PoiseClass, int>> dictionary = new Dictionary<string, KeyValuePair<PoiseClass, int>>(StringComparer.OrdinalIgnoreCase); for (int i = 0; i < flat.Length; i += 3) { dictionary[(string)flat[i]] = new KeyValuePair<PoiseClass, int>((PoiseClass)flat[i + 1], (int)flat[i + 2]); } return dictionary; } public static PoiseClass ClassOf(string prefab, int slot, float movementModifier) { if (prefab != null && s_table.TryGetValue(prefab, out var value)) { return value.Key; } if (slot == 0) { return PoiseClass.Medium; } if (movementModifier <= -0.04f) { return PoiseClass.Heavy; } if (movementModifier < 0f) { return PoiseClass.Medium; } return PoiseClass.Light; } public static float PiecePoise(float classPoise, float armor, float typeShare, float armorFull) { float num = Clamp(typeShare, 0f, 1f); float num2 = Math.Max(1f, armorFull); return 100f * (num * classPoise + (1f - num) * Math.Max(0f, armor) / num2); } public static float SetPoise(float helmet, float chest, float legs, float wH, float wC, float wL) { return wH * helmet + wC * chest + wL * legs; } public static float Effect(float poise, float max, float ceiling, float shape, float decay, float knee = 100f) { float num = Math.Max(0f, poise); float num2 = Math.Max(max, ceiling); float num3 = Math.Max(1f, knee); if (num <= num3) { return max * (float)Math.Pow(num / num3, Math.Max(0.05f, shape)); } return max + (num2 - max) * (1f - (float)Math.Exp((0f - (num - num3)) / Math.Max(1f, decay))); } public static float BlockPoise(float blockPower, float blockPowerForFull, float addForFull, float weight) { return Math.Max(0f, addForFull) * Math.Max(0f, weight) * Math.Max(0f, blockPower) / Math.Max(1f, blockPowerForFull); } public static float ParryPoise(float setPoise, float flat, float underdog) { return Math.Max(0f, flat) + Math.Max(0f, underdog) * (1f - Clamp(setPoise / 100f, 0f, 1f)); } public static float Clamp(float v, float lo, float hi) { if (!(v < lo)) { if (!(v > hi)) { return v; } return hi; } return lo; } } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] internal static class PoiseP_Block { private static void Prefix(Humanoid __instance, HitData hit) { if (hit == PoiseGame.LastHit) { PoiseGame.LastHit = null; } PoiseGame.InBlock = __instance; PoiseGame.InBlockFrame = Time.frameCount; } private static void Postfix(Humanoid __instance, HitData hit, bool __result, float ___m_blockTimer) { PoiseGame.InBlock = null; if (__instance is Player) { PoiseGame.LastHit = hit; PoiseGame.LastKind = (__result ? ((!PoiseGame.IsParry(__instance, ___m_blockTimer)) ? HitKind.Blocked : HitKind.Parried) : HitKind.Open); } } } [HarmonyPatch(typeof(Character), "ApplyPushback", new Type[] { typeof(HitData) })] internal static class PoiseP_Push { private static void Prefix(Character __instance, HitData hit) { if (!PoiseCfg.Enabled.Value || hit == null) { return; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!((Object)(object)val == (Object)null)) { float num = PoiseGame.Worn(val); HitKind hitKind = PoiseGame.KindFor(hit); float num2 = ((hitKind == HitKind.Open) ? num : PoiseGame.PoiseFor(num, hitKind, PoiseGame.BlockerAddOf((Humanoid)(object)val))); float num3 = PoiseGame.Factor(num2, hitKind); if (PoiseCfg.LogHits.Value) { Plugin.Log.LogInfo((object)("poise " + num.ToString("0.0") + ((num2 != num) ? (" (+" + (num2 - num).ToString("0.0") + " from the blocker)") : "") + ", " + hitKind.ToString() + " hit, knockback x" + num3.ToString("0.00"))); } hit.m_pushForce *= num3; } } } [HarmonyPatch(typeof(Character), "AddStaggerDamage")] internal static class PoiseP_Stagger { private static void Prefix(Character __instance, ref float damage) { if (!PoiseCfg.Enabled.Value) { return; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if (!((Object)(object)val == (Object)null)) { float num = PoiseGame.Worn(val); if (PoiseGame.BlockingNow((Humanoid)(object)val)) { num += PoiseGame.BlockerAddOf((Humanoid)(object)val); } float num2 = PoiseGame.StaggerFactor(num); if (PoiseCfg.LogHits.Value) { Plugin.Log.LogInfo((object)("poise " + num.ToString("0.0") + ", stagger buildup x" + num2.ToString("0.00"))); } damage *= num2; } } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int), typeof(bool) })] internal static class PoiseP_Tooltip { private static void Postfix(ItemData item, int qualityLevel, float worldLevel, ref string __result) { if (PoiseCfg.Enabled.Value && PoiseCfg.ShowTooltip.Value && PoiseGame.IsArmor(item)) { float num = PoiseGame.PieceValue(PoiseGame.Of(item, item.GetArmor(qualityLevel, worldLevel))); __result = __result + "\nPoise: " + Mathf.RoundToInt(num); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { __result = __result + "\nWorn set poise: " + Mathf.RoundToInt(PoiseGame.Worn(localPlayer)); } } } } internal static class Sprint { internal sealed class Pend { public Player Player; public string Category; public bool Shield; public int Hit; public Values V; public bool Normal; } internal static Pend Pending; internal static Attack Current; internal static Player Who; private static Pend s_run; private static bool s_stepping; private static float s_stepT; private static float s_began; private static float s_stepSeconds; private static float s_v0; private static float s_speedFactor; private static bool s_struck; private static bool s_recovering; private static float s_trigT; private static float s_stepMax; private static readonly Dictionary<string, float> s_windupSeen = new Dictionary<string, float>(); private static Vector3 s_startPos; private static float s_animT; private static float s_holdUntil; private static bool s_holding; private static bool s_held; private static readonly Dictionary<string, float> s_animHitSeen = new Dictionary<string, float>(); internal const float HoldLead = 0.03f; private static readonly FieldInfo F_body = AccessTools.Field(typeof(Character), "m_body"); private static readonly FieldInfo F_currentVel = AccessTools.Field(typeof(Character), "m_currentVel"); private static readonly FieldInfo F_groundNormal = AccessTools.Field(typeof(Character), "m_lastGroundNormal"); private static readonly FieldInfo F_run = AccessTools.Field(typeof(Character), "m_run"); private static readonly FieldInfo F_zanim = AccessTools.Field(typeof(Character), "m_zanim"); private static readonly FieldInfo F_animator = AccessTools.Field(typeof(Character), "m_animator"); private static readonly FieldInfo F_leftItem = AccessTools.Field(typeof(Humanoid), "m_leftItem"); private static readonly FieldInfo F_currentAttack = AccessTools.Field(typeof(Humanoid), "m_currentAttack"); private static readonly FieldInfo F_nextChain = AccessTools.Field(typeof(Attack), "m_nextAttackChainLevel"); internal static float SpeedFactor => s_speedFactor; internal static float StaminaFactor { get { if (s_run == null) { return 1f; } return s_run.V.StaminaFactor; } } internal static float DamageFactor { get { if (s_run == null) { return 1f; } return s_run.V.DamageFactor; } } internal static float AdrenalineFloor { get { if (s_run == null) { return 0f; } return s_run.V.AdrenalineCost; } } internal static bool Stepping => s_stepping; internal static Attack CurrentAttackOf(Humanoid h) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (Attack)F_currentAttack.GetValue(h); } internal static void SetNextChain(Attack a, int level) { F_nextChain.SetValue(a, level); } internal static string CategoryOf(ItemData w) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 if (w == null || w.m_shared == null || w.m_shared.m_attack == null) { return null; } SharedData shared = w.m_shared; Attack attack = shared.m_attack; if ((int)attack.m_attackType == 2 || (int)attack.m_attackType == 5 || (int)attack.m_attackType == 3) { return null; } if (attack.m_requiresReload) { return null; } string text = ((object)Unsafe.As<ItemType, ItemType>(ref shared.m_itemType)/*cast due to .constrained prefix*/).ToString(); if (text != "OneHandedWeapon" && text != "TwoHandedWeapon" && text != "TwoHandedWeaponLeft") { return null; } string text2 = attack.m_attackAnimation ?? ""; if (text2.IndexOf("dualaxes", StringComparison.OrdinalIgnoreCase) >= 0) { return "DualAxes"; } if (text2.IndexOf("dual_knives", StringComparison.OrdinalIgnoreCase) >= 0) { return "DualKnives"; } bool flag = text.StartsWith("TwoHanded"); switch (((object)Unsafe.As<SkillType, SkillType>(ref shared.m_skillType)/*cast due to .constrained prefix*/).ToString()) { case "Swords": if (!flag) { return "Sword"; } return "Greatsword"; case "Axes": if (!flag) { return "Axe"; } return "Battleaxe"; case "Clubs": if (!flag) { return "Club"; } return "Sledge"; case "Knives": return "Knife"; case "Spears": return "Spear"; case "Polearms": return "Atgeir"; case "Unarmed": return "Fists"; case "Pickaxes": return "Pickaxe"; default: return null; } } internal static bool HasShield(Humanoid h) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 object? value = F_leftItem.GetValue(h); ItemData val = (ItemData)((value is ItemData) ? value : null); if (val != null && val.m_shared != null) { return (int)val.m_shared.m_itemType == 5; } return false; } internal static void Decide(Humanoid h, bool secondary) { Pending = null; Player val = (Player)(object)((h is Player) ? h : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return; } string text = CategoryOf(((Humanoid)val).GetCurrentWeapon()); if (text != null) { if (!secondary && Cfg.Enabled.Value) { Pending = TrySprint(val, text); } if (Pending == null && Cfg.NormalSpeedsOn() && !((Character)val).IsStaggering()) { Pending = new Pend { Player = val, Category = text, Shield = HasShield((Humanoid)(object)val), Hit = 0, V = Cfg.NormalValues(), Normal = true }; } } } private static Pend TrySprint(Player p, string cat) { //IL_0052: 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) if (((Character)p).InAttack()) { return null; } if (!((Character)p).IsOnGround() || ((Character)p).IsSwimming() || ((Character)p).IsAttached() || ((Character)p).IsCrouching() || ((Character)p).IsStaggering()) { return null; } if (((Character)p).IsRunning() || (bool)F_run.GetValue(p)) { Vector3 moveDir = ((Character)p).GetMoveDir(); if (!(((Vector3)(ref moveDir)).sqrMagnitude < 0.01f)) { bool shield = HasShield((Humanoid)(object)p); int num = Cfg.Hit(cat, shield); if (num <= 0) { return null; } Values v = Cfg.Get(shield); if (v.AdrenalineCost > 0f && p.GetAdrenaline() < v.AdrenalineCost) { return null; } return new Pend { Player = p, Category = cat, Shield = shield, Hit = num, V = v }; } } return null; } internal static void Begin(Pend pd) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) s_run = pd; Who = pd.Player; s_began = Time.time; s_stepT = 0f; s_stepSeconds = Mathf.Max(0.05f, pd.V.StepSeconds); s_stepMax = s_stepSeconds; if (pd.V.StepUntilHit) { if (s_windupSeen.TryGetValue(Key(pd), out var value)) { s_stepSeconds = Mathf.Clamp(value, 0.1f, 1.5f); } s_stepMax = s_stepSeconds * 1.5f; } s_v0 = pd.V.StepDistance / (0.75f * s_stepSeconds); s_stepping = pd.V.StepDistance > 0.001f; s_startPos = ((Component)pd.Player).transform.position; s_struck = false; s_recovering = false; s_animT = 0f; s_holding = false; s_held = false; s_speedFactor = WindupAt(pd.V, 0f); if (pd.V.AdrenalineCost > 0f) { ((Character)pd.Player).AddAdrenaline(0f - pd.V.AdrenalineCost); } SetAnimSpeed((Character)(object)pd.Player, s_speedFactor); if (Cfg.LogDetails.Value && !pd.Normal) { Plugin.Log.LogInfo((object)("Sprint attack: " + pd.Category + (pd.Shield ? " + shield" : "") + ", combo hit " + pd.Hit + ", step " + pd.V.StepDistance.ToString("0.0") + " m over " + s_stepSeconds.ToString("0.00") + " s, swing x" + s_speedFactor.ToString("0.00"))); } } internal static float RampSpeed(float startFactor, float endFactor, float shape, float u) { float num = Mathf.Max(0.1f, endFactor); float num2 = ((startFactor > 0f) ? Mathf.Max(0.1f, startFactor) : num); float num3 = ((shape > 0f) ? shape : 1f); return Mathf.Lerp(num2, num, Mathf.Pow(Mathf.Clamp01(u), num3)); } internal static float WindupAt(Values v, float u) { return RampSpeed(v.WindupStartFactor, v.WindupFactor, v.WindupShape, u); } internal static float WindupRealSeconds(float hitAnimSeconds, float startFactor, float endFactor, float shape) { float num = 0f; for (int i = 0; i < 200; i++) { num += 1f / RampSpeed(startFactor, endFactor, shape, ((float)i + 0.5f) / 200f); } return hitAnimSeconds * num / 200f; } internal static float SeedHit(string cat) { if (!(cat == "Sledge") && !(cat == "Pickaxe")) { return 0.6f; } return 1.3f; } internal static void OnTrigger() { OnTriggerAt(Time.time, log: true); } internal static void OnTriggerAt(float now, bool log) { if (s_run != null && !s_struck) { s_struck = true; s_holding = false; s_trigT = now; LearnAnim(s_animT); s_speedFactor = Mathf.Max(0.1f, s_run.V.StrikeFactor); if (Who != null) { SetAnimSpeed((Character)(object)Who, s_speedFactor); } if (s_run.V.StepUntilHit) { s_stepping = false; } LearnWindup(now - s_began); if (log) { LogTrigger(); } if (s_run.V.StrikeSeconds <= 0.0001f) { ToRecovery(); } } } private static string Key(Pend pd) { return pd.Category + (pd.Shield ? "+S" : ""); } private static void LearnAnim(float t) { if (s_run != null && !s_run.Normal && !(t < 0.05f) && !(t > 3f)) { string key = Key(s_run); s_animHitSeen[key] = (s_animHitSeen.TryGetValue(key, out var value) ? (0.5f * (value + t)) : t); } } internal static void WindupTick(Player p, float dt) { if (s_run == null || s_struck || s_recovering) { return; } float value; bool flag = s_animHitSeen.TryGetValue(Key(s_run), out value); if (!flag) { value = SeedHit(s_run.Category); } s_animT += dt * Mathf.Max(0f, s_speedFactor); if (s_holding) { if (Time.time < s_holdUntil) { return; } s_holding = false; s_held = true; } float num = (s_run.Normal ? 0f : Mathf.Clamp(s_run.V.HoldSeconds, 0f, 0.6f)); if (num > 0.001f && flag && !s_held && s_animT >= value - 0.03f) { s_holding = true; s_holdUntil = Time.time + num; s_speedFactor = 0f; SetAnimSpeed((Character)(object)p, 0f); return; } float num2 = WindupAt(s_run.V, (value > 0.01f) ? (s_animT / value) : 1f); if (Mathf.Abs(num2 - s_speedFactor) > 0.01f) { s_speedFactor = num2; SetAnimSpeed((Character)(object)p, num2); } } private static void LearnWindup(float t) { if (s_run != null && !s_run.Normal && !(t < 0.05f) && !(t > 3f)) { string key = Key(s_run); s_windupSeen[key] = (s_windupSeen.TryGetValue(key, out var value) ? (0.5f * (value + t)) : t); } } internal static void ToRecovery() { if (s_run != null && !s_recovering) { s_recovering = true; s_speedFactor = Mathf.Max(0.1f, s_run.V.RecoveryFactor); if (Who != null) { SetAnimSpeed((Character)(object)Who, s_speedFactor); } } } internal static bool UpdatePhase(float sinceTrigger) { if (s_run != null && s_struck && !s_recovering && sinceTrigger >= s_run.V.StrikeSeconds) { ToRecovery(); } return s_recovering; } private static void LogTrigger() { if (Cfg.LogDetails != null && Cfg.LogDetails.Value && Plugin.Log != null && (s_run == null || !s_run.Normal)) { Plugin.Log.LogInfo((object)("Sprint attack: hit trigger after " + (Time.time - s_began).ToString("0.00") + " s")); } } private static void SetAnimSpeed(Character c, float f) { object? value = F_zanim.GetValue(c); ZSyncAnimation val = (ZSyncAnimation)((value is ZSyncAnimation) ? value : null); if ((Object)(object)val != (Object)null) { val.SetSpeed(f); } } internal static void Tick() { if (Current == null) { return; } Player who = Who; if ((Object)(object)who == (Object)null || (Object)(object)who != (Object)(object)Player.m_localPlayer || ((Character)who).IsDead()) { End("player gone"); return; } if (Current.IsDone()) { End("swing done"); return; } if (CurrentAttackOf((Humanoid)(object)who) != Current) { End("replaced"); return; } if (Time.time - s_began > 0.8f && !((Character)who).InAttack()) { End("not in attack"); return; } if (((Character)who).IsStaggering()) { End("staggered"); return; } UpdatePhase(Time.time - s_trigT); WindupTick(who, Time.deltaTime); object? value = F_animator.GetValue(who); Animator val = (Animator)((value is Animator) ? value : null); if ((Object)(object)val != (Object)null && Mathf.Abs(val.speed - 1f) < 0.001f) { SetAnimSpeed((Character)(object)who, s_speedFactor); } } internal static void StepTick(Character c, float dt) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (!s_stepping || (Object)(object)c != (Object)(object)Who) { return; } s_stepT += dt; if (s_stepT >= s_stepMax || !c.IsOnGround() || c.IsStaggering() || c.IsKnockedBack()) { s_stepping = false; return; } float num = s_v0 * (1f - 0.5f * Mathf.Min(1f, s_stepT / s_stepSeconds)); Vector3 forward = ((Component)c).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); Vector3 val = forward * num; Vector3 val2 = (Vector3)F_groundNormal.GetValue(c); if (((Vector3)(ref val2)).sqrMagnitude > 0.1f) { Vector3 val3 = Vector3.ProjectOnPlane(val, val2); if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { val = ((Vector3)(ref val3)).normalized * num; } } ((Rigidbody)F_body.GetValue(c)).linearVelocity = val; F_currentVel.SetValue(c, (object)new Vector3(val.x, 0f, val.z)); } internal static void End(string why) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (Current == null && s_run == null) { return; } Player who = Who; if ((Object)(object)who != (Object)null) { try { SetAnimSpeed((Character)(object)who, 1f); } catch (Exception) { } } if (Cfg.LogDetails != null && Cfg.LogDetails.Value && s_run != null && !s_run.Normal && (Object)(object)who != (Object)null) { float num = Vector3.Distance(((Component)who).transform.position, s_startPos); Plugin.Log.LogInfo((object)("Sprint attack ended (" + why + "): moved " + num.ToString("0.0") + " m in " + (Time.time - s_began).ToString("0.00") + " s")); } Current = null; Pending = null; Who = null; s_run = null; s_stepping = false; s_struck = false; s_recovering = false; s_holding = false; s_held = false; } } internal static class Swing { private static readonly FieldInfo F_groundNormal = AccessTools.Field(typeof(Character), "m_lastGroundNormal"); internal static bool InTrigger; internal static bool Hit; internal static bool HitChar; internal static bool LikelyKill; internal static bool Own
plugins/EinsteinCrew-PuckosCarePackage/Pucko-CreatureComforts/CreatureComforts.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Pucko.CreatureComforts; internal static class Heat { private sealed class Entry { public float Next; public bool Warm; } private static readonly Dictionary<int, Entry> _cache = new Dictionary<int, Entry>(); private static readonly FieldInfo _fAll = AccessTools.Field(typeof(EffectArea), "s_allAreas"); public static void Reset() { _cache.Clear(); } public static bool AtNow(Component c) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null) { return false; } return (Object)(object)EffectArea.IsPointInsideArea(c.transform.position, (Type)1, Math.Max(0f, Plugin.HeatRadius.Value)) != (Object)null; } public static bool At(Component c) { if ((Object)(object)c == (Object)null || !Plugin.WarmEnabled.Value) { return false; } int instanceID = ((Object)c).GetInstanceID(); float time = Time.time; if (!_cache.TryGetValue(instanceID, out var value)) { if (_cache.Count > 4096) { _cache.Clear(); } value = new Entry(); value.Next = time + (float)(instanceID & 0xF) * 0.1f; _cache[instanceID] = value; value.Warm = AtNow(c); value.Next = time + Math.Max(1f, Plugin.HeatCheckInterval.Value); return value.Warm; } if (time >= value.Next) { value.Warm = AtNow(c); value.Next = time + Math.Max(1f, Plugin.HeatCheckInterval.Value); } return value.Warm; } public static bool Nearest(Vector3 pos, float radius, out Vector3 where) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) where = Vector3.zero; List<EffectArea> list = ((!(_fAll == null)) ? (_fAll.GetValue(null) as List<EffectArea>) : null); if (list == null) { return false; } float num = radius * radius; bool result = false; for (int i = 0; i < list.Count; i++) { EffectArea val = list[i]; if (!((Object)(object)val == (Object)null) && (byte)(val.m_type & 1) != 0) { Vector3 val2 = ((Component)val).transform.position - pos; val2.y = 0f; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude <= num) { num = sqrMagnitude; where = ((Component)val).transform.position; result = true; } } } return result; } } internal static class ClimbLimit { private sealed class Entry { public float Angle; public float Next; } private static readonly Dictionary<int, Entry> _cache = new Dictionary<int, Entry>(); private static readonly HashSet<string> _logged = new HashSet<string>(); public static void Reset() { _cache.Clear(); _logged.Clear(); } public static float AngleFor(Character c) { int instanceID = ((Object)c).GetInstanceID(); float time = Time.time; if (_cache.TryGetValue(instanceID, out var value) && time < value.Next) { return value.Angle; } if (value == null) { if (_cache.Count > 4096) { _cache.Clear(); } value = new Entry(); _cache[instanceID] = value; } value.Angle = Compute(c); value.Next = time + 2f + (float)(instanceID & 7) * 0.1f; return value.Angle; } private static float Compute(Character c) { try { if (c.IsPlayer() || c.IsBoss()) { return 90f; } bool flag = c.IsTamed(); if ((!flag) ? (!Plugin.ClimbWild.Value) : (!Plugin.ClimbTamed.Value)) { return 90f; } float num = ((!flag) ? Plugin.ClimbWildAngle.Value : Plugin.ClimbTamedAngle.Value); string name = ((Object)((Component)c).gameObject).name; string[] array = Core.Tokens(((!flag) ? Plugin.ClimbWildSteep : Plugin.ClimbTamedSteep).Value); foreach (string text in array) { int num2 = text.LastIndexOf(':'); if (num2 > 0 && name.IndexOf(text.Substring(0, num2).Trim(), StringComparison.OrdinalIgnoreCase) >= 0) { if (float.TryParse(text.Substring(num2 + 1).Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { num = result; } break; } } num = Mathf.Clamp(num, 20f, 90f); if (Plugin.LogDetails.Value && _logged.Add(Utils.GetPrefabName(((Component)c).gameObject) + "|" + flag + "|" + num)) { Plugin.Log.LogInfo((object)("ClimbLimit: " + Utils.GetPrefabName(((Component)c).gameObject) + ((!flag) ? " (wild)" : " (tame)") + " slides above " + num + " degrees; logged once per combination")); } return num; } catch (Exception ex) { Plugin.Log.LogError((object)("ClimbLimit: " + ex)); return 90f; } } } [HarmonyPatch(typeof(Character), "GetSlideAngle")] internal static class SlideAngle_Patch { [HarmonyPostfix] private static void Postfix(Character __instance, ref float __result) { if (!(__result < 89.9f) && (Plugin.ClimbTamed.Value || Plugin.ClimbWild.Value)) { __result = ClimbLimit.AngleFor(__instance); } } } [HarmonyPatch(typeof(BaseAI), "Awake")] internal static class HareJump_Patch { private static readonly FieldInfo _fInterval = AccessTools.Field(typeof(BaseAI), "m_jumpInterval"); private static readonly HashSet<string> _logged = new HashSet<string>(); [HarmonyPostfix] private static void Postfix(BaseAI __instance) { try { if (Plugin.HareJump.Value && Core.Is((Component)(object)__instance, Plugin.HareSpecies)) { Character component = ((Component)__instance).GetComponent<Character>(); if (_fInterval != null) { _fInterval.SetValue(__instance, Plugin.HareJumpInterval.Value); } if ((Object)(object)component != (Object)null && component.m_jumpForce < Plugin.HareJumpForce.Value) { component.m_jumpForce = Plugin.HareJumpForce.Value; } if (Plugin.LogDetails.Value && _logged.Add(((Object)((Component)__instance).gameObject).name)) { Plugin.Log.LogInfo((object)("HareJump: " + Utils.GetPrefabName(((Component)__instance).gameObject) + " now hops every " + Plugin.HareJumpInterval.Value + " s, jump force " + ((!((Object)(object)component == (Object)null)) ? component.m_jumpForce : (-1f)))); } } } catch (Exception ex) { Plugin.Log.LogError((object)("HareJump: " + ex)); } } } internal static class EggStack { [ThreadStatic] internal static ItemData Incoming; internal static bool On => Plugin.HenEnabled == null || Plugin.HenEnabled.Value; internal static int Sig(ItemData it) { if (it == null || it.m_customData == null || it.m_customData.Count == 0) { return 0; } int num = 0; if (it.m_customData.ContainsKey("henhouse.infertile")) { num |= 1; } if (it.m_customData.ContainsKey("henhouse.straw")) { num |= 2; } if (it.m_customData.ContainsKey("creaturecomforts.warm")) { num |= 4; } return num; } } [HarmonyPatch(typeof(ItemData), "IsSameType")] internal static class EggSameType_Patch { [HarmonyPostfix] private static void Postfix(ItemData __instance, ItemData other, ref bool __result) { if (__result && EggStack.On && EggStack.Sig(__instance) != EggStack.Sig(other)) { __result = false; } } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })] internal static class EggAdd1_Patch { [HarmonyPrefix] private static void Prefix(ItemData item, out ItemData __state) { __state = EggStack.Incoming; EggStack.Incoming = item; } [HarmonyFinalizer] private static Exception Finalizer(ItemData __state, Exception __exception) { EggStack.Incoming = __state; return __exception; } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData), typeof(Vector2i) })] internal static class EggAdd2_Patch { [HarmonyPrefix] private static void Prefix(ItemData item, out ItemData __state) { __state = EggStack.Incoming; EggStack.Incoming = item; } [HarmonyFinalizer] private static Exception Finalizer(ItemData __state, Exception __exception) { EggStack.Incoming = __state; return __exception; } } [HarmonyPatch(typeof(Inventory), "FindFreeStackItem")] internal static class EggFindStack_Patch { private static readonly FieldInfo _inv = AccessTools.Field(typeof(Inventory), "m_inventory"); [HarmonyPostfix] private static void Postfix(Inventory __instance, string name, int quality, float worldLevel, ref ItemData __result) { ItemData incoming = EggStack.Incoming; if (__result == null || incoming == null || !EggStack.On) { return; } int num = EggStack.Sig(incoming); if (EggStack.Sig(__result) == num) { return; } ItemData val = null; List<ItemData> list = ((!(_inv == null)) ? (_inv.GetValue(__instance) as List<ItemData>) : null); if (list != null) { foreach (ItemData item in list) { if (item.m_shared.m_name == name && item.m_quality == quality && item.m_stack < item.m_shared.m_maxStackSize && (float)item.m_worldLevel == worldLevel && EggStack.Sig(item) == num) { val = item; break; } } } __result = val; } } [HarmonyPatch(typeof(ItemDrop), "AutoStackItems")] internal static class EggAutoStack_Patch { [HarmonyPrefix] private static bool Prefix(ItemDrop __instance) { return !EggStack.On || !Hens.IsEgg(__instance); } } internal static class Hens { private sealed class SteerState { public Procreation Proc; public Character Ch; public bool IsLayer; public bool IsWarm; public float Next; public bool Steer; public Vector3 Target; public float NextWarmSearch; public bool HaveWarmTarget; public Vector3 WarmTarget; } public const string EggPrefab = "ChickenEgg"; public const string KeyInfertile = "henhouse.infertile"; public const string KeyStraw = "henhouse.straw"; public const string KeyWarm = "creaturecomforts.warm"; private static readonly FieldInfo _fInst = AccessTools.Field(typeof(ItemDrop), "s_instances"); private static readonly FieldInfo _fMy = AccessTools.Field(typeof(Procreation), "m_myPrefab"); private static readonly FieldInfo _fEgg = AccessTools.Field(typeof(EggGrow), "m_item"); private static readonly MethodInfo _mSave = AccessTools.Method(typeof(ItemDrop), "Save", (Type[])null, (Type[])null); private static readonly MethodInfo _mPreg = AccessTools.Method(typeof(Procreation), "IsPregnant", (Type[])null, (Type[])null); private static readonly FieldInfo _fNview = AccessTools.Field(typeof(Procreation), "m_nview"); private static readonly Dictionary<int, SteerState> _steer = new Dictionary<int, SteerState>(); private static readonly Dictionary<int, float> _waitStart = new Dictionary<int, float>(); private static readonly Dictionary<int, KeyValuePair<float, int>> _base = new Dictionary<int, KeyValuePair<float, int>>(); private static readonly HashSet<string> _seen = new HashSet<string>(); public static List<ItemDrop> Instances() { return (!(_fInst == null)) ? ((List<ItemDrop>)_fInst.GetValue(null)) : null; } public static GameObject MyPrefab(Procreation p) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (GameObject)_fMy.GetValue(p); } public static ItemDrop EggItem(EggGrow g) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (ItemDrop)_fEgg.GetValue(g); } public static void SaveDrop(ItemDrop d) { _mSave.Invoke(d, null); } public static bool IsEgg(ItemDrop d) { return (Object)(object)d != (Object)null && (Object)(object)((Component)d).GetComponent<EggGrow>() != (Object)null; } private static bool NamedLike(ItemDrop d, string eggName) { return eggName == null || ((Object)((Component)d).gameObject).name.StartsWith(eggName, StringComparison.Ordinal); } public static bool Has(ItemDrop d, string key) { return (Object)(object)d != (Object)null && d.m_itemData != null && d.m_itemData.m_customData != null && d.m_itemData.m_customData.ContainsKey(key); } public static bool Has(ItemData it, string key) { return it != null && it.m_customData != null && it.m_customData.ContainsKey(key); } public static int InfertileNearby(Vector3 pos, float range, string eggName) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) int num = 0; List<ItemDrop> list = Instances(); if (list == null) { return 0; } float num2 = range * range; for (int i = 0; i < list.Count; i++) { ItemDrop val = list[i]; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)val).transform.position - pos; if (!(((Vector3)(ref val2)).sqrMagnitude > num2) && Has(val, "henhouse.infertile") && NamedLike(val, eggName) && IsEgg(val)) { num++; } } } return num; } public static int FertileEggsNearby(Vector3 pos, float range, ItemDrop except, string eggName) { //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_0055: Unknown result type (might be due to invalid IL or missing references) int num = 0; List<ItemDrop> list = Instances(); if (list == null) { return 0; } float num2 = range * range; for (int i = 0; i < list.Count; i++) { ItemDrop val = list[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)except)) { Vector3 val2 = ((Component)val).transform.position - pos; if (!(((Vector3)(ref val2)).sqrMagnitude > num2) && NamedLike(val, eggName) && IsEgg(val) && !Has(val, "henhouse.infertile")) { num++; } } } return num; } public static double? SecondsToDue(Procreation p) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!(bool)_mPreg.Invoke(p, null)) { return null; } ZNetView val = (ZNetView)_fNview.GetValue(p); if ((Object)(object)val == (Object)null || !val.IsValid()) { return null; } long ticks = val.GetZDO().GetLong(ZDOVars.s_pregnant, 0L); double totalSeconds = (ZNet.instance.GetTime() - new DateTime(ticks)).TotalSeconds; return (double)p.m_pregnancyDuration - totalSeconds; } public static void ResetSteer() { _steer.Clear(); _waitStart.Clear(); } private static SteerState StateOf(BaseAI ai) { int instanceID = ((Object)ai).GetInstanceID(); if (_steer.TryGetValue(instanceID, out var value)) { return value; } if (_steer.Count > 4096) { _steer.Clear(); } value = new SteerState(); value.Proc = ((Component)ai).GetComponent<Procreation>(); value.Ch = ((Component)ai).GetComponent<Character>(); value.IsLayer = (Object)(object)value.Proc != (Object)null && Core.IsLayer(value.Proc); value.IsWarm = Core.Is((Component)(object)ai, Plugin.WarmSpecies); value.Next = 0f; _steer[instanceID] = value; return value; } private static bool WarmNow(Component c, SteerState s) { return s.IsWarm && Heat.At(c); } private static bool WarmSpot(SteerState s, Vector3 from, float radius, float now, out Vector3 t) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) if (now >= s.NextWarmSearch) { s.NextWarmSearch = now + Math.Max(1f, Plugin.HeatCheckInterval.Value); s.HaveWarmTarget = Heat.Nearest(from, radius, out s.WarmTarget); } t = s.WarmTarget; return s.HaveWarmTarget; } private static void Refresh(BaseAI ai, SteerState s, float now) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) s.Next = now + 1f + (float)(((Object)ai).GetInstanceID() & 7) * 0.05f; s.Steer = false; Vector3 t; if (s.IsLayer && Plugin.HenSeek.Value) { double? num = SecondsToDue(s.Proc); if (num.HasValue && num.Value <= (double)Plugin.HenSeekLead.Value) { if (!Straw.At((Component)(object)s.Proc) && !WarmNow((Component)(object)s.Proc, s)) { if (Straw.Nearest(((Component)s.Proc).transform.position, Plugin.HenSeekRadius.Value, out t)) { s.Steer = true; s.Target = t; } else if (s.IsWarm && Plugin.WarmEnabled.Value && WarmSpot(s, ((Component)s.Proc).transform.position, Plugin.HenSeekRadius.Value, now, out t)) { s.Steer = true; s.Target = t; } } return; } } if (s.IsWarm && Plugin.WarmEnabled.Value && Plugin.PreferWarmth.Value && (Object)(object)s.Ch != (Object)null && s.Ch.IsTamed() && !Heat.At((Component)(object)ai) && WarmSpot(s, ((Component)ai).transform.position, Plugin.WarmthSearchRadius.Value, now, out t)) { s.Steer = true; s.Target = t; } } public static bool SteerToStraw(BaseAI ai, float dt) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) try { if (!Plugin.HenEnabled.Value) { return true; } SteerState steerState = StateOf(ai); if (!steerState.IsLayer && !steerState.IsWarm) { return true; } float time = Time.time; if (time >= steerState.Next) { Refresh(ai, steerState, time); } if (!steerState.Steer) { return true; } Core.MoveTo(ai, dt, steerState.Target, (!steerState.IsWarm || steerState.IsLayer) ? 0.3f : 1.5f, arg5: false); return false; } catch (Exception ex) { Plugin.Log.LogError((object)("SteerToStraw: " + ex)); return true; } } public static bool HoldForStraw(Procreation p, bool due) { //IL_0087: 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) try { if (!due || !Plugin.HenEnabled.Value || !Plugin.HenSeek.Value || !Core.IsLayer(p)) { return due; } int instanceID = ((Object)p).GetInstanceID(); bool flag = Plugin.WarmEnabled.Value && Core.Is((Component)(object)p, Plugin.WarmSpecies); if (Straw.At((Component)(object)p) || (flag && Heat.At((Component)(object)p)) || (!Straw.Nearest(((Component)p).transform.position, Plugin.HenSeekRadius.Value, out var where) && (!flag || !Heat.Nearest(((Component)p).transform.position, Plugin.HenSeekRadius.Value, out where)))) { _waitStart.Remove(instanceID); return due; } float time = Time.time; if (!_waitStart.TryGetValue(instanceID, out var value)) { value = time; _waitStart[instanceID] = time; } if (time - value >= Plugin.HenSeekMaxWait.Value) { _waitStart.Remove(instanceID); return due; } return false; } catch (Exception ex) { Plugin.Log.LogError((object)("HoldForStraw: " + ex)); return due; } } public static int MaxCreatures(Procreation p) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) int maxCreatures = p.m_maxCreatures; try { if (!Plugin.HenEnabled.Value || Plugin.HenInfertileCap.Value <= 0 || !Core.IsLayer(p)) { return maxCreatures; } float num = (float)Plugin.HenInfertileCap.Value * ((!Straw.At((Component)(object)p)) ? 1f : Plugin.HenCapMult.Value); int num2 = InfertileNearby(((Component)p).transform.position, p.m_totalCheckRange, Core.EggName(p)); return (num2 >= Mathf.RoundToInt(num)) ? maxCreatures : int.MaxValue; } catch (Exception ex) { Plugin.Log.LogError((object)("MaxCreatures: " + ex)); return maxCreatures; } } public static int CountOffspring(GameObject prefab, Vector3 center, float range, bool eventOnly, bool procOnly) { //IL_0001: 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) int num = SpawnSystem.GetNrOfInstances(prefab, center, range, eventOnly, procOnly); try { if (Plugin.HenEnabled.Value && (Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<EggGrow>() != (Object)null) { num = Math.Max(0, num - InfertileNearby(center, range, Utils.GetPrefabName(prefab))); } } catch (Exception ex) { Plugin.Log.LogError((object)("CountOffspring: " + ex)); } return num; } public static GameObject OnLaid(GameObject egg, Procreation p) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) try { if (!Plugin.HenEnabled.Value || (Object)(object)egg == (Object)null || !Core.IsLayer(p)) { return egg; } ItemDrop component = egg.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || component.m_itemData == null) { return egg; } Vector3 position = ((Component)p).transform.position; int nrOfInstances = SpawnSystem.GetNrOfInstances(MyPrefab(p), position, p.m_totalCheckRange, false, false); int num = FertileEggsNearby(position, p.m_totalCheckRange, component, Core.EggName(p)); bool flag = nrOfInstances + num >= p.m_maxCreatures; bool flag2 = Straw.At((Component)(object)p); bool flag3 = Plugin.WarmEnabled.Value && Core.Is((Component)(object)p, Plugin.WarmSpecies) && Heat.AtNow((Component)(object)p); if (component.m_itemData.m_customData == null) { component.m_itemData.m_customData = new Dictionary<string, string>(); } if (flag) { component.m_itemData.m_customData["henhouse.infertile"] = "1"; } if (flag2) { component.m_itemData.m_customData["henhouse.straw"] = "1"; } if (flag3) { component.m_itemData.m_customData["creaturecomforts.warm"] = "1"; } if (flag || flag2 || flag3) { SaveDrop(component); } if (Plugin.LogDetails.Value) { Plugin.Log.LogInfo((object)("Egg laid (" + Core.EggName(p) + "): " + ((!flag) ? "fertile" : "INFERTILE") + ((!flag2) ? "" : ", on straw") + ((!flag3) ? "" : ", warm") + " (layers " + nrOfInstances + " + fertile eggs " + num + " vs cap " + p.m_maxCreatures + ")")); } } catch (Exception ex) { Plugin.Log.LogError((object)("OnLaid: " + ex)); } return egg; } public static void ApplyRate(Procreation p) { try { if (!Core.IsLayer(p)) { return; } int instanceID = ((Object)p).GetInstanceID(); if (!_base.TryGetValue(instanceID, out var value)) { if (_base.Count > 4096) { _base.Clear(); } value = new KeyValuePair<float, int>(p.m_pregnancyDuration, p.m_requiredLovePoints); _base[instanceID] = value; } if (Plugin.LogDetails.Value && _seen.Add(Utils.GetPrefabName(((Component)p).gameObject))) { Plugin.Log.LogInfo((object)("Egg layer settings (" + Utils.GetPrefabName(((Component)p).gameObject) + "): maxCreatures " + p.m_maxCreatures + ", totalCheckRange " + p.m_totalCheckRange + ", partnerCheckRange " + p.m_partnerCheckRange + ", pregnancyChance " + p.m_pregnancyChance + ", pregnancyDuration " + p.m_pregnancyDuration + ", requiredLovePoints " + p.m_requiredLovePoints + ", updateInterval " + p.m_updateInterval)); } float straw = ((!Plugin.HenEnabled.Value || !Straw.At((Component)(object)p)) ? 1f : Math.Max(1f, Plugin.HenRateMult.Value)); float fire = ((!Plugin.HenEnabled.Value || !Plugin.WarmEnabled.Value || !Core.Is((Component)(object)p, Plugin.WarmSpecies) || !Heat.At((Component)(object)p)) ? 1f : Math.Max(1f, Plugin.FireRateMult.Value)); float num = Core.Combine(straw, fire); p.m_pregnancyDuration = value.Key / num; p.m_requiredLovePoints = Math.Max(1, Mathf.RoundToInt((float)value.Value / num)); } catch (Exception ex) { Plugin.Log.LogError((object)("ApplyRate: " + ex)); } } } [HarmonyPatch(typeof(Procreation), "Procreate")] internal static class HenProcreate_Patch { [HarmonyPrefix] private static void Prefix(Procreation __instance) { Hens.ApplyRate(__instance); } [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return Rewrite(instructions.ToList()); } internal static List<CodeInstruction> Rewrite(List<CodeInstruction> l) { //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Expected O, but got Unknown //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown FieldInfo fieldInfo = AccessTools.Field(typeof(Procreation), "m_maxCreatures"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(Procreation), "m_offspringPrefab"); MethodInfo methodInfo = AccessTools.Method(typeof(SpawnSystem), "GetNrOfInstances", new Type[5] { typeof(GameObject), typeof(Vector3), typeof(float), typeof(bool), typeof(bool) }, (Type[])null); List<int> list = new List<int>(); List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); for (int i = 0; i < l.Count; i++) { if (CodeInstructionExtensions.LoadsField(l[i], fieldInfo, false)) { list.Add(i); } if (CodeInstructionExtensions.Calls(l[i], methodInfo)) { list2.Add(i); } MethodInfo methodInfo2 = l[i].operand as MethodInfo; if (methodInfo2 != null && methodInfo2.Name == "Instantiate" && methodInfo2.IsGenericMethod && methodInfo2.GetGenericArguments()[0] == typeof(GameObject) && methodInfo2.GetParameters().Length == 3) { list3.Add(i); } } bool flag = list.Count == 1 && list2.Count == 4 && list3.Count == 1; int num = ((!flag) ? (-1) : list2[2]); if (flag) { flag = false; for (int j = Math.Max(0, num - 12); j < num; j++) { if (CodeInstructionExtensions.LoadsField(l[j], fieldInfo2, false)) { flag = true; } } } if (!flag) { if (Plugin.Log != null) { Plugin.Log.LogError((object)("HenHouse module: Procreation.Procreate does not look as expected (max " + list.Count + ", counts " + list2.Count + ", instantiate " + list3.Count + "); patch skipped, vanilla hens")); } return l; } int index = list[0]; int num2 = list3[0]; l[index].opcode = OpCodes.Call; l[index].operand = AccessTools.Method(typeof(Hens), "MaxCreatures", (Type[])null, (Type[])null); l[num].opcode = OpCodes.Call; l[num].operand = AccessTools.Method(typeof(Hens), "CountOffspring", (Type[])null, (Type[])null); l.Insert(num2 + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); l.Insert(num2 + 2, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Hens), "OnLaid", (Type[])null, (Type[])null))); return l; } } [HarmonyPatch(typeof(BaseAI), "IdleMovement")] internal static class HenIdle_Patch { [HarmonyPrefix] private static bool Prefix(BaseAI __instance, float dt) { return Hens.SteerToStraw(__instance, dt); } } [HarmonyPatch(typeof(Procreation), "IsDue")] internal static class HenIsDue_Patch { [HarmonyPostfix] private static void Postfix(Procreation __instance, ref bool __result) { __result = Hens.HoldForStraw(__instance, __result); } } [HarmonyPatch(typeof(EggGrow), "CanGrow")] internal static class EggCanGrow_Patch { [HarmonyPrefix] private static bool Prefix(EggGrow __instance, ref bool __result) { if (Hens.Has(Hens.EggItem(__instance), "henhouse.infertile")) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(EggGrow), "Start")] internal static class EggStart_Patch { [HarmonyPostfix] private static void Postfix(EggGrow __instance) { try { ItemDrop d = Hens.EggItem(__instance); if (Plugin.HenEnabled.Value && !Hens.Has(d, "henhouse.infertile")) { float straw = ((!Hens.Has(d, "henhouse.straw")) ? 1f : Math.Max(1f, Plugin.HenHatchMult.Value)); float fire = ((!Hens.Has(d, "creaturecomforts.warm")) ? 1f : Math.Max(1f, Plugin.FireHatchMult.Value)); float num = Core.Combine(straw, fire); if (num > 1f) { __instance.m_growTime /= num; } } } catch (Exception ex) { Plugin.Log.LogError((object)("EggStart: " + ex)); } } } [HarmonyPatch(typeof(EggGrow), "GetHoverText")] internal static class EggHover_Patch { [HarmonyPostfix] private static void Postfix(EggGrow __instance, ref string __result) { if (Hens.Has(Hens.EggItem(__instance), "henhouse.infertile")) { __result += "\n<color=#a0a0a0>infertile - will never hatch</color>"; } } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int), typeof(bool) })] internal static class Tooltip_Patch { [HarmonyPostfix] private static void Postfix(ItemData __0, ref string __result) { if (Hens.Has(__0, "henhouse.infertile")) { __result += "\n<color=#a0a0a0>Infertile: will never hatch</color>"; } else if (Hens.Has(__0, "henhouse.straw") || Hens.Has(__0, "creaturecomforts.warm")) { string text = __result; __result = text + "\n<color=#c8b060>Laid " + ((!Hens.Has(__0, "henhouse.straw")) ? "" : "on straw") + ((!Hens.Has(__0, "henhouse.straw") || !Hens.Has(__0, "creaturecomforts.warm")) ? "" : " and ") + ((!Hens.Has(__0, "creaturecomforts.warm")) ? "" : "by a warm mother") + ": hatches faster</color>"; } } } internal static class Migration { public static int Migrated; private static Dictionary<string, string> _old; private static readonly Dictionary<string, string> ChangedDefaults = new Dictionary<string, string> { { "2 - Straw bonus|BreedingSpeedMultiplierInStraw", "2" }, { "2 - Straw bonus|GrowSpeedMultiplierInStraw", "2" }, { "2 - Straw bonus|GrowingSpecies", "piggy,cub,calf" }, { "3 - PigHouse digging|DigFasterInStraw", "2" }, { "6 - LoxHouse|Species", "Lox" }, { "7 - HenHouse|EggRateMultiplierInStraw", "2" }, { "7 - HenHouse|InfertileCapMultiplierInStraw", "2" }, { "7 - HenHouse|HatchSpeedMultiplierInStraw", "2" } }; public static void Load(ConfigFile c) { try { string directoryName = Path.GetDirectoryName(c.ConfigFilePath); string path = Path.Combine(directoryName, "pucko.animalhousebandry.cfg"); if (!File.Exists(path)) { return; } if (File.Exists(c.ConfigFilePath)) { string[] array = File.ReadAllLines(c.ConfigFilePath); foreach (string text in array) { if (text.TrimStart().StartsWith("[")) { return; } } } Dictionary<string, string> dictionary = new Dictionary<string, string>(); string text2 = null; string[] array2 = File.ReadAllLines(path); foreach (string text3 in array2) { string text4 = text3.Trim(); if (text4.Length == 0 || text4.StartsWith("#")) { continue; } if (text4.StartsWith("[") && text4.EndsWith("]")) { text2 = text4.Substring(1, text4.Length - 2); continue; } int num = text4.IndexOf('='); if (text2 != null && num > 0) { dictionary[text2 + "|" + text4.Substring(0, num).Trim()] = text4.Substring(num + 1).Trim(); } } _old = dictionary; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Migration: could not read the old config: " + ex.Message)); _old = null; } } private static bool Same(string a, string b) { if (double.TryParse(a, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && double.TryParse(b, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { return Math.Abs(result - result2) < 1E-06; } return string.Equals(a, b, StringComparison.OrdinalIgnoreCase); } public static void Apply(ConfigEntryBase e, string section, string key) { if (_old == null) { return; } try { string key2 = section + "|" + key; if (_old.TryGetValue(key2, out var value) && (!ChangedDefaults.TryGetValue(key2, out var value2) || !Same(value, value2))) { e.SetSerializedValue(value); Migrated++; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Migration: " + section + "/" + key + ": " + ex.Message)); } } } [BepInPlugin("pucko.creaturecomforts", "CreatureComforts", "0.5.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("pucko.henhouse")] [BepInIncompatibility("pucko.animalhousebandry")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "pucko.creaturecomforts"; public const string OldGuid = "pucko.animalhousebandry"; public const string Version = "0.5.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> LogDetails; internal static ConfigEntry<string> StrawNames; internal static ConfigEntry<string> BreedSpecies; internal static ConfigEntry<string> GrowSpecies; internal static ConfigEntry<float> StrawRadius; internal static ConfigEntry<float> StrawBreedMult; internal static ConfigEntry<float> StrawGrowMult; internal static ConfigEntry<bool> PigEnabled; internal static ConfigEntry<bool> PigRequireFed; internal static ConfigEntry<bool> PigletsForage; internal static ConfigEntry<bool> PigOnStructures; internal static ConfigEntry<bool> DirtFx; internal static ConfigEntry<bool> DigSound; internal static ConfigEntry<string> PigSpecies; internal static ConfigEntry<string> DefaultDrop; internal static ConfigEntry<string> RareDrop; internal static ConfigEntry<string> DirtFxPrefab; internal static ConfigEntry<string> SoundPrefab; internal static ConfigEntry<float> MinInterval; internal static ConfigEntry<float> MaxInterval; internal static ConfigEntry<float> StarCooldownPct; internal static ConfigEntry<float> DigStrawMult; internal static ConfigEntry<float> DigSeconds; internal static ConfigEntry<float> RareBase; internal static ConfigEntry<float> RarePerStar; internal static ConfigEntry<float> BonusPerStar; internal static ConfigEntry<float> NearbyRadius; internal static ConfigEntry<int> MaxNearby; internal static ConfigEntry<bool> EatFood; internal static ConfigEntry<bool> EatFish; internal static ConfigEntry<bool> EatRawFish; internal static ConfigEntry<bool> EatRawMeat; internal static ConfigEntry<bool> Cannibal; internal static ConfigEntry<bool> EatSeeds; internal static ConfigEntry<string> ExtraFood; internal static ConfigEntry<string> SeedWords; internal static ConfigEntry<float> FoodRange; internal static ConfigEntry<float> FoodInterval; internal static ConfigEntry<bool> DogEnabled; internal static ConfigEntry<string> DogSpecies; internal static ConfigEntry<float> FollowDistance; internal static ConfigEntry<float> FollowRunDistance; internal static ConfigEntry<float> FollowSettle; internal static ConfigEntry<bool> HenEnabled; internal static ConfigEntry<bool> HenSeek; internal static ConfigEntry<int> HenInfertileCap; internal static ConfigEntry<float> HenRateMult; internal static ConfigEntry<float> HenCapMult; internal static ConfigEntry<float> HenHatchMult; internal static ConfigEntry<float> HenSeekRadius; internal static ConfigEntry<float> HenSeekLead; internal static ConfigEntry<float> HenSeekMaxWait; internal static ConfigEntry<bool> LoxEnabled; internal static ConfigEntry<bool> LoxLogHits; internal static ConfigEntry<bool> LoxBlockAllTamed; internal static ConfigEntry<string> LoxSpecies; internal static ConfigEntry<string> LayerSpecies; internal static ConfigEntry<bool> WarmEnabled; internal static ConfigEntry<bool> PreferWarmth; internal static ConfigEntry<string> WarmSpecies; internal static ConfigEntry<float> HeatCheckInterval; internal static ConfigEntry<float> HeatRadius; internal static ConfigEntry<float> FireRateMult; internal static ConfigEntry<float> FireHatchMult; internal static ConfigEntry<float> FireGrowMult; internal static ConfigEntry<float> CombinedMax; internal static ConfigEntry<float> WarmthSearchRadius; internal static ConfigEntry<bool> ClimbTamed; internal static ConfigEntry<bool> ClimbWild; internal static ConfigEntry<bool> HareJump; internal static ConfigEntry<float> ClimbTamedAngle; internal static ConfigEntry<float> ClimbWildAngle; internal static ConfigEntry<float> HareJumpInterval; internal static ConfigEntry<float> HareJumpForce; internal static ConfigEntry<string> ClimbTamedSteep; internal static ConfigEntry<string> ClimbWildSteep; internal static ConfigEntry<string> HareSpecies; private static ConfigEntry<T> Bind<T>(ConfigFile c, string section, string key, T def, string desc, AcceptableValueBase range = null) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown object[] array = new object[1]; ConfigurationManagerAttributes val = new ConfigurationManagerAttributes(); val.IsAdminOnly = true; array[0] = val; ConfigEntry<T> val2 = c.Bind<T>(section, key, def, new ConfigDescription(desc, range, array)); Migration.Apply((ConfigEntryBase)(object)val2, section, key); return val2; } private void Awake() { //IL_0b6d: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ConfigFile config = ((BaseUnityPlugin)this).Config; Migration.Load(config); LogDetails = config.Bind<bool>("1 - General", "LogDetails", false, "Log what the modules decide (digs, blocked hits, found straw pieces). Only affects your own game."); StrawNames = Bind(config, "2 - Straw bonus", "StrawPieceNames", "straw", "Comma-separated words; a placed piece whose prefab name contains one of them (case-insensitive) counts as straw bedding."); StrawRadius = Bind(config, "2 - Straw bonus", "StrawRadius", 1.5f, "How close (metres, horizontal) an animal must be to a straw piece to count as standing on it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 6f)); BreedSpecies = Bind(config, "2 - Straw bonus", "BreedingSpecies", "Boar,Wolf,Lox", "Comma-separated prefab names (contains-match) whose breeding speeds up on straw. Egg layers (hens, Asksvin) are handled by the HenHouse module (sections 7-9) and always skipped here."); StrawBreedMult = Bind(config, "2 - Straw bonus", "BreedingSpeedMultiplierInStraw", 1.5f, "Animals on straw breed this many times faster (divides the pregnancy time and the love points needed). 1 = no bonus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); GrowSpecies = Bind(config, "2 - Straw bonus", "GrowingSpecies", "piggy,cub,calf,asksvin", "Comma-separated words; young animals whose prefab name contains one of them grow up faster while standing on straw."); StrawGrowMult = Bind(config, "2 - Straw bonus", "GrowSpeedMultiplierInStraw", 1.5f, "Young animals on straw grow up this many times faster. 1 = no bonus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); PigEnabled = Bind(config, "3 - PigHouse digging", "Enabled", def: true, "Happy tame boars dig up mushrooms. This replaces the TruffleBoars mod: remove TruffleBoars or you get double mushrooms."); PigSpecies = Bind(config, "3 - PigHouse digging", "Species", "Boar", "Comma-separated prefab names (contains-match) of the animals that dig, eat the wider diet, etc."); PigRequireFed = Bind(config, "3 - PigHouse digging", "RequireFed", def: true, "Boars only dig when fed (not hungry)."); PigletsForage = Bind(config, "3 - PigHouse digging", "PigletsCanForage", def: false, "Young piglets dig too."); PigOnStructures = Bind(config, "3 - PigHouse digging", "AllowOnStructures", def: false, "Allow digging on top of player-built floors. Off = only on natural ground."); MinInterval = Bind(config, "3 - PigHouse digging", "MinForageInterval", 240f, "Minimum seconds between digs for a 0-star boar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 7200f)); MaxInterval = Bind(config, "3 - PigHouse digging", "MaxForageInterval", 480f, "Maximum seconds between digs for a 0-star boar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 7200f)); StarCooldownPct = Bind(config, "3 - PigHouse digging", "StarCooldownReductionPercent", 20f, "Shorter wait per star (20 = 1 star -20%, 2 stars -40%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 40f)); DigStrawMult = Bind(config, "3 - PigHouse digging", "DigFasterInStraw", 1.5f, "A boar standing on straw digs this many times as often. 1 = no bonus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); DigSeconds = Bind(config, "3 - PigHouse digging", "DigSeconds", 3f, "How long the boar stands rooting before the mushroom appears.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f)); DefaultDrop = Bind(config, "3 - PigHouse digging", "DefaultDropPrefab", "Mushroom", "Common find (Mushroom = red)."); RareDrop = Bind(config, "3 - PigHouse digging", "RareDropPrefab", "MushroomYellow", "Rarer find (MushroomYellow = yellow)."); RareBase = Bind(config, "3 - PigHouse digging", "RareChancePercent", 20f, "Chance that the find is the rare one, for a 0-star boar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f)); RarePerStar = Bind(config, "3 - PigHouse digging", "RareChancePerStarPercent", 15f, "Added rare chance per star.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f)); BonusPerStar = Bind(config, "3 - PigHouse digging", "BonusDropChancePerStarPercent", 30f, "Chance per star of one extra mushroom.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f)); MaxNearby = Bind(config, "3 - PigHouse digging", "MaxNearbyItems", 5, "A boar does not dig while this many loose mushrooms already lie within NearbyScanRadius (protects pens from clutter and lag). 0 = no limit.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200)); NearbyRadius = Bind(config, "3 - PigHouse digging", "NearbyScanRadius", 8f, "Metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f)); DirtFx = Bind(config, "3 - PigHouse digging", "DirtParticles", def: true, "Dirt puff while rooting."); DigSound = Bind(config, "3 - PigHouse digging", "DigSound", def: true, "Sound while rooting."); DirtFxPrefab = Bind(config, "3 - PigHouse digging", "DirtEffectPrefab", "", "Empty = pick automatically (the choice is logged at startup). Or name a vfx prefab."); SoundPrefab = Bind(config, "3 - PigHouse digging", "SoundPrefab", "", "Empty = the boar's own eating sound. Or name an sfx prefab."); EatFood = Bind(config, "4 - PigHouse diet", "EatCookedFood", def: true, "Boars eat any food item (cooked meals, bread, berries, vegetables, honey...). Mead and potions are not food."); EatFish = Bind(config, "4 - PigHouse diet", "EatFish", def: true, "Boars eat whole fish."); EatRawFish = Bind(config, "4 - PigHouse diet", "EatRawFish", def: true, "Boars eat raw fish."); EatRawMeat = Bind(config, "4 - PigHouse diet", "EatRawMeat", def: true, "Boars eat raw meats."); Cannibal = Bind(config, "4 - PigHouse diet", "AllowCannibalism", def: false, "Boars eat boar meat and boar jerky."); EatSeeds = Bind(config, "4 - PigHouse diet", "EatSeeds", def: false, "Boars eat seeds, grain and nuts (puts your crops at risk)."); SeedWords = Bind(config, "4 - PigHouse diet", "SeedWords", "seed,acorn,barley,flax,cone", "Prefab-name words that mark an item as seed/grain."); ExtraFood = Bind(config, "4 - PigHouse diet", "ExtraFoodPrefabs", "", "Comma-separated item prefab names that boars may always eat."); FoodRange = Bind(config, "4 - PigHouse diet", "FoodSearchRange", 8f, "Metres boars look for thrown food (vanilla 5). 0 = leave vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f)); FoodInterval = Bind(config, "4 - PigHouse diet", "FoodSearchInterval", 10f, "Seconds between food searches (vanilla 10). Lower = more CPU in big pens. 0 = leave vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f)); DogEnabled = Bind(config, "5 - DogHouse", "Enabled", def: true, "Tame wolves told to follow keep a respectable distance instead of hugging you."); DogSpecies = Bind(config, "5 - DogHouse", "Species", "Wolf", "Comma-separated prefab names (contains-match) of followers that keep their distance."); FollowDistance = Bind(config, "5 - DogHouse", "FollowDistance", 8f, "Metres. The follower stops when closer than this, and walks back to it when further (vanilla: 3).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f)); FollowSettle = Bind(config, "5 - DogHouse", "ApproachTo", 6f, "Metres. When it has to catch up, it walks until it is this close, then stops (must be <= FollowDistance).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 40f)); FollowRunDistance = Bind(config, "5 - DogHouse", "RunDistance", 16f, "It runs only when further away than this (vanilla: 10).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 80f)); LoxEnabled = Bind(config, "6 - LoxHouse", "Enabled", def: true, "Damage that tame lox and Asksvin deal to buildings is ignored."); LoxSpecies = Bind(config, "6 - LoxHouse", "Species", "Lox,Asksvin", "Comma-separated prefab names (contains-match) whose damage to buildings is blocked (tame ones only)."); LoxBlockAllTamed = Bind(config, "6 - LoxHouse", "BlockAllTamedAnimals", def: false, "Block building damage from every tame creature, not just the species above."); LoxLogHits = Bind(config, "6 - LoxHouse", "LogHits", def: true, "Log (once per combination) hits on buildings by tame creatures, blocked or not (diagnostic)."); HenEnabled = Bind(config, "7 - HenHouse", "Enabled", def: true, "Hens at max population lay infertile overflow eggs, straw gives more eggs and faster hatching, hens walk to straw to lay. Off = vanilla hens (already flagged eggs stay flagged)."); HenInfertileCap = Bind(config, "7 - HenHouse", "InfertileEggCap", 12, "At max population, hens keep laying eggs that never hatch until this many infertile eggs are lying around (within the hens' check range). 0 = no overflow eggs (vanilla).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200)); HenRateMult = Bind(config, "7 - HenHouse", "EggRateMultiplierInStraw", 1.5f, "Egg layers (hens, Asksvin) on straw lay this many times as often (1.5 = 50% more eggs). Divides the pregnancy time and the love points needed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); HenCapMult = Bind(config, "7 - HenHouse", "InfertileCapMultiplierInStraw", 1.5f, "Multiplier on InfertileEggCap for egg layers on straw (the higher cap). Only straw raises the cap, warmth never does.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); HenHatchMult = Bind(config, "7 - HenHouse", "HatchSpeedMultiplierInStraw", 1.5f, "Fertile eggs laid on straw hatch this many times faster.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); HenSeek = Bind(config, "8 - HenHouse seeking straw", "HensWalkToStraw", def: true, "A hen that is about to lay walks to the nearest straw piece (if one is within SearchRadius) and lays there."); HenSeekRadius = Bind(config, "8 - HenHouse seeking straw", "SearchRadius", 15f, "How far (metres) a hen looks for straw when she is about to lay.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 50f)); HenSeekLead = Bind(config, "8 - HenHouse seeking straw", "StartWalkingSecondsBeforeLaying", 40f, "She starts walking to the straw this many seconds before the egg is due.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 300f)); HenSeekMaxWait = Bind(config, "8 - HenHouse seeking straw", "MaxExtraWaitSeconds", 90f, "If she cannot reach straw, laying is delayed at most this long, then she lays where she stands.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f)); LayerSpecies = Bind(config, "9 - Egg layers", "OtherLayers", "Asksvin", "Comma-separated prefab names (contains-match) of egg-laying animals besides hens that get the HenHouse treatment (sections 7-8): overflow infertile eggs, laying on straw, straw/warmth hatch bonuses. The animal needs a Procreation whose offspring is an egg item. Empty = hens only."); WarmEnabled = Bind(config, "10 - Warmth", "Enabled", def: true, "Fire bonus: animals standing in a heat area (campfire, hearth, ...) get the fire multipliers below, and their eggs are flagged warm. Stacks with straw up to CombinedMaxMultiplier."); WarmSpecies = Bind(config, "10 - Warmth", "Species", "Asksvin", "Comma-separated prefab names (contains-match) that get the fire bonus and like to stay warm. Young animals count too if their name contains the word."); HeatCheckInterval = Bind(config, "10 - Warmth", "HeatCheckInterval", 6f, "Seconds between heat tests per animal (each is a small physics query). 5-15 is plenty.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f)); HeatRadius = Bind(config, "10 - Warmth", "HeatRadius", 0.8f, "Metres. How close to a heat area (inside it, plus this) counts as warm. Eggs use 0.5 in the game.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f)); FireRateMult = Bind(config, "10 - Warmth", "EggRateMultiplierNearFire", 1.5f, "Warm egg layers lay this many times as often. Multiplies with straw, then capped by CombinedMaxMultiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); FireHatchMult = Bind(config, "10 - Warmth", "HatchSpeedMultiplierNearFire", 1.5f, "Fertile eggs laid while the mother was warm hatch this many times faster (multiplies with straw, then capped).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); FireGrowMult = Bind(config, "10 - Warmth", "GrowSpeedMultiplierNearFire", 1.5f, "Young warm animals grow up this many times faster (multiplies with straw, then capped).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); CombinedMax = Bind(config, "10 - Warmth", "CombinedMaxMultiplier", 2f, "Ceiling for straw x fire together on one animal or egg (each alone is not capped by this). 2 = never more than double.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f)); PreferWarmth = Bind(config, "10 - Warmth", "PreferToStayWarm", def: true, "Tame animals of these species that are idle and not warm walk to the nearest heat area within WarmthSearchRadius, and hang around it. Egg layers about to lay also look for warmth when no straw is near (sections 7-8 settings apply)."); WarmthSearchRadius = Bind(config, "10 - Warmth", "WarmthSearchRadius", 12f, "Metres. How far an idle animal looks for a heat area. Keep it about pen-sized: a fire on the other side of a wall just makes them stand at the wall.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 50f)); ClimbTamed = Bind(config, "11 - Climb limit", "TamedEnabled", def: true, "Tame creatures slide back down slopes steeper than the angle below (vanilla: only vertical stops them, so they climb roofs, pen walls and each other). Applies live."); ClimbTamedAngle = Bind(config, "11 - Climb limit", "TamedAngle", 60f, "Degrees. Steepest slope a tame creature can walk up. Players slide at 38 in vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 90f)); ClimbTamedSteep = Bind(config, "11 - Climb limit", "TamedSteepSpecies", "Hare:80,Wolf:70,Asksvin:60", "Comma-separated Name:angle (contains-match, first match wins) overriding TamedAngle: mountain and Mistlands natives get a higher limit. A first guess, tune after testing."); ClimbWild = Bind(config, "11 - Climb limit", "WildEnabled", def: true, "Also limit wild creatures (enemies). Changes enemy pathing and raid behaviour around bases; switch off to leave wild creatures vanilla. Applies live."); ClimbWildAngle = Bind(config, "11 - Climb limit", "WildAngle", 60f, "Degrees for wild creatures.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 90f)); ClimbWildSteep = Bind(config, "11 - Climb limit", "WildSteepSpecies", "Hare:80,Seeker:75,Tick:80,Gjall:75,Fenring:75,Ulv:75,Hatchling:75,StoneGolem:75,Wolf:70", "Comma-separated Name:angle for wild creatures native to steep biomes (Mountain, Mistlands). Bosses are never limited."); HareJump = Bind(config, "11 - Climb limit", "HareJumpEnabled", def: true, "Hares hop (the game gives them no jump)."); HareSpecies = Bind(config, "11 - Climb limit", "HareSpecies", "Hare", "Comma-separated prefab names (contains-match) that get the jump."); HareJumpInterval = Bind(config, "11 - Climb limit", "HareJumpIntervalSeconds", 3f, "Seconds between hops while moving. Guess; tune in the lab.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f)); HareJumpForce = Bind(config, "11 - Climb limit", "HareJumpForce", 6f, "Jump force (the game's own value is raised to at least this). Guess; tune in the lab.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f)); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { Core.Invalidate(); }; new Harmony("pucko.creaturecomforts").PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)("CreatureComforts 0.5.0 loaded" + ((Migration.Migrated <= 0) ? "" : (" (took over " + Migration.Migrated + " settings from the AnimalHousebandry config)")))); } } internal static class Core { private static readonly Dictionary<string, string[]> _tok = new Dictionary<string, string[]>(); private static readonly Dictionary<ConfigEntry<string>, Dictionary<int, bool>> _kind = new Dictionary<ConfigEntry<string>, Dictionary<int, bool>>(); private static readonly Dictionary<int, bool> _hen = new Dictionary<int, bool>(); private static readonly Dictionary<int, bool> _layer = new Dictionary<int, bool>(); public static readonly Func<BaseAI, float, Vector3, float, bool, bool> MoveTo = (Func<BaseAI, float, Vector3, float, bool, bool>)Delegate.CreateDelegate(typeof(Func<BaseAI, float, Vector3, float, bool, bool>), AccessTools.Method(typeof(BaseAI), "MoveTo", new Type[4] { typeof(float), typeof(Vector3), typeof(float), typeof(bool) }, (Type[])null)); public static readonly Action<BaseAI> StopMoving = (Action<BaseAI>)Delegate.CreateDelegate(typeof(Action<BaseAI>), AccessTools.Method(typeof(BaseAI), "StopMoving", (Type[])null, (Type[])null)); private static readonly FieldInfo _fInst = AccessTools.Field(typeof(ItemDrop), "s_instances"); public static string[] Tokens(string s) { s = s ?? ""; if (_tok.TryGetValue(s, out var value)) { return value; } value = (from x in s.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries) select x.Trim() into x where x.Length > 0 select x).ToArray(); _tok[s] = value; return value; } public static bool NameHas(string name, string[] tokens) { if (string.IsNullOrEmpty(name)) { return false; } for (int i = 0; i < tokens.Length; i++) { if (name.IndexOf(tokens[i], StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } public static bool Is(Component c, ConfigEntry<string> words) { if ((Object)(object)c == (Object)null) { return false; } if (!_kind.TryGetValue(words, out var value)) { value = new Dictionary<int, bool>(); _kind[words] = value; } int instanceID = ((Object)c).GetInstanceID(); if (value.TryGetValue(instanceID, out var value2)) { return value2; } if (value.Count > 4096) { value.Clear(); } return value[instanceID] = NameHas(((Object)c.gameObject).name, Tokens(words.Value)); } public static bool IsHen(Procreation p) { if ((Object)(object)p == (Object)null) { return false; } int instanceID = ((Object)p).GetInstanceID(); if (_hen.TryGetValue(instanceID, out var value)) { return value; } if (_hen.Count > 4096) { _hen.Clear(); } value = (Object)(object)p.m_offspring != (Object)null && Utils.GetPrefabName(p.m_offspring) == "ChickenEgg"; _hen[instanceID] = value; return value; } public static bool IsLayer(Procreation p) { if ((Object)(object)p == (Object)null) { return false; } int instanceID = ((Object)p).GetInstanceID(); if (_layer.TryGetValue(instanceID, out var value)) { return value; } if (_layer.Count > 4096) { _layer.Clear(); } value = false; GameObject offspring = p.m_offspring; if ((Object)(object)offspring != (Object)null && (Object)(object)offspring.GetComponent<ItemDrop>() != (Object)null) { value = Utils.GetPrefabName(offspring) == "ChickenEgg" || NameHas(((Object)((Component)p).gameObject).name, Tokens(Plugin.LayerSpecies.Value)); } _layer[instanceID] = value; return value; } public static string EggName(Procreation p) { return (!((Object)(object)p == (Object)null) && !((Object)(object)p.m_offspring == (Object)null)) ? Utils.GetPrefabName(p.m_offspring) : null; } public static void Invalidate() { _kind.Clear(); _layer.Clear(); Diet.Dirty = true; Straw.Rebuild(); Heat.Reset(); ClimbLimit.Reset(); Hens.ResetSteer(); } public static float Combine(float straw, float fire) { straw = Math.Max(1f, straw); fire = Math.Max(1f, fire); if (straw <= 1f || fire <= 1f) { return Math.Max(straw, fire); } return Math.Min(straw * fire, Math.Max(Math.Max(1f, Plugin.CombinedMax.Value), Math.Max(straw, fire))); } public static int CountLoose(Vector3 pos, float range, string a, string b) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) List<ItemDrop> list = ((!(_fInst == null)) ? ((List<ItemDrop>)_fInst.GetValue(null)) : null); if (list == null) { return 0; } float num = range * range; int num2 = 0; for (int i = 0; i < list.Count; i++) { ItemDrop val = list[i]; if ((Object)(object)val == (Object)null) { continue; } Vector3 val2 = ((Component)val).transform.position - pos; if (!(((Vector3)(ref val2)).sqrMagnitude > num)) { string name = ((Object)((Component)val).gameObject).name; if (name.StartsWith(a, StringComparison.OrdinalIgnoreCase) || name.StartsWith(b, StringComparison.OrdinalIgnoreCase)) { num2++; } } } return num2; } } internal static class Straw { private static readonly List<Piece> _list = new List<Piece>(); private static readonly FieldInfo _fAll = AccessTools.Field(typeof(Piece), "s_allPieces"); private static readonly FieldInfo _fGhost = AccessTools.Field(typeof(Piece), "s_ghostLayer"); private static int _ghost = -999; private static int _logged; public static int Count => _list.Count; public static void OnAwake(Piece p) { if ((Object)(object)p != (Object)null && Core.NameHas(((Object)((Component)p).gameObject).name, Core.Tokens(Plugin.StrawNames.Value)) && !_list.Contains(p)) { _list.Add(p); if (Plugin.LogDetails.Value && _logged < 5) { _logged++; Plugin.Log.LogInfo((object)("Straw registered: " + ((Object)((Component)p).gameObject).name + " (" + _list.Count + " in the registry)")); } } } public static bool Nearest(Vector3 pos, float radius, out Vector3 where) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) where = Vector3.zero; if (_list.Count == 0) { return false; } if (_ghost == -999) { _ghost = ((!(_fGhost == null)) ? ((int)_fGhost.GetValue(null)) : (-1)); } float num = radius * radius; bool result = false; for (int num2 = _list.Count - 1; num2 >= 0; num2--) { Piece val = _list[num2]; if ((Object)(object)val == (Object)null) { _list.RemoveAt(num2); } else if (((Component)val).gameObject.layer != _ghost) { Vector3 val2 = ((Component)val).transform.position - pos; val2.y = 0f; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude <= num) { num = sqrMagnitude; where = ((Component)val).transform.position; result = true; } } } return result; } public static void OnDestroy(Piece p) { _list.Remove(p); } public static void Rebuild() { try { _list.Clear(); List<Piece> list = ((!(_fAll == null)) ? ((List<Piece>)_fAll.GetValue(null)) : null); if (list == null) { return; } foreach (Piece item in list) { OnAwake(item); } } catch (Exception ex) { Plugin.Log.LogError((object)("Straw.Rebuild: " + ex)); } } public static bool At(Component who) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)who == (Object)null || _list.Count == 0) { return false; } Vector3 position = who.transform.position; float value = Plugin.StrawRadius.Value; float num = value * value; for (int num2 = _list.Count - 1; num2 >= 0; num2--) { Piece val = _list[num2]; if ((Object)(object)val == (Object)null) { _list.RemoveAt(num2); } else { if (_ghost == -999) { _ghost = ((!(_fGhost == null)) ? ((int)_fGhost.GetValue(null)) : (-1)); } if (((Component)val).gameObject.layer != _ghost) { Vector3 val2 = ((Component)val).transform.position - position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude <= num) { return true; } } } } return false; } } [HarmonyPatch(typeof(Piece), "Awake")] internal static class PieceAwake_Patch { [HarmonyPostfix] private static void Postfix(Piece __instance) { Straw.OnAwake(__instance); } } [HarmonyPatch(typeof(Piece), "OnDestroy")] internal static class PieceDestroy_Patch { [HarmonyPostfix] private static void Postfix(Piece __instance) { Straw.OnDestroy(__instance); } } [HarmonyPatch(typeof(Procreation), "Procreate")] internal static class Breed_Patch { private static readonly Dictionary<int, KeyValuePair<float, int>> _base = new Dictionary<int, KeyValuePair<float, int>>(); [HarmonyPrefix] private static void Prefix(Procreation __instance) { try { if ((Object)(object)__instance == (Object)null || Core.IsLayer(__instance) || !Core.Is((Component)(object)__instance, Plugin.BreedSpecies)) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!_base.TryGetValue(instanceID, out var value)) { if (_base.Count > 4096) { _base.Clear(); } value = new KeyValuePair<float, int>(__instance.m_pregnancyDuration, __instance.m_requiredLovePoints); _base[instanceID] = value; } float num = ((!(Plugin.StrawBreedMult.Value > 1f) || !Straw.At((Component)(object)__instance)) ? 1f : Plugin.StrawBreedMult.Value); __instance.m_pregnancyDuration = value.Key / num; __instance.m_requiredLovePoints = Math.Max(1, Mathf.RoundToInt((float)value.Value / num)); } catch (Exception ex) { Plugin.Log.LogError((object)("Breed prefix: " + ex)); } } } [HarmonyPatch(typeof(Growup), "GrowUpdate")] internal static class Grow_Patch { [HarmonyPrefix] private static void Prefix(Growup __instance, out float __state) { __state = -1f; try { float straw = ((!(Plugin.StrawGrowMult.Value > 1f) || !Core.Is((Component)(object)__instance, Plugin.GrowSpecies) || !Straw.At((Component)(object)__instance)) ? 1f : Plugin.StrawGrowMult.Value); float fire = ((!Plugin.WarmEnabled.Value || !(Plugin.FireGrowMult.Value > 1f) || !Core.Is((Component)(object)__instance, Plugin.WarmSpecies) || !Heat.At((Component)(object)__instance)) ? 1f : Plugin.FireGrowMult.Value); float num = Core.Combine(straw, fire); if (!(num <= 1f)) { __state = __instance.m_growTime; __instance.m_growTime = __state / num; } } catch (Exception ex) { Plugin.Log.LogError((object)("Grow prefix: " + ex)); } } [HarmonyPostfix] private static void Postfix(Growup __instance, float __state) { if (__state >= 0f && (Object)(object)__instance != (Object)null) { __instance.m_growTime = __state; } } } internal class PigForager : MonoBehaviour { public static int Active; public static readonly HashSet<int> Digging = new HashSet<int>(); private static readonly int KLast = StringExtensionMethods.GetStableHashCode("pucko_pig_last"); private static readonly int KFrac = StringExtensionMethods.GetStableHashCode("pucko_pig_frac"); private static int _mask = -1; private static int _terrain = -1; private static GameObject _dirt; private static GameObject _sound; private static bool _fxResolved; private static readonly FieldInfo _fAnim = AccessTools.Field(typeof(BaseAI), "m_animator"); private Character _ch; private Tameable _tame; private BaseAI _ai; private ZNetView _nv; private bool _digging; private float _holdUntil; private void Start() { _ch = ((Component)this).GetComponent<Character>(); _tame = ((Component)this).GetComponent<Tameable>(); _ai = ((Component)this).GetComponent<BaseAI>(); _nv = ((Component)this).GetComponent<ZNetView>(); if ((Object)(object)_ch == (Object)null || (Object)(object)_tame == (Object)null || (Object)(object)_ai == (Object)null || (Object)(object)_nv == (Object)null) { Object.Destroy((Object)(object)this); } else { ((MonoBehaviour)this).InvokeRepeating("Tick", Random.Range(1f, 4f), 2f); } } private void OnDestroy() { if (_digging) { Active = Math.Max(0, Active - 1); Digging.Remove(((Object)((Component)this).gameObject).GetInstanceID()); } } private void Tick() { //IL_0226: Unknown result type (might be due to invalid IL or missing references) try { if (_digging || !Plugin.PigEnabled.Value || Time.time < _holdUntil || !_nv.IsValid() || !_nv.IsOwner() || !_ch.IsTamed()) { return; } ZDO zDO = _nv.GetZDO(); long ticks = ZNet.instance.GetTime().Ticks; long num = zDO.GetLong(KLast, 0L); if (num == 0) { zDO.Set(KLast, ticks); zDO.Set(KFrac, Random.value); return; } double num2 = (double)(ticks - num) / 10000000.0; int num3 = Math.Max(0, _ch.GetLevel() - 1); float num4 = Mathf.Lerp(Plugin.MinInterval.Value, Plugin.MaxInterval.Value, zDO.GetFloat(KFrac, 0.5f)) * Mathf.Max(0.1f, 1f - (float)num3 * Plugin.StarCooldownPct.Value / 100f); float num5 = Math.Max(1f, Plugin.DigStrawMult.Value); if (!(num2 < (double)(num4 / num5)) && (!(num2 < (double)num4) || Straw.At((Component)(object)this)) && (!Plugin.PigRequireFed.Value || !_tame.IsHungry()) && !_ai.IsAlerted() && _ch.IsOnGround() && !_ch.InWater() && (!((Object)(object)((Component)this).GetComponent<Growup>() != (Object)null) || Plugin.PigletsForage.Value)) { if (!NaturalGround()) { _holdUntil = Time.time + 20f; } else if (Plugin.MaxNearby.Value > 0 && Core.CountLoose(((Component)this).transform.position, Plugin.NearbyRadius.Value, Plugin.DefaultDrop.Value, Plugin.RareDrop.Value) >= Plugin.MaxNearby.Value) { _holdUntil = Time.time + 30f; } else { ((MonoBehaviour)this).StartCoroutine(Dig(num3)); } } } catch (Exception ex) { Plugin.Log.LogError((object)("PigForager.Tick: " + ex)); _holdUntil = Time.time + 60f; } } private bool NaturalGround() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (_mask < 0) { _mask = LayerMask.GetMask(new string[5] { "terrain", "piece", "piece_nonsolid", "static_solid", "Default" }); _terrain = LayerMask.NameToLayer("terrain"); } RaycastHit val = default(RaycastHit); if (!Physics.Raycast(((Component)this).transform.position + Vector3.up * 0.6f, Vector3.down, ref val, 2.2f, _mask)) { return false; } return Plugin.PigOnStructures.Value || ((Component)((RaycastHit)(ref val)).collider).gameObject.layer == _terrain; } private IEnumerator Dig(int stars) { _digging = true; Active++; Digging.Add(((Object)((Component)this).gameObject).GetInstanceID()); bool aborted = false; try { Core.StopMoving(_ai); ZSyncAnimation anim = (ZSyncAnimation)((!(_fAnim == null)) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)anim != (Object)null) { anim.SetTrigger("consume"); } float total = Plugin.DigSeconds.Value; float t = 0f; bool fx = false; while (t < total) { yield return (object)new WaitForSeconds(0.25f); t += 0.25f; if ((Object)(object)_ai == (Object)null || _ai.IsAlerted()) { aborted = true; break; } if (!fx && t >= total * 0.4f) { fx = true; Effects(); } } if (!aborted) { Reward(stars); } } finally { _digging = false; Active = Math.Max(0, Active - 1); Digging.Remove(((Object)((Component)this).gameObject).GetInstanceID()); if ((Object)(object)_nv != (Object)null && _nv.IsValid() && _nv.IsOwner()) { ZDO zDO = _nv.GetZDO(); if (!aborted) { zDO.Set(KLast, ZNet.instance.GetTime().Ticks); zDO.Set(KFrac, Random.value); } else { _holdUntil = Time.time + 30f; } } } } private void Effects() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_007f: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) ResolveFx(); Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * 0.8f; if (Plugin.DirtFx.Value && (Object)(object)_dirt != (Object)null) { Object.Instantiate<GameObject>(_dirt, val, Quaternion.identity); } if (!Plugin.DigSound.Value) { return; } if ((Object)(object)_sound != (Object)null) { Object.Instantiate<GameObject>(_sound, val, Quaternion.identity); return; } Humanoid component = ((Component)this).GetComponent<Humanoid>(); if ((Object)(object)component != (Object)null && component.m_consumeItemEffects != null) { component.m_consumeItemEffects.Create(val, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); } } private static void ResolveFx() { if (!_fxResolved && !((Object)(object)ZNetScene.instance == (Object)null)) { _fxResolved = true; _dirt = Pick(Plugin.DirtFxPrefab.Value, "vfx_", new string[3] { "dirt", "mud", "ground" }); _sound = Pick(Plugin.SoundPrefab.Value, "sfx_", new string[3] { "dirt", "mud", "pickable_pick" }); Plugin.Log.LogInfo((object)("PigHouse effects: dirt = " + ((!Object.op_Implicit((Object)(object)_dirt)) ? "(none)" : ((Object)_dirt).name) + ", sound = " + ((!Object.op_Implicit((Object)(object)_sound)) ? "(boar's own eating sound)" : ((Object)_sound).name))); } } private static GameObject Pick(string configured, string prefix, string[] words) { ZNetScene instance = ZNetScene.instance; if (!string.IsNullOrEmpty(configured)) { return instance.GetPrefab(configured); } GameObject val = null; foreach (GameObject prefab in instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { string name = ((Object)prefab).name; if (name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && Core.NameHas(name, words) && ((Object)(object)val == (Object)null || name.Length < ((Object)val).name.Length)) { val = prefab; } } } return val; } private void Reward(int stars) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return; } float num = Plugin.RareBase.Value + (float)stars * Plugin.RarePerStar.Value; string text = ((!(Random.value * 100f < num)) ? Plugin.DefaultDrop.Value : Plugin.RareDrop.Value); int num2 = 1 + ((Random.value * 100f < (float)stars * Plugin.BonusPerStar.Value) ? 1 : 0); GameObject prefab = instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { Plugin.Log.LogWarning((object)("PigHouse: prefab '" + text + "' not found")); return; } for (int i = 0; i < num2; i++) { Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * 0.9f + Vector3.up * 0.4f + new Vector3(Random.Range(-0.3f, 0.3f), 0f, Random.Range(-0.3f, 0.3f)); Object.Instantiate<GameObject>(prefab, val, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)); } if (Plugin.LogDetails.Value) { Plugin.Log.LogInfo((object)("PigHouse: " + ((Object)((Component)this).gameObject).name + " (" + stars + " star) dug up " + num2 + " x " + text)); } } } [HarmonyPatch(typeof(Tameable), "Awake")] internal static class PigAttach_Patch { [HarmonyPostfix] private static void Postfix(Tameable __instance) { try { if ((Object)(object)((Component)__instance).GetComponent<PigForager>() == (Object)null && Core.Is((Component)(object)__instance, Plugin.PigSpecies)) { ((Component)__instance).gameObject.AddComponent<PigForager>(); } } catch (Exception ex) { Plugin.Log.LogError((object)("PigAttach: " + ex)); } } } [HarmonyPatch(typeof(BaseAI), "IdleMovement")] internal static class PigFreeze_Patch { [HarmonyPrefix] private static bool Prefix(BaseAI __instance) { return PigForager.Active == 0 || !PigForager.Digging.Contains(((Object)((Component)__instance).gameObject).GetInstanceID()); } } internal static class Diet { public static bool Dirty = true; private static HashSet<string> _names = new HashSet<string>(); private static ObjectDB _db; public static HashSet<string> Get(MonsterAI ai) { //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Invalid comparison between Unknown and I4 //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Invalid comparison between Unknown and I4 if (!Dirty && (Object)(object)_db == (Object)(object)ObjectDB.instance) { return _names; } HashSet<string> hashSet = new HashSet<string>(); _db = ObjectDB.instance; Dirty = false; try { if (ai.m_consumeItems != null) { foreach (ItemDrop consumeItem in ai.m_consumeItems) { if ((Object)(object)consumeItem != (Object)null && consumeItem.m_itemData != null) { hashSet.Add(consumeItem.m_itemData.m_shared.m_name); } } } if ((Object)(object)_db != (Object)null) { string[] tokens = Core.Tokens(Plugin.SeedWords.Value); string[] array = Core.Tokens(Plugin.ExtraFood.Value); foreach (GameObject item in _db.m_items) { if ((Object)(object)item == (Object)null) { continue; } ItemDrop component = item.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || component.m_itemData == null) { continue; } SharedData shared = component.m_itemData.m_shared; string name = ((Object)item).name; string[] array2 = array; foreach (string a in array2) { if (string.Equals(a, name, StringComparison.OrdinalIgnoreCase)) { hashSet.Add(shared.m_name); break; } } if (!Plugin.EatSeeds.Value && Core.NameHas(name, tokens)) { continue; } bool flag = name.Equals("RawMeat", StringComparison.OrdinalIgnoreCase) || name.IndexOf("boar", StringComparison.OrdinalIgnoreCase) >= 0; if (Plugin.Cannibal.Value || !flag) { bool flag2 = false; if (Plugin.EatFish.Value && (int)shared.m_itemType == 21) { flag2 = true; } else if (Plugin.EatRawFish.Value && (name.IndexOf("FishRaw", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("FishAngler", StringComparison.OrdinalIgnoreCase) >= 0)) { flag2 = true; } else if (Plugin.EatRawMeat.Value && (name.EndsWith("Meat", StringComparison.OrdinalIgnoreCase) || name.Equals("NeckTail", StringComparison.OrdinalIgnoreCase)) && name.IndexOf("cooked", StringComparison.OrdinalIgnoreCase) < 0) { flag2 = true; } else if (Plugin.EatFood.Value && (int)shared.m_itemType == 2 && shared.m_food > 0f) { flag2 = true; } if (flag2) { hashSet.Add(shared.m_name); } } } } _names = hashSet; if (Plugin.LogDetails.Value) { Plugin.Log.LogInfo((object)("PigHouse diet: " + hashSet.Count + " item types")); } } catch (Exception ex) { Plugin.Log.LogError((object)("Diet.Get: " + ex)); } return _names; } } [HarmonyPatch(typeof(MonsterAI), "CanConsume")] internal static class CanConsume_Patch { [HarmonyPrefix] private static bool Prefix(MonsterAI __instance, ItemData item, ref bool __result) { try { if (!Plugin.PigEnabled.Value || item == null || !Core.Is((Component)(object)__instance, Plugin.PigSpecies)) { return true; } __result = Diet.Get(__instance).Contains(item.m_shared.m_name); return false; } catch (Exception ex) { Plugin.Log.LogError((object)("CanConsume: " + ex)); return true; } } } [HarmonyPatch(typeof(MonsterAI), "Awake")] internal static class FoodSearch_Patch { [HarmonyPostfix] private static void Postfix(MonsterAI __instance) { try { if (Plugin.PigEnabled.Value && Core.Is((Component)(object)__instance, Plugin.PigSpecies)) { if (Plugin.FoodRange.Value > 0f) { __instance.m_consumeSearchRange = Math.Max(__instance.m_consumeSearchRange, Plugin.FoodRange.Value); } if (Plugin.FoodInterval.Value > 0f) { __instance.m_consumeSearchInterval = Plugin.FoodInterval.Value; } } } catch (Exception ex) { Plugin.Log.LogError((object)("FoodSearch: " + ex)); } } } [HarmonyPatch(typeof(BaseAI), "Follow")] internal static class Follow_Patch { [HarmonyPrefix] private static bool Prefix(BaseAI __instance, GameObject go, float dt) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) try { if (!Plugin.DogEnabled.Value || (Object)(object)go == (Object)null || !Core.Is((Component)(object)__instance, Plugin.DogSpecies)) { return true; } float value = Plugin.FollowDistance.Value; float arg = Math.Min(Plugin.FollowSettle.Value, value); float num = Vector3.Distance(go.transform.position, ((Component)__instance).transform.position); if (num < value) { Core.StopMoving(__instance); return false; } Core.MoveTo(__instance, dt, go.transform.position, arg, num > Plugin.FollowRunDistance.Value); return false; } catch (Exception ex) { Plugin.Log.LogError((object)("Follow prefix: " + ex)); return true; } } } internal static class LoxGuard { private static readonly HashSet<string> _seen = new HashSet<string>(); public static bool Block(Component target, HitData hit, string kind) { //IL_013b: Unknown result type (might be due to invalid IL or missing references) try { if (!Plugin.LoxEnabled.Value || hit == null) { return false; } Character attacker = hit.GetAttacker(); if ((Object)(object)attacker == (Object)null || !attacker.IsTamed()) { return false; } bool flag = Plugin.LoxBlockAllTamed.Value || Core.Is((Component)(object)attacker, Plugin.LoxSpecies); if (Plugin.LoxLogHits.Value) { string item = kind + "|" + ((Object)((Component)attacker).gameObject).name + "|" + ((Object)target.gameObject).name + "|" + flag; if (_seen.Add(item)) { Plugin.Log.LogInfo((object)string.Concat("LoxHouse: ", (!flag) ? "not blocked" : "BLOCKED", " ", kind, " hit by tame ", Utils.GetPrefabName(((Component)attacker).gameObject), " on ", Utils.GetPrefabName(target.gameObject), " (hitType ", hit.m_hitType, ", damage ", hit.GetTotalDamage(), "); logged once per combination")); } } return flag; } catch (Exception ex) { Plugin.Log.LogError((object)("LoxGuard: " + ex)); return false; } } } [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] internal static class WearDamage_Patch { [HarmonyPrefix] private static bool Prefix(WearNTear __instance, HitData hit) { return !LoxGuard.Block((Component)(object)__instance, hit, "building"); } } [HarmonyPatch(typeof(Destructible), "RPC_Damage")] internal static class DestructDamage_Patch { [HarmonyPrefix] private static bool Prefix(Destructible __instance, HitData hit) { if ((Object)(object)((Component)__instance).GetComponent<Piece>() == (Object)null) { return true; } return !LoxGuard.Block((Component)(object)__instance, hit, "piece"); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class SceneLog_Patch { [HarmonyPostfix] private static void Postfix(ZNetScene __instance) { try { Straw.Rebuild(); string[] array = Core.Tokens(Plugin.StrawNames.Value); string[] tokens = array.Concat(new string[2] { "hay", "nest" }).ToArray(); List<string> list = new List<string>(); List<string> list2 = new List<string>(); foreach (GameObject prefab in __instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { if ((Object)(object)prefab.GetComponent<Piece>() != (Object)null && Core.NameHas(((Object)prefab).name, tokens)) { list.Add(((Object)prefab).name + ((!Core.NameHas(((Object)prefab).name, array)) ? "" : " [matches]")); } if ((Object)(object)prefab.GetComponent<Procreation>() != (Object)null) { list2.Add(((Object)prefab).name + (Core.IsHen(prefab.GetComponent<Procreation>()) ? "(hen)" : ((!Core.IsLayer(prefab.GetComponent<Procreation>())) ? "" : ("(egg layer, egg " + Core.EggName(prefab.GetComponent<Procreation>()) + ")")))); } } } Plugin.Log.LogInfo((object)("CreatureComforts: straw/hay/nest pieces: " + ((list.Count != 0) ? string.Join(", ", list.ToArray()) : "(none)"))); Plugin.Log.LogInfo((object)("CreatureComforts: animals with Procreation: " + string.Join(", ", list2.ToArray()))); string[] array2 = new string[2] { Plugin.DefaultDrop.Value, Plugin.RareDrop.Value }; foreach (string text in array2) { if ((Object)(object)__instance.GetPrefab(text) == (Object)null) { Plugin.Log.LogWarning((object)("CreatureComforts: drop prefab not found: " + text)); } } } catch (Exception ex) { Plugin.Log.LogError((object)("SceneLog: " + ex)); } } }
plugins/EinsteinCrew-PuckosCarePackage/Pucko-FlowerVases/FlowerVases.dll
Decompiled 2 weeks 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.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace Pucko.FlowerVases; internal static class Alloc { public static int[] Allocate(int[] desired, int cap, bool oneEach, bool byStack) { int num = desired.Length; int[] array = new int[num]; if (num == 0 || cap <= 0) { return array; } int num2 = 0; for (int i = 0; i < num; i++) { num2 += Math.Max(0, desired[i]); } if (num2 <= cap) { for (int j = 0; j < num; j++) { array[j] = Math.Max(0, desired[j]); } return array; } if (cap < num) { List<int> list = new List<int>(); for (int k = 0; k < num; k++) { if (desired[k] > 0) { list.Add(k); } } list.Sort((int a, int b) => (desired[a] == desired[b]) ? a.CompareTo(b) : desired[b].CompareTo(desired[a])); for (int num3 = 0; num3 < list.Count && num3 < cap; num3++) { array[list[num3]] = 1; } return array; } double[] array2 = new double[num]; for (int num4 = 0; num4 < num; num4++) { array2[num4] = ((desired[num4] <= 0) ? 0.0 : (byStack ? ((double)desired[num4]) : 1.0)); } int num5 = 0; if (oneEach) { for (int num6 = 0; num6 < num; num6++) { array[num6] = ((desired[num6] > 0) ? 1 : 0); num5 += array[num6]; } } int num7 = cap - num5; while (num7 > 0) { double num8 = 0.0; for (int num9 = 0; num9 < num; num9++) { if (array[num9] < desired[num9]) { num8 += array2[num9]; } } if (num8 <= 0.0) { break; } int num10 = 0; for (int num11 = 0; num11 < num; num11++) { if (array[num11] < desired[num11]) { int val = (int)Math.Floor((double)num7 * array2[num11] / num8); val = Math.Min(val, desired[num11] - array[num11]); array[num11] += val; num10 += val; } } if (num10 == 0) { int num12 = -1; double num13 = -1.0; for (int num14 = 0; num14 < num; num14++) { if (array[num14] < desired[num14]) { double num15 = array2[num14] / (double)(array[num14] + 1); if (num15 > num13 + 1E-12) { num13 = num15; num12 = num14; } } } if (num12 < 0) { break; } array[num12]++; num10 = 1; } num7 -= num10; } return array; } public static List<int> Order(int[] counts, bool interleaved) { int[] array = (int[])counts.Clone(); List<int> list = new List<int>(); if (interleaved) { bool flag = true; while (flag) { flag = false; for (int i = 0; i < array.Length; i++) { if (array[i] > 0) { list.Add(i); array[i]--; flag = true; } } } } else { for (int j = 0; j < array.Length; j++) { for (int k = 0; k < array[j]; k++) { list.Add(j); } } } return list; } } internal sealed class Entry { public int Flower; public string Model; public float Hue = float.NaN; public int Count; public int Cm; public int Sz; public bool Same(int f, string m, float h, int cm, int sz) { if (Flower == f && Model == m && Cm == cm && Sz == sz) { if (!float.IsNaN(Hue)) { if (!float.IsNaN(h)) { return Math.Abs(Hue - h) < 0.5f; } return false; } return float.IsNaN(h); } return false; } } internal sealed class PotBouquet : MonoBehaviour { private const string RootName = "PuckoFlowerBouquet"; private Container _cont; private GameObject _root; private int _sig = int.MinValue; private int _ver = -1; private Bounds _pot; private bool _hasPot; private bool _logged; private bool _failed; private readonly List<Mesh> _meshes = new List<Mesh>(); private void ClearMeshes() { foreach (Mesh mesh in _meshes) { if ((Object)(object)mesh != (Object)null) { Object.Destroy((Object)(object)mesh); } } _meshes.Clear(); } private void Awake() { _cont = ((Component)this).GetComponent<Container>(); ((MonoBehaviour)this).InvokeRepeating("Tick", Random.value * 0.25f, 0.25f); } private void OnDestroy() { ((MonoBehaviour)this).CancelInvoke(); ClearMeshes(); } private static string PrefabName(GameObject go) { string name = ((Object)go).name; int num = name.IndexOf("(Clone)", StringComparison.Ordinal); if (num < 0) { return name; } return name.Substring(0, num).Trim(); } private void Tick() { if (_failed) { return; } try { Run(); } catch (Exception ex) { _failed = true; Plugin.Log.LogError((object)("FlowerVases: pot '" + PrefabName(((Component)this).gameObject) + "' switched off after an error: " + ex)); if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } } private void Run() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!Cfg.Enabled.Value) { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); _root = null; ClearMeshes(); _sig = int.MinValue; } return; } Inventory val = (((Object)(object)_cont != (Object)null) ? _cont.GetInventory() : null); if (val == null) { return; } float value = Cfg.ShowDistance.Value; if (value > 0f) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Vector3 val2 = ((Component)localPlayer).transform.position - ((Component)this).transform.position; bool flag = ((Vector3)(ref val2)).sqrMagnitude <= value * value; if ((Object)(object)_root != (Object)null && _root.activeSelf != flag) { _root.SetActive(flag); } if (!flag) { return; } } int num = val.GetWidth() * val.GetHeight(); string text = PrefabName(((Component)this).gameObject); bool flag2 = text.IndexOf("red", StringComparison.OrdinalIgnoreCase) >= 0; bool flag3 = Cfg.SizeEnabled(num) && (flag2 ? Cfg.RedPots.Value : Cfg.GreenPots.Value); int num2 = 17; List<ItemData> allItems = val.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { ItemData val3 = allItems[i]; num2 = num2 * 31 + (((Object)(object)val3.m_dropPrefab != (Object)null) ? ((Object)val3.m_dropPrefab).GetInstanceID() : 0); num2 = num2 * 31 + val3.m_stack; } num2 = num2 * 31 + num + (flag3 ? 1 : 0) + (Cfg.Preview.Value ? 7 : 0); num2 = num2 * 31 + PotSettings.Signature(_cont, val); if (num2 == _sig && Cfg.Version == _ver) { return; } _sig = num2; _ver = Cfg.Version; if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); _root = null; } ClearMeshes(); if (!flag3) { return; } Flower[] flowers = Cfg.Flowers; List<Entry> list = new List<Entry>(); for (int j = 0; j < allItems.Count; j++) { ItemData val4 = allItems[j]; string text2 = (((Object)(object)val4.m_dropPrefab != (Object)null) ? ((Object)val4.m_dropPrefab).name : null); if (text2 == null) { continue; } for (int k = 0; k < flowers.Length; k++) { if (flowers[k].Enabled.Value && flowers[k].Matches(text2)) { PotSettings.Slot slot = PotSettings.GetSlot(_cont, val4.m_gridPos.x, val4.m_gridPos.y); Add(list, k, slot.Model, slot.Hue, slot.Cm, slot.Sz, val4.m_stack); break; } } } if (Cfg.Preview.Value && allItems.Count == 0) { string[] array = Cfg.PreviewKinds.Value.Split(','); for (int l = 0; l < array.Length; l++) { string b = array[l].Trim(); for (int m = 0; m < flowers.Length; m++) { if (flowers[m].Enabled.Value && (string.Equals(flowers[m].Key, b, StringComparison.OrdinalIgnoreCase) || string.Equals(flowers[m].Label, b, StringComparison.OrdinalIgnoreCase))) { Add(list, m, null, float.NaN, 0, 0, Cfg.PreviewStack.Value); } } } } if (list.Count == 0) { return; } if (!_hasPot) { _hasPot = Geo.BoundsOf(((Component)this).transform, null, out _pot); } if (!_hasPot) { if (!_logged) { Plugin.Log.LogWarning((object)("FlowerVases: pot '" + text + "' has no mesh to measure; skipped.")); _logged = true; } } else { Build(list, num, text); } } private static void Add(List<Entry> list, int f, string model, float hue, int cm, int sz, int n) { foreach (Entry item in list) { if (item.Same(f, model, hue, cm, sz)) { item.Count += n; return; } } list.Add(new Entry { Flower = f, Model = model, Hue = hue, Cm = cm, Sz = sz, Count = n }); } private void Build(List<Entry> entries, int slots, string pname) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: 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_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Expected O, but got Unknown //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_063e: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0862: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_088d: Unknown result type (might be due to invalid IL or missing references) //IL_08b3: Unknown result type (might be due to invalid IL or missing references) //IL_08b8: Unknown result type (might be due to invalid IL or missing references) Flower[] flowers = Cfg.Flowers; Cfg.Look look = Cfg.LookFor(PotSettings.GetPreset(_cont)); string mix = PotSettings.GetMix(_cont); bool flag = ((mix.Length > 0) ? mix : Cfg.MixMode.Value) == "Interleaved"; List<Entry> list = new List<Entry>(); List<Template> list2 = new List<Template>(); List<int> list3 = new List<int>(); foreach (Entry entry in entries) { Template template = Models.Get(flowers[entry.Flower], entry.Model, entry.Hue); if (template != null) { list.Add(entry); list2.Add(template); list3.Add(Math.Max(1, (entry.Count + look.PerStem - 1) / look.PerStem)); } } if (list.Count == 0) { return; } int cap = look.MaxFor(slots); int[] array = Alloc.Allocate(list3.ToArray(), cap, Cfg.OneEach.Value, Cfg.ShareByStack.Value); string pattern = PotSettings.GetPattern(_cont); List<int> list4 = Alloc.Order(array, flag && pattern != "Rings"); int count = list4.Count; if (count == 0) { return; } _root = new GameObject("PuckoFlowerBouquet"); _root.transform.SetParent(((Component)this).transform, false); float num = Mathf.Min(((Bounds)(ref _pot)).extents.x, ((Bounds)(ref _pot)).extents.z) * Cfg.MouthRadius.Value / 100f; float num2 = num * look.Spread / 100f; float num3 = ((Bounds)(ref _pot)).max.y - Cfg.Depth.Value; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Bounds)(ref _pot)).center.x, num3, ((Bounds)(ref _pot)).center.z); Vector3 position = ((Component)this).transform.position; int num4 = (Mathf.RoundToInt(position.x * 10f) * 73856093) ^ (Mathf.RoundToInt(position.y * 10f) * 83492791) ^ (Mathf.RoundToInt(position.z * 10f) * 19349663) ^ (Cfg.Seed.Value * 7919); Random random = new Random(num4); double num5 = random.NextDouble() * Math.PI * 2.0; int count2 = list.Count; if (flag && pattern == "Random") { Random random2 = new Random(num4 ^ 0x5BD1E995); for (int num6 = list4.Count - 1; num6 > 0; num6--) { int index = random2.Next(num6 + 1); int value = list4[num6]; list4[num6] = list4[index]; list4[index] = value; } } Vector3 val2 = default(Vector3); for (int i = 0; i < count; i++) { int num7 = list4[i]; Flower flower = flowers[list[num7].Flower]; double num8; double num9; if (flag) { num8 = num5 + (double)i * 2.39996323; num9 = ((count == 1) ? 0.0 : Math.Sqrt(((double)i + 0.5) / (double)count)); } else { double num10 = Math.PI * 2.0 / (double)count2; num8 = num5 + num10 * (double)num7 + random.NextDouble() * num10 * 0.9; num9 = ((count == 1) ? 0.0 : Math.Sqrt(random.NextDouble())); } float num11 = (float)num9 * num2; float num12 = (float)Math.Cos(num8); float num13 = (float)Math.Sin(num8); Vector3 localPosition = val + new Vector3(num11 * num12, flower.HeightOffset.Value + (float)list[num7].Cm / 100f, num11 * num13); float num14 = ((num2 > 0.0001f) ? Mathf.Clamp01(num11 / num2) : 0f); float num15 = look.Lean * (0.35f + 0.65f * num14); ((Vector3)(ref val2))..ctor(num12, 0f, num13); Vector3 val3 = Vector3.Cross(Vector3.up, val2); Quaternion val4 = Quaternion.AngleAxis(num15, val3); float num16 = look.Tilt * (float)random.NextDouble(); float num17 = (float)(random.NextDouble() * 360.0); val4 = Quaternion.AngleAxis(num16, new Vector3(Mathf.Cos(num17 * ((float)Math.PI / 180f)), 0f, Mathf.Sin(num17 * ((float)Math.PI / 180f)))) * val4; val4 *= Quaternion.AngleAxis((float)(random.NextDouble() * 360.0), Vector3.up); float num18 = 1f + look.HVar / 100f * (float)(random.NextDouble() * 2.0 - 1.0); float num19 = 1f + look.SVar / 100f * (float)(random.NextDouble() * 2.0 - 1.0); float num20 = look.Height * num18 * num19 * Cfg.GlobalScale.Value / 100f * flower.Scale.Value / 100f * PotSettings.SizeMult[list[num7].Sz + 2]; GameObject val5 = new GameObject("stem"); val5.transform.SetParent(_root.transform, false); val5.transform.localPosition = localPosition; val5.transform.localRotation = val4; GameObject obj = Object.Instantiate<GameObject>(list2[num7].Pick(i), val5.transform, false); ((Object)obj).name = flower.Key; obj.SetActive(true); obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.Euler(flower.ExtraPitch.Value, 0f, 0f); obj.transform.localScale = Vector3.one * num20; StemMesh.Apply(obj, val5.transform, ((Component)this).transform, _pot, num * Cfg.ClipRadius.Value / 100f, Cfg.ClipMouth.Value, flower.StalkLen.Value, flower.StalkZone.Value, num20, _meshes); } SetLayer(_root, ((Component)this).gameObject.layer); if (!Cfg.LogDetails.Value) { return; } StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < list.Count; j++) { if (j > 0) { stringBuilder.Append(", "); } stringBuilder.Append(flowers[list[j].Flower].Label).Append((list[j].Model != null) ? (" [" + list[j].Model + "]") : "").Append(float.IsNaN(list[j].Hue) ? "" : (" hue " + list[j].Hue.ToString("0"))) .Append(" x") .Append(list[j].Count) .Append(" -> ") .Append(array[j]) .Append(" stems"); } Plugin.Log.LogInfo((object)("Bouquet in '" + pname + "' (" + slots + " slot" + ((slots == 1) ? "" : "s") + ", cap " + cap + "): " + stringBuilder?.ToString() + "; pot size " + ((Bounds)(ref _pot)).size.x.ToString("0.00") + " x " + ((Bounds)(ref _pot)).size.y.ToString("0.00") + " x " + ((Bounds)(ref _pot)).size.z.ToString("0.00") + " m")); } private static void SetLayer(GameObject go, int layer) { Transform[] componentsInChildren = go.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = layer; } } } internal sealed class ConfigurationManagerAttributes { public int? Order; public bool? IsAdvanced; } internal sealed class Flower { public string Key; public string Label; public ConfigEntry<bool> Enabled; public ConfigEntry<bool> AutoUpright; public ConfigEntry<bool> Push; public ConfigEntry<bool> NearFade; public ConfigEntry<bool> Split; public ConfigEntry<string> Items; public ConfigEntry<string> Models; public ConfigEntry<string> OnlyChild; public ConfigEntry<string> Choice; public ConfigEntry<float> Scale; public ConfigEntry<float> HeightOffset; public ConfigEntry<float> ExtraPitch; public ConfigEntry<float> Keep; public ConfigEntry<float> Sway; public ConfigEntry<float> Bloom; public ConfigEntry<float> Hue; public ConfigEntry<float> StalkLen; public ConfigEntry<float> StalkZone; public string[][] Options; public const string CustomChoice = "Custom (use the names below)"; private string _raw; private HashSet<string> _set = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public string EffModels(string label = null) { string[] array = ((label != null) ? ByLabel(label) : Pick()); if (array == null) { return Models.Value; } return array[1]; } public string EffOnly(string label = null) { string[] array = ((label != null) ? ByLabel(label) : Pick()); object obj; if (array == null) { obj = OnlyChild.Value; if (obj == null) { return ""; } } else { obj = array[2]; } return (string)obj; } private string[] Pick() { if (Options == null || Choice == null) { return null; } return ByLabel(Choice.Value); } private string[] ByLabel(string label) { if (Options == null) { return null; } string[][] options = Options; foreach (string[] array in options) { if (array[0] == label) { return array; } } return null; } public bool Matches(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return false; } string text = Items.Value ?? ""; if (text != _raw) { _raw = text; _set.Clear(); string[] array = text.Split(','); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length > 0) { _set.Add(text2); } } } return _set.Contains(prefabName); } } internal static class Cfg { public sealed class Look { public int Small; public int Medium; public int Large; public int PerStem; public float Spread; public float Lean; public float Tilt; public float Height; public float HVar; public float SVar; public int MaxFor(int slots) { if (slots < 3) { if (slots != 2) { return Small; } return Medium; } return Large; } } public static int Version; private static int _order = 1000; private static bool _applying; public const string Wild = "Wild meadow"; public const string Neat = "Neat bunch"; public const string Over = "Overflowing"; public const string Tall = "Tall and sparse"; public const string Single = "Single stem"; public const string Custom = "Custom"; public const string Tight = "Tight bundle"; public const string Loose = "Loose armful"; public const string Cottage = "Cottage garden"; public const string Spray = "Tall spray"; public const string Sparse = "Sparse wildflowers"; public const string MixInter = "Interleaved"; public const string MixGroup = "Grouped by kind"; public static ConfigEntry<bool> PotPanel; public static ConfigEntry<bool> ClipMouth; public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> LogDetails; public static ConfigEntry<bool> LogModels; public static ConfigEntry<bool> OneEach; public static ConfigEntry<bool> ShareByStack; public static ConfigEntry<bool> SmallPots; public static ConfigEntry<bool> MediumPots; public static ConfigEntry<bool> LargePots; public static ConfigEntry<bool> GreenPots; public static ConfigEntry<bool> RedPots; public static ConfigEntry<bool> Preview; public static ConfigEntry<bool> DumpNow; public static ConfigEntry<string> Preset; public static ConfigEntry<string> MixMode; public static ConfigEntry<string> Prefixes; public static ConfigEntry<string> ExtraPrefabs; public static ConfigEntry<string> PreviewKinds; public static ConfigEntry<string> DumpFilter; public static ConfigEntry<int> PotPanelX; public static ConfigEntry<int> PotPanelY; public static ConfigEntry<int> MaxSmall; public static ConfigEntry<int> MaxMedium; public static ConfigEntry<int> MaxLarge; public static ConfigEntry<int> ItemsPerStem; public static ConfigEntry<int> Seed; public static ConfigEntry<int> PreviewStack; public static ConfigEntry<float> ClipRadius; public static ConfigEntry<float> UprightRatio; public static ConfigEntry<float> Spread; public static ConfigEntry<float> MouthRadius; public static ConfigEntry<float> Lean; public static ConfigEntry<float> RandomTilt; public static ConfigEntry<float> BaseHeight; public static ConfigEntry<float> HeightVar; public static ConfigEntry<float> GlobalScale; public static ConfigEntry<float> ScaleVar; public static ConfigEntry<float> Depth; public static ConfigEntry<float> ShowDistance; public static Flower[] Flowers; public static readonly string[] PresetNames = new string[10] { "Wild meadow", "Neat bunch", "Overflowing", "Tall and sparse", "Single stem", "Tight bundle", "Loose armful", "Cottage garden", "Tall spray", "Sparse wildflowers" }; private static ConfigEntry<T> B<T>(ConfigFile c, string sec, string key, T def, string desc, AcceptableValueBase range = null) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ConfigEntry<T> obj = c.Bind<T>(sec, key, def, new ConfigDescription(desc, range, new object[1] { new ConfigurationManagerAttributes { Order = _order-- } })); obj.SettingChanged += delegate { Version++; }; return obj; } public static void Bind(ConfigFile c) { //IL_0a2f: Unknown result type (might be due to invalid IL or missing references) //IL_0a39: Expected O, but got Unknown Enabled = B(c, "1 - General", "Enabled", def: true, "Show flowers sticking out of the decorative pots when flowers are stored in them. Client-side and graphical only: nothing about the pots or their contents changes."); Preset = B(c, "1 - General", "LookPreset", "Wild meadow", "Pick a look. Choosing one sets the sliders below as a starting point; after that you can tweak any slider. 'Custom' changes nothing.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[11] { "Wild meadow", "Neat bunch", "Overflowing", "Tall and sparse", "Single stem", "Tight bundle", "Loose armful", "Cottage garden", "Tall spray", "Sparse wildflowers", "Custom" })); LogDetails = B(c, "1 - General", "LogDetails", def: true, "Write a line to the BepInEx log for every pot that gets a bouquet (its prefab name, size and what is in it). Useful in this early version."); LogModels = B(c, "1 - General", "LogModels", def: true, "Write a line to the BepInEx log when a flower model is loaded: which prefab was used, its size and how it was turned upright. Useful in this early version."); MaxSmall = B(c, "2 - Amount", "MaxStemsSmallPot", 6, "Most stems a small pot (1 slot) shows.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 40)); MaxMedium = B(c, "2 - Amount", "MaxStemsMediumPot", 10, "Most stems a medium pot (2 slots) shows.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 40)); MaxLarge = B(c, "2 - Amount", "MaxStemsLargePot", 15, "Most stems a large pot (3 slots) shows.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 40)); ItemsPerStem = B(c, "2 - Amount", "ItemsPerStem", 4, "How many stored flowers make one stem (rounded up, at least one stem per kind). High = a few stems however full the pot is.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200)); OneEach = B(c, "2 - Amount", "OneStemPerKindFirst", def: true, "When a pot holds several kinds and there is not room for all of them, every kind still gets at least one stem."); ShareByStack = B(c, "2 - Amount", "ShareByStackSize", def: true, "When there is not room for everything, share the stems out by how many of each kind is stored. Off = equal share per kind."); MixMode = B(c, "3 - Mix", "MixMode", "Interleaved", "Interleaved: the kinds are mixed through the whole bouquet. Grouped by kind: each kind gets its own side of the pot.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Interleaved", "Grouped by kind" })); Spread = B(c, "4 - Shape", "SpreadPercent", 85f, "How wide the bouquet spreads at the mouth, in % of the mouth radius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f)); MouthRadius = B(c, "4 - Shape", "MouthRadiusPercent", 40f, "Where the pot's mouth is, as % of the pot's half width. Lower for pots with a narrow neck, higher for wide ones.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 100f)); Lean = B(c, "4 - Shape", "LeanDegrees", 28f, "How far the outer stems lean outward, in degrees (the middle stems lean less).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 80f)); RandomTilt = B(c, "4 - Shape", "RandomTiltDegrees", 10f, "Random extra tilt of every stem in a random direction, in degrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 40f)); BaseHeight = B(c, "4 - Shape", "StemHeightMeters", 0.45f, "How tall a stem is, in metres (the part below the rim is included, see SinkIntoPotMeters).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1.5f)); HeightVar = B(c, "4 - Shape", "HeightVariationPercent", 30f, "Random difference in height between stems, in %.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 80f)); GlobalScale = B(c, "4 - Shape", "SizePercent", 100f, "Size of all flowers together, in %. Each flower kind also has its own size below.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 300f)); ScaleVar = B(c, "4 - Shape", "SizeVariationPercent", 15f, "Random difference in size between stems, in %.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f)); Depth = B(c, "4 - Shape", "SinkIntoPotMeters", 0.08f, "How far below the rim the stems start, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f)); ClipMouth = B(c, "4 - Shape", "ClipToMouth", def: true, "Squeeze every part of a stem that is below the pot's rim back inside the pot's mouth, so stems never poke out through the side of the pot. Above the rim nothing is changed. Needs flowers with a readable mesh."); ClipRadius = B(c, "4 - Shape", "ClipRadiusPercent", 100f, "How wide the pot's mouth is for ClipToMouth, in % of the mouth radius (MouthRadiusPercent). Lower = tighter, higher = lets stems out further.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 200f)); Seed = B(c, "4 - Shape", "SeedOffset", 0, "Re-rolls the arrangement. Each pot keeps its own look (from its position) for a given value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 999)); List<Flower> list = new List<Flower>(); string[][] opts = new string[5][] { new string[3] { "Grown plant (blooming)", "sapling_flax", "healthy_grown" }, new string[3] { "Young plant", "sapling_flax", "healthy" }, new string[3] { "Ripe plant", "Pickable_Flax", "" }, new string[3] { "Wild plant", "Pickable_Flax_Wild", "" }, new string[3] { "Item (bundle)", "Flax", "" } }; list.Add(MakeFlower(c, "Thistle", "Thistle", "Thistle", on: true, unusedSplit: false, new string[2][] { new string[3] { "Item model", "Thistle", "" }, new string[3] { "Plant model", "Pickable_Thistle", "" } }, "Item model", -1f, split: false)); list.Add(MakeFlower(c, "Flax", "Flax", "Flax", on: true, unusedSplit: false, opts, "Grown plant (blooming)", -1f, split: false)); list.Add(MakeFlower(c, "Fiddlehead", "Fiddlehead", "Fiddleheadfern", on: false, unusedSplit: false, new string[3][] { new string[3] { "Tall frond", "FernFiddleHeadAshlands", "" }, new string[3] { "Plant (pickable)", "Pickable_Fiddlehead", "" }, new string[3] { "Item model", "Fiddleheadfern", "" } }, "Tall frond", -1f, split: false)); list.Add(MakeFlower(c, "FragrantBundle", "Fragrant Bundle", "FragrantBundle", on: false, unusedSplit: false, new string[1][] { new string[3] { "Item model", "FragrantBundle", "" } }, "Item model", -1f, split: false)); string[][] array = new string[3][] { new string[5] { "Onion", "Onion Flowers", "sapling_seedonion", "Pickable_SeedOnion", "healthy_grown" }, new string[5] { "Carrot", "Carrot Flowers", "sapling_seedcarrot", "Pickable_SeedCarrot", "" }, new string[5] { "Turnip", "Turnip Flowers", "sapling_seedturnip", "Pickable_SeedTurnip", "" } }; foreach (string[] array2 in array) { list.Add(MakeFlower(c, array2[0] + "Flowers", array2[1], array2[0], on: true, unusedSplit: false, new string[4][] { new string[3] { "Ready to pick", array2[3], array2[4] }, new string[3] { "Grown flowers", array2[2], "healthy_grown" }, new string[3] { "Young plant", array2[2], "healthy" }, new string[3] { "Plant with root", array2[2], "" } }, "Ready to pick", -1f, split: false, autoUp: false)); } list.Add(MakeFlower(c, "PlainsFlowers", "Plains Flowers", "Dandelion", on: true, unusedSplit: false, new string[1][] { new string[3] { "Plains heath flowers", "instanced_heathflowers", "" } }, "Plains heath flowers", -1f, split: false)); Flowers = list.ToArray(); SmallPots = B(c, "6 - Pots", "SmallPots", def: true, "Show flowers in small pots (1 slot)."); MediumPots = B(c, "6 - Pots", "MediumPots", def: true, "Show flowers in medium pots (2 slots)."); LargePots = B(c, "6 - Pots", "LargePots", def: true, "Show flowers in large pots (3 slots)."); GreenPots = B(c, "6 - Pots", "GreenPots", def: true, "Show flowers in the green pots."); RedPots = B(c, "6 - Pots", "RedPots", def: true, "Show flowers in the red pots (a pot whose prefab name contains 'red')."); Prefixes = B(c, "6 - Pots", "PotPrefabPrefixes", "piece_pot", "Comma-separated beginnings of the prefab names that count as pots. Changes need a world reload."); ExtraPrefabs = B(c, "6 - Pots", "ExtraPotPrefabs", "", "Comma-separated exact prefab names of other containers that should get flowers too (must hold items). Changes need a world reload."); ShowDistance = B(c, "7 - Extras", "ShowWithinMeters", 40f, "Only pots within this distance of you show their flowers (0 = always).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f)); PotPanel = B(c, "7 - Extras", "ShowPotPanel", def: true, "Show the flower options (look, mix, model and colour per stack) in a pot's inventory window. What you choose there is saved with the pot."); PotPanelX = B(c, "7 - Extras", "PotPanelOffsetX", 0, "Move the pot window options sideways (pixels).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-600, 600)); PotPanelY = B(c, "7 - Extras", "PotPanelOffsetY", 0, "Move the pot window options up (+) or down (-) (pixels).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-600, 600)); Preview = B(c, "7 - Extras", "PreviewInEmptyPots", def: false, "Debug: put a sample bouquet in every EMPTY pot nearby, so you can tune the look without filling pots first."); PreviewKinds = B(c, "7 - Extras", "PreviewKinds", "Plains Flowers,Thistle,Flax", "Which flowers the preview shows (flower names as in the sections below, comma-separated)."); PreviewStack = B(c, "7 - Extras", "PreviewItemsPerKind", 12, "How many of each kind the preview pretends to hold.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200)); UprightRatio = B(c, "8 - Debug", "UprightLongerThan", 1f, "AutoUpright only turns a model onto its end when its longest side is this many times longer than its height as the game made it. 1.0 = always turn the long side up (as 0.0.1 did); higher = leave squat models as the game made them. Applies to models loaded after the change.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 4f)); DumpFilter = B(c, "8 - Debug", "PrefabListFilter", "flax,dandelion,thistle,flower,bloom,fern,fiddle,fragrant,pickable_,sapling,bush,shrub,vines,heath,lavender,puff,mushroom,reed,cattail", "Comma-separated name parts; the prefab list file describes every game prefab whose name contains one of them."); DumpNow = c.Bind<bool>("8 - Debug", "WritePrefabList", false, new ConfigDescription("Switch on to write BepInEx/FlowerVases-prefabs.txt (what the matching game prefabs are made of) and FlowerVases-all-prefab-names.txt (every prefab name). Turns itself off again. Needs a world to be loaded.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = _order-- } })); DumpNow.SettingChanged += delegate { if (DumpNow.Value) { DumpNow.Value = false; Dump.Run(); } }; Preset.SettingChanged += delegate { ApplyPreset(Preset.Value); }; } private static Flower MakeFlower(ConfigFile c, string key, string label, string items, bool on, bool unusedSplit, string[][] opts, string defChoice, float hue, bool split, bool autoUp = true) { string sec = "5 - " + label; Flower flower = new Flower { Key = key, Label = label, Options = opts }; flower.Enabled = B(c, sec, "Enabled", on, "Show " + label + " in the pots."); flower.Items = B(c, sec, "ItemNames", items, "Comma-separated prefab names of the stored items that count as " + label + "."); List<string> list = new List<string>(); foreach (string[] array in opts) { list.Add(array[0]); } list.Add("Custom (use the names below)"); flower.Choice = B(c, sec, "Model", defChoice, "Which model " + label + " uses. Pick 'Custom' to use the prefab names typed in ModelPrefabs / OnlyChildObject below.", (AcceptableValueBase)(object)new AcceptableValueList<string>(list.ToArray())); flower.Models = B(c, sec, "ModelPrefabs", opts[0][1], "Only used when Model is Custom: comma-separated prefab names (game prefabs, items, or ground cover names) to take the model from; the first one that exists is used."); flower.OnlyChild = B(c, sec, "OnlyChildObject", opts[0][2], "Only used when Model is Custom: use only the part of the model prefab with this object name, even if the game keeps it switched off (for example 'healthy_grown' on sapling_flax). Empty = the whole visible model."); flower.Scale = B(c, sec, "SizePercent", 100f, "Size of " + label + " compared with the other flowers, in %.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 400f)); flower.HeightOffset = B(c, sec, "HeightOffsetMeters", 0f, "Moves " + label + " up or down in the pot, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 0.5f)); flower.StalkLen = B(c, sec, "StalkLengthPercent", 100f, "Makes the stalk part of " + label + " longer (or shorter) without making the blooms and leaf tips bigger: only the lower part of the model is stretched, the upper part is moved up. 100 = unchanged. Needs a readable mesh.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 400f)); flower.StalkZone = B(c, sec, "StalkPartPercent", 50f, "How much of the model's height, from the bottom, counts as the stalk that StalkLengthPercent stretches.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 90f)); flower.AutoUpright = B(c, sec, "AutoUpright", autoUp, "Turn the model so its longest side points up (item models lie on the side). Off = use the model as it is. Applies to models loaded after the change."); flower.Sway = B(c, sec, "SwayPercent", 0f, "How much the plant sways in the wind: 100 = as in the game, 0 = stands still. Works by scaling the wind numbers of the plant's shader on a copy of its material (the log lists the numbers). Applies to models loaded after the change.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f)); flower.Push = B(c, sec, "PlayerPush", def: false, "On = the plant is pushed away when you walk close (the game's normal grass behaviour, where the shader has it). Off = it stays put. Applies to models loaded after the change."); flower.NearFade = B(c, sec, "NearCameraFade", def: true, "On = the game's normal behaviour of fading/culling plants very close to the camera, where the shader has it. Off = tries to stop that (for plants that look strange up close). Applies to models loaded after the change."); flower.Bloom = B(c, sec, "BloomSizePercent", 100f, "Makes the blooms bigger or smaller: the small parts of the model whose colour is not green (blue flax flowers, yellow dandelion heads) are scaled around their own centre. 100 = unchanged. Needs a readable mesh and texture. Applies to models loaded after the change.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 500f)); flower.Hue = B(c, sec, "BloomHueDegrees", hue, "Recolors the blooms (the non-green parts of the texture): the hue is set to this value in degrees, keeping brightness. 0 = red, 55 = yellow, 120 = green, 220 = blue, 290 = purple. -1 = keep the game's colour. Works on a copy of the texture. Applies to models loaded after the change.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 360f)); flower.Split = B(c, sec, "SplitIntoStalks", split, "For models that are a whole plant with several flower stalks (the dandelion item): cut the model into its separate parts and use one flower stalk per stem, turned to point up. Off = the whole model per stem. Applies to models loaded after the change."); flower.ExtraPitch = B(c, sec, "ExtraTurnDegrees", 0f, "Extra turn about the base, in degrees. 180 flips a model that came out upside down.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f)); flower.Keep = B(c, sec, "KeepPercent", 100f, "Cut the model after turning it upright: 100 = whole model; 40 = only the upper 40 % (for example the flower head without its long leaves); -40 = only the lower 40 %. Needs a readable mesh. Applies to models loaded after the change.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f)); return flower; } public static int MaxFor(int slots) { if (slots < 3) { if (slots != 2) { return MaxSmall.Value; } return MaxMedium.Value; } return MaxLarge.Value; } public static bool SizeEnabled(int slots) { if (slots < 3) { if (slots != 2) { return SmallPots.Value; } return MediumPots.Value; } return LargePots.Value; } public static float[] PresetTable(string name) { return name switch { "Wild meadow" => new float[10] { 6f, 10f, 15f, 4f, 85f, 28f, 10f, 0.45f, 30f, 15f }, "Neat bunch" => new float[10] { 4f, 7f, 10f, 4f, 55f, 8f, 3f, 0.42f, 8f, 5f }, "Overflowing" => new float[10] { 8f, 14f, 22f, 2f, 110f, 45f, 12f, 0.32f, 30f, 20f }, "Tall and sparse" => new float[10] { 3f, 5f, 7f, 6f, 60f, 12f, 5f, 0.75f, 35f, 10f }, "Single stem" => new float[10] { 4f, 4f, 4f, 200f, 20f, 6f, 3f, 0.55f, 15f, 5f }, "Tight bundle" => new float[10] { 4f, 6f, 8f, 6f, 30f, 5f, 3f, 0.45f, 15f, 10f }, "Loose armful" => new float[10] { 7f, 12f, 18f, 3f, 130f, 40f, 14f, 0.4f, 25f, 18f }, "Cottage garden" => new float[10] { 8f, 14f, 20f, 2f, 100f, 22f, 10f, 0.3f, 40f, 25f }, "Tall spray" => new float[10] { 3f, 5f, 7f, 6f, 50f, 10f, 4f, 0.9f, 25f, 10f }, "Sparse wildflowers" => new float[10] { 3f, 4f, 6f, 8f, 90f, 30f, 18f, 0.5f, 50f, 35f }, _ => null, }; } public static Look LookFor(string preset) { float[] array = (string.IsNullOrEmpty(preset) ? null : PresetTable(preset)); if (array == null) { return new Look { Small = MaxSmall.Value, Medium = MaxMedium.Value, Large = MaxLarge.Value, PerStem = ItemsPerStem.Value, Spread = Spread.Value, Lean = Lean.Value, Tilt = RandomTilt.Value, Height = BaseHeight.Value, HVar = HeightVar.Value, SVar = ScaleVar.Value }; } return new Look { Small = (int)array[0], Medium = (int)array[1], Large = (int)array[2], PerStem = (int)array[3], Spread = array[4], Lean = array[5], Tilt = array[6], Height = array[7], HVar = array[8], SVar = array[9] }; } private static void ApplyPreset(string name) { if (_applying || name == "Custom") { return; } float[] array = PresetTable(name); if (array == null) { return; } _applying = true; try { P((int)array[0], (int)array[1], (int)array[2], (int)array[3], array[4], array[5], array[6], array[7], array[8], array[9]); } finally { _applying = false; Version++; } } private static void P(int small, int medium, int large, int perStem, float spread, float lean, float tilt, float height, float hvar, float svar) { MaxSmall.Value = small; MaxMedium.Value = medium; MaxLarge.Value = large; ItemsPerStem.Value = perStem; Spread.Value = spread; Lean.Value = lean; RandomTilt.Value = tilt; BaseHeight.Value = height; HeightVar.Value = hvar; ScaleVar.Value = svar; } } internal static class Dump { public static void Run() { try { if ((Object)(object)ZNetScene.instance == (Object)null) { Plugin.Log.LogWarning((object)"Prefab list: load a world first."); return; } Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>(StringComparer.Ordinal); ZNetScene instance = ZNetScene.instance; if (instance.m_prefabs != null) { foreach (GameObject prefab in instance.m_prefabs) { if ((Object)(object)prefab != (Object)null && !dictionary.ContainsKey(((Object)prefab).name)) { dictionary[((Object)prefab).name] = prefab; } } } if (instance.m_nonNetViewPrefabs != null) { foreach (GameObject nonNetViewPrefab in instance.m_nonNetViewPrefabs) { if ((Object)(object)nonNetViewPrefab != (Object)null && !dictionary.ContainsKey(((Object)nonNetViewPrefab).name)) { dictionary[((Object)nonNetViewPrefab).name] = nonNetViewPrefab; } } } if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items != null) { foreach (GameObject item in ObjectDB.instance.m_items) { if ((Object)(object)item != (Object)null && !dictionary.ContainsKey(((Object)item).name)) { dictionary[((Object)item).name] = item; } } } List<string> list = new List<string>(dictionary.Keys); list.Sort(StringComparer.OrdinalIgnoreCase); string bepInExRootPath = Paths.BepInExRootPath; File.WriteAllLines(Path.Combine(bepInExRootPath, "FlowerVases-all-prefab-names.txt"), list.ToArray()); List<string> list2 = new List<string>(); string[] array = Cfg.DumpFilter.Value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { list2.Add(text); } } StringBuilder stringBuilder = new StringBuilder(); int num = 0; foreach (string item2 in list) { bool flag = false; foreach (string item3 in list2) { if (item2.IndexOf(item3, StringComparison.OrdinalIgnoreCase) >= 0) { flag = true; break; } } if (flag) { if (++num > 300) { stringBuilder.AppendLine("... stopped at 300 prefabs; narrow PrefabListFilter"); break; } Describe(stringBuilder, dictionary[item2]); } } stringBuilder.Insert(0, "FlowerVases prefab list: " + num + " prefabs match [" + Cfg.DumpFilter.Value + "] of " + list.Count + " in total\n\n"); File.WriteAllText(Path.Combine(bepInExRootPath, "FlowerVases-prefabs.txt"), stringBuilder.ToString()); WriteClutter(bepInExRootPath); Plugin.Log.LogInfo((object)("Prefab list written: " + num + " matching prefabs, " + list.Count + " names in total (BepInEx folder).")); } catch (Exception ex) { Plugin.Log.LogError((object)("Prefab list failed: " + ex)); } } private static void WriteClutter(string dir) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) ClutterSystem instance = ClutterSystem.instance; if ((Object)(object)instance == (Object)null || instance.m_clutter == null) { Plugin.Log.LogWarning((object)"Clutter list: ClutterSystem not found."); return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("FlowerVases clutter list (ground cover): " + instance.m_clutter.Count + " entries. Use the m_name or the prefab name in a flower's ModelPrefabs.\n"); foreach (Clutter item in instance.m_clutter) { if (item != null) { stringBuilder.Append("## m_name=").Append(item.m_name).Append(" biome=") .Append(item.m_biome) .Append(" enabled=") .Append(item.m_enabled) .Append(" instanced=") .Append(item.m_instanced) .Append(" scale=") .Append(item.m_scaleMin.ToString("0.##")) .Append("-") .Append(item.m_scaleMax.ToString("0.##")) .AppendLine(); if ((Object)(object)item.m_prefab != (Object)null) { Describe(stringBuilder, item.m_prefab); } else { stringBuilder.AppendLine(" (no prefab)\n"); } } } File.WriteAllText(Path.Combine(dir, "FlowerVases-clutter.txt"), stringBuilder.ToString()); } private static void Describe(StringBuilder sb, GameObject go) { //IL_0026: 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) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = sb.Append("== ").Append(((Object)go).name).Append(" (root scale "); Vector3 val = go.transform.localScale; stringBuilder.Append(((Vector3)(ref val)).ToString("0.###")).AppendLine(")"); Component[] components = go.GetComponents<Component>(); foreach (Component val2 in components) { if ((Object)(object)val2 == (Object)null || val2 is Transform) { continue; } sb.Append(" [").Append(((object)val2).GetType().Name).Append("]"); Pickable val3 = (Pickable)(object)((val2 is Pickable) ? val2 : null); if ((Object)(object)val3 != (Object)null) { PickableFields(sb, val3); } InstanceRenderer val4 = (InstanceRenderer)(object)((val2 is InstanceRenderer) ? val2 : null); if ((Object)(object)val4 != (Object)null) { StringBuilder stringBuilder2 = sb.Append(" mesh="); object value; if (!((Object)(object)val4.m_mesh != (Object)null)) { value = "-"; } else { string[] obj = new string[6] { ((Object)val4.m_mesh).name, " v", val4.m_mesh.vertexCount.ToString(), " ", null, null }; Bounds bounds = val4.m_mesh.bounds; val = ((Bounds)(ref bounds)).size; obj[4] = ((Vector3)(ref val)).ToString("0.##"); obj[5] = (val4.m_mesh.isReadable ? " readable" : ""); value = string.Concat(obj); } stringBuilder2.Append((string?)value).Append(" mat=").Append(((Object)(object)val4.m_material != (Object)null) ? (((Object)val4.m_material).name + "/" + (((Object)(object)val4.m_material.shader != (Object)null) ? ((Object)val4.m_material.shader).name : "?")) : "-") .Append(" scale=") .Append(((Vector3)(ref val4.m_scale)).ToString("0.##")); } ItemDrop val5 = (ItemDrop)(object)((val2 is ItemDrop) ? val2 : null); if ((Object)(object)val5 != (Object)null && val5.m_itemData != null && val5.m_itemData.m_shared != null) { sb.Append(" item ").Append(val5.m_itemData.m_shared.m_name); } sb.AppendLine(); } Walk(sb, go.transform, 1, 0); sb.AppendLine(); } private static void PickableFields(StringBuilder sb, Pickable pk) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown FieldInfo[] fields = typeof(Pickable).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { try { if (fieldInfo.FieldType == typeof(GameObject)) { GameObject val = (GameObject)fieldInfo.GetValue(pk); sb.Append(" ").Append(fieldInfo.Name).Append("=") .Append(((Object)(object)val != (Object)null) ? ((Object)val).name : "-"); } else { if (!(fieldInfo.FieldType == typeof(GameObject[]))) { continue; } GameObject[] array = (GameObject[])fieldInfo.GetValue(pk); sb.Append(" ").Append(fieldInfo.Name).Append("=["); if (array != null) { for (int j = 0; j < array.Length; j++) { sb.Append((j > 0) ? "," : "").Append(((Object)(object)array[j] != (Object)null) ? ((Object)array[j]).name : "-"); } } sb.Append("]"); continue; } } catch { } } } private static void Walk(StringBuilder sb, Transform t, int depth, int guard) { //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) if (depth > 6) { return; } for (int i = 0; i < t.childCount; i++) { Transform child = t.GetChild(i); sb.Append(new string(' ', depth * 2 + 1)).Append("- ").Append(((Object)child).name) .Append(((Component)child).gameObject.activeSelf ? "" : " (INACTIVE)"); Component[] components = ((Component)child).GetComponents<Component>(); foreach (Component val in components) { if ((Object)(object)val == (Object)null || val is Transform || val is MeshFilter) { continue; } Renderer val2 = (Renderer)(object)((val is Renderer) ? val : null); if ((Object)(object)val2 != (Object)null) { Geo.MeshOf(val2, out var m); StringBuilder stringBuilder = sb.Append(" <").Append(((object)val).GetType().Name).Append(val2.enabled ? "" : " OFF") .Append(" mesh="); object value; if (!((Object)(object)m != (Object)null)) { value = "-"; } else { string[] obj = new string[5] { ((Object)m).name, " v", m.vertexCount.ToString(), " ", null }; Bounds bounds = m.bounds; Vector3 size = ((Bounds)(ref bounds)).size; obj[4] = ((Vector3)(ref size)).ToString("0.##"); value = string.Concat(obj); } stringBuilder.Append((string?)value).Append(" mats="); Material[] sharedMaterials = val2.sharedMaterials; for (int k = 0; k < sharedMaterials.Length; k++) { sb.Append((k > 0) ? "," : "").Append(((Object)(object)sharedMaterials[k] != (Object)null) ? (((Object)sharedMaterials[k]).name + "/" + (((Object)(object)sharedMaterials[k].shader != (Object)null) ? ((Object)sharedMaterials[k].shader).name : "?")) : "-"); } sb.Append(">"); } else { sb.Append(" [").Append(((object)val).GetType().Name).Append("]"); } } sb.AppendLine(); Walk(sb, child, depth + 1, guard); } } } internal sealed class Template { public GameObject Wrapper; public List<GameObject> Variants; public string Source; public GameObject Pick(int i) { if (Variants == null || Variants.Count <= 0) { return Wrapper; } return Variants[i % Variants.Count]; } } internal static class Geo { public static bool MeshOf(Renderer r, out Mesh m) { m = null; MeshRenderer val = (MeshRenderer)(object)((r is MeshRenderer) ? r : null); if ((Object)(object)val != (Object)null) { MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { m = component.sharedMesh; } } else { SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((r is SkinnedMeshRenderer) ? r : null); if ((Object)(object)val2 != (Object)null) { m = val2.sharedMesh; } } return (Object)(object)m != (Object)null; } public static void Grow(ref Bounds b, ref bool any, Mesh m, Matrix4x4 mat) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references) //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00a4: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = m.bounds; Vector3 center = ((Bounds)(ref bounds)).center; bounds = m.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; Vector3 val = default(Vector3); for (int i = 0; i < 8; i++) { ((Vector3)(ref val))..ctor(center.x + (((i & 1) == 0) ? (0f - extents.x) : extents.x), center.y + (((i & 2) == 0) ? (0f - extents.y) : extents.y), center.z + (((i & 4) == 0) ? (0f - extents.z) : extents.z)); Vector3 val2 = ((Matrix4x4)(ref mat)).MultiplyPoint3x4(val); if (!any) { b = new Bounds(val2, Vector3.zero); any = true; } else { ((Bounds)(ref b)).Encapsulate(val2); } } } public static bool BoundsOf(Transform root, GameObject skip, out Bounds b) { //IL_0001: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) b = default(Bounds); bool any = false; Matrix4x4 worldToLocalMatrix = root.worldToLocalMatrix; Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if ((!((Object)(object)skip != (Object)null) || !((Component)val).transform.IsChildOf(skip.transform)) && MeshOf(val, out var m)) { Grow(ref b, ref any, m, worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix); } } return any; } } internal static class Models { private sealed class Pix { public Color32[] C; public int W; public int H; } private static readonly Dictionary<string, Template> _cache = new Dictionary<string, Template>(); private static Transform _holder; private static readonly HashSet<string> _shadersLogged = new HashSet<string>(); private static readonly Dictionary<int, Pix> _pix = new Dictionary<int, Pix>(); private static readonly Dictionary<string, Texture2D> _recolored = new Dictionary<string, Texture2D>(); public static Template Get(Flower f) { return Get(f, null, float.NaN); } public static Template Get(Flower f, string modelLabel, float hueOverride) { string text = f.EffModels(modelLabel); string text2 = f.EffOnly(modelLabel) ?? ""; float hue = (float.IsNaN(hueOverride) ? f.Hue.Value : hueOverride); string key = text + "|" + f.AutoUpright.Value + "|" + Cfg.UprightRatio.Value.ToString("0.00") + "|" + text2 + "|" + f.Keep.Value.ToString("0") + "|" + f.Sway.Value.ToString("0") + "|" + f.Push.Value + "|" + f.NearFade.Value + "|" + f.Bloom.Value.ToString("0") + "|" + f.Split.Value + "|" + hue.ToString("0"); if (_cache.TryGetValue(key, out var value)) { return value; } try { value = Build(text, f.AutoUpright.Value, text2, f.Keep.Value, f.Sway.Value, f.Push.Value, f.NearFade.Value, f.Bloom.Value, f.Split.Value, hue); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Flower model '" + text + "' failed: " + ex)); value = null; } _cache[key] = value; return value; } private static GameObject Find(string name) { GameObject val = null; if ((Object)(object)ZNetScene.instance != (Object)null) { val = ZNetScene.instance.GetPrefab(name); } if ((Object)(object)val == (Object)null && (Object)(object)ObjectDB.instance != (Object)null) { val = ObjectDB.instance.GetItemPrefab(name); } if ((Object)(object)val == (Object)null && (Object)(object)ClutterSystem.instance != (Object)null && ClutterSystem.instance.m_clutter != null) { foreach (Clutter item in ClutterSystem.instance.m_clutter) { if (item != null && (Object)(object)item.m_prefab != (Object)null && (string.Equals(item.m_name, name, StringComparison.OrdinalIgnoreCase) || string.Equals(((Object)item.m_prefab).name, name, StringComparison.OrdinalIgnoreCase))) { val = item.m_prefab; break; } } } return val; } private static void EnsureHolder() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0025: Expected O, but got Unknown if (!((Object)(object)_holder != (Object)null)) { GameObject val = new GameObject("FlowerVases_templates"); val.SetActive(false); Object.DontDestroyOnLoad((Object)val); _holder = val.transform; } } private static Template Build(string csv, bool auto, string only, float keep, float sway, bool push, bool nearFade, float bloom, bool split, float hue) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; string text = null; string[] array = csv.Split(','); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length != 0) { val = Find(text2); if ((Object)(object)val != (Object)null) { text = text2; break; } } } if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Flower model: none of the prefabs '" + csv + "' exist (yet). Check the ModelPrefabs setting.")); return null; } EnsureHolder(); GameObject val2 = new GameObject("tpl_" + text); val2.transform.SetParent(_holder, false); GameObject val3 = Object.Instantiate<GameObject>(val, val2.transform, false); ((Object)val3).name = "model"; val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; InstanceRenderer component = val3.GetComponent<InstanceRenderer>(); if ((Object)(object)component != (Object)null && (Object)(object)component.m_mesh != (Object)null && (Object)(object)val3.GetComponentInChildren<MeshRenderer>(true) == (Object)null) { GameObject val4 = new GameObject("instanced"); val4.transform.SetParent(val3.transform, false); val4.transform.localScale = ((((Vector3)(ref component.m_scale)).sqrMagnitude > 1E-06f) ? component.m_scale : Vector3.one); val4.AddComponent<MeshFilter>().sharedMesh = component.m_mesh; ((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = component.m_material; auto = false; } if (only.Length > 0) { Transform val5 = FindDeep(val3.transform, only); if ((Object)(object)val5 != (Object)null) { Transform val6 = val5; while ((Object)(object)val6 != (Object)null) { ((Component)val6).gameObject.SetActive(true); if ((Object)(object)val6 == (Object)(object)val3.transform) { break; } val6 = val6.parent; } LODGroup[] componentsInChildren = val3.GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } List<Object> list = new List<Object>(); Renderer[] componentsInChildren2 = val3.GetComponentsInChildren<Renderer>(true); foreach (Renderer val7 in componentsInChildren2) { if (!((Component)val7).transform.IsChildOf(val5)) { list.Add((Object)(object)val7); } } Kill(list); } else { Plugin.Log.LogWarning((object)("Flower model '" + text + "': no object named '" + only + "' in it; using the whole model.")); } } Strip(val3); Tune(val3, text, sway, push, nearFade, hue >= 0f); if (Mathf.Abs(bloom - 100f) > 0.5f) { Bloom(val3, val2.transform, text, bloom); } if (hue >= 0f) { Recolor(val3, text, hue); } if (Geo.BoundsOf(val2.transform, null, out var b)) { Vector3 size = ((Bounds)(ref b)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-08f)) { if (split) { Template template = BuildSplit(val2, val3, text, b); if (template != null) { return template; } } Vector3 size2 = ((Bounds)(ref b)).size; int num = ((!(size2.x >= size2.y) || !(size2.x >= size2.z)) ? ((size2.y >= size2.z) ? 1 : 2) : 0); float num2 = num switch { 1 => size2.y, 0 => size2.x, _ => size2.z, }; if (num != 1 && num2 < size2.y * Cfg.UprightRatio.Value) { num = 1; } bool readable; float num3 = HeadSide(val2.transform, b, num, out readable); string text3 = "kept as is"; if (auto && num != 1) { text3 = "long side " + "XYZ"[num] + " turned up"; } if (auto) { Quaternion localRotation = Quaternion.identity; switch (num) { case 0: localRotation = Quaternion.Euler(0f, 0f, (num3 >= 0f) ? 90f : (-90f)); break; case 2: localRotation = Quaternion.Euler((num3 >= 0f) ? (-90f) : 90f, 0f, 0f); break; default: if (num3 < -0.1f) { localRotation = Quaternion.Euler(180f, 0f, 0f); } break; } val3.transform.localRotation = localRotation; if (num == 1 && num3 < -0.1f) { text3 = "flipped (head was at the bottom)"; } } if (!Geo.BoundsOf(val2.transform, null, out b)) { Object.Destroy((Object)(object)val2); return null; } if (Mathf.Abs(keep) < 99.5f) { if (Trim(val2.transform, b, keep) > 0) { text3 = text3 + "; cut to " + keep.ToString("0") + "%"; if (!Geo.BoundsOf(val2.transform, null, out b)) { Object.Destroy((Object)(object)val2); return null; } } else { Plugin.Log.LogWarning((object)("Flower model '" + text + "': could not cut it (mesh not readable or nothing left).")); } } float y = ((Bounds)(ref b)).size.y; if (y < 0.0001f) { Object.Destroy((Object)(object)val2); return null; } float num4 = 1f / y; Vector3 val8 = default(Vector3); ((Vector3)(ref val8))..ctor(((Bounds)(ref b)).center.x, ((Bounds)(ref b)).min.y, ((Bounds)(ref b)).center.z); Vector3 localScale = val3.transform.localScale; val3.transform.localScale = new Vector3(localScale.x * num4, localScale.y * num4, localScale.z * num4); val3.transform.localPosition = (0f - num4) * val8; if (Cfg.LogModels.Value) { Plugin.Log.LogInfo((object)("Flower model '" + text + "': size " + size2.x.ToString("0.###") + " x " + size2.y.ToString("0.###") + " x " + size2.z.ToString("0.###") + " (" + text3 + "; mesh readable: " + readable + ", head side " + num3.ToString("0.00") + ")")); } return new Template { Wrapper = val2, Source = text }; } } Plugin.Log.LogWarning((object)("Flower model '" + text + "' has no visible mesh after stripping; skipped.")); Object.Destroy((Object)(object)val2); return null; } private static Transform FindDeep(Transform root, string name) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (string.Equals(((Object)val).name, name, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static int Trim(Transform wrapper, Bounds b, float keep) { //IL_003d: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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) float num = Mathf.Clamp01(Mathf.Abs(keep) / 100f); bool flag = keep > 0f; float cutY = (flag ? (((Bounds)(ref b)).min.y + (1f - num) * ((Bounds)(ref b)).size.y) : (((Bounds)(ref b)).min.y + num * ((Bounds)(ref b)).size.y)); Matrix4x4 worldToLocalMatrix = wrapper.worldToLocalMatrix; int num2 = 0; MeshFilter[] componentsInChildren = ((Component)wrapper).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { Mesh sharedMesh = val.sharedMesh; if (!((Object)(object)sharedMesh == (Object)null) && sharedMesh.isReadable) { Matrix4x4 mat = worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; Mesh val2 = TrimMesh(sharedMesh, mat, cutY, flag); if ((Object)(object)val2 != (Object)null) { val.sharedMesh = val2; num2++; } } } return num2; } private static Mesh TrimMesh(Mesh m, Matrix4x4 mat, float cutY, bool upper) { //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) Vector3[] vertices = m.vertices; Vector3[] normals = m.normals; Vector2[] uv = m.uv; Vector2[] uv2 = m.uv2; Color[] colors = m.colors; Vector4[] tangents = m.tangents; bool flag = normals.Length == vertices.Length; bool flag2 = uv.Length == vertices.Length; bool flag3 = uv2.Length == vertices.Length; bool flag4 = colors.Length == vertices.Length; bool flag5 = tangents.Length == vertices.Length; int[] array = new int[vertices.Length]; for (int i = 0; i < array.Length; i++) { array[i] = -1; } List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<Vector2> list4 = new List<Vector2>(); List<Color> list5 = new List<Color>(); List<Vector4> list6 = new List<Vector4>(); int subMeshCount = m.subMeshCount; List<int>[] array2 = new List<int>[subMeshCount]; int num = 0; for (int j = 0; j < subMeshCount; j++) { array2[j] = new List<int>(); int[] triangles = m.GetTriangles(j); for (int k = 0; k + 2 < triangles.Length; k += 3) { float num2 = (((Matrix4x4)(ref mat)).MultiplyPoint3x4(vertices[triangles[k]]).y + ((Matrix4x4)(ref mat)).MultiplyPoint3x4(vertices[triangles[k + 1]]).y + ((Matrix4x4)(ref mat)).MultiplyPoint3x4(vertices[triangles[k + 2]]).y) / 3f; if (upper ? (num2 < cutY) : (num2 > cutY)) { continue; } for (int l = 0; l < 3; l++) { int num3 = triangles[k + l]; if (array[num3] < 0) { array[num3] = list.Count; list.Add(vertices[num3]); if (flag) { list2.Add(normals[num3]); } if (flag2) { list3.Add(uv[num3]); } if (flag3) { list4.Add(uv2[num3]); } if (flag4) { list5.Add(colors[num3]); } if (flag5) { list6.Add(tangents[num3]); } } array2[j].Add(array[num3]); } num++; } } if (num == 0) { return null; } Mesh val = new Mesh(); ((Object)val).name = ((Object)m).name + "_cut"; val.SetVertices(list); if (flag) { val.SetNormals(list2); } if (flag2) { val.SetUVs(0, list3); } if (flag3) { val.SetUVs(1, list4); } if (flag4) { val.SetColors(list5); } if (flag5) { val.SetTangents(list6); } val.subMeshCount = subMeshCount; for (int n = 0; n < subMeshCount; n++) { val.SetTriangles(array2[n], n); } val.RecalculateBounds(); return val; } private static bool Has(string lo, params string[] parts) { foreach (string value in parts) { if (lo.Contains(value)) { return true; } } return false; } private static void Tune(GameObject inst, string used, float sway, bool push, bool nearFade, bool recolor) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Invalid comparison between Unknown and I4 //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Invalid comparison between Unknown and I4 bool flag = sway < 99.5f || sway > 100.5f || !push || !nearFade || recolor; Renderer[] componentsInChildren = inst.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] array = (flag ? val.materials : val.sharedMaterials); Material[] array2 = array; foreach (Material val2 in array2) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2.shader == (Object)null) { continue; } Shader shader = val2.shader; StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); int propertyCount = shader.GetPropertyCount(); for (int k = 0; k < propertyCount; k++) { string propertyName = shader.GetPropertyName(k); ShaderPropertyType propertyType = shader.GetPropertyType(k); bool flag2 = (int)propertyType == 2 || (int)propertyType == 3; stringBuilder2.Append(propertyName).Append(flag2 ? "(f) " : " "); if (!flag || !flag2) { continue; } string text = propertyName.ToLowerInvariant(); float num = val2.GetFloat(propertyName); if ((sway < 99.5f || sway > 100.5f) && Sway.IsMotion(propertyName)) { float num2 = Sway.Scaled(propertyName, num, sway); if (num2 != num) { stringBuilder.Append(propertyName).Append("=").Append(num.ToString("0.###")) .Append("->") .Append(num2.ToString("0.###")) .Append(" "); val2.SetFloat(propertyName, num2); } } else if (!push && text.Contains("push")) { stringBuilder.Append(propertyName).Append("=").Append(num.ToString("0.###")) .Append("->0 "); val2.SetFloat(propertyName, 0f); } else if (!nearFade && Has(text, "camcull", "nearfade", "camfade")) { stringBuilder.Append(propertyName).Append("=").Append(num.ToString("0.###")) .Append("->0 "); val2.SetFloat(propertyName, 0f); } } if (Cfg.LogModels.Value) { if (stringBuilder.Length > 0) { Plugin.Log.LogInfo((object)("Material tuning '" + used + "' material '" + ((Object)val2).name + "' shader '" + ((Object)shader).name + "': changed [" + stringBuilder.ToString().Trim() + "]")); } if (_shadersLogged.Add(((Object)shader).name)) { Plugin.Log.LogInfo((object)("Shader '" + ((Object)shader).name + "' properties: " + stringBuilder2.ToString().Trim())); } } } if (flag) { val.materials = array; } } } private static Pix PixelsOf(Texture tex) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tex == (Object)null) { return null; } int instanceID = ((Object)tex).GetInstanceID(); if (_pix.TryGetValue(instanceID, out var value)) { return value; } try { int num = Mathf.Min(tex.width, 1024); int num2 = Mathf.Min(tex.height, 1024); RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0); Graphics.Blit(tex, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); val.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); value = new Pix { C = val.GetPixels32(), W = num, H = num2 }; Object.Destroy((Object)(object)val); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read texture '" + ((Object)tex).name + "': " + ex.Message)); value = null; } _pix[instanceID] = value; return value; } private static bool IsBloom(Pix p, Vector2 uv) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (p == null) { return false; } int num = Mathf.Clamp((int)((uv.x - Mathf.Floor(uv.x)) * (float)p.W), 0, p.W - 1); int num2 = Mathf.Clamp((int)((uv.y - Mathf.Floor(uv.y)) * (float)p.H), 0, p.H - 1); return IsBloomTexel(p.C[num2 * p.W + num]); } private static bool IsBloomTexel(Color32 c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0029: Unknown result type (might be due to invalid IL or missing references) if (c.a < 40) { return false; } if ((float)(int)c.g >= (float)(int)c.r * 1.05f) { return !((float)(int)c.g >= (float)(int)c.b * 1.05f); } return true; } private static void Recolor(GameObject inst, string used, float hueDeg) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = inst.GetComponentsInChildren<Renderer>(true); float num = default(float); float num2 = default(float); float num3 = default(float); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val == (Object)null) { continue; } Texture mainTexture = val.mainTexture; if ((Object)(object)mainTexture != (Object)null) { Texture2D val2 = HueTexture(mainTexture, hueDeg, emissive: false, used); if ((Object)(object)val2 != (Object)null) { val.mainTexture = (Texture)(object)val2; } } string[] array = new string[2] { "_EmissiveTex", "_EmissionMap" }; foreach (string text in array) { if (!val.HasProperty(text)) { continue; } Texture texture = val.GetTexture(text); if (!((Object)(object)texture == (Object)null)) { Texture2D val3 = HueTexture(texture, hueDeg, emissive: true, used); if ((Object)(object)val3 != (Object)null) { val.SetTexture(text, (Texture)(object)val3); } } } if (!val.HasProperty("_EmissionColor")) { continue; } Color.RGBToHSV(val.GetColor("_EmissionColor"), ref num, ref num2, ref num3); if (num3 > 0.01f && num2 >= 0.1f) { val.SetColor("_EmissionColor", Color.HSVToRGB(hueDeg / 360f, num2, num3, true)); if (Cfg.LogModels.Value) { Plugin.Log.LogInfo((object)("Recolor '" + used + "': emission colour of '" + ((Object)val).name + "' set to hue " + hueDeg.ToString("0"))); } } } } } private static Texture2D HueTexture(Texture tex, float hueDeg, bool emissive, string used) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) string key = ((Object)tex).GetInstanceID() + "|" + hueDeg.ToString("0.#") + (emissive ? "|e" : ""); if (_recolored.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Pix pix = PixelsOf(tex); if (pix == null) { return null; } Color32[] array = (Color32[])(object)new Color32[pix.C.Length]; int num = 0; float num2 = hueDeg / 360f; float num3 = default(float); float num4 = default(float); float num5 = default(float); for (int i = 0; i < array.Length; i++) { Color32 val = (array[i] = pix.C[i]); Color.RGBToHSV(Color32.op_Implicit(val), ref num3, ref num4, ref num5); if (emissive) { if (num5 < 0.05f || num4 < 0.1f) { continue; } } else if (!IsBloomTexel(val) || num4 < 0.15f) { continue; } Color32 val2 = Color32.op_Implicit(Color.HSVToRGB(num2, num4, num5)); val2.a = val.a; array[i] = val2; num++; } value = new Texture2D(pix.W, pix.H, (TextureFormat)4, true); value.SetPixels32(array); value.Apply(true); ((Texture)value).wrapMode = tex.wrapMode; ((Texture)value).filterMode = tex.filterMode; ((Texture)value).anisoLevel = tex.anisoLevel; ((Object)value).name = ((Object)tex).name + "_hue" + hueDeg.ToString("0"); _recolored[key] = value; if (Cfg.LogModels.Value) { Plugin.Log.LogInfo((object)("Recolor '" + used + "': " + (emissive ? "emission " : "") + "texture '" + ((Object)tex).name + "' " + pix.W + "x" + pix.H + ", " + num + " texels set to hue " + hueDeg.ToString("0"))); } return value; } private static void Bloom(GameObject inst, Transform wrapper, string used, float percent) { //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0228: 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) float num = percent / 100f; int num2 = 0; int num3 = 0; MeshFilter[] componentsInChildren = inst.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { Mesh sharedMesh = val.sharedMesh; Renderer component = ((Component)val).GetComponent<Renderer>(); if ((Object)(object)sharedMesh == (Object)null || !sharedMesh.isReadable || (Object)(object)component == (Object)null) { continue; } Material[] sharedMaterials = component.sharedMaterials; Vector3[] vertices = sharedMesh.vertices; Vector3[] normals = sharedMesh.normals; Vector2[] uv = sharedMesh.uv; Color[] colors = sharedMesh.colors; if (uv.Length != vertices.Length) { continue; } bool flag = normals.Length == vertices.Length; bool flag2 = colors.Length == vertices.Length; List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<Color> list4 = new List<Color>(); int subMeshCount = sharedMesh.subMeshCount; List<int>[] array = new List<int>[subMeshCount]; for (int j = 0; j < subMeshCount; j++) { array[j] = new List<int>(); Pix p = PixelsOf((sharedMaterials.Length != 0) ? sharedMaterials[Mathf.Min(j, sharedMaterials.Length - 1)].mainTexture : null); int[] triangles = sharedMesh.GetTriangles(j); for (int k = 0; k + 2 < triangles.Length; k += 3) { int num4 = triangles[k]; int num5 = triangles[k + 1]; int num6 = triangles[k + 2]; Vector2 uv2 = (uv[num4] + uv[num5] + uv[num6]) / 3f; bool flag3 = IsBloom(p, uv2); num2++; Vector3 val2 = (vertices[num4] + vertices[num5] + vertices[num6]) / 3f; if (flag3) { num3++; } int[] array2 = new int[3] { num4, num5, num6 }; for (int l = 0; l < 3; l++) { int num7 = array2[l]; list.Add(flag3 ? (val2 + (vertices[num7] - val2) * num) : vertices[num7]); list3.Add(uv[num7]); if (flag) { list2.Add(normals[num7]); } if (flag2) { list4.Add(colors[num7]); } array[j].Add(list.Count - 1); } } } Mesh val3 = new Mesh(); ((Object)val3).name = ((Object)sharedMesh).name + "_bloom"; val3.SetVertices(list); val3.SetUVs(0, list3); if (flag) { val3.SetNormals(list2); } if (flag2) { val3.SetColors(list4); } val3.subMeshCount = subMeshCount; for (int m = 0; m < subMeshCount; m++) { val3.SetTriangles(array[m], m); } val3.RecalculateBounds(); val.sharedMesh = val3; } if (Cfg.LogModels.Value) { Plugin.Log.LogInfo((object)("Bloom size '" + used + "': " + num3 + " of " + num2 + " triangles counted as blooms, scaled to " + percent.ToString("0") + "%")); } } private static Template BuildSplit(GameObject wrapperGo, GameObject inst, string used, Bounds whole) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: 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_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Expected O, but got Unknown //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05ac: Unknown result type (might be due to invalid IL or missing references) //IL_06db: Unknown result type (might be due to invalid IL or missing references) //IL_06e2: Expected O, but got Unknown //IL_06f9: Unknown result type (might be due to invalid IL or missing references) //IL_0700: Expected O, but got Unknown //IL_0731: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_07a4: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) MeshFilter val = null; MeshFilter[] componentsInChildren = inst.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren) { if ((Object)(object)val2.sharedMesh != (Object)null && val2.sharedMesh.isReadable && (Object)(object)((Component)val2).GetComponent<MeshRenderer>() != (Object)null) { val = val2; break; } } if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Split '" + used + "': no readable mesh, using the whole model.")); return null; } Mesh sharedMesh = val.sharedMesh; Material[] sharedMaterials = ((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterials; Matrix4x4 val3 = wrapperGo.transform.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; Vector3[] vertices = sharedMesh.vertices; Vector2[] uv = sharedMesh.uv; Vector3[] normals = sharedMesh.normals; Color[] colors = sharedMesh.colors; bool flag = uv.Length == vertices.Length; bool flag2 = normals.Length == vertices.Length; bool flag3 = colors.Length == vertices.Length; Vector3[] array = (Vector3[])(object)new Vector3[vertices.Length]; for (int j = 0; j < array.Length; j++) { array[j] = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(vertices[j]); } int[] parent = new int[array.Length]; for (int k = 0; k < parent.Length; k++) { parent[k] = k; } Func<int, int> func = null; func = delegate(int x) { while (parent[x] != x) { parent[x] = parent[parent[x]]; x = parent[x]; } return x; }; int subMeshCount = sharedMesh.subMeshCount; List<int[]> list = new List<int[]>(); for (int num = 0; num < subMeshCount; num++) { int[] triangles = sharedMesh.GetTriangles(num); for (int num2 = 0; num2 + 2 < triangles.Length; num2 += 3) { list.Add(new int[4] { num, triangles[num2], triangles[num2 + 1], triangles[num2 + 2] }); int num3 = func(triangles[num2]); int num4 = func(triangles[num2 + 1]); int arg = func(triangles[num2 + 2]); parent[num4] = num3; parent[func(arg)] = func(num3); } } Dictionary<int, List<int[]>> dictionary = new Dictionary<int, List<int[]>>(); foreach (int[] item in list) { int key = func(item[1]); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new List<int[]>()); } value.Add(item); } List<GameObject> list3 = new List<GameObject>(); int num5 = 0; int num6 = 0; StringBuilder stringBu
plugins/EinsteinCrew-PuckosCarePackage/Pucko-ForgeofActualPotential/ForgeofActualPotential.dll
Decompiled 2 weeks 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.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Managers; using Jotunn.Utils; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace Pucko.FoAP; internal static class ArmorBonus { private static readonly string[] Table; private static readonly Dictionary<string, string> BuiltIn; private static readonly Dictionary<string, string> ClassOv; private static List<KeyValuePair<string, float>> Heavy; private static List<KeyValuePair<string, float>> Light; private static List<KeyValuePair<string, float>> Mage; private static string[] Order; private const string SeName = "FoAP_ArmorClass"; private static readonly int SeHash; private static float _timer; private static float _bonusMaxHealth; private static float _bonusMaxStamina; private static float _bonusMaxEitr; public static string LastSummary; private static readonly FieldInfo HelmetF; private static readonly FieldInfo ChestF; private static readonly FieldInfo LegsF; private static readonly MethodInfo UpdateEquip; private static readonly HashSet<string> Known; static ArmorBonus() { Table = new string[57] { "HelmetLeather|head|light|0|", "ArmorLeatherChest|chest|light|0|", "ArmorLeatherLegs|legs|light|0|", "ArmorBerserkerChest|chest|light|1|BerserkerArmor", "ArmorBerserkerLegs|legs|light|1|BerserkerArmor", "HelmetTrollLeather|head|light|1|TrollArmor", "ArmorTrollLeatherChest|chest|light|1|TrollArmor", "ArmorTrollLeatherLegs|legs|light|1|TrollArmor", "HelmetBronze|head|heavy|1|", "ArmorBronzeChest|chest|heavy|1|", "ArmorBronzeLegs|legs|heavy|1|", "HelmetRoot|head|light|2|RootArmor", "ArmorRootChest|chest|light|2|RootArmor", "ArmorRootLegs|legs|light|2|RootArmor", "HelmetIron|head|heavy|2|", "ArmorIronChest|chest|heavy|2|", "ArmorIronLegs|legs|heavy|2|", "HelmetFenring|head|light|3|FenringArmor", "ArmorFenringChest|chest|light|3|FenringArmor", "ArmorFenringLegs|legs|light|3|FenringArmor", "HelmetDrake|head|heavy|3|", "ArmorWolfChest|chest|heavy|3|", "ArmorWolfLegs|legs|heavy|3|", "HelmetBerserkerUndead|head|light|4|BerserkerUndeadArmor", "ArmorBerserkerUndeadChest|chest|light|4|BerserkerUndeadArmor", "ArmorBerserkerUndeadLegs|legs|light|4|BerserkerUndeadArmor", "HelmetLox|head|light|4|LoxArmor", "ArmorLoxChest|chest|light|4|LoxArmor", "ArmorLoxLegs|legs|light|4|LoxArmor", "HelmetPadded|head|heavy|4|", "ArmorPaddedCuirass|chest|heavy|4|", "ArmorPaddedGreaves|legs|heavy|4|", "HelmetBerserkerHood|head|light|1|BerserkerArmor", "HelmetCarapace|head|heavy|5|", "HelmetMage|head|mage|5|", "ArmorCarapaceChest|chest|heavy|5|", "ArmorMageChest|chest|mage|5|", "ArmorCarapaceLegs|legs|heavy|5|", "ArmorMageLegs|legs|mage|5|", "HelmetAshlandsMediumHood|head|light|6|AshlandsMediumArmor", "ArmorAshlandsMediumChest|chest|light|6|AshlandsMediumArmor", "ArmorAshlandsMediumlegs|legs|light|6|AshlandsMediumArmor", "HelmetFlametal|head|heavy|6|", "HelmetMage_Ashlands|head|mage|6|", "ArmorFlametalChest|chest|heavy|6|", "ArmorMageChest_Ashlands|chest|mage|6|", "ArmorFlametalLegs|legs|heavy|6|", "ArmorMageLegs_Ashlands|legs|mage|6|", "HelmetDNMediumHood|head|light|7|DeepNorthMediumArmor", "ArmorDeepNorthMediumChest|chest|light|7|DeepNorthMediumArmor", "ArmorDeepNorthMediumlegs|legs|light|7|DeepNorthMediumArmor", "HelmetDNHeavy|head|heavy|7|", "HelmetDNMage|head|mage|7|", "ArmorDeepNorthHeavyChest|chest|heavy|7|", "ArmorDeepNorthMageChest|chest|mage|7|", "ArmorDeepNorthHeavylegs|legs|heavy|7|", "ArmorDeepNorthMagelegs|legs|mage|7|" }; BuiltIn = new Dictionary<string, string>(StringComparer.Ordinal); ClassOv = new Dictionary<string, string>(StringComparer.Ordinal); Heavy = new List<KeyValuePair<string, float>>(); Light = new List<KeyValuePair<string, float>>(); Mage = new List<KeyValuePair<string, float>>(); Order = new string[3] { "chest", "head", "legs" }; SeHash = StringExtensionMethods.GetStableHashCode("FoAP_ArmorClass"); LastSummary = ""; HelmetF = AccessTools.Field(typeof(Humanoid), "m_helmetItem"); ChestF = AccessTools.Field(typeof(Humanoid), "m_chestItem"); LegsF = AccessTools.Field(typeof(Humanoid), "m_legItem"); UpdateEquip = AccessTools.Method(typeof(Humanoid), "UpdateEquipmentStatusEffects", (Type[])null, (Type[])null); Known = new HashSet<string> { "healthregen", "staminaregen", "eitrregen", "movespeed", "adrenalinegain", "attackstamina", "runstamina", "armor", "physicaldamage", "elementaldamage", "spiritdamage", "alldamage", "maxhealth", "maxstamina", "maxeitr" }; string[] table = Table; for (int i = 0; i < table.Length; i++) { string[] array = table[i].Split('|'); BuiltIn[array[0]] = array[2]; } } public static void Reload() { Heavy = Stats(Cfg.AbHeavy.Value); Light = Stats(Cfg.AbLight.Value); Mage = Stats(Cfg.AbMage.Value); List<string> list = new List<string>(); string[] array = (Cfg.AbOrder.Value ?? "").Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim().ToLowerInvariant(); switch (text) { case "chest": case "head": case "legs": list.Add(text); break; } } array = new string[3] { "chest", "head", "legs" }; foreach (string item in array) { if (!list.Contains(item)) { list.Add(item); } } Order = list.ToArray(); ClassOv.Clear(); foreach (KeyValuePair<string, string> item2 in Parse.Pairs(Cfg.AbClassOverrides.Value)) { ClassOv[item2.Key] = item2.Value.ToLowerInvariant(); } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && UpdateEquip != null) { try { UpdateEquip.Invoke(localPlayer, null); } catch (Exception) { } } _timer = 99f; } private static List<KeyValuePair<string, float>> Stats(string text) { List<KeyValuePair<string, float>> list = new List<KeyValuePair<string, float>>(); foreach (KeyValuePair<string, string> item in Parse.Pairs(text)) { string text2 = item.Key.Replace(" ", "").ToLowerInvariant(); if (!Known.Contains(text2)) { Plugin.Log.LogWarning((object)("Max-level armor: unknown stat '" + item.Key + "' ignored")); } else { list.Add(new KeyValuePair<string, float>(text2, Parse.F(item.Value, 0f))); } } return list; } public static ItemData Piece(Humanoid h, string slot) { object? value = ((slot == "head") ? HelmetF : ((slot == "chest") ? ChestF : LegsF)).GetValue(h); return (ItemData)((value is ItemData) ? value : null); } public static string ClassOf(ItemData it) { string key = (((Object)(object)it.m_dropPrefab != (Object)null) ? ((Object)it.m_dropPrefab).name : ""); if (ClassOv.TryGetValue(key, out var value)) { return value; } if (BuiltIn.TryGetValue(key, out value)) { return value; } if (it.m_shared.m_eitrRegenModifier > 0f) { return "mage"; } if (it.m_shared.m_movementModifier <= -0.04f) { return "heavy"; } return "light"; } public static int RankFromProgress(float lowest) { if (lowest >= 0.9999f) { return 2; } if (lowest >= (float)Mathf.Clamp(Cfg.AbRankIProgress.Value, 1, 100) / 100f - 0.0001f) { return 1; } return 0; } public static int Rank(Humanoid h) { if (!Cfg.Enabled.Value || !Cfg.AbEnabled.Value || (Object)(object)h == (Object)null) { return 0; } float num = 1f; string[] array = new string[3] { "head", "chest", "legs" }; foreach (string slot in array) { ItemData val = Piece(h, slot); if (val == null) { return 0; } num = Mathf.Min(num, Plan.Progress(val, val.m_quality)); } return RankFromProgress(num); } public static float RankFactor(int rank) { if (rank < 2) { if (rank != 1) { return 0f; } return (float)Mathf.Clamp(Cfg.AbRankIStrength.Value, 0, 100) / 100f; } return 1f; } public static bool Qualifies(Humanoid h) { return Rank(h) > 0; } public static ItemData Donor(Humanoid h) { List<ItemData> list = new List<ItemData>(); string[] array = new string[3] { "head", "chest", "legs" }; foreach (string slot in array) { list.Add(Piece(h, slot)); } Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (ItemData item in list) { string setName = item.m_shared.m_setName; if (!string.IsNullOrEmpty(setName)) { dictionary.TryGetValue(setName, out var value); dictionary[setName] = value + 1; if (dictionary[setName] >= item.m_shared.m_setSize) { return null; } } } array = Order; foreach (string slot2 in array) { ItemData val = Piece(h, slot2); if (val != null && (Object)(object)val.m_shared.m_setStatusEffect != (Object)null && !string.IsNullOrEmpty(val.m_shared.m_setName)) { return val; } } return null; } private static float Strength(Player p) { float num = Mathf.Clamp01((float)Cfg.AbFloor.Value / 100f); if (Cfg.AbTrinketFull.Value) { SEMan sEMan = ((Character)p).GetSEMan(); foreach (ItemData equippedItem in ((Humanoid)p).GetInventory().GetEquippedItems()) { StatusEffect fullAdrenalineSE = equippedItem.m_shared.m_fullAdrenalineSE; if ((Object)(object)fullAdrenalineSE != (Object)null && sEMan.HaveStatusEffect(fullAdrenalineSE.NameHash())) { return 1f; } } } float maxAdrenaline = ((Character)p).GetMaxAdrenaline(); float num2 = ((maxAdrenaline > 0.001f) ? Mathf.Clamp01(p.GetAdrenaline() / maxAdrenaline) : 0f); return num + (1f - num) * num2; } public static void Update(float dt) { _timer += dt; if (_timer < 0.25f) { return; } _timer = 0f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return; } SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan == null) { return; } int num = Rank((Humanoid)(object)localPlayer); if (num <= 0) { if (sEMan.HaveStatusEffect(SeHash)) { sEMan.RemoveStatusEffect(SeHash, true); } _bonusMaxHealth = (_bonusMaxStamina = (_bonusMaxEitr = 0f)); LastSummary = ""; return; } Dictionary<string, float> dictionary = new Dictionary<string, float>(); List<string> list = new List<string>(); string[] array = new string[3] { "head", "chest", "legs" }; foreach (string slot in array) { string text = ClassOf(Piece((Humanoid)(object)localPlayer, slot)); list.Add(text); foreach (KeyValuePair<string, float> item in (text == "heavy") ? Heavy : ((text == "mage") ? Mage : Light)) { dictionary.TryGetValue(item.Key, out var value); dictionary[item.Key] = value + item.Value / 3f; } } float s = Strength(localPlayer) * RankFactor(num); StatusEffect statusEffect = sEMan.GetStatusEffect(SeHash); SE_Stats val = (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null); if ((Object)(object)val == (Object)null) { SE_Stats val2 = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val2).name = "FoAP_ArmorClass"; ((StatusEffect)val2).m_name = ((num >= 2) ? "Class Mastery II" : "Class Mastery I"); ((StatusEffect)val2).m_ttl = 0f; StatusEffect val3 = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")) : null); if ((Object)(object)val3 != (Object)null) { ((StatusEffect)val2).m_icon = val3.m_icon; } sEMan.AddStatusEffect((StatusEffect)(object)val2, false, 0, 0f, (short)(-1)); StatusEffect statusEffect2 = sEMan.GetStatusEffect(SeHash); val = (SE_Stats)(object)((statusEffect2 is SE_Stats) ? statusEffect2 : null); if ((Object)(object)val == (Object)null) { return; } } Apply(val, dictionary, s, list, num); } private static void Apply(SE_Stats se, Dictionary<string, float> total, float s, List<string> classes, int rank) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; float num5 = 0f; float num6 = 0f; float num7 = 0f; float num8 = 0f; DamageTypes percentigeDamageModifiers = default(DamageTypes); _bonusMaxHealth = (_bonusMaxStamina = (_bonusMaxEitr = 0f)); StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair<string, float> item in total) { float num9 = item.Value * s; float num10 = num9 / 100f; switch (item.Key) { case "healthregen": num += num10; break; case "staminaregen": num2 += num10; break; case "eitrregen": num3 += num10; break; case "movespeed": num4 += num10; break; case "adrenalinegain": num5 += num10; break; case "attackstamina": num6 -= num10; break; case "runstamina": num7 -= num10; break; case "armor": num8 += item.Value * s; break; case "physicaldamage": percentigeDamageModifiers.m_blunt += num10; percentigeDamageModifiers.m_slash += num10; percentigeDamageModifiers.m_pierce += num10; break; case "elementaldamage": percentigeDamageModifiers.m_fire += num10; percentigeDamageModifiers.m_frost += num10; percentigeDamageModifiers.m_lightning += num10; percentigeDamageModifiers.m_poison += num10; break; case "spiritdamage": percentigeDamageModifiers.m_spirit += num10; break; case "alldamage": percentigeDamageModifiers.m_blunt += num10; percentigeDamageModifiers.m_slash += num10; percentigeDamageModifiers.m_pierce += num10; percentigeDamageModifiers.m_fire += num10; percentigeDamageModifiers.m_frost += num10; percentigeDamageModifiers.m_lightning += num10; percentigeDamageModifiers.m_poison += num10; percentigeDamageModifiers.m_spirit += num10; break; case "maxhealth": _bonusMaxHealth += num9; break; case "maxstamina": _bonusMaxStamina += num9; break; case "maxeitr": _bonusMaxEitr += num9; break; } stringBuilder.Append(Label(item.Key)).Append(": <color=orange>").Append(num9.ToString("+0.#;-0.#", CultureInfo.InvariantCulture)) .Append(IsFlat(item.Key) ? "" : "%") .Append("</color>\n"); } se.m_healthRegenMultiplier = 1f + num; se.m_staminaRegenMultiplier = 1f + num2; se.m_eitrRegenMultiplier = 1f + num3; se.m_speedModifier = num4; se.m_adrenalineModifier = num5; se.m_attackStaminaUseModifier = num6; se.m_runStaminaDrainModifier = num7; se.m_addArmor = num8; se.m_percentigeDamageModifiers = percentigeDamageModifiers; ((StatusEffect)se).m_name = ((rank >= 2) ? "Class Mastery II" : "Class Mastery I"); ((StatusEffect)se).m_tooltip = ((rank >= 2) ? "Class Mastery II: helmet, chest and legs all at their highest level" : ("Class Mastery I: helmet, chest and legs all at least " + Mathf.Clamp(Cfg.AbRankIProgress.Value, 1, 100) + "% of the way (reach the highest level on all three for Class Mastery II)")) + " (" + string.Join("/", classes.ToArray()) + ").\nStrength " + Mathf.RoundToInt(s * 100f) + "% (rank, adrenaline meter; the meter is full while a trinket buff runs).\n" + stringBuilder.ToString().TrimEnd('\n'); LastSummary = ((StatusEffect)se).m_tooltip; } private static bool IsFlat(string k) { switch (k) { default: return k == "armor"; case "maxhealth": case "maxstamina": case "maxeitr": return true; } } private static string Label(string k) { return k switch { "healthregen" => "Health regen", "staminaregen" => "Stamina regen", "eitrregen" => "Eitr regen", "movespeed" => "Move speed", "physicaldamage" => "Physical damage", "elementaldamage" => "Elemental damage", "spiritdamage" => "Spirit damage", "alldamage" => "All damage", "attackstamina" => "Cheaper attacks", "runstamina" => "Cheaper running", "armor" => "Armor", "adrenalinegain" => "Adrenaline gain", "maxhealth" => "Max health", "maxstamina" => "Max stamina", "maxeitr" => "Max eitr", _ => k, }; } public static void AddMax(ref float hp, ref float stamina, ref float eitr) { hp += _bonusMaxHealth; stamina += _bonusMaxStamina; eitr += _bonusMaxEitr; } } [HarmonyPatch(typeof(Humanoid), "HaveSetEffect")] internal static class BorrowSetPatch { private static void Postfix(Humanoid __instance, ItemData item, ref bool __result) { if (!__result && item != null && Cfg.AbBorrow.Value && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && ArmorBonus.Qualifies(__instance)) { ItemData val = ArmorBonus.Donor(__instance); if (val != null && val == item) { __result = true; } } } } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] internal static class MaxStatsPatch { private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { ArmorBonus.AddMax(ref hp, ref stamina, ref eitr); } } } internal static class Cfg { public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> LogDetails; public static ConfigEntry<float> TopChance; public static ConfigEntry<float> StartLevel; public static ConfigEntry<float> FloorChance; public static ConfigEntry<float> HalfwayLevels; public static ConfigEntry<float> Shape; public static ConfigEntry<bool> ScaleChance; public static ConfigEntry<bool> ArmorScaleChance; public static ConfigEntry<int> ChanceRefLevel; public static ConfigEntry<int> ArmorChanceRefLevel; public static ConfigEntry<string> LevelOverrides; public static ConfigEntry<float> ArmorTopChance; public static ConfigEntry<float> ArmorStartLevel; public static ConfigEntry<float> ArmorFloorChance; public static ConfigEntry<float> ArmorHalfwayLevels; public static ConfigEntry<float> ArmorShape; public static ConfigEntry<string> ArmorLevelOverrides; public static ConfigEntry<int> MaxRefineLevel; public static ConfigEntry<int> LevelsLostOnFailure; public static ConfigEntry<float> BreakChanceOnFailure; public static ConfigEntry<float> BreakRefund; public static ConfigEntry<float> IdolRefundOnFailure; public static ConfigEntry<float> PityPerFailure; public static ConfigEntry<float> PityCap; public static ConfigEntry<bool> KeepSeededRoll; public static ConfigEntry<bool> ShowChanceInForge; public static ConfigEntry<bool> ShowChanceMessage; public static ConfigEntry<bool> RepairOnRefine; public static ConfigEntry<bool> KeepItemData; public static ConfigEntry<float> ForgeTimeMultiplier; public static ConfigEntry<float> HeavySpeedCutAtMax; public static ConfigEntry<int> HeavySpeedFullLevel; public static ConfigEntry<bool> WeaponBlockEnabled; public static ConfigEntry<bool> WeaponBlockTwoHandedOnly; public static ConfigEntry<bool> HideBreakWarning; public static ConfigEntry<float> WeaponBlockShare; public static ConfigEntry<bool> HeavySpeedEnabled; public static ConfigEntry<bool> LightSpeedEnabled; public static ConfigEntry<float> LightSpeedAtMax; public static ConfigEntry<bool> RoundStats; public static ConfigEntry<bool> TidyTooltips; public static ConfigEntry<bool> CsEnabled; public static ConfigEntry<bool> CsMessage; public static ConfigEntry<bool> CsFlavour; public static ConfigEntry<float> CsChance0; public static ConfigEntry<float> CsChance100; public static ConfigEntry<int> CsExtraLevels; public static ConfigEntry<int> TooltipDecimals; public static ConfigEntry<bool> XiEnabled; public static ConfigEntry<float> XiFirstBonus; public static ConfigEntry<float> XiBonusDrop; public static ConfigEntry<int> XiMax; public static ConfigEntry<KeyCode> XiMoreKey; public static ConfigEntry<KeyCode> XiLessKey; public static ConfigEntry<bool> FdEnabled; public static ConfigEntry<bool> FdCanKill; public static ConfigEntry<bool> FdMessage; public static ConfigEntry<float> FdMinPct; public static ConfigEntry<float> FdMaxPct; public static ConfigEntry<float> FdHighMinPct; public static ConfigEntry<float> FdHighMaxPct; public static ConfigEntry<float> FdHighChanceSkill0; public static ConfigEntry<float> FdHighChanceSkill100; public static ConfigEntry<float> FdPerLevelPct; public static ConfigEntry<float> FdXChance0; public static ConfigEntry<float> FdXChance100; public static ConfigEntry<float> FdXMinPct; public static ConfigEntry<float> FdXMaxPct; public static ConfigEntry<string> MaxLevel; public static ConfigEntry<string> PowerAtMaxLevel; public static ConfigEntry<string> Growth; public static ConfigEntry<string> GrowthShape; public static ConfigEntry<string> GrowthExponent; public static ConfigEntry<float> DamageShare; public static ConfigEntry<string> ArmorMaxLevel; public static ConfigEntry<string> ArmorAtMaxLevel; public static ConfigEntry<string> BlockAtMaxLevel; public static ConfigEntry<string> ArmorGrowth; public static ConfigEntry<string> ArmorGrowthShape; public static ConfigEntry<string> ArmorGrowthExponent; public static ConfigEntry<string> TierOverrides; public static ConfigEntry<string> ItemOverrides; public static ConfigEntry<bool> AbEnabled; public static ConfigEntry<bool> AbBorrow; public static ConfigEntry<bool> AbTrinketFull; public static ConfigEntry<int> AbFloor; public static ConfigEntry<int> AbRankIProgress; public static ConfigEntry<int> AbRankIStrength; public static ConfigEntry<string> AbOrder; public static ConfigEntry<string> AbHeavy; public static ConfigEntry<string> AbLight; public static ConfigEntry<string> AbMage; public static ConfigEntry<string> AbClassOverrides; public static ConfigEntry<bool> GlowClamp; public static ConfigEntry<int> GlowFullLevels; public static ConfigEntry<bool> CustomizeEnabled; public static ConfigEntry<bool> FistGlow; public static ConfigEntry<float> GlowStrengthUnlock; public static ConfigEntry<float> GlowStrengthMin; public static ConfigEntry<float> GlowStrengthCapAtUnlock; public static ConfigEntry<float> GlowStrengthCapAtMax; public static ConfigEntry<float> GlowPresetsFirstAt; public static ConfigEntry<float> GlowPresetsAllAt; public static ConfigEntry<float> GlowPlacementUnlock; public static ConfigEntry<float> GlowFullColourUnlock; public static ConfigEntry<float> GlowMaxIntensity; public static ConfigEntry<float> GlowSizeUnlock; public static ConfigEntry<float> GlowSizeCapAtUnlock; public static ConfigEntry<float> GlowSizeCapAtMax; public static ConfigEntry<int> GlowPresetsFirstCount; public static ConfigEntry<bool> DropsEnabled; public static ConfigEntry<bool> RequirePlayerKill; public static ConfigEntry<bool> SummonsDrop; public static ConfigEntry<bool> DropAnnouncement; public static ConfigEntry<bool> LogDrops; public static ConfigEntry<float> GlobalMultiplier; public static ConfigEntry<float> ChancePerStar; public static ConfigEntry<float> EventMultiplier; public static ConfigEntry<float> WeaponShare; public static ConfigEntry<float> BaseChance; public static ConfigEntry<float> StrengthExponent; public static ConfigEntry<float> MinFactor; public static ConfigEntry<float> MaxFactor; public static ConfigEntry<float> CrowdRate; public static ConfigEntry<float> CrowdExponent; public static ConfigEntry<int> MaxStars; public static ConfigEntry<int> BossIdolsMin; public static ConfigEntry<int> BossIdolsMax; public static ConfigEntry<string> BossAverageIdols; public static ConfigEntry<string> ChanceOverrides; public static ConfigEntry<string> DropTierOverrides; public static ConfigEntry<string> Excluded; private static ConfigurationManagerAttributes AdminTag() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true }; } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, string d) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d, (AcceptableValueBase)null, new object[1] { AdminTag() })); } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, ConfigDescription d) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d.Description, d.AcceptableValues, new object[1] { AdminTag() })); } private static ConfigEntry<T> Loc<T>(ConfigFile c, string s, string k, T v, string d) { return c.Bind<T>(s, k, v, d); } private static ConfigEntry<T> Loc<T>(ConfigFile c, string s, string k, T v, ConfigDescription d) { return c.Bind<T>(s, k, v, d); } public static void Bind(ConfigFile c) { //IL_08ed: Unknown result type (might be due to invalid IL or missing references) //IL_08f7: Expected O, but got Unknown //IL_0972: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Expected O, but got Unknown //IL_0b31: Unknown result type (might be due to invalid IL or missing references) //IL_0b3b: Expected O, but got Unknown //IL_0c2f: Unknown result type (might be due to invalid IL or missing references) //IL_0c39: Expected O, but got Unknown //IL_0cc4: Unknown result type (might be due to invalid IL or missing references) //IL_0cce: Expected O, but got Unknown Enabled = Adm(c, "1 - General", "Enabled", v: true, "Master switch for the whole mod (Forge refining, power plan, drops and armor bonus). Off = the game's own behaviour."); LogDetails = Loc(c, "1 - General", "LogDetails", v: false, "Write extra lines to the log: every refine roll, every plan applied to an item."); TopChance = Adm(c, "10 - Success curve", "TopChance", 80f, "Weapons. Chance at and below StartLevel, in percent."); StartLevel = Adm(c, "10 - Success curve", "StartLevel", 7f, "Item level (before refining) after which the chance starts to fall."); FloorChance = Adm(c, "10 - Success curve", "FloorChance", 20f, "The chance never falls below this."); HalfwayLevels = Adm(c, "10 - Success curve", "HalfwayLevels", 4f, "Levels past StartLevel until the chance is halfway between top and floor."); Shape = Adm(c, "10 - Success curve", "Shape", 1f, "1 = exponential; above 1 holds high longer, below 1 drops fast then flattens."); LevelOverrides = Adm(c, "10 - Success curve", "LevelOverrides", "", "Hand-set chances as level:percent. These win over the curve."); ScaleChance = Adm(c, "10 - Success curve", "ScaleChanceToTierCap", v: true, "On: the weapon curve above is drawn for ChanceReferenceMaxLevel levels, and each tier stretches it over its own max level, so every tier has the same odds at the same share of the way to its cap. Off: one curve for every tier, by item level."); ChanceRefLevel = Adm(c, "10 - Success curve", "ChanceReferenceMaxLevel", 20, "The max level the weapon curve above was drawn for (used with ScaleChanceToTierCap)."); ArmorTopChance = Adm(c, "10 - Success curve", "ArmorTopChance", 75f, "Armor and shields use their own curve (same meaning as above)."); ArmorStartLevel = Adm(c, "10 - Success curve", "ArmorStartLevel", 3f, ""); ArmorFloorChance = Adm(c, "10 - Success curve", "ArmorFloorChance", 20f, ""); ArmorHalfwayLevels = Adm(c, "10 - Success curve", "ArmorHalfwayLevels", 5f, ""); ArmorShape = Adm(c, "10 - Success curve", "ArmorShape", 1.25f, ""); ArmorScaleChance = Adm(c, "10 - Success curve", "ArmorScaleChanceToTierCap", v: true, "As ScaleChanceToTierCap, for armor and shields."); ArmorChanceRefLevel = Adm(c, "10 - Success curve", "ArmorChanceReferenceMaxLevel", 13, "The max level the armor curve above was drawn for."); ArmorLevelOverrides = Adm(c, "10 - Success curve", "ArmorLevelOverrides", "", ""); MaxRefineLevel = Adm(c, "11 - Failure", "MaxRefineLevel", 32, "Highest level the Forge ever refines to (0 = no limit besides the tier's MaxLevel)."); LevelsLostOnFailure = Adm(c, "11 - Failure", "LevelsLostOnFailure", 0, "Levels lost when a refine fails. 0 = the item keeps its level (the idols are still spent)."); BreakChanceOnFailure = Adm(c, "11 - Failure", "BreakChanceOnFailure", 0f, "Percent chance that a failed refine destroys the item."); BreakRefund = Adm(c, "11 - Failure", "BreakRefund", -1f, "Share (0 to 1) of the item's materials returned when it breaks. -1 = the idol's own game value."); IdolRefundOnFailure = Adm(c, "11 - Failure", "IdolRefundOnFailure", 0f, "Percent of the idols given back when a refine fails."); PityPerFailure = Adm(c, "11 - Failure", "PityPerFailure", 2f, "Percentage points added to the next attempt's chance for every failure in a row (stored on the item, reset on success)."); PityCap = Adm(c, "11 - Failure", "PityCap", 20f, "The most percentage points pity can add."); KeepSeededRoll = Adm(c, "12 - Forge", "KeepSeededRoll", v: false, "true = the game's own saved roll (reloading does not reroll). false = a fresh roll every attempt."); ShowChanceInForge = Loc(c, "12 - Forge", "ShowChanceInForge", v: true, "Show the success chance and the level cap in the Forge panel."); ShowChanceMessage = Loc(c, "12 - Forge", "ShowChanceMessage", v: false, "Show the chance as a message when you refine."); RepairOnRefine = Adm(c, "12 - Forge", "RepairOnRefine", v: true, "A refined item comes back fully repaired."); KeepItemData = Adm(c, "12 - Forge", "KeepItemData", v: true, "Keep the very same item (crafter name, custom data, inventory slot) instead of the game creating a new one."); MaxLevel = Adm(c, "13 - Power plan", "MaxLevel", "0:32, 1:29, 2:26, 3:24, 4:22, 5:20, 6:18, 7:16", "Highest level per tier (0 Meadows … 7 Deep North). 0 = no Forge refining."); PowerAtMaxLevel = Adm(c, "13 - Power plan", "PowerAtMaxLevel", "0:7.627, 1:6.193, 2:5.364, 3:4.59, 4:4.102, 5:4.284, 6:3.683, 7:2.5", "Multiplier on each weapon's own power (damage per full stamina bar) at its normal max quality."); Growth = Adm(c, "13 - Power plan", "Growth", "0:Custom, 1:Custom, 2:Custom, 3:Custom, 4:Custom, 5:Custom, 6:Custom, 7:Custom", "Name of the growth (informational; GrowthShape and GrowthExponent decide)."); GrowthShape = Adm(c, "13 - Power plan", "GrowthShape", "0:Power, 1:Power, 2:Power, 3:Power, 4:Power, 5:Power, 6:Power, 7:Power", "Power: share of boost = x^exponent. S: x^e / (x^e + (1-x)^e). ReverseS: the same with 1/e. x = levels done / levels possible."); GrowthExponent = Adm(c, "13 - Power plan", "GrowthExponent", "0:3, 1:3.15, 2:2.95, 3:3.05, 4:3, 5:2.7, 6:1.55, 7:1.65", "Exponent (Power) or steepness (S, ReverseS)."); DamageShare = Adm(c, "13 - Power plan", "DamageShare", 80f, "Percent of the extra power delivered as damage; the rest as cheaper attacks (stamina, draw, reload, eitr)."); ArmorMaxLevel = Adm(c, "13 - Power plan", "ArmorMaxLevel", "0:24, 1:22, 2:20, 3:18, 4:16, 5:14, 6:12, 7:10", "Highest level per tier for armor and shields. 0 = no Forge refining."); ArmorAtMaxLevel = Adm(c, "13 - Power plan", "ArmorAtMaxLevel", "0:9.832, 1:6.051, 2:4.627, 3:3.746, 4:3.105, 5:2.622, 6:2.291, 7:2", "Multiplier on each armor piece's own armor at its normal max quality."); BlockAtMaxLevel = Adm(c, "13 - Power plan", "BlockAtMaxLevel", "0:10.6, 1:6, 2:4.048, 3:3.125, 4:2.26, 5:2.341, 6:1.739, 7:1.75", "Multiplier on each shield's own block power at its normal max quality."); ArmorGrowth = Adm(c, "13 - Power plan", "ArmorGrowth", "0:Custom, 1:Custom, 2:Custom, 3:Custom, 4:Custom, 5:Custom, 6:Custom, 7:Custom", "Name of the armor growth (informational)."); ArmorGrowthShape = Adm(c, "13 - Power plan", "ArmorGrowthShape", "0:Power, 1:Power, 2:Power, 3:Power, 4:Power, 5:Power, 6:Power, 7:Power", "As GrowthShape, for armor and shields."); ArmorGrowthExponent = Adm(c, "13 - Power plan", "ArmorGrowthExponent", "0:2.4, 1:2.5, 2:2.45, 3:2.35, 4:2.2, 5:2.2, 6:1.95, 7:1.25", "As GrowthExponent, for armor and shields."); TierOverrides = Adm(c, "13 - Power plan", "TierOverrides", "AtgeirGold:7, HelmetBerserkerHood:1", "prefab:tier for items whose own Forge idol puts them in the wrong tier for the power plan."); ItemOverrides = Adm(c, "13 - Power plan", "ItemOverrides", "HelmetBerserkerHood:Upgrader1Armor:-:-, HelmetBerserkerUndead:Upgrader4Armor:-:-, HelmetFenring:Upgrader3Armor:-:-, HelmetLox:Upgrader4Armor:-:-, HelmetRoot:Upgrader2Armor:-:-, HelmetTrollLeather:Upgrader1Armor:-:-", "prefab:ForgeIdol:MaxLevel:BoostAtMaxLevel[:GrowthShape:GrowthExponent], - keeps the normal value. Swaps the Forge idol; with a growth shape the item ignores its tier's curve (1 to Boost along that shape), without one it follows its tier's curve to the tier's MaxLevel, then rises evenly to Boost."); ForgeTimeMultiplier = Adm(c, "12 - Forge", "ForgeTimeMultiplier", 0.1f, "Multiplies the time an upgrade takes at the Forge (and any other upgrade station): 1 = the game's time, 0.5 = half, 0.1 = a tenth. Applies to the base time and the extra time per level."); HideBreakWarning = Loc(c, "12 - Forge", "HideBreakWarning", v: true, "Hide the game's \"Maximum safe quality. Refinement may break your item.\" line in the Forge panel while BreakChanceOnFailure is 0."); WeaponBlockEnabled = Adm(c, "12 - Forge", "WeaponBlockPower", v: true, "Weapons that can block get more block power as they are refined (parry and block armor), by WeaponBlockShare of their power boost."); WeaponBlockTwoHandedOnly = Adm(c, "12 - Forge", "WeaponBlockTwoHandedOnly", v: true, "Only two-handed weapons gain block power. Off: one-handed weapons that block gain it too."); WeaponBlockShare = Adm(c, "12 - Forge", "WeaponBlockShare", 25f, "Share of a weapon's power boost applied to its block power, in %. A weapon at 3x power with 25 gets 1 + (3 - 1) x 0.25 = 1.5x block power. 100 = the same multiplier as its damage, 0 = none."); HeavySpeedEnabled = Adm(c, "15 - Heavy armor", "Enabled", v: true, "Heavy helmets, chests and legs lose part of their movement speed penalty as they are refined."); HeavySpeedCutAtMax = Adm(c, "15 - Heavy armor", "PenaltyCutAtMaxLevelPercent", 50f, "How much of the movement speed penalty is gone at the piece's highest level, in %. It grows with progress from 0 at the item's normal max quality (4) to this value at its own max level (or at FullLevel when that is set), so every tier gets the full cut at its own cap. 50 = the penalty is halved, 100 = gone."); HeavySpeedFullLevel = Adm(c, "15 - Heavy armor", "FullLevel", 0, "0 = the full cut is reached at each piece's own max level (progress based, 1.7.0). A number above 0 puts every piece on one fixed scale instead: the level where the full cut is reached, and a piece below it gets the share it would have at its level."); LightSpeedEnabled = Adm(c, "15 - Heavy armor", "LightSpeedEnabled", v: true, "Light helmets, chests and legs gain movement speed as they are refined (the light counterpart of the heavy penalty cut). Mage armor gets nothing."); LightSpeedAtMax = Adm(c, "15 - Heavy armor", "LightSpeedPerPieceAtMaxPercent", 1f, "Movement speed each light piece adds at its highest level, in %. It grows with progress from 0 at the item's normal max quality. 1 = +1% per piece, +3% for a full light set at max level."); FdEnabled = Adm(c, "16 - Failure damage", "Enabled", v: true, "A failed refine hurts you. The damage ignores armor and resistances."); FdMinPct = Adm(c, "16 - Failure damage", "MinPercent", 5f, "Normal failure: least damage, as % of your max health."); FdMaxPct = Adm(c, "16 - Failure damage", "MaxPercent", 15f, "Normal failure: most damage, as % of your max health. The damage is a random amount between Min and Max."); FdHighChanceSkill0 = Adm(c, "16 - Failure damage", "HighDamageChanceAtSkill0", 25f, "Chance in % that a failure is a HIGH damage failure, at Crafting skill 0."); FdHighChanceSkill100 = Adm(c, "16 - Failure damage", "HighDamageChanceAtSkill100", 5f, "Chance in % of a high damage failure at Crafting skill 100. Between 0 and 100 the chance moves evenly from one value to the other. Put the larger number here to make skill make it worse."); FdHighMinPct = Adm(c, "16 - Failure damage", "HighMinPercent", 40f, "High damage failure: least damage, as % of your max health."); FdHighMaxPct = Adm(c, "16 - Failure damage", "HighMaxPercent", 70f, "High damage failure: most damage, as % of your max health."); FdXChance0 = Adm(c, "16 - Failure damage", "ExtremeChanceAtSkill0", 8f, "Chance in % that a failure is an EXTREME failure (checked before the high one), at Crafting skill 0."); FdXChance100 = Adm(c, "16 - Failure damage", "ExtremeChanceAtSkill100", 1f, "Chance in % of an extreme failure at Crafting skill 100. Between 0 and 100 the chance moves evenly. 0 turns extreme failures off."); FdXMinPct = Adm(c, "16 - Failure damage", "ExtremeMinPercent", 60f, "Extreme failure: least damage, as % of your max health (before the item level bonus)."); FdXMaxPct = Adm(c, "16 - Failure damage", "ExtremeMaxPercent", 100f, "Extreme failure: most damage, as % of your max health (before the item level bonus)."); FdPerLevelPct = Adm(c, "16 - Failure damage", "PercentMorePerItemLevel", 3f, "Failures hurt more at higher item levels: the damage grows by this many % for every level the item has (3 = a level 18 item hits 1.54 times as hard as a level 0 item)."); FdCanKill = Adm(c, "16 - Failure damage", "CanKill", v: true, "On: a failure can kill you. Off: the damage never takes you below 1 health."); FdMessage = Loc(c, "16 - Failure damage", "ShowMessage", v: true, "Show a message with the damage you took."); XiEnabled = Adm(c, "17 - Extra idols", "Enabled", v: true, "Spend extra idols on a refine to raise its chance. Pick how many with the two keys while the Forge panel is open. The extra idols are used up whether the refine succeeds or fails."); XiFirstBonus = Adm(c, "17 - Extra idols", "FirstIdolBonus", 10f, "Percentage points the first extra idol adds to the chance."); XiBonusDrop = Adm(c, "17 - Extra idols", "BonusDropPerIdol", 2f, "Each further extra idol adds this many points less than the one before (10, 8, 6, 4, 2 with the defaults). When the bonus reaches 0 no more idols can be added."); XiMax = Adm(c, "17 - Extra idols", "MaxExtraIdols", 10, "Upper limit on extra idols per refine (the bonus running out can stop it sooner). The chance never goes above 100%."); XiMoreKey = Loc<KeyCode>(c, "17 - Extra idols", "MoreKey", (KeyCode)280, "Key that adds one extra idol while the Forge panel is open."); XiLessKey = Loc<KeyCode>(c, "17 - Extra idols", "LessKey", (KeyCode)281, "Key that removes one extra idol."); RoundStats = Adm(c, "18 - Tooltips", "RoundStats", v: true, "Refined armor, shield and weapon block values and weapon damage are rounded to whole numbers, like the game's own items, so tooltips are clean and show exactly what you get."); TidyTooltips = Loc(c, "18 - Tooltips", "TidyTooltips", v: true, "Round long decimals in item tooltips (attack stamina, eitr use, movement speed and so on) to TooltipDecimals places."); TooltipDecimals = Loc(c, "18 - Tooltips", "TooltipDecimals", 1, new ConfigDescription("How many decimals tooltips show.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 3), Array.Empty<object>())); CsEnabled = Adm(c, "19 - Critical success", "Enabled", v: true, "A successful refine can be a critical success that gives extra levels at once."); CsChance0 = Adm(c, "19 - Critical success", "ChanceAtSkill0", 5f, "Chance in % that a successful refine is critical, at Crafting skill 0."); CsChance100 = Adm(c, "19 - Critical success", "ChanceAtSkill100", 15f, "Chance in % of a critical success at Crafting skill 100. Between 0 and 100 the chance moves evenly from one value to the other."); CsExtraLevels = Adm(c, "19 - Critical success", "ExtraLevels", 1, new ConfigDescription("Extra levels a critical success gives on top of the normal one (1 = two levels in all). Never goes above the item's highest level.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>())); CsFlavour = Loc(c, "19 - Critical success", "FlavourMessages", v: true, "Short sayings from the forge and the gods on normal successes too (critical and failure messages always use them)."); CsMessage = Loc(c, "19 - Critical success", "ShowMessage", v: true, "Show a message on a critical success."); AbEnabled = Adm(c, "14 - Max-level armor", "Enabled", v: true, "Wear a helmet, chest and legs that are all refined far enough (Class Mastery I: each piece at or above RankIProgressPercent of its own range; Class Mastery II: all three at their highest level): you get the bonus of each piece's class (each piece adds a third), times the rank strength, times strength = floor + (1 - floor) x adrenaline fill. While a trinket's buff runs, strength is 1 for that buff's duration. Pieces from different sets borrow one set bonus; a full matching set keeps its own and also gets the class bonus."); AbRankIProgress = Adm(c, "14 - Max-level armor", "RankIProgressPercent", 50, "Class Mastery I: helmet, chest and legs must each be at least this far along their own refining (progress = levels above the normal max quality / levels the piece can reach), in %."); AbRankIStrength = Adm(c, "14 - Max-level armor", "RankIStrengthPercent", 50, "Class Mastery I gives the class bonus at this share of its strength, in %. Class Mastery II (all three pieces at their highest level) gives 100%. The adrenaline meter scaling applies on top."); AbBorrow = Adm(c, "14 - Max-level armor", "BorrowSetBonus", v: true, "Mixed pieces borrow one set bonus (first piece with one, in SetBonusOrder)."); AbOrder = Adm(c, "14 - Max-level armor", "SetBonusOrder", "Chest, Head, Legs", "Which slot is checked first for the borrowed set bonus."); AbFloor = Adm(c, "14 - Max-level armor", "MeterFloorPercent", 20, "Bonus with an empty adrenaline meter, or no meter (no trinket), as % of the full bonus."); AbTrinketFull = Adm(c, "14 - Max-level armor", "TrinketGivesFullBonus", v: true, "While a trinket's full-adrenaline buff is active, the bonus stays at 100% for the buff's duration."); AbHeavy = Adm(c, "14 - Max-level armor", "BonusHeavy", "HealthRegen:50, PhysicalDamage:20", "Stat:amount at a full meter with three pieces of the class. Stats: HealthRegen, StaminaRegen, EitrRegen, MoveSpeed, PhysicalDamage, ElementalDamage, SpiritDamage, AllDamage, AttackStamina, RunStamina, Armor, AdrenalineGain, MaxHealth, MaxStamina, MaxEitr. Regen, damage, speed and adrenaline are %, cheaper costs are % less; armor and max health/stamina/eitr are flat."); AbLight = Adm(c, "14 - Max-level armor", "BonusLight", "StaminaRegen:50, MoveSpeed:10", ""); AbMage = Adm(c, "14 - Max-level armor", "BonusMage", "EitrRegen:50, ElementalDamage:20, SpiritDamage:20", ""); AbClassOverrides = Adm(c, "14 - Max-level armor", "ArmorClassOverrides", "", "prefab:Heavy|Light|Mage for pieces whose built-in class you want to change."); GlowClamp = Loc(c, "23 - Glow", "ClampToProgress", v: true, "Weapon and armor glow follows how far an item is refined (progress to its own max level) instead of its raw level, so a tier with a high cap does not glow far brighter than the others. Only changes how items look on your screen."); GlowFullLevels = Loc(c, "23 - Glow", "FullGlowLevels", 16, new ConfigDescription("The glow of an item at its highest level equals the glow of this many levels above its normal max quality (16 = the vanilla level 20 glow).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 40), Array.Empty<object>())); CustomizeEnabled = Adm(c, "23 - Glow", "CustomizeTab", v: true, "Adds a Customize tab next to Upgrade in the crafting window: change the glow of a refined weapon (colour, strength, size). Free. What you can change unlocks with the item's progress (see below)."); FistGlow = Adm(c, "23 - Glow", "FistWeaponGlow", v: true, "Fist weapons (claws, knuckles) get a glow once refined, like other weapons. Needs a glowing weapon prefab in the game to copy the effect from. NOTE: switched off in the code since 1.8.14 (this setting has no effect for now)."); GlowStrengthUnlock = Adm(c, "23 - Glow", "StrengthUnlockProgress", 0f, "Progress (percent of the way from the normal max quality to the item's highest level) at which the strength slider unlocks. 0 = as soon as the item is refined."); GlowStrengthMin = Adm(c, "23 - Glow", "StrengthMin", 0f, "Dimmest strength. 0 = glow off, 1 = the standard glow."); GlowStrengthCapAtUnlock = Adm(c, "23 - Glow", "StrengthCapAtUnlock", 1f, "Highest strength allowed when the slider unlocks (1 = the standard glow). Dimmer is always allowed."); GlowStrengthCapAtMax = Adm(c, "23 - Glow", "StrengthCapAtMax", 2.5f, "Highest strength allowed at the item's highest level. The cap grows in between. Tune in game: bright glows cost frames."); GlowPresetsFirstAt = Adm(c, "23 - Glow", "FirstPresetsProgress", 0f, "Progress at which the first set of colour presets unlocks. 0 = as soon as the item is refined."); GlowPresetsFirstCount = Adm(c, "23 - Glow", "FirstPresetsCount", 4, new ConfigDescription("How many presets (from the top of the list) the first set holds.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>())); GlowPresetsAllAt = Adm(c, "23 - Glow", "AllPresetsProgress", 40f, "Progress at which every colour preset is unlocked."); GlowSizeUnlock = Adm(c, "23 - Glow", "SizeUnlockProgress", 0f, "Progress at which the glow size slider unlocks. 0 = as soon as the item is refined."); GlowSizeCapAtUnlock = Adm(c, "23 - Glow", "SizeCapAtUnlock", 1f, "Biggest glow size allowed when the slider unlocks (1 = the standard size). Smaller is always allowed."); GlowSizeCapAtMax = Adm(c, "23 - Glow", "SizeCapAtMax", 2.5f, new ConfigDescription("Biggest glow size allowed at the item's highest level. The cap grows in between.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3f), Array.Empty<object>())); GlowPlacementUnlock = Adm(c, "23 - Glow", "PlacementUnlockProgress", 80f, "Progress at which you can choose where on the weapon it glows."); GlowFullColourUnlock = Adm(c, "23 - Glow", "FullColourUnlockProgress", 100f, "Progress at which any colour is unlocked (100 = only at the highest level)."); GlowMaxIntensity = Adm(c, "23 - Glow", "MaxIntensity", 8f, "Hard limit for the glow intensity after strength is applied (the standard glow of a top level item is about 5)."); DropsEnabled = Adm(c, "20 - Drops", "Enabled", v: true, "Enemies drop Forge idols. The tier is the lowest biome the enemy spawns in; the chance comes from its health and how often it spawns (see 21 - Drop chance). The file BepInEx/FoAP-DropTable.txt lists the result for every enemy."); GlobalMultiplier = Adm(c, "20 - Drops", "GlobalMultiplier", 1f, "Multiplies every drop chance. Bosses are not affected."); ChancePerStar = Adm(c, "20 - Drops", "ChancePerStar", 2f, "Chance factor per star. 2 doubles the chance at 1 star and quadruples it at 2 stars."); MaxStars = Adm(c, "20 - Drops", "MaxStars", 2, "Stars above this count no more for the chance."); EventMultiplier = Adm(c, "20 - Drops", "EventMultiplier", 1f, "Chance factor for raid creatures and creatures killed during a world event."); WeaponShare = Adm(c, "20 - Drops", "WeaponShare", 70f, "Percent of drops that are Battle idols. The rest are Protection idols."); BossIdolsMin = Adm(c, "20 - Drops", "BossIdolsMin", 1, "Fewest idols a boss drops."); BossIdolsMax = Adm(c, "20 - Drops", "BossIdolsMax", 5, "Most idols a boss drops."); RequirePlayerKill = Adm(c, "20 - Drops", "RequirePlayerKill", v: true, "Only creatures killed by a player drop idols (a kill finished by damage over time counts when a player hit the creature). Bosses always drop."); SummonsDrop = Adm(c, "20 - Drops", "SummonsDrop", v: false, "Creatures that only exist because another creature or a trigger spawns them can drop idols too."); DropAnnouncement = Loc(c, "20 - Drops", "DropAnnouncement", v: false, "Tell the nearest player when an idol drops."); LogDrops = Loc(c, "20 - Drops", "LogDrops", v: false, "Write one line to the log for every idol roll. Only affects your own game."); BossAverageIdols = Adm(c, "20 - Drops", "BossAverageIdols", "Eikthyr:3, gd_king:3, Bonemass:3, Dragon:3.6, GoblinKing:3.9, SeekerQueen:4.2, Fader:4.2, FrozenKing_p3:4.2, Skeleton_Hildir:3, Fenring_Cultist_Hildir:3, GoblinBrute_Hildir:2, GoblinShaman_Hildir:2, GoblinBruteBros:2", "Average idols per boss kill, prefab:average. Each kill drops BossIdolsMin + Binomial(BossIdolsMax - BossIdolsMin, p) with p = (average - min) / (max - min). Bosses always drop; their tier is the biome they die in."); BaseChance = Adm(c, "21 - Drop chance", "BaseChance", 2.5f, "Drop chance in percent for a typical enemy of its tier (one with the middle health of the enemies that spawn in that tier)."); StrengthExponent = Adm(c, "21 - Drop chance", "StrengthExponent", 0.8f, "How fast the chance grows with health. The chance is multiplied by (health / typical health of the tier) to this power. 0 = every enemy the same."); MinFactor = Adm(c, "21 - Drop chance", "MinFactor", 0.25f, "Weakest enemies drop at least BaseChance x this."); MaxFactor = Adm(c, "21 - Drop chance", "MaxFactor", 4f, "Strongest enemies drop at most BaseChance x this."); CrowdRate = Adm(c, "21 - Drop chance", "CrowdRate", 60f, "Enemies that spawn more often than this many per hour (summed over their spawners) get a lower chance, so swarms do not flood the world with idols. 0 = off."); CrowdExponent = Adm(c, "21 - Drop chance", "CrowdExponent", 0.5f, "How strongly the crowd rule lowers the chance: factor = (CrowdRate / spawns per hour) to this power."); ChanceOverrides = Adm(c, "22 - Creatures", "ChanceOverrides", "Tick:0.2, SeekerBrood:0.2", "Own base chance in percent for single enemies, PrefabName:percent. Replaces the health formula and also makes an enemy eligible that would otherwise be skipped."); DropTierOverrides = Adm(c, "22 - Creatures", "TierOverrides", "", "Own idol tier (0 Meadows, 1 Black Forest, 2 Swamp, 3 Mountains, 4 Plains, 5 Mistlands, 6 Ashlands, 7 Deep North) for single enemies, PrefabName:tier."); Excluded = Adm(c, "22 - Creatures", "Excluded", "TrainingDummy, Hive", "Enemies that never drop idols, PrefabName separated by commas. Enemies without attacks, young animals and tamed ones are skipped automatically."); } } internal static class Parse { public static float F(string s, float def) { if (!float.TryParse((s ?? "").Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return def; } return result; } public static float[] Tiers(string value, float def) { float[] array = new float[8]; for (int i = 0; i < 8; i++) { array[i] = def; } foreach (KeyValuePair<string, string> item in Pairs(value)) { if (int.TryParse(item.Key, out var result) && result >= 0 && result < 8) { array[result] = F(item.Value, def); } } return array; } public static string[] TierWords(string value, string def) { string[] array = new string[8]; for (int i = 0; i < 8; i++) { array[i] = def; } foreach (KeyValuePair<string, string> item in Pairs(value)) { if (int.TryParse(item.Key, out var result) && result >= 0 && result < 8 && item.Value.Length > 0) { array[result] = item.Value; } } return array; } public static List<KeyValuePair<string, string>> Pairs(string value) { List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>(); if (string.IsNullOrEmpty(value)) { return list; } string[] array = value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length != 0) { int num = text.IndexOf(':'); if (num > 0) { list.Add(new KeyValuePair<string, string>(text.Substring(0, num).Trim(), text.Substring(num + 1).Trim())); } } } return list; } public static HashSet<string> Names(string value) { HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); if (string.IsNullOrEmpty(value)) { return hashSet; } string[] array = value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { hashSet.Add(text); } } return hashSet; } } internal static class Drops { private class Info { public string Skip; public bool Boss; public float Health; public int Mask; public int WideMask; public float Rate; public int SpawnTier = -1; } private static Dictionary<string, float> ChanceOv = new Dictionary<string, float>(StringComparer.Ordinal); private static Dictionary<string, int> TierOv = new Dictionary<string, int>(StringComparer.Ordinal); private static HashSet<string> ExcludedSet = new HashSet<string>(StringComparer.Ordinal); private static Dictionary<string, float> BossAvg = new Dictionary<string, float>(StringComparer.Ordinal); private static readonly Dictionary<string, Info> Cache = new Dictionary<string, Info>(StringComparer.Ordinal); private static readonly float[] TierMedian = new float[8]; private static HashSet<string> SummonOnly = new HashSet<string>(StringComparer.Ordinal); private static bool Ready; private static readonly HashSet<string> Announced = new HashSet<string>(); private static readonly FieldInfo CharacterF = AccessTools.Field(typeof(CharacterDrop), "m_character"); private static readonly FieldInfo LastHitF = AccessTools.Field(typeof(Character), "m_lastHit"); private static readonly FieldInfo InstancesF = AccessTools.Field(typeof(SpawnSystem), "m_instances"); private const int MaxBiomesPerSpawner = 3; public static void Reload() { ChanceOv.Clear(); TierOv.Clear(); BossAvg.Clear(); foreach (KeyValuePair<string, string> item in Parse.Pairs(Cfg.ChanceOverrides.Value)) { ChanceOv[item.Key] = Parse.F(item.Value, 0f); } foreach (KeyValuePair<string, string> item2 in Parse.Pairs(Cfg.DropTierOverrides.Value)) { if (int.TryParse(item2.Value, out var result) && result >= 0 && result <= 7) { TierOv[item2.Key] = result; continue; } Plugin.Log.LogWarning((object)("TierOverrides: '" + item2.Key + ":" + item2.Value + "' is not PrefabName:tier (0-7)")); } ExcludedSet = Parse.Names(Cfg.Excluded.Value); foreach (KeyValuePair<string, string> item3 in Parse.Pairs(Cfg.BossAverageIdols.Value)) { BossAvg[item3.Key] = Parse.F(item3.Value, 3f); } Ready = false; Cache.Clear(); } private static int TierOf(Biome b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if ((int)b <= 16) { switch (b - 1) { default: if ((int)b != 8) { if ((int)b != 16) { break; } return 4; } return 1; case 0: return 0; case 1: return 2; case 3: return 3; case 2: break; } } else if ((int)b <= 64) { if ((int)b == 32) { return 6; } if ((int)b == 64) { return 7; } } else { if ((int)b == 256) { return 2; } if ((int)b == 512) { return 5; } } return -1; } public static int BiomeTier(int mask) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_002a: Unknown result type (might be due to invalid IL or missing references) int num = -1; foreach (Biome value in Enum.GetValues(typeof(Biome))) { if ((mask & value) != 0) { int num2 = TierOf(value); if (num2 >= 0 && (num < 0 || num2 < num)) { num = num2; } } } return num; } public static float BasePercent(float health, float typical, float spawnsPerHour) { double val = 1.0; if (typical > 0f && health > 0f) { val = Math.Pow(health / typical, Math.Max(0.0, Cfg.StrengthExponent.Value)); } val = Math.Max(Cfg.MinFactor.Value, Math.Min(Cfg.MaxFactor.Value, val)); double num = Cfg.CrowdRate.Value; if (num > 0.0 && (double)spawnsPerHour > num) { val *= Math.Pow(num / (double)spawnsPerHour, Math.Max(0.0, Cfg.CrowdExponent.Value)); } return (float)((double)Cfg.BaseChance.Value * val); } public static float Chance(float percent, int stars, float perStar, bool fromEvent, float eventMult, float globalMult) { double num = (double)percent / 100.0 * Math.Pow(perStar, Math.Max(0, stars)); if (fromEvent) { num *= (double)eventMult; } num *= (double)globalMult; return (float)Math.Max(0.0, Math.Min(1.0, num)); } public static string IdolName(int tier, bool weapon) { return "Upgrader" + tier + (weapon ? "Weapon" : "Armor"); } public static int BossCount(string boss, Random rng) { int num = Math.Max(0, Cfg.BossIdolsMin.Value); int num2 = Math.Max(num, Cfg.BossIdolsMax.Value); if (!BossAvg.TryGetValue(boss, out var value)) { value = (float)(num + num2) / 2f; } double num3 = ((num2 > num) ? Math.Max(0.0, Math.Min(1.0, (double)(value - (float)num) / (double)(num2 - num))) : 0.0); int num4 = num; for (int i = 0; i < num2 - num; i++) { if (rng.NextDouble() < num3) { num4++; } } return num4; } private static float SpawnsPerHour(float interval, float chancePercent, int gmin, int gmax) { if (!(interval > 0f)) { return 0f; } return 3600f / interval * chancePercent / 100f * (float)(gmin + gmax) / 2f; } private static int BitCount(int v) { int num = 0; while (v != 0) { num += v & 1; v >>= 1; } return num; } private static int Count(Array a) { return a?.Length ?? 0; } private static Info Describe(Character ch) { //IL_001f: 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_002e: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 Info info = new Info { Boss = ch.IsBoss(), Health = ch.m_health }; if ((int)ch.m_faction == 0 || (int)ch.m_faction == 11 || (int)ch.m_faction == 12) { info.Skip = "faction " + ((object)Unsafe.As<Faction, Faction>(ref ch.m_faction)/*cast due to .constrained prefix*/).ToString(); } else if ((Object)(object)((Component)ch).GetComponent<Growup>() != (Object)null) { info.Skip = "a young animal that grows up"; } else if (!info.Boss) { Humanoid val = (Humanoid)(object)((ch is Humanoid) ? ch : null); if (!((Object)(object)val != (Object)null) || Count(val.m_defaultItems) + Count(val.m_randomWeapon) + Count(val.m_randomSets) <= 0) { info.Skip = "it has no attacks"; } } return info; } private static Info InfoFor(Character ch, string name) { if (Cache.TryGetValue(name, out var value)) { return value; } value = Describe(ch); Cache[name] = value; return value; } private static List<SpawnSystem> Systems() { if (!(InstancesF != null)) { return null; } return InstancesF.GetValue(null) as List<SpawnSystem>; } private static bool Prepare() { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected I4, but got Unknown //IL_0154: 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_015f: Expected I4, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected I4, but got Unknown if (Ready) { return true; } List<SpawnSystem> list = Systems(); SpawnSystem val = null; if (list != null) { foreach (SpawnSystem item in list) { if ((Object)(object)item != (Object)null) { val = item; break; } } } if ((Object)(object)val == (Object)null || val.m_spawnLists == null) { return false; } HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); foreach (SpawnSystemList spawnList in val.m_spawnLists) { if ((Object)(object)spawnList == (Object)null) { continue; } foreach (SpawnData spawner in spawnList.m_spawners) { if (spawner == null || !spawner.m_enabled || (Object)(object)spawner.m_prefab == (Object)null || !string.IsNullOrEmpty(spawner.m_requiredPersistentEvent)) { continue; } Character component = spawner.m_prefab.GetComponent<Character>(); if (!((Object)(object)component == (Object)null)) { string name = ((Object)spawner.m_prefab).name; hashSet.Add(name); Info info = InfoFor(component, name); if (BitCount((int)spawner.m_biome) > 3) { info.WideMask |= spawner.m_biome; } else { info.Mask |= spawner.m_biome; } info.Rate = Math.Max(info.Rate, SpawnsPerHour(spawner.m_spawnInterval, spawner.m_spawnChance, spawner.m_groupSizeMin, spawner.m_groupSizeMax)); } } } List<float>[] array = new List<float>[8]; for (int i = 0; i < 8; i++) { array[i] = new List<float>(); } foreach (string item2 in hashSet) { Info info2 = Cache[item2]; info2.SpawnTier = BiomeTier(info2.Mask); if (info2.Skip == null && !info2.Boss && info2.SpawnTier >= 0) { array[info2.SpawnTier].Add(info2.Health); } } for (int j = 0; j < 8; j++) { List<float> list2 = array[j]; list2.Sort(); TierMedian[j] = ((list2.Count == 0) ? 0f : ((list2.Count % 2 == 1) ? list2[list2.Count / 2] : ((list2[list2.Count / 2 - 1] + list2[list2.Count / 2]) / 2f))); } SummonOnly = FindSummonOnly(hashSet); Ready = true; WriteTable(hashSet); return true; } private static HashSet<string> FindSummonOnly(HashSet<string> natural) { HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); try { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || instance.m_prefabs == null) { return hashSet; } foreach (GameObject prefab in instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { SpawnAbility[] componentsInChildren = prefab.GetComponentsInChildren<SpawnAbility>(true); foreach (SpawnAbility val in componentsInChildren) { AddPrefabs(hashSet, val.m_spawnPrefab); } TriggerSpawner[] componentsInChildren2 = prefab.GetComponentsInChildren<TriggerSpawner>(true); foreach (TriggerSpawner val2 in componentsInChildren2) { AddPrefabs(hashSet, val2.m_creaturePrefabs); } } } hashSet.ExceptWith(natural); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Drops: could not list summoned creatures: " + ex.Message)); } return hashSet; } private static void AddPrefabs(HashSet<string> set, GameObject[] prefabs) { if (prefabs == null) { return; } foreach (GameObject val in prefabs) { if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<Character>() != (Object)null) { set.Add(((Object)val).name); } } } private static void WriteTable(HashSet<string> natural) { try { List<string> list = new List<string>(); foreach (string item in natural) { Info info = Cache[item]; if (info.Skip == null && !info.Boss && info.SpawnTier >= 0) { ChanceOv.TryGetValue(item, out var value); int num = (TierOv.ContainsKey(item) ? TierOv[item] : info.SpawnTier); if (!ChanceOv.ContainsKey(item)) { value = BasePercent(info.Health, TierMedian[num], info.Rate); } float num2 = TierMedian[num]; list.Add(num.ToString("D1") + "\t" + item + "\t" + info.Health.ToString("0", CultureInfo.InvariantCulture) + "\t" + num2.ToString("0", CultureInfo.InvariantCulture) + "\t" + info.Rate.ToString("0.#", CultureInfo.InvariantCulture) + "\t" + value.ToString("0.###", CultureInfo.InvariantCulture) + (ExcludedSet.Contains(item) ? "\texcluded" : "") + (SummonOnly.Contains(item) ? "\tsummon-only" : "")); } } list.Sort(StringComparer.Ordinal); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("tier\tcreature\thealth\ttier typical health\tspawns per hour\tbase chance %"); foreach (string item2 in list) { stringBuilder.AppendLine(item2); } File.WriteAllText(Path.Combine(Paths.BepInExRootPath, "FoAP-DropTable.txt"), stringBuilder.ToString()); Plugin.Log.LogInfo((object)("Drop table for " + list.Count + " creatures written to BepInEx/FoAP-DropTable.txt")); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Drops: could not write the drop table: " + ex.Message)); } } private static string SkipReason(Character ch, bool boss, out string note) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 note = null; if (ch.IsTamed()) { return "tamed"; } if ((int)ch.m_faction == 11) { return "player summon"; } if (boss || !Cfg.RequirePlayerKill.Value) { return null; } HitData val = (HitData)((LastHitF != null) ? /*isinst with value type is only supported in some contexts*/: null); if (val != null && val.HaveAttacker()) { Character attacker = val.GetAttacker(); if (!((Object)(object)attacker != (Object)null) || !attacker.IsPlayer()) { return "last hit not from a player"; } return null; } ZNetView component = ((Component)ch).GetComponent<ZNetView>(); ZDO val2 = (((Object)(object)component != (Object)null) ? component.GetZDO() : null); if (val2 == null || val2.GetInt(ZDOVars.s_attackers, 0) <= 0) { return "last hit had no attacker and no player hit it"; } note = "last hit without attacker (damage over time), a player hit it"; return null; } private static bool FromEvent(Character ch) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) BaseAI baseAI = ch.GetBaseAI(); MonsterAI val = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null); if ((Object)(object)val != (Object)null && val.IsEventCreature()) { return true; } PersistentEventSystem instance = PersistentEventSystem.instance; if ((Object)(object)instance != (Object)null) { return instance.GetActiveEvent(((Component)ch).transform.position) != null; } return false; } private static void Add(List<KeyValuePair<GameObject, int>> drops, string creature, int tier, bool weapon, string detail) { string text = IdolName(tier, weapon); GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(text) : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)(creature + ": idol " + text + " not found in the item database")); return; } drops.Add(new KeyValuePair<GameObject, int>(val, 1)); if (Cfg.LogDrops.Value) { Plugin.Log.LogInfo((object)(creature + ": drops " + text + ", " + detail)); } if (Cfg.DropAnnouncement.Value && (Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, "An idol dropped (" + (weapon ? "Battle" : "Protection") + ", tier " + tier + ")", 0, (Sprite)null, false); } } internal static void OnGenerate(CharacterDrop cd, List<KeyValuePair<GameObject, int>> result) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected I4, but got Unknown if (!Cfg.Enabled.Value || !Cfg.DropsEnabled.Value || result == null) { return; } object? value = CharacterF.GetValue(cd); Character val = (Character)((value is Character) ? value : null); if ((Object)(object)val == (Object)null) { return; } string prefabName = Utils.GetPrefabName(((Component)cd).gameObject); if (ExcludedSet.Contains(prefabName)) { return; } bool flag = Prepare(); Info info = InfoFor(val, prefabName); bool flag2 = ChanceOv.ContainsKey(prefabName); if (info.Skip != null && !flag2) { Why(prefabName, info.Skip); return; } if (!Cfg.SummonsDrop.Value && SummonOnly.Contains(prefabName)) { Why(prefabName, "it only exists when another creature or trigger spawns it"); return; } string text = ""; if (TierOv.TryGetValue(prefabName, out var value2)) { text = " (tier override)"; } else if (info.SpawnTier >= 0) { value2 = info.SpawnTier; } else { value2 = BiomeTier((int)Heightmap.FindBiome(((Component)val).transform.position)); if (value2 < 0) { Why(prefabName, "no biome tier"); return; } text = " (tier from where it died)"; } string note; string text2 = SkipReason(val, info.Boss, out note); if (text2 == null) { foreach (KeyValuePair<GameObject, int> item in result) { if ((Object)(object)item.Key != (Object)null && ((Object)item.Key).name.StartsWith("Upgrader", StringComparison.Ordinal)) { text2 = "it already drops an idol"; break; } } } if (text2 != null) { Why(prefabName, text2); return; } if (info.Boss) { if (Announced.Add(prefabName)) { Plugin.Log.LogInfo((object)("boss " + prefabName + ": tier " + value2 + text)); } int num = BossCount(prefabName, new Random(Random.Range(0, int.MaxValue))); for (int i = 0; i < num; i++) { Add(result, prefabName, value2, Random.value * 100f < Cfg.WeaponShare.Value, "boss" + text); } return; } if (!flag && !flag2) { Why(prefabName, "spawn data not read yet"); return; } if (!ChanceOv.TryGetValue(prefabName, out var value3)) { value3 = BasePercent(info.Health, TierMedian[value2], info.Rate); } int stars = Mathf.Clamp(val.GetLevel() - 1, 0, Cfg.MaxStars.Value); bool flag3 = FromEvent(val); float num2 = Chance(value3, stars, Cfg.ChancePerStar.Value, flag3, Cfg.EventMultiplier.Value, Cfg.GlobalMultiplier.Value); float value4 = Random.value; string text3 = stars + " star, tier " + value2 + ", base " + value3.ToString("0.###", CultureInfo.InvariantCulture) + "%, chance " + (num2 * 100f).ToString("0.###", CultureInfo.InvariantCulture) + "%" + (flag3 ? " (event)" : "") + ", roll " + (value4 * 100f).ToString("0.###", CultureInfo.InvariantCulture) + text + ((note != null) ? (", " + note) : ""); if (value4 < num2) { Add(result, prefabName, value2, Random.value * 100f < Cfg.WeaponShare.Value, text3); } else { Why(prefabName, text3); } } private static void Why(string name, string reason) { if (Cfg.LogDrops.Value) { Plugin.Log.LogInfo((object)(name + ": no idol, " + reason)); } } public static void Patch(Harmony h) { } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] internal static class GenerateDropListPatch { [HarmonyPriority(0)] private static void Postfix(CharacterDrop __instance, List<KeyValuePair<GameObject, int>> __result) { try { Drops.OnGenerate(__instance, __result); } catch (Exception ex) { Plugin.Log.LogError((object)("Idol drop failed: " + ex)); } } } internal static class Forge { private const string FailsKey = "foap_fails"; private static readonly MethodInfo AddWordM = AccessTools.Method(typeof(Localization), "AddWord", (Type[])null, (Type[])null); private static readonly FieldInfo UpgradeItemF = AccessTools.Field(typeof(InventoryGui), "m_craftUpgradeItem"); private static readonly FieldInfo RecipeF = AccessTools.Field(typeof(InventoryGui), "m_craftRecipe"); private static readonly FieldInfo SelectedF = AccessTools.Field(typeof(InventoryGui), "m_selectedRecipe"); public static int ExtraWanted; private static readonly string[] SayNormalSuccess = new string[6] { "The forge hums with approval.", "Well struck!", "The runes glow brighter.", "The metal sings.", "The gods nod.", "A fine piece of work." }; private static readonly string[] SayCritical = new string[5] { "The gods are smiling upon you!", "Odin himself guides your hammer!", "A flawless strike, the forge sings!", "Freyja blesses your work!", "Thor's thunder rings in the steel!" }; private static readonly string[] SayFail = new string[5] { "Sparks fly!", "The anvil rings false.", "The metal resists you.", "The runes flicker and fade.", "A crack runs through the glow." }; private static readonly string[] SayHigh = new string[5] { "The forge lashes out!", "The gods are displeased!", "Fire bites back!", "Loki laughs at your hammer!", "The steel screams!" }; private static readonly string[] SayExtreme = new string[5] { "The gods are furious!", "The forge EXPLODES!", "Ragnarok comes early!", "Odin turns his eye from you!", "Surtr's fire answers!" }; public static ItemData UpgradeItem() { InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance == (Object)null)) { object? value = UpgradeItemF.GetValue(instance); return (ItemData)((value is ItemData) ? value : null); } return null; } public static ItemData SelectedItem() { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || SelectedF == null) { return null; } object value = SelectedF.GetValue(instance); if (value == null) { return null; } PropertyInfo property = value.GetType().GetProperty("ItemData"); if (!(property == null)) { object? value2 = property.GetValue(value, null); return (ItemData)((value2 is ItemData) ? value2 : null); } return null; } public static Recipe SelectedRecipe() { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || SelectedF == null) { return null; } object value = SelectedF.GetValue(instance); if (value == null) { return null; } PropertyInfo property = value.GetType().GetProperty("Recipe"); if (!(property == null)) { object? value2 = property.GetValue(value, null); return (Recipe)((value2 is Recipe) ? value2 : null); } return null; } public static Recipe CraftRecipe() { InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance == (Object)null)) { object? value = RecipeF.GetValue(instance); return (Recipe)((value is Recipe) ? value : null); } return null; } public static float Curve(float level, float top, float start, float floor, float half, float shape, string overrides) { foreach (KeyValuePair<string, string> item in Parse.Pairs(overrides)) { if (int.TryParse(item.Key, out var result) && result == (int)level) { return Mathf.Clamp(Parse.F(item.Value, top), 0f, 100f); } } floor = Math.Min(floor, top); if (level <= start) { return Mathf.Clamp(top, 0f, 100f); } half = Math.Max(0.0001f, half); shape = Math.Max(0.05f, shape); double num = Math.Pow(level - start, shape) / Math.Pow(half, shape); return Mathf.Clamp((float)((double)floor + (double)(top - floor) * Math.Exp((0.0 - Math.Log(2.0)) * num)), 0f, 100f); } private static float Planned(int kind, int level) { return (float)Math.Round((kind == 1) ? Curve(level, Cfg.ArmorTopChance.Value, Cfg.ArmorStartLevel.Value, Cfg.ArmorFloorChance.Value, Cfg.ArmorHalfwayLevels.Value, Cfg.ArmorShape.Value, Cfg.ArmorLevelOverrides.Value) : Curve(level, Cfg.TopChance.Value, Cfg.StartLevel.Value, Cfg.FloorChance.Value, Cfg.HalfwayLevels.Value, Cfg.Shape.Value, Cfg.LevelOverrides.Value), 1); } public static float BaseChance(int kind, int level, int cap, int mq) { bool num = ((kind == 1) ? Cfg.ArmorScaleChance.Value : Cfg.ScaleChance.Value); int num2 = ((kind == 1) ? Cfg.ArmorChanceRefLevel.Value : Cfg.ChanceRefLevel.Value); if (!num || cap <= mq || num2 <= mq || cap == num2 || level < mq) { return Planned(kind, level); } float num3 = (float)mq + (float)((level - mq) * (num2 - mq)) / (float)(cap - mq); int num4 = (int)Math.Floor(num3); float num5 = num3 - (float)num4; float num6 = Planned(kind, num4); float num7 = Planned(kind, num4 + 1); return num6 + (num7 - num6) * num5; } public static int Fails(ItemData it) { if (it == null || it.m_customData == null || !it.m_customData.TryGetValue("foap_fails", out var value) || !int.TryParse(value, out var result)) { return 0; } return result; } private static void SetFails(ItemData it, int n) { if (it.m_customData != null) { if (n <= 0) { it.m_customData.Remove("foap_fails"); } else { it.m_customData["foap_fails"] = n.ToString(CultureInfo.InvariantCulture); } } } public static float Chance(ItemData it) { ItemPlan itemPlan = Plan.Get(it); float num = BaseChance(itemPlan?.Kind ?? 0, it.m_quality, itemPlan?.MaxLevel ?? 0, it.m_shared.m_maxQuality); if (Cfg.PityPerFailure.Value > 0f) { num += Math.Min(Cfg.PityCap.Value, Cfg.PityPerFailure.Value * (float)Fails(it)); } return Mathf.Clamp(num, 0f, 100f); } public static float ExtraBonus(int n) { float num = 0f; float num2 = Cfg.XiFirstBonus.Value; float value = Cfg.XiBonusDrop.Value; for (int i = 0; i < n; i++) { if (!(num2 > 0f)) { break; } num += num2; num2 -= value; } return num; } public static int ExtraLimit() { int num = 0; float num2 = Cfg.XiFirstBonus.Value; float value = Cfg.XiBonusDrop.Value; while (num < Cfg.XiMax.Value && num2 > 0f) { num++; num2 -= value; if (value <= 0f && num >= Cfg.XiMax.Value) { break; } } return num; } private static Requirement IdolReq(ItemData it, out int baseCost, bool panel) { baseCost = 0; Recipe val = (panel ? SelectedRecipe() : CraftRecipe()); if ((Object)(object)val == (Object)null || it == null) { return null; } Requirement[] resources = val.m_resources; foreach (Requirement val2 in resources) { if (val2 != null && val2.m_upgraderResource && !((Object)(object)val2.m_resItem == (Object)null)) { baseCost = val2.GetAmount(it.m_quality + 1); return val2; } } return null; } private static string IdolName(Requirement q) { return q.m_resItem.m_itemData.m_shared.m_name; } public static int ExtraUsable(ItemData it, bool baseAlreadyPaid) { if (!Cfg.Enabled.Value || !Cfg.XiEnabled.Value || it == null || (Object)(object)Player.m_localPlayer == (Object)null) { return 0; } int baseCost; Requirement val = IdolReq(it, out baseCost, !baseAlreadyPaid); if (val == null) { return 0; } int num = ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(IdolName(val), -1, true); if (!baseAlreadyPaid) { num -= baseCost; } return Math.Max(0, Math.Min(Math.Min(ExtraWanted, ExtraLimit()), num)); } public static float ChanceWith(ItemData it, int extra) { return Mathf.Clamp(Chance(it) + ExtraBonus(extra), 0f, 100f); } private static void SpendExtra(ItemData it, int n) { int baseCost; Requirement val = IdolReq(it, out baseCost, panel: false); if (val != null && n > 0) { ((Humanoid)Player.m_localPlayer).GetInventory().RemoveItem(IdolName(val), n, -1, true); } } public static float Roll(Player player, int hash) { if (!Cfg.Enabled.Value || Cfg.KeepSeededRoll.Value) { return player.GetItemUpgradeChance(hash); } return Random.value; } public static float SuccessThreshold(SharedData idol) { if (!Cfg.Enabled.Value) { return idol.m_upgradeChance; } ItemData val = UpgradeItem(); if (val == null) { return idol.m_upgradeChance; } int num = ExtraUsable(val, baseAlreadyPaid: true); float num2 = ChanceWith(val, num); if (num > 0) { SpendExtra(val, num); if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, num + " extra idol" + ((num == 1) ? "" : "s") + " used (+" + ExtraBonus(num).ToString("0.#", CultureInfo.InvariantCulture) + "%)", 0, (Sprite)null, false); } } if (Cfg.LogDetails.Value) { Plugin.Log.LogInfo((object)("refine " + val.m_shared.m_name + " level " + val.m_quality + " -> " + (val.m_quality + 1) + ": chance " + num2.ToString("0.#", CultureInfo.InvariantCulture) + "%" + ((num > 0) ? (" (with " + num + " extra idols)") : ""))); } if (Cfg.ShowChanceMessage.Value && (Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, "Refining level " + val.m_quality + " item: " + num2.ToString("0.#", CultureInfo.InvariantCulture) + "% chance", 0, (Sprite)null, false); } if (!(num2 <= 0f)) { return num2 / 100f; } return -1f; } public static float BreakThreshold(SharedData idol) { if (!Cfg.Enabled.Value) { return idol.m_breakChance; } float value = Cfg.BreakChanceOnFailure.Value; if (value <= 0f) { return -1f; } if (!(Random.value * 100f < value)) { return -1f; } return 2f; } public static float BreakReturn(SharedData idol) { if (!Cfg.Enabled.Value || !(Cfg.BreakRefund.Value >= 0f)) { return idol.m_breakReturnIngreientsAmount; } return Cfg.BreakRefund.Value; } public static int FailSub() { if (!Cfg.Enabled.Value) { return 2; } return 1 + Math.Max(0, Cfg.LevelsLostOnFailure.Value); } public static string FailKey() { if (!Cfg.Enabled.Value || Cfg.LevelsLostOnFailure.Value > 0) { return "$msg_upgrader_failed"; } if (Localization.instance != null && AddWordM != null) { AddWordM.Invoke(Localization.instance, new object[2] { "msg_upgrader_failed_keep", "Refining $1 failed. It stays at level $2." }); } return "$msg_upgrader_failed_keep"; } public static ItemData AddSuccess(Inventory inv, string name, int stack, int quality, int variant, long crafterId, string crafterName, Vector2i pos, bool pickedUp, bool b1, bool b2) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return AddRefined(inv, name, stack, quality, variant, crafterId, crafterName, pos, pickedUp, b1, b2, fail: false); } public static ItemData AddFail(Inventory inv, string name, int stack, int quality, int variant, long crafterId, string crafterName, Vector2i pos, bool pickedUp, bool b1, bool b2) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return AddRefined(inv, name, stack, quality, variant, crafterId, crafterName, pos, pickedUp, b1, b2, fail: true); } private static ItemData AddRefined(Inventory inv, string name, int stack, int quality, int variant, long crafterId, string crafterName, Vector2i pos, bool pickedUp, bool b1, bool b2, bool fail) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (!Cfg.Enabled.Value) { return inv.AddItem(name, stack, quality, variant, crafterId, crafterName, pos, pickedUp, b1, b2); } ItemData val = UpgradeItem(); quality = Math.Max(1, quality); if (!fail) { int num = quality; quality = CriticalSuccess(val, quality); if (quality == num && Cfg.CsFlavour.Value && (Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, Say(SayNormalSuccess), 0, (Sprite)null, false); } } if (fail) { RefundIdols(inv); FailureDamage(); } if (val == null || !Cfg.KeepItemData.Value) { ItemData val2 = inv.AddItem(name, stack, quality, variant, crafterId, crafterName, pos, pickedUp, b1, b2); if (val2 != null) { SetFails(val2, fail ? (Fails(val) + 1) : 0); } return val2; } SetFails(val, fail ? (Fails(val) + 1) : 0); val.m_quality = quality; if (Cfg.RepairOnRefine.Value) { val.m_durability = val.GetMaxDurability(); } bool flag = ((pos.x >= 0 && pos.y >= 0) ? inv.AddItem(val, pos) : inv.AddItem(val)); if (!flag) { flag = inv.AddItem(val); } if (!flag && (Object)(object)Player.m_localPlayer != (Object)null) { ItemDrop.DropItem(val, val.m_stack, ((Component)Player.m_localPlayer).transform.position + Vector3.up, Quaternion.identity); ((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_inventoryfull", 0, (Sprite)null, false); } return val; } private static string Say(string[] a) { return a[Random.Range(0, a.Length)]; } public static int CriticalSuccess(ItemData item, int quality) { try { Player localPlayer = Player.m_localPlayer; if (!Cfg.CsEnabled.Value || (Object)(object)localPlayer == (Object)null || item == null || Cfg.CsExtraLevels.Value <= 0) { return quality; } float num = Mathf.Clamp(((Character)localPlayer).GetSkillLevel((SkillType)107), 0f, 100f); float num2 = Mathf.Lerp(Cfg.CsChance0.Value, Cfg.CsChance100.Value, num / 100f); if (Random.value * 100f >= num2) { return quality; } int val = Plan.Cap(item); int num3 = Math.Min(quality + Cfg.CsExtraLevels.Value, val); if (num3 <= quality) { return quality; } if (Cfg.CsMessage.Value) { ((Character)localPlayer).Message((MessageType)1, Say(SayCritical) + " Level " + quality + " → " + num3, 0, (Sprite)null, false); } if (Cfg.LogDetails.Value) { Plugin.Log.LogInfo((object)("Critical success: level " + quality + " -> " + num3 + " (chance " + num2.ToString("0.#", CultureInfo.InvariantCulture) + "% at crafting skill " + num.ToString("0") + ")")); } return num3; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Critical success failed: " + ex.Message)); return quality; } } public static void FailureDamage() { //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) try { Player localPlayer = Player.m_localPlayer; if (!Cfg.FdEnabled.Value || (Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return; } float num = Mathf.Clamp(((Character)localPlayer).GetSkillLevel((SkillType)107), 0f, 100f); float num2 = Mathf.Lerp(Cfg.FdHighChanceSkill0.Value, Cfg.FdHighChanceSkill100.Value, num / 100f); float num3 = Mathf.Lerp(Cfg.FdXChance0.Value, Cfg.FdXChance100.Value, num / 100f); bool flag = Random.value * 100f < num3; bool flag2 = !flag && Random.value * 100f < num2; float num4 = (flag ? Cfg.FdXMinPct.Value : (flag2 ? Cfg.FdHighMinPct.Value : Cfg.FdMinPct.Value)); float num5 = (flag ? Cfg.FdXMaxPct.Value : (flag2 ? Cfg.FdHighMaxPct.Value : Cfg.FdMaxPct.Value)); if (num5 < num4) { float num6 = num4; num4 = num5; num5 = num6; } ItemData val = UpgradeItem(); int num7 = ((val != null) ? Math.Max(0, val.m_quality) : 0); float num8 = 1f + Math.Max(0f, Cfg.FdPerLevelPct.Value) * (float)num7 / 100f; float num9 = ((Character)localPlayer).GetMaxHealth() * Random.Range(num4, num5) / 100f * num8; if (!Cfg.FdCanKill.Value) { num9 = Mathf.Min(num9, ((Character)localPlayer).GetHealth() - 1f); } if (!(num9 < 1f)) { HitData val2 = new HitData(); val2.m_damage.m_damage = num9; val2.m_point = ((Component)localPlayer).transform.position; val2.m_dir = Vector3.up; ((Character)localPlayer).ApplyDamage(val2, true, true, (DamageModifier)0); if (Cfg.LogDetails.Value) { Plugin.Log.LogInfo((object)("Failed refine hurt the player for " + num9.ToString("0.#", CultureInfo.InvariantCulture) + (flag ? " (EXTREME)" : (flag2 ? " (high)" : "")) + ", item level " + num7 + " (x" + num8.ToString("0.##", CultureInfo.InvariantCulture) + "), high chance " + num2.ToString("0.#", CultureInfo.InvariantCulture) + "% at crafting skill " + num.ToString("0", CultureInfo.InvariantCulture))); } if (Cfg.FdMessage.Value) { ((Character)localPlayer).Message((MessageType)1, Say(flag ? SayExtreme : (flag2 ? SayHigh : SayFail)) + " -" + Mathf.RoundToInt(num9) + " health", 0, (Sprite)null, false); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Failure damage failed: " + ex.Message)); } } private static void RefundIdols(Inventory inv) { float value = Cfg.IdolRefundOnFailure.Value; ItemData val = UpgradeItem(); Recipe val2 = CraftRecipe(); if (value <= 0f || val == null || (Object)(object)val2 == (Object)null) { return; } Requirement[] resources = val2.m_resources; foreach (Requirement val3 in resources) { if (val3 != null && val3.m_upgraderResource && !((Object)(object)val3.m_resItem == (Object)null)) { int num = Mathf.FloorToInt((float)val3.GetAmount(val.m_quality + 1) * value / 100f); if (num > 0) { inv.AddItem(((Object)val3.m_resItem).name, num, 1, 0, 0L, "", false, false); } break; } } } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] internal static class DoCraftingPatch { private static readonly MethodInfo GetChance = AccessTools.Method(typeof(Player), "GetItemUpgradeChance", new Type[1] { typeof(int) }, (Type[])null); private static readonly FieldInfo UpgradeChanceF = AccessTools.Field(typeof(SharedData), "m_upgradeChance"); private static readonly FieldInfo BreakChanceF = AccessTools.Field(typeof(SharedData), "m_breakChance"); private static readonly FieldInfo BreakReturnF = AccessTools.Field(typeof(SharedData), "m_breakReturnIngreientsAmount"); private static readonly MethodInfo AddItemM = AccessTools.Method(typeof(Inventory), "AddItem", new Type[10] { typeof(string), typeof(int), typeof(int), typeof(int), typeof(long), typeof(string), typeof(Vector2i), typeof(bool), typeof(bool), typeof(bool) }, (Type[])null); private static MethodInfo M(string n) { return AccessTools.Method(typeof(Forge), n, (Type[])null, (Type[])null); } internal static List<CodeInstruction> Rewrite(IEnumerable<CodeInstruction> code, out string problem) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown problem = null; List<CodeInstruction> list = new List<CodeInstruction>(code); List<CodeInstruction> result = new List<CodeInstruction>(list); int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (CodeInstructionExtensions.Calls(val, GetChance)) { list[i] = new CodeInstruction(OpCodes.Call, (object)M("Roll")); num++; } else if (CodeInstructionExtensions.LoadsField(val, UpgradeChanceF, false)) { list[i] = new CodeInstruction(OpCodes.Call, (object)M("SuccessThreshold")); num2++; } else if (CodeInstructionExtensions.LoadsField(val, BreakChanceF, false)) { list[i] = new CodeInstruction(OpCodes.Call, (object)M("BreakThreshold")); num3++; } else if (CodeInstructionExtensions.LoadsField(val, BreakReturnF, false)) { list[i] = new CodeInstruction(OpCodes.Call, (object)M("BreakReturn")); num4++; } else if (val.opcode == OpCodes.Ldc_I4_2 && i > 0 && list[i - 1].opcode == OpCodes.Ldloc_0 && i + 1 < list.Count && list[i + 1].opcode == OpCodes.Sub) { list[i] = new CodeInstruction(OpCodes.Call, (object)M("FailSub")); num5++; } else if (CodeInstructionExtensions.Calls(val, AddItemM)) { switch (num6) { case 0: list[i] = new CodeInstruction(OpCodes.Call, (object)M("AddSuccess")); break; case 2: list[i] = new CodeInstruction(OpCodes.Call, (object)M("AddFail")); break; } num6++; } else if (val.opcode == OpCodes.Ldstr && val.operand as string == "$msg_upgrader_failed") { list[i] = new CodeInstruction(OpCodes.Call, (object)M("FailKey")); num7++; } } if (num != 1 || num2 != 1 || num3 != 1 || num4 != 2 || num5 != 2 || num6 != 4 || num7 != 1) { problem = "DoCrafting did not look as expected (roll " + num + ", chance " + num2 + ", break " + num3 + ", return " + num4 + ", level " + num5 + ", add " + num6 + ", message " + num7 + "); the game's own Forge stays active"; return result; } return list; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code) { string problem; List<CodeInstruction> result = Rewrite(code, out problem); if (problem != null) { Plugin.Log.LogError((object)problem); return result; } Plugin.Log.LogInfo((object)"Forge refining patched (DoCrafting)"); return result; } private static bool Prefix(InventoryGui __instance, Player player) { if (!Cfg.Enabled.Value) { return true; } ItemData val = Forge.UpgradeItem(); if (val == null) { return true; } CraftingStation currentCraftingStation = player.GetCurrentCraftingStation(); if ((Object)(object)currentCraftingStation == (Object)null || !currentCraftingStation.m_upgrader) { return true; } if (val.m_quality + 1 > Plan.Cap(val)) { ((Character)player).Message((MessageType)2, "This item can't be refined any further", 0, (Sprite)null, false); return false; } return true; } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] internal static class PanelPatch { private const string Marker = "\u200b"; private static readonly FieldInfo DurF = AccessTools.Field(typeof(InventoryGui), "m_upgraderDuration"); private static readonly FieldInfo DurLvlF = AccessTools.Field(typeof(InventoryGui), "m_upgraderDurationPerLevel"); private static float origDur = -1f; private static float origLvl = -1f; private static float lastLogged = -1f; private static readonly FieldInfo CraftTypeF = AccessTools.Field(typeof(InventoryGui), "m_itemCraftType"); private static void Prefix(InventoryGui __instance) { if (!(DurF == null) && !(DurLvlF == null)) { if (origDur < 0f) { origDur = (float)DurF.GetValue(__instance); origLvl = (float)DurLvlF.GetValue(__instance); } float num = (Cfg.Enabled.Value ? Math.Max(0.01f, Cfg.ForgeTimeMultiplier.Value) : 1f); if (num != lastLogged) { lastLogged = num; Plugin.Log.LogInfo((object)("Forge time multiplier " + num.ToString("0.##", CultureInfo.InvariantCulture) + " (game: " + origDur + " s + " + origLvl + " s per level)")); } DurF.SetValue(__instance, origDur * num); DurLvlF.SetValue(__instance, origLvl * num); } } private static void Postfix(InventoryGui __instance, Player player) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) if (!Cfg.Enabled.Value || (Object)(object)player == (Object)null) { return; } if (Cfg.HideBreakWarning.Value && Cfg.BreakChanceOnFailure.Value <= 0f && CraftTypeF != null) { CraftingStation currentCraftingStation = player.GetCurrentCraftingStation(); if ((Object)(object)currentCraftingStation != (Object)null && currentCraftingStation.m_upgrader) { object? value = CraftTypeF.GetValue(__instance); TMP_Text val = (TMP_Text)((value is TMP_Text) ? value : null); if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(val.text)) { val.text = ""; } } } if (!Cfg.ShowChanceInForge.Value) { return; } ItemData val2 = Forge.SelectedItem(); if (val2 == null) { return; } CraftingStation currentCraftingStation2 = player.GetCurrentCraftingStation(); if ((Object)(object)currentCraftingStation2 == (Object)null || !currentCraftingStation2.m_upgrader) { return; } int num = Plan.Cap(val2); bool flag = val2.m_quality + 1 > num; if (flag && (Object)(object)__instance.m_craftButton != (Object)null) { ((Selectable)__instance.m_craftButton).interactable = false; } TMP_Text recipeDecription = __instance.m_recipeDecription; if ((Object)(object)recipeDecription == (Object)null || recipeDecription.text == null) { return; } string text; if (flag) { text = "<color=#ff8a65>Fully refined (level " + num + ")</color>"; } else { if (Cfg.XiEnabled.Value) { bool num2 = Input.GetKeyDown(Cfg.XiMoreKey.Value) || ZInput.GetKeyDown(Cfg.XiMoreKey.Value, true); bool flag2 = Input.GetKeyDown(Cfg.XiLessKey.Value) || ZInput.GetKeyDown(Cfg.XiLessKey.Value, true); if (num2) { Forge.ExtraWanted = Math.Min(Forge.ExtraLimit(), Forge.ExtraWanted + 1); } if (flag2) { Forge.ExtraWanted = Math.Max(0, Forge.ExtraWanted - 1); } if ((num2 || flag2) && Cfg.LogDetails.Value) { Plugin.Log.LogInfo((object)("extra idols key: wanted " + Forge.ExtraWanted)); } } int num3 = Forge.ExtraUsable(val2, baseAlreadyPaid: false); Forge.Chance(val2); float num4 = Forge.ChanceWith(val2, num3); string text2 = ((num4 >= 60f) ? "#9ccc65" : ((num4 >= 30f) ? "#ffd54f" : "#ff8a65")); text = "Chance to succeed: <color=" + text2 + ">" + num4.ToString("0.#", CultureInfo.InvariantCulture) + "%</color> (level " + val2.m_quality + " → " + (val2.m_quality + 1) + ", max " + ((num == int.MaxValue) ? "-" : num.ToString()) + ")"; if (Cfg.XiEnabled.Value) { float num5 = Forge.ExtraBonus(num3 + 1) - Forge.ExtraBonus(num3); text = text + "\nExtra idols: <color=#ffd54f>" + num3 + "</color>" + ((num3 > 0) ? (" (+" + Forge.ExtraBonus(num3).ToString("0.#", CultureInfo.InvariantCulture) + "%)") : "") + ((num3 < Forge.ExtraLimit() && num5 > 0f) ? (", next +" + num5.ToString("0.#", CultureInfo.InvariantCulture) + "%") : "") + ((Forge.ExtraWanted > num3) ? (", <color=#ff8a65>" + Forge.ExtraWanted + " wanted, but you need " + (Forge.ExtraWanted - num3) + " more idol" + ((Forge.ExtraWanted - num3 == 1) ? "" : "s") + " in your inventory</color>") : "") + " [" + ((object)Cfg.XiMoreKey.Value/*cast due to .constrained prefix*/).ToString() + " / " + ((object)Cfg.X
plugins/EinsteinCrew-PuckosCarePackage/Pucko-GrapplingHookReforged/GrapplingHookReforged.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace Pucko.GHR; internal static class Cfg { public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> LogDetails; public static ConfigEntry<int> HookChainAmount; public static ConfigEntry<int> HookEitrAmount; public static ConfigEntry<int> HookSpringAmount; public static ConfigEntry<int> HookMaxLevel; public static ConfigEntry<float> HookRangePercent; public static ConfigEntry<float> HookPullPercent; public static ConfigEntry<float> HookReloadLevelCut; public static ConfigEntry<float> HookReloadSkillCut; private static ConfigurationManagerAttributes AdminTag() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true }; } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, string d) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d, (AcceptableValueBase)null, new object[1] { AdminTag() })); } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, ConfigDescription d) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d.Description, d.AcceptableValues, new object[1] { AdminTag() })); } public static void Bind(ConfigFile c) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown Enabled = Adm(c, "1 - General", "Enabled", v: true, "The grappling hook can be upgraded at the Black Forge (a normal material upgrade, always succeeds). Each level adds range (how far it flies and how long the rope can stretch) and pull speed, up to the percentages below at its top level. Upgrading to level N needs a level N Black Forge. Off: the hook is the game's own."); LogDetails = c.Bind<bool>("1 - General", "LogDetails", false, "Write extra lines to the log: the rope length and pull speed every time the hook holds."); HookChainAmount = Adm(c, "2 - Upgrade", "ChainsPerRefine", 4, new ConfigDescription("Chains each refine costs (the same for every refine).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); HookSpringAmount = Adm(c, "2 - Upgrade", "MechanicalSpringsPerRefine", 2, new ConfigDescription("Mechanical Springs (made at the Artisan table) each refine costs (the same for every refine). 0 = no springs.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); HookEitrAmount = Adm(c, "2 - Upgrade", "RefinedEitrPerRefine", 5, new ConfigDescription("Refined Eitr each refine costs (the same for every refine). The rest of the hook's recipe (wood, mandibles, hook) is not charged for refines.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>())); HookMaxLevel = Adm(c, "2 - Upgrade", "MaxLevel", 5, new ConfigDescription("Highest level the hook can be upgraded to. A new hook is level 1, so 5 means four refines.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 30), Array.Empty<object>())); HookRangePercent = Adm(c, "2 - Upgrade", "RangePercentAtMaxLevel", 100f, new ConfigDescription("Extra range at MaxLevel, in %. 100 = twice as far. The hook's flight speed and its rope length (the longest the rope may stretch before it lets go) both grow by this, evenly from level 1 (0%) to MaxLevel.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>())); HookPullPercent = Adm(c, "2 - Upgrade", "PullSpeedPercentAtMaxLevel", 50f, new ConfigDescription("Extra pull speed at MaxLevel, in %. 50 = you are pulled in 1.5 times as fast. Grows evenly from level 1 (0%) to MaxLevel.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); HookReloadLevelCut = Adm(c, "3 - Reload", "ReloadTimeCutPercentAtMaxLevel", 50f, new ConfigDescription("Shorter reload at MaxLevel, in %. 50 = reload takes half as long (2 s becomes 1 s). Grows evenly from level 1 (0%) to MaxLevel.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f), Array.Empty<object>())); HookReloadSkillCut = Adm(c, "3 - Reload", "ReloadTimeCutPercentAtCrossbowSkill100", 50f, new ConfigDescription("Shorter reload at Crossbows skill 100, in %, growing evenly from skill 0 (0%). Stacks with the level bonus. 50 is what the game gives its crossbows. The hook does not train the skill itself. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f), Array.Empty<object>())); } } internal static class Hook { public const string Prefab = "GrapplingHook"; public const string ChainPrefab = "Chain"; public const string SpringPrefab = "MechanicalSpring"; public const string EitrPrefab = "Eitr"; private static Recipe s_recipe; private static bool s_active; private static SharedData s_shared; private static int s_origMaxQuality = 1; private static Requirement s_chain; private static Requirement s_spring; private static readonly Dictionary<Requirement, int> s_refine = new Dictionary<Requirement, int>(); public static void SyncRecipe(ObjectDB db) { //IL_0227: 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_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown try { if ((Object)(object)s_recipe != (Object)null) { Undo(); } if (!Cfg.Enabled.Value) { return; } ItemDrop val = Item(db, "Chain"); ItemDrop val2 = Item(db, "Eitr"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"Grappling hook: Chain or Refined Eitr not found, the hook stays unrefinable"); return; } foreach (Recipe recipe in db.m_recipes) { if ((Object)(object)recipe == (Object)null || (Object)(object)recipe.m_item == (Object)null || ((Object)recipe.m_item).name != "GrapplingHook" || recipe.m_resources == null) { continue; } if (recipe.m_resources.Any((Requirement q) => q?.m_upgraderResource ?? false)) { Plugin.Log.LogWarning((object)"Grappling hook: the recipe already has a Forge idol requirement (another mod?), left alone"); break; } SharedData val3 = ((recipe.m_item.m_itemData != null) ? recipe.m_item.m_itemData.m_shared : null); if (val3 == null) { break; } s_recipe = recipe; s_shared = val3; s_origMaxQuality = val3.m_maxQuality; s_active = true; val3.m_maxQuality = Math.Max(2, Cfg.HookMaxLevel.Value); int value = Cfg.HookEitrAmount.Value; int value2 = Cfg.HookChainAmount.Value; bool flag = false; Requirement[] resources = recipe.m_resources; foreach (Requirement val4 in resources) { if (val4 != null && !((Object)(object)val4.m_resItem == (Object)null)) { if ((Object)(object)val4.m_resItem == (Object)(object)val2) { s_refine[val4] = value; flag = true; } else { s_refine[val4] = 0; } } } List<Requirement> list = new List<Requirement>(recipe.m_resources); if (!flag) { Requirement val5 = new Requirement { m_resItem = val2, m_amount = 0, m_amountPerLevel = 0, m_recover = false }; list.Add(val5); s_refine[val5] = value; } s_chain = new Requirement { m_resItem = val, m_amount = 0, m_amountPerLevel = 0, m_recover = false }; list.Add(s_chain); s_refine[s_chain] = value2; ItemDrop val6 = Item(db, "MechanicalSpring"); int value3 = Cfg.HookSpringAmount.Value; if ((Object)(object)val6 == (Object)null) { Plugin.Log.LogWarning((object)"Grappling hook: Mechanical Spring not found, refines do not cost it"); } else { s_spring = new Requirement { m_resItem = val6, m_amount = 0, m_amountPerLevel = 0, m_recover = false }; list.Add(s_spring); s_refine[s_spring] = value3; } recipe.m_resources = list.ToArray(); Plugin.Log.LogInfo((object)("Grappling hook: refine at the Black Forge up to level " + val3.m_maxQuality + ", " + value2 + " Chain + " + value + " Refined Eitr + " + ((s_spring != null) ? value3 : 0) + " Mechanical Spring per refine")); break; } } catch (Exception ex) { Plugin.Log.LogError((object)("Grappling hook recipe: " + ex)); } } private static ItemDrop Item(ObjectDB db, string name) { GameObject itemPrefab = db.GetItemPrefab(name); if (!((Object)(object)itemPrefab != (Object)null)) { return null; } return itemPrefab.GetComponent<ItemDrop>(); } private static void Undo() { try { if (s_shared != null) { s_shared.m_maxQuality = s_origMaxQuality; } if ((Object)(object)s_recipe != (Object)null && s_chain != null && s_recipe.m_resources != null) { Requirement[] resources = s_recipe.m_resources.Where((Requirement q) => q != s_chain && q != s_spring && (q == null || q.m_amount != 0 || !s_refine.ContainsKey(q) || !((Object)(object)q.m_resItem != (Object)null) || !(((Object)q.m_resItem).name == "Eitr"))).ToArray(); s_recipe.m_resources = resources; } } finally { s_active = false; s_recipe = null; s_shared = null; s_chain = null; s_spring = null; s_refine.Clear(); } } public static int AmountFor(Requirement r, int quality, int vanilla) { if (quality >= 2 && s_active && s_refine.TryGetValue(r, out var value)) { return value; } return vanilla; } public static bool IsHook(ItemData it) { if (it != null && (Object)(object)it.m_dropPrefab != (Object)null) { return ((Object)it.m_dropPrefab).name == "GrapplingHook"; } return false; } public static float Share(int quality, int baseQuality, int maxLevel) { if (maxLevel <= baseQuality) { return 0f; } return Mathf.Clamp01((float)(quality - baseQuality) / (float)(maxLevel - baseQuality)); } public static float ShareOf(ItemData it) { if (!Cfg.Enabled.Value || !IsHook(it)) { return 0f; } return Share(it.m_quality, 1, Math.Max(2, Cfg.HookMaxLevel.Value)); } public static float RangeMult(ItemData it) { return 1f + ShareOf(it) * Mathf.Max(0f, Cfg.HookRangePercent.Value) / 100f; } public static float PullMult(ItemData it) { return 1f + ShareOf(it) * Mathf.Max(0f, Cfg.HookPullPercent.Value) / 100f; } public static float ReloadTime(float baseTime, float levelShare, float skillFactor) { float num = baseTime * (1f - Mathf.Clamp01(levelShare) * Mathf.Clamp(Cfg.HookReloadLevelCut.Value, 0f, 90f) / 100f) * (1f - Mathf.Clamp01(skillFactor) * Mathf.Clamp(Cfg.HookReloadSkillCut.Value, 0f, 90f) / 100f); return Mathf.Max(0.1f, num); } public static float CrossbowSkill() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer != (Object)null)) { return 0f; } return ((Character)localPlayer).GetSkillFactor((SkillType)14); } public static ItemData Equipped(Humanoid h) { if ((Object)(object)h == (Object)null) { return null; } Inventory inventory = h.GetInventory(); if (inventory == null) { return null; } foreach (ItemData equippedItem in inventory.GetEquippedItems()) { if (IsHook(equippedItem)) { return equippedItem; } } return null; } } [HarmonyPatch(typeof(Projectile), "Setup")] internal static class HookFlightPatch { private static void Prefix(ref Vector3 velocity, ItemData item) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) float num = Hook.RangeMult(item); if (num != 1f) { velocity *= num; } } } [HarmonyPatch(typeof(GrapplingPoint), "Activate")] internal static class HookPointPatch { private static readonly ConditionalWeakTable<GrapplingPoint, object> Done = new ConditionalWeakTable<GrapplingPoint, object>(); private static void Postfix(GrapplingPoint __instance, Character character) { ItemData val = Hook.Equipped((Humanoid)(object)((character is Humanoid) ? character : null)); if (val == null) { return; } float num = Hook.RangeMult(val); float num2 = Hook.PullMult(val); if ((num != 1f || num2 != 1f) && !Done.TryGetValue(__instance, out var _)) { Done.Add(__instance, null); __instance.m_maxLength *= num; __instance.m_pullForce *= num2; if (Cfg.LogDetails.Value) { Plugin.Log.LogInfo((object)("Grappling hook level " + val.m_quality + ": rope length " + __instance.m_maxLength.ToString("0.#", CultureInfo.InvariantCulture) + ", pull speed " + __instance.m_pullForce.ToString("0.#", CultureInfo.InvariantCulture))); } } } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int), typeof(bool) })] internal static class HookTooltipPatch { private static void Postfix(ItemData item, int qualityLevel, ref string __result) { if (Cfg.Enabled.Value && Hook.IsHook(item) && item.m_shared != null) { int maxLevel = Math.Max(2, Cfg.HookMaxLevel.Value); float num = Hook.Share(qualityLevel, 1, maxLevel); float num2 = num * Cfg.HookRangePercent.Value; float num3 = num * Cfg.HookPullPercent.Value; __result = __result + "\nRange: <color=orange>+" + num2.ToString("0", CultureInfo.InvariantCulture) + "%</color>\nPull speed: <color=orange>+" + num3.ToString("0", CultureInfo.InvariantCulture) + "%</color>"; float num4 = ((item.m_shared.m_attack != null) ? item.m_shared.m_attack.m_reloadTime : 0f); if (num4 > 0f) { __result = __result + "\nReload: <color=orange>" + Hook.ReloadTime(num4, num, Hook.CrossbowSkill()).ToString("0.##", CultureInfo.InvariantCulture) + " s</color>"; } } } } [HarmonyPatch(typeof(Requirement), "GetAmount", new Type[] { typeof(int) })] internal static class HookAmountPatch { private static void Postfix(Requirement __instance, int qualityLevel, ref int __result) { __result = Hook.AmountFor(__instance, qualityLevel, __result); } } [HarmonyPatch(typeof(ItemData), "GetWeaponLoadingTime")] internal static class HookReloadPatch { private static void Postfix(ItemData __instance, ref float __result) { if (Cfg.Enabled.Value && Hook.IsHook(__instance) && __instance.m_shared != null && __instance.m_shared.m_attack != null && __instance.m_shared.m_attack.m_requiresReload) { float num = Hook.ReloadTime(__instance.m_shared.m_attack.m_reloadTime, Hook.ShareOf(__instance), Hook.CrossbowSkill()); if (Cfg.LogDetails.Value) { Plugin.Log.LogInfo((object)("Grappling hook level " + __instance.m_quality + ": reload " + num.ToString("0.##", CultureInfo.InvariantCulture) + " s")); } __result = num; } } } [BepInPlugin("pucko.grapplinghookreforged", "GrapplingHookReforged", "1.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "pucko.grapplinghookreforged"; public const string NAME = "GrapplingHookReforged"; public const string VERSION = "1.2.1"; internal static ManualLogSource Log; private static bool s_dirty = true; private ObjectDB _lastDb; private Harmony _harmony; private FileSystemWatcher _watcher; private long _fileChangedTicks; internal static void MarkDirty() { s_dirty = true; } private void Awake() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Cfg.Bind(((BaseUnityPlugin)this).Config); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { s_dirty = true; }; ((BaseUnityPlugin)this).Config.ConfigReloaded += delegate { s_dirty = true; }; SynchronizationManager.OnConfigurationSynchronized += delegate(object s, ConfigurationSynchronizationEventArgs e) { if (e.UpdatedPluginGUIDs == null || !e.UpdatedPluginGUIDs.Contains("pucko.grapplinghookreforged")) { return; } Log.LogInfo((object)(e.InitialSynchronization ? "Received the server's settings" : "Server settings updated")); s_dirty = true; try { if (!e.InitialSynchronization && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ((BaseUnityPlugin)this).Config.Save(); Log.LogInfo((object)("Saved the admin's changes to " + Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath))); } } catch (Exception ex) { Log.LogError((object)("Saving synced settings failed: " + ex.Message)); } }; ItemManager.OnItemsRegistered += MarkDirty; ItemManager.OnItemsRegisteredFejd += MarkDirty; _harmony = new Harmony("pucko.grapplinghookreforged"); _harmony.PatchAll(typeof(Plugin).Assembly); WatchConfigFile(); Log.LogInfo((object)"GrapplingHookReforged 1.2.1 loaded"); } private void WatchConfigFile() { try { _watcher = new FileSystemWatcher(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath)); _watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite; _watcher.Changed += OnFileEvent; _watcher.Created += OnFileEvent; _watcher.Renamed += OnFileEvent; _watcher.EnableRaisingEvents = true; } catch (Exception ex) { Log.LogWarning((object)("Config file watching is unavailable, changes need a restart: " + ex.Message)); } } private void OnFileEvent(object sender, FileSystemEventArgs e) { Interlocked.Exchange(ref _fileChangedTicks, DateTime.UtcNow.Ticks); } private void Update() { long num = Interlocked.Read(in _fileChangedTicks); if (num != 0L && DateTime.UtcNow.Ticks - num > 5000000) { Interlocked.Exchange(ref _fileChangedTicks, 0L); try { ((BaseUnityPlugin)this).Config.Reload(); Log.LogInfo((object)"Config file changed on disk, reloaded"); } catch (Exception ex) { Log.LogError((object)("Config reload failed: " + ex.Message)); } s_dirty = true; } ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance != (Object)(object)_lastDb) { _lastDb = instance; s_dirty = true; } if (s_dirty && (Object)(object)instance != (Object)null && instance.m_recipes != null && instance.m_recipes.Count > 0) { s_dirty = false; try { Hook.SyncRecipe(instance); } catch (Exception ex2) { Log.LogError((object)("Applying the config failed: " + ex2)); } } } private void OnDestroy() { if (_watcher != null) { _watcher.EnableRaisingEvents = false; _watcher.Dispose(); } } }
plugins/EinsteinCrew-PuckosCarePackage/Pucko-NordVPO/NordVPO.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using NordVPO.Extensions; using NordVPO.Patches; using NordVPO.Patches.ObjectManagement; using NordVPO.Patches.Water; using NordVPO.Profiling; using NordVPO.RuntimeDebugDraw.Internal; using Unity.Burst; using Unity.Collections; using Unity.Jobs; using Unity.Mathematics; using Unity.Profiling; using Unity.Profiling.LowLevel.Unsafe; using UnityEngine; using UnityEngine.Profiling; using UnityEngine.Rendering; using UnityEngine.Scripting; using VPOBurst; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: AssemblyTitle("NordVPO")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("NordVPO")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("AD2F8A00-7A5E-460D-80ED-F48DF0221D8C")] [assembly: AssemblyFileVersion("0.1.28")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.28.0")] [module: UnverifiableCode] [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; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace NordVPO { public sealed class LoadingGuard : MonoBehaviour { internal static int DeadInstancesRemoved; internal static int FlagsRepaired; internal static int ObjectsSpawnedByGuard; internal static int Errors; private static ConfigEntry<bool> _enabled; private static ConfigEntry<float> _rescueAfter; private static ConfigEntry<float> _spawnAfter; private static ConfigEntry<bool> _backgroundCleanup; private static ConfigEntry<bool> _logLoadTimes; private static ConfigEntry<bool> _logTimeline; private float _nextTimeline; private static readonly List<ZDO> AreaObjects = new List<ZDO>(); private static readonly Dictionary<string, int> ErrorCounts = new Dictionary<string, int>(); private static float _lastErrorSummary; private bool _inLoading; private string _loadingKind; private float _loadingStart; private bool _rescued; private float _nextSpawnAttempt; private float _armedAt = -1f; private float _lastProgress; private long _progressSig; private int _deadAtStart; private int _spawnedAtStart; internal static void BindConfig(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown _enabled = config.Bind<bool>("3 - Loading screen safety net", "Enabled", true, "Watches loading screens after death, portals and joining. If one takes too long, it finds and fixes the objects that keep it from finishing, instead of you having to relog."); _rescueAfter = config.Bind<float>("3 - Loading screen safety net", "Rescue after (seconds)", 15f, new ConfigDescription("How long a loading screen may last after the game has started receiving objects (a join) or from the start (a portal), with no progress for 5 seconds, before the safety net checks what is blocking it and repairs the bookkeeping. Portals to far places always take at least 8 seconds in the base game.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 120f), Array.Empty<object>())); _spawnAfter = config.Bind<float>("3 - Loading screen safety net", "Spawn missing after (seconds)", 25f, new ConfigDescription("If still loading after this long, the safety net spawns the missing objects around you directly. Repeats every 10 seconds while the loading screen lasts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 180f), Array.Empty<object>())); _backgroundCleanup = config.Bind<bool>("3 - Loading screen safety net", "Background cleanup", true, "Continuously checks a small slice of loaded objects each frame for ones that were destroyed without being unregistered (the cause of the endless loading screen), and lets them respawn properly."); _logLoadTimes = config.Bind<bool>("3 - Loading screen safety net", "Log loading times", true, "Writes how long each respawn, portal and join loading screen took to the BepInEx log."); _logTimeline = config.Bind<bool>("3 - Loading screen safety net", "Log loading timeline", true, "While a loading screen is up, writes a line every 2 seconds with what the game is waiting for: terrain ready or not, terrain build queue, objects known and spawned. Shows why a join takes as long as it does."); } internal static void ReportError(string what, Exception e) { Errors++; ErrorCounts.TryGetValue(what, out var value); ErrorCounts[what] = value + 1; if (value < 3) { NordVPO.Logger.LogWarning((object)$"Error while {what} (handled, the game continues): {e}"); } else if (Time.realtimeSinceStartup - _lastErrorSummary > 60f) { _lastErrorSummary = Time.realtimeSinceStartup; NordVPO.Logger.LogWarning((object)$"Error while {what} happened {value + 1} times so far (handled). Last: {e.Message}"); } } private void Update() { VeeCompat.Tick(); try { Tick(); } catch (Exception e) { ReportError("running the loading screen safety net", e); } } private void Tick() { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) if (_enabled == null || !_enabled.Value) { return; } ZNetScene instance = ZNetScene.instance; ZNet instance2 = ZNet.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance2) || !Object.op_Implicit((Object)(object)Game.instance) || instance2.IsDedicated()) { _inLoading = false; return; } Player localPlayer = Player.m_localPlayer; bool flag = !Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsTeleporting(); if (_backgroundCleanup.Value) { ZNetSceneObjectManagementPatch.SweepDeadInstances(instance, flag ? 5000 : 250); } if (!flag) { if (_inLoading) { EndLoading(); } return; } if (!_inLoading) { _inLoading = true; _loadingKind = (Object.op_Implicit((Object)(object)localPlayer) ? "Portal/teleport" : "Respawn/join"); _loadingStart = Time.realtimeSinceStartup; _rescued = false; _nextSpawnAttempt = 0f; _armedAt = (Object.op_Implicit((Object)(object)localPlayer) ? 0f : (-1f)); _lastProgress = 0f; _progressSig = 0L; _deadAtStart = DeadInstancesRemoved; _spawnedAtStart = ObjectsSpawnedByGuard; _nextTimeline = 0f; return; } float num = Time.realtimeSinceStartup - _loadingStart; Vector3 target = (Object.op_Implicit((Object)(object)localPlayer) ? localPlayer.m_teleportTargetPos : instance2.GetReferencePosition()); if (_logTimeline != null && _logTimeline.Value && num >= _nextTimeline) { _nextTimeline = num + 2f; LogTimeline(instance, target, num); } long num2 = (long)((ZDOMan.instance != null) ? ZDOMan.instance.NrOfObjects() : 0) * 1000003L + ((instance.m_instances != null) ? instance.m_instances.Count : 0); HeightmapBuilder instance3 = HeightmapBuilder.instance; if (instance3 != null && instance3.m_ready != null && instance3.m_toBuild != null) { num2 += ((long)instance3.m_ready.Count * 7919L + instance3.m_toBuild.Count) * 31; } if (num2 != _progressSig) { _progressSig = num2; _lastProgress = num; } if (_armedAt < 0f) { if (Object.op_Implicit((Object)(object)localPlayer) || num2 <= 0 || ZDOMan.instance == null || ZDOMan.instance.NrOfObjects() <= 0) { return; } _armedAt = num; _lastProgress = num; } float num3 = num - _armedAt; float num4 = num - _lastProgress; if (!_rescued && num3 >= _rescueAfter.Value && num4 >= 5f) { _rescued = true; Rescue(instance, target, num); _nextSpawnAttempt = Mathf.Max(_armedAt + _spawnAfter.Value, num + 1f); } else if (_rescued && num >= _nextSpawnAttempt && num4 >= 5f) { _nextSpawnAttempt = num + 10f; SpawnMissing(instance, target, num); } } private static void LogTimeline(ZNetScene scene, Vector3 target, float elapsed) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) try { bool flag = ZoneSystem.instance.IsZoneLoaded(ZoneSystem.GetZone(target)); HeightmapBuilder instance = HeightmapBuilder.instance; int num = ((instance != null && instance.m_toBuild != null) ? instance.m_toBuild.Count : (-1)); int num2 = ((instance != null && instance.m_ready != null) ? instance.m_ready.Count : (-1)); int num3 = ((ZDOMan.instance != null) ? ZDOMan.instance.NrOfObjects() : (-1)); int num4 = ((scene.m_instances != null) ? scene.m_instances.Count : (-1)); bool flag2 = scene.IsAreaReady(target); NordVPO.Logger.LogInfo((object)(string.Format("Loading {0:0.0} s: target terrain {1}, area ready {2}, terrain builds waiting {3}, built {4}, ", elapsed, flag ? "ready" : "NOT ready", flag2, num, num2) + $"objects known {num3}, spawned {num4}, frame {Time.unscaledDeltaTime * 1000f:0} ms.")); } catch (Exception e) { ReportError("logging the loading timeline", e); } } private void EndLoading() { _inLoading = false; if (_loadingKind == "Respawn/join") { VeeCompat.RequestRemerge(ObjectsSpawnedByGuard > _spawnedAtStart); } float num = Time.realtimeSinceStartup - _loadingStart; if (_logLoadTimes.Value || _rescued) { int num2 = DeadInstancesRemoved - _deadAtStart; NordVPO.Logger.LogInfo((object)($"{_loadingKind} loading screen took {num:0.0} s" + ((num2 > 0) ? $"; {num2} destroyed-but-registered objects were cleaned up during it" : "") + (_rescued ? " (the safety net stepped in)" : ""))); } } private void Rescue(ZNetScene scene, Vector3 target, float elapsed) { //IL_000d: 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) int num = ZNetSceneObjectManagementPatch.SweepDeadInstances(scene, int.MaxValue); int blockers; string text = Diagnose(scene, target, out blockers, repair: true); NordVPO.Logger.LogWarning((object)$"Loading screen still up after {elapsed:0} s; target {target:F0}. Removed {num} dead objects. {text}"); ZNetSceneObjectManagementPatch.RequestFullRescan(); if (blockers == 0) { NordVPO.Logger.LogInfo((object)"No blocking objects found around the target; the game is waiting on terrain or the server."); } } private void SpawnMissing(ZNetScene scene, Vector3 target, float elapsed) { //IL_0011: 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_0041: Unknown result type (might be due to invalid IL or missing references) ZNetSceneObjectManagementPatch.SweepDeadInstances(scene, int.MaxValue); if (!ZoneSystem.instance.IsZoneLoaded(ZoneSystem.GetZone(target))) { NordVPO.Logger.LogWarning((object)$"Still loading after {elapsed:0} s: the terrain at the target is not loaded yet (server or network)."); return; } int num = 0; StringBuilder stringBuilder = new StringBuilder(); CollectAreaObjects(target); foreach (ZDO areaObject in AreaObjects) { if (scene.IsPrefabZDOValid(areaObject) && !Object.op_Implicit((Object)(object)scene.FindInstance(areaObject))) { if (areaObject.Created) { areaObject.Created = false; FlagsRepaired++; } GameObject val = null; try { val = scene.CreateObject(areaObject); } catch (Exception e) { ReportError("spawning " + PrefabName(scene, areaObject), e); } if (Object.op_Implicit((Object)(object)val)) { num++; ObjectsSpawnedByGuard++; } else if (stringBuilder.Length < 400) { stringBuilder.Append(PrefabName(scene, areaObject)).Append(' '); } } } NordVPO.Logger.LogWarning((object)($"Still loading after {elapsed:0} s: spawned {num} missing objects directly." + ((stringBuilder.Length > 0) ? (" Could not spawn: " + stringBuilder) : ""))); } internal static string Diagnose(ZNetScene scene, Vector3 target, out int blockers, bool repair) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_001c: 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_00e9: 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_0103: 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_0168: Unknown result type (might be due to invalid IL or missing references) blockers = 0; Vector2s zone = ZoneSystem.GetZone(target); if (!ZoneSystem.instance.IsZoneLoaded(zone)) { return $"Terrain of zone {zone.x},{zone.y} is not loaded yet."; } CollectAreaObjects(target); int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; StringBuilder stringBuilder = new StringBuilder(); foreach (ZDO areaObject in AreaObjects) { if (!scene.IsPrefabZDOValid(areaObject) || Object.op_Implicit((Object)(object)scene.FindInstance(areaObject))) { continue; } blockers++; string text; if (scene.m_instances.ContainsKey(areaObject)) { num++; text = "destroyed but still registered"; if (repair) { ZNetSceneObjectManagementPatch.ForgetDeadInstance(scene, areaObject); } } else if (areaObject.Created) { num2++; text = "marked as spawned but has no instance"; if (repair) { areaObject.Created = false; FlagsRepaired++; } } else if (ZNetSceneObjectManagementPatch.IsQueued(areaObject.m_uid)) { if (ZoneSystem.instance.IsZoneReadyForType(areaObject.GetSector(), areaObject.Type)) { num3++; text = "queued, waiting its turn"; } else { num4++; text = "queued, zone not ready for its type"; } } else { num5++; text = "not queued for spawning"; } if (blockers <= 8) { stringBuilder.Append($"\n {PrefabName(scene, areaObject)} {areaObject.m_uid} at {areaObject.GetPosition():F0}: {text}"); } } if (blockers == 0) { return "Area check passes now."; } return $"{blockers} objects block the area: {num} destroyed-but-registered, {num2} flagged-without-instance, " + $"{num5} not queued, {num3} queued, {num4} queued-but-zone-not-ready. " + "Object manager: " + (ZNetSceneObjectManagementPatch.IsTracking ? ZNetSceneObjectManagementPatch.DescribeQueues() : "not active") + "." + stringBuilder; } private static void CollectAreaObjects(Vector3 target) { //IL_000f: 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_0018: Unknown result type (might be due to invalid IL or missing references) AreaObjects.Clear(); ZDOMan.instance.FindSectorObjects(ZoneSystem.GetZone(target), new SimulationDistance(1, 0, false), AreaObjects, (List<ZDO>)null); } private static string PrefabName(ZNetScene scene, ZDO zdo) { GameObject prefab = scene.GetPrefab(zdo.GetPrefab()); if (!Object.op_Implicit((Object)(object)prefab)) { return "prefab#" + zdo.GetPrefab(); } return ((Object)prefab).name; } } public static class AssetBundleHelper { public static AssetBundle GetAssetBundleFromResources(string fileName) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(fileName)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } } public class BoundsOctreeNode<T> { private struct OctreeObject { public T Obj; public Bounds Bounds; } private float looseness; private float minSize; private float adjLength; private Bounds bounds; private readonly List<OctreeObject> objects = new List<OctreeObject>(); private BoundsOctreeNode<T>[] children; private Bounds[] childBounds; private IEqualityComparer<T> comparator; private const int NUM_OBJECTS_ALLOWED = 8; public Vector3 Center { get; private set; } public float BaseLength { get; private set; } private bool HasChildren => children != null; public BoundsOctreeNode(float baseLengthVal, float minSizeVal, float loosenessVal, Vector3 centerVal, IEqualityComparer<T> comparer = null) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) SetValues(baseLengthVal, minSizeVal, loosenessVal, centerVal, comparer); } public bool Add(T obj, Bounds objBounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!Encapsulates(bounds, objBounds)) { return false; } SubAdd(obj, objBounds); return true; } public bool Remove(T obj) { bool flag = false; for (int i = 0; i < objects.Count; i++) { if (comparator.Equals(objects[i].Obj, obj)) { objects.RemoveAtSwapBack(i); flag = true; break; } } if (!flag && children != null) { for (int j = 0; j < 8; j++) { flag = children[j].Remove(obj); if (flag) { break; } } } if (flag && children != null && ShouldMerge()) { Merge(); } return flag; } public bool Remove(T obj, Bounds objBounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!Encapsulates(bounds, objBounds)) { return false; } return SubRemove(obj, objBounds, parentContained: false); } public int RemoveAll(Bounds objBounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!Encapsulates(bounds, objBounds)) { return 0; } return SubRemoveAll(objBounds); } public bool IsColliding(ref Bounds checkBounds) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!((Bounds)(ref bounds)).Intersects(checkBounds)) { return false; } for (int i = 0; i < objects.Count; i++) { OctreeObject octreeObject = objects[i]; if (((Bounds)(ref octreeObject.Bounds)).Intersects(checkBounds)) { return true; } } if (children != null) { for (int j = 0; j < 8; j++) { if (children[j].IsColliding(ref checkBounds)) { return true; } } } return false; } public bool IsColliding(ref Ray checkRay, float maxDistance = float.PositiveInfinity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) float num = default(float); if (!((Bounds)(ref bounds)).IntersectRay(checkRay, ref num) || num > maxDistance) { return false; } for (int i = 0; i < objects.Count; i++) { OctreeObject octreeObject = objects[i]; if (((Bounds)(ref octreeObject.Bounds)).IntersectRay(checkRay, ref num) && num <= maxDistance) { return true; } } if (children != null) { for (int j = 0; j < 8; j++) { if (children[j].IsColliding(ref checkRay, maxDistance)) { return true; } } } return false; } public void GetOverlapping(ref Bounds checkBounds, List<T> result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!((Bounds)(ref bounds)).Intersects(checkBounds)) { return; } for (int i = 0; i < objects.Count; i++) { OctreeObject octreeObject = objects[i]; if (((Bounds)(ref octreeObject.Bounds)).Intersects(checkBounds)) { result.Add(objects[i].Obj); } } if (children != null) { for (int j = 0; j < 8; j++) { children[j].GetOverlapping(ref checkBounds, result); } } } public void GetOverlapping(Vector3 center, float radius, List<T> collidingWith) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!bounds.IntersectsSphere(center, radius)) { return; } for (int i = 0; i < objects.Count; i++) { if (objects[i].Bounds.IntersectsSphere(center, radius)) { collidingWith.Add(objects[i].Obj); } } if (children != null) { for (int j = 0; j < 8; j++) { children[j].GetOverlapping(center, radius, collidingWith); } } } public void GetOverlappingXZ(ref Bounds checkBounds, List<T> result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!bounds.IntersectsXZ(checkBounds)) { return; } for (int i = 0; i < objects.Count; i++) { if (objects[i].Bounds.IntersectsXZ(checkBounds)) { result.Add(objects[i].Obj); } } if (children != null) { for (int j = 0; j < 8; j++) { children[j].GetOverlappingXZ(ref checkBounds, result); } } } public void GetColliding(ref Ray checkRay, List<T> result, float maxDistance = float.PositiveInfinity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) float num = default(float); if (!((Bounds)(ref bounds)).IntersectRay(checkRay, ref num) || num > maxDistance) { return; } for (int i = 0; i < objects.Count; i++) { OctreeObject octreeObject = objects[i]; if (((Bounds)(ref octreeObject.Bounds)).IntersectRay(checkRay, ref num) && num <= maxDistance) { result.Add(objects[i].Obj); } } if (children != null) { for (int j = 0; j < 8; j++) { children[j].GetColliding(ref checkRay, result, maxDistance); } } } public void GetWithinFrustum(Plane[] planes, List<T> result) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!GeometryUtility.TestPlanesAABB(planes, bounds)) { return; } for (int i = 0; i < objects.Count; i++) { if (GeometryUtility.TestPlanesAABB(planes, objects[i].Bounds)) { result.Add(objects[i].Obj); } } if (children != null) { for (int j = 0; j < 8; j++) { children[j].GetWithinFrustum(planes, result); } } } public void SetChildren(BoundsOctreeNode<T>[] childOctrees) { if (childOctrees.Length != 8) { Debug.LogError((object)("Child octree array must be length 8. Was length: " + childOctrees.Length)); } else { children = childOctrees; } } public Bounds GetBounds() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return bounds; } public void DrawAllBounds(float depth = 0f) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0069: Unknown result type (might be due to invalid IL or missing references) float num = depth / 7f; new Color(num, 0f, 1f - num); new Bounds(Center, new Vector3(adjLength, adjLength, adjLength)); if (children != null) { depth += 1f; for (int i = 0; i < 8; i++) { children[i].DrawAllBounds(depth); } } Gizmos.color = Color.white; } public void DrawAllObjects() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_009f: Unknown result type (might be due to invalid IL or missing references) float num = BaseLength / 20f; Gizmos.color = new Color(0f, 1f - num, num, 0.25f); foreach (OctreeObject @object in objects) { Bounds val = @object.Bounds; Vector3 center = ((Bounds)(ref val)).center; val = @object.Bounds; Gizmos.DrawCube(center, ((Bounds)(ref val)).size); } if (children != null) { for (int i = 0; i < 8; i++) { children[i].DrawAllObjects(); } } Gizmos.color = Color.white; } public BoundsOctreeNode<T> ShrinkIfPossible(float minLength) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (BaseLength < 2f * minLength) { return this; } if (objects.Count == 0 && (children == null || children.Length == 0)) { return this; } int num = -1; for (int i = 0; i < objects.Count; i++) { OctreeObject octreeObject = objects[i]; int num2 = BestFitChild(((Bounds)(ref octreeObject.Bounds)).center); if (i == 0 || num2 == num) { if (Encapsulates(childBounds[num2], octreeObject.Bounds)) { if (num < 0) { num = num2; } continue; } return this; } return this; } if (children != null) { bool flag = false; for (int j = 0; j < children.Length; j++) { if (children[j].HasAnyObjects()) { if (flag) { return this; } if (num >= 0 && num != j) { return this; } flag = true; num = j; } } } if (children == null) { SetValues(BaseLength / 2f, minSize, looseness, ((Bounds)(ref childBounds[num])).center); return this; } if (num == -1) { return this; } return children[num]; } public int BestFitChild(Vector3 objBoundsCenter) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) return ((!(objBoundsCenter.x <= Center.x)) ? 1 : 0) + ((!(objBoundsCenter.y >= Center.y)) ? 4 : 0) + ((!(objBoundsCenter.z <= Center.z)) ? 2 : 0); } public bool HasAnyObjects() { if (objects.Count > 0) { return true; } if (children != null) { for (int i = 0; i < 8; i++) { if (children[i].HasAnyObjects()) { return true; } } } return false; } private void SetValues(float baseLengthVal, float minSizeVal, float loosenessVal, Vector3 centerVal, IEqualityComparer<T> comparer = null) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0051: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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) //IL_00d5: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) BaseLength = baseLengthVal; minSize = minSizeVal; looseness = loosenessVal; Center = centerVal; adjLength = looseness * baseLengthVal; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(adjLength, adjLength, adjLength); bounds = new Bounds(Center, val); float num = BaseLength / 4f; float num2 = BaseLength / 2f * looseness; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(num2, num2, num2); childBounds = (Bounds[])(object)new Bounds[8]; childBounds[0] = new Bounds(Center + new Vector3(0f - num, num, 0f - num), val2); childBounds[1] = new Bounds(Center + new Vector3(num, num, 0f - num), val2); childBounds[2] = new Bounds(Center + new Vector3(0f - num, num, num), val2); childBounds[3] = new Bounds(Center + new Vector3(num, num, num), val2); childBounds[4] = new Bounds(Center + new Vector3(0f - num, 0f - num, 0f - num), val2); childBounds[5] = new Bounds(Center + new Vector3(num, 0f - num, 0f - num), val2); childBounds[6] = new Bounds(Center + new Vector3(0f - num, 0f - num, num), val2); childBounds[7] = new Bounds(Center + new Vector3(num, 0f - num, num), val2); comparator = comparer ?? EqualityComparer<T>.Default; } private void SubAdd(T obj, Bounds objBounds) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00a0: 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_00ba: 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) if (!HasChildren) { if (objects.Count < 8 || BaseLength / 2f < minSize) { OctreeObject item = new OctreeObject { Obj = obj, Bounds = objBounds }; objects.Add(item); return; } if (children == null) { Split(); if (children == null) { Debug.LogError((object)"Child creation failed for an unknown reason. Early exit."); return; } for (int num = objects.Count - 1; num >= 0; num--) { OctreeObject item2 = objects[num]; int num2 = BestFitChild(((Bounds)(ref item2.Bounds)).center); if (Encapsulates(children[num2].bounds, item2.Bounds)) { children[num2].SubAdd(item2.Obj, item2.Bounds); objects.Remove(item2); } } } } int num3 = BestFitChild(((Bounds)(ref objBounds)).center); if (Encapsulates(children[num3].bounds, objBounds)) { children[num3].SubAdd(obj, objBounds); return; } OctreeObject item3 = new OctreeObject { Obj = obj, Bounds = objBounds }; objects.Add(item3); } private bool SubRemove(T obj, Bounds objBounds, bool parentContained) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) bool flag = false; for (int i = 0; i < objects.Count; i++) { OctreeObject octreeObject = objects[i]; if (comparator.Equals(octreeObject.Obj, obj)) { objects.RemoveAtSwapBack(i); flag = true; break; } } if (!flag && children != null) { int num = BestFitChild(((Bounds)(ref objBounds)).center); BoundsOctreeNode<T> boundsOctreeNode = children[num]; if (((Bounds)(ref objBounds)).Intersects(boundsOctreeNode.bounds)) { flag = boundsOctreeNode.SubRemove(obj, objBounds, parentContained); } if (!flag) { for (int j = 0; j < children.Length; j++) { if (num == j) { continue; } boundsOctreeNode = children[j]; bool flag2 = parentContained; if (!flag2) { if (Encapsulates(objBounds, boundsOctreeNode.bounds)) { flag2 = true; } else if (!((Bounds)(ref objBounds)).Intersects(boundsOctreeNode.bounds)) { continue; } } if (((Bounds)(ref objBounds)).Intersects(boundsOctreeNode.bounds)) { flag = boundsOctreeNode.SubRemove(obj, objBounds, flag2); if (flag) { break; } } } } } if (flag && children != null && ShouldMerge()) { Merge(); } return flag; } private int SubRemoveAll(Bounds objBounds) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) int num = objects.RemoveAll((OctreeObject obj) => ((Bounds)(ref obj.Bounds)).Intersects(objBounds)); if (num < 1 && children != null) { int num2 = BestFitChild(((Bounds)(ref objBounds)).center); num = children[num2].SubRemoveAll(objBounds); } if (num > 0 && children != null && ShouldMerge()) { Merge(); } return num; } private void Split() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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) float num = BaseLength / 4f; float baseLengthVal = BaseLength / 2f; children = new BoundsOctreeNode<T>[8]; children[0] = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, Center + new Vector3(0f - num, num, 0f - num)); children[1] = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, Center + new Vector3(num, num, 0f - num)); children[2] = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, Center + new Vector3(0f - num, num, num)); children[3] = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, Center + new Vector3(num, num, num)); children[4] = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, Center + new Vector3(0f - num, 0f - num, 0f - num)); children[5] = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, Center + new Vector3(num, 0f - num, 0f - num)); children[6] = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, Center + new Vector3(0f - num, 0f - num, num)); children[7] = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, Center + new Vector3(num, 0f - num, num)); } private void Merge() { for (int i = 0; i < 8; i++) { BoundsOctreeNode<T> boundsOctreeNode = children[i]; for (int num = boundsOctreeNode.objects.Count - 1; num >= 0; num--) { OctreeObject item = boundsOctreeNode.objects[num]; objects.Add(item); } } children = null; } private static bool Encapsulates(Bounds outerBounds, Bounds innerBounds) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (((Bounds)(ref outerBounds)).Contains(((Bounds)(ref innerBounds)).min)) { return ((Bounds)(ref outerBounds)).Contains(((Bounds)(ref innerBounds)).max); } return false; } private bool ShouldMerge() { int num = objects.Count; if (children != null) { BoundsOctreeNode<T>[] array = children; foreach (BoundsOctreeNode<T> boundsOctreeNode in array) { if (boundsOctreeNode.children != null) { return false; } num += boundsOctreeNode.objects.Count; } } return num <= 8; } } public class BoundsOctree<T> { private BoundsOctreeNode<T> rootNode; private readonly float looseness; private readonly float initialSize; private readonly float minSize; public int Count { get; private set; } public BoundsOctree(float initialWorldSize, Vector3 initialWorldPos, float minNodeSize, float loosenessVal, IEqualityComparer<T> comparer = null) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (minNodeSize > initialWorldSize) { Debug.LogWarning((object)("Minimum node size must be at least as big as the initial world size. Was: " + minNodeSize + " Adjusted to: " + initialWorldSize)); minNodeSize = initialWorldSize; } Count = 0; initialSize = initialWorldSize; minSize = minNodeSize; looseness = Mathf.Clamp(loosenessVal, 1f, 2f); rootNode = new BoundsOctreeNode<T>(initialSize, minSize, looseness, initialWorldPos, comparer); } public void Add(T obj, Bounds objBounds) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0017: Unknown result type (might be due to invalid IL or missing references) int num = 0; while (!rootNode.Add(obj, objBounds)) { Grow(((Bounds)(ref objBounds)).center - rootNode.Center); if (++num > 20) { Debug.LogError((object)("Aborted Add operation as it seemed to be going on forever (" + (num - 1) + ") attempts at growing the octree.")); return; } } Count++; } public bool Remove(T obj) { bool num = rootNode.Remove(obj); if (num) { Count--; Shrink(); } return num; } public bool Remove(T obj, Bounds objBounds) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) bool num = rootNode.Remove(obj, objBounds); if (num) { Count--; Shrink(); } return num; } public bool IsColliding(Bounds checkBounds) { return rootNode.IsColliding(ref checkBounds); } public bool IsColliding(Ray checkRay, float maxDistance) { return rootNode.IsColliding(ref checkRay, maxDistance); } public void GetOverlapping(List<T> collidingWith, Bounds checkBounds) { rootNode.GetOverlapping(ref checkBounds, collidingWith); } public void GetOverlapping(List<T> collidingWith, Vector3 center, float radius) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) rootNode.GetOverlapping(center, radius, collidingWith); } public void GetOverlappingXZ(List<T> collidingWith, Bounds checkBounds) { rootNode.GetOverlappingXZ(ref checkBounds, collidingWith); } public void GetOverlapping(List<T> collidingWith, Ray checkRay, float maxDistance = float.PositiveInfinity) { rootNode.GetColliding(ref checkRay, collidingWith, maxDistance); } public List<T> GetWithinFrustum(Camera cam) { Plane[] planes = GeometryUtility.CalculateFrustumPlanes(cam); List<T> result = new List<T>(); rootNode.GetWithinFrustum(planes, result); return result; } public Bounds GetMaxBounds() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return rootNode.GetBounds(); } public void DrawAllBounds() { rootNode.DrawAllBounds(); } public void DrawAllObjects() { rootNode.DrawAllObjects(); } private void Grow(Vector3 direction) { //IL_0000: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00b7: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) int num = ((direction.x >= 0f) ? 1 : (-1)); int num2 = ((direction.y >= 0f) ? 1 : (-1)); int num3 = ((direction.z >= 0f) ? 1 : (-1)); BoundsOctreeNode<T> boundsOctreeNode = rootNode; float num4 = rootNode.BaseLength / 2f; float baseLengthVal = rootNode.BaseLength * 2f; Vector3 val = rootNode.Center + new Vector3((float)num * num4, (float)num2 * num4, (float)num3 * num4); rootNode = new BoundsOctreeNode<T>(baseLengthVal, minSize, looseness, val); if (!boundsOctreeNode.HasAnyObjects()) { return; } int num5 = rootNode.BestFitChild(boundsOctreeNode.Center); BoundsOctreeNode<T>[] array = new BoundsOctreeNode<T>[8]; for (int i = 0; i < 8; i++) { if (i == num5) { array[i] = boundsOctreeNode; continue; } num = ((i % 2 != 0) ? 1 : (-1)); num2 = ((i <= 3) ? 1 : (-1)); num3 = ((i >= 2 && (i <= 3 || i >= 6)) ? 1 : (-1)); array[i] = new BoundsOctreeNode<T>(boundsOctreeNode.BaseLength, minSize, looseness, val + new Vector3((float)num * num4, (float)num2 * num4, (float)num3 * num4)); } rootNode.SetChildren(array); } private void Shrink() { rootNode = rootNode.ShrinkIfPossible(initialSize); } } public static class BurstLoader { public const string WindowsBurstLibraryFileName = "VPOBurst_win_x86_64.dll"; public const string LinuxBurstLibraryFileName = "VPOBurst_linux_x86_64.so"; public static bool LibraryLoaded { get; private set; } public static bool JobsAreBursted { get; private set; } public static void Initialize() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_0060: Unknown result type (might be due to invalid IL or missing references) string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (string.IsNullOrEmpty(directoryName)) { NordVPO.Logger.LogWarning((object)"VPO Burst: could not resolve plugin directory"); return; } string text = (((int)Application.platform != 2) ? (((int)Application.platform == 13 || (int)Application.platform == 43) ? "VPOBurst_linux_x86_64.so" : null) : "VPOBurst_win_x86_64.dll"); if (text == null) { NordVPO.Logger.LogWarning((object)$"VPO Burst: unsupported Unity platform '{Application.platform}'"); return; } string text2 = Path.Combine(directoryName, text); if (!File.Exists(text2)) { NordVPO.Logger.LogWarning((object)("VPO Burst: missing '" + text + "' next to the plugin.")); return; } LibraryLoaded = BurstRuntime.LoadAdditionalLibrary(text2); if (!LibraryLoaded) { NordVPO.Logger.LogWarning((object)("VPO Burst: BurstRuntime.LoadAdditionalLibrary failed for '" + text2 + "'")); } JobsAreBursted = ProbeIsBursted(); if (JobsAreBursted) { NordVPO.Logger.LogInfo((object)"VPO Burst: Burst jobs are enabled"); } else { NordVPO.Logger.LogWarning((object)"VPO Burst: Burst jobs are disabled"); } } private static string GetBurstLibraryFileName() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if ((int)Application.platform == 2) { return "VPOBurst_win_x86_64.dll"; } if ((int)Application.platform == 13) { return "VPOBurst_linux_x86_64.so"; } return null; } public static bool ProbeIsBursted() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_001a: Unknown result type (might be due to invalid IL or missing references) NativeArray<int> flag = default(NativeArray<int>); flag..ctor(1, (Allocator)3, (NativeArrayOptions)0); try { IJobExtensions.Run<CheckBurstedJob>(new CheckBurstedJob { Flag = flag }); return flag[0] == 1; } finally { flag.Dispose(); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("dev.ontrigger.vpo")] [BepInPlugin("pucko.nordvpo", "NordVPO", "0.1.28")] public class NordVPO : BaseUnityPlugin { public const string PluginId = "pucko.nordvpo"; public const string PluginName = "NordVPO"; public const string PluginVersion = "0.1.28"; internal const string OriginalVpoId = "dev.ontrigger.vpo"; internal const string ValheimRaftId = "BepIn.Sarcen.ValheimRAFT"; internal const string JotunnId = "com.jotunn.jotunn"; internal const string HDTerrain = "Badgers.ValheimHDTerrain"; private static NordVPO _instance; private Harmony _harmony; internal static ManualLogSource Logger { get; private set; } public static event Action<ConfigFile, Harmony> OnInitialized; private NordVPO() { Logger = ((BaseUnityPlugin)this).Logger; } private void Awake() { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown _instance = this; Features.BindConfig(((BaseUnityPlugin)this).Config); LoadingGuard.BindConfig(((BaseUnityPlugin)this).Config); FrameProfiler.BindConfig(((BaseUnityPlugin)this).Config); VeeCompat.BindConfig(((BaseUnityPlugin)this).Config); try { WearNTearUpdaterPatch.BindConfig(((BaseUnityPlugin)this).Config); } catch (Exception ex) { Logger.LogError((object)("Config section failed (WearNTearUpdaterPatch): " + ex.Message)); } try { WearNTearPatches.BindConfig(((BaseUnityPlugin)this).Config); } catch (Exception ex2) { Logger.LogError((object)("Config section failed (WearNTearPatches): " + ex2.Message)); } try { ParticleCuller.BindConfig(((BaseUnityPlugin)this).Config); } catch (Exception ex3) { Logger.LogError((object)("Config section failed (ParticleCuller): " + ex3.Message)); } try { GcTuning.BindConfig(((BaseUnityPlugin)this).Config); } catch (Exception ex4) { Logger.LogError((object)("Config section failed (GcTuning): " + ex4.Message)); } try { ZNetSceneObjectManagementPatch.BindConfig(((BaseUnityPlugin)this).Config); } catch (Exception ex5) { Logger.LogError((object)("Config section failed (object unloading): " + ex5.Message)); } try { ShadowTuning.BindConfig(((BaseUnityPlugin)this).Config); } catch (Exception ex6) { Logger.LogError((object)("Config section failed (ShadowTuning): " + ex6.Message)); } BurstLoader.Initialize(); VeeCompat.Detect(); _harmony = new Harmony("pucko.nordvpo"); Features.PatchEnabled(_harmony, Assembly.GetExecutingAssembly()); CollectionExtensions.Do<Type>((IEnumerable<Type>)AccessTools.GetTypesFromAssembly(Assembly.GetExecutingAssembly()), (Action<Type>)delegate(Type type) { if (type.IsAbstract && type.IsSealed && type.GetConstructor(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, Array.Empty<ParameterModifier>()) != null) { RuntimeHelpers.RunClassConstructor(type.TypeHandle); } }); ModCompatibility.Initialize(); NordVPO.OnInitialized?.Invoke(((BaseUnityPlugin)this).Config, _harmony); ((Component)this).gameObject.AddComponent<LoadingGuard>(); ((Component)this).gameObject.AddComponent<FrameProfiler>(); ((Component)this).gameObject.AddComponent<ParticleCuller>(); ((Component)this).gameObject.AddComponent<ShadowTuning>(); ((Component)this).gameObject.AddComponent<GcTuning>(); Logger.LogInfo((object)("NordVPO 0.1.28 loaded. Features " + Features.Summary())); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public sealed class ParticleCuller : MonoBehaviour { private static ConfigEntry<bool> _enabled; private static ConfigEntry<float> _distance; private static ConfigEntry<float> _rescan; private readonly List<ParticleSystemRenderer> _renderers = new List<ParticleSystemRenderer>(2048); private readonly HashSet<ParticleSystemRenderer> _hidden = new HashSet<ParticleSystemRenderer>(); private float _nextScan; private int _cursor; private bool _wasOn; internal static void BindConfig(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown _enabled = config.Bind<bool>("7 - Particle culling", "Hide far particles (experimental)", false, "Hides the renderers of particle systems (smoke, fire, sparks) farther than the distance below from the camera. The systems keep running, so nothing about the game changes, they are only not drawn. Applies at once."); _distance = config.Bind<float>("7 - Particle culling", "Distance (m)", 120f, new ConfigDescription("Particle systems farther than this from the camera are not drawn. They come back at 90% of this distance (no flicker at the edge).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 1000f), Array.Empty<object>())); _rescan = config.Bind<float>("7 - Particle culling", "Look for new particle systems every (seconds)", 2f, new ConfigDescription("How often the list of particle systems is refreshed (a scan of the scene, a fraction of a ms per 1000 systems).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); } private void Update() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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) if (_enabled == null || !_enabled.Value) { if (_wasOn) { ShowAll(); _wasOn = false; } return; } _wasOn = true; Camera main = Camera.main; if (!Object.op_Implicit((Object)(object)main)) { return; } if (Time.unscaledTime >= _nextScan) { _nextScan = Time.unscaledTime + _rescan.Value; _renderers.Clear(); _renderers.AddRange(Object.FindObjectsByType<ParticleSystemRenderer>((FindObjectsSortMode)0)); _cursor = 0; } int num = Mathf.Max(64, _renderers.Count / 30 + 1); Vector3 position = ((Component)main).transform.position; float value = _distance.Value; float num2 = value * value; float num3 = value * 0.9f * (value * 0.9f); int num4 = 0; while (num4 < num && _cursor < _renderers.Count) { ParticleSystemRenderer val = _renderers[_cursor]; if (Object.op_Implicit((Object)(object)val)) { Vector3 val2 = ((Component)val).transform.position - position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude > num2) { if (((Renderer)val).enabled) { ((Renderer)val).enabled = false; _hidden.Add(val); } } else if (sqrMagnitude < num3 && _hidden.Remove(val)) { ((Renderer)val).enabled = true; } } num4++; _cursor++; } if (_cursor >= _renderers.Count) { _cursor = 0; } if (_hidden.Count > 0 && Time.frameCount % 30 == 0) { _hidden.RemoveWhere((ParticleSystemRenderer r) => !Object.op_Implicit((Object)(object)r)); } } private void ShowAll() { foreach (ParticleSystemRenderer item in _hidden) { if (Object.op_Implicit((Object)(object)item)) { ((Renderer)item).enabled = true; } } _hidden.Clear(); } private void OnDisable() { ShowAll(); } } internal static class Features { internal sealed class Feature { public string Key; public string Description; public Type[] Types = Array.Empty<Type>(); public ConfigEntry<bool> Entry; public bool Patched; public bool ConflictsWithVee; } internal const string Section = "1 - Features"; private static readonly HashSet<Type> AlwaysOn = new HashSet<Type> { typeof(ModCompatibility) }; internal static readonly List<Feature> All = new List<Feature> { new Feature { Key = "Object streaming", Description = "Faster spawning and unloading of world objects as you move (VPO's rewritten object streaming), with NordVPO's fix for the endless loading screen. Off = the game's own object handling.", Types = new Type[1] { typeof(ZNetSceneObjectManagementPatch) } }, new Feature { Key = "Faster ownership release", Description = "Cheaper check of which nearby objects this game hands back when you walk away from an area. Same result as the game, less work each frame.", Types = new Type[1] { typeof(ZDOManReleaseNearbyPatch) } }, new Feature { Key = "Building support cache", Description = "Caches the structural-support calculation of building pieces. Big help in large bases.", Types = new Type[1] { typeof(WearNTearPatches) } }, new Feature { Key = "Building update throttle", Description = "Slows down the wear and support update of building pieces (setting 6 - Building updates): one global interval, and tiers by distance to you (near pieces keep updating often, far ones rarely). Off = the game's own scheduler is never touched.", Types = new Type[1] { typeof(WearNTearUpdaterPatch) } }, new Feature { Key = "Distant sound muting", Description = "Mutes sound sources that are out of hearing range so they stop costing CPU.", Types = new Type[1] { typeof(ZSFXVirtualizationPatch) } }, new Feature { Key = "Effect draw distance", Description = "Stops drawing particle effects (smoke, sparks) farther than 288 m away.", Types = new Type[1] { typeof(EffectCulling) } }, new Feature { Key = "Tree leaf particle culling", Description = "Adds a distance cut-off for leaf particles on trees, which otherwise draw at huge distances, and merges prefab materials.", Types = new Type[1] { typeof(PrefabPatches) } }, new Feature { Key = "Light flicker batching", Description = "Updates flickering torches and fires in one batch. Small gain.", Types = new Type[1] { typeof(VPOLightFlicker) } }, new Feature { Key = "Water floaters batching", Description = "Updates floating objects (boats, items in water) in one batch. With Valheim Enhanced Edition installed, who does this is chosen in 5 - Compatibility (NordVPO by default).", Types = new Type[1] { typeof(WaterVolumeManagerPatch) }, ConflictsWithVee = true }, new Feature { Key = "Fast wave math", Description = "Uses compiled (Burst) code for water wave calculations.", Types = new Type[1] { typeof(BurstedCalcWavePatch) } }, new Feature { Key = "Location lookup cache", Description = "Finds the location (dungeon, village) of a zone directly instead of searching all of them.", Types = new Type[1] { typeof(LocationZoneCachePatch) } }, new Feature { Key = "Equipment visuals cache", Description = "Reads a character's equipment data once per update instead of many times.", Types = new Type[1] { typeof(VisEquipmentDataPatch) } }, new Feature { Key = "Grass render order", Description = "Changes the render queue of grass and clutter for cheaper drawing.", Types = new Type[1] { typeof(ClutterSystemRenderQueuePatch) } }, new Feature { Key = "Network data allocation fix", Description = "Removes memory garbage when object data changes (less stutter from garbage collection)." }, new Feature { Key = "Terrain colour generation", Description = "Faster terrain colour and mesh generation when new terrain loads." } }; internal static void BindConfig(ConfigFile config) { foreach (Feature item in All) { item.Entry = config.Bind<bool>("1 - Features", item.Key, true, item.Description + " Restart the game after changing this."); } } internal static bool IsOn(string key) { Feature feature = All.FirstOrDefault((Feature x) => x.Key == key); if (feature?.Entry != null) { return feature.Entry.Value; } return true; } internal static void PatchEnabled(Harmony harmony, Assembly assembly) { Dictionary<Type, Feature> dictionary = new Dictionary<Type, Feature>(); Type[] types; foreach (Feature item in All) { types = item.Types; foreach (Type key in types) { dictionary[key] = item; } } types = AccessTools.GetTypesFromAssembly(assembly); foreach (Type type in types) { if (!type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Any()) { continue; } Type type2 = type; while (type2.DeclaringType != null && !dictionary.ContainsKey(type2) && !AlwaysOn.Contains(type2)) { type2 = type2.DeclaringType; } if (dictionary.TryGetValue(type2, out var value)) { if (!value.Entry.Value) { continue; } if (value.ConflictsWithVee && VeeCompat.StandDown) { NordVPO.Logger.LogInfo((object)(value.Key + ": left to Valheim Enhanced Edition, as set in 5 - Compatibility.")); value.Patched = true; continue; } value.Patched = true; } else if (!AlwaysOn.Contains(type2)) { NordVPO.Logger.LogWarning((object)("Patch class " + type.FullName + " has no feature switch; patching it anyway.")); } try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception arg) { NordVPO.Logger.LogError((object)string.Format("Could not apply {0} ({1}); that optimization is off: {2}", type.Name, value?.Key ?? "core", arg)); if (value != null) { value.Patched = false; } } } } internal static string Summary() { IEnumerable<string> values = from f in All where f.Entry != null && f.Entry.Value select f.Key; List<string> list = (from f in All where f.Entry != null && !f.Entry.Value select f.Key).ToList(); return "on: " + string.Join(", ", values) + ((list.Count > 0) ? ("; off: " + string.Join(", ", list)) : ""); } } public sealed class ShadowTuning : MonoBehaviour { private static ConfigEntry<float> _distance; private static ConfigEntry<int> _cascades; private bool _haveOriginal; private float _origDistance; private int _origCascades; private float _next; private float _lastSetDistance; private int _lastSetCascades; internal static void BindConfig(ConfigFile config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown _distance = config.Bind<float>("8 - Shadows", "Shadow distance (m)", 0f, new ConfigDescription("How far from the camera objects still cast shadows. The game uses 120 m at shadow quality Medium. Lower = fewer shadow casters = less GPU work in a big base, but shadows of far pieces appear later. Try 60, 80, 100. 0 = the game's own value (do not touch).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 400f), Array.Empty<object>())); _cascades = config.Bind<int>("8 - Shadows", "Shadow cascades", 0, new ConfigDescription("Number of shadow cascades (the sun's shadow is drawn once per cascade, so 4 costs about twice as much as 2). Use 1, 2 or 4. 0 = the game's own value (do not touch).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), Array.Empty<object>())); } private void Update() { if (Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 0.5f; float num = ((_distance != null) ? _distance.Value : 0f); int num2 = ((_cascades != null) ? _cascades.Value : 0); if (num2 == 3) { num2 = 2; } if (num > 0f || num2 > 0) { if (!_haveOriginal) { _haveOriginal = true; _origDistance = QualitySettings.shadowDistance; _origCascades = QualitySettings.shadowCascades; } if (num > 0f && !Mathf.Approximately(QualitySettings.shadowDistance, num)) { QualitySettings.shadowDistance = num; } if (num2 > 0 && QualitySettings.shadowCascades != num2) { QualitySettings.shadowCascades = num2; } } if (_haveOriginal) { if (num <= 0f && Mathf.Approximately(QualitySettings.shadowDistance, _lastSetDistance)) { QualitySettings.shadowDistance = _origDistance; } if (num2 <= 0 && QualitySettings.shadowCascades == _lastSetCascades) { QualitySettings.shadowCascades = _origCascades; } if (num <= 0f && num2 <= 0) { _haveOriginal = false; } } _lastSetDistance = ((num > 0f) ? num : QualitySettings.shadowDistance); _lastSetCascades = ((num2 > 0) ? num2 : QualitySettings.shadowCascades); } } public sealed class GcTuning : MonoBehaviour { internal enum GcPlan { Game, Manual } private static ConfigEntry<int> _reserveMb; private static ConfigEntry<GcPlan> _plan; private static ConfigEntry<int> _thresholdMb; private static ConfigEntry<bool> _duringLoading; private static ConfigEntry<float> _sliceMs; private static ConfigEntry<float> _gameSliceMs; private static ConfigEntry<bool> _logEvery; private const int ChunkMb = 16; private static bool _reserveDone; private static string _reserveResult = "not run"; private static string _lastError = ""; private static int _manualCollections; private static bool _incremental; private readonly List<byte[]> _chunks = new List<byte[]>(); private long _reserveTarget; private long _reserved; private bool _weSetManual; private bool _collecting; private float _lastCollect; private int _lastCount; private static int _started; private int _startedSeen; private int _oursFrame = -100; private float _lastLogged; private int _logged; private ulong _appliedSlice; private long _heapBefore; internal static void BindConfig(ConfigFile config) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown _reserveMb = config.Bind<int>("9 - Memory and garbage collection", "Reserve extra memory at start (MB)", 2048, new ConfigDescription("At game start NordVPO allocates this much memory once and gives it back to the game's heap, so the heap is already large. Garbage collections then happen less often because the game does not need to collect as soon as the heap fills up. 0 = off. Only used at start, so it applies after a restart (or the next time you change it before it has run).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 16384), Array.Empty<object>())); _plan = config.Bind<GcPlan>("9 - Memory and garbage collection", "Garbage collection plan", GcPlan.Game, new ConfigDescription("Game = the game collects when it wants (default). Manual = automatic collection is switched off and NordVPO collects at loading screens and when the heap passes the limit below, in small slices if the game supports it. Experimental: if the heap limit is too high the game uses more memory.", (AcceptableValueBase)null, Array.Empty<object>())); _thresholdMb = config.Bind<int>("9 - Memory and garbage collection", "Manual: collect when the heap passes (MB)", 1500, new ConfigDescription("In Manual mode: when the managed heap in use grows past this, a collection runs (in slices when possible).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(256, 16384), Array.Empty<object>())); _duringLoading = config.Bind<bool>("9 - Memory and garbage collection", "Manual: collect during loading screens", true, "In Manual mode: do a full collection when a loading screen is up (respawn, portal, join), where a pause is not noticed."); _sliceMs = config.Bind<float>("9 - Memory and garbage collection", "Manual: time per frame for a collection (ms)", 2f, new ConfigDescription("In Manual mode with incremental collection available: how much of each frame a running collection may use.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); _gameSliceMs = config.Bind<float>("9 - Memory and garbage collection", "Game plan: incremental slice (ms)", 0f, new ConfigDescription("If the game runs incremental garbage collection, this sets how long each slice may take. Lower = smoother but the collection takes more frames. 0 = leave the game's own value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _logEvery = config.Bind<bool>("9 - Memory and garbage collection", "Log garbage collections", false, "Writes heap size and collection count to the BepInEx log (first 60 collections, then a summary every minute)."); } internal static string Describe() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { return $" Garbage collection: mode {GarbageCollector.GCMode}, incremental {GarbageCollector.isIncremental}, slice {(double)GarbageCollector.incrementalTimeSliceNanoseconds / 1000000.0:0.0} ms; " + string.Format("plan {0}, reserve {1} MB ({2}), manual collections {3}", (_plan == null) ? "?" : _plan.Value.ToString(), (_reserveMb != null) ? _reserveMb.Value : 0, _reserveResult, _manualCollections) + ((_lastError.Length > 0) ? (", last error: " + _lastError) : ""); } catch (Exception ex) { return " Garbage collection: could not be read (" + ex.Message + ")"; } } private static float HeapUsedMb() { return (float)Profiler.GetMonoUsedSizeLong() / 1048576f; } private static float HeapReservedMb() { return (float)Profiler.GetMonoHeapSizeLong() / 1048576f; } private void Start() { try { _incremental = GarbageCollector.isIncremental; } catch (Exception ex) { _lastError = ex.Message; } _lastCount = GC.CollectionCount(0); NordVPO.Logger.LogInfo((object)$"Garbage collector: mode {SafeMode()}, incremental {_incremental}; heap {HeapUsedMb():0} of {HeapReservedMb():0} MB."); } private static string SafeMode() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { return ((object)GarbageCollector.GCMode/*cast due to .constrained prefix*/).ToString(); } catch { return "?"; } } private void Update() { try { if (_reserveMb != null) { Reserve(); ApplyPlan(); LogCollections(); } } catch (Exception ex) { _lastError = ex.Message; RestoreGameMode(); } } private void Reserve() { if (_reserveDone) { return; } long num = (long)_reserveMb.Value * 1048576L; if (num <= 0) { return; } if (_chunks.Count == 0 && _reserved == 0L) { _heapBefore = Profiler.GetMonoHeapSizeLong(); _reserveTarget = num; } for (int i = 0; i < 2; i++) { if (_reserved >= _reserveTarget) { break; } _chunks.Add(new byte[16777216]); _reserved += 16777216L; } if (_reserved >= _reserveTarget) { long monoUsedSizeLong = Profiler.GetMonoUsedSizeLong(); long monoHeapSizeLong = Profiler.GetMonoHeapSizeLong(); _chunks.Clear(); GC.Collect(); long monoHeapSizeLong2 = Profiler.GetMonoHeapSizeLong(); _reserveDone = true; _reserveResult = $"heap {_heapBefore / 1048576} -> {monoHeapSizeLong / 1048576} while held -> {monoHeapSizeLong2 / 1048576} MB after release"; NordVPO.Logger.LogInfo((object)$"Reserved {_reserved / 1048576} MB: {_reserveResult} (used while held {monoUsedSizeLong / 1048576} MB, in use now {HeapUsedMb():0} MB)."); } } private void ApplyPlan() { if (_plan.Value == GcPlan.Game) { RestoreGameMode(); if (_incremental && _gameSliceMs.Value > 0f) { ulong num = (ulong)(_gameSliceMs.Value * 1000000f); if (num != _appliedSlice) { GarbageCollector.incrementalTimeSliceNanoseconds = num; _appliedSlice = num; } } return; } if (!_weSetManual) { GarbageCollector.GCMode = (Mode)2; _weSetManual = true; NordVPO.Logger.LogInfo((object)"Garbage collection set to Manual (NordVPO collects at loading screens and at the heap limit)."); } float realtimeSinceStartup = Time.realtimeSinceStartup; ulong num2 = (ulong)(_sliceMs.Value * 1000000f); if (_collecting) { _oursFrame = Time.frameCount; _collecting = GarbageCollector.CollectIncremental(num2); if (!_collecting) { _manualCollections++; } return; } Player localPlayer = Player.m_localPlayer; bool flag = Object.op_Implicit((Object)(object)localPlayer) && ((Character)localPlayer).IsTeleporting(); bool flag2 = Object.op_Implicit((Object)(object)ZNetScene.instance) && ZNetScene.instance.InLoadingScreen(); bool flag3 = !Object.op_Implicit((Object)(object)localPlayer) || (flag && flag2); float num3 = HeapUsedMb(); bool flag4 = num3 > (float)_thresholdMb.Value; bool flag5 = _duringLoading.Value && flag3 && num3 > 300f && realtimeSinceStartup - _lastCollect > 8f; if ((!flag4 && !flag5) || realtimeSinceStartup - _lastCollect < 3f) { return; } _lastCollect = realtimeSinceStartup; _started++; if (_logEvery.Value) { NordVPO.Logger.LogInfo((object)string.Format("Manual collection started by NordVPO: reason {0}; heap in use {1:0} MB, limit {2} MB, player {3}, teleporting {4}, loading screen up {5}.", flag4 ? "heap limit" : "loading screen", num3, _thresholdMb.Value, Object.op_Implicit((Object)(object)localPlayer) ? "yes" : "no", flag, flag2)); } if (_incremental && !flag5) { _collecting = GarbageCollector.CollectIncremental(num2); if (!_collecting) { _manualCollections++; } } else { GC.Collect(); _manualCollections++; } } private void RestoreGameMode() { if (_weSetManual) { try { GarbageCollector.GCMode = (Mode)1; } catch { } _weSetManual = false; _collecting = false; NordVPO.Logger.LogInfo((object)"Garbage collection back to the game's own (automatic)."); } } private void LogCollections() { if (!_logEvery.Value) { return; } int num = GC.CollectionCount(0); if (num != _lastCount) { int num2 = num - _lastCount; _lastCount = num; float realtimeSinceStartup = Time.realtimeSinceStartup; if (_logged < 60) { _logged++; string text = ((_started != _startedSeen || Time.frameCount - _oursFrame <= 3) ? "NordVPO" : "the game or another mod"); _startedSeen = _started; NordVPO.Logger.LogInfo((object)$"Garbage collection #{num} (+{num2}) started by {text}; heap in use {HeapUsedMb():0} of {HeapReservedMb():0} MB."); _lastLogged = realtimeSinceStartup; } else if (realtimeSinceStartup - _lastLogged > 60f) { _lastLogged = realtimeSinceStartup; NordVPO.Logger.LogInfo((object)$"Garbage collections so far: {num}; heap in use {HeapUsedMb():0} of {HeapReservedMb():0} MB."); } } } private void OnDestroy() { RestoreGameMode(); } } [HarmonyPatch] internal static class ModCompatibility { internal static bool IsHDTerrainPresent => Chainloader.PluginInfos.ContainsKey("Badgers.ValheimHDTerrain"); internal static void Initialize() { } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void InitTerrainCompat() { } } internal static class VeeCompat { internal enum FloaterOwner { NordVPO, VEE } internal enum RemergeWhen { Never, AfterSafetyNetSpawn, AfterEveryJoin } internal const string VeeId = "com.chase.valheimenhancededition"; private const string Section = "5 - Compatibility"; private static ConfigEntry<FloaterOwner> _floaterOwner; private static ConfigEntry<bool> _veeFloaters; private static bool _reasserting; private static ConfigEntry<bool> _forward; private static Action<ZNetView> _forget; private static bool _bridgeFailed; private static ConfigEntry<RemergeWhen> _remerge; private static float _remergeOffAt = -1f; private static ConfigEntry<bool> _veeMerged; private static float _remergeOnAt = -1f; internal static bool Present { get; private set; } internal static string Version { get; private set; } = ""; internal static bool StandDown { get { if (Present && _floaterOwner != null) { return _floaterOwner.Value == FloaterOwner.VEE; } return false; } } internal static void BindConfig(ConfigFile config) { _floaterOwner = config.Bind<FloaterOwner>("5 - Compatibility", "Water floaters, when Valheim Enhanced Edition is installed", FloaterOwner.NordVPO, "Only matters when Valheim Enhanced Edition (VEE) is installed. Both mods replace the game's update of floating things (boats, items, swimmers). NordVPO = NordVPO does it (measured about twice as fast) and VEE's own floater update (its Water / FastFloaters setting) is switched off in memory while the game runs; VEE's config file is not changed by NordVPO. VEE = VEE does it and NordVPO's Features / Water floaters batching is not applied. Restart the game after changing this."); _forward = config.Bind<bool>("5 - Compatibility", "Valheim Enhanced Edition: tell it about removed objects", true, "Only matters when Valheim Enhanced Edition is installed. NordVPO replaces the game's object removal, so VEE's zone cache would not see removals; this forwards each one to VEE."); _remerge = config.Bind<RemergeWhen>("5 - Compatibility", "Rebuild VEE merged buildings after joining (experimental)", RemergeWhen.AfterEveryJoin, "Only matters when Valheim Enhanced Edition (VEE) is installed and its Merged buildings is on. Right after logging in, merged walls can flicker until Merged buildings is switched off and on again in F1. This does that switch by itself a few seconds after the loading screen ends (in memory only, VEE's file is not changed). Never = off. AfterSafetyNetSpawn = only when the loading screen safety net had to spawn objects. AfterEveryJoin = after every join or respawn. Costs one rebuild of the merged cells (a short hitch)."); } internal static void RequestRemerge(bool safetyNetSpawned) { try { if (!Present || _remerge == null || _remerge.Value == RemergeWhen.Never || (_remerge.Value == RemergeWhen.AfterSafetyNetSpawn && !safetyNetSpawned)) { return; } if (_veeMerged == null) { if (!Chainloader.PluginInfos.TryGetValue("com.chase.valheimenhancededition", out var value) || (Object)(object)value.Instance == (Object)null) { _remerge = null; return; } ConfigFile config = value.Instance.Config; foreach (ConfigDefinition key in config.Keys) { if (key.Key == "Enabled" && key.Section.IndexOf("Merged", StringComparison.OrdinalIgnoreCase) >= 0 && config[key] is ConfigEntry<bool> veeMerged) { _veeMerged = veeMerged; break; } } if (_veeMerged == null) { NordVPO.Logger.LogWarning((object)"VEE's Merged buildings / Enabled setting was not found; cannot rebuild merged buildings."); _remerge = null; return; } } if (_veeMerged.Value) { _remergeOffAt = Time.realtimeSinceStartup + 4f; NordVPO.Logger.LogInfo((object)"Merged buildings will be rebuilt in 4 s (off, then on again 2 s later)."); } } catch (Exception ex) { NordVPO.Logger.LogWarning((object)("Could not rebuild VEE merged buildings: " + ex.Message)); } } internal static void Tick() { if (_remergeOffAt >= 0f && Time.realtimeSinceStartup >= _remergeOffAt) { _remergeOffAt = -1f; try { if (_veeMerged != null && _veeMerged.Value) { SetMerged(on: false); _remergeOnAt = Time.realtimeSinceStartup + 2f; NordVPO.Logger.LogInfo((object)"Merged buildings switched off to rebuild them (back on in 2 s)."); } } catch (Exception ex) { NordVPO.Logger.LogWarning((object)("Could not rebuild VEE merged buildings: " + ex.Message)); } } if (_remergeOnAt < 0f || Time.realtimeSinceStartup < _remergeOnAt) { return; } _remergeOnAt = -1f; try { SetMerged(on: true); NordVPO.Logger.LogInfo((object)"Merged buildings switched back on."); } catch (Exception ex2) { NordVPO.Logger.LogWarning((object)("Could not switch VEE merged buildings back on: " + ex2.Message)); } } private static void SetMerged(bool on) { ConfigFile configFile = ((ConfigEntryBase)_veeMerged).ConfigFile; bool saveOnConfigSet = configFile.SaveOnConfigSet; try { configFile.SaveOnConfigSet = false; _veeMerged.Value = on; } finally { configFile.SaveOnConfigSet = saveOnConfigSet; } } internal static void Detect() { try { if (Chainloader.PluginInfos.TryGetValue("com.chase.valheimenhancededition", out var value) && !((Object)(object)value.Instance == (Object)null)) { Present = true; Version = value.Metadata.Version.ToString(); if (_floaterOwner.Value == FloaterOwner.NordVPO) { TakeOverFloaters(value.Instance.Config); } Type type = ((object)value.Instance).GetType().Assembly.GetType("PerfMod.ZoneUnload"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Forget", new Type[1] { typeof(ZNetView) }, (Type[])null)); if (methodInfo != null && methodInfo.IsStatic) { _forget = (Action<ZNetView>)Delegate.CreateDelegate(typeof(Action<ZNetView>), methodInfo); } NordVPO.Logger.LogInfo((object)("Valheim Enhanced Edition " + Version + " found. " + (StandDown ? "Water floaters are left to VEE. " : ((_veeFloaters != null) ? "NordVPO updates water floaters; VEE's own floater update is off for this session. " : "")) + ((_forget != null && _forward.Value) ? "Removed objects are forwarded to its zone cache." : "Its zone cache will not be told about removals (bridge unavailable)."))); } } catch (Exception ex) { NordVPO.Logger.LogWarning((object)("Could not set up compatibility with Valheim Enhanced Edition: " + ex.Message)); } } internal static void TakeOverFloaters(ConfigFile veeConfig) { ConfigEntry<bool> entry = default(ConfigEntry<bool>); if (!veeConfig.TryGetEntry<bool>("Water", "FastFloaters", ref entry)) { NordVPO.Logger.LogWarning((object)"Valheim Enhanced Edition's Water / FastFloaters setting was not found; both mods may update water floaters."); return; } _veeFloaters = entry; ForceOff(entry); entry.SettingChanged += delegate { if (!_reasserting && entry.Value) { NordVPO.Logger.LogInfo((object)"Valheim Enhanced Edition's FastFloaters was switched on; turning it off again (NordVPO does the floaters). Change 5 - Compatibility to give them to VEE."); ForceOff(entry); } }; } private static void ForceOff(ConfigEntry<bool> entry) { if (!entry.Value) { return; } ConfigFile configFile = ((ConfigEntryBase)entry).ConfigFile; bool saveOnConfigSet = configFile.SaveOnConfigSet; _reasserting = true; try { configFile.SaveOnConfigSet = false; entry.Value = false; } finally { configFile.SaveOnConfigSet = saveOnConfigSet; _reasserting = false; } } internal static void NotifyRemoved(ZNetView view) { if (_forget == null || _bridgeFailed || (Object)(object)view == (Object)null || !_forward.Value) { return; } try { _forget(view); } catch (Exception ex) { _bridgeFailed = true; NordVPO.Logger.LogWarning((object)("Valheim Enhanced Edition bridge turned off after an error: " + ex.Message)); } } } public static class ThreadedWorldLoadingPatch { } } namespace NordVPO.Patches { [HarmonyPatch] public static class WearNTearUpdaterPatch { private const string Section = "6 - Building updates"; private static ConfigEntry<float> _interval; private static float _lastDeadline; private static float _lastPassTime; private static float _lastCall; private static bool _warned; private static ConfigEntry<bool> _tiered; private static ConfigEntry<float> _nearRange; private static ConfigEntry<float> _nearInterval; private static ConfigEntry<float> _midRange; private static ConfigEntry<float> _midInterval; private static ConfigEntry<float> _farRange; private static ConfigEntry<float> _farInterval; private static ConfigEntry<float> _beyondInterval; private static int _pass; internal static void BindConfig(ConfigFile config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown _interval = config.Bind<float>("6 - Building updates", "Building update interval (seconds)", 1f, new ConfigDescription("How often every building piece gets its wear and support update. 1 = the game's own rate (no change). Higher values save CPU in big bases (about 0.5 ms per frame at 3 in a base with ~100 updates per frame), but things that depend on the update react later, for example a roof falls up to this many seconds after you destroy its support. Applies at once; no restart needed (needs Features / Building update throttle on).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>())); _tiered = config.Bind<bool>("6 - Building updates", "Tiered updates (by distance to you)", true, new ConfigDescription("Pieces near you keep updating often, far pieces update less often. Works on top of the interval above (leave that at 1 so the tiers decide). A piece's tier is its distance to your character; its update interval is the tier's interval below. Applies at once. Does nothing on a dedicated server (no local player).", (AcceptableValueBase)null, Array.Empty<object>())); _nearRange = config.Bind<float>("6 - Building updates", "Tier 1: range (m)", 5f, new ConfigDescription("Pieces within this distance of you use the tier 1 interval.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); _nearInterval = config.Bind<float>("6 - Building updates", "Tier 1: interval (s)", 1f, new ConfigDescription("Seconds between updates for tier 1 (1 = the game's own rate).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); _midRange = config.Bind<float>("6 - Building updates", "Tier 2: range (m)", 50f, new ConfigDescription("Pieces farther than tier 1 but within this distance use the tier 2 interval.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>())); _midInterval = config.Bind<float>("6 - Building updates", "Tier 2: interval (s)", 3f, new ConfigDescription("Seconds between updates for tier 2.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); _farRange = config.Bind<float>("6 - Building updates", "Tier 3: range (m)", 500f, new ConfigDescription("Pieces farther than tier 2 but within this distance use the tier 3 interval.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5000f), Array.Empty<object>())); _farInterval = config.Bind<float>("6 - Building updates", "Tier 3: interval (s)", 10f, new ConfigDescription("Seconds between updates for tier 3.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); _beyondInterval = config.Bind<float>("6 - Building updates", "Beyond tier 3: interval (s)", 60f, new ConfigDescription("Seconds between updates for pieces beyond tier 3.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); } private static float TierInterval(float sqrDistance) { float value = _nearRange.Value; if (sqrDistance <= value * value) { return _nearInterval.Value; } float value2 = _midRange.Value; if (sqrDistance <= value2 * value2) { return _midInterval.Value; } float value3 = _farRange.Value; if (sqrDistance <= value3 * value3) { return _farInterval.Value; } return _beyondInterval.Value; } [HarmonyPatch(typeof(WearNTear), "UpdateWear")] [HarmonyPrefix] [HarmonyPriority(0)] private static bool UpdateWear_Prefix(WearNTear __instance) { //IL_002c: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (_tiered == null || !_tiered.Value) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } Vector3 val = ((Component)__instance).transform.position - ((Component)localPlayer).transform.position; return RunsThisPass(((Vector3)(ref val)).sqrMagnitude, ((Object)__instance).GetInstanceID(), _pass); } internal static bool RunsThisPass(float sqrDistance, int instanceId, int pass) { float num = Mathf.Max(1f, _interval?.Value ?? 1f); int num2 = Mathf.RoundToInt(TierInterval(sqrDistance) / num); if (num2 <= 1) { return true; } uint num3 = (uint)(instanceId * -1640531535) >> 16; return (uint)(pass + (int)num3) % (uint)num2 == 0; } [HarmonyPatch(typeof(WearNTearUpdater), "UpdateWearNTear")] [HarmonyPostfix] private static void UpdateWearNTear_Postfix(WearNTearUpdater __instance, float time) { float num = _interval?.Value ?? 1f; if (time - _lastCall > 1.5f) { _lastPassTime = time; } _lastCall = time; float sleepUntilNext = __instance.m_sleepUntilNext; if (sleepUntilNext == time + 1f && sleepUntilNext != _lastDeadline) { _pass++; _lastPassTime = time; if (!(num <= 1f)) { _lastDeadline = time + num; __instance.m_sleepUntilNext = _lastDeadline; } return; } if (_lastPassTime <= 0f) { _lastPassTime = time; return; } float num2 = Mathf.Max(5f, num * 2f); if (time - _lastPassTime >= num2) { _pass++; _lastPassTime = time; if (!_warned) { _warned = true; NordVPO.Logger.LogWarning((object)"Building updates: the game's update deadline no longer matches what NordVPO expects, so passes are now counted from elapsed time (tiers still work; the global building update interval does not)."); } } } } public static class PrefabMaterialCombiner { private const string AlphaTestOn = "_ALPHATEST_ON"; public static void CombinePrefabMaterials(GameObject prefab) { WearNTear component = prefab.GetComponent<WearNTear>(); LODGroup component2 = ((Component)component).GetComponent<LODGroup>(); if ((Object)(object)component2 != (Object)null) { CombineTexturesForObject(CollectValidRenderers(component2)); return; } List<Renderer> list = new List<Renderer>(); GameObject worn = component.m_worn; if ((Object)(object)worn != (Object)null) { list.AddRange(CollectValidRenderers(worn.GetComponent<LODGroup>())); } GameObject val = component.m_new; if ((Object)(object)val != (Object)null) { list.AddRange(CollectValidRenderers(val.GetComponent<LODGroup>())); } GameObject wet = component.m_wet; if ((Object)(object)wet != (Object)null) { list.AddRange(CollectValidRenderers(wet.GetComponent<LODGroup>())); } GameObject val2 = component.m_new; if ((Object)(object)val2 != (Object)null) { list.AddRange(CollectValidRenderers(val2.GetComponent<LODGroup>())); } CombineTexturesForObject(list); } private static IEnumerable<Renderer> CollectValidRenderers(LODGroup inlineLodGroup) { return inlineLodGroup.GetLODs().SelectMany((LOD lod) => lod.renderers).Where(delegate(Renderer r) { Material[] sharedMaterials = r.sharedMaterials; return sharedMaterials.Length > 1 && (from mat in sharedMaterials group mat by mat.IsKeywordEnabled("_ALPHATEST_ON")).Any((IGrouping<bool, Material> group) => group.Count() > 1); }); } private static void CombineTexturesForObject(IEnumerable<Renderer> renderers) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result t
plugins/EinsteinCrew-PuckosCarePackage/Pucko-NordVPO/Unity.Burst.Unsafe.dll
Decompiled 2 weeks agousing System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: InternalsVisibleTo("Unity.Burst")] [assembly: AssemblyFileVersion("4.0.0.0")] [assembly: AssemblyInformationalVersion("4.0.0.0")] [assembly: AssemblyTitle("Unity.Burst.Unsafe")] [assembly: AssemblyDescription("System.Runtime.CompilerServices.Unsafe")] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: CLSCompliant(false)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("4.0.5.0")] namespace Unity.Burst { internal static class Unsafe : Object { [MethodImpl(256)] [NonVersionable] public unsafe static T Read<T>(void* source) { return System.Runtime.CompilerServices.Unsafe.Read<T>(source); } [MethodImpl(256)] [NonVersionable] public unsafe static T ReadUnaligned<T>(void* source) { return System.Runtime.CompilerServices.Unsafe.ReadUnaligned<T>(source); } [MethodImpl(256)] [NonVersionable] public static T ReadUnaligned<T>(ref byte source) { return System.Runtime.CompilerServices.Unsafe.ReadUnaligned<T>(ref source); } [MethodImpl(256)] [NonVersionable] public unsafe static void Write<T>(void* destination, T value) { System.Runtime.CompilerServices.Unsafe.Write(destination, value); } [MethodImpl(256)] [NonVersionable] public unsafe static void WriteUnaligned<T>(void* destination, T value) { System.Runtime.CompilerServices.Unsafe.WriteUnaligned(destination, value); } [MethodImpl(256)] [NonVersionable] public static void WriteUnaligned<T>(ref byte destination, T value) { System.Runtime.CompilerServices.Unsafe.WriteUnaligned(ref destination, value); } [MethodImpl(256)] [NonVersionable] public unsafe static void Copy<T>(void* destination, ref T source) { System.Runtime.CompilerServices.Unsafe.Write(destination, source); } [MethodImpl(256)] [NonVersionable] public unsafe static void Copy<T>(ref T destination, void* source) { destination = System.Runtime.CompilerServices.Unsafe.Read<T>(source); } [MethodImpl(256)] [NonVersionable] public unsafe static void* AsPointer<T>(ref T value) { return System.Runtime.CompilerServices.Unsafe.AsPointer(ref value); } [MethodImpl(256)] [NonVersionable] public static int SizeOf<T>() { return System.Runtime.CompilerServices.Unsafe.SizeOf<T>(); } [MethodImpl(256)] [NonVersionable] public unsafe static void CopyBlock(void* destination, void* source, uint byteCount) { // IL cpblk instruction System.Runtime.CompilerServices.Unsafe.CopyBlock(destination, source, byteCount); } [MethodImpl(256)] [NonVersionable] public static void CopyBlock(ref byte destination, ref byte source, uint byteCount) { // IL cpblk instruction System.Runtime.CompilerServices.Unsafe.CopyBlock(ref destination, ref source, byteCount); } [MethodImpl(256)] [NonVersionable] public unsafe static void CopyBlockUnaligned(void* destination, void* source, uint byteCount) { // IL cpblk instruction System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(destination, source, byteCount); } [MethodImpl(256)] [NonVersionable] public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount) { // IL cpblk instruction System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(ref destination, ref source, byteCount); } [MethodImpl(256)] [NonVersionable] public unsafe static void InitBlock(void* startAddress, byte value, uint byteCount) { // IL initblk instruction System.Runtime.CompilerServices.Unsafe.InitBlock(startAddress, value, byteCount); } [MethodImpl(256)] [NonVersionable] public static void InitBlock(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction System.Runtime.CompilerServices.Unsafe.InitBlock(ref startAddress, value, byteCount); } [MethodImpl(256)] [NonVersionable] public unsafe static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount) { // IL initblk instruction System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(startAddress, value, byteCount); } [MethodImpl(256)] [NonVersionable] public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(ref startAddress, value, byteCount); } [MethodImpl(256)] [NonVersionable] public static T As<T>(object o) where T : class { return (T)o; } [MethodImpl(256)] [NonVersionable] public unsafe static ref T AsRef<T>(void* source) { return ref *(T*)source; } [MethodImpl(256)] [NonVersionable] public static ref T AsRef<T>(in T source) { return ref source; } [MethodImpl(256)] [NonVersionable] public static ref TTo As<TFrom, TTo>(ref TFrom source) { return ref System.Runtime.CompilerServices.Unsafe.As<TFrom, TTo>(ref source); } [MethodImpl(256)] [NonVersionable] public static ref T Unbox<T>(object box) where T : struct, ValueType { return ref (T)box; } [MethodImpl(256)] [NonVersionable] public static ref T Add<T>(ref T source, int elementOffset) { return ref System.Runtime.CompilerServices.Unsafe.Add(ref source, elementOffset); } [MethodImpl(256)] [NonVersionable] public unsafe static void* Add<T>(void* source, int elementOffset) { return (byte*)source + (nint)elementOffset * (nint)System.Runtime.CompilerServices.Unsafe.SizeOf<T>(); } [MethodImpl(256)] [NonVersionable] public static ref T Add<T>(ref T source, System.IntPtr elementOffset) { return ref System.Runtime.CompilerServices.Unsafe.Add(ref source, elementOffset); } [MethodImpl(256)] [NonVersionable] public static ref T AddByteOffset<T>(ref T source, System.IntPtr byteOffset) { return ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(256)] [NonVersionable] public static ref T Subtract<T>(ref T source, int elementOffset) { return ref System.Runtime.CompilerServices.Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(256)] [NonVersionable] public unsafe static void* Subtract<T>(void* source, int elementOffset) { return (byte*)source - (nint)elementOffset * (nint)System.Runtime.CompilerServices.Unsafe.SizeOf<T>(); } [MethodImpl(256)] [NonVersionable] public static ref T Subtract<T>(ref T source, System.IntPtr elementOffset) { return ref System.Runtime.CompilerServices.Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(256)] [NonVersionable] public static ref T SubtractByteOffset<T>(ref T source, System.IntPtr byteOffset) { return ref System.Runtime.CompilerServices.Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(256)] [NonVersionable] public static System.IntPtr ByteOffset<T>(ref T origin, ref T target) { return System.Runtime.CompilerServices.Unsafe.ByteOffset(target: ref target, origin: ref origin); } [MethodImpl(256)] [NonVersionable] public static bool AreSame<T>(ref T left, ref T right) { return System.Runtime.CompilerServices.Unsafe.AreSame(ref left, ref right); } [MethodImpl(256)] [NonVersionable] public static bool IsAddressGreaterThan<T>(ref T left, ref T right) { return System.Runtime.CompilerServices.Unsafe.IsAddressGreaterThan(ref left, ref right); } [MethodImpl(256)] [NonVersionable] public static bool IsAddressLessThan<T>(ref T left, ref T right) { return System.Runtime.CompilerServices.Unsafe.IsAddressLessThan(ref left, ref right); } } } namespace System.Runtime.Versioning { [AttributeUsage(/*Could not decode attribute arguments.*/)] internal sealed class NonVersionableAttribute : Attribute { } } namespace System.Runtime.CompilerServices { internal sealed class IsReadOnlyAttribute : Attribute { } }
plugins/EinsteinCrew-PuckosCarePackage/Pucko-NordVPO/Unity.Burst.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using AOT; using Microsoft.CodeAnalysis; using Unity.Burst; using Unity.Burst.LowLevel; using Unity.Collections.LowLevel.Unsafe; using Unity.Jobs.LowLevel.Unsafe; using UnityEngine; using UnityEngine.Scripting; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("Unity.Burst.CodeGen")] [assembly: InternalsVisibleTo("Unity.Burst.Editor")] [assembly: InternalsVisibleTo("Unity.Burst.Tests.UnitTests")] [assembly: InternalsVisibleTo("Unity.Burst.Editor.Tests")] [assembly: InternalsVisibleTo("Unity.Burst.Benchmarks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } } [CompilerGenerated] [EditorBrowsable(EditorBrowsableState.Never)] [GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)] internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1 { private struct MonoScriptData { public byte[] FilePathsData; public byte[] TypesData; public int TotalTypes; public int TotalFiles; public bool IsEditorOnly; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static MonoScriptData Get() { return new MonoScriptData { FilePathsData = new byte[3832] { 0, 0, 0, 1, 0, 0, 0, 83, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 46, 99, 115, 0, 0, 0, 5, 0, 0, 0, 75, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 82, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 79, 112, 116, 105, 111, 110, 115, 46, 99, 115, 0, 0, 0, 4, 0, 0, 0, 74, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 66, 117, 114, 115, 116, 82, 117, 110, 116, 105, 109, 101, 46, 99, 115, 0, 0, 0, 4, 0, 0, 0, 79, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 46, 70, 108, 111, 97, 116, 46, 99, 115, 0, 0, 0, 4, 0, 0, 0, 73, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 92, 65, 108, 105, 97, 115, 105, 110, 103, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 99, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 92, 65, 115, 115, 117, 109, 101, 82, 97, 110, 103, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 92, 67, 111, 110, 115, 116, 97, 110, 116, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 83, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 92, 72, 105, 110, 116, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 101, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 92, 73, 103, 110, 111, 114, 101, 87, 97, 114, 110, 105, 110, 103, 65, 116, 116, 114, 105, 98, 117, 116, 101, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 102, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 92, 83, 107, 105, 112, 76, 111, 99, 97, 108, 115, 73, 110, 105, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 77, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 70, 117, 110, 99, 116, 105, 111, 110, 80, 111, 105, 110, 116, 101, 114, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 81, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 65, 114, 109, 92, 78, 69, 79, 78, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 65, 114, 109, 92, 78, 69, 79, 78, 95, 65, 65, 114, 99, 104, 54, 52, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 96, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 65, 114, 109, 92, 78, 69, 79, 78, 95, 65, 65, 114, 99, 104, 54, 52, 95, 99, 114, 121, 112, 116, 111, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 97, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 65, 114, 109, 92, 78, 69, 79, 78, 95, 65, 65, 114, 99, 104, 54, 52, 95, 100, 111, 116, 112, 114, 111, 100, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 94, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 65, 114, 109, 92, 78, 69, 79, 78, 95, 65, 65, 114, 99, 104, 54, 52, 95, 114, 100, 109, 97, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 86, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 65, 114, 109, 92, 78, 69, 79, 78, 95, 99, 116, 111, 114, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 79, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 67, 111, 109, 109, 111, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 83, 105, 109, 100, 68, 101, 98, 117, 103, 86, 105, 101, 119, 115, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 77, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 118, 49, 50, 56, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 77, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 118, 50, 53, 54, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 76, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 118, 54, 52, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 80, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 65, 118, 120, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 81, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 65, 118, 120, 50, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 81, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 66, 109, 105, 49, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 81, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 66, 109, 105, 50, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 83, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 67, 111, 109, 109, 111, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 80, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 67, 115, 114, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 81, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 70, 49, 54, 67, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 80, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 70, 109, 97, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 83, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 80, 111, 112, 99, 110, 116, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 80, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 83, 115, 101, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 81, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 83, 115, 101, 50, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 81, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 83, 115, 101, 51, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 83, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 83, 115, 101, 52, 95, 49, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 83, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 83, 115, 101, 52, 95, 50, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 82, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 92, 120, 56, 54, 92, 83, 115, 115, 101, 51, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 78, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 78, 111, 65, 108, 105, 97, 115, 65, 116, 116, 114, 105, 98, 117, 116, 101, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 83, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 83, 97, 102, 101, 83, 116, 114, 105, 110, 103, 65, 114, 114, 97, 121, 72, 101, 108, 112, 101, 114, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 74, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 98, 117, 114, 115, 116, 64, 54, 98, 98, 57, 97, 99, 97, 51, 101, 102, 51, 56, 92, 82, 117, 110, 116, 105, 109, 101, 92, 83, 104, 97, 114, 101, 100, 83, 116, 97, 116, 105, 99, 46, 99, 115 }, TypesData = new byte[3068] { 0, 0, 0, 0, 33, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 0, 0, 0, 0, 40, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 124, 67, 111, 109, 109, 97, 110, 100, 66, 117, 105, 108, 100, 101, 114, 0, 0, 0, 0, 51, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 124, 83, 116, 97, 116, 105, 99, 84, 121, 112, 101, 82, 101, 105, 110, 105, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 45, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 124, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 72, 101, 108, 112, 101, 114, 0, 0, 0, 0, 38, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 124, 70, 97, 107, 101, 68, 101, 108, 101, 103, 97, 116, 101, 0, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 66, 117, 114, 115, 116, 67, 111, 109, 112, 105, 108, 101, 114, 79, 112, 116, 105, 111, 110, 115, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 66, 117, 114, 115, 116, 82, 117, 110, 116, 105, 109, 101, 0, 0, 0, 0, 35, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 82, 117, 110, 116, 105, 109, 101, 124, 72, 97, 115, 104, 67, 111, 100, 101, 51, 50, 0, 0, 0, 0, 35, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 82, 117, 110, 116, 105, 109, 101, 124, 72, 97, 115, 104, 67, 111, 100, 101, 54, 52, 0, 0, 0, 0, 42, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 82, 117, 110, 116, 105, 109, 101, 124, 80, 114, 101, 115, 101, 114, 118, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 0, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 124, 116, 66, 105, 103, 73, 110, 116, 0, 0, 0, 0, 37, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 124, 116, 70, 108, 111, 97, 116, 85, 110, 105, 111, 110, 51, 50, 0, 0, 0, 0, 37, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 124, 116, 70, 108, 111, 97, 116, 85, 110, 105, 111, 110, 54, 52, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 0, 0, 0, 0, 41, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 124, 80, 114, 101, 115, 101, 114, 118, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 36, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 124, 78, 117, 109, 98, 101, 114, 66, 117, 102, 102, 101, 114, 0, 0, 0, 0, 37, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 66, 117, 114, 115, 116, 83, 116, 114, 105, 110, 103, 124, 70, 111, 114, 109, 97, 116, 79, 112, 116, 105, 111, 110, 115, 0, 0, 0, 0, 37, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 124, 65, 108, 105, 97, 115, 105, 110, 103, 0, 0, 0, 0, 49, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 124, 65, 115, 115, 117, 109, 101, 82, 97, 110, 103, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 37, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 124, 67, 111, 110, 115, 116, 97, 110, 116, 0, 0, 0, 0, 33, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 124, 72, 105, 110, 116, 0, 0, 0, 0, 51, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 124, 73, 103, 110, 111, 114, 101, 87, 97, 114, 110, 105, 110, 103, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 52, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 124, 83, 107, 105, 112, 76, 111, 99, 97, 108, 115, 73, 110, 105, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 28, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 73, 70, 117, 110, 99, 116, 105, 111, 110, 80, 111, 105, 110, 116, 101, 114, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 70, 117, 110, 99, 116, 105, 111, 110, 80, 111, 105, 110, 116, 101, 114, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 65, 114, 109, 1, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 65, 114, 109, 124, 78, 101, 111, 110, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 65, 114, 109, 1, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 65, 114, 109, 124, 78, 101, 111, 110, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 65, 114, 109, 1, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 65, 114, 109, 124, 78, 101, 111, 110, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 65, 114, 109, 1, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 65, 114, 109, 124, 78, 101, 111, 110, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 65, 114, 109, 1, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 65, 114, 109, 124, 78, 101, 111, 110, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 65, 114, 109, 1, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 65, 114, 109, 124, 78, 101, 111, 110, 0, 0, 0, 0, 29, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 67, 111, 109, 109, 111, 110, 0, 0, 0, 0, 46, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 66, 117, 114, 115, 116, 84, 97, 114, 103, 101, 116, 67, 112, 117, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 35, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 86, 54, 52, 68, 101, 98, 117, 103, 86, 105, 101, 119, 0, 0, 0, 0, 36, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 86, 49, 50, 56, 68, 101, 98, 117, 103, 86, 105, 101, 119, 0, 0, 0, 0, 36, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 86, 50, 53, 54, 68, 101, 98, 117, 103, 86, 105, 101, 119, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 118, 49, 50, 56, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 118, 50, 53, 54, 0, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 118, 54, 52, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 30, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 65, 118, 120, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 65, 118, 120, 50, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 66, 109, 105, 49, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 66, 109, 105, 50, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 40, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 82, 111, 117, 110, 100, 105, 110, 103, 83, 99, 111, 112, 101, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 70, 49, 54, 67, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 30, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 70, 109, 97, 0, 0, 0, 0, 36, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 43, 70, 109, 97, 124, 85, 110, 105, 111, 110, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 33, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 80, 111, 112, 99, 110, 116, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 30, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 83, 115, 101, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 83, 115, 101, 50, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 83, 115, 101, 51, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 33, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 83, 115, 101, 52, 95, 49, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 33, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 83, 115, 101, 52, 95, 50, 0, 0, 0, 0, 46, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 43, 83, 115, 101, 52, 95, 50, 124, 83, 116, 114, 66, 111, 111, 108, 65, 114, 114, 97, 121, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 124, 88, 56, 54, 0, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 73, 110, 116, 114, 105, 110, 115, 105, 99, 115, 46, 88, 56, 54, 124, 83, 115, 115, 101, 51, 0, 0, 0, 0, 28, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 78, 111, 65, 108, 105, 97, 115, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 33, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 83, 97, 102, 101, 83, 116, 114, 105, 110, 103, 65, 114, 114, 97, 121, 72, 101, 108, 112, 101, 114, 1, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 83, 104, 97, 114, 101, 100, 83, 116, 97, 116, 105, 99, 1, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 124, 83, 104, 97, 114, 101, 100, 83, 116, 97, 116, 105, 99, 0, 0, 0, 0, 42, 85, 110, 105, 116, 121, 46, 66, 117, 114, 115, 116, 46, 83, 104, 97, 114, 101, 100, 83, 116, 97, 116, 105, 99, 124, 80, 114, 101, 115, 101, 114, 118, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101 }, TotalFiles = 42, TotalTypes = 83, IsEditorOnly = false }; } } namespace Unity.Burst { public enum OptimizeFor { Default, Performance, Size, FastCompilation, Balanced } public enum FloatMode { Default, Strict, Deterministic, Fast } public enum FloatPrecision { Standard, High, Medium, Low } [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method)] [RequireAttributeUsages] public class BurstCompileAttribute : Attribute { internal bool? _compileSynchronously; internal bool? _debug; internal bool? _disableSafetyChecks; internal bool? _disableDirectCall; public FloatMode FloatMode { get; set; } public FloatPrecision FloatPrecision { get; set; } public bool CompileSynchronously { get { if (!_compileSynchronously.HasValue) { return false; } return _compileSynchronously.Value; } set { _compileSynchronously = value; } } public bool Debug { get { if (!_debug.HasValue) { return false; } return _debug.Value; } set { _debug = value; } } public bool DisableSafetyChecks { get { if (!_disableSafetyChecks.HasValue) { return false; } return _disableSafetyChecks.Value; } set { _disableSafetyChecks = value; } } public bool DisableDirectCall { get { if (!_disableDirectCall.HasValue) { return false; } return _disableDirectCall.Value; } set { _disableDirectCall = value; } } public OptimizeFor OptimizeFor { get; set; } internal string[] Options { get; set; } public BurstCompileAttribute() { } public BurstCompileAttribute(FloatPrecision floatPrecision, FloatMode floatMode) { FloatMode = floatMode; FloatPrecision = floatPrecision; } internal BurstCompileAttribute(string[] options) { Options = options; } } public static class BurstCompiler { private class CommandBuilder { private StringBuilder _builder; private bool _hasArgs; public CommandBuilder() { _builder = new StringBuilder(); _hasArgs = false; } public CommandBuilder Begin(string cmd) { _builder.Clear(); _hasArgs = false; _builder.Append(cmd); return this; } public CommandBuilder With(string arg) { if (!_hasArgs) { _builder.Append(' '); } _hasArgs = true; _builder.Append(arg); return this; } public CommandBuilder With(IntPtr arg) { if (!_hasArgs) { _builder.Append(' '); } _hasArgs = true; _builder.AppendFormat("0x{0:X16}", arg.ToInt64()); return this; } public CommandBuilder And(char sep = '|') { _builder.Append(sep); return this; } public string SendToCompiler() { return SendRawCommandToCompiler(_builder.ToString()); } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal class StaticTypeReinitAttribute : Attribute { public readonly Type reinitType; public StaticTypeReinitAttribute(Type toReinit) { reinitType = toReinit; } } [BurstCompile] internal static class BurstCompilerHelper { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool IsBurstEnabledDelegate(); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate bool IsBurstEnabled_00000145$PostfixBurstDelegate(); internal static class IsBurstEnabled_00000145$BurstDirectCall { private static IntPtr Pointer; [BurstDiscard] private static void GetFunctionPointerDiscard(ref IntPtr P_0) { if (Pointer == (IntPtr)0) { Pointer = CompileFunctionPointer<IsBurstEnabled_00000145$PostfixBurstDelegate>(IsBurstEnabled).Value; } P_0 = Pointer; } private static IntPtr GetFunctionPointer() { nint result = 0; GetFunctionPointerDiscard(ref result); return result; } public unsafe static bool Invoke() { if (IsEnabled) { IntPtr functionPointer = GetFunctionPointer(); if (functionPointer != (IntPtr)0) { return ((delegate* unmanaged[Cdecl]<bool>)functionPointer)(); } } return IsBurstEnabled$BurstManaged(); } } private static readonly IsBurstEnabledDelegate IsBurstEnabledImpl = IsBurstEnabled; public static readonly bool IsBurstGenerated = IsCompiledByBurst(IsBurstEnabledImpl); [BurstCompile] [MonoPInvokeCallback(typeof(IsBurstEnabledDelegate))] private static bool IsBurstEnabled() { return IsBurstEnabled_00000145$BurstDirectCall.Invoke(); } [BurstDiscard] private static void DiscardedMethod(ref bool value) { value = false; } private unsafe static bool IsCompiledByBurst(Delegate del) { return BurstCompilerService.GetAsyncCompiledAsyncDelegateMethod(BurstCompilerService.CompileAsyncDelegateMethod((object)del, string.Empty)) != null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [BurstCompile] [MonoPInvokeCallback(typeof(IsBurstEnabledDelegate))] internal static bool IsBurstEnabled$BurstManaged() { bool value = true; DiscardedMethod(ref value); return value; } } private class FakeDelegate { [Preserve] public MethodInfo Method { get; } public FakeDelegate(MethodInfo method) { Method = method; } } [ThreadStatic] private static CommandBuilder _cmdBuilder; internal static bool _IsEnabled; public static readonly BurstCompilerOptions Options = new BurstCompilerOptions(isGlobal: true); internal static Action OnCompileILPPMethod2; private static readonly MethodInfo DummyMethodInfo = typeof(BurstCompiler).GetMethod("DummyMethod", BindingFlags.Static | BindingFlags.NonPublic); public static bool IsEnabled { get { if (_IsEnabled) { return BurstCompilerHelper.IsBurstGenerated; } return false; } } public static bool IsLoadAdditionalLibrarySupported() { return IsApiAvailable("LoadBurstLibrary"); } private static CommandBuilder BeginCompilerCommand(string cmd) { if (_cmdBuilder == null) { _cmdBuilder = new CommandBuilder(); } return _cmdBuilder.Begin(cmd); } public static void SetExecutionMode(BurstExecutionEnvironment mode) { BurstCompilerService.SetCurrentExecutionMode((uint)mode); } public static BurstExecutionEnvironment GetExecutionMode() { return (BurstExecutionEnvironment)BurstCompilerService.GetCurrentExecutionMode(); } internal unsafe static T CompileDelegate<T>(T delegateMethod, bool deterministicCompilation = false) where T : class { return (T)(object)Marshal.GetDelegateForFunctionPointer((IntPtr)Compile(delegateMethod, isFunctionPointer: false, deterministicCompilation), delegateMethod.GetType()); } [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] private static void VerifyDelegateIsNotMulticast<T>(T delegateMethod) where T : class { if ((delegateMethod as Delegate).GetInvocationList().Length > 1) { throw new InvalidOperationException($"Burst does not support multicast delegates, please use a regular delegate for `{delegateMethod}'"); } } [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] private static void VerifyDelegateHasCorrectUnmanagedFunctionPointerAttribute<T>(T delegateMethod) where T : class { UnmanagedFunctionPointerAttribute customAttribute = delegateMethod.GetType().GetCustomAttribute<UnmanagedFunctionPointerAttribute>(); if (customAttribute == null || customAttribute.CallingConvention != CallingConvention.Cdecl) { Debug.LogWarning((object)("The delegate type " + delegateMethod.GetType().FullName + " should be decorated with [UnmanagedFunctionPointer(CallingConvention.Cdecl)] to ensure runtime interoperabilty between managed code and Burst-compiled code.")); } } [Obsolete("This method will be removed in a future version of Burst")] public static IntPtr CompileILPPMethod(RuntimeMethodHandle burstMethodHandle, RuntimeMethodHandle managedMethodHandle, RuntimeTypeHandle delegateTypeHandle) { throw new NotImplementedException(); } public unsafe static IntPtr CompileILPPMethod2(RuntimeMethodHandle burstMethodHandle) { if (burstMethodHandle.Value == IntPtr.Zero) { throw new ArgumentNullException("burstMethodHandle"); } OnCompileILPPMethod2?.Invoke(); MethodInfo methodInfo = (MethodInfo)MethodBase.GetMethodFromHandle(burstMethodHandle); return (IntPtr)Compile(new FakeDelegate(methodInfo), methodInfo, isFunctionPointer: true, isILPostProcessing: true); } [Obsolete("This method will be removed in a future version of Burst")] public unsafe static void* GetILPPMethodFunctionPointer(IntPtr ilppMethod) { throw new NotImplementedException(); } public unsafe static void* GetILPPMethodFunctionPointer2(IntPtr ilppMethod, RuntimeMethodHandle managedMethodHandle, RuntimeTypeHandle delegateTypeHandle) { if (managedMethodHandle.Value == IntPtr.Zero) { throw new ArgumentNullException("managedMethodHandle"); } if (delegateTypeHandle.Value == IntPtr.Zero) { throw new ArgumentNullException("delegateTypeHandle"); } if (ilppMethod == IntPtr.Zero) { GetManagedFallbackDelegate(out var managedFallbackDelegate, out var _); return (void*)Marshal.GetFunctionPointerForDelegate(managedFallbackDelegate); } return ilppMethod.ToPointer(); void GetManagedFallbackDelegate(out Delegate reference, out GCHandle reference2) { MethodInfo method = (MethodInfo)MethodBase.GetMethodFromHandle(managedMethodHandle); Type typeFromHandle = Type.GetTypeFromHandle(delegateTypeHandle); reference = Delegate.CreateDelegate(typeFromHandle, method); reference2 = GCHandle.Alloc(reference); } } [Obsolete("This method will be removed in a future version of Burst")] public unsafe static void* CompileUnsafeStaticMethod(RuntimeMethodHandle handle) { throw new NotImplementedException(); } public unsafe static FunctionPointer<T> CompileFunctionPointer<T>(T delegateMethod) where T : class { return new FunctionPointer<T>(new IntPtr(Compile(delegateMethod, isFunctionPointer: true))); } private unsafe static void* Compile(object delegateObj, bool isFunctionPointer, bool deterministicCompilation = false) { if (!(delegateObj is Delegate)) { throw new ArgumentException("object instance must be a System.Delegate", "delegateObj"); } Delegate obj = (Delegate)delegateObj; return Compile(obj, obj.Method, isFunctionPointer, isILPostProcessing: false, deterministicCompilation); } private unsafe static void* Compile(object delegateObj, MethodInfo methodInfo, bool isFunctionPointer, bool isILPostProcessing, bool deterministicCompilation = false) { if (delegateObj == null) { throw new ArgumentNullException("delegateObj"); } if (delegateObj.GetType().IsGenericType) { throw new InvalidOperationException($"The delegate type `{delegateObj.GetType()}` must be a non-generic type"); } if (!methodInfo.IsStatic) { throw new InvalidOperationException($"The method `{methodInfo}` must be static. Instance methods are not supported"); } if (methodInfo.IsGenericMethod) { throw new InvalidOperationException($"The method `{methodInfo}` must be a non-generic method"); } Delegate obj = null; if (!isILPostProcessing) { obj = delegateObj as Delegate; } Delegate obj2 = delegateObj as Delegate; if (BurstCompilerOptions.HasBurstCompileAttribute(methodInfo)) { void* ptr = null; if (Options.EnableBurstCompilation && BurstCompilerHelper.IsBurstGenerated) { if (isFunctionPointer && methodInfo.Name.EndsWith("$BurstManaged")) { delegateObj = methodInfo.DeclaringType.GetMethod(methodInfo.Name.Replace("$BurstManaged", ""), BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).CreateDelegate(obj2.GetType()); } ptr = BurstCompilerService.GetAsyncCompiledAsyncDelegateMethod(BurstCompilerService.CompileAsyncDelegateMethod(delegateObj, string.Empty)); } if (ptr == null) { if (isILPostProcessing) { return null; } GCHandle.Alloc(obj); ptr = (void*)Marshal.GetFunctionPointerForDelegate(obj); } if (ptr == null) { throw new InvalidOperationException($"Burst failed to compile the function pointer `{methodInfo}`"); } return ptr; } throw new InvalidOperationException($"Burst cannot compile the function pointer `{methodInfo}` because the `[BurstCompile]` attribute is missing"); } internal static void Shutdown() { } internal static void Cancel() { } internal static bool IsCurrentCompilationDone() { return true; } internal static void Enable() { } internal static void Disable() { } internal static bool IsHostEditorArm() { return false; } internal static void TriggerUnsafeStaticMethodRecompilation() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { foreach (Attribute item in from x in assemblies[i].GetCustomAttributes() where x.GetType().FullName == "Unity.Burst.BurstCompiler+StaticTypeReinitAttribute" select x) { (item as StaticTypeReinitAttribute).reinitType.GetMethod("Constructor", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[0]); } } } internal static void TriggerRecompilation() { } internal static void UnloadAdditionalLibraries() { SendCommandToCompiler("$unload_burst_natives"); } internal static bool IsApiAvailable(string apiName) { return SendCommandToCompiler("$is_native_api_available", apiName) == "True"; } internal static int RequestSetProtocolVersion(int version) { string text = SendCommandToCompiler("$request_set_protocol_version_editor", $"{version}"); if (string.IsNullOrEmpty(text) || !int.TryParse(text, out var result)) { result = 0; } SendCommandToCompiler("$set_protocol_version_burst", $"{result}"); return result; } internal static void Initialize(string[] assemblyFolders, string[] ignoreAssemblies) { } internal static void NotifyCompilationStarted(string[] assemblyFolders, string[] ignoreAssemblies) { } internal static void NotifyAssemblyCompilationNotRequired(string assemblyName) { } internal static void NotifyAssemblyCompilationFinished(string assemblyName, string[] defines) { } internal static void NotifyCompilationFinished() { } internal static string AotCompilation(string[] assemblyFolders, string[] assemblyRoots, string options) { return "failed"; } internal static void SetProfilerCallbacks() { } private static string SendRawCommandToCompiler(string command) { string disassembly = BurstCompilerService.GetDisassembly(DummyMethodInfo, command); if (!string.IsNullOrEmpty(disassembly)) { return disassembly.TrimStart('\n'); } return ""; } private static string SendCommandToCompiler(string commandName, string commandArgs = null) { if (commandName == null) { throw new ArgumentNullException("commandName"); } if (commandArgs == null) { return SendRawCommandToCompiler(commandName); } return BeginCompilerCommand(commandName).With(commandArgs).SendToCompiler(); } private static void DummyMethod() { } } internal enum GlobalSafetyChecksSettingKind { Off, On, ForceOn } public sealed class BurstCompilerOptions { private const string DisableCompilationArg = "--burst-disable-compilation"; private const string ForceSynchronousCompilationArg = "--burst-force-sync-compilation"; internal const string DefaultLibraryName = "lib_burst_generated"; internal const string BurstInitializeName = "burst.initialize"; internal const string BurstInitializeExternalsName = "burst.initialize.externals"; internal const string BurstInitializeStaticsName = "burst.initialize.statics"; internal const string OptionBurstcSwitch = "+burstc"; internal const string OptionGroup = "group"; internal const string OptionPlatform = "platform="; internal const string OptionMinimumOSVersion = "minimum-os-version="; internal const string OptionBackend = "backend="; internal const string OptionGlobalSafetyChecksSetting = "global-safety-checks-setting="; internal const string OptionDisableSafetyChecks = "disable-safety-checks"; internal const string OptionDisableOpt = "disable-opt"; internal const string OptionFastMath = "fastmath"; internal const string OptionTarget = "target="; internal const string OptionOptLevel = "opt-level="; internal const string OptionLogTimings = "log-timings"; internal const string OptionOptForSize = "opt-for-size"; internal const string OptionFloatPrecision = "float-precision="; internal const string OptionFloatMode = "float-mode="; internal const string OptionBranchProtection = "branch-protection="; internal const string OptionDisableWarnings = "disable-warnings="; internal const string OptionAssemblyDefines = "assembly-defines="; internal const string OptionDump = "dump="; internal const string OptionFormat = "format="; internal const string OptionDebugTrap = "debugtrap"; internal const string OptionDisableVectors = "disable-vectors"; internal const string OptionDebug = "debug="; internal const string OptionDebugMode = "debugMode"; internal const string OptionStaticLinkage = "generate-static-linkage-methods"; internal const string OptionJobMarshalling = "generate-job-marshalling-methods"; internal const string OptionTempDirectory = "temp-folder="; internal const string OptionEnableDirectExternalLinking = "enable-direct-external-linking"; internal const string OptionLinkerOptions = "linker-options="; internal const string OptionEnableAutoLayoutFallbackCheck = "enable-autolayout-fallback-check"; internal const string OptionEnableFrameInfoRegistration = "enable-frame-info-registration"; internal const string OptionGenerateLinkXml = "generate-link-xml="; internal const string OptionMetaDataGeneration = "meta-data-generation="; internal const string OptionDisableStringInterpolationInExceptionMessages = "disable-string-interpolation-in-exception-messages"; internal const string OptionPlatformConfiguration = "platform-configuration="; internal const string OptionStackProtector = "stack-protector="; internal const string OptionStackProtectorBufferSize = "stack-protector-buffer-size="; internal const string OptionForceDisableFrameInfoRegistration = "force-disable-frame-info-registration"; internal const string OptionCacheDirectory = "cache-directory="; internal const string OptionJitDisableFunctionCaching = "disable-function-caching"; internal const string OptionJitDisableAssemblyCaching = "disable-assembly-caching"; internal const string OptionJitEnableAssemblyCachingLogs = "enable-assembly-caching-logs"; internal const string OptionJitEnableSynchronousCompilation = "enable-synchronous-compilation"; internal const string OptionJitCompilationPriority = "compilation-priority="; internal const string OptionJitIsForFunctionPointer = "is-for-function-pointer"; internal const string OptionJitManagedFunctionPointer = "managed-function-pointer="; internal const string OptionJitManagedDelegateHandle = "managed-delegate-handle="; internal const string OptionEnableInterpreter = "enable-interpreter"; internal const string OptionAotAssemblyFolder = "assembly-folder="; internal const string OptionRootAssembly = "root-assembly="; internal const string OptionIncludeRootAssemblyReferences = "include-root-assembly-references="; internal const string OptionAotMethod = "method="; internal const string OptionAotType = "type="; internal const string OptionAotAssembly = "assembly="; internal const string OptionAotOutputPath = "output="; internal const string OptionAotKeepIntermediateFiles = "keep-intermediate-files"; internal const string OptionAotNoLink = "nolink"; internal const string OptionAotOnlyStaticMethods = "only-static-methods"; internal const string OptionMethodPrefix = "method-prefix="; internal const string OptionAotNoNativeToolchain = "no-native-toolchain"; internal const string OptionAotEmitLlvmObjects = "emit-llvm-objects"; internal const string OptionAotKeyFolder = "key-folder="; internal const string OptionAotDecodeFolder = "decode-folder="; internal const string OptionVerbose = "verbose"; internal const string OptionValidateExternalToolChain = "validate-external-tool-chain"; internal const string OptionCompilerThreads = "threads="; internal const string OptionChunkSize = "chunk-size="; internal const string OptionPrintLogOnMissingPInvokeCallbackAttribute = "print-monopinvokecallbackmissing-message"; internal const string OptionOutputMode = "output-mode="; internal const string OptionAlwaysCreateOutput = "always-create-output="; internal const string OptionAotPdbSearchPaths = "pdb-search-paths="; internal const string OptionSafetyChecks = "safety-checks"; internal const string OptionLibraryOutputMode = "library-output-mode="; internal const string OptionCompilationId = "compilation-id="; internal const string OptionTargetFramework = "target-framework="; internal const string OptionDiscardAssemblies = "discard-assemblies="; internal const string OptionSaveExtraContext = "save-extra-context"; internal const string CompilerCommandShutdown = "$shutdown"; internal const string CompilerCommandCancel = "$cancel"; internal const string CompilerCommandEnableCompiler = "$enable_compiler"; internal const string CompilerCommandDisableCompiler = "$disable_compiler"; internal const string CompilerCommandSetDefaultOptions = "$set_default_options"; internal const string CompilerCommandTriggerSetupRecompilation = "$trigger_setup_recompilation"; internal const string CompilerCommandIsCurrentCompilationDone = "$is_current_compilation_done"; internal const string CompilerCommandTriggerRecompilation = "$trigger_recompilation"; internal const string CompilerCommandInitialize = "$initialize"; internal const string CompilerCommandDomainReload = "$domain_reload"; internal const string CompilerCommandVersionNotification = "$version"; internal const string CompilerCommandGetTargetCpuFromHost = "$get_target_cpu_from_host"; internal const string CompilerCommandSetProfileCallbacks = "$set_profile_callbacks"; internal const string CompilerCommandUnloadBurstNatives = "$unload_burst_natives"; internal const string CompilerCommandIsNativeApiAvailable = "$is_native_api_available"; internal const string CompilerCommandILPPCompilation = "$ilpp_compilation"; internal const string CompilerCommandIsArmTestEnv = "$is_arm_test_env"; internal const string CompilerCommandNotifyAssemblyCompilationNotRequired = "$notify_assembly_compilation_not_required"; internal const string CompilerCommandNotifyAssemblyCompilationFinished = "$notify_assembly_compilation_finished"; internal const string CompilerCommandNotifyCompilationStarted = "$notify_compilation_started"; internal const string CompilerCommandNotifyCompilationFinished = "$notify_compilation_finished"; internal const string CompilerCommandDirtyAllAssemblies = "$dirty_all_assemblies"; internal const string CompilerCommandAotCompilation = "$aot_compilation"; internal const string CompilerCommandRequestInitialiseDebuggerCommmand = "$request_debug_command"; internal const string CompilerCommandInitialiseDebuggerCommmand = "$load_debugger_interface"; internal const string CompilerCommandRequestSetProtocolVersionEditor = "$request_set_protocol_version_editor"; internal const string CompilerCommandSetProtocolVersionBurst = "$set_protocol_version_burst"; internal static readonly bool ForceDisableBurstCompilation; private static readonly bool ForceBurstCompilationSynchronously; internal static readonly bool IsSecondaryUnityProcess; private bool _enableBurstCompilation; private bool _enableBurstCompileSynchronously; private bool _enableBurstSafetyChecks; private bool _enableBurstTimings; private bool _enableBurstDebug; private bool _forceEnableBurstSafetyChecks; private bool IsGlobal { get; } public bool IsEnabled { get { if (EnableBurstCompilation) { return !ForceDisableBurstCompilation; } return false; } } public bool EnableBurstCompilation { get { return _enableBurstCompilation; } set { if (IsGlobal && ForceDisableBurstCompilation) { value = false; } bool num = _enableBurstCompilation != value; _enableBurstCompilation = value; if (IsGlobal) { JobsUtility.JobCompilerEnabled = value; BurstCompiler._IsEnabled = value; } if (num) { OnOptionsChanged(); } } } public bool EnableBurstCompileSynchronously { get { return _enableBurstCompileSynchronously; } set { bool num = _enableBurstCompileSynchronously != value; _enableBurstCompileSynchronously = value; if (num) { OnOptionsChanged(); } } } public bool EnableBurstSafetyChecks { get { return _enableBurstSafetyChecks; } set { bool num = _enableBurstSafetyChecks != value; _enableBurstSafetyChecks = value; if (num) { OnOptionsChanged(); MaybeTriggerRecompilation(); } } } public bool ForceEnableBurstSafetyChecks { get { return _forceEnableBurstSafetyChecks; } set { bool num = _forceEnableBurstSafetyChecks != value; _forceEnableBurstSafetyChecks = value; if (num) { OnOptionsChanged(); MaybeTriggerRecompilation(); } } } public bool EnableBurstDebug { get { return _enableBurstDebug; } set { bool num = _enableBurstDebug != value; _enableBurstDebug = value; if (num) { OnOptionsChanged(); MaybeTriggerRecompilation(); } } } [Obsolete("This property is no longer used and will be removed in a future major release")] public bool DisableOptimizations { get { return false; } set { } } [Obsolete("This property is no longer used and will be removed in a future major release. Use the [BurstCompile(FloatMode = FloatMode.Fast)] on the method directly to enable this feature")] public bool EnableFastMath { get { return true; } set { } } internal bool EnableBurstTimings { get { return _enableBurstTimings; } set { bool num = _enableBurstTimings != value; _enableBurstTimings = value; if (num) { OnOptionsChanged(); } } } internal bool RequiresSynchronousCompilation { get { if (!EnableBurstCompileSynchronously) { return ForceBurstCompilationSynchronously; } return true; } } internal Action OptionsChanged { get; set; } internal static string SerialiseCompilationOptionsSafe(string[] roots, string[] folders, string options) { return SafeStringArrayHelper.SerialiseStringArraySafe(new string[3] { SafeStringArrayHelper.SerialiseStringArraySafe(roots), SafeStringArrayHelper.SerialiseStringArraySafe(folders), options }); } internal static (string[] roots, string[] folders, string options) DeserialiseCompilationOptionsSafe(string from) { string[] array = SafeStringArrayHelper.DeserialiseStringArraySafe(from); return (roots: SafeStringArrayHelper.DeserialiseStringArraySafe(array[0]), folders: SafeStringArrayHelper.DeserialiseStringArraySafe(array[1]), options: array[2]); } private BurstCompilerOptions() : this(isGlobal: false) { } internal BurstCompilerOptions(bool isGlobal) { IsGlobal = isGlobal; EnableBurstCompilation = true; EnableBurstSafetyChecks = true; } internal BurstCompilerOptions Clone() { return new BurstCompilerOptions { EnableBurstCompilation = EnableBurstCompilation, EnableBurstCompileSynchronously = EnableBurstCompileSynchronously, EnableBurstSafetyChecks = EnableBurstSafetyChecks, EnableBurstTimings = EnableBurstTimings, EnableBurstDebug = EnableBurstDebug, ForceEnableBurstSafetyChecks = ForceEnableBurstSafetyChecks }; } private static bool TryGetAttribute(MemberInfo member, out BurstCompileAttribute attribute) { attribute = null; if (member == null) { return false; } attribute = GetBurstCompileAttribute(member); if (attribute == null) { return false; } return true; } private static bool TryGetAttribute(Assembly assembly, out BurstCompileAttribute attribute) { if (assembly == null) { attribute = null; return false; } attribute = assembly.GetCustomAttribute<BurstCompileAttribute>(); return attribute != null; } private static BurstCompileAttribute GetBurstCompileAttribute(MemberInfo memberInfo) { BurstCompileAttribute customAttribute = memberInfo.GetCustomAttribute<BurstCompileAttribute>(); if (customAttribute != null) { return customAttribute; } foreach (Attribute customAttribute2 in memberInfo.GetCustomAttributes()) { if (customAttribute2.GetType().FullName == "Burst.Compiler.IL.Tests.TestCompilerAttribute") { List<string> list = new List<string>(); return new BurstCompileAttribute(FloatPrecision.Standard, FloatMode.Default) { CompileSynchronously = true, Options = list.ToArray() }; } } return null; } internal static bool HasBurstCompileAttribute(MemberInfo member) { if (member == null) { throw new ArgumentNullException("member"); } BurstCompileAttribute attribute; return TryGetAttribute(member, out attribute); } internal static void MergeAttributes(ref BurstCompileAttribute memberAttribute, in BurstCompileAttribute assemblyAttribute) { if (memberAttribute.FloatMode == FloatMode.Default) { memberAttribute.FloatMode = assemblyAttribute.FloatMode; } if (memberAttribute.FloatPrecision == FloatPrecision.Standard) { memberAttribute.FloatPrecision = assemblyAttribute.FloatPrecision; } if (memberAttribute.OptimizeFor == OptimizeFor.Default) { memberAttribute.OptimizeFor = assemblyAttribute.OptimizeFor; } if (!memberAttribute._compileSynchronously.HasValue && assemblyAttribute._compileSynchronously.HasValue) { memberAttribute._compileSynchronously = assemblyAttribute._compileSynchronously; } if (!memberAttribute._debug.HasValue && assemblyAttribute._debug.HasValue) { memberAttribute._debug = assemblyAttribute._debug; } if (!memberAttribute._disableDirectCall.HasValue && assemblyAttribute._disableDirectCall.HasValue) { memberAttribute._disableDirectCall = assemblyAttribute._disableDirectCall; } if (!memberAttribute._disableSafetyChecks.HasValue && assemblyAttribute._disableSafetyChecks.HasValue) { memberAttribute._disableSafetyChecks = assemblyAttribute._disableSafetyChecks; } } internal bool TryGetOptions(MemberInfo member, out string flagsOut, bool isForILPostProcessing = false, bool isForCompilerClient = false, bool deterministicCompilation = false) { flagsOut = null; if (!TryGetAttribute(member, out var attribute)) { return false; } if (TryGetAttribute(member.Module.Assembly, out var attribute2)) { MergeAttributes(ref attribute, in attribute2); } flagsOut = GetOptions(attribute, isForILPostProcessing, isForCompilerClient, deterministicCompilation); return true; } internal string GetOptions(BurstCompileAttribute attr = null, bool isForILPostProcessing = false, bool isForCompilerClient = false, bool deterministicCompilation = false) { StringBuilder stringBuilder = new StringBuilder(); if (!isForCompilerClient && ((attr != null && attr.CompileSynchronously) || RequiresSynchronousCompilation)) { AddOption(stringBuilder, GetOption("enable-synchronous-compilation")); } if (!BurstCompiler.IsApiAvailable("RegisterFrameInfo")) { AddOption(stringBuilder, GetOption("force-disable-frame-info-registration")); } AddOption(stringBuilder, GetOption("debug=", "LineOnly")); if (isForILPostProcessing) { AddOption(stringBuilder, GetOption("compilation-priority=", CompilationPriority.ILPP)); } FloatMode floatMode = FloatMode.Default; if (deterministicCompilation) { floatMode = FloatMode.Deterministic; } if (attr != null) { if (attr.FloatMode != FloatMode.Default) { floatMode = attr.FloatMode; } if (attr.FloatPrecision != FloatPrecision.Standard) { AddOption(stringBuilder, GetOption("float-precision=", attr.FloatPrecision)); } if (attr.DisableSafetyChecks) { AddOption(stringBuilder, GetOption("disable-safety-checks")); } if (attr.Options != null) { string[] options = attr.Options; foreach (string text in options) { if (!string.IsNullOrEmpty(text)) { AddOption(stringBuilder, text); } } } switch (attr.OptimizeFor) { case OptimizeFor.Default: case OptimizeFor.Balanced: AddOption(stringBuilder, GetOption("opt-level=", 2)); break; case OptimizeFor.Performance: AddOption(stringBuilder, GetOption("opt-level=", 3)); break; case OptimizeFor.Size: AddOption(stringBuilder, GetOption("opt-for-size")); AddOption(stringBuilder, GetOption("opt-level=", 3)); break; case OptimizeFor.FastCompilation: AddOption(stringBuilder, GetOption("opt-level=", 1)); break; } } if (floatMode != FloatMode.Default) { AddOption(stringBuilder, GetOption("float-mode=", floatMode)); } if (ForceEnableBurstSafetyChecks) { AddOption(stringBuilder, GetOption("global-safety-checks-setting=", GlobalSafetyChecksSettingKind.ForceOn)); } else if (EnableBurstSafetyChecks) { AddOption(stringBuilder, GetOption("global-safety-checks-setting=", GlobalSafetyChecksSettingKind.On)); } else { AddOption(stringBuilder, GetOption("global-safety-checks-setting=", GlobalSafetyChecksSettingKind.Off)); } if (EnableBurstTimings) { AddOption(stringBuilder, GetOption("log-timings")); } if (EnableBurstDebug || (attr != null && attr.Debug)) { AddOption(stringBuilder, GetOption("debugMode")); } AddOption(stringBuilder, GetOption("temp-folder=", Path.Combine(Environment.CurrentDirectory, "Temp", "Burst"))); return stringBuilder.ToString(); } private static void AddOption(StringBuilder builder, string option) { if (builder.Length != 0) { builder.Append('\n'); } builder.Append(option); } internal static string GetOption(string optionName, object value = null) { if (optionName == null) { throw new ArgumentNullException("optionName"); } return "--" + optionName + (value ?? string.Empty); } private void OnOptionsChanged() { OptionsChanged?.Invoke(); } private void MaybeTriggerRecompilation() { } static BurstCompilerOptions() { string[] commandLineArgs = Environment.GetCommandLineArgs(); foreach (string text in commandLineArgs) { if (!(text == "--burst-disable-compilation")) { if (text == "--burst-force-sync-compilation") { ForceBurstCompilationSynchronously = true; } } else { ForceDisableBurstCompilation = true; } } if (CheckIsSecondaryUnityProcess()) { ForceDisableBurstCompilation = true; IsSecondaryUnityProcess = true; } string environmentVariable = Environment.GetEnvironmentVariable("UNITY_BURST_DISABLE_COMPILATION"); if (!string.IsNullOrEmpty(environmentVariable) && environmentVariable != "0") { ForceDisableBurstCompilation = true; } } private static bool CheckIsSecondaryUnityProcess() { return false; } } internal enum BurstTargetCpu { Auto, X86_SSE2, X86_SSE4, X64_SSE2, X64_SSE4, AVX, AVX2, WASM32, ARMV7A_NEON32, ARMV8A_AARCH64, THUMB2_NEON32, ARMV8A_AARCH64_HALFFP, ARMV9A } [Flags] internal enum NativeDumpFlags { None = 0, IL = 1, Unused = 2, IR = 4, IROptimized = 8, Asm = 0x10, Function = 0x20, Analysis = 0x40, IRPassAnalysis = 0x80, ILPre = 0x100, IRPerEntryPoint = 0x200, All = 0x3FD } internal enum CompilationPriority { EagerCompilationSynchronous, Asynchronous, ILPP, EagerCompilationAsynchronous } public enum BurstExecutionEnvironment { Default = 0, NonDeterministic = 0, Deterministic = 1 } public static class BurstRuntime { [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HashCode32<T> { public static readonly int Value = HashStringWithFNV1A32(typeof(T).AssemblyQualifiedName); } [StructLayout(LayoutKind.Sequential, Size = 1)] private struct HashCode64<T> { public static readonly long Value = HashStringWithFNV1A64(typeof(T).AssemblyQualifiedName); } internal class PreserveAttribute : Attribute { } public static int GetHashCode32<T>() { return HashCode32<T>.Value; } public static int GetHashCode32(Type type) { return HashStringWithFNV1A32(type.AssemblyQualifiedName); } public static long GetHashCode64<T>() { return HashCode64<T>.Value; } public static long GetHashCode64(Type type) { return HashStringWithFNV1A64(type.AssemblyQualifiedName); } internal static int HashStringWithFNV1A32(string text) { uint num = 2166136261u; foreach (char c in text) { num = 16777619 * (num ^ (byte)(c & 0xFF)); num = 16777619 * (num ^ (byte)((int)c >> 8)); } return (int)num; } internal static long HashStringWithFNV1A64(string text) { ulong num = 14695981039346656037uL; foreach (char c in text) { num = 1099511628211L * (num ^ (byte)(c & 0xFF)); num = 1099511628211L * (num ^ (byte)((int)c >> 8)); } return (long)num; } public static bool LoadAdditionalLibrary(string pathToLibBurstGenerated) { if (BurstCompiler.IsLoadAdditionalLibrarySupported()) { return LoadAdditionalLibraryInternal(pathToLibBurstGenerated); } return false; } internal static bool LoadAdditionalLibraryInternal(string pathToLibBurstGenerated) { return (bool)typeof(BurstCompilerService).GetMethod("LoadBurstLibrary").Invoke(null, new object[1] { pathToLibBurstGenerated }); } [Preserve] internal unsafe static void RuntimeLog(byte* message, int logType, byte* fileName, int lineNumber) { BurstCompilerService.RuntimeLog((void*)null, (BurstLogType)logType, message, fileName, lineNumber); } internal static void Initialize() { } [Preserve] internal static void PreventRequiredAttributeStrip() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) new BurstDiscardAttribute(); new ConditionalAttribute("HEJSA"); new JobProducerTypeAttribute(typeof(BurstRuntime)); } [Preserve] internal unsafe static void Log(byte* message, int logType, byte* fileName, int lineNumber) { BurstCompilerService.Log((void*)null, (BurstLogType)logType, message, (byte*)null, lineNumber); } public unsafe static byte* GetUTF8LiteralPointer(string str, out int byteCount) { throw new NotImplementedException("This function only works from Burst"); } } internal static class BurstString { public struct tBigInt { private const int c_BigInt_MaxBlocks = 35; public int m_length; public unsafe fixed uint m_blocks[35]; public int GetLength() { return m_length; } public unsafe uint GetBlock(int idx) { return m_blocks[idx]; } public void SetZero() { m_length = 0; } public bool IsZero() { return m_length == 0; } public unsafe void SetU64(ulong val) { if (val > uint.MaxValue) { m_blocks[0] = (uint)(val & 0xFFFFFFFFu); m_blocks[1] = (uint)((val >> 32) & 0xFFFFFFFFu); m_length = 2; } else if (val != 0L) { m_blocks[0] = (uint)(val & 0xFFFFFFFFu); m_length = 1; } else { m_length = 0; } } public unsafe void SetU32(uint val) { if (val != 0) { m_blocks[0] = val; m_length = ((val != 0) ? 1 : 0); } else { m_length = 0; } } public unsafe uint GetU32() { if (m_length != 0) { return m_blocks[0]; } return 0u; } } public enum CutoffMode { Unique, TotalLength, FractionLength } public enum PrintFloatFormat { Positional, Scientific } [StructLayout(LayoutKind.Explicit)] public struct tFloatUnion32 { [FieldOffset(0)] public float m_floatingPoint; [FieldOffset(0)] public uint m_integer; public bool IsNegative() { return m_integer >> 31 != 0; } public uint GetExponent() { return (m_integer >> 23) & 0xFF; } public uint GetMantissa() { return m_integer & 0x7FFFFF; } } [StructLayout(LayoutKind.Explicit)] public struct tFloatUnion64 { [FieldOffset(0)] public double m_floatingPoint; [FieldOffset(0)] public ulong m_integer; public bool IsNegative() { return m_integer >> 63 != 0; } public uint GetExponent() { return (uint)((m_integer >> 52) & 0x7FF); } public ulong GetMantissa() { return m_integer & 0xFFFFFFFFFFFFFL; } } internal class PreserveAttribute : Attribute { } private enum NumberBufferKind { Integer, Float } private struct NumberBuffer { private unsafe readonly byte* _buffer; public NumberBufferKind Kind; public int DigitsCount; public int Scale; public readonly bool IsNegative; public unsafe NumberBuffer(NumberBufferKind kind, byte* buffer, int digitsCount, int scale, bool isNegative) { Kind = kind; _buffer = buffer; DigitsCount = digitsCount; Scale = scale; IsNegative = isNegative; } public unsafe byte* GetDigitsPointer() { return _buffer; } } public enum NumberFormatKind : byte { General, Decimal, DecimalForceSigned, Hexadecimal } public struct FormatOptions { public NumberFormatKind Kind; public sbyte AlignAndSize; public byte Specifier; public bool Lowercase; public bool Uppercase => !Lowercase; public FormatOptions(NumberFormatKind kind, sbyte alignAndSize, byte specifier, bool lowercase) { this = default(FormatOptions); Kind = kind; AlignAndSize = alignAndSize; Specifier = specifier; Lowercase = lowercase; } public unsafe int EncodeToRaw() { FormatOptions formatOptions = this; return *(int*)(&formatOptions); } public int GetBase() { if (Kind == NumberFormatKind.Hexadecimal) { return 16; } return 10; } public override string ToString() { return string.Format("{0}: {1}, {2}: {3}, {4}: {5}, {6}: {7}", "Kind", Kind, "AlignAndSize", AlignAndSize, "Specifier", Specifier, "Uppercase", Uppercase); } } private static readonly byte[] logTable = new byte[256] { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; private static readonly uint[] g_PowerOf10_U32 = new uint[8] { 1u, 10u, 100u, 1000u, 10000u, 100000u, 1000000u, 10000000u }; private static readonly byte[] InfinityString = new byte[8] { 73, 110, 102, 105, 110, 105, 116, 121 }; private static readonly byte[] NanString = new byte[3] { 78, 97, 78 }; private const int SinglePrecision = 9; private const int DoublePrecision = 17; internal const int SingleNumberBufferLength = 10; internal const int DoubleNumberBufferLength = 18; private const int SinglePrecisionCustomFormat = 7; private const int DoublePrecisionCustomFormat = 15; private static readonly char[] SplitByColon = new char[1] { ':' }; private static uint LogBase2(uint val) { uint num = val >> 24; if (num != 0) { return (uint)(24 + logTable[num]); } num = val >> 16; if (num != 0) { return (uint)(16 + logTable[num]); } num = val >> 8; if (num != 0) { return (uint)(8 + logTable[num]); } return logTable[val]; } private unsafe static int BigInt_Compare(in tBigInt lhs, in tBigInt rhs) { int num = lhs.m_length - rhs.m_length; if (num != 0) { return num; } for (int num2 = lhs.m_length - 1; num2 >= 0; num2--) { if (lhs.m_blocks[num2] != rhs.m_blocks[num2]) { if (lhs.m_blocks[num2] > rhs.m_blocks[num2]) { return 1; } return -1; } } return 0; } private static void BigInt_Add(out tBigInt pResult, in tBigInt lhs, in tBigInt rhs) { if (lhs.m_length < rhs.m_length) { BigInt_Add_internal(out pResult, in rhs, in lhs); } else { BigInt_Add_internal(out pResult, in lhs, in rhs); } } private unsafe static void BigInt_Add_internal(out tBigInt pResult, in tBigInt pLarge, in tBigInt pSmall) { int length = pLarge.m_length; int length2 = pSmall.m_length; pResult.m_length = length; ulong num = 0uL; fixed (uint* blocks = pLarge.m_blocks) { fixed (uint* blocks2 = pSmall.m_blocks) { fixed (uint* blocks3 = pResult.m_blocks) { uint* ptr = blocks; uint* ptr2 = blocks2; uint* ptr3 = blocks3; uint* ptr4 = ptr + length; uint* ptr5 = ptr2 + length2; while (ptr2 != ptr5) { ulong num2 = num + *ptr + *ptr2; num = num2 >> 32; *ptr3 = (uint)(num2 & 0xFFFFFFFFu); ptr++; ptr2++; ptr3++; } while (ptr != ptr4) { ulong num3 = num + *ptr; num = num3 >> 32; *ptr3 = (uint)(num3 & 0xFFFFFFFFu); ptr++; ptr3++; } if (num != 0L) { *ptr3 = 1u; pResult.m_length = length + 1; } else { pResult.m_length = length; } } } } } private static void BigInt_Multiply(out tBigInt pResult, in tBigInt lhs, in tBigInt rhs) { if (lhs.m_length < rhs.m_length) { BigInt_Multiply_internal(out pResult, in rhs, in lhs); } else { BigInt_Multiply_internal(out pResult, in lhs, in rhs); } } private unsafe static void BigInt_Multiply_internal(out tBigInt pResult, in tBigInt pLarge, in tBigInt pSmall) { int num = pLarge.m_length + pSmall.m_length; for (int i = 0; i < num; i++) { pResult.m_blocks[i] = 0u; } fixed (uint* blocks = pLarge.m_blocks) { uint* ptr = blocks + pLarge.m_length; fixed (uint* blocks2 = pResult.m_blocks) { fixed (uint* blocks3 = pSmall.m_blocks) { uint* ptr2 = blocks3; uint* ptr3 = ptr2 + pSmall.m_length; uint* ptr4 = blocks2; while (ptr2 != ptr3) { uint num2 = *ptr2; if (num2 != 0) { uint* ptr5 = blocks; uint* ptr6 = ptr4; ulong num3 = 0uL; do { ulong num4 = (ulong)(*ptr6 + (long)(*ptr5) * (long)num2) + num3; num3 = num4 >> 32; *ptr6 = (uint)(num4 & 0xFFFFFFFFu); ptr5++; ptr6++; } while (ptr5 != ptr); *ptr6 = (uint)(num3 & 0xFFFFFFFFu); } ptr2++; ptr4++; } if (num > 0 && pResult.m_blocks[num - 1] == 0) { pResult.m_length = num - 1; } else { pResult.m_length = num; } } } } } private unsafe static void BigInt_Multiply(out tBigInt pResult, in tBigInt lhs, uint rhs) { uint num = 0u; fixed (uint* blocks = pResult.m_blocks) { fixed (uint* blocks2 = lhs.m_blocks) { uint* ptr = blocks; uint* ptr2 = blocks2; uint* ptr3 = ptr2 + lhs.m_length; while (ptr2 != ptr3) { ulong num2 = (ulong)((long)(*ptr2) * (long)rhs + num); *ptr = (uint)(num2 & 0xFFFFFFFFu); num = (uint)(num2 >> 32); ptr2++; ptr++; } if (num != 0) { *ptr = num; pResult.m_length = lhs.m_length + 1; } else { pResult.m_length = lhs.m_length; } } } } private unsafe static void BigInt_Multiply2(out tBigInt pResult, in tBigInt input) { uint num = 0u; fixed (uint* blocks = pResult.m_blocks) { fixed (uint* blocks2 = input.m_blocks) { uint* ptr = blocks; uint* ptr2 = blocks2; uint* ptr3 = ptr2 + input.m_length; while (ptr2 != ptr3) { uint num2 = *ptr2; *ptr = (num2 << 1) | num; num = num2 >> 31; ptr2++; ptr++; } if (num != 0) { *ptr = num; pResult.m_length = input.m_length + 1; } else { pResult.m_length = input.m_length; } } } } private unsafe static void BigInt_Multiply2(ref tBigInt pResult) { uint num = 0u; fixed (uint* blocks = pResult.m_blocks) { uint* ptr = blocks; for (uint* ptr2 = ptr + pResult.m_length; ptr != ptr2; ptr++) { uint num2 = *ptr; *ptr = (num2 << 1) | num; num = num2 >> 31; } if (num != 0) { *ptr = num; pResult.m_length++; } } } private unsafe static void BigInt_Multiply10(ref tBigInt pResult) { ulong num = 0uL; fixed (uint* blocks = pResult.m_blocks) { uint* ptr = blocks; for (uint* ptr2 = ptr + pResult.m_length; ptr != ptr2; ptr++) { ulong num2 = (ulong)((long)(*ptr) * 10L) + num; *ptr = (uint)(num2 & 0xFFFFFFFFu); num = num2 >> 32; } if (num != 0L) { *ptr = (uint)num; pResult.m_length++; } } } private unsafe static tBigInt g_PowerOf10_Big(int i) { tBigInt result = default(tBigInt); switch (i) { case 0: result.m_length = 1; result.m_blocks[0] = 100000000u; break; case 1: result.m_length = 2; result.m_blocks[0] = 1874919424u; result.m_blocks[1] = 2328306u; break; case 2: result.m_length = 4; result.m_blocks[0] = 0u; result.m_blocks[1] = 2242703233u; result.m_blocks[2] = 762134875u; result.m_blocks[3] = 1262u; break; case 3: result.m_length = 7; result.m_blocks[0] = 0u; result.m_blocks[1] = 0u; result.m_blocks[2] = 3211403009u; result.m_blocks[3] = 1849224548u; result.m_blocks[4] = 3668416493u; result.m_blocks[5] = 3913284084u; result.m_blocks[6] = 1593091u; break; case 4: result.m_length = 14; result.m_blocks[0] = 0u; result.m_blocks[1] = 0u; result.m_blocks[2] = 0u; result.m_blocks[3] = 0u; result.m_blocks[4] = 781532673u; result.m_blocks[5] = 64985353u; result.m_blocks[6] = 253049085u; result.m_blocks[7] = 594863151u; result.m_blocks[8] = 3553621484u; result.m_blocks[9] = 3288652808u; result.m_blocks[10] = 3167596762u; result.m_blocks[11] = 2788392729u; result.m_blocks[12] = 3911132675u; result.m_blocks[13] = 590u; break; default: result.m_length = 27; result.m_blocks[0] = 0u; result.m_blocks[1] = 0u; result.m_blocks[2] = 0u; result.m_blocks[3] = 0u; result.m_blocks[4] = 0u; result.m_blocks[5] = 0u; result.m_blocks[6] = 0u; result.m_blocks[7] = 0u; result.m_blocks[8] = 2553183233u; result.m_blocks[9] = 3201533787u; result.m_blocks[10] = 3638140786u; result.m_blocks[11] = 303378311u; result.m_blocks[12] = 1809731782u; result.m_blocks[13] = 3477761648u; result.m_blocks[14] = 3583367183u; result.m_blocks[15] = 649228654u; result.m_blocks[16] = 2915460784u; result.m_blocks[17] = 487929380u; result.m_blocks[18] = 1011012442u; result.m_blocks[19] = 1677677582u; result.m_blocks[20] = 3428152256u; result.m_blocks[21] = 1710878487u; result.m_blocks[22] = 1438394610u; result.m_blocks[23] = 2161952759u; result.m_blocks[24] = 4100910556u; result.m_blocks[25] = 1608314830u; result.m_blocks[26] = 349175u; break; } return result; } private static void BigInt_Pow10(out tBigInt pResult, uint exponent) { tBigInt lhs = default(tBigInt); tBigInt pResult2 = default(tBigInt); uint num = exponent & 7; lhs.SetU32(g_PowerOf10_U32[num]); exponent >>= 3; int num2 = 0; while (exponent != 0) { if ((exponent & 1) != 0) { BigInt_Multiply(out pResult2, in lhs, g_PowerOf10_Big(num2)); lhs = pResult2; pResult2 = lhs; } num2++; exponent >>= 1; } pResult = lhs; } private static void BigInt_MultiplyPow10(out tBigInt pResult, in tBigInt input, uint exponent) { tBigInt pResult2 = default(tBigInt); tBigInt pResult3 = default(tBigInt); uint num = exponent & 7; if (num != 0) { BigInt_Multiply(out pResult2, in input, g_PowerOf10_U32[num]); } else { pResult2 = input; } exponent >>= 3; int num2 = 0; while (exponent != 0) { if ((exponent & 1) != 0) { BigInt_Multiply(out pResult3, in pResult2, g_PowerOf10_Big(num2)); pResult2 = pResult3; pResult3 = pResult2; } num2++; exponent >>= 1; } pResult = pResult2; } private unsafe static void BigInt_Pow2(out tBigInt pResult, uint exponent) { int num = (int)exponent / 32; for (uint num2 = 0u; num2 <= num; num2++) { pResult.m_blocks[num2] = 0u; } pResult.m_length = num + 1; int num3 = (int)exponent % 32; ref uint reference = ref pResult.m_blocks[num]; reference |= (uint)(1 << num3); } private unsafe static uint BigInt_DivideWithRemainder_MaxQuotient9(ref tBigInt pDividend, in tBigInt divisor) { int num = divisor.m_length; if (pDividend.m_length < divisor.m_length) { return 0u; } fixed (uint* blocks = divisor.m_blocks) { fixed (uint* blocks2 = pDividend.m_blocks) { uint* ptr = blocks; uint* ptr2 = blocks2; uint* ptr3 = ptr + num - 1; uint num2 = *(ptr2 + num - 1) / (*ptr3 + 1); if (num2 != 0) { ulong num3 = 0uL; ulong num4 = 0uL; do { ulong num5 = (ulong)((long)(*ptr) * (long)num2) + num4; num4 = num5 >> 32; ulong num6 = *ptr2 - (num5 & 0xFFFFFFFFu) - num3; num3 = (num6 >> 32) & 1; *ptr2 = (uint)(num6 & 0xFFFFFFFFu); ptr++; ptr2++; } while (ptr <= ptr3); while (num > 0 && pDividend.m_blocks[num - 1] == 0) { num--; } pDividend.m_length = num; } if (BigInt_Compare(in pDividend, in divisor) >= 0) { num2++; ptr = blocks; ptr2 = blocks2; ulong num7 = 0uL; do { ulong num8 = (ulong)((long)(*ptr2) - (long)(*ptr)) - num7; num7 = (num8 >> 32) & 1; *ptr2 = (uint)(num8 & 0xFFFFFFFFu); ptr++; ptr2++; } while (ptr <= ptr3); while (num > 0 && pDividend.m_blocks[num - 1] == 0) { num--; } pDividend.m_length = num; } return num2; } } } private unsafe static void BigInt_ShiftLeft(ref tBigInt pResult, uint shift) { int num = (int)shift / 32; int num2 = (int)shift % 32; int length = pResult.m_length; if (num2 == 0) { fixed (uint* blocks = pResult.m_blocks) { uint* ptr = blocks + length - 1; uint* ptr2 = ptr + num; while (ptr >= blocks) { *ptr2 = *ptr; ptr--; ptr2--; } } for (uint num3 = 0u; num3 < num; num3++) { pResult.m_blocks[num3] = 0u; } pResult.m_length += num; return; } int num4 = length - 1; int num5 = length + num; pResult.m_length = num5 + 1; int num6 = 32 - num2; uint num7 = 0u; uint num8 = pResult.m_blocks[num4]; uint num9 = num8 >> num6; while (num4 > 0) { pResult.m_blocks[num5] = num7 | num9; num7 = num8 << num2; num4--; num5--; num8 = pResult.m_blocks[num4]; num9 = num8 >> num6; } pResult.m_blocks[num5] = num7 | num9; pResult.m_blocks[num5 - 1] = num8 << num2; for (uint num10 = 0u; num10 < num; num10++) { pResult.m_blocks[num10] = 0u; } if (pResult.m_blocks[pResult.m_length - 1] == 0) { pResult.m_length--; } } private unsafe static uint Dragon4(ulong mantissa, int exponent, uint mantissaHighBitIdx, bool hasUnequalMargins, CutoffMode cutoffMode, uint cutoffNumber, byte* pOutBuffer, uint bufferSize, out int pOutExponent) { byte* ptr = pOutBuffer; if (mantissa == 0L) { *ptr = 48; pOutExponent = 0; return 1u; } tBigInt pResult = default(tBigInt); tBigInt pResult2 = default(tBigInt); tBigInt input = default(tBigInt); tBigInt pResult3 = default(tBigInt); tBigInt* ptr2; if (hasUnequalMargins) { if (exponent > 0) { pResult2.SetU64(4 * mantissa); BigInt_ShiftLeft(ref pResult2, (uint)exponent); pResult.SetU32(4u); BigInt_Pow2(out input, (uint)exponent); BigInt_Pow2(out pResult3, (uint)(exponent + 1)); } else { pResult2.SetU64(4 * mantissa); BigInt_Pow2(out pResult, (uint)(-exponent + 2)); input.SetU32(1u); pResult3.SetU32(2u); } ptr2 = &pResult3; } else { if (exponent > 0) { pResult2.SetU64(2 * mantissa); BigInt_ShiftLeft(ref pResult2, (uint)exponent); pResult.SetU32(2u); BigInt_Pow2(out input, (uint)exponent); } else { pResult2.SetU64(2 * mantissa); BigInt_Pow2(out pResult, (uint)(-exponent + 1)); input.SetU32(1u); } ptr2 = &input; } int num = (int)Math.Ceiling((double)((int)mantissaHighBitIdx + exponent) * 0.3010299956639812 - 0.69); if (cutoffMode == CutoffMode.FractionLength && num <= (int)(0 - cutoffNumber)) { num = (int)(0 - cutoffNumber + 1); } if (num > 0) { BigInt_MultiplyPow10(out var pResult4, in pResult, (uint)num); pResult = pResult4; } else if (num < 0) { BigInt_Pow10(out var pResult5, (uint)(-num)); BigInt_Multiply(out var pResult6, in pResult2, in pResult5); pResult2 = pResult6; BigInt_Multiply(out pResult6, in input, in pResult5); input = pResult6; if (ptr2 != &input) { BigInt_Multiply2(out *ptr2, in input); } } if (BigInt_Compare(in pResult2, in pResult) >= 0) { num++; } else { BigInt_Multiply10(ref pResult2); BigInt_Multiply10(ref input); if (ptr2 != &input) { BigInt_Multiply2(out *ptr2, in input); } } int num2 = num - (int)bufferSize; switch (cutoffMode) { case CutoffMode.TotalLength: { int num4 = num - (int)cutoffNumber; if (num4 > num2) { num2 = num4; } break; } case CutoffMode.FractionLength: { int num3 = (int)(0 - cutoffNumber); if (num3 > num2) { num2 = num3; } break; } } pOutExponent = num - 1; uint block = pResult.GetBlock(pResult.GetLength() - 1); if (block < 8 || block > 429496729) { uint num5 = LogBase2(block); uint shift = (59 - num5) % 32; BigInt_ShiftLeft(ref pResult, shift); BigInt_ShiftLeft(ref pResult2, shift); BigInt_ShiftLeft(ref input, shift); if (ptr2 != &input) { BigInt_Multiply2(out *ptr2, in input); } } uint num6; bool flag; bool flag2; if (cutoffMode == CutoffMode.Unique) { while (true) { num--; num6 = BigInt_DivideWithRemainder_MaxQuotient9(ref pResult2, in pResult); BigInt_Add(out var pResult7, in pResult2, in *ptr2); flag = BigInt_Compare(in pResult2, in input) < 0; flag2 = BigInt_Compare(in pResult7, in pResult) > 0; if (flag || flag2 || num == num2) { break; } *ptr = (byte)(48 + num6); ptr++; BigInt_Multiply10(ref pResult2); BigInt_Multiply10(ref input); if (ptr2 != &input) { BigInt_Multiply2(out *ptr2, in input); } } } else { flag = false; flag2 = false; while (true) { num--; num6 = BigInt_DivideWithRemainder_MaxQuotient9(ref pResult2, in pResult); if (pResult2.IsZero() || num == num2) { break; } *ptr = (byte)(48 + num6); ptr++; BigInt_Multiply10(ref pResult2); } } bool flag3 = flag; if (flag == flag2) { BigInt_Multiply2(ref pResult2); int num7 = BigInt_Compare(in pResult2, in pResult); flag3 = num7 < 0; if (num7 == 0) { flag3 = (num6 & 1) == 0; } } if (flag3) { *ptr = (byte)(48 + num6); ptr++; } else if (num6 == 9) { while (true) { if (ptr == pOutBuffer) { *ptr = 49; ptr++; pOutExponent++; break; } ptr--; if (*ptr != 57) { byte* intPtr = ptr; (*intPtr)++; ptr++; break; } } } else { *ptr = (byte)(48 + num6 + 1); ptr++; } return (uint)(ptr - pOutBuffer); } private unsafe static int FormatPositional(byte* pOutBuffer, uint bufferSize, ulong mantissa, int exponent, uint mantissaHighBitIdx, bool hasUnequalMargins, int precision) { uint num = bufferSize - 1; int pOutExponent; uint num2 = ((precision >= 0) ? Dragon4(mantissa, exponent, mantissaHighBitIdx, hasUnequalMargins, CutoffMode.FractionLength, (uint)precision, pOutBuffer, num, out pOutExponent) : Dragon4(mantissa, exponent, mantissaHighBitIdx, hasUnequalMargins, CutoffMode.Unique, 0u, pOutBuffer, num, out pOutExponent)); uint num3 = 0u; if (pOutExponent >= 0) { uint num4 = (uint)(pOutExponent + 1); if (num2 < num4) { if (num4 > num) { num4 = num; } for (; num2 < num4; num2++) { pOutBuffer[num2] = 48; } } else if (num2 > num4) { num3 = num2 - num4; uint num5 = num - num4 - 1; if (num3 > num5) { num3 = num5; } Unsafe.CopyBlock((void*)(pOutBuffer + num4 + 1), (void*)(pOutBuffer + num4), num3); pOutBuffer[num4] = 46; num2 = num4 + 1 + num3; } } else { if (num > 2) { uint num6 = (uint)(-pOutExponent - 1); uint num7 = num - 2; if (num6 > num7) { num6 = num7; } uint num8 = 2 + num6; num3 = num2; uint num9 = num - num8; if (num3 > num9) { num3 = num9; } Unsafe.CopyBlock((void*)(pOutBuffer + num8), (void*)pOutBuffer, num3); for (uint num10 = 2u; num10 < num8; num10++) { pOutBuffer[num10] = 48; } num3 += num6; num2 = num3; } if (num > 1) { pOutBuffer[1] = 46; num2++; } if (num != 0) { *pOutBuffer = 48; num2++; } } if (precision > (int)num3 && num2 < num) { if (num3 == 0) { pOutBuffer[num2++] = 46; } uint num11 = (uint)(num2 + (precision - (int)num3)); if (num11 > num) { num11 = num; } for (; num2 < num11; num2++) { pOutBuffer[num2] = 48; } } return (int)num2; } private unsafe static int FormatScientific(byte* pOutBuffer, uint bufferSize, ulong mantissa, int exponent, uint mantissaHighBitIdx, bool hasUnequalMargins, int precision) { int pOutExponent; uint num = ((precision >= 0) ? Dragon4(mantissa, exponent, mantissaHighBitIdx, hasUnequalMargins, CutoffMode.TotalLength, (uint)(precision + 1), pOutBuffer, bufferSize, out pOutExponent) : Dragon4(mantissa, exponent, mantissaHighBitIdx, hasUnequalMargins, CutoffMode.Unique, 0u, pOutBuffer, bufferSize, out pOutExponent)); byte* ptr = pOutBuffer; if (bufferSize > 1) { ptr++; bufferSize--; } uint num2 = num - 1; if (num2 != 0 && bufferSize > 1) { uint num3 = bufferSize - 2; if (num2 > num3) { num2 = num3; } Unsafe.CopyBlock((void*)(ptr + 1), (void*)ptr, num2); *ptr = 46; ptr += 1 + num2; bufferSize -= 1 + num2; } if (precision > (int)num2 && bufferSize > 1) { if (num2 == 0) { *ptr = 46; ptr++; bufferSize--; } uint num4 = (uint)(precision - num2); if (num4 > bufferSize - 1) { num4 = bufferSize - 1; } for (byte* ptr2 = ptr + num4; ptr < ptr2; ptr++) { *ptr = 48; } } if (bufferSize > 1) { byte* ptr3 = stackalloc byte[5]; *ptr3 = 101; if (pOutExponent >= 0) { ptr3[1] = 43; } else { ptr3[1] = 45; pOutExponent = -pOutExponent; } uint num5 = (uint)(pOutExponent / 100); uint num6 = (uint)((pOutExponent - num5 * 100) / 10); uint num7 = (uint)(pOutExponent - num5 * 100 - num6 * 10); ptr3[2] = (byte)(48 + num5); ptr3[3] = (byte)(48 + num6); ptr3[4] = (byte)(48 + num7); uint num8 = bufferSize - 1; uint num9 = ((5 < num8) ? 5u : num8); Unsafe.CopyBlock((void*)ptr, (void*)ptr3, num9); ptr += num9; bufferSize -= num9; } return (int)(ptr - pOutBuffer); } private unsafe static void FormatInfinityNaN(byte* dest, ref int destIndex, int destLength, ulong mantissa, bool isNegative, FormatOptions formatOptions) { int length = ((mantissa == 0L) ? (8 + (isNegative ? 1 : 0)) : 3); int alignAndSize = formatOptions.AlignAndSize; if (AlignLeft(dest, ref destIndex, destLength, alignAndSize, length)) { return; } if (mantissa == 0L) { if (isNegative) { if (destIndex >= destLength) { return; } dest[destIndex++] = 45; } for (int i = 0; i < 8; i++) { if (destIndex >= destLength) { return; } dest[destIndex++] = InfinityString[i]; } } else { for (int j = 0; j < 3; j++) { if (destIndex >= destLength) { return; } dest[destIndex++] = NanString[j]; } } AlignRight(dest, ref destIndex, destLength, alignAndSize, length); } [MethodImpl(MethodImplOptions.NoInlining)] priva
plugins/EinsteinCrew-PuckosCarePackage/Pucko-NordVPO/Unity.Mathematics.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.ComponentModel; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using Unity.IL2CPP.CompilerServices; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("Unity.Mathematics.Tests")] [assembly: InternalsVisibleTo("Unity.Mathematics.PerformanceTests")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [CompilerGenerated] [EditorBrowsable(EditorBrowsableState.Never)] [GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)] internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1 { private struct MonoScriptData { public byte[] FilePathsData; public byte[] TypesData; public int TotalTypes; public int TotalFiles; public bool IsEditorOnly; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static MonoScriptData Get() { return new MonoScriptData { FilePathsData = new byte[8823] { 0, 0, 0, 2, 0, 0, 0, 97, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 71, 101, 111, 109, 101, 116, 114, 121, 92, 77, 105, 110, 77, 97, 120, 65, 65, 66, 66, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 92, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 71, 101, 111, 109, 101, 116, 114, 121, 92, 80, 108, 97, 110, 101, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 121, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 73, 108, 50, 67, 112, 112, 69, 97, 103, 101, 114, 83, 116, 97, 116, 105, 99, 67, 108, 97, 115, 115, 67, 111, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 65, 116, 116, 114, 105, 98, 117, 116, 101, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 94, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 99, 101, 108, 108, 117, 108, 97, 114, 50, 68, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 95, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 99, 101, 108, 108, 117, 108, 97, 114, 50, 120, 50, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 97, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 99, 101, 108, 108, 117, 108, 97, 114, 50, 120, 50, 120, 50, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 94, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 99, 101, 108, 108, 117, 108, 97, 114, 51, 68, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 98, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 99, 108, 97, 115, 115, 105, 99, 110, 111, 105, 115, 101, 50, 68, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 98, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 99, 108, 97, 115, 115, 105, 99, 110, 111, 105, 115, 101, 51, 68, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 98, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 99, 108, 97, 115, 115, 105, 99, 110, 111, 105, 115, 101, 52, 68, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 99, 111, 109, 109, 111, 110, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 110, 111, 105, 115, 101, 50, 68, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 110, 111, 105, 115, 101, 51, 68, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 95, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 110, 111, 105, 115, 101, 51, 68, 103, 114, 97, 100, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 110, 111, 105, 115, 101, 52, 68, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 95, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 78, 111, 105, 115, 101, 92, 112, 115, 114, 100, 110, 111, 105, 115, 101, 50, 68, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 96, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 80, 114, 111, 112, 101, 114, 116, 121, 65, 116, 116, 114, 105, 98, 117, 116, 101, 115, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 94, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 97, 102, 102, 105, 110, 101, 95, 116, 114, 97, 110, 115, 102, 111, 114, 109, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 50, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 50, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 50, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 51, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 51, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 51, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 52, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 52, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 98, 111, 111, 108, 52, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 50, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 50, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 50, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 51, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 51, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 51, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 52, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 52, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 91, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 100, 111, 117, 98, 108, 101, 52, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 50, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 50, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 50, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 51, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 51, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 51, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 52, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 52, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 90, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 102, 108, 111, 97, 116, 52, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 82, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 104, 97, 108, 102, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 104, 97, 108, 102, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 104, 97, 108, 102, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 104, 97, 108, 102, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 86, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 50, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 50, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 50, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 86, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 51, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 51, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 51, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 86, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 52, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 52, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 105, 110, 116, 52, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 82, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 109, 97, 116, 104, 46, 99, 115, 0, 0, 0, 5, 0, 0, 0, 99, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 109, 97, 116, 104, 95, 117, 110, 105, 116, 121, 95, 99, 111, 110, 118, 101, 114, 115, 105, 111, 110, 46, 99, 115, 0, 0, 0, 4, 0, 0, 0, 84, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 109, 97, 116, 114, 105, 120, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 109, 97, 116, 114, 105, 120, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 88, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 113, 117, 97, 116, 101, 114, 110, 105, 111, 110, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 84, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 114, 97, 110, 100, 111, 109, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 93, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 114, 105, 103, 105, 100, 95, 116, 114, 97, 110, 115, 102, 111, 114, 109, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 81, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 115, 118, 100, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 50, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 50, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 50, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 51, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 51, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 51, 120, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 3, 0, 0, 0, 87, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 52, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 52, 120, 50, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 52, 120, 51, 46, 103, 101, 110, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 89, 92, 76, 105, 98, 114, 97, 114, 121, 92, 80, 97, 99, 107, 97, 103, 101, 67, 97, 99, 104, 101, 92, 99, 111, 109, 46, 117, 110, 105, 116, 121, 46, 109, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 64, 56, 48, 49, 55, 98, 53, 48, 55, 99, 99, 55, 52, 92, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 92, 117, 105, 110, 116, 52, 120, 52, 46, 103, 101, 110, 46, 99, 115 }, TypesData = new byte[5559] { 0, 0, 0, 0, 37, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 71, 101, 111, 109, 101, 116, 114, 121, 124, 77, 105, 110, 77, 97, 120, 65, 65, 66, 66, 0, 0, 0, 0, 31, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 71, 101, 111, 109, 101, 116, 114, 121, 124, 77, 97, 116, 104, 0, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 71, 101, 111, 109, 101, 116, 114, 121, 124, 80, 108, 97, 110, 101, 0, 0, 0, 0, 73, 85, 110, 105, 116, 121, 46, 73, 76, 50, 67, 80, 80, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 124, 73, 108, 50, 67, 112, 112, 69, 97, 103, 101, 114, 83, 116, 97, 116, 105, 99, 67, 108, 97, 115, 115, 67, 111, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 65, 116, 116, 114, 105, 98, 117, 116, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 1, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 110, 111, 105, 115, 101, 0, 0, 0, 0, 40, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 80, 111, 115, 116, 78, 111, 114, 109, 97, 108, 105, 122, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 41, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 68, 111, 78, 111, 116, 78, 111, 114, 109, 97, 108, 105, 122, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 0, 0, 0, 33, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 65, 102, 102, 105, 110, 101, 84, 114, 97, 110, 115, 102, 111, 114, 109, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 50, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 50, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 50, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 50, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 51, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 51, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 51, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 51, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 52, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 52, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 52, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 98, 111, 111, 108, 52, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 50, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 50, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 50, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 50, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 51, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 51, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 51, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 51, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 52, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 52, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 52, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 27, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 100, 111, 117, 98, 108, 101, 52, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 50, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 50, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 50, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 50, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 51, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 51, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 51, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 51, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 52, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 52, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 52, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 52, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 104, 97, 108, 102, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 104, 97, 108, 102, 50, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 104, 97, 108, 102, 51, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 104, 97, 108, 102, 52, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 50, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 50, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 50, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 50, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 51, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 51, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 51, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 51, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 52, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 52, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 52, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 105, 110, 116, 52, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 38, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 109, 97, 116, 104, 124, 76, 111, 110, 103, 68, 111, 117, 98, 108, 101, 85, 110, 105, 111, 110, 1, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 50, 1, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 51, 1, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 52, 1, 0, 0, 0, 28, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 113, 117, 97, 116, 101, 114, 110, 105, 111, 110, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 52, 120, 52, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 50, 120, 50, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 51, 120, 51, 1, 0, 0, 0, 26, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 102, 108, 111, 97, 116, 52, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 1, 0, 0, 0, 28, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 113, 117, 97, 116, 101, 114, 110, 105, 111, 110, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 24, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 82, 97, 110, 100, 111, 109, 0, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 82, 105, 103, 105, 100, 84, 114, 97, 110, 115, 102, 111, 114, 109, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 21, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 115, 118, 100, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 50, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 50, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 50, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 50, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 51, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 51, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 51, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 51, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 23, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 52, 1, 0, 0, 0, 32, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 46, 124, 68, 101, 98, 117, 103, 103, 101, 114, 80, 114, 111, 120, 121, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 52, 120, 50, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 52, 120, 51, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104, 0, 0, 0, 0, 25, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 117, 105, 110, 116, 52, 120, 52, 1, 0, 0, 0, 22, 85, 110, 105, 116, 121, 46, 77, 97, 116, 104, 101, 109, 97, 116, 105, 99, 115, 124, 109, 97, 116, 104 }, TotalFiles = 90, TotalTypes = 185, IsEditorOnly = false }; } } namespace Unity.IL2CPP.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)] internal class Il2CppEagerStaticClassConstructionAttribute : Attribute { } } namespace Unity.Mathematics { [Il2CppEagerStaticClassConstruction] public static class noise { public static float2 cellular(float2 P) { float2 float5 = mod289(math.floor(P)); float2 obj = math.frac(P); float3 float6 = math.float3(-1f, 0f, 1f); float3 float7 = math.float3(-0.5f, 0.5f, 1.5f); float3 float8 = permute(float5.x + float6); float3 obj2 = permute(float8.x + float5.y + float6); float3 float9 = math.frac(obj2 * (1f / 7f)) - 0.42857143f; float3 float10 = mod7(math.floor(obj2 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float11 = obj.x + 0.5f + 1f * float9; float3 float12 = obj.y - float7 + 1f * float10; float3 x = float11 * float11 + float12 * float12; float3 obj3 = permute(float8.y + float5.y + float6); float9 = math.frac(obj3 * (1f / 7f)) - 0.42857143f; float10 = mod7(math.floor(obj3 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float11 = obj.x - 0.5f + 1f * float9; float12 = obj.y - float7 + 1f * float10; float3 y = float11 * float11 + float12 * float12; float3 obj4 = permute(float8.z + float5.y + float6); float9 = math.frac(obj4 * (1f / 7f)) - 0.42857143f; float10 = mod7(math.floor(obj4 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float11 = obj.x - 1.5f + 1f * float9; float12 = obj.y - float7 + 1f * float10; float3 y2 = float11 * float11 + float12 * float12; float3 x2 = math.min(x, y); y = math.max(x, y); y = math.min(y, y2); x = math.min(x2, y); y = math.max(x2, y); x.xy = ((x.x < x.y) ? x.xy : x.yx); x.xz = ((x.x < x.z) ? x.xz : x.zx); x.yz = math.min(x.yz, y.yz); x.y = math.min(x.y, x.z); x.y = math.min(x.y, y.x); return math.sqrt(x.xy); } public static float2 cellular2x2(float2 P) { float2 float5 = mod289(math.floor(P)); float2 obj = math.frac(P); float4 float6 = obj.x + math.float4(-0.5f, -1.5f, -0.5f, -1.5f); float4 float7 = obj.y + math.float4(-0.5f, -0.5f, -1.5f, -1.5f); float4 obj2 = permute(permute(float5.x + math.float4(0f, 1f, 0f, 1f)) + float5.y + math.float4(0f, 0f, 1f, 1f)); float4 float8 = mod7(obj2) * (1f / 7f) + 1f / 14f; float4 float9 = mod7(math.floor(obj2 * (1f / 7f))) * (1f / 7f) + 1f / 14f; float4 obj3 = float6 + 0.8f * float8; float4 float10 = float7 + 0.8f * float9; float4 float11 = obj3 * obj3 + float10 * float10; float11.xy = ((float11.x < float11.y) ? float11.xy : float11.yx); float11.xz = ((float11.x < float11.z) ? float11.xz : float11.zx); float11.xw = ((float11.x < float11.w) ? float11.xw : float11.wx); float11.y = math.min(float11.y, float11.z); float11.y = math.min(float11.y, float11.w); return math.sqrt(float11.xy); } public static float2 cellular2x2x2(float3 P) { float3 float5 = mod289(math.floor(P)); float3 float6 = math.frac(P); float4 float7 = float6.x + math.float4(0f, -1f, 0f, -1f); float4 float8 = float6.y + math.float4(0f, 0f, -1f, -1f); float4 obj = permute(permute(float5.x + math.float4(0f, 1f, 0f, 1f)) + float5.y + math.float4(0f, 0f, 1f, 1f)); float4 float9 = permute(obj + float5.z); float4 obj2 = permute(obj + float5.z + math.float4(1f, 1f, 1f, 1f)); float4 float10 = math.frac(float9 * (1f / 7f)) - 0.42857143f; float4 float11 = mod7(math.floor(float9 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float4 float12 = math.floor(float9 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float4 float13 = math.frac(obj2 * (1f / 7f)) - 0.42857143f; float4 float14 = mod7(math.floor(obj2 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float4 float15 = math.floor(obj2 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float4 float16 = float7 + 0.8f * float10; float4 float17 = float8 + 0.8f * float11; float4 float18 = float6.z + 0.8f * float12; float4 float19 = float7 + 0.8f * float13; float4 float20 = float8 + 0.8f * float14; float4 float21 = float6.z - 1f + 0.8f * float15; float4 x = float16 * float16 + float17 * float17 + float18 * float18; float4 y = float19 * float19 + float20 * float20 + float21 * float21; float4 float22 = math.min(x, y); y = math.max(x, y); float22.xy = ((float22.x < float22.y) ? float22.xy : float22.yx); float22.xz = ((float22.x < float22.z) ? float22.xz : float22.zx); float22.xw = ((float22.x < float22.w) ? float22.xw : float22.wx); float22.yzw = math.min(float22.yzw, y.yzw); float22.y = math.min(float22.y, float22.z); float22.y = math.min(float22.y, float22.w); float22.y = math.min(float22.y, y.x); return math.sqrt(float22.xy); } public static float2 cellular(float3 P) { float3 float5 = mod289(math.floor(P)); float3 obj = math.frac(P) - 0.5f; float3 float6 = obj.x + math.float3(1f, 0f, -1f); float3 float7 = obj.y + math.float3(1f, 0f, -1f); float3 float8 = obj.z + math.float3(1f, 0f, -1f); float3 obj2 = permute(float5.x + math.float3(-1f, 0f, 1f)); float3 float9 = permute(obj2 + float5.y - 1f); float3 float10 = permute(obj2 + float5.y); float3 obj3 = permute(obj2 + float5.y + 1f); float3 float11 = permute(float9 + float5.z - 1f); float3 float12 = permute(float9 + float5.z); float3 float13 = permute(float9 + float5.z + 1f); float3 float14 = permute(float10 + float5.z - 1f); float3 float15 = permute(float10 + float5.z); float3 float16 = permute(float10 + float5.z + 1f); float3 float17 = permute(obj3 + float5.z - 1f); float3 float18 = permute(obj3 + float5.z); float3 obj4 = permute(obj3 + float5.z + 1f); float3 float19 = math.frac(float11 * (1f / 7f)) - 0.42857143f; float3 float20 = mod7(math.floor(float11 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float21 = math.floor(float11 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float22 = math.frac(float12 * (1f / 7f)) - 0.42857143f; float3 float23 = mod7(math.floor(float12 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float24 = math.floor(float12 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float25 = math.frac(float13 * (1f / 7f)) - 0.42857143f; float3 float26 = mod7(math.floor(float13 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float27 = math.floor(float13 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float28 = math.frac(float14 * (1f / 7f)) - 0.42857143f; float3 float29 = mod7(math.floor(float14 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float30 = math.floor(float14 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float31 = math.frac(float15 * (1f / 7f)) - 0.42857143f; float3 float32 = mod7(math.floor(float15 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float33 = math.floor(float15 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float34 = math.frac(float16 * (1f / 7f)) - 0.42857143f; float3 float35 = mod7(math.floor(float16 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float36 = math.floor(float16 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float37 = math.frac(float17 * (1f / 7f)) - 0.42857143f; float3 float38 = mod7(math.floor(float17 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float39 = math.floor(float17 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float40 = math.frac(float18 * (1f / 7f)) - 0.42857143f; float3 float41 = mod7(math.floor(float18 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float42 = math.floor(float18 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float43 = math.frac(obj4 * (1f / 7f)) - 0.42857143f; float3 float44 = mod7(math.floor(obj4 * (1f / 7f))) * (1f / 7f) - 0.42857143f; float3 float45 = math.floor(obj4 * (1f / 49f)) * (1f / 6f) - 5f / 12f; float3 float46 = float6 + 1f * float19; float3 float47 = float7.x + 1f * float20; float3 float48 = float8.x + 1f * float21; float3 float49 = float6 + 1f * float22; float3 float50 = float7.x + 1f * float23; float3 float51 = float8.y + 1f * float24; float3 float52 = float6 + 1f * float25; float3 float53 = float7.x + 1f * float26; float3 float54 = float8.z + 1f * float27; float3 float55 = float6 + 1f * float28; float3 float56 = float7.y + 1f * float29; float3 float57 = float8.x + 1f * float30; float3 float58 = float6 + 1f * float31; float3 float59 = float7.y + 1f * float32; float3 float60 = float8.y + 1f * float33; float3 float61 = float6 + 1f * float34; float3 float62 = float7.y + 1f * float35; float3 float63 = float8.z + 1f * float36; float3 float64 = float6 + 1f * float37; float3 float65 = float7.z + 1f * float38; float3 float66 = float8.x + 1f * float39; float3 float67 = float6 + 1f * float40; float3 float68 = float7.z + 1f * float41; float3 float69 = float8.y + 1f * float42; float3 obj5 = float6 + 1f * float43; float3 float70 = float7.z + 1f * float44; float3 float71 = float8.z + 1f * float45; float3 x = float46 * float46 + float47 * float47 + float48 * float48; float3 y = float49 * float49 + float50 * float50 + float51 * float51; float3 y2 = float52 * float52 + float53 * float53 + float54 * float54; float3 x2 = float55 * float55 + float56 * float56 + float57 * float57; float3 y3 = float58 * float58 + float59 * float59 + float60 * float60; float3 y4 = float61 * float61 + float62 * float62 + float63 * float63; float3 x3 = float64 * float64 + float65 * float65 + float66 * float66; float3 y5 = float67 * float67 + float68 * float68 + float69 * float69; float3 y6 = obj5 * obj5 + float70 * float70 + float71 * float71; float3 x4 = math.min(x, y); y = math.max(x, y); x = math.min(x4, y2); y2 = math.max(x4, y2); y = math.min(y, y2); float3 x5 = math.min(x2, y3); y3 = math.max(x2, y3); x2 = math.min(x5, y4); y4 = math.max(x5, y4); y3 = math.min(y3, y4); float3 x6 = math.min(x3, y5); y5 = math.max(x3, y5); x3 = math.min(x6, y6); y6 = math.max(x6, y6); y5 = math.min(y5, y6); float3 x7 = math.min(x, x2); x2 = math.max(x, x2); x = math.min(x7, x3); x3 = math.max(x7, x3); x.xy = ((x.x < x.y) ? x.xy : x.yx); x.xz = ((x.x < x.z) ? x.xz : x.zx); y = math.min(y, x2); y = math.min(y, y3); y = math.min(y, x3); y = math.min(y, y5); x.yz = math.min(x.yz, y.xy); x.y = math.min(x.y, y.z); x.y = math.min(x.y, x.z); return math.sqrt(x.xy); } public static float cnoise(float2 P) { float4 x = math.floor(P.xyxy) + math.float4(0f, 0f, 1f, 1f); float4 float5 = math.frac(P.xyxy) - math.float4(0f, 0f, 1f, 1f); x = mod289(x); float4 xzxz = x.xzxz; float4 yyww = x.yyww; float4 xzxz2 = float5.xzxz; float4 yyww2 = float5.yyww; float4 obj = math.frac(permute(permute(xzxz) + yyww) * (1f / 41f)) * 2f - 1f; float4 float6 = math.abs(obj) - 0.5f; float4 float7 = math.floor(obj + 0.5f); float4 obj2 = obj - float7; float2 float8 = math.float2(obj2.x, float6.x); float2 float9 = math.float2(obj2.y, float6.y); float2 float10 = math.float2(obj2.z, float6.z); float2 float11 = math.float2(obj2.w, float6.w); float4 float12 = taylorInvSqrt(math.float4(math.dot(float8, float8), math.dot(float10, float10), math.dot(float9, float9), math.dot(float11, float11))); float8 *= float12.x; float10 *= float12.y; float9 *= float12.z; float11 *= float12.w; float x2 = math.dot(float8, math.float2(xzxz2.x, yyww2.x)); float x3 = math.dot(float9, math.float2(xzxz2.y, yyww2.y)); float y = math.dot(float10, math.float2(xzxz2.z, yyww2.z)); float y2 = math.dot(float11, math.float2(xzxz2.w, yyww2.w)); float2 float13 = fade(float5.xy); float2 float14 = math.lerp(math.float2(x2, y), math.float2(x3, y2), float13.x); float num = math.lerp(float14.x, float14.y, float13.y); return 2.3f * num; } public static float pnoise(float2 P, float2 rep) { float4 x = math.floor(P.xyxy) + math.float4(0f, 0f, 1f, 1f); float4 float5 = math.frac(P.xyxy) - math.float4(0f, 0f, 1f, 1f); x = math.fmod(x, rep.xyxy); x = mod289(x); float4 xzxz = x.xzxz; float4 yyww = x.yyww; float4 xzxz2 = float5.xzxz; float4 yyww2 = float5.yyww; float4 obj = math.frac(permute(permute(xzxz) + yyww) * (1f / 41f)) * 2f - 1f; float4 float6 = math.abs(obj) - 0.5f; float4 float7 = math.floor(obj + 0.5f); float4 obj2 = obj - float7; float2 float8 = math.float2(obj2.x, float6.x); float2 float9 = math.float2(obj2.y, float6.y); float2 float10 = math.float2(obj2.z, float6.z); float2 float11 = math.float2(obj2.w, float6.w); float4 float12 = taylorInvSqrt(math.float4(math.dot(float8, float8), math.dot(float10, float10), math.dot(float9, float9), math.dot(float11, float11))); float8 *= float12.x; float10 *= float12.y; float9 *= float12.z; float11 *= float12.w; float x2 = math.dot(float8, math.float2(xzxz2.x, yyww2.x)); float x3 = math.dot(float9, math.float2(xzxz2.y, yyww2.y)); float y = math.dot(float10, math.float2(xzxz2.z, yyww2.z)); float y2 = math.dot(float11, math.float2(xzxz2.w, yyww2.w)); float2 float13 = fade(float5.xy); float2 float14 = math.lerp(math.float2(x2, y), math.float2(x3, y2), float13.x); float num = math.lerp(float14.x, float14.y, float13.y); return 2.3f * num; } public static float cnoise(float3 P) { float3 float5 = math.floor(P); float3 x = float5 + math.float3(1f); float5 = mod289(float5); x = mod289(x); float3 float6 = math.frac(P); float3 y = float6 - math.float3(1f); float4 x2 = math.float4(float5.x, x.x, float5.x, x.x); float4 float7 = math.float4(float5.yy, x.yy); float4 zzzz = float5.zzzz; float4 zzzz2 = x.zzzz; float4 obj = permute(permute(x2) + float7); float4 float8 = permute(obj + zzzz); float4 obj2 = permute(obj + zzzz2); float4 x3 = float8 * (1f / 7f); float4 x4 = math.frac(math.floor(x3) * (1f / 7f)) - 0.5f; x3 = math.frac(x3); float4 threshold = math.float4(0.5f) - math.abs(x3) - math.abs(x4); float4 float9 = math.step(threshold, math.float4(0f)); x3 -= float9 * (math.step(0f, x3) - 0.5f); x4 -= float9 * (math.step(0f, x4) - 0.5f); float4 x5 = obj2 * (1f / 7f); float4 x6 = math.frac(math.floor(x5) * (1f / 7f)) - 0.5f; x5 = math.frac(x5); float4 threshold2 = math.float4(0.5f) - math.abs(x5) - math.abs(x6); float4 float10 = math.step(threshold2, math.float4(0f)); x5 -= float10 * (math.step(0f, x5) - 0.5f); x6 -= float10 * (math.step(0f, x6) - 0.5f); float3 float11 = math.float3(x3.x, x4.x, threshold.x); float3 float12 = math.float3(x3.y, x4.y, threshold.y); float3 float13 = math.float3(x3.z, x4.z, threshold.z); float3 float14 = math.float3(x3.w, x4.w, threshold.w); float3 float15 = math.float3(x5.x, x6.x, threshold2.x); float3 float16 = math.float3(x5.y, x6.y, threshold2.y); float3 float17 = math.float3(x5.z, x6.z, threshold2.z); float3 float18 = math.float3(x5.w, x6.w, threshold2.w); float4 float19 = taylorInvSqrt(math.float4(math.dot(float11, float11), math.dot(float13, float13), math.dot(float12, float12), math.dot(float14, float14))); float11 *= float19.x; float13 *= float19.y; float12 *= float19.z; float14 *= float19.w; float4 float20 = taylorInvSqrt(math.float4(math.dot(float15, float15), math.dot(float17, float17), math.dot(float16, float16), math.dot(float18, float18))); float15 *= float20.x; float17 *= float20.y; float16 *= float20.z; float18 *= float20.w; float x7 = math.dot(float11, float6); float y2 = math.dot(float12, math.float3(y.x, float6.yz)); float z = math.dot(float13, math.float3(float6.x, y.y, float6.z)); float w = math.dot(float14, math.float3(y.xy, float6.z)); float x8 = math.dot(float15, math.float3(float6.xy, y.z)); float y3 = math.dot(float16, math.float3(y.x, float6.y, y.z)); float z2 = math.dot(float17, math.float3(float6.x, y.yz)); float w2 = math.dot(float18, y); float3 float21 = fade(float6); float4 float22 = math.lerp(math.float4(x7, y2, z, w), math.float4(x8, y3, z2, w2), float21.z); float2 float23 = math.lerp(float22.xy, float22.zw, float21.y); float num = math.lerp(float23.x, float23.y, float21.x); return 2.2f * num; } public static float pnoise(float3 P, float3 rep) { float3 float5 = math.fmod(math.floor(P), rep); float3 x = math.fmod(float5 + math.float3(1f), rep); float5 = mod289(float5); x = mod289(x); float3 float6 = math.frac(P); float3 y = float6 - math.float3(1f); float4 x2 = math.float4(float5.x, x.x, float5.x, x.x); float4 float7 = math.float4(float5.yy, x.yy); float4 zzzz = float5.zzzz; float4 zzzz2 = x.zzzz; float4 obj = permute(permute(x2) + float7); float4 float8 = permute(obj + zzzz); float4 obj2 = permute(obj + zzzz2); float4 x3 = float8 * (1f / 7f); float4 x4 = math.frac(math.floor(x3) * (1f / 7f)) - 0.5f; x3 = math.frac(x3); float4 threshold = math.float4(0.5f) - math.abs(x3) - math.abs(x4); float4 float9 = math.step(threshold, math.float4(0f)); x3 -= float9 * (math.step(0f, x3) - 0.5f); x4 -= float9 * (math.step(0f, x4) - 0.5f); float4 x5 = obj2 * (1f / 7f); float4 x6 = math.frac(math.floor(x5) * (1f / 7f)) - 0.5f; x5 = math.frac(x5); float4 threshold2 = math.float4(0.5f) - math.abs(x5) - math.abs(x6); float4 float10 = math.step(threshold2, math.float4(0f)); x5 -= float10 * (math.step(0f, x5) - 0.5f); x6 -= float10 * (math.step(0f, x6) - 0.5f); float3 float11 = math.float3(x3.x, x4.x, threshold.x); float3 float12 = math.float3(x3.y, x4.y, threshold.y); float3 float13 = math.float3(x3.z, x4.z, threshold.z); float3 float14 = math.float3(x3.w, x4.w, threshold.w); float3 float15 = math.float3(x5.x, x6.x, threshold2.x); float3 float16 = math.float3(x5.y, x6.y, threshold2.y); float3 float17 = math.float3(x5.z, x6.z, threshold2.z); float3 float18 = math.float3(x5.w, x6.w, threshold2.w); float4 float19 = taylorInvSqrt(math.float4(math.dot(float11, float11), math.dot(float13, float13), math.dot(float12, float12), math.dot(float14, float14))); float11 *= float19.x; float13 *= float19.y; float12 *= float19.z; float14 *= float19.w; float4 float20 = taylorInvSqrt(math.float4(math.dot(float15, float15), math.dot(float17, float17), math.dot(float16, float16), math.dot(float18, float18))); float15 *= float20.x; float17 *= float20.y; float16 *= float20.z; float18 *= float20.w; float x7 = math.dot(float11, float6); float y2 = math.dot(float12, math.float3(y.x, float6.yz)); float z = math.dot(float13, math.float3(float6.x, y.y, float6.z)); float w = math.dot(float14, math.float3(y.xy, float6.z)); float x8 = math.dot(float15, math.float3(float6.xy, y.z)); float y3 = math.dot(float16, math.float3(y.x, float6.y, y.z)); float z2 = math.dot(float17, math.float3(float6.x, y.yz)); float w2 = math.dot(float18, y); float3 float21 = fade(float6); float4 float22 = math.lerp(math.float4(x7, y2, z, w), math.float4(x8, y3, z2, w2), float21.z); float2 float23 = math.lerp(float22.xy, float22.zw, float21.y); float num = math.lerp(float23.x, float23.y, float21.x); return 2.2f * num; } public static float cnoise(float4 P) { float4 float5 = math.floor(P); float4 x = float5 + 1f; float5 = mod289(float5); x = mod289(x); float4 float6 = math.frac(P); float4 y = float6 - 1f; float4 x2 = math.float4(float5.x, x.x, float5.x, x.x); float4 float7 = math.float4(float5.yy, x.yy); float4 float8 = math.float4(float5.zzzz); float4 float9 = math.float4(x.zzzz); float4 float10 = math.float4(float5.wwww); float4 float11 = math.float4(x.wwww); float4 obj = permute(permute(x2) + float7); float4 float12 = permute(obj + float8); float4 obj2 = permute(obj + float9); float4 float13 = permute(float12 + float10); float4 float14 = permute(float12 + float11); float4 float15 = permute(obj2 + float10); float4 obj3 = permute(obj2 + float11); float4 x3 = float13 * (1f / 7f); float4 x4 = math.floor(x3) * (1f / 7f); float4 x5 = math.floor(x4) * (1f / 6f); x3 = math.frac(x3) - 0.5f; x4 = math.frac(x4) - 0.5f; x5 = math.frac(x5) - 0.5f; float4 threshold = math.float4(0.75f) - math.abs(x3) - math.abs(x4) - math.abs(x5); float4 float16 = math.step(threshold, math.float4(0f)); x3 -= float16 * (math.step(0f, x3) - 0.5f); x4 -= float16 * (math.step(0f, x4) - 0.5f); float4 x6 = float14 * (1f / 7f); float4 x7 = math.floor(x6) * (1f / 7f); float4 x8 = math.floor(x7) * (1f / 6f); x6 = math.frac(x6) - 0.5f; x7 = math.frac(x7) - 0.5f; x8 = math.frac(x8) - 0.5f; float4 threshold2 = math.float4(0.75f) - math.abs(x6) - math.abs(x7) - math.abs(x8); float4 float17 = math.step(threshold2, math.float4(0f)); x6 -= float17 * (math.step(0f, x6) - 0.5f); x7 -= float17 * (math.step(0f, x7) - 0.5f); float4 x9 = float15 * (1f / 7f); float4 x10 = math.floor(x9) * (1f / 7f); float4 x11 = math.floor(x10) * (1f / 6f); x9 = math.frac(x9) - 0.5f; x10 = math.frac(x10) - 0.5f; x11 = math.frac(x11) - 0.5f; float4 threshold3 = math.float4(0.75f) - math.abs(x9) - math.abs(x10) - math.abs(x11); float4 float18 = math.step(threshold3, math.float4(0f)); x9 -= float18 * (math.step(0f, x9) - 0.5f); x10 -= float18 * (math.step(0f, x10) - 0.5f); float4 x12 = obj3 * (1f / 7f); float4 x13 = math.floor(x12) * (1f / 7f); float4 x14 = math.floor(x13) * (1f / 6f); x12 = math.frac(x12) - 0.5f; x13 = math.frac(x13) - 0.5f; x14 = math.frac(x14) - 0.5f; float4 threshold4 = math.float4(0.75f) - math.abs(x12) - math.abs(x13) - math.abs(x14); float4 float19 = math.step(threshold4, math.float4(0f)); x12 -= float19 * (math.step(0f, x12) - 0.5f); x13 -= float19 * (math.step(0f, x13) - 0.5f); float4 float20 = math.float4(x3.x, x4.x, x5.x, threshold.x); float4 float21 = math.float4(x3.y, x4.y, x5.y, threshold.y); float4 float22 = math.float4(x3.z, x4.z, x5.z, threshold.z); float4 float23 = math.float4(x3.w, x4.w, x5.w, threshold.w); float4 float24 = math.float4(x9.x, x10.x, x11.x, threshold3.x); float4 float25 = math.float4(x9.y, x10.y, x11.y, threshold3.y); float4 float26 = math.float4(x9.z, x10.z, x11.z, threshold3.z); float4 float27 = math.float4(x9.w, x10.w, x11.w, threshold3.w); float4 obj4 = math.float4(x6.x, x7.x, x8.x, threshold2.x); float4 float28 = math.float4(x6.y, x7.y, x8.y, threshold2.y); float4 float29 = math.float4(x6.z, x7.z, x8.z, threshold2.z); float4 float30 = math.float4(x6.w, x7.w, x8.w, threshold2.w); float4 float31 = math.float4(x12.x, x13.x, x14.x, threshold4.x); float4 float32 = math.float4(x12.y, x13.y, x14.y, threshold4.y); float4 float33 = math.float4(x12.z, x13.z, x14.z, threshold4.z); float4 float34 = math.float4(x12.w, x13.w, x14.w, threshold4.w); float4 float35 = taylorInvSqrt(math.float4(math.dot(float20, float20), math.dot(float22, float22), math.dot(float21, float21), math.dot(float23, float23))); float20 *= float35.x; float22 *= float35.y; float21 *= float35.z; float23 *= float35.w; float4 float36 = taylorInvSqrt(math.float4(math.dot(obj4, obj4), math.dot(float29, float29), math.dot(float28, float28), math.dot(float30, float30))); float4 x15 = obj4 * float36.x; float29 *= float36.y; float28 *= float36.z; float30 *= float36.w; float4 float37 = taylorInvSqrt(math.float4(math.dot(float24, float24), math.dot(float26, float26), math.dot(float25, float25), math.dot(float27, float27))); float24 *= float37.x; float26 *= float37.y; float25 *= float37.z; float27 *= float37.w; float4 float38 = taylorInvSqrt(math.float4(math.dot(float31, float31), math.dot(float33, float33), math.dot(float32, float32), math.dot(float34, float34))); float31 *= float38.x; float33 *= float38.y; float32 *= float38.z; float34 *= float38.w; float x16 = math.dot(float20, float6); float y2 = math.dot(float21, math.float4(y.x, float6.yzw)); float z = math.dot(float22, math.float4(float6.x, y.y, float6.zw)); float w = math.dot(float23, math.float4(y.xy, float6.zw)); float x17 = math.dot(float24, math.float4(float6.xy, y.z, float6.w)); float y3 = math.dot(float25, math.float4(y.x, float6.y, y.z, float6.w)); float z2 = math.dot(float26, math.float4(float6.x, y.yz, float6.w)); float w2 = math.dot(float27, math.float4(y.xyz, float6.w)); float x18 = math.dot(x15, math.float4(float6.xyz, y.w)); float y4 = math.dot(float28, math.float4(y.x, float6.yz, y.w)); float z3 = math.dot(float29, math.float4(float6.x, y.y, float6.z, y.w)); float w3 = math.dot(float30, math.float4(y.xy, float6.z, y.w)); float x19 = math.dot(float31, math.float4(float6.xy, y.zw)); float y5 = math.dot(float32, math.float4(y.x, float6.y, y.zw)); float z4 = math.dot(float33, math.float4(float6.x, y.yzw)); float w4 = math.dot(float34, y); float4 float39 = fade(float6); float4 start = math.lerp(math.float4(x16, y2, z, w), math.float4(x18, y4, z3, w3), float39.w); float4 end = math.lerp(math.float4(x17, y3, z2, w2), math.float4(x19, y5, z4, w4), float39.w); float4 float40 = math.lerp(start, end, float39.z); float2 float41 = math.lerp(float40.xy, float40.zw, float39.y); float num = math.lerp(float41.x, float41.y, float39.x); return 2.2f * num; } public static float pnoise(float4 P, float4 rep) { float4 float5 = math.fmod(math.floor(P), rep); float4 x = math.fmod(float5 + 1f, rep); float5 = mod289(float5); x = mod289(x); float4 float6 = math.frac(P); float4 y = float6 - 1f; float4 x2 = math.float4(float5.x, x.x, float5.x, x.x); float4 float7 = math.float4(float5.yy, x.yy); float4 float8 = math.float4(float5.zzzz); float4 float9 = math.float4(x.zzzz); float4 float10 = math.float4(float5.wwww); float4 float11 = math.float4(x.wwww); float4 obj = permute(permute(x2) + float7); float4 float12 = permute(obj + float8); float4 obj2 = permute(obj + float9); float4 float13 = permute(float12 + float10); float4 float14 = permute(float12 + float11); float4 float15 = permute(obj2 + float10); float4 obj3 = permute(obj2 + float11); float4 x3 = float13 * (1f / 7f); float4 x4 = math.floor(x3) * (1f / 7f); float4 x5 = math.floor(x4) * (1f / 6f); x3 = math.frac(x3) - 0.5f; x4 = math.frac(x4) - 0.5f; x5 = math.frac(x5) - 0.5f; float4 threshold = math.float4(0.75f) - math.abs(x3) - math.abs(x4) - math.abs(x5); float4 float16 = math.step(threshold, math.float4(0f)); x3 -= float16 * (math.step(0f, x3) - 0.5f); x4 -= float16 * (math.step(0f, x4) - 0.5f); float4 x6 = float14 * (1f / 7f); float4 x7 = math.floor(x6) * (1f / 7f); float4 x8 = math.floor(x7) * (1f / 6f); x6 = math.frac(x6) - 0.5f; x7 = math.frac(x7) - 0.5f; x8 = math.frac(x8) - 0.5f; float4 threshold2 = math.float4(0.75f) - math.abs(x6) - math.abs(x7) - math.abs(x8); float4 float17 = math.step(threshold2, math.float4(0f)); x6 -= float17 * (math.step(0f, x6) - 0.5f); x7 -= float17 * (math.step(0f, x7) - 0.5f); float4 x9 = float15 * (1f / 7f); float4 x10 = math.floor(x9) * (1f / 7f); float4 x11 = math.floor(x10) * (1f / 6f); x9 = math.frac(x9) - 0.5f; x10 = math.frac(x10) - 0.5f; x11 = math.frac(x11) - 0.5f; float4 threshold3 = math.float4(0.75f) - math.abs(x9) - math.abs(x10) - math.abs(x11); float4 float18 = math.step(threshold3, math.float4(0f)); x9 -= float18 * (math.step(0f, x9) - 0.5f); x10 -= float18 * (math.step(0f, x10) - 0.5f); float4 x12 = obj3 * (1f / 7f); float4 x13 = math.floor(x12) * (1f / 7f); float4 x14 = math.floor(x13) * (1f / 6f); x12 = math.frac(x12) - 0.5f; x13 = math.frac(x13) - 0.5f; x14 = math.frac(x14) - 0.5f; float4 threshold4 = math.float4(0.75f) - math.abs(x12) - math.abs(x13) - math.abs(x14); float4 float19 = math.step(threshold4, math.float4(0f)); x12 -= float19 * (math.step(0f, x12) - 0.5f); x13 -= float19 * (math.step(0f, x13) - 0.5f); float4 float20 = math.float4(x3.x, x4.x, x5.x, threshold.x); float4 float21 = math.float4(x3.y, x4.y, x5.y, threshold.y); float4 float22 = math.float4(x3.z, x4.z, x5.z, threshold.z); float4 float23 = math.float4(x3.w, x4.w, x5.w, threshold.w); float4 float24 = math.float4(x9.x, x10.x, x11.x, threshold3.x); float4 float25 = math.float4(x9.y, x10.y, x11.y, threshold3.y); float4 float26 = math.float4(x9.z, x10.z, x11.z, threshold3.z); float4 float27 = math.float4(x9.w, x10.w, x11.w, threshold3.w); float4 obj4 = math.float4(x6.x, x7.x, x8.x, threshold2.x); float4 float28 = math.float4(x6.y, x7.y, x8.y, threshold2.y); float4 float29 = math.float4(x6.z, x7.z, x8.z, threshold2.z); float4 float30 = math.float4(x6.w, x7.w, x8.w, threshold2.w); float4 float31 = math.float4(x12.x, x13.x, x14.x, threshold4.x); float4 float32 = math.float4(x12.y, x13.y, x14.y, threshold4.y); float4 float33 = math.float4(x12.z, x13.z, x14.z, threshold4.z); float4 float34 = math.float4(x12.w, x13.w, x14.w, threshold4.w); float4 float35 = taylorInvSqrt(math.float4(math.dot(float20, float20), math.dot(float22, float22), math.dot(float21, float21), math.dot(float23, float23))); float20 *= float35.x; float22 *= float35.y; float21 *= float35.z; float23 *= float35.w; float4 float36 = taylorInvSqrt(math.float4(math.dot(obj4, obj4), math.dot(float29, float29), math.dot(float28, float28), math.dot(float30, float30))); float4 x15 = obj4 * float36.x; float29 *= float36.y; float28 *= float36.z; float30 *= float36.w; float4 float37 = taylorInvSqrt(math.float4(math.dot(float24, float24), math.dot(float26, float26), math.dot(float25, float25), math.dot(float27, float27))); float24 *= float37.x; float26 *= float37.y; float25 *= float37.z; float27 *= float37.w; float4 float38 = taylorInvSqrt(math.float4(math.dot(float31, float31), math.dot(float33, float33), math.dot(float32, float32), math.dot(float34, float34))); float31 *= float38.x; float33 *= float38.y; float32 *= float38.z; float34 *= float38.w; float x16 = math.dot(float20, float6); float y2 = math.dot(float21, math.float4(y.x, float6.yzw)); float z = math.dot(float22, math.float4(float6.x, y.y, float6.zw)); float w = math.dot(float23, math.float4(y.xy, float6.zw)); float x17 = math.dot(float24, math.float4(float6.xy, y.z, float6.w)); float y3 = math.dot(float25, math.float4(y.x, float6.y, y.z, float6.w)); float z2 = math.dot(float26, math.float4(float6.x, y.yz, float6.w)); float w2 = math.dot(float27, math.float4(y.xyz, float6.w)); float x18 = math.dot(x15, math.float4(float6.xyz, y.w)); float y4 = math.dot(float28, math.float4(y.x, float6.yz, y.w)); float z3 = math.dot(float29, math.float4(float6.x, y.y, float6.z, y.w)); float w3 = math.dot(float30, math.float4(y.xy, float6.z, y.w)); float x19 = math.dot(float31, math.float4(float6.xy, y.zw)); float y5 = math.dot(float32, math.float4(y.x, float6.y, y.zw)); float z4 = math.dot(float33, math.float4(float6.x, y.yzw)); float w4 = math.dot(float34, y); float4 float39 = fade(float6); float4 start = math.lerp(math.float4(x16, y2, z, w), math.float4(x18, y4, z3, w3), float39.w); float4 end = math.lerp(math.float4(x17, y3, z2, w2), math.float4(x19, y5, z4, w4), float39.w); float4 float40 = math.lerp(start, end, float39.z); float2 float41 = math.lerp(float40.xy, float40.zw, float39.y); float num = math.lerp(float41.x, float41.y, float39.x); return 2.2f * num; } private static float mod289(float x) { return x - math.floor(x * 0.0034602077f) * 289f; } private static float2 mod289(float2 x) { return x - math.floor(x * 0.0034602077f) * 289f; } private static float3 mod289(float3 x) { return x - m
plugins/EinsteinCrew-PuckosCarePackage/Pucko-NordVPO/VPOBurst_Managed.dll
Decompiled 2 weeks agousing System; using System.CodeDom.Compiler; using System.ComponentModel; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using AOT; using Unity.Burst; using Unity.Collections; using Unity.Jobs; using Unity.Mathematics; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [CompilerGenerated] [EditorBrowsable(EditorBrowsableState.Never)] [GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)] internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1 { private struct MonoScriptData { public byte[] FilePathsData; public byte[] TypesData; public int TotalTypes; public int TotalFiles; public bool IsEditorOnly; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static MonoScriptData Get() { return new MonoScriptData { FilePathsData = new byte[198] { 0, 0, 0, 3, 0, 0, 0, 37, 92, 65, 115, 115, 101, 116, 115, 92, 86, 80, 79, 66, 117, 114, 115, 116, 92, 67, 97, 108, 99, 117, 108, 97, 116, 101, 87, 97, 118, 101, 115, 74, 111, 98, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 48, 92, 65, 115, 115, 101, 116, 115, 92, 86, 80, 79, 66, 117, 114, 115, 116, 92, 71, 101, 110, 101, 114, 97, 116, 101, 67, 111, 108, 108, 105, 115, 105, 111, 110, 86, 101, 114, 116, 105, 99, 101, 115, 74, 111, 98, 46, 99, 115, 0, 0, 0, 2, 0, 0, 0, 37, 92, 65, 115, 115, 101, 116, 115, 92, 86, 80, 79, 66, 117, 114, 115, 116, 92, 71, 101, 110, 101, 114, 97, 116, 101, 67, 111, 108, 111, 114, 115, 74, 111, 98, 46, 99, 115, 0, 0, 0, 1, 0, 0, 0, 44, 92, 65, 115, 115, 101, 116, 115, 92, 86, 80, 79, 66, 117, 114, 115, 116, 92, 71, 101, 110, 101, 114, 97, 116, 101, 68, 105, 115, 116, 97, 110, 116, 67, 111, 108, 111, 114, 115, 74, 111, 98, 46, 99, 115 }, TypesData = new byte[265] { 0, 0, 0, 0, 24, 86, 80, 79, 66, 117, 114, 115, 116, 124, 87, 97, 118, 101, 82, 101, 113, 117, 101, 115, 116, 68, 97, 116, 97, 0, 0, 0, 0, 19, 86, 80, 79, 66, 117, 114, 115, 116, 124, 87, 97, 116, 101, 114, 87, 97, 118, 101, 115, 0, 0, 0, 0, 26, 86, 80, 79, 66, 117, 114, 115, 116, 124, 67, 97, 108, 99, 117, 108, 97, 116, 101, 87, 97, 118, 101, 115, 74, 111, 98, 0, 0, 0, 0, 37, 86, 80, 79, 66, 117, 114, 115, 116, 124, 71, 101, 110, 101, 114, 97, 116, 101, 67, 111, 108, 108, 105, 115, 105, 111, 110, 86, 101, 114, 116, 105, 99, 101, 115, 74, 111, 98, 0, 0, 0, 0, 36, 86, 80, 79, 66, 117, 114, 115, 116, 124, 71, 101, 110, 101, 114, 97, 116, 101, 67, 111, 108, 108, 105, 115, 105, 111, 110, 73, 110, 100, 105, 99, 101, 115, 74, 111, 98, 0, 0, 0, 0, 26, 86, 80, 79, 66, 117, 114, 115, 116, 124, 71, 101, 110, 101, 114, 97, 116, 101, 67, 111, 108, 111, 114, 115, 74, 111, 98, 0, 0, 0, 0, 24, 86, 80, 79, 66, 117, 114, 115, 116, 124, 67, 104, 101, 99, 107, 66, 117, 114, 115, 116, 101, 100, 74, 111, 98, 0, 0, 0, 0, 33, 86, 80, 79, 66, 117, 114, 115, 116, 124, 71, 101, 110, 101, 114, 97, 116, 101, 68, 105, 115, 116, 97, 110, 116, 67, 111, 108, 111, 114, 115, 74, 111, 98 }, TotalFiles = 4, TotalTypes = 8, IsEditorOnly = false }; } } namespace VPOBurst; public struct WaveRequestData { public Vector3 Position; public float Depth; public float HeightOffset; public float WaveFactorBig; public Vector4 Wind; public Vector4 Wind2; public float WindBlend; public bool UseGlobalWind; } [BurstCompile] public static class WaterWaves { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate float CalcWave_00000003$PostfixBurstDelegate(in float3 worldPos, float depth, in float4 wind, float waterTime, float waveFactor, float waveFactorBig); internal static class CalcWave_00000003$BurstDirectCall { private static IntPtr Pointer; [BurstDiscard] private static void GetFunctionPointerDiscard(ref IntPtr P_0) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (Pointer == (IntPtr)0) { Pointer = BurstCompiler.CompileFunctionPointer<CalcWave_00000003$PostfixBurstDelegate>((CalcWave_00000003$PostfixBurstDelegate)CalcWave).Value; } P_0 = Pointer; } private static IntPtr GetFunctionPointer() { nint result = 0; GetFunctionPointerDiscard(ref result); return result; } public unsafe static float Invoke(in float3 worldPos, float depth, in float4 wind, float waterTime, float waveFactor, float waveFactorBig) { if (BurstCompiler.IsEnabled) { IntPtr functionPointer = GetFunctionPointer(); if (functionPointer != (IntPtr)0) { return ((delegate* unmanaged[Cdecl]<ref float3, float, ref float4, float, float, float, float>)functionPointer)(ref worldPos, depth, ref wind, waterTime, waveFactor, waveFactorBig); } } return CalcWave$BurstManaged(in worldPos, depth, in wind, waterTime, waveFactor, waveFactorBig); } } [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate float CalcWaveBlended_00000004$PostfixBurstDelegate(in float3 worldPos, float depth, in float4 wind1, in float4 wind2, float windBlend, float waterTime, float waveFactor, float waveFactorBig); internal static class CalcWaveBlended_00000004$BurstDirectCall { private static IntPtr Pointer; [BurstDiscard] private static void GetFunctionPointerDiscard(ref IntPtr P_0) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (Pointer == (IntPtr)0) { Pointer = BurstCompiler.CompileFunctionPointer<CalcWaveBlended_00000004$PostfixBurstDelegate>((CalcWaveBlended_00000004$PostfixBurstDelegate)CalcWaveBlended).Value; } P_0 = Pointer; } private static IntPtr GetFunctionPointer() { nint result = 0; GetFunctionPointerDiscard(ref result); return result; } public unsafe static float Invoke(in float3 worldPos, float depth, in float4 wind1, in float4 wind2, float windBlend, float waterTime, float waveFactor, float waveFactorBig) { if (BurstCompiler.IsEnabled) { IntPtr functionPointer = GetFunctionPointer(); if (functionPointer != (IntPtr)0) { return ((delegate* unmanaged[Cdecl]<ref float3, float, ref float4, ref float4, float, float, float, float, float>)functionPointer)(ref worldPos, depth, ref wind1, ref wind2, windBlend, waterTime, waveFactor, waveFactorBig); } } return CalcWaveBlended$BurstManaged(in worldPos, depth, in wind1, in wind2, windBlend, waterTime, waveFactor, waveFactorBig); } } private static readonly float2 Dir1 = math.normalize(new float2(1.0312f, 0.312f)); private static readonly float2 Tan1 = new float2(0f - Dir1.y, Dir1.x); private static readonly float2 Dir2 = math.normalize(new float2(-0.123f, 1.12f)); private static readonly float2 Tan2 = new float2(0f - Dir2.y, Dir2.x); private static readonly float2 Dir3 = math.normalize(new float2(0.423f, 0.124f)); private static readonly float2 Tan3 = new float2(0f - Dir3.y, Dir3.x); private static readonly float2 Dir4 = math.normalize(new float2(0.123f, -0.64f)); private static readonly float2 Tan4 = new float2(0f - Dir4.y, Dir4.x); private static readonly float2 Dir5 = math.normalize(new float2(-0.523f, -0.64f)); private static readonly float2 Tan5 = new float2(0f - Dir5.y, Dir5.x); private static readonly float2 Dir6 = math.normalize(new float2(0.223f, 0.74f)); private static readonly float2 Tan6 = new float2(0f - Dir6.y, Dir6.x); private static readonly float2 Dir7 = math.normalize(new float2(0.923f, -0.24f)); private static readonly float2 Tan7 = new float2(0f - Dir7.y, Dir7.x); private static readonly float2 Dir8 = math.normalize(new float2(-0.323f, 0.44f)); private static readonly float2 Tan8 = new float2(0f - Dir8.y, Dir8.x); private static readonly float2 Dir9 = math.normalize(new float2(0.5312f, -0.812f)); private static readonly float2 Tan9 = new float2(0f - Dir9.y, Dir9.x); [BurstCompile] [MonoPInvokeCallback(typeof(VPOBurst.CalcWave_00000003$PostfixBurstDelegate))] public static float CalcWave(in float3 worldPos, float depth, in float4 wind, float waterTime, float waveFactor, float waveFactorBig) { return CalcWave_00000003$BurstDirectCall.Invoke(in worldPos, depth, in wind, waterTime, waveFactor, waveFactorBig); } [BurstCompile] [MonoPInvokeCallback(typeof(VPOBurst.CalcWaveBlended_00000004$PostfixBurstDelegate))] public static float CalcWaveBlended(in float3 worldPos, float depth, in float4 wind1, in float4 wind2, float windBlend, float waterTime, float waveFactor, float waveFactorBig) { return CalcWaveBlended_00000004$BurstDirectCall.Invoke(in worldPos, depth, in wind1, in wind2, windBlend, waterTime, waveFactor, waveFactorBig); } private static float CreateWave(in float3 worldPos, float time, float waveSpeed, float waveLength, float waveHeight, float2 dir, float2 tangent, float sharpness) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) float2 val = -(worldPos.z * dir + worldPos.x * tangent); float num = time * waveSpeed; return (TrochSin(num + val.y * waveLength, sharpness) * TrochSin(num * 0.123f + val.x * 0.13123f * waveLength, sharpness) - 0.2f) * waveHeight; } private static float TrochSin(float x, float k) { return math.sin(x - math.cos(x) * k) * 0.5f + 0.5f; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [BurstCompile] internal static float CalcWave$BurstManaged(in float3 worldPos, float depth, in float4 wind, float waterTime, float waveFactor, float waveFactorBig) { //IL_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: 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) float2 val = math.normalize(new float2(wind.x, wind.z)); float2 tangent = default(float2); ((float2)(ref tangent))..ctor(0f - val.y, val.x); float num = math.lerp(0f, wind.w, math.saturate(depth)); float time = waterTime / 20f; float num2 = CreateWave(in worldPos, time, 10f, 0.04f, 8f * waveFactorBig, val, tangent, 0.5f) + CreateWave(in worldPos, time, 14.123f, 0.08f, 6f * waveFactorBig, Dir1, Tan1, 0.5f) + CreateWave(in worldPos, time, 22.312f, 0.1f, 4f * waveFactorBig, Dir2, Tan2, 0.5f) + CreateWave(in worldPos, time, 31.42f, 0.2f, 2f * waveFactorBig, Dir3, Tan3, 0.5f) + CreateWave(in worldPos, time, 35.42f, 0.4f, 1f * waveFactorBig, Dir4, Tan4, 0.5f) + CreateWave(in worldPos, time, 38.1223f, 1f, 0.8f * waveFactorBig, Dir5, Tan5, 0.7f) + CreateWave(in worldPos, time, 41.1223f, 1.2f, 0.6f * waveFactor, Dir6, Tan6, 0.8f) + CreateWave(in worldPos, time, 51.5123f, 1.3f, 0.4f * waveFactor, Dir7, Tan7, 0.9f) + CreateWave(in worldPos, time, 54.2f, 1.3f, 0.3f * waveFactor, Dir8, Tan8, 0.9f) + CreateWave(in worldPos, time, 56.123f, 1.5f, 0.2f * waveFactor, Dir9, Tan9, 0.9f); return num2 * num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [BurstCompile] internal static float CalcWaveBlended$BurstManaged(in float3 worldPos, float depth, in float4 wind1, in float4 wind2, float windBlend, float waterTime, float waveFactor, float waveFactorBig) { if (depth == 0f) { return 0f; } if (windBlend == 0f) { return CalcWave(in worldPos, depth, in wind1, waterTime, waveFactor, waveFactorBig); } float num = CalcWave(in worldPos, depth, in wind1, waterTime, waveFactor, waveFactorBig); float num2 = CalcWave(in worldPos, depth, in wind2, waterTime, waveFactor, waveFactorBig); return math.lerp(num, num2, windBlend); } } [BurstCompile] public struct CalculateWavesJob : IJobParallelFor { [ReadOnly] public NativeArray<WaveRequestData> WaveRequests; [ReadOnly] public float Time; [WriteOnly] public NativeArray<float> Results; public void Execute(int index) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) WaveRequestData waveRequestData = WaveRequests[index]; float num = 0f; if (waveRequestData.UseGlobalWind && waveRequestData.Depth != 0f) { float3 worldPos = float3.op_Implicit(waveRequestData.Position); float4 wind = float4.op_Implicit(waveRequestData.Wind); float4 wind2 = float4.op_Implicit(waveRequestData.Wind2); num = WaterWaves.CalcWaveBlended(in worldPos, waveRequestData.Depth, in wind, in wind2, waveRequestData.WindBlend, Time, 1f, waveRequestData.WaveFactorBig); } Results[index] = waveRequestData.HeightOffset + num; } } [BurstCompile] public struct GenerateCollisionVerticesJob : IJob { [ReadOnly] public int Width; [ReadOnly] public float Scale; [ReadOnly] public NativeArray<float> Heights; [WriteOnly] public NativeArray<Vector3> Verts; [WriteOnly] public NativeArray<float> MinMax; public void Execute() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) int num = Width + 1; float num2 = (float)Width * Scale * -0.5f; float num3 = float.MaxValue; float num4 = float.MinValue; for (int i = 0; i < Verts.Length; i++) { int num5 = i / num; int num6 = i % num; float num7 = Heights[num5 * num + num6]; Verts[i] = new Vector3(num2 + (float)num6 * Scale, num7, num2 + (float)num5 * Scale); num3 = math.min(num3, num7); num4 = math.max(num4, num7); } MinMax[0] = num3; MinMax[1] = num4; } } [BurstCompile] public struct GenerateCollisionIndicesJob : IJobParallelFor { [ReadOnly] public int Width; [WriteOnly] public NativeArray<int> Indices; public void Execute(int quadIndex) { int num = quadIndex / Width; int num2 = quadIndex % Width; int num3 = Width + 1; int num4 = num * num3 + num2; int num5 = num4 + 1; int num6 = num4 + num3 + 1; int num7 = num4 + num3; int num8 = quadIndex * 6; Indices[num8] = num4; Indices[num8 + 1] = num7; Indices[num8 + 2] = num5; Indices[num8 + 3] = num5; Indices[num8 + 4] = num7; Indices[num8 + 5] = num6; } } [BurstCompile] public struct GenerateColorsJob : IJobParallelFor { [ReadOnly] public int Width; [ReadOnly] [DeallocateOnJobCompletion] public NativeArray<Color32> CornerColors; [WriteOnly] public NativeArray<Color32> Colors; public void Execute(int index) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) int num = Width + 1; float num2 = math.floor((float)index / (float)num); int num3 = index % num; float iy = math.smoothstep(0f, 1f, num2 / (float)Width); float ix = math.smoothstep(0f, 1f, (float)num3 / (float)Width); Colors[index] = GetBiomeColor(ix, iy); } private Color32 GetBiomeColor(float ix, float iy) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_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) //IL_0042: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Color32 val = Color32.Lerp(CornerColors[0], CornerColors[1], ix); Color32 val2 = Color32.Lerp(CornerColors[2], CornerColors[3], ix); return Color32.Lerp(val, val2, iy); } } [BurstCompile] public struct CheckBurstedJob : IJob { public NativeArray<int> Flag; [BurstDiscard] private void MarkNotBursted() { Flag[0] = 0; } public void Execute() { Flag[0] = 1; MarkNotBursted(); } } [BurstCompile] public struct GenerateDistantColorsJob : IJobParallelFor { [ReadOnly] public int Width; [ReadOnly] public float Scale; [ReadOnly] public float StartX; [ReadOnly] public float StartZ; [ReadOnly] public int MapSize; [ReadOnly] public NativeArray<byte> BiomeMap; [WriteOnly] public NativeArray<Color32> Colors; public void Execute(int index) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) int num = Width + 1; int num2 = index / num; int num3 = index % num; float num4 = StartX + (float)num3 * Scale; float num5 = StartZ + (float)num2 * Scale; int num6 = (int)((num4 - 6f) / 12f + 1024f); int num7 = (int)((num5 - 6f) / 12f + 1024f); if (num6 < 0) { num6 = 0; } else if (num6 >= MapSize) { num6 = MapSize - 1; } if (num7 < 0) { num7 = 0; } else if (num7 >= MapSize) { num7 = MapSize - 1; } Colors[index] = GetBiomeColor(BiomeMap[num7 * MapSize + num6]); } private static Color32 GetBiomeColor(byte biome) { //IL_0037: 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_0047: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00bb: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color32 result = (Color32)(biome switch { 2 => new Color32(byte.MaxValue, (byte)0, (byte)0, (byte)0), 3 => new Color32((byte)0, byte.MaxValue, (byte)0, (byte)0), 4 => new Color32((byte)0, (byte)0, byte.MaxValue, (byte)0), 5 => new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue), 6 => new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue), 7 => new Color32((byte)0, byte.MaxValue, (byte)0, (byte)0), 9 => new Color32((byte)0, (byte)0, byte.MaxValue, byte.MaxValue), _ => new Color32((byte)0, (byte)0, (byte)0, (byte)0), }); if (1 == 0) { } return result; } } internal static class $BurstDirectCallInitializer { [RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)] private static void Initialize() { BurstCompilerOptions options = BurstCompiler.Options; } }
plugins/EinsteinCrew-PuckosCarePackage/Pucko-QuickStack/QuickStack.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace QuickStack; internal static class Locks { internal const string Key = "pucko.quickstack.lock"; internal static bool IsLocked(ItemData it) { if (it != null && it.m_customData != null) { return it.m_customData.ContainsKey("pucko.quickstack.lock"); } return false; } internal static bool Toggle(ItemData it) { if (it.m_customData == null) { it.m_customData = new Dictionary<string, string>(); } if (it.m_customData.Remove("pucko.quickstack.lock")) { return false; } it.m_customData["pucko.quickstack.lock"] = "1"; return true; } } internal static class LockMarkers { private const string MarkerName = "QuickStackLock"; private static readonly FieldInfo Elements = AccessTools.Field(typeof(InventoryGrid), "m_elements"); private static readonly FieldInfo GridInventory = AccessTools.Field(typeof(InventoryGrid), "m_inventory"); private static readonly FieldInfo GridWidth = AccessTools.Field(typeof(InventoryGrid), "m_width"); private static Sprite _sprite; private static readonly string[] Bitmap = new string[11] { "...#####...", "..##...##..", "..#.....#..", "..#.....#..", ".#########.", ".#########.", ".####.####.", ".###...###.", ".####.####.", ".#########.", ".#########." }; private static Sprite GetSprite() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_01b7: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_sprite != (Object)null) { return _sprite; } int num = Bitmap[0].Length + 2; int num2 = Bitmap.Length + 2; Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)0; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.97f, 0.8f, 0.28f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0f, 0f, 0f, 0.95f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0f, 0f, 0f, 0f); bool[,] array = new bool[num, num2]; for (int i = 0; i < Bitmap.Length; i++) { for (int j = 0; j < Bitmap[i].Length; j++) { array[j + 1, num2 - 2 - i] = Bitmap[i][j] == '#'; } } for (int k = 0; k < num2; k++) { for (int l = 0; l < num; l++) { if (array[l, k]) { val.SetPixel(l, k, val2); continue; } bool flag = false; for (int m = -1; m <= 1; m++) { if (flag) { break; } for (int n = -1; n <= 1; n++) { int num3 = l + n; int num4 = k + m; if (num3 >= 0 && num4 >= 0 && num3 < num && num4 < num2 && array[num3, num4]) { flag = true; break; } } } val.SetPixel(l, k, flag ? val3 : val4); } } val.Apply(); _sprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f), 100f); return _sprite; } internal static void RefreshAll() { InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_playerGrid == (Object)null)) { Refresh(instance.m_playerGrid); } } internal static void Refresh(InventoryGrid grid) { try { Player localPlayer = Player.m_localPlayer; object? value = GridInventory.GetValue(grid); Inventory val = (Inventory)((value is Inventory) ? value : null); if (!(Elements.GetValue(grid) is List<InventoryElement> list)) { return; } bool flag = (Object)(object)localPlayer != (Object)null && val != null && val == ((Humanoid)localPlayer).GetInventory() && Plugin.LockEnabled.Value && Plugin.ShowLockMarker.Value; int num = (int)GridWidth.GetValue(grid); if (num < 1) { return; } for (int i = 0; i < list.Count; i++) { InventoryElement val2 = list[i]; if (!((Object)(object)val2 == (Object)null)) { bool flag2 = false; if (flag) { flag2 = Locks.IsLocked(val.GetItemAt(i % num, i / num)); } SetMarker(((Component)val2).transform, flag2); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Lock markers: " + ex.Message)); } } private static void SetMarker(Transform cell, bool on) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) Transform val = cell.Find("QuickStackLock"); if (!on) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } return; } if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("QuickStackLock", new Type[2] { typeof(RectTransform), typeof(Image) }); val2.transform.SetParent(cell, false); RectTransform val3 = (RectTransform)val2.transform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(1f, 1f); val3.anchorMax = val4; val3.anchorMin = val4; val3.pivot = new Vector2(1f, 1f); val3.anchoredPosition = new Vector2(-2f, -2f); val3.sizeDelta = new Vector2(13f, 15f); Image component = val2.GetComponent<Image>(); component.sprite = GetSprite(); ((Graphic)component).raycastTarget = false; val = val2.transform; } val.SetAsLastSibling(); ((Component)val).gameObject.SetActive(true); } } internal static class Logic { public static List<string> ParseList(string s) { List<string> list = new List<string>(); if (string.IsNullOrWhiteSpace(s)) { return list; } string[] array = s.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { list.Add(text); } } return list; } public static bool Matches(IList<string> patterns, params string[] names) { if (patterns == null || patterns.Count == 0) { return false; } foreach (string text in names) { if (string.IsNullOrEmpty(text)) { continue; } foreach (string pattern in patterns) { if (text.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } } return false; } public static List<int> MergeStacks(IList<int> stacks, int maxStack) { List<int> list = new List<int>(); if (stacks == null || stacks.Count == 0) { return list; } long num = 0L; foreach (int stack in stacks) { num += Math.Max(0, stack); } if (maxStack < 1) { maxStack = 1; } while (num > 0) { int num2 = (int)Math.Min(num, maxStack); list.Add(num2); num -= num2; } return list; } public static List<int> FreeCells(int width, int firstRow, int endRow, ISet<int> occupied) { List<int> list = new List<int>(); for (int i = firstRow; i < endRow; i++) { for (int j = 0; j < width; j++) { int item = i * width + j; if (occupied == null || !occupied.Contains(item)) { list.Add(item); } } } return list; } public static int Category(string itemType) { switch (itemType) { case "OneHandedWeapon": case "TwoHandedWeapon": case "Torch": case "Attach_Atgeir": case "TwoHandedWeaponLeft": case "Bow": return 0; case "Shield": return 1; case "Chest": case "Hands": case "Customization": case "Helmet": case "Legs": case "Shoulder": case "Trinket": case "Utility": return 2; case "Tool": return 3; case "Ammo": case "AmmoNonEquipable": return 4; case "Consumable": return 5; case "Fish": return 6; case "Material": return 7; case "Trophy": return 8; default: return 9; } } public static string Plural(int n, string one, string many) { if (n != 1) { return many; } return one; } public static string Summary(float radius, int found, int moved, int hit, int refused, int silent, int locked, bool single = false) { string text = ((found == 0) ? ("No chests within " + radius.ToString("0.#") + " m") : (single ? ((moved > 0) ? ("Quick stacked " + moved + Plural(moved, " item", " items") + " into this chest") : "Nothing to stack in this chest") : ((moved <= 0) ? "Nothing to stack nearby" : ("Quick stacked " + moved + Plural(moved, " item", " items") + " into " + hit + Plural(hit, " chest", " chests"))))); int num = locked + refused; if (num > 0) { text = text + " (" + num + " locked)"; } if (silent > 0) { text = text + " (" + silent + " did not answer)"; } return text; } } [HarmonyPatch(typeof(Inventory), "StackAll")] internal static class Inventory_StackAll { internal class St { public int Before; public bool Ours; public List<ItemData> Held; public List<ItemData> List; } private static readonly MethodInfo ChangedMethod = AccessTools.Method(typeof(Inventory), "Changed", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null); private static void Prefix(Inventory __0, ref bool __1, out St __state) { __state = new St(); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || __0 != ((Humanoid)localPlayer).GetInventory()) { return; } bool active = Stacker.Active; __state.Ours = active; if (active) { __1 = false; } List<ItemData> list = Stacker.InvList.GetValue(__0) as List<ItemData>; if (list != null) { bool flag = active && Plugin.SkipHotbar.Value; List<ItemData> list2 = new List<ItemData>(); foreach (ItemData item in list) { if ((Plugin.LockEnabled.Value && Locks.IsLocked(item)) || (flag && item.m_gridPos.y == 0)) { list2.Add(item); } } if (list2.Count > 0) { foreach (ItemData item2 in list2) { list.Remove(item2); } __state.Held = list2; __state.List = list; } } if (active) { __state.Before = CountItems(list); } } private static int CountItems(List<ItemData> list) { int num = 0; if (list != null) { foreach (ItemData item in list) { num += item.m_stack; } } return num; } private static void Postfix(St __state, Inventory __0) { if (__state != null && __state.Ours) { List<ItemData> list = Stacker.InvList.GetValue(__0) as List<ItemData>; Stacker.OnMoved(__state.Before - CountItems(list)); } } private static Exception Finalizer(Inventory __0, Exception __exception, St __state) { if (__state != null && __state.Held != null && __state.List != null) { __state.List.AddRange(__state.Held); try { if (ChangedMethod != null) { ChangedMethod.Invoke(__0, new object[2] { false, false }); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not refresh the inventory after stacking: " + ex.Message)); } } return __exception; } } [HarmonyPatch(typeof(Container), "RPC_StackResponse")] internal static class Container_RPC_StackResponse { private static bool Prefix(bool __1) { if (!Stacker.Active) { return true; } if (__1) { return true; } Stacker.OnResponse(granted: false); return false; } private static void Postfix(bool __1) { if (Stacker.Active && __1) { Stacker.OnResponse(granted: true); } } } [HarmonyPatch(typeof(InventoryGui), "Awake")] internal static class InventoryGui_Awake { private static void Postfix(InventoryGui __instance) { try { QuickButton.Create(__instance); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not create the Quick Stack button: " + ex)); } } } [HarmonyPatch(typeof(InventoryGui), "Show")] internal static class InventoryGui_Show { private static void Postfix() { QuickButton.Apply(); } } [HarmonyPatch(typeof(InventoryGui), "OnSelectedItem")] internal static class InventoryGui_OnSelectedItem { private static readonly FieldInfo DragItem = AccessTools.Field(typeof(InventoryGui), "m_dragItem"); private static bool Prefix(InventoryGui __instance, InventoryGrid __0, ItemData __1, Modifier __3) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.LockEnabled.Value || __1 == null) { return true; } if ((int)__3 != 0) { return true; } if (!Input.GetKey(Plugin.LockKey.Value)) { return true; } if ((Object)(object)__0 != (Object)(object)__instance.m_playerGrid) { return true; } if (DragItem != null && DragItem.GetValue(__instance) != null) { return true; } bool flag = Locks.Toggle(__1); LockMarkers.Refresh(__0); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && Plugin.ShowMessage.Value) { ((Character)localPlayer).Message((MessageType)1, (flag ? "Locked: " : "Unlocked: ") + Localization.instance.Localize(__1.m_shared.m_name), 0, (Sprite)null, false); } return false; } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui")] internal static class InventoryGrid_UpdateGui { private static void Postfix(InventoryGrid __instance) { LockMarkers.Refresh(__instance); } } [BepInPlugin("pucko.quickstack", "QuickStack", "0.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "pucko.quickstack"; public const string Name = "QuickStack"; public const string Version = "0.4.0"; internal static ManualLogSource Log; internal static ConfigEntry<float> Radius; internal static ConfigEntry<float> MaxRadius; internal static ConfigEntry<KeyboardShortcut> Hotkey; internal static ConfigEntry<bool> ShowMessage; internal static ConfigEntry<bool> HotkeyOpenChestOnly; internal static ConfigEntry<bool> SortHotkeyOpenChest; internal static ConfigEntry<bool> ShowChestSortButton; internal static ConfigEntry<Vector2> ChestSortNudge; internal static ConfigEntry<bool> SkipHotbar; internal static ConfigEntry<bool> IncludeVehicles; internal static ConfigEntry<string> Excluded; internal static ConfigEntry<bool> ShowButton; internal static ConfigEntry<string> ButtonLabel; internal static ConfigEntry<Vector2> ButtonOffset; internal static ConfigEntry<float> ButtonSize; internal static ConfigEntry<string> TextColor; internal static ConfigEntry<bool> ShowSortButton; internal static ConfigEntry<string> SortText; internal static ConfigEntry<KeyboardShortcut> SortHotkey; internal static ConfigEntry<bool> SortHotbar; internal static ConfigEntry<bool> LockEnabled; internal static ConfigEntry<KeyCode> LockKey; internal static ConfigEntry<bool> ShowLockMarker; private Harmony _harmony; private bool _headless; internal static float EffectiveRadius => Mathf.Min(Radius.Value, MaxRadius.Value); private static ConfigurationManagerAttributes AdminTag() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true }; } public static void BindSettings(ConfigFile Config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) Radius = Config.Bind<float>("1 General", "Radius", 7.5f, new ConfigDescription("Chests within this many metres of you are stacked into. Your own choice, but never more than the server's MaxRadius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), Array.Empty<object>())); MaxRadius = Config.Bind<float>("1 General", "MaxRadius", 5f, new ConfigDescription("Set by the server: the largest radius anyone may use (metres). The radius used is the smaller of Radius and this.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1] { AdminTag() })); Hotkey = Config.Bind<KeyboardShortcut>("1 General", "Hotkey", KeyboardShortcut.Empty, "Quick stack from anywhere in the world (inventory open or not). Unbound by default."); ShowMessage = Config.Bind<bool>("1 General", "ShowMessage", true, "Show a summary message after each quick stack."); HotkeyOpenChestOnly = Config.Bind<bool>("1 General", "HotkeyOpenChestOnly", true, "With a chest open, the stack hotkey stacks only into that chest. (The inventory button always stacks into every chest in range.)"); SkipHotbar = Config.Bind<bool>("2 Filters", "SkipHotbar", true, "Never move items from the top (hotbar) row of your inventory. Equipped items and EquipmentAndQuickSlots slots are always kept, same as the game's Place Stacks."); IncludeVehicles = Config.Bind<bool>("2 Filters", "IncludeVehicles", false, new ConfigDescription("Set by the server: also stack into carts and ship cargo chests.", (AcceptableValueBase)null, new object[1] { AdminTag() })); Excluded = Config.Bind<string>("2 Filters", "ExcludedContainers", "", new ConfigDescription("Set by the server: comma-separated names to skip (case-insensitive part of the container's prefab or display name), e.g. \"reinforced, private\". Gravestones are always skipped.", (AcceptableValueBase)null, new object[1] { AdminTag() })); ShowButton = Config.Bind<bool>("3 Button", "ShowButton", true, "Show the Quick Stack button in the inventory."); ButtonLabel = Config.Bind<string>("3 Button", "Text", "QS", "Button text."); ButtonOffset = Config.Bind<Vector2>("3 Button", "Nudge", new Vector2(0f, 10f), "Move the button from its default spot (the middle between the armor and weight readouts). x right, y up, in pixels. Applies live (F1)."); ButtonSize = Config.Bind<float>("3 Button", "Size", 44f, new ConfigDescription("Width and height of the square button, in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 100f), Array.Empty<object>())); TextColor = Config.Bind<string>("3 Button", "TextColor", "", "Button text colour as #RRGGBB. Empty = the same yellow the game uses for the armor and weight numbers."); ShowSortButton = Config.Bind<bool>("4 Sort", "ShowSortButton", true, "Show the Sort button under the Quick Stack button."); SortText = Config.Bind<string>("4 Sort", "Text", "SORT", "Sort button text."); SortHotkey = Config.Bind<KeyboardShortcut>("4 Sort", "Hotkey", KeyboardShortcut.Empty, "Sort the inventory from anywhere in the world. Unbound by default."); SortHotbar = Config.Bind<bool>("4 Sort", "SortHotbar", false, "Also sort the top (hotbar) row. Off = the hotbar stays exactly as you set it."); SortHotkeyOpenChest = Config.Bind<bool>("4 Sort", "HotkeySortsOpenChest", true, "With a chest open, the sort hotkey sorts that chest instead of your inventory."); ShowChestSortButton = Config.Bind<bool>("4 Sort", "ShowChestSortButton", true, "Show a Sort button in the chest window, next to Place Stacks."); ChestSortNudge = Config.Bind<Vector2>("4 Sort", "ChestSortNudge", Vector2.zero, "Move the chest Sort button from its default spot (right of Place Stacks). x right, y up, pixels. Applies live (F1)."); LockEnabled = Config.Bind<bool>("5 Lock", "Enabled", true, "Hold the lock key and click an item in your inventory to lock it. Locked items are skipped by Quick Stack, Sort and the game's own Place Stacks."); LockKey = Config.Bind<KeyCode>("5 Lock", "LockKey", (KeyCode)308, "Key to hold while clicking (Mouse 1) to lock or unlock an item."); ShowLockMarker = Config.Bind<bool>("5 Lock", "ShowMarker", true, "Show a small padlock on locked items."); } private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _headless = (int)SystemInfo.graphicsDeviceType == 4; BindSettings(((BaseUnityPlugin)this).Config); ShowButton.SettingChanged += delegate { QuickButton.Apply(); }; ButtonLabel.SettingChanged += delegate { QuickButton.Apply(); }; ButtonOffset.SettingChanged += delegate { QuickButton.Apply(); }; ButtonSize.SettingChanged += delegate { QuickButton.Apply(); }; TextColor.SettingChanged += delegate { QuickButton.Apply(); }; ShowSortButton.SettingChanged += delegate { QuickButton.Apply(); }; ShowChestSortButton.SettingChanged += delegate { QuickButton.Apply(); }; ChestSortNudge.SettingChanged += delegate { QuickButton.Apply(); }; SortText.SettingChanged += delegate { QuickButton.Apply(); }; ShowLockMarker.SettingChanged += delegate { LockMarkers.RefreshAll(); }; LockEnabled.SettingChanged += delegate { LockMarkers.RefreshAll(); }; if (_headless) { Log.LogInfo((object)"QuickStack 0.4.0 loaded on a dedicated server (settings only; the buttons and hotkeys run on the players' games)."); return; } _harmony = new Harmony("pucko.quickstack"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"QuickStack 0.4.0 loaded."); } private void Update() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0034: Unknown result type (might be due to invalid IL or missing references) if (_headless) { return; } try { KeyboardShortcut value = Hotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && Stacker.CanUseHotkey()) { Stacker.RunHotkey(); } value = SortHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && Stacker.CanUseHotkey()) { Sorter.RunHotkey(); } Stacker.Tick(); } catch (Exception ex) { Log.LogError((object)ex); Stacker.Reset(); } } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } } internal static class QuickButton { private const float Gap = 4f; private static GameObject _qs; private static GameObject _sort; private static GameObject _chestSort; private static RectTransform _stackSrc; internal static void Create(InventoryGui gui) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown Button stackAllButton = gui.m_stackAllButton; RectTransform player = gui.m_player; if ((Object)(object)stackAllButton == (Object)null || (Object)(object)player == (Object)null) { Plugin.Log.LogWarning((object)"Place Stacks button or inventory panel not found; no Quick Stack button."); return; } _qs = Make(stackAllButton, player, "QuickStackButton", new UnityAction(Stacker.Run)); _sort = Make(stackAllButton, player, "QuickStackSortButton", new UnityAction(Sorter.Run)); _stackSrc = ((Component)stackAllButton).GetComponent<RectTransform>(); RectTransform val = (RectTransform)(((Object)(object)_stackSrc != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); _chestSort = (((Object)(object)val != (Object)null) ? Make(stackAllButton, val, "QuickStackChestSortButton", new UnityAction(Sorter.RunContainer)) : null); Apply(); } private static GameObject Make(Button src, RectTransform parent, string name, UnityAction onClick) { GameObject val = Object.Instantiate<GameObject>(((Component)src).gameObject, (Transform)(object)parent, false); ((Object)val).name = name; val.SetActive(true); Button component = val.GetComponent<Button>(); for (int i = 0; i < ((UnityEventBase)component.onClick).GetPersistentEventCount(); i++) { ((UnityEventBase)component.onClick).SetPersistentListenerState(i, (UnityEventCallState)0); } ((UnityEventBase)component.onClick).RemoveAllListeners(); ((UnityEvent)component.onClick).AddListener(onClick); ((Selectable)component).interactable = true; MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && ((object)val2).GetType().Name == "UIGamePad") { Object.Destroy((Object)(object)val2); } } val.transform.SetAsLastSibling(); return val; } internal static void Apply() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_qs == (Object)null) && !((Object)(object)_sort == (Object)null)) { ApplyChestSort(); InventoryGui instance = InventoryGui.instance; float value = Plugin.ButtonSize.Value; Color color = TextColor(instance); _qs.SetActive(Plugin.ShowButton.Value); _sort.SetActive(Plugin.ShowSortButton.Value); Transform parent = ((Transform)_qs.GetComponent<RectTransform>()).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); Rect rect = val.rect; Vector2 center = ((Rect)(ref rect)).center; Vector2 val3 = default(Vector2); if (TryMidpoint(instance, out var mid)) { Vector3 val2 = ((Transform)val).InverseTransformPoint(mid); ((Vector2)(ref val3))..ctor(val2.x - center.x, val2.y - center.y); } else { rect = val.rect; float num = ((Rect)(ref rect)).xMax - value * 0.5f - 10f - center.x; rect = val.rect; ((Vector2)(ref val3))..ctor(num, ((Rect)(ref rect)).yMin + value * 0.5f + 10f - center.y); } val3 += Plugin.ButtonOffset.Value; Style(_qs, Plugin.ButtonLabel.Value, value, color, val3); Style(_sort, Plugin.SortText.Value, value, color, val3 + new Vector2(0f, 0f - (value + 4f))); } } private static void ApplyChestSort() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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) if (!((Object)(object)_chestSort == (Object)null) && !((Object)(object)_stackSrc == (Object)null)) { InventoryGui instance = InventoryGui.instance; float value = Plugin.ButtonSize.Value; _chestSort.SetActive(Plugin.ShowChestSortButton.Value); Transform parent = _chestSort.transform.parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); Vector3[] array = (Vector3[])(object)new Vector3[4]; _stackSrc.GetWorldCorners(array); float num = float.MinValue; float num2 = float.MaxValue; float num3 = float.MinValue; for (int i = 0; i < 4; i++) { Vector3 val2 = ((Transform)val).InverseTransformPoint(array[i]); num = Mathf.Max(num, val2.x); num2 = Mathf.Min(num2, val2.y); num3 = Mathf.Max(num3, val2.y); } Rect rect = val.rect; Vector2 center = ((Rect)(ref rect)).center; Vector2 pos = new Vector2(num + 4f + value * 0.5f - center.x, (num2 + num3) * 0.5f - center.y) + Plugin.ChestSortNudge.Value; Style(_chestSort, Plugin.SortText.Value, value, TextColor(instance), pos); } } private static void Style(GameObject go, string label, float size, Color color, Vector2 pos) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) Text[] componentsInChildren = go.GetComponentsInChildren<Text>(true); foreach (Text obj in componentsInChildren) { obj.text = label; ((Graphic)obj).color = color; obj.resizeTextForBestFit = true; obj.resizeTextMinSize = 8; obj.resizeTextMaxSize = Mathf.RoundToInt(size * 0.5f); } TMP_Text[] componentsInChildren2 = go.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text obj2 in componentsInChildren2) { obj2.text = label; ((Graphic)obj2).color = color; obj2.enableAutoSizing = true; obj2.fontSizeMin = 8f; obj2.fontSizeMax = size * 0.5f; } RectTransform component = go.GetComponent<RectTransform>(); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); component.anchorMax = val; component.anchorMin = val; component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(size, size); ((Transform)component).localScale = Vector3.one; component.anchoredPosition = pos; } private static Color TextColor(InventoryGui gui) { //IL_007e: 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_005b: 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_0037: Unknown result type (might be due to invalid IL or missing references) string value = Plugin.TextColor.Value; Color result = default(Color); if (!string.IsNullOrEmpty(value) && ColorUtility.TryParseHtmlString(value.StartsWith("#") ? value : ("#" + value), ref result)) { return result; } if ((Object)(object)gui != (Object)null && (Object)(object)gui.m_armor != (Object)null) { result = ((Graphic)gui.m_armor).color; result.a = 1f; return result; } return new Color(1f, 0.85f, 0.3f, 1f); } private static bool TryMidpoint(InventoryGui gui, out Vector3 mid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) mid = Vector3.zero; if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_armor == (Object)null || (Object)(object)gui.m_weight == (Object)null) { return false; } mid = (Center(gui.m_armor.rectTransform) + Center(gui.m_weight.rectTransform)) * 0.5f; return true; } private static Vector3 Center(RectTransform r) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4]; r.GetWorldCorners(array); return (array[0] + array[1] + array[2] + array[3]) * 0.25f; } } internal static class Sorter { private static readonly MethodInfo Changed = AccessTools.Method(typeof(Inventory), "Changed", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null); private static readonly FieldInfo DragItem = AccessTools.Field(typeof(InventoryGui), "m_dragItem"); private static bool _eaqsLooked; private static PropertyInfo _eaqsVisibleRows; internal static int VisibleRows(Inventory inv) { if (!_eaqsLooked) { _eaqsLooked = true; Type type = AccessTools.TypeByName("EquipmentAndQuickSlots.Slots"); if (type != null) { _eaqsVisibleRows = type.GetProperty("VisibleRows", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } } int num = inv.GetHeight(); if (_eaqsVisibleRows != null) { try { num = Mathf.Clamp((int)_eaqsVisibleRows.GetValue(null, null), 1, num); } catch { } } return num; } private static bool Dragging() { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance != (Object)null && DragItem != null) { return DragItem.GetValue(instance) != null; } return false; } internal static void RunHotkey() { Container val = (Plugin.SortHotkeyOpenChest.Value ? Stacker.OpenContainer() : null); if ((Object)(object)val != (Object)null) { RunContainer(val); } else { Run(); } } internal static void Run() { Player p = Player.m_localPlayer; if ((Object)(object)p == (Object)null || ((Character)p).IsTeleporting() || ((Character)p).IsDead() || Dragging()) { return; } Inventory inventory = ((Humanoid)p).GetInventory(); if (SortInventory(endRow: VisibleRows(inventory), firstRow: (!Plugin.SortHotbar.Value) ? 1 : 0, inv: inventory, width: inventory.GetWidth(), isFixed: (ItemData it) => ((Humanoid)p).IsItemEquiped(it), kept: out var kept)) { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_playerGrid != (Object)null) { LockMarkers.Refresh(instance.m_playerGrid); } Notify(p, "Inventory sorted", kept); } } internal static void RunContainer() { Container val = Stacker.OpenContainer(); if ((Object)(object)val != (Object)null) { RunContainer(val); } } private static void RunContainer(Container c) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsTeleporting() && !((Character)localPlayer).IsDead() && !Dragging()) { Inventory inventory = c.GetInventory(); if (inventory != null && SortInventory(inventory, inventory.GetWidth(), 0, inventory.GetHeight(), (ItemData it) => false, out var kept)) { Notify(localPlayer, "Chest sorted", kept); } } } private static void Notify(Player p, string text, int kept) { if (Plugin.ShowMessage.Value) { ((Character)p).Message((MessageType)2, text + ((kept > 0) ? (" (" + kept + " kept in place)") : ""), 0, (Sprite)null, false); } } private static bool SortInventory(Inventory inv, int width, int firstRow, int endRow, Func<ItemData, bool> isFixed, out int kept) { //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) kept = 0; if (width < 1 || firstRow >= endRow) { return false; } List<ItemData> list = new List<ItemData>(); HashSet<int> hashSet = new HashSet<int>(); foreach (ItemData item in new List<ItemData>(inv.GetAllItems())) { int x = item.m_gridPos.x; int y = item.m_gridPos.y; if (x >= 0 && x < width && y >= firstRow && y < endRow) { if (isFixed(item) || (Plugin.LockEnabled.Value && Locks.IsLocked(item))) { hashSet.Add(y * width + x); } else { list.Add(item); } } } kept = hashSet.Count; foreach (IGrouping<string, ItemData> item2 in from i in list where i.m_shared.m_maxStackSize > 1 && (i.m_customData == null || i.m_customData.Count == 0) group i by i.m_shared.m_name + "|" + i.m_quality + "|" + i.m_worldLevel) { List<ItemData> list2 = item2.OrderByDescending((ItemData i) => i.m_stack).ToList(); if (list2.Count < 2) { continue; } List<int> list3 = Logic.MergeStacks(list2.Select((ItemData i) => i.m_stack).ToList(), list2[0].m_shared.m_maxStackSize); for (int num = 0; num < list2.Count; num++) { if (num < list3.Count) { list2[num].m_stack = list3[num]; continue; } inv.RemoveItem(list2[num]); list.Remove(list2[num]); } } Localization loc = Localization.instance; List<ItemData> list4 = list.OrderBy((ItemData i) => Logic.Category(((object)Unsafe.As<ItemType, ItemType>(ref i.m_shared.m_itemType)/*cast due to .constrained prefix*/).ToString())).ThenBy<ItemData, string>((ItemData i) => (loc == null) ? i.m_shared.m_name : loc.Localize(i.m_shared.m_name), StringComparer.CurrentCultureIgnoreCase).ThenByDescending((ItemData i) => i.m_quality) .ThenByDescending((ItemData i) => i.m_stack) .ToList(); List<int> list5 = Logic.FreeCells(width, firstRow, endRow, hashSet); if (list5.Count < list4.Count) { Plugin.Log.LogWarning((object)"Sort: not enough free cells, aborted."); return false; } for (int num2 = 0; num2 < list4.Count; num2++) { list4[num2].m_gridPos = new Vector2i(list5[num2] % width, list5[num2] / width); } if (Changed != null) { Changed.Invoke(inv, new object[2] { false, false }); } return true; } } internal static class Stacker { internal static readonly FieldInfo InvList = AccessTools.Field(typeof(Inventory), "m_inventory"); private static readonly FieldInfo NView = AccessTools.Field(typeof(Container), "m_nview"); private static readonly FieldInfo CurrentContainer = AccessTools.Field(typeof(InventoryGui), "m_currentContainer"); private static readonly MethodInfo CheckAccess = AccessTools.Method(typeof(Container), "CheckAccess", new Type[1] { typeof(long) }, (Type[])null); private static readonly MethodInfo InTextInput = AccessTools.Method(typeof(Minimap), "InTextInput", (Type[])null, (Type[])null); private const float Timeout = 3f; internal static bool Active; private static int _found; private static int _responses; private static int _refused; private static int _moved; private static int _hit; private static int _locked; private static float _deadline; private static float _radius; private static bool _single; internal static void Reset() { Active = false; } internal static bool CanUseHotkey() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting()) { return false; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return false; } if (Console.IsVisible() || Menu.IsVisible() || TextInput.IsVisible() || Game.IsPaused()) { return false; } if (InTextInput != null && (Object)(object)Minimap.instance != (Object)null) { try { if ((bool)InTextInput.Invoke(null, null)) { return false; } } catch { } } return true; } internal static Container OpenContainer() { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || !InventoryGui.IsVisible()) { return null; } object? value = CurrentContainer.GetValue(instance); Container val = (Container)((value is Container) ? value : null); if (!((Object)(object)val != (Object)null)) { return null; } return val; } internal static void RunHotkey() { Container val = (Plugin.HotkeyOpenChestOnly.Value ? OpenContainer() : null); if ((Object)(object)val != (Object)null) { RunOne(val); } else { Run(); } } private static void RunOne(Container c) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsTeleporting() && !Active) { object? value = NView.GetValue(c); ZNetView val = (ZNetView)((value is ZNetView) ? value : null); if (!((Object)(object)val == (Object)null) && val.IsValid()) { Begin(localPlayer, new List<Container> { c }, 0, single: true); } } } internal static void Run() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !((Character)localPlayer).IsTeleporting() && !Active) { _radius = Plugin.EffectiveRadius; int locked; List<Container> targets = FindContainers(localPlayer, _radius, out locked); Begin(localPlayer, targets, locked, single: false); } } private static void Begin(Player p, List<Container> targets, int locked, bool single) { _radius = Plugin.EffectiveRadius; _found = targets.Count; _responses = (_refused = (_moved = (_hit = 0))); _locked = locked; _single = single; if (_found == 0) { Notify(p); return; } Active = true; _deadline = Time.time + 3f; foreach (Container target in targets) { try { target.StackAll(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("StackAll failed on " + ((Object)target).name + ": " + ex.Message)); _responses++; _refused++; } } } private static List<Container> FindContainers(Player p, float radius, out int locked) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) locked = 0; List<Container> list = new List<Container>(); HashSet<Container> hashSet = new HashSet<Container>(); Collider[] array = Physics.OverlapSphere(((Component)p).transform.position, radius, -1, (QueryTriggerInteraction)2); List<string> list2 = Logic.ParseList(Plugin.Excluded.Value); long playerID = Game.instance.GetPlayerProfile().GetPlayerID(); Container val = null; if ((Object)(object)InventoryGui.instance != (Object)null && InventoryGui.IsVisible()) { object? value = CurrentContainer.GetValue(InventoryGui.instance); val = (Container)((value is Container) ? value : null); } Collider[] array2 = array; for (int i = 0; i < array2.Length; i++) { Container componentInParent = ((Component)array2[i]).GetComponentInParent<Container>(); if ((Object)(object)componentInParent == (Object)null || !hashSet.Add(componentInParent)) { continue; } object? value2 = NView.GetValue(componentInParent); ZNetView val2 = (ZNetView)((value2 is ZNetView) ? value2 : null); if (!((Object)(object)val2 == (Object)null) && val2.IsValid() && !((Object)(object)((Component)componentInParent).GetComponentInParent<TombStone>() != (Object)null) && (Plugin.IncludeVehicles.Value || (!((Object)(object)componentInParent.m_wagon != (Object)null) && !((Object)(object)((Component)componentInParent).GetComponentInParent<Ship>() != (Object)null))) && (list2.Count <= 0 || !Logic.Matches(list2, ((Object)((Component)componentInParent).gameObject).name, componentInParent.m_name, Localization.instance.Localize(componentInParent.m_name)))) { bool flag = (Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)componentInParent; if (componentInParent.IsInUse() && !flag) { locked++; } else if ((Object)(object)componentInParent.m_wagon != (Object)null && componentInParent.m_wagon.InUse() && !flag) { locked++; } else if (CheckAccess != null && !(bool)CheckAccess.Invoke(componentInParent, new object[1] { playerID })) { locked++; } else if (!PrivateArea.CheckAccess(((Component)componentInParent).transform.position, 0f, false, false)) { locked++; } else { list.Add(componentInParent); } } } return list; } internal static void OnResponse(bool granted) { if (Active) { _responses++; if (!granted) { _refused++; } } } internal static void OnMoved(int n) { if (Active && n > 0) { _moved += n; _hit++; } } internal static void Tick() { if (Active) { if ((Object)(object)Player.m_localPlayer == (Object)null) { Active = false; } else if (_responses >= _found || Time.time > _deadline) { Finish(); } } } private static void Finish() { Player localPlayer = Player.m_localPlayer; int silent = Math.Max(0, _found - _responses); Active = false; if ((Object)(object)localPlayer != (Object)null) { Notify(localPlayer, silent); } Plugin.Log.LogInfo((object)("Quick stack: " + Logic.Summary(_radius, _found, _moved, _hit, _refused, silent, _locked, _single))); } private static void Notify(Player p, int silent = 0) { if (Plugin.ShowMessage.Value) { ((Character)p).Message((MessageType)2, Logic.Summary(_radius, _found, _moved, _hit, _refused, silent, _locked, _single), 0, (Sprite)null, false); } } }
plugins/EinsteinCrew-PuckosCarePackage/Pucko-ShipLantern/ShipLantern.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace ShipLantern; [BepInPlugin("pucko.shiplantern", "ShipLantern", "0.3.4")] public class Plugin : BaseUnityPlugin { public const string Guid = "pucko.shiplantern"; public const string Version = "0.3.4"; public static Plugin Instance; public static ManualLogSource Log; public static ConfigEntry<bool> Enabled; public static ConfigEntry<string> AcceptedItems; public static ConfigEntry<bool> ShowArm; public static ConfigEntry<float> ArmYaw; public static ConfigEntry<float> ArmPitch; public static ConfigEntry<float> LinkSpacing; public static ConfigEntry<float> OffsetX; public static ConfigEntry<float> OffsetY; public static ConfigEntry<float> OffsetZ; public static ConfigEntry<float> VisualScale; public static ConfigEntry<float> LightRange; public static ConfigEntry<float> Gravity; public static ConfigEntry<float> Damping; public static ConfigEntry<float> IdleSway; public static ConfigEntry<float> BackLimit; public static ConfigEntry<float> Smoothing; public static ConfigEntry<int> ChainLinks; public static ConfigEntry<bool> LogBounds; private void Awake() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Expected O, but got Unknown //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Expected O, but got Unknown //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 General", "Enabled", true, "Adds a one-slot lantern mount to the Longship's front head. Needed on server AND clients."); AcceptedItems = ((BaseUnityPlugin)this).Config.Bind<string>("1 General", "AcceptedItems", "Lantern", "Comma-separated item prefab names the mount accepts (e.g. Lantern,Lantern_DN,Lantern_hooded)."); OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("2 Placement", "AnchorX", 0f, new ConfigDescription("Move the arm's root (the chain hangs from its tip) sideways (ship local, metres). Client-side; changes apply live.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>())); OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("2 Placement", "AnchorY", 0.416f, new ConfigDescription("Move the arm's root up/down (ship local, metres).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1.5f), Array.Empty<object>())); OffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("2 Placement", "AnchorZ", -0.73f, new ConfigDescription("Move the arm's root (and with it the chain) forward/back (ship local, metres).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1.5f, 1.5f), Array.Empty<object>())); VisualScale = ((BaseUnityPlugin)this).Config.Bind<float>("2 Placement", "Scale", 0.7f, new ConfigDescription("Size of the chain and lantern (1 = size of the wall-mounted Dverger lantern).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 2f), Array.Empty<object>())); ChainLinks = ((BaseUnityPlugin)this).Config.Bind<int>("3 Chain", "ChainLinks", 6, new ConfigDescription("Number of chain links.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>())); ShowArm = ((BaseUnityPlugin)this).Config.Bind<bool>("2 Placement", "ShowArm", true, "Show the lantern's holder arm (the 'tongue') that the chain hangs from."); ArmYaw = ((BaseUnityPlugin)this).Config.Bind<float>("2 Placement", "ArmYaw", 90f, new ConfigDescription("Direction the arm points, degrees around the vertical axis (ship local). 90 = straight forward out of the mouth, 0 = to the left, 180 = to the right.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())); ArmPitch = ((BaseUnityPlugin)this).Config.Bind<float>("2 Placement", "ArmPitch", -15.55f, new ConfigDescription("Tilt the arm: positive = tip up, negative = tip down (degrees). The chain follows the tip.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-90f, 90f), Array.Empty<object>())); LinkSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("3 Chain", "LinkSpacing", 0.74f, new ConfigDescription("How far apart the links sit, as a fraction of link height (below 1 = links overlap/interlock).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 1.1f), Array.Empty<object>())); Gravity = ((BaseUnityPlugin)this).Config.Bind<float>("3 Chain", "Gravity", 3f, new ConfigDescription("Gravity multiplier for the swinging (higher = snappier swing).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); Damping = ((BaseUnityPlugin)this).Config.Bind<float>("3 Chain", "Damping", 0.8f, new ConfigDescription("Swing damping per second (0 = swings forever, higher = settles faster).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); IdleSway = ((BaseUnityPlugin)this).Config.Bind<float>("3 Chain", "IdleSway", 0f, new ConfigDescription("Small constant sea-breeze sway (m/s2), so the lantern is never perfectly still.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); Smoothing = ((BaseUnityPlugin)this).Config.Bind<float>("3 Chain", "Smoothing", 0.045f, new ConfigDescription("Seconds over which the lantern's hanging point is smoothed before the swing is worked out. Higher = calmer lantern that follows the ship's rocking more slowly, 0 = follows every jolt (jittery).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.3f), Array.Empty<object>())); BackLimit = ((BaseUnityPlugin)this).Config.Bind<float>("3 Chain", "BackLimit", 0.6f, new ConfigDescription("How far (metres) the chain may swing back past the hanging point towards the ship's head before it is stopped.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); LightRange = ((BaseUnityPlugin)this).Config.Bind<float>("2 Placement", "LightRangeMultiplier", 2f, new ConfigDescription("Multiplier on the lantern light range.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); LogBounds = ((BaseUnityPlugin)this).Config.Bind<bool>("9 Debug", "LogHeadBounds", false, "Debug: log the ship head mesh bounds, the visual changes and the chain build for every ship (helps tuning the placement)."); if (Enabled.Value) { Harmony val = new Harmony("pucko.shiplantern"); val.PatchAll(typeof(Patches)); PatchInventory(val); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ShipLantern 0.3.4 loaded"); } } private static void PatchInventory(Harmony h) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(Patches).GetMethod("InvBlockBool")); Type typeFromHandle = typeof(ItemData); MethodInfo[] array = new MethodInfo[4] { AccessTools.Method(typeof(Inventory), "CanAddItem", new Type[2] { typeFromHandle, typeof(int) }, (Type[])null), AccessTools.Method(typeof(Inventory), "AddItem", new Type[1] { typeFromHandle }, (Type[])null), AccessTools.Method(typeof(Inventory), "AddItem", new Type[2] { typeFromHandle, typeof(Vector2i) }, (Type[])null), AccessTools.Method(typeof(Inventory), "AddItem", new Type[5] { typeFromHandle, typeof(int), typeof(int), typeof(int), typeof(bool) }, (Type[])null) }; foreach (MethodInfo methodInfo in array) { if (methodInfo == null) { Log.LogError((object)"Inventory patch target missing - filter incomplete"); } else { h.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } public static bool Accepts(ItemData item) { if (item == null) { return false; } string n = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : ""); return (from s in AcceptedItems.Value.Split(',') select s.Trim()).Any((string s) => s.Length > 0 && string.Equals(s, n, StringComparison.OrdinalIgnoreCase)); } } public static class Patches { public static bool InvBlockBool(Inventory __instance, ItemData item, ref bool __result) { if (!HeadSlot.Inventories.Contains(__instance)) { return true; } if (Plugin.Accepts(item)) { return true; } __result = false; return false; } [HarmonyPatch(typeof(Ship), "Awake")] [HarmonyPostfix] private static void ShipAwake(Ship __instance) { ((MonoBehaviour)__instance).StartCoroutine(HeadSlot.Attach(__instance)); } [HarmonyPatch(typeof(Container), "TakeAll")] [HarmonyPrefix] private static bool TakeAll(Container __instance, Humanoid character, ref bool __result) { HeadSlot headSlot = __instance as HeadSlot; if ((Object)(object)headSlot == (Object)null) { return true; } __result = headSlot.DoTakeAll(character); return false; } [HarmonyPatch(typeof(Container), "StackAll")] [HarmonyPrefix] private static bool StackAll(Container __instance) { return !(__instance is HeadSlot); } [HarmonyPatch(typeof(Container), "SetInUse")] [HarmonyPrefix] private static bool SetInUse(Container __instance, bool inUse) { HeadSlot headSlot = __instance as HeadSlot; if ((Object)(object)headSlot == (Object)null) { return true; } headSlot.SetUse(inUse); return false; } [HarmonyPatch(typeof(Container), "UpdateUseVisual")] [HarmonyPrefix] private static bool UpdateUseVisual(Container __instance) { return !(__instance is HeadSlot); } } public class HeadSlot : Container, Hoverable, Interactable { public static readonly HashSet<Inventory> Inventories = new HashSet<Inventory>(); private const string Key = "pucko_shiplantern_items"; private static readonly int KeyHash = StringExtensionMethods.GetStableHashCode("pucko_shiplantern_items"); private static readonly FieldInfo fNview = AccessTools.Field(typeof(Container), "m_nview"); private static readonly FieldInfo fInv = AccessTools.Field(typeof(Container), "m_inventory"); private static readonly FieldInfo fInUse = AccessTools.Field(typeof(Container), "m_inUse"); private ZNetView nv; private Inventory inv; private bool loading; private uint lastRev = uint.MaxValue; private GameObject visual; private string shown = ""; private Vector3 visOffset; private ChainSim chain; private Tongue tongue; private bool tongueTried; public static IEnumerator Attach(Ship ship) { yield return null; if ((Object)(object)ship == (Object)null) { yield break; } ZNetView component = ((Component)ship).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.GetZDO() != null && component.GetZDO().GetPrefab() == StringExtensionMethods.GetStableHashCode("VikingShip") && !((Object)(object)((Component)ship).GetComponentInChildren<HeadSlot>(true) != (Object)null)) { Vector3 center = default(Vector3); ((Vector3)(ref center))..ctor(0f, 3.3f, 10.7f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 3.4f, 11.6f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0.9f, 1.2f, 1.2f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f, 3.84f, 11.1f); Bounds? val4 = HeadBounds(ship); if (val4.HasValue) { Bounds value = val4.Value; center = ((Bounds)(ref value)).center; ((Vector3)(ref val))..ctor(((Bounds)(ref value)).center.x, ((Bounds)(ref value)).min.y + ((Bounds)(ref value)).size.y * 0.45f, ((Bounds)(ref value)).max.z + 0.25f); ((Vector3)(ref val2))..ctor(Mathf.Max(0.9f, ((Bounds)(ref value)).size.x + 0.5f), ((Bounds)(ref value)).size.y - 0.5f, 1.2f); ((Vector3)(ref val3))..ctor(((Bounds)(ref value)).center.x, ((Bounds)(ref value)).min.y + 0.6f + val2.y * 0.5f, ((Bounds)(ref value)).max.z - 0.25f); } Container val5 = ((IEnumerable<Container>)((Component)ship).GetComponentsInChildren<Container>(true)).FirstOrDefault((Func<Container, bool>)((Container c) => !(c is HeadSlot))); GameObject val6 = new GameObject("ShipLantern_HeadSlot"); val6.SetActive(false); val6.transform.SetParent(((Component)ship).transform, false); val6.transform.localPosition = center; val6.layer = (((Object)(object)val5 != (Object)null) ? ((Component)val5).gameObject.layer : LayerMask.NameToLayer("piece_nonsolid")); BoxCollider obj = val6.AddComponent<BoxCollider>(); ((Collider)obj).isTrigger = true; obj.size = val2; obj.center = val3 - center; HeadSlot headSlot = val6.AddComponent<HeadSlot>(); headSlot.visOffset = val - center; ((Container)headSlot).m_name = "Lantern mount"; ((Container)headSlot).m_width = 1; ((Container)headSlot).m_height = 1; ((Container)headSlot).m_checkGuardStone = false; if ((Object)(object)val5 != (Object)null) { ((Container)headSlot).m_bkg = val5.m_bkg; } val6.SetActive(true); } } private static Bounds? HeadBounds(Ship ship) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00f5: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) try { Bounds? result = null; string[] array = new string[3] { "visual/hull_new/skull_head", "visual/hull_new/dragon_head", "visual/unused/dragon_head" }; foreach (string text in array) { Transform val = ((Component)ship).transform.Find("ship/" + text) ?? ((Component)ship).transform.Find(text); if ((Object)(object)val == (Object)null) { continue; } MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { continue; } Bounds bounds = component.sharedMesh.bounds; Bounds value = default(Bounds); bool flag = true; for (int j = 0; j < 8; j++) { Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))); Vector3 val3 = ((Component)ship).transform.InverseTransformPoint(val.TransformPoint(val2)); if (flag) { ((Bounds)(ref value))..ctor(val3, Vector3.zero); flag = false; } else { ((Bounds)(ref value)).Encapsulate(val3); } } if (Plugin.LogBounds.Value) { ManualLogSource log = Plugin.Log; string[] obj = new string[6] { "Head '", text, "' bounds in ship space: min ", null, null, null }; Vector3 val4 = ((Bounds)(ref value)).min; obj[3] = ((Vector3)(ref val4)).ToString("F2"); obj[4] = " max "; val4 = ((Bounds)(ref value)).max; obj[5] = ((Vector3)(ref val4)).ToString("F2"); log.LogInfo((object)string.Concat(obj)); } if (!result.HasValue) { result = value; } } return result; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Head bounds failed: " + ex.Message)); return null; } } private void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown nv = ((Component)this).GetComponentInParent<ZNetView>(); if (!((Object)(object)nv == (Object)null) && nv.GetZDO() != null) { inv = new Inventory("Lantern mount", base.m_bkg, 1, 1); Inventories.Add(inv); Inventory obj = inv; obj.m_onChanged = (Action)Delegate.Combine(obj.m_onChanged, new Action(OnInvChanged)); fNview.SetValue(this, nv); fInv.SetValue(this, inv); nv.Register<long>("PHL_RequestOpen", (Action<long, long>)RPC_RequestOpen2); nv.Register<bool>("PHL_OpenResponse", (Action<long, bool>)RPC_OpenResponse2); Load2(force: true); ((MonoBehaviour)this).InvokeRepeating("Poll", 1f, 1f); } } private void OnDestroy() { if (inv != null) { Inventories.Remove(inv); } } private Vector3 Root() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //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_0034: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.TransformPoint(visOffset + new Vector3(Plugin.OffsetX.Value, Plugin.OffsetY.Value, Plugin.OffsetZ.Value)); } private Vector3 Tip() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) Vector3 val = Root(); if (tongue == null) { return val; } return tongue.Place(val, ((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Component)this).transform.parent : ((Component)this).transform); } private void LateUpdate() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (tongue == null && !Application.isBatchMode && !tongueTried && (Object)(object)ZNetScene.instance != (Object)null) { tongueTried = true; try { tongue = Tongue.Build(((Component)this).transform); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Tongue: " + ex.Message)); } } if (tongue != null || chain != null) { Vector3 anchor = Tip(); if (chain != null && (Object)(object)visual != (Object)null) { chain.Step(Time.deltaTime, anchor); } } } public string GetHoverName() { return base.m_name; } public string GetHoverText() { string text = base.m_name + ((inv != null && inv.NrOfItems() == 0) ? " ( $piece_container_empty )" : ""); text += "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_container_open"; return Localization.instance.Localize(text); } public bool Interact(Humanoid character, bool hold, bool alt) { if (hold || (Object)(object)nv == (Object)null) { return false; } long playerID = Game.instance.GetPlayerProfile().GetPlayerID(); nv.InvokeRPC("PHL_RequestOpen", new object[1] { playerID }); return true; } private void RPC_RequestOpen2(long sender, long playerID) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (nv.IsOwner()) { if ((bool)fInUse.GetValue(this)) { nv.InvokeRPC(sender, "PHL_OpenResponse", new object[1] { false }); return; } ZDOMan.instance.ForceSendZDO(sender, nv.GetZDO().m_uid); nv.GetZDO().SetOwner(sender); nv.InvokeRPC(sender, "PHL_OpenResponse", new object[1] { true }); } } private void RPC_OpenResponse2(long sender, bool granted) { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { if (granted) { InventoryGui.instance.Show((Container)(object)this, 1); } else { ((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_inuse", 0, (Sprite)null, false); } } } public void SetUse(bool inUse) { if (!((Object)(object)nv == (Object)null) && nv.IsOwner()) { fInUse.SetValue(this, inUse); } } public bool DoTakeAll(Humanoid who) { if (inv == null || (Object)(object)who == (Object)null) { return false; } Inventory inventory = who.GetInventory(); foreach (ItemData item in inv.GetAllItems().ToList()) { if (inventory.CanAddItem(item, item.m_stack)) { inventory.MoveItemToThis(inv, item); } } return true; } private void OnInvChanged() { if (!loading) { UpdateVisual(); if (!((Object)(object)nv == (Object)null) && nv.IsOwner()) { Save2(); } } } private void Save2() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); inv.Save(val); nv.GetZDO().Set(KeyHash, val.GetArray()); lastRev = nv.GetZDO().DataRevision; } private void Poll() { if (!((Object)(object)nv == (Object)null) && nv.IsValid()) { Load2(force: false); } } private void Load2(bool force) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown ZDO zDO = nv.GetZDO(); if ((!force && zDO.DataRevision == lastRev) || (!force && (bool)fInUse.GetValue(this))) { return; } lastRev = zDO.DataRevision; byte[] byteArray = zDO.GetByteArray(KeyHash, (byte[])null); if (byteArray == null) { UpdateVisual(); return; } loading = true; try { inv.Load(new ZPackage(byteArray)); } finally { loading = false; } UpdateVisual(); } private static void DumpTree(Transform t, int d) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (d <= 4) { ManualLogSource log = Plugin.Log; string[] obj = new string[9] { new string(' ', d * 2), ((Object)t).name, " active=", ((Component)t).gameObject.activeSelf.ToString(), " scale=", null, null, null, null }; Vector3 localScale = t.localScale; obj[5] = ((Vector3)(ref localScale)).ToString("F2"); obj[6] = " ["; obj[7] = string.Join(" ", (from c in ((Component)t).GetComponents<Component>() where (Object)(object)c != (Object)null && !(c is Transform) select ((object)c).GetType().Name).ToArray()); obj[8] = "]"; log.LogInfo((object)string.Concat(obj)); for (int num = 0; num < t.childCount; num++) { DumpTree(t.GetChild(num), d + 1); } } } private void UpdateVisual() { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) try { string text = ""; ItemData val = inv.GetAllItems().FirstOrDefault(); if (val != null && (Object)(object)val.m_dropPrefab != (Object)null) { text = ((Object)val.m_dropPrefab).name; } if (text == shown) { return; } if (Plugin.LogBounds.Value) { Plugin.Log.LogInfo((object)("UpdateVisual: want='" + text + "' batch=" + Application.isBatchMode)); } shown = text; if ((Object)(object)visual != (Object)null) { Object.Destroy((Object)(object)visual); visual = null; chain = null; } if (!(text == "") && !Application.isBatchMode) { visual = new GameObject("LanternVisual"); visual.transform.SetParent(((Component)this).transform, false); chain = ChainSim.Build(visual, ((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Component)this).transform.parent : ((Component)this).transform); if (chain == null) { Object.Destroy((Object)(object)visual); visual = null; } else { chain.Step(0f, Tip()); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("UpdateVisual: " + ex)); } } } public class Tongue { private Transform arm; private float tipDx; private float tipDy; public static Tongue Build(Transform parent) { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0160: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_019d: 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_01df: Unknown result type (might be due to invalid IL or missing references) GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("dvergrprops_lantern") : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"dvergrprops_lantern prefab not found (tongue)"); return null; } Mesh val2 = null; MeshFilter[] componentsInChildren = val.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val3 in componentsInChildren) { if ((Object)(object)val3.sharedMesh != (Object)null && ((Object)val3.sharedMesh).name.StartsWith("LanternBroken.019")) { val2 = val3.sharedMesh; break; } } if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"arm mesh LanternBroken.019 not found"); return null; } Material val4 = null; Transform val5 = val.transform.Find("New"); if ((Object)(object)val5 != (Object)null && (Object)(object)val5.Find("default") != (Object)null) { MeshRenderer component = ((Component)val5.Find("default")).GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null) { val4 = ((Renderer)component).sharedMaterial; } } if ((Object)(object)val4 == (Object)null) { MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>(true); if ((Object)(object)componentInChildren != (Object)null) { val4 = ((Renderer)componentInChildren).sharedMaterial; } } Bounds bounds = val2.bounds; Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).center.y, ((Bounds)(ref bounds)).center.z); GameObject val7 = new GameObject("LanternArm"); val7.transform.SetParent(parent, false); GameObject val8 = new GameObject("m"); val8.transform.SetParent(val7.transform, false); val8.transform.localPosition = -val6; val8.AddComponent<MeshFilter>().sharedMesh = val2; ((Renderer)val8.AddComponent<MeshRenderer>()).sharedMaterial = val4; return new Tongue { arm = val7.transform, tipDx = -0.875f - val6.x, tipDy = 0.2f - val6.y }; } public Vector3 Place(Vector3 root, Transform ship) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) bool value = Plugin.ShowArm.Value; if (((Component)arm).gameObject.activeSelf != value) { ((Component)arm).gameObject.SetActive(value); } float value2 = Plugin.VisualScale.Value; arm.localScale = Vector3.one * value2; arm.position = root; arm.rotation = ship.rotation * Quaternion.Euler(0f, Plugin.ArmYaw.Value, 0f) * Quaternion.Euler(0f, 0f, 0f - Plugin.ArmPitch.Value); if (!value) { return root; } return root + arm.rotation * (new Vector3(tipDx, tipDy, 0f) * value2); } } public class ChainSim { private const float Dt = 1f / 60f; private Transform ship; private Transform[] links; private float[] linkLen; private Transform body; private float bodyHalf; private ChainMath cm; private bool init; private float scaleBuilt; private float spacingBuilt; public static ChainSim Build(GameObject root, Transform ship) { //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: 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_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("dvergrprops_lantern") : null); if ((Object)(object)prefab == (Object)null) { Plugin.Log.LogWarning((object)"dvergrprops_lantern prefab not found"); return null; } Mesh val = Find("LanternBroken.013"); Mesh val2 = Find("LanternBroken.016"); Mesh val3 = Find("LanternBroken.014"); Mesh val4 = Find("LanternBroken.011"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null) { Plugin.Log.LogWarning((object)("lantern fragment meshes missing (" + ((Object)(object)val != (Object)null) + "," + ((Object)(object)val2 != (Object)null) + "," + ((Object)(object)val3 != (Object)null) + "," + ((Object)(object)val4 != (Object)null) + ")")); return null; } Material val5 = null; Transform val6 = null; Transform val7 = null; Transform val8 = prefab.transform.Find("New"); if ((Object)(object)val8 != (Object)null) { MeshRenderer val9 = (((Object)(object)val8.Find("default") != (Object)null) ? ((Component)val8.Find("default")).GetComponent<MeshRenderer>() : null); if ((Object)(object)val9 != (Object)null) { val5 = ((Renderer)val9).sharedMaterial; } val6 = val8.Find("Point Light"); val7 = val8.Find("flare"); } if ((Object)(object)val5 == (Object)null) { MeshRenderer componentInChildren = prefab.GetComponentInChildren<MeshRenderer>(true); if ((Object)(object)componentInChildren != (Object)null) { val5 = ((Renderer)componentInChildren).sharedMaterial; } } ChainSim chainSim = new ChainSim { ship = ship }; Mesh[] array = (Mesh[])(object)new Mesh[3] { val2, val3, val4 }; int value = Plugin.ChainLinks.Value; chainSim.links = (Transform[])(object)new Transform[value]; chainSim.linkLen = new float[value]; for (int i = 0; i < value; i++) { Mesh val10 = array[i % 3]; GameObject val11 = new GameObject("Link" + i); val11.transform.SetParent(root.transform, false); GameObject val12 = new GameObject("m"); val12.transform.SetParent(val11.transform, false); Transform transform = val12.transform; Bounds bounds = val10.bounds; transform.localPosition = -((Bounds)(ref bounds)).center; val12.AddComponent<MeshFilter>().sharedMesh = val10; ((Renderer)val12.AddComponent<MeshRenderer>()).sharedMaterial = val5; val12.transform.localRotation = Quaternion.identity; chainSim.links[i] = val11.transform; float[] array2 = chainSim.linkLen; int num = i; bounds = val10.bounds; array2[num] = ((Bounds)(ref bounds)).size.y; } GameObject val13 = new GameObject("Body"); val13.transform.SetParent(root.transform, false); GameObject val14 = new GameObject("m"); val14.transform.SetParent(val13.transform, false); Bounds bounds2 = val.bounds; Vector3 val15 = default(Vector3); ((Vector3)(ref val15))..ctor(((Bounds)(ref bounds2)).center.x, ((Bounds)(ref bounds2)).max.y - 0.06f, ((Bounds)(ref bounds2)).center.z); val14.transform.localPosition = -val15; val14.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val14.AddComponent<MeshRenderer>()).sharedMaterial = val5; chainSim.body = val13.transform; chainSim.bodyHalf = val15.y - ((Bounds)(ref bounds2)).center.y; if ((Object)(object)val6 != (Object)null) { GameObject obj = Object.Instantiate<GameObject>(((Component)val6).gameObject, val13.transform); ((Object)obj).name = "LanternLight"; obj.SetActive(true); obj.transform.localPosition = val6.localPosition - val15; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; Light[] componentsInChildren = obj.GetComponentsInChildren<Light>(true); foreach (Light obj2 in componentsInChildren) { obj2.range *= Plugin.LightRange.Value; } } if ((Object)(object)val7 != (Object)null) { GameObject obj3 = Object.Instantiate<GameObject>(((Component)val7).gameObject, val13.transform); ((Object)obj3).name = "LanternFlare"; obj3.SetActive(true); obj3.transform.localPosition = val7.localPosition - val15; obj3.transform.localRotation = Quaternion.identity; obj3.transform.localScale = Vector3.one; } chainSim.cm = new ChainMath(value + 2); if (Plugin.LogBounds.Value) { Plugin.Log.LogInfo((object)("Chain lantern built: " + value + " links, body half " + chainSim.bodyHalf.ToString("F2") + ", light=" + ((Object)(object)val6 != (Object)null) + ", material=" + (((Object)(object)val5 != (Object)null) ? ((Object)val5).name : "null"))); } return chainSim; Mesh Find(string key) { MeshFilter[] componentsInChildren2 = prefab.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val16 in componentsInChildren2) { if ((Object)(object)val16.sharedMesh != (Object)null && ((Object)val16.sharedMesh).name.StartsWith(key)) { return val16.sharedMesh; } } return null; } } private void Layout() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) float num = (scaleBuilt = Plugin.VisualScale.Value); spacingBuilt = Plugin.LinkSpacing.Value; int num2 = links.Length; for (int i = 0; i < num2; i++) { cm.SegLen[i] = linkLen[i] * num * Plugin.LinkSpacing.Value; } cm.SegLen[num2] = (bodyHalf - 0.06f) * num; Transform[] array = links; for (int j = 0; j < array.Length; j++) { array[j].localScale = Vector3.one * num; } body.localScale = Vector3.one * num; } public void Step(float dt, Vector3 anchor) { //IL_0073: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) int num = links.Length; if (!init || Mathf.Abs(Plugin.VisualScale.Value - scaleBuilt) > 0.0001f || Mathf.Abs(Plugin.LinkSpacing.Value - spacingBuilt) > 0.0001f) { Layout(); if (!init) { cm.Reset(anchor); init = true; } } cm.Step(dt, anchor, ship.worldToLocalMatrix, ship.localToWorldMatrix, ship.right, ship.forward, Time.time, Plugin.Gravity.Value, Plugin.Damping.Value, Plugin.IdleSway.Value, Plugin.BackLimit.Value, Plugin.Smoothing.Value, 8, 0.3f); float y = ship.eulerAngles.y; for (int i = 0; i < num; i++) { Vector3 val = cm.Render(i); Vector3 val2 = cm.Render(i + 1); Vector3 val3 = val - val2; Quaternion rotation = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val3)).normalized) * Quaternion.Euler(0f, y + ((i % 2 == 0) ? 0f : 90f), 0f); links[i].position = (val + val2) * 0.5f; links[i].rotation = rotation; } Vector3 val4 = cm.Render(num) - cm.Render(num + 1); body.position = cm.Render(num); body.rotation = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val4)).normalized) * Quaternion.Euler(0f, y, 0f); } } public sealed class ChainMath { public Vector3[] P; public Vector3[] Prev; public float[] SegLen; private Vector3[] Vel; private Vector3[] Vel2; private Vector3 f1; private Vector3 f2; private Vector3 prevF; private bool init; public Vector3 RenderOffset; public ChainMath(int points) { P = (Vector3[])(object)new Vector3[points]; Prev = (Vector3[])(object)new Vector3[points]; SegLen = new float[points - 1]; Vel = (Vector3[])(object)new Vector3[points]; Vel2 = (Vector3[])(object)new Vector3[points]; } public void Reset(Vector3 anchor) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) P[0] = anchor; for (int i = 1; i < P.Length; i++) { P[i] = P[i - 1] + Vector3.down * SegLen[i - 1]; } Array.Copy(P, Prev, P.Length); f1 = (f2 = (prevF = anchor)); init = true; RenderOffset = Vector3.zero; } public Vector3 Render(int i) { //IL_001c: 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_0037: 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) float num = 1f - (float)i / (float)(P.Length - 1); return P[i] + RenderOffset * ((num < 0f) ? 0f : num); } public void Step(float dt, Vector3 anchor, Matrix4x4 w2l, Matrix4x4 l2w, Vector3 shipRight, Vector3 shipForward, float time, float gravity, float damping, float sway, float backLimit, float smoothing, int iterations, float blur = 0f) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0009: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00bb: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: 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_021d: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: 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_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) if (!init) { Reset(anchor); } Vector3 val = P[0] - anchor; if (((Vector3)(ref val)).sqrMagnitude > 25f) { Reset(anchor); } if (dt <= 0f) { RenderOffset = anchor - P[0]; return; } dt = Mathf.Min(dt, 0.1f); prevF = f2; if (!(smoothing > 0.0001f)) { val = (f1 = (f2 = anchor)); } else { float num = 1f - Mathf.Exp((0f - dt) / (smoothing * 0.5f)); f1 = Vector3.Lerp(f1, anchor, num); f2 = Vector3.Lerp(f2, f1, num); } int num2 = Mathf.Clamp(Mathf.CeilToInt(dt / 0.008f), 1, 12); float num3 = dt / (float)num2; float num4 = Mathf.Exp((0f - damping) * num3); float num5 = ((Matrix4x4)(ref w2l)).MultiplyPoint3x4(f2).z - backLimit; for (int i = 1; i <= num2; i++) { Vector3 val2 = Vector3.Lerp(prevF, f2, (float)i / (float)num2); P[0] = val2; Prev[0] = val2; Vector3 val3 = Vector3.down * 9.81f * gravity; Vector3 val4 = (shipRight * Mathf.Sin(time * 1.3f) + shipForward * Mathf.Sin(time * 0.9f + 1f)) * sway; for (int j = 1; j < P.Length; j++) { Vel[j] = (P[j] - Prev[j]) * num4; } Vel[0] = Vector3.zero; if (blur > 0f) { for (int k = 1; k < P.Length; k++) { Vector3 val5 = Vel[k - 1]; Vector3 val6 = ((k + 1 < P.Length) ? Vel[k + 1] : Vel[k]); Vel2[k] = Vel[k] * (1f - blur) + (val5 + val6) * (0.5f * blur); } for (int l = 1; l < P.Length; l++) { Vel[l] = Vel2[l]; } } for (int m = 1; m < P.Length; m++) { Vector3 val7 = Vel[m]; float magnitude = ((Vector3)(ref val7)).magnitude; if (magnitude > 0.4f) { val7 *= 0.4f / magnitude; } Prev[m] = P[m]; ref Vector3 reference = ref P[m]; reference += val7 + (val3 + val4) * (num3 * num3); } for (int n = 0; n < iterations; n++) { for (int num6 = 0; num6 < P.Length - 1; num6++) { Vector3 val8 = P[num6 + 1] - P[num6]; float magnitude2 = ((Vector3)(ref val8)).magnitude; if (!(magnitude2 < 1E-05f)) { Vector3 val9 = val8 * ((magnitude2 - SegLen[num6]) / magnitude2); if (num6 == 0) { ref Vector3 reference2 = ref P[num6 + 1]; reference2 -= val9; continue; } ref Vector3 reference3 = ref P[num6]; reference3 += val9 * 0.5f; ref Vector3 reference4 = ref P[num6 + 1]; reference4 -= val9 * 0.5f; } } for (int num7 = 1; num7 < P.Length; num7++) { Vector3 val10 = ((Matrix4x4)(ref w2l)).MultiplyPoint3x4(P[num7]); if (val10.z < num5) { val10.z = num5; P[num7] = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(val10); } } } } P[0] = f2; RenderOffset = anchor - f2; } }
plugins/EinsteinCrew-PuckosCarePackage/Pucko-SkyVines/SkyVines.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace Pucko.SkyVines; internal static class Cfg { public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> LogDecisions; public static ConfigEntry<bool> ShowRays; public static ConfigEntry<bool> ShowAllNearby; public static ConfigEntry<float> NearbyRadius; public static ConfigEntry<float> MaxRoofHeight; public static ConfigEntry<float> RingRadius; public static ConfigEntry<float> RingTilt; public static ConfigEntry<float> BlockedShare; public static ConfigEntry<int> RingRays; public static ConfigEntry<string> PerPlant; private static ConfigurationManagerAttributes AdminTag() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true }; } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, ConfigDescription d) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d.Description, d.AcceptableValues, new object[1] { AdminTag() })); } public static void Bind(ConfigFile c) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown Enabled = Adm(c, "1 - General", "Enabled", v: true, new ConfigDescription("Plants that the game says need an open sky use the looser check below. Off: the game's own check (one ray straight up, 100 m).", (AcceptableValueBase)null, Array.Empty<object>())); LogDecisions = c.Bind<bool>("1 - General", "LogDecisions", false, "Write a log line every time a plant's sky check is overruled (position, rays that hit, result)."); MaxRoofHeight = Adm(c, "2 - Sky rules", "MaxRoofHeight", 12f, new ConfigDescription("Only a roof within this many metres above the plant counts. An eave or beam higher up is ignored.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); RingRays = Adm(c, "2 - Sky rules", "RingRays", 8, new ConfigDescription("Extra rays in a ring around the plant, on top of the one straight up. 0 = only the straight ray (height limit only).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32), Array.Empty<object>())); RingRadius = Adm(c, "2 - Sky rules", "RingRadius", 1.5f, new ConfigDescription("Radius of that ring in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 6f), Array.Empty<object>())); RingTilt = Adm(c, "2 - Sky rules", "RingTilt", 0f, new ConfigDescription("Angle in degrees the ring rays lean outward from straight up. 0 = all rays vertical. With 30, a ray 10 m up has moved about 5.8 m further out than its start, so the ring reaches a wide eave far above. The height limit stays vertical (MaxRoofHeight).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>())); BlockedShare = Adm(c, "2 - Sky rules", "BlockedShare", 60f, new ConfigDescription("Share of all rays (straight one plus ring) that must hit a roof before the plant counts as roofed, in %. A thin eave blocks only some of them. 100 = every ray must hit, 1 = any single hit counts (nearly the game's own check, but limited to MaxRoofHeight).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); PerPlant = Adm(c, "2 - Sky rules", "PerPlantOverrides", "", new ConfigDescription("Per-plant exceptions: comma separated prefab:height:share, or prefab:off for a plant that never needs open sky. Examples: VineGreen_sapling:30:100,Beech_Sapling:off. Prefab names are listed in PuckoDataDump's plants.csv. Plants not listed use the values above.", (AcceptableValueBase)null, Array.Empty<object>())); ShowRays = c.Bind<bool>("3 - Debug", "ShowRays", false, "Draw the probe rays for the plant you are looking at: red = hit a roof within the limit, green = open. Local only."); ShowAllNearby = c.Bind<bool>("3 - Debug", "ShowRaysForAllNearby", false, "With ShowRays on: draw the rays for every plant within NearbyRadius of you (up to 40, nearest first), not only the one under the crosshair. Local only."); NearbyRadius = c.Bind<float>("3 - Debug", "NearbyRadius", 15f, new ConfigDescription("Distance in metres for ShowRaysForAllNearby.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 60f), Array.Empty<object>())); } } [BepInPlugin("pucko.skyvines", "SkyVines", "0.0.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "pucko.skyvines"; public const string NAME = "SkyVines"; public const string VERSION = "0.0.3"; internal static ManualLogSource Log; private Harmony _harmony; private bool _drawing; private void Awake() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Cfg.Bind(((BaseUnityPlugin)this).Config); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { Sky.Invalidate(); }; ((BaseUnityPlugin)this).Config.ConfigReloaded += delegate { Sky.Invalidate(); }; SynchronizationManager.OnConfigurationSynchronized += delegate { Sky.Invalidate(); }; _harmony = new Harmony("pucko.skyvines"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"SkyVines 0.0.3 loaded"); } private void Update() { if (Cfg.ShowRays.Value || _drawing) { try { RayDraw.Tick(); _drawing = Cfg.ShowRays.Value; } catch (Exception ex) { Log.LogWarning((object)("Ray view failed, switching it off: " + ex.Message)); Cfg.ShowRays.Value = false; _drawing = false; } } } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } } internal static class RayDraw { private const int MaxPlants = 40; private static readonly List<LineRenderer> s_lines = new List<LineRenderer>(); private static readonly List<Plant> s_near = new List<Plant>(); private static GameObject s_root; private static Material s_mat; private static float s_scanAt; internal static void Tick() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) List<Plant> list = new List<Plant>(); Player localPlayer = Player.m_localPlayer; if (Cfg.ShowRays.Value && (Object)(object)localPlayer != (Object)null) { if (Cfg.ShowAllNearby.Value) { if (Time.time >= s_scanAt) { s_scanAt = Time.time + 1f; Rescan(((Component)localPlayer).transform.position); } Vector3 position = ((Component)localPlayer).transform.position; float num = Cfg.NearbyRadius.Value * Cfg.NearbyRadius.Value; foreach (Plant item in s_near) { if ((Object)(object)item != (Object)null) { Vector3 val = ((Component)item).transform.position - position; if (((Vector3)(ref val)).sqrMagnitude <= num) { list.Add(item); } } } } else { GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject(); Plant val2 = (((Object)(object)hoverObject != (Object)null) ? hoverObject.GetComponentInParent<Plant>() : null); if ((Object)(object)val2 != (Object)null) { list.Add(val2); } } } int num2 = 0; foreach (Plant item2 in list) { num2 = Draw(item2, num2); } Hide(num2); } private static void Rescan(Vector3 pos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) s_near.Clear(); List<Plant> list = new List<Plant>(Object.FindObjectsOfType<Plant>()); list.Sort(delegate(Plant a, Plant b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_002d: 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) Vector3 val = ((Component)a).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; val = ((Component)b).transform.position - pos; return sqrMagnitude.CompareTo(((Vector3)(ref val)).sqrMagnitude); }); for (int num = 0; num < list.Count && num < 40; num++) { s_near.Add(list[num]); } } private static int Draw(Plant plant, int used) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) SkySettings s = Sky.Resolve(plant); if (s.Off) { return used; } Vector3 position = ((Component)plant).transform.position; int num = Sky.Mask(); int num2 = SkyRule.Total(s); Vector3 val2 = default(Vector3); RaycastHit val3 = default(RaycastHit); for (int i = 0; i < num2; i++) { SkyRay skyRay = SkyRule.Ray(s, i); Vector3 val = position + new Vector3(skyRay.Dx, 0f, skyRay.Dz); ((Vector3)(ref val2))..ctor(skyRay.Ux, skyRay.Uy, skyRay.Uz); bool flag = Physics.Raycast(val, val2, ref val3, skyRay.Length, num); Vector3 val4 = (flag ? ((RaycastHit)(ref val3)).point : (val + val2 * skyRay.Length)); LineRenderer obj = Line(used++); ((Component)obj).gameObject.SetActive(true); Color startColor = (obj.endColor = (flag ? new Color(1f, 0.15f, 0.1f, 0.9f) : new Color(0.2f, 1f, 0.3f, 0.9f))); obj.startColor = startColor; obj.SetPosition(0, val); obj.SetPosition(1, val4); } return used; } private static LineRenderer Line(int i) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_root == (Object)null) { s_root = new GameObject("SkyVines_rays"); Object.DontDestroyOnLoad((Object)(object)s_root); s_lines.Clear(); } if ((Object)(object)s_mat == (Object)null) { s_mat = new Material(Shader.Find("Sprites/Default")); } while (s_lines.Count <= i) { GameObject val = new GameObject("ray"); val.transform.SetParent(s_root.transform, false); LineRenderer val2 = val.AddComponent<LineRenderer>(); val2.positionCount = 2; float startWidth = (val2.endWidth = 0.03f); val2.startWidth = startWidth; ((Renderer)val2).material = s_mat; val2.useWorldSpace = true; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; s_lines.Add(val2); } return s_lines[i]; } private static void Hide(int from) { for (int i = from; i < s_lines.Count; i++) { if ((Object)(object)s_lines[i] != (Object)null) { ((Component)s_lines[i]).gameObject.SetActive(false); } } } } internal static class Sky { private static Dictionary<string, SkySettings> s_overrides; private static string s_overrideText; private static FieldInfo s_maskField; private static bool s_warnedFailure; internal static void Invalidate() { s_overrides = null; } internal static SkySettings Defaults() { return new SkySettings { MaxHeight = Cfg.MaxRoofHeight.Value, Rays = Cfg.RingRays.Value, Radius = Cfg.RingRadius.Value, TiltDeg = Cfg.RingTilt.Value, SharePercent = Cfg.BlockedShare.Value, Off = false }; } internal static string PrefabName(Plant p) { string name = ((Object)((Component)p).gameObject).name; int num = name.IndexOf("(Clone)", StringComparison.Ordinal); return ((num >= 0) ? name.Substring(0, num) : name).Trim(); } internal static SkySettings Resolve(Plant p) { SkySettings skySettings = Defaults(); string text = Cfg.PerPlant.Value ?? ""; if (s_overrides == null || s_overrideText != text) { List<string> list = new List<string>(); s_overrides = SkyRule.ParseOverrides(text, skySettings, list); s_overrideText = text; foreach (string item in list) { Plugin.Log.LogWarning((object)("PerPlantOverrides: " + item)); } } if (!s_overrides.TryGetValue(PrefabName(p), out var value)) { return skySettings; } return value; } internal static int Mask() { if (s_maskField == null) { s_maskField = AccessTools.Field(typeof(Plant), "m_roofMask"); } int num = ((s_maskField != null) ? ((int)s_maskField.GetValue(null)) : 0); if (num == 0) { return LayerMask.GetMask(new string[3] { "Default", "static_solid", "piece" }); } return num; } internal static SkyResult Check(Plant p, SkySettings s) { //IL_000d: 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) Vector3 origin = ((Component)p).transform.position; int mask = Mask(); return SkyRule.Evaluate(s, (SkyRay ray) => Physics.Raycast(origin + new Vector3(ray.Dx, 0f, ray.Dz), new Vector3(ray.Ux, ray.Uy, ray.Uz), ray.Length, mask)); } internal static void Fail(Exception e) { if (!s_warnedFailure) { s_warnedFailure = true; Plugin.Log.LogError((object)("Sky check failed, using the game's own result from now on for failing plants: " + e)); } } } [HarmonyPatch(typeof(Plant), "HaveRoof")] internal static class HaveRoofPatch { private static void Postfix(Plant __instance, ref bool __result) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!__result || !Cfg.Enabled.Value) { return; } try { SkySettings s = Sky.Resolve(__instance); SkyResult skyResult = Sky.Check(__instance, s); if (Cfg.LogDecisions.Value) { ManualLogSource log = Plugin.Log; string[] obj = new string[15] { Sky.PrefabName(__instance), " at ", null, null, null, null, null, null, null, null, null, null, null, null, null }; Vector3 position = ((Component)__instance).transform.position; obj[2] = ((Vector3)(ref position)).ToString("0.0"); obj[3] = ": "; obj[4] = skyResult.Hits.ToString(); obj[5] = "/"; obj[6] = skyResult.Total.ToString(); obj[7] = " rays hit within "; obj[8] = s.MaxHeight.ToString("0.#"); obj[9] = " m (tilt "; obj[10] = s.TiltDeg.ToString("0.#"); obj[11] = "), need "; obj[12] = s.SharePercent.ToString("0.#"); obj[13] = "% -> "; obj[14] = (s.Off ? "never needs sky" : (skyResult.Roofed ? "roofed" : "OPEN")); log.LogInfo((object)string.Concat(obj)); } __result = skyResult.Roofed; } catch (Exception e) { Sky.Fail(e); } } } internal struct SkySettings { public float MaxHeight; public int Rays; public float Radius; public float TiltDeg; public float SharePercent; public bool Off; } internal struct SkyRay { public float Dx; public float Dz; public float Ux; public float Uy; public float Uz; public float Length; } internal struct SkyResult { public bool Roofed; public int Hits; public int Total; public bool[] Hit; } internal static class SkyRule { public static int Total(SkySettings s) { return 1 + Math.Max(0, s.Rays); } public static void Offset(SkySettings s, int i, out float dx, out float dz) { if (i <= 0 || s.Rays <= 0) { dx = 0f; dz = 0f; } else { double num = (double)(i - 1) * (Math.PI * 2.0 / (double)s.Rays); dx = (float)(Math.Cos(num) * (double)s.Radius); dz = (float)(Math.Sin(num) * (double)s.Radius); } } public static SkyRay Ray(SkySettings s, int i) { SkyRay result = default(SkyRay); Offset(s, i, out result.Dx, out result.Dz); double num = ((i <= 0 || s.Rays <= 0) ? 0.0 : (Math.Max(0.0, Math.Min(80.0, s.TiltDeg)) * Math.PI / 180.0)); double num2 = Math.Sin(num); double num3 = Math.Cos(num); double num4 = Math.Sqrt(result.Dx * result.Dx + result.Dz * result.Dz); double num5 = ((num4 > 1E-06) ? ((double)result.Dx / num4) : 0.0); double num6 = ((num4 > 1E-06) ? ((double)result.Dz / num4) : 0.0); result.Ux = (float)(num5 * num2); result.Uz = (float)(num6 * num2); result.Uy = (float)num3; result.Length = (float)((double)s.MaxHeight / num3); return result; } public static SkyResult Evaluate(SkySettings s, Func<SkyRay, bool> hit) { SkyResult result = default(SkyResult); if (s.Off) { result.Total = 0; result.Hit = new bool[0]; result.Roofed = false; return result; } result.Total = Total(s); result.Hit = new bool[result.Total]; for (int i = 0; i < result.Total; i++) { bool flag = hit(Ray(s, i)); result.Hit[i] = flag; if (flag) { result.Hits++; } } result.Roofed = (float)result.Hits * 100f >= s.SharePercent * (float)result.Total - 0.0001f; return result; } public static Dictionary<string, SkySettings> ParseOverrides(string text, SkySettings defaults, List<string> errors) { Dictionary<string, SkySettings> dictionary = new Dictionary<string, SkySettings>(StringComparer.OrdinalIgnoreCase); if (string.IsNullOrEmpty(text)) { return dictionary; } string[] array = text.Split(new char[3] { ',', ';', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length == 0) { continue; } string[] array2 = text2.Split(':'); string text3 = array2[0].Trim(); if (text3.Length == 0 || array2.Length < 2) { errors?.Add("'" + text2 + "': expected prefab:height[:share] or prefab:off"); continue; } SkySettings value = defaults; if (array2.Length == 2 && array2[1].Trim().Equals("off", StringComparison.OrdinalIgnoreCase)) { value.Off = true; dictionary[text3] = value; continue; } if (!float.TryParse(array2[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || result <= 0f) { errors?.Add("'" + text2 + "': height must be a number above 0"); continue; } value.MaxHeight = result; if (array2.Length >= 3) { if (!float.TryParse(array2[2].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) || result2 <= 0f || result2 > 100f) { errors?.Add("'" + text2 + "': share must be 1-100"); continue; } value.SharePercent = result2; } dictionary[text3] = value; } return dictionary; } }
plugins/EinsteinCrew-PuckosCarePackage/Pucko-VineWrap/VineWrap.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace Pucko.VineWrap; internal static class Cfg { public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> SpawnWraps; public static ConfigEntry<bool> SurfaceCheck; public static ConfigEntry<bool> AlignToEdge; public static ConfigEntry<bool> RequireSamePiece; public static ConfigEntry<bool> LogProbes; public static ConfigEntry<bool> ShowProbes; public static ConfigEntry<bool> Deterministic; public static ConfigEntry<bool> SlideAlongEdge; public static ConfigEntry<float> RoofTilt; public static ConfigEntry<float> TipRelief; public static ConfigEntry<bool> RoofEdgeSearch; public static ConfigEntry<bool> ReliefOn; public static ConfigEntry<float> RoofMaxMidEdge; public static ConfigEntry<float> AgeDays; public static ConfigEntry<float> AgedCrowding; public static ConfigEntry<float> AgedMinSurface; public static ConfigEntry<float> AgedMinRun; public static ConfigEntry<float> AgedMaxMidEdge; public static ConfigEntry<float> PretendAgeDays; public static ConfigEntry<float> AgeSpeed; public static ConfigEntry<float> RecheckSeconds; public static ConfigEntry<float> CoverRadius; public static ConfigEntry<float> MaxMidEdge; public static ConfigEntry<float> UnderAngle; public static ConfigEntry<float> MinTurn; public static ConfigEntry<float> MaxTurn; public static ConfigEntry<float> Fluff; public static ConfigEntry<float> Reach; public static ConfigEntry<float> Variety; public static ConfigEntry<float> Runs; public static ConfigEntry<float> Patchiness; public static ConfigEntry<float> Narrowing; public static ConfigEntry<float> Crowding; public static ConfigEntry<float> WrapAmount; public static ConfigEntry<float> MixShare; public static ConfigEntry<float> CornerMinEdge; public static ConfigEntry<WrapStyle> Style; public static ConfigEntry<WrapStyle> ThickStyle; public static ConfigEntry<float> SeamOverlap; public static ConfigEntry<float> SurfaceLift; public static ConfigEntry<float> ScaleBoost; public static ConfigEntry<float> ScaleShift; public static ConfigEntry<float> MitreTurn; public static ConfigEntry<float> MitreLift; public static ConfigEntry<float> MitreSlide; public static ConfigEntry<float> WidthMargin; public static ConfigEntry<float> MinWidthScale; public static ConfigEntry<float> MinRun; public static ConfigEntry<float> MinSurface; public static ConfigEntry<float> SurfaceTolerance; public static ConfigEntry<float> ShowSeconds; public static ConfigEntry<WrapDir> Directions; public static ConfigEntry<SeamMethod> Method; public static ConfigEntry<WidthFit> Fit; public static ConfigEntry<string> Plants; public static ConfigEntry<string> PieceAllow; public static ConfigEntry<string> PieceDeny; public static ConfigEntry<string> SizeExempt; public static ConfigEntry<string> RoofList; public static ConfigEntry<KeyboardShortcut> FlatKey; public static ConfigEntry<Character> CharacterPick; public static ConfigEntry<GrowthMode> Growth; public static ConfigEntry<AgeCurve> Curve; public static ConfigEntry<float> Thickness; public static ConfigEntry<float> Drape; public static ConfigEntry<float> Spread; public static ConfigEntry<float> AgeFastShare; public static ConfigEntry<float> AgeSlowDays; public static ConfigEntry<float> RandomBaseChance; public static ConfigEntry<float> GapErode; public static ConfigEntry<bool> LineageAge; public static ConfigEntry<bool> DrapeEnabled; public static ConfigEntry<bool> DrapeUnder; public static ConfigEntry<bool> DrapeHang; public static ConfigEntry<bool> LeadEnabled; public static ConfigEntry<bool> CapsEnabled; public static ConfigEntry<float> DrapeChance; public static ConfigEntry<float> LeadChance; public static ConfigEntry<float> HangTaper; public static ConfigEntry<float> DrapeAgeBonus; public static ConfigEntry<float> LeadAgeBonus; public static ConfigEntry<float> AreaRadius; public static ConfigEntry<float> StatsMinutes; public static ConfigEntry<int> DrapeLength; public static ConfigEntry<int> LeadSteps; public static ConfigEntry<int> MaxCellsPerPiece; public static ConfigEntry<int> MaxCellsPerArea; public static ConfigEntry<int> MaxLoadedCells; private static ConfigurationManagerAttributes AdminTag() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true }; } private static ConfigEntry<T> Adm<T>(ConfigFile c, string s, string k, T v, string d, AcceptableValueBase av = null) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown return c.Bind<T>(s, k, v, new ConfigDescription(d, av, new object[1] { AdminTag() })); } private static AcceptableValueRange<float> R(float a, float b) { return new AcceptableValueRange<float>(a, b); } public static void Bind(ConfigFile c) { //IL_0d20: Unknown result type (might be due to invalid IL or missing references) //IL_0d93: Unknown result type (might be due to invalid IL or missing references) //IL_0d9d: Expected O, but got Unknown //IL_0dcb: Unknown result type (might be due to invalid IL or missing references) //IL_0dd5: Expected O, but got Unknown CharacterPick = Adm(c, "0 - Character", "Character", Character.OvergrownMax, "Growth character, on top of Style. Custom = the sliders in '0 - Look' and the drape/lead values in section 8, exactly as set (the 0.8.x behaviour plus drape and lead vines). Tidy = about the 0.8.x look, no drape, no lead vines. Overgrown = thick and dense, spreads wide. Curtain = drapes down from edges and overhangs. Creeper = long thin sideways runs. Ruin = an uneven mix with bare patches. OvergrownRoofline / OvergrownStretch / OvergrownCreep = Overgrown plus the roof fix / full-width stretching / long leads and tip relief. OvergrownMax (default since 0.9.2) = all of those at once. Any choice except Custom replaces the '0 - Look' sliders Fluff, Reach, Variety, Runs, Patchiness, Narrowing, Crowding and WrapAmount."); Thickness = Adm(c, "0 - Character", "Thickness", 50f, "Slider 0-100, 50 = the character as designed. Higher = fuller wraps that stand off more, reach further, overlap more, stay wider and leave fewer gaps.", (AcceptableValueBase)(object)R(0f, 100f)); Drape = Adm(c, "0 - Character", "Drape", 50f, "Slider 0-100, 50 = the character as designed. How often and how far vines drape down over overhangs and hang below edges. 0 = no drape.", (AcceptableValueBase)(object)R(0f, 100f)); Spread = Adm(c, "0 - Character", "SpreadDistance", 50f, "Slider 0-100, 50 = the character as designed. How often a sideways run becomes a lead vine and how far it pushes past the game's own width limit. 0 = no lead vines.", (AcceptableValueBase)(object)R(0f, 100f)); Growth = Adm(c, "0 - Character", "GrowthMode", GrowthMode.Random, "Random (default): each recheck of a refused edge is a fresh roll, and the chance and reach rise with the vine's age; looks stay tied to the spot, so a grown cell keeps its look. Classic = 0.8.x (the Deterministic switch in section 1 decides)."); Style = Adm(c, "0 - Look", "Style", WrapStyle.Natural, "How the vine turns a corner. Natural = folded round the edge (Hinge). Corners = a chamfered Mitre cell on thick pieces (stone, marble), folded Hinge on slim beams. Mixed = mostly Hinge, with MixShare % of the wraps using the other methods for variety. Custom = the SeamMethod in section 3."); Fluff = Adm(c, "0 - Look", "Fluff", 50f, "Slider 0-100, used when Character = Custom (a preset replaces it). How far the wrap stands off the surface. 0 = pressed flat against it, 50 = as in 0.4.0, 100 = a fuller, bushier look.", (AcceptableValueBase)(object)R(0f, 100f)); Reach = Adm(c, "0 - Look", "Reach", 50f, "Slider 0-100, used when Character = Custom (a preset replaces it). How far the wrap spreads across the side face. 0 = stops short of the far end, 50 = as in 0.4.0, 100 = spills over the far edge. Does not change Mitre cells.", (AcceptableValueBase)(object)R(0f, 100f)); Variety = Adm(c, "0 - Look", "Variety", 60f, "Slider 0-100, used when Character = Custom (a preset replaces it). How much each cell differs from the next: size (+-30 % at 100), reach (+-0.3 m), a small stand-off change (always toward the surface) and a twist of up to 20 degrees. The same spot always gets the same look. 0 = every wrap identical.", (AcceptableValueBase)(object)R(0f, 100f)); Runs = Adm(c, "0 - Look", "Runs", 50f, "Slider 0-100, used when Character = Custom (a preset replaces it). Thick and thin runs: all the wraps round one piece (a beam, a post) share a size and reach, and different pieces differ: some runs lean, some heavy. 0 = every run the same.", (AcceptableValueBase)(object)R(0f, 100f)); Patchiness = Adm(c, "0 - Look", "Patchiness", 20f, "Slider 0-100, used when Character = Custom (a preset replaces it). Bare gaps: the world is split into 2 m patches and a share of them stays unwrapped (at 100, half of them). Gaps are decided per patch, so the same place is always bare. 0 = no gaps.", (AcceptableValueBase)(object)R(0f, 100f)); ThickStyle = Adm(c, "0 - Look", "ThickStyle", WrapStyle.Corners, "Style for thick pieces (stone and marble walls, middle edge at least CornerMinEdge). Beams and posts use Style. Corners = Mitre chamfer, Natural = folded Hinge, Mixed = a mix."); Narrowing = Adm(c, "0 - Look", "Narrowing", 40f, "Slider 0-100, used when Character = Custom (a preset replaces it). Cells the game grows after a wrap on a slim piece: 0 = full width again (spreads widest, can stick out), 100 = keep the wrap's narrow width (tidy, spreads least).", (AcceptableValueBase)(object)R(0f, 100f)); Crowding = Adm(c, "0 - Look", "Crowding", 60f, "Slider 0-100, used when Character = Custom (a preset replaces it). How close to other vines a wrap may grow. 0 = the game's own rule (any overlap with another vine blocks it), 100 = other vines never block a wrap (they overlap and thicken). Pieces always block.", (AcceptableValueBase)(object)R(0f, 100f)); WrapAmount = Adm(c, "0 - Look", "WrapAmount", 100f, "Slider 0-100, used when Character = Custom (a preset replaces it). Share of the wrappable edges that are wrapped. Decided per spot, not by chance: the same edge always gets the same answer. 100 = every one.", (AcceptableValueBase)(object)R(0f, 100f)); Enabled = Adm(c, "1 - General", "Enabled", v: true, "Master switch for the whole mod (probe and wrap)."); SpawnWraps = Adm(c, "1 - General", "SpawnWraps", v: true, "On: a vine that reaches the edge of an allowed piece grows a cell onto the side face. Off: only probe, log and draw."); SurfaceCheck = Adm(c, "1 - General", "SurfaceCheck", v: true, "On (default): a wrap only grows where a real surface is under the new cell (9 sample rays; the centre and MinSurface of them must hit a piece at the right depth and angle). Off: no check, cells can end up in the air; for experiments only."); MinSurface = Adm(c, "1 - General", "MinSurface", 0.55f, "Share of the 9 surface samples that must hit (the centre one always must). Higher = stricter.", (AcceptableValueBase)(object)R(0.1f, 1f)); Deterministic = Adm(c, "1 - General", "Deterministic", v: true, "GrowthMode Classic only. On (default, as 0.5.0-0.7.0): every choice is a stable hash of the spot, so the same edge always gets the same answer and the same look, and a wrappable edge wraps at its next growth check. Off (as 0.4.0): WrapAmount, the Mixed style and each cell's looks (size, reach, stand-off, twist) are rolled again at every growth check, and the vine's own growth chance is rolled before a wrap, so wraps come at the normal growth pace. Patchiness gaps and Runs stay tied to the place in both modes."); SurfaceTolerance = Adm(c, "1 - General", "SurfaceTolerance", 0.2f, "How far, in metres, a sample's hit may be from the expected surface depth and still count.", (AcceptableValueBase)(object)R(0.02f, 0.5f)); Plants = Adm(c, "2 - Wrap policy", "Plants", "VineGreen,VineAsh", "Which vines wrap: comma separated parts of the vine prefab name (VineGreen = Ivy, VineAsh = Ashvine). Empty = all."); MaxMidEdge = Adm(c, "2 - Wrap policy", "MaxMidEdge", 0.8f, "Only pieces whose middle edge is at most this many metres are wrapped (a beam is 0.3-0.7). Wider walls and floors keep flat vines.", (AcceptableValueBase)(object)R(0.1f, 4f)); SizeExempt = Adm(c, "2 - Wrap policy", "SizeExemptList", "stone,blackmarble", "Pieces whose name contains one of these comma separated parts are wrapped whatever their size, so the corners of stone and marble walls get vines too. Flat wall faces stay flat either way; this only affects where a vine reaches an edge."); RoofList = Adm(c, "2 - Wrap policy", "RoofList", "roof", "Pieces whose name contains one of these comma separated parts count as roofs: they may be wrapped up to RoofMaxMidEdge wide, so a vine can turn over a roof edge or ridge onto the next roof piece and blend in. Empty = no roof rule."); RoofMaxMidEdge = Adm(c, "2 - Wrap policy", "RoofMaxMidEdge", 2.5f, "Largest middle edge in metres for RoofList pieces (a 2 m roof panel has 2.0). The surface check still applies.", (AcceptableValueBase)(object)R(0.1f, 4f)); PieceAllow = Adm(c, "2 - Wrap policy", "PieceAllowList", "", "Only wrap pieces whose name contains one of these comma separated parts (e.g. beam,pole). Empty = any piece that passes the size rule."); PieceDeny = Adm(c, "2 - Wrap policy", "PieceDenyList", "", "Never wrap pieces whose name contains one of these comma separated parts (e.g. stone,marble)."); Directions = Adm(c, "2 - Wrap policy", "WrapDirections", WrapDir.Sideways | WrapDir.Over, "Which way a vine may turn: Sideways = round a side edge, Over = over a top edge onto an upward face, Under = onto a downward face (underside of a beam or overhang)."); UnderAngle = Adm(c, "2 - Wrap policy", "UnderAngle", 20f, "A new face tilted down by less than this many degrees still counts as Sideways, not Under.", (AcceptableValueBase)(object)R(0f, 80f)); MinTurn = Adm(c, "2 - Wrap policy", "MinTurnAngle", 20f, "Edge type: smallest bend between the old and the new face that counts as an edge to wrap (a nearly flat join is ignored).", (AcceptableValueBase)(object)R(0f, 180f)); MaxTurn = Adm(c, "2 - Wrap policy", "MaxTurnAngle", 120f, "Edge type: largest bend that is wrapped (90 = square corner; higher also wraps sharp roof ridges).", (AcceptableValueBase)(object)R(0f, 180f)); RequireSamePiece = Adm(c, "2 - Wrap policy", "RequireSamePiece", v: false, "On: only wrap when the face the vine sits on and the side face are the same piece. Off (default): vines may also wrap where a beam meets a wall."); MixShare = Adm(c, "3 - Seam tuning", "MixShare", 30f, "Style Mixed only: the share of wraps in % that use HingeScale or Mitre instead of Hinge.", (AcceptableValueBase)(object)R(0f, 100f)); CornerMinEdge = Adm(c, "3 - Seam tuning", "CornerMinEdge", 0.8f, "Style Corners only: pieces whose middle edge is at least this many metres (stone, marble walls) get Mitre cells.", (AcceptableValueBase)(object)R(0.2f, 4f)); CoverRadius = Adm(c, "3 - Seam tuning", "CoverRadius", 0.35f, "A wrap is not grown where another vine cell already sits on the same face within this distance (stops one spot being wrapped again and again). 0.75 (0.8.0) also blocked normal neighbours and stopped sheets spreading; lower = more wraps, 0 = guard off.", (AcceptableValueBase)(object)R(0f, 1.5f)); SlideAlongEdge = Adm(c, "3 - Seam tuning", "SlideAlongEdge", v: true, "Hinge methods: when the side face does not continue at the middle of the new cell (near the top or end of a post or beam), try lines further along the edge and slide the cell (up to about 0.7 m) so it sits on the face. Off = 0.7.0 behaviour."); AlignToEdge = Adm(c, "3 - Seam tuning", "AlignToEdge", v: true, "Hinge methods: turn the new cell so its long side is parallel to the edge it wrapped round (at most 45 degrees), so it follows a slanted post instead of drifting off it."); Method = Adm(c, "3 - Seam tuning", "SeamMethod", SeamMethod.Hinge, "Used when Style is Custom. Hinge = the next cell is folded round the edge onto the side face. HingeScale = hinge, shifted by HingeScaleShift and scaled by ScaleBoost to cover the seam. Mitre = one cell over the edge, tilted by MitreTurn of the full bend."); SeamOverlap = Adm(c, "3 - Seam tuning", "SeamOverlap", 0f, "All methods except Mitre: moves the new cell toward the edge by this many metres (negative = away).", (AcceptableValueBase)(object)R(-0.5f, 1f)); SurfaceLift = Adm(c, "3 - Seam tuning", "SurfaceLift", 0f, "All methods: moves the new cell out from the surface by this many metres.", (AcceptableValueBase)(object)R(-0.3f, 0.5f)); ScaleShift = Adm(c, "3 - Seam tuning", "HingeScaleShift", 0.15f, "HingeScale only: extra move toward the edge in metres.", (AcceptableValueBase)(object)R(-0.5f, 1f)); ScaleBoost = Adm(c, "3 - Seam tuning", "ScaleBoost", 1.15f, "HingeScale only: scale of the new cell (1 = none). Saved with the vine.", (AcceptableValueBase)(object)R(0.5f, 2f)); MitreTurn = Adm(c, "3 - Seam tuning", "MitreTurn", 0.5f, "Mitre only: how much of the bend the cell is tilted (0.5 = a 45 degree chamfer over a square corner).", (AcceptableValueBase)(object)R(0f, 1f)); MitreLift = Adm(c, "3 - Seam tuning", "MitreLift", 0f, "Mitre only: moves the cell out from the corner along the bisector, in metres.", (AcceptableValueBase)(object)R(-0.3f, 0.6f)); MitreSlide = Adm(c, "3 - Seam tuning", "MitreSlide", 0.4f, "Mitre only: moves the cell along its growth direction, in metres.", (AcceptableValueBase)(object)R(-1f, 1.5f)); Fit = Adm(c, "4 - Width fit", "WidthFit", WidthFit.Scale, "Scale (default): when the side face is shorter than a full cell, the new cell is shrunk across that face to the face's length plus WidthMargin and starts at the edge. Off: the cell keeps its size (it then usually fails the surface check on slim pieces). Saved with the vine."); WidthMargin = Adm(c, "4 - Width fit", "WidthMargin", 0.3f, "Extra length in metres on top of the face's length, so the vine covers the edges (half on each side).", (AcceptableValueBase)(object)R(-0.2f, 2f)); MinWidthScale = Adm(c, "4 - Width fit", "MinWidthScale", 0.1f, "Never shrink a cell below this scale.", (AcceptableValueBase)(object)R(0.05f, 1f)); MinRun = Adm(c, "4 - Width fit", "MinRun", 0.25f, "A side face that runs less than this many metres from the edge is not wrapped.", (AcceptableValueBase)(object)R(0.1f, 2f)); AgeDays = Adm(c, "6 - Age", "AgeDays", 3f, "Length of the first, fast age stage in in-game days (1 day = 30 min real). A vine gets more persistent at edges the older it is: its rules move from the normal values toward the Aged values below. AgeCurve Linear: fully aged after AgeDays (0.8.x). TwoStage: AgeFastShare of the way after AgeDays, then the rest over AgeSlowDays. 0 = age off. Pieces always block and the surface check always applies; nothing grows into open air.", (AcceptableValueBase)(object)R(0f, 30f)); AgedCrowding = Adm(c, "6 - Age", "AgedCrowding", 100f, "Crowding a fully aged cell uses (only ever looser than Crowding).", (AcceptableValueBase)(object)R(0f, 100f)); AgedMinSurface = Adm(c, "6 - Age", "AgedMinSurface", 0.4f, "MinSurface a fully aged cell uses (the centre sample must still hit).", (AcceptableValueBase)(object)R(0.3f, 1f)); AgedMinRun = Adm(c, "6 - Age", "AgedMinRun", 0.1f, "MinRun a fully aged cell uses.", (AcceptableValueBase)(object)R(0.1f, 2f)); AgedMaxMidEdge = Adm(c, "6 - Age", "AgedMaxMidEdge", 2.5f, "MaxMidEdge a fully aged cell uses, so roofs and wide walls become wrappable with time.", (AcceptableValueBase)(object)R(0.1f, 4f)); PretendAgeDays = Adm(c, "6 - Age", "PretendAgeDays", -1f, "Testing aid: treat every stuck cell as this many in-game days old (e.g. 3 = fully aged at once). -1 = use the real age.", (AcceptableValueBase)(object)R(-1f, 3650f)); Curve = Adm(c, "6 - Age", "AgeCurve", AgeCurve.TwoStage, "TwoStage (default): a fast first stage over AgeDays, then a slow second stage over weeks to years that never quite flattens. Linear = 0.8.x (fully aged after AgeDays)."); AgeFastShare = Adm(c, "6 - Age", "AgeFastShare", 0.4f, "TwoStage: how much of the aging happens in the first stage (0.4 = 40 % after AgeDays).", (AcceptableValueBase)(object)R(0f, 1f)); AgeSlowDays = Adm(c, "6 - Age", "AgeSlowDays", 180f, "TwoStage: time scale of the slow stage in in-game days. After AgeDays + AgeSlowDays a vine has 63 % of the slow stage, after 3x AgeSlowDays 95 %. 180 = about half a game year (a server running 24/7 gives 48 game days per real day).", (AcceptableValueBase)(object)R(0f, 3650f)); LineageAge = Adm(c, "6 - Age", "LineageAge", v: true, "On: a cell counts as old as its vine (cells remember the age of the cell they grew from), so the growing tips of an old vine spread like an old vine. Off = each cell's own age (0.8.x). Cells grown before 0.9.0 start from their own age."); AgeSpeed = Adm(c, "6 - Age", "AgeSpeed", 1f, "Testing aid: every cell counts as this many times older than it really is (1 = real time). With 1 in-game day = 30 min, 48 makes a real day count as 48 in-game days. Unlike PretendAgeDays it keeps cells different from each other.", (AcceptableValueBase)(object)R(1f, 100000f)); RandomBaseChance = Adm(c, "7 - Random growth", "RandomBaseChance", 0.35f, "GrowthMode Random: chance that one recheck of a refused edge tries again for a young vine. Rises to 1 with age. The rules of that try are relaxed by a random share of the vine's age.", (AcceptableValueBase)(object)R(0f, 1f)); GapErode = Adm(c, "7 - Random growth", "GapErode", 0.5f, "GrowthMode Random: how much old vines grow into the bare patches (Patchiness). 0 = gaps stay bare for good, 0.5 = a fully aged vine fills half its tries into a gap.", (AcceptableValueBase)(object)R(0f, 1f)); DrapeEnabled = Adm(c, "8 - Drape and lead vines", "DrapeEnabled", v: true, "Master switch for draping (both parts below). Off = Under stays as WrapDirections says and nothing hangs."); DrapeUnder = Adm(c, "8 - Drape and lead vines", "DrapeUnder", v: true, "A vine may wrap onto the underside of a beam or overhang (the 'Under' direction) even when WrapDirections does not list Under. Same surface check as any wrap."); DrapeHang = Adm(c, "8 - Drape and lead vines", "DrapeHang", v: true, "A vine growing down past the bottom edge of a piece, with open air below, may hang cells in the air below the edge, like a curtain (up to the drape length). Pieces and the ground still block."); DrapeChance = Adm(c, "8 - Drape and lead vines", "DrapeChance", 0.3f, "Character Custom: chance per try that a drape (Under or hanging) is attempted. Presets set their own.", (AcceptableValueBase)(object)R(0f, 1f)); DrapeLength = Adm(c, "8 - Drape and lead vines", "DrapeLength", 2, "Character Custom: how many cells may hang below an edge. Presets set their own.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8)); HangTaper = Adm(c, "8 - Drape and lead vines", "HangTaper", 0.08f, "Each hanging cell is this much smaller than the one above it (0.08 = 8 %).", (AcceptableValueBase)(object)R(0f, 0.5f)); DrapeAgeBonus = Adm(c, "8 - Drape and lead vines", "DrapeAgeBonus", 1f, "Hanging length grows with age: x(1 + age relax * this). 1 = a fully aged vine hangs twice as far.", (AcceptableValueBase)(object)R(0f, 3f)); LeadEnabled = Adm(c, "8 - Drape and lead vines", "LeadEnabled", v: true, "Lead vines: a cell grown sideways may become a lead that keeps its heading and pushes past the game's own width limit (about 3 m either side of where the vine started) for up to the lead length, also round corners."); LeadChance = Adm(c, "8 - Drape and lead vines", "LeadChance", 0.15f, "Character Custom: chance that a new sideways cell starts a lead run. Presets set their own.", (AcceptableValueBase)(object)R(0f, 0.8f)); LeadSteps = Adm(c, "8 - Drape and lead vines", "LeadSteps", 4, "Character Custom: how many cells a lead run may push before it may stop. Presets set their own.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 16)); LeadAgeBonus = Adm(c, "8 - Drape and lead vines", "LeadAgeBonus", 1f, "Lead length grows with age: x(1 + age relax * this). 1 = a fully aged vine pushes twice as far.", (AcceptableValueBase)(object)R(0f, 3f)); CapsEnabled = Adm(c, "9 - Caps", "CapsEnabled", v: true, "Server health: stop the mod's own growth (wraps, drapes, lead pushes) when a cap below is reached. The game's normal vine growth is not capped. A cap stop is written to the log."); MaxCellsPerPiece = Adm(c, "9 - Caps", "MaxCellsPerPiece", 40, "Most vine cells on and around one piece (its bounds plus 1 m). 0 = no cap.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000)); MaxCellsPerArea = Adm(c, "9 - Caps", "MaxCellsPerArea", 250, "Most vine cells within AreaRadius of a new cell. 0 = no cap.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5000)); AreaRadius = Adm(c, "9 - Caps", "AreaRadius", 8f, "Radius in metres for MaxCellsPerArea.", (AcceptableValueBase)(object)R(2f, 32f)); MaxLoadedCells = Adm(c, "9 - Caps", "MaxLoadedCells", 4000, "Most vine cells loaded around the growing player (all vines in the loaded area). 0 = no cap.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50000)); RoofTilt = Adm(c, "10 - Roofs and old tips (0.9.1)", "RoofTilt", 30f, "Degrees a roof piece's surface may tilt away from the expected face before the surface check refuses it. 30 = 0.9.0. The Overgrown Roofline and Max characters use 50 instead.", (AcceptableValueBase)(object)R(20f, 70f)); RoofEdgeSearch = Adm(c, "10 - Roofs and old tips (0.9.1)", "RoofEdgeSearch", v: false, "On: when no side face is found next to a roof piece (RoofList), search wider and deeper for the next roof panel. Off = 0.9.0. The Roofline and Max characters switch it on by themselves."); ReliefOn = Adm(c, "10 - Roofs and old tips (0.9.1)", "TipReliefEnabled", v: true, "Master switch for tip relief (the strength comes from the character or TipRelief)."); TipRelief = Adm(c, "10 - Roofs and old tips (0.9.1)", "TipRelief", 0f, "0-1. Old vines close their growing tips less often: the game's chance of closing a tip is scaled by 1 - TipRelief x the vine's age share (young vines are not affected). 0 = off (0.9.0). The Stretch, Creep and Max characters set their own.", (AcceptableValueBase)(object)R(0f, 1f)); RecheckSeconds = Adm(c, "5 - Debug and tools", "RecheckSeconds", 20f, "A cell whose wrap was refused is probed again in that direction only after this many seconds (saves work: the same edge gives the same answer). 0 = probe at every growth check (0.7.0).", (AcceptableValueBase)(object)R(0f, 300f)); FlatKey = c.Bind<KeyboardShortcut>("5 - Debug and tools", "FlatKey", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "Look at a vine cell and press this key to mark it (and the cells that grow from it) to stay flat, or unmark it. None = off. Local key; the mark is saved with the vine."); LogProbes = c.Bind<bool>("5 - Debug and tools", "LogProbes", true, "Write one log line per probe (piece, size, direction, verdict). Local only."); ShowProbes = c.Bind<bool>("5 - Debug and tools", "ShowProbes", true, "Draw each probe in the world: white = the vine's step, yellow = the search ray, green/red = allowed/refused, blue arrow = new face normal, red/green/blue axes = the new cell. Local only."); StatsMinutes = c.Bind<float>("5 - Debug and tools", "StatsMinutes", 5f, new ConfigDescription("Every this many minutes write one summary line (wraps, drapes, lead pushes, cap stops, random tries) when LogProbes is on. 0 = off. Local only.", (AcceptableValueBase)(object)R(0f, 120f), Array.Empty<object>())); ShowSeconds = c.Bind<float>("5 - Debug and tools", "ShowSeconds", 10f, new ConfigDescription("How long a drawn probe stays visible.", (AcceptableValueBase)(object)R(1f, 120f), Array.Empty<object>())); } } internal static class VineData { internal const string FlatKey = "pucko_vw_flat"; internal const string SX = "pucko_vw_sx"; internal const string SY = "pucko_vw_sy"; internal const string SZ = "pucko_vw_sz"; private static readonly FieldInfo FView = AccessTools.Field(typeof(Vine), "m_nview"); private static readonly FieldInfo FAll = AccessTools.Field(typeof(Vine), "s_allVines"); private static readonly MethodInfo MGetOff = AccessTools.Method(typeof(Vine), "GetOriginOffset", (Type[])null, (Type[])null); private static readonly MethodInfo MSetOff = AccessTools.Method(typeof(Vine), "SetOriginOffset", (Type[])null, (Type[])null); internal static ZDO Zdo(Vine v) { ZNetView val = (ZNetView)((FView != null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val != (Object)null) || !val.IsValid()) { return null; } return val.GetZDO(); } internal static bool IsFlat(Vine v) { ZDO val = Zdo(v); if (val != null) { return val.GetBool("pucko_vw_flat", false); } return false; } internal static void SetFlat(Vine v, bool on) { ZDO val = Zdo(v); if (val != null) { val.Set("pucko_vw_flat", on); } } internal static Vine NewestNear(Vine parent, Vector3 near, float radius) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) List<Vine> list = ((FAll != null) ? (FAll.GetValue(null) as List<Vine>) : null); if (list == null || list.Count == 0) { return null; } Vine val = list[list.Count - 1]; if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)parent) { return null; } Vector3 val2 = ((Component)val).transform.position - near; if (!(((Vector3)(ref val2)).sqrMagnitude <= radius * radius)) { return null; } return val; } internal static bool CoveredAt(Vine parent, Vector3 pos, Vector3 normal, float radius) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) List<Vine> list = ((FAll != null) ? (FAll.GetValue(null) as List<Vine>) : null); if (list == null) { return false; } float num = radius * radius; for (int num2 = list.Count - 1; num2 >= 0; num2--) { Vine val = list[num2]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)parent)) { Transform transform = ((Component)val).transform; Vector3 val2 = transform.position - pos; if (!(((Vector3)(ref val2)).sqrMagnitude > num) && WrapPolicy.Covers(((Vector3)(ref val2)).magnitude, Mathf.Abs(Vector3.Dot(transform.right, normal)), radius)) { return true; } } } return false; } internal static void AddOriginOffset(Vine child, Vector3 add) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_003d: Unknown result type (might be due to invalid IL or missing references) if (!(MGetOff == null) && !(MSetOff == null)) { Vector3 val = (Vector3)MGetOff.Invoke(child, null); MSetOff.Invoke(child, new object[1] { val + add }); } } internal static void ApplyScale(Vine c, Vector3 scale) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) ((Component)c).transform.localScale = scale; ZDO val = Zdo(c); if (val != null) { val.Set("pucko_vw_sx", scale.x); val.Set("pucko_vw_sy", scale.y); val.Set("pucko_vw_sz", scale.z); } } internal static void InheritFlat(Vine parent) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (IsFlat(parent)) { Vine val = NewestNear(parent, ((Component)parent).transform.position, 4f); if ((Object)(object)val != (Object)null) { SetFlat(val, on: true); } } } internal static void InheritScale(Vine parent) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_019c: 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) ZDO val = Zdo(parent); if (val == null) { return; } float num = val.GetFloat("pucko_vw_sx", 0f); float num2 = val.GetFloat("pucko_vw_sy", 0f); float num3 = val.GetFloat("pucko_vw_sz", 0f); if (num <= 0f || num2 <= 0f || num3 <= 0f) { return; } WrapPolicy.InheritRatio(num, num2, num3, out var rx, out var ry, out var rz); if (!WrapPolicy.NarrowsAny(rx, ry, rz)) { return; } float narrowing = Tune.Cur.Narrowing; rx = WrapPolicy.BlendRatio(rx, narrowing); ry = WrapPolicy.BlendRatio(ry, narrowing); rz = WrapPolicy.BlendRatio(rz, narrowing); if (!WrapPolicy.NarrowsAny(rx, ry, rz)) { return; } Vine val2 = NewestNear(parent, ((Component)parent).transform.position, 4f); if ((Object)(object)val2 == (Object)null) { return; } ZDO val3 = Zdo(val2); if (val3 == null || !(val3.GetFloat("pucko_vw_sx", 0f) > 0f)) { Vector3 localScale = ((Component)val2).transform.localScale; ApplyScale(val2, new Vector3(localScale.x * rx, localScale.y * ry, localScale.z * rz)); if (Cfg.LogProbes.Value) { ManualLogSource log = Plugin.Log; string[] obj = new string[8] { "grown cell keeps the wrap's narrowing x", rx.ToString("0.00"), ",", ry.ToString("0.00"), ",", rz.ToString("0.00"), " at ", null }; Vector3 position = ((Component)val2).transform.position; obj[7] = ((Vector3)(ref position)).ToString("0.00"); log.LogInfo((object)string.Concat(obj)); } } } internal static void Tick() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = Cfg.FlatKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey == 0 || !((KeyboardShortcut)(ref value)).IsDown() || (Object)(object)Player.m_localPlayer == (Object)null) { return; } GameObject hoverObject = ((Humanoid)Player.m_localPlayer).GetHoverObject(); Vine val = (((Object)(object)hoverObject != (Object)null) ? hoverObject.GetComponentInParent<Vine>() : null); if ((Object)(object)val == (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, "VineWrap: no vine under the crosshair", 0, (Sprite)null, false); return; } object? value2 = FView.GetValue(val); ZNetView val2 = (ZNetView)((value2 is ZNetView) ? value2 : null); if (!((Object)(object)val2 == (Object)null) && val2.IsValid()) { if (!val2.IsOwner()) { val2.ClaimOwnership(); } bool flag = !IsFlat(val); SetFlat(val, flag); ((Character)Player.m_localPlayer).Message((MessageType)1, flag ? "VineWrap: this vine stays flat" : "VineWrap: this vine may wrap", 0, (Sprite)null, false); } } } [HarmonyPatch(typeof(Vine), "Awake")] internal static class AwakePatch { private static void Postfix(Vine __instance) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) try { ZDO val = VineData.Zdo(__instance); if (val != null) { float num = val.GetFloat("pucko_vw_sx", 0f); float num2 = val.GetFloat("pucko_vw_sy", 0f); float num3 = val.GetFloat("pucko_vw_sz", 0f); if (num > 0f && num2 > 0f && num3 > 0f) { ((Component)__instance).transform.localScale = new Vector3(num, num2, num3); } } } catch { } } } public enum Character { Custom, Tidy, Overgrown, Curtain, Creeper, Ruin, OvergrownRoofline, OvergrownStretch, OvergrownCreep, OvergrownMax } public enum GrowthMode { Classic, Random } public enum AgeCurve { Linear, TwoStage } public class Tuning { public float Fluff = 50f; public float Reach = 50f; public float Variety = 60f; public float Runs = 50f; public float Patchiness = 20f; public float Narrowing = 40f; public float Crowding = 60f; public float WrapAmount = 100f; public float DrapeChance; public float LeadChance; public int DrapeLength; public int LeadSteps; public float Relief; public float RoofTilt; public bool RoofSearch; public float MinSurface; public Tuning Copy() { return new Tuning { Fluff = Fluff, Reach = Reach, Variety = Variety, Runs = Runs, Patchiness = Patchiness, Narrowing = Narrowing, Crowding = Crowding, WrapAmount = WrapAmount, DrapeChance = DrapeChance, LeadChance = LeadChance, DrapeLength = DrapeLength, LeadSteps = LeadSteps, Relief = Relief, RoofTilt = RoofTilt, RoofSearch = RoofSearch, MinSurface = MinSurface }; } public override string ToString() { return "Fluff " + Fluff.ToString("0") + ", Reach " + Reach.ToString("0") + ", Variety " + Variety.ToString("0") + ", Runs " + Runs.ToString("0") + ", Patchiness " + Patchiness.ToString("0") + ", Narrowing " + Narrowing.ToString("0") + ", Crowding " + Crowding.ToString("0") + ", WrapAmount " + WrapAmount.ToString("0") + ", drape " + (DrapeChance * 100f).ToString("0") + " % x" + DrapeLength + ", lead " + (LeadChance * 100f).ToString("0") + " % x" + LeadSteps + ((Relief > 0f) ? (", tip relief " + (Relief * 100f).ToString("0") + " %") : "") + ((RoofTilt > 0f) ? (", roof tilt " + RoofTilt.ToString("0")) : "") + (RoofSearch ? ", roof search" : "") + ((MinSurface > 0f) ? (", MinSurface " + MinSurface.ToString("0.00")) : ""); } } public static class GrowthPolicy { public const float MaxDrapeChance = 1f; public const float MaxLeadChance = 0.8f; public const int MaxDrapeLength = 8; public const int MaxLeadSteps = 16; public const float HangMinDown = -0.3f; private static float C01(float v) { return Math.Max(0f, Math.Min(1f, v)); } private static float C100(float v) { return Math.Max(0f, Math.Min(100f, v)); } public static Tuning Preset(Character c, Tuning custom) { switch (c) { case Character.Tidy: return new Tuning { Fluff = 50f, Reach = 50f, Variety = 60f, Runs = 50f, Patchiness = 20f, Narrowing = 40f, Crowding = 60f, WrapAmount = 100f, DrapeChance = 0f, DrapeLength = 0, LeadChance = 0f, LeadSteps = 0 }; case Character.Overgrown: return new Tuning { Fluff = 65f, Reach = 70f, Variety = 75f, Runs = 60f, Patchiness = 5f, Narrowing = 20f, Crowding = 90f, WrapAmount = 100f, DrapeChance = 0.3f, DrapeLength = 2, LeadChance = 0.15f, LeadSteps = 4 }; case Character.Curtain: return new Tuning { Fluff = 55f, Reach = 60f, Variety = 60f, Runs = 50f, Patchiness = 10f, Narrowing = 30f, Crowding = 75f, WrapAmount = 100f, DrapeChance = 0.8f, DrapeLength = 5, LeadChance = 0.05f, LeadSteps = 2 }; case Character.Creeper: return new Tuning { Fluff = 40f, Reach = 45f, Variety = 50f, Runs = 40f, Patchiness = 15f, Narrowing = 70f, Crowding = 60f, WrapAmount = 90f, DrapeChance = 0.1f, DrapeLength = 1, LeadChance = 0.5f, LeadSteps = 10 }; case Character.Ruin: return new Tuning { Fluff = 60f, Reach = 60f, Variety = 100f, Runs = 100f, Patchiness = 40f, Narrowing = 30f, Crowding = 80f, WrapAmount = 85f, DrapeChance = 0.4f, DrapeLength = 3, LeadChance = 0.25f, LeadSteps = 6 }; case Character.OvergrownRoofline: return new Tuning { Fluff = 65f, Reach = 70f, Variety = 75f, Runs = 60f, Patchiness = 5f, Narrowing = 20f, Crowding = 90f, WrapAmount = 100f, DrapeChance = 0.3f, DrapeLength = 2, LeadChance = 0.25f, LeadSteps = 6, RoofTilt = 50f, RoofSearch = true }; case Character.OvergrownStretch: return new Tuning { Fluff = 65f, Reach = 70f, Variety = 75f, Runs = 70f, Patchiness = 5f, Narrowing = 0f, Crowding = 90f, WrapAmount = 100f, DrapeChance = 0.3f, DrapeLength = 2, LeadChance = 0.3f, LeadSteps = 6, MinSurface = 0.4f, Relief = 0.4f }; case Character.OvergrownCreep: return new Tuning { Fluff = 65f, Reach = 70f, Variety = 75f, Runs = 60f, Patchiness = 5f, Narrowing = 20f, Crowding = 90f, WrapAmount = 100f, DrapeChance = 0.3f, DrapeLength = 2, LeadChance = 0.5f, LeadSteps = 10, Relief = 0.7f }; case Character.OvergrownMax: return new Tuning { Fluff = 65f, Reach = 70f, Variety = 75f, Runs = 70f, Patchiness = 5f, Narrowing = 0f, Crowding = 90f, WrapAmount = 100f, DrapeChance = 0.35f, DrapeLength = 3, LeadChance = 0.5f, LeadSteps = 5, RoofTilt = 50f, RoofSearch = true, MinSurface = 0.4f, Relief = 0.7f }; default: if (custom == null) { return new Tuning(); } return custom.Copy(); } } public static float Toward(float baseV, float max, float s) { s = C100(s); if (s <= 50f) { return baseV * s / 50f; } return baseV + (Math.Max(max, baseV) - baseV) * (s - 50f) / 50f; } public static Tuning Resolve(Character c, Tuning custom, float thickness, float drape, float spread) { Tuning tuning = Preset(c, custom); float num = (C100(thickness) - 50f) / 50f; tuning.Fluff = C100(tuning.Fluff + 25f * num); tuning.Reach = C100(tuning.Reach + 25f * num); tuning.Crowding = C100(tuning.Crowding + 35f * num); tuning.Narrowing = C100(tuning.Narrowing - 35f * num); tuning.Patchiness = C100(tuning.Patchiness - 20f * num); tuning.DrapeChance = C01(Toward(tuning.DrapeChance, 1f, drape)); tuning.DrapeLength = Math.Max(0, Math.Min(8, (int)Math.Round(Toward(tuning.DrapeLength, 8f, drape)))); tuning.LeadChance = C01(Math.Min(0.8f, Toward(tuning.LeadChance, 0.8f, spread))); tuning.LeadSteps = Math.Max(0, Math.Min(16, (int)Math.Round(Toward(tuning.LeadSteps, 16f, spread)))); return tuning; } public static float ReliefFactor(float strength, float relax) { return 1f - C01(strength) * C01(relax); } public static float TwoStage(float age, float fastDays, float fastShare, float slowDays) { if (age <= 0f || float.IsNaN(age)) { return 0f; } fastShare = C01(fastShare); float num = ((fastDays <= 0.0001f) ? 1f : Math.Min(1f, age / fastDays)); float num2 = Math.Max(0f, age - Math.Max(0f, fastDays)); float num3 = ((!(slowDays <= 0.0001f)) ? ((float)(1.0 - Math.Exp((0f - num2) / slowDays))) : ((num2 > 0f) ? 1f : 0f)); return C01(fastShare * num + (1f - fastShare) * num3); } public static float Relax(AgeCurve curve, float age, float fastDays, float fastShare, float slowDays, float pretendDays) { if (fastDays <= 0.0001f) { return 0f; } if (curve == AgeCurve.Linear) { return WrapPolicy.AgeRelax(age, fastDays, pretendDays); } return TwoStage((pretendDays >= 0f) ? pretendDays : age, fastDays, fastShare, slowDays); } public static float PickAge(float cellAge, float lineageAge, bool useLineage) { if (useLineage && lineageAge > cellAge) { return lineageAge; } return cellAge; } public static float AttemptChance(float baseChance, float relax) { baseChance = C01(baseChance); return C01(baseChance + (1f - baseChance) * C01(relax)); } public static float AttemptRelax(float relax, float roll) { return C01(relax) * (float)Math.Sqrt(C01(roll)); } public static float WrapChance(float wrapAmount, float relax) { float num = C100(wrapAmount) / 100f; return C01(num + (1f - num) * C01(relax)); } public static bool GapHolds(float relax, float erode, float roll) { return roll >= C01(relax) * C01(erode); } public static int AgedCount(int n, float relax, float bonus) { if (n <= 0) { return 0; } return (int)Math.Round((float)n * (1f + C01(relax) * Math.Max(0f, bonus))); } public static bool LeadNext(int parentRun, int parentPush, int parentHeading, int stepHeading, int maxSteps, float roll, float chance, out int childRun, out int childPush) { childRun = 0; childPush = Math.Max(0, parentPush); if (maxSteps <= 0 || stepHeading == 0 || parentPush >= maxSteps) { return false; } if (parentRun > 0 && parentHeading == stepHeading) { childRun = parentRun + 1; childPush = parentPush + 1; return true; } if (roll < C01(chance)) { childRun = 1; childPush = parentPush + 1; return true; } return false; } public static float LeadOffsetZ(float parentZ) { return parentZ; } public static bool GameWidthCloses(float z, float y, float maxWidth, float extraPerHeight) { return Math.Abs(z) + 1f > maxWidth + y * extraPerHeight; } public static bool CanHang(float stepDownY, int parentHang, bool parentOnFace, int maxLength, float roll, float chance, out int childHang) { childHang = 0; if (stepDownY > -0.3f || maxLength <= 0) { return false; } if (parentHang <= 0 && !parentOnFace) { return false; } if (parentHang >= maxLength) { return false; } float num = ((parentHang <= 0) ? C01(chance) : (0.5f + C01(chance) / 2f)); if (chance <= 0f || roll >= num) { return false; } childHang = parentHang + 1; return true; } public static float HangScale(float taper) { return Math.Max(0.5f, 1f - Math.Max(0f, Math.Min(0.5f, taper))); } public static string CapHit(int onPiece, int maxPiece, int inArea, int maxArea, int loaded, int maxLoaded) { if (maxLoaded > 0 && loaded >= maxLoaded) { return "loaded cells " + loaded + "/" + maxLoaded; } if (maxArea > 0 && inArea >= maxArea) { return "cells in area " + inArea + "/" + maxArea; } if (maxPiece > 0 && onPiece >= maxPiece) { return "cells on piece " + onPiece + "/" + maxPiece; } return ""; } } internal static class Guard { private static readonly HashSet<string> s_off = new HashSet<string>(); internal static bool On(string module) { return !s_off.Contains(module); } internal static void Fail(string module, Exception e) { if (s_off.Add(module)) { Plugin.Log.LogWarning((object)("VineWrap module '" + module + "' failed and is off until restart (wrapping goes on): " + e)); } } } internal static class Tune { private static Tuning s_cur; private static bool s_dirty = true; internal static Tuning Cur { get { if (s_cur == null || s_dirty) { s_dirty = false; Tuning tuning = Compute(); string text = ((s_cur != null) ? s_cur.ToString() : ""); s_cur = tuning; if (tuning.ToString() != text) { Plugin.Log.LogInfo((object)("Character " + Cfg.CharacterPick.Value.ToString() + " (Thickness " + Cfg.Thickness.Value.ToString("0") + ", Drape " + Cfg.Drape.Value.ToString("0") + ", SpreadDistance " + Cfg.Spread.Value.ToString("0") + ", GrowthMode " + Cfg.Growth.Value.ToString() + ") -> " + tuning)); } } return s_cur; } } internal static void Hook(ConfigFile c) { c.SettingChanged += delegate { s_dirty = true; }; } private static Tuning Compute() { try { Tuning custom = new Tuning { Fluff = Cfg.Fluff.Value, Reach = Cfg.Reach.Value, Variety = Cfg.Variety.Value, Runs = Cfg.Runs.Value, Patchiness = Cfg.Patchiness.Value, Narrowing = Cfg.Narrowing.Value, Crowding = Cfg.Crowding.Value, WrapAmount = Cfg.WrapAmount.Value, DrapeChance = Cfg.DrapeChance.Value, DrapeLength = Cfg.DrapeLength.Value, LeadChance = Cfg.LeadChance.Value, LeadSteps = Cfg.LeadSteps.Value }; return GrowthPolicy.Resolve(Cfg.CharacterPick.Value, custom, Cfg.Thickness.Value, Cfg.Drape.Value, Cfg.Spread.Value); } catch (Exception e) { Guard.Fail("character", e); return new Tuning { Fluff = Cfg.Fluff.Value, Reach = Cfg.Reach.Value, Variety = Cfg.Variety.Value, Runs = Cfg.Runs.Value, Patchiness = Cfg.Patchiness.Value, Narrowing = Cfg.Narrowing.Value, Crowding = Cfg.Crowding.Value, WrapAmount = Cfg.WrapAmount.Value }; } } } internal static class Stats { internal static int Wraps; internal static int Under; internal static int Hangs; internal static int LeadStarts; internal static int LeadPushes; internal static int CapStops; internal static int Tries; internal static int TryWaits; internal static int GapFills; internal static int RoofSearch; internal static int Relieved; private static float s_next = -1f; internal static void Tick() { float value = Cfg.StatsMinutes.Value; if (value <= 0f || !Cfg.LogProbes.Value) { return; } if (s_next < 0f) { s_next = Time.time + value * 60f; } else if (!(Time.time < s_next)) { s_next = Time.time + value * 60f; if (Wraps + Under + Hangs + LeadStarts + LeadPushes + CapStops + Tries + RoofSearch + Relieved != 0) { Plugin.Log.LogInfo((object)("summary (last " + value.ToString("0") + " min): wraps " + Wraps + " (of them Under " + Under + "), hanging " + Hangs + ", lead starts " + LeadStarts + ", lead pushes " + LeadPushes + ", cap stops " + CapStops + ", random rolls " + Tries + " (said wait " + TryWaits + "), gaps filled " + GapFills + ", loaded cells " + Lineage.LoadedCount())); Wraps = (Under = (Hangs = (LeadStarts = (LeadPushes = (CapStops = (Tries = (TryWaits = (GapFills = (RoofSearch = (Relieved = 0)))))))))); } } } } internal static class Diag { private static readonly HashSet<string> s_done = new HashSet<string>(); private static readonly string[] s_fields = new string[19] { "m_maxGrowWidth", "m_extraGrowWidthPerHeight", "m_maxGrowUp", "m_maxGrowDown", "m_maxGrowEdgeIgnoreChance", "m_growSides", "m_growUp", "m_growDown", "m_closeEndChance", "m_closeEndChancePerBranch", "m_closeEndChancePerHeight", "m_maxCloseEndChance", "m_growCheckChance", "m_growCheckChancePerBranch", "m_growChance", "m_growTime", "m_growTimePerBranch", "m_size", "m_randomOffset" }; private static FieldInfo[] s_infos; internal static void Prefab(Vine v) { if (!Guard.On("diag")) { return; } try { string text = ((Object)v).name; int num = text.IndexOf('('); if (num > 0) { text = text.Substring(0, num); } if (!s_done.Add(text)) { return; } if (s_infos == null) { s_infos = new FieldInfo[s_fields.Length]; for (int i = 0; i < s_fields.Length; i++) { s_infos[i] = AccessTools.Field(typeof(Vine), s_fields[i]); } } StringBuilder stringBuilder = new StringBuilder("vine prefab " + text + " growth values:"); for (int j = 0; j < s_infos.Length; j++) { stringBuilder.Append(" ").Append(s_fields[j].Substring(2)).Append("=") .Append((s_infos[j] != null) ? Convert.ToString(s_infos[j].GetValue(v), CultureInfo.InvariantCulture) : "?"); } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } catch (Exception e) { Guard.Fail("diag", e); } } } internal static class Lineage { internal const string Born = "pucko_vw_born"; internal const string Run = "pucko_vw_lead"; internal const string Push = "pucko_vw_push"; internal const string Head = "pucko_vw_head"; private static readonly FieldInfo FAll = AccessTools.Field(typeof(Vine), "s_allVines"); private static readonly MethodInfo MGetOff = AccessTools.Method(typeof(Vine), "GetOriginOffset", (Type[])null, (Type[])null); private static readonly MethodInfo MSetOff = AccessTools.Method(typeof(Vine), "SetOriginOffset", (Type[])null, (Type[])null); internal static List<Vine> All() { if (!(FAll != null)) { return null; } return FAll.GetValue(null) as List<Vine>; } internal static int LoadedCount() { return All()?.Count ?? 0; } internal static void OnGrown(Vine parent, Vine child, Vector3 unitLocal, float relax, Tuning t) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)parent == (Object)null || (Object)(object)child == (Object)null) { return; } ZDO val = VineData.Zdo(parent); ZDO val2 = VineData.Zdo(child); if (val == null || val2 == null) { return; } if (Cfg.LineageAge.Value && Guard.On("lineage")) { try { long num = val.GetLong("pucko_vw_born", 0L); if (num <= 0) { num = val.GetLong(ZDOVars.s_plantTime, 0L); } long num2 = val2.GetLong(ZDOVars.s_plantTime, 0L); if (num > 0 && (num2 <= 0 || num < num2)) { val2.Set("pucko_vw_born", num); } } catch (Exception e) { Guard.Fail("lineage", e); } } if (!Guard.On("lead")) { return; } try { LeadStep(parent, child, val, val2, unitLocal, relax, t); } catch (Exception e2) { Guard.Fail("lead", e2); } } private static void LeadStep(Vine parent, Vine child, ZDO pz, ZDO cz, Vector3 unitLocal, float relax, Tuning t) { //IL_002a: 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_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) int num = pz.GetInt("pucko_vw_push", 0); if (!Cfg.LeadEnabled.Value) { if (num > 0) { cz.Set("pucko_vw_push", num); } return; } int num2 = ((WrapPolicy.Dominant(unitLocal.x, unitLocal.y, unitLocal.z) == 2) ? ((unitLocal.z > 0f) ? 1 : (-1)) : 0); int maxSteps = GrowthPolicy.AgedCount(t.LeadSteps, relax, Cfg.LeadAgeBonus.Value); int childRun; int childPush; bool flag = GrowthPolicy.LeadNext(pz.GetInt("pucko_vw_lead", 0), num, pz.GetInt("pucko_vw_head", 0), num2, maxSteps, Random.value, t.LeadChance, out childRun, out childPush); if (flag && Caps.Check(((Component)child).transform.position, null, "lead") != null) { flag = false; childRun = 0; childPush = num; } if (childPush > 0) { cz.Set("pucko_vw_push", childPush); } if (flag && !(MGetOff == null) && !(MSetOff == null)) { cz.Set("pucko_vw_lead", childRun); cz.Set("pucko_vw_head", num2); Vector3 val = (Vector3)MGetOff.Invoke(parent, null); Vector3 val2 = (Vector3)MGetOff.Invoke(child, null); val2.z = GrowthPolicy.LeadOffsetZ(val.z); MSetOff.Invoke(child, new object[1] { val2 }); if (childRun == 1) { Stats.LeadStarts++; } else { Stats.LeadPushes++; } if (Cfg.LogProbes.Value) { ManualLogSource log = Plugin.Log; string[] obj = new string[12] { "lead vine ", childRun.ToString(), " (line ", childPush.ToString(), "/", maxSteps.ToString(), ") at ", null, null, null, null, null }; Vector3 position = ((Component)child).transform.position; obj[7] = ((Vector3)(ref position)).ToString("0.00"); obj[8] = ", heading "; obj[9] = ((num2 > 0) ? "+z" : "-z"); obj[10] = ", offset z kept at "; obj[11] = val2.z.ToString("0"); log.LogInfo((object)string.Concat(obj)); } } } } internal static class Caps { private static readonly Dictionary<int, Bounds> s_bounds = new Dictionary<int, Bounds>(); private static readonly Dictionary<int, float> s_boundsTime = new Dictionary<int, float>(); private static readonly Dictionary<string, float> s_logNext = new Dictionary<string, float>(); internal static string Check(Vector3 pos, Piece piece, string what) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00ca: 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) //IL_00d2: 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_00d8: 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) if (!Cfg.CapsEnabled.Value || !Guard.On("caps")) { return null; } try { List<Vine> list = Lineage.All(); if (list == null) { return null; } int value = Cfg.MaxCellsPerPiece.Value; int value2 = Cfg.MaxCellsPerArea.Value; int value3 = Cfg.MaxLoadedCells.Value; int count = list.Count; int num = 0; int num2 = 0; float num3 = Cfg.AreaRadius.Value * Cfg.AreaRadius.Value; bool flag = (Object)(object)piece != (Object)null && value > 0; Bounds val = (Bounds)(flag ? PieceBounds(piece) : default(Bounds)); if (value2 > 0 || flag) { for (int i = 0; i < list.Count; i++) { Vine val2 = list[i]; if ((Object)(object)val2 == (Object)null) { continue; } Vector3 position = ((Component)val2).transform.position; if (value2 > 0) { Vector3 val3 = position - pos; if (((Vector3)(ref val3)).sqrMagnitude <= num3) { num++; } } if (flag && ((Bounds)(ref val)).Contains(position)) { num2++; } } } string text = GrowthPolicy.CapHit(num2, value, num, value2, count, value3); if (text.Length == 0) { return null; } Stats.CapStops++; string key = what + ":" + text.Substring(0, (text.IndexOf(' ') > 0) ? text.IndexOf(' ') : text.Length); if (!s_logNext.TryGetValue(key, out var value4) || Time.time >= value4) { s_logNext[key] = Time.time + 15f; Plugin.Log.LogInfo((object)("cap stopped " + what + " at " + ((Vector3)(ref pos)).ToString("0.00") + ": " + text + (((Object)(object)piece != (Object)null) ? (" (piece " + ((Object)piece).name + ")") : ""))); } return text; } catch (Exception e) { Guard.Fail("caps", e); return null; } } private static Bounds PieceBounds(Piece p) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) int instanceID = ((Object)p).GetInstanceID(); if (s_bounds.TryGetValue(instanceID, out var value) && s_boundsTime.TryGetValue(instanceID, out var value2) && Time.time - value2 < 30f) { return value; } bool flag = false; Collider[] componentsInChildren = ((Component)p).GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !val.isTrigger) { if (!flag) { value = val.bounds; flag = true; } else { ((Bounds)(ref value)).Encapsulate(val.bounds); } } } if (!flag) { ((Bounds)(ref value))..ctor(((Component)p).transform.position, Vector3.one); } ((Bounds)(ref value)).Expand(2f); if (s_bounds.Count > 2000) { s_bounds.Clear(); s_boundsTime.Clear(); } s_bounds[instanceID] = value; s_boundsTime[instanceID] = Time.time; return value; } } internal static class Drape { internal const string HangKey = "pucko_vw_hang"; internal static bool UnderOn() { if (Cfg.DrapeEnabled.Value && Cfg.DrapeUnder.Value) { return Guard.On("under"); } return false; } internal static int HangOf(Vine v) { ZDO val = VineData.Zdo(v); if (val == null) { return 0; } return val.GetInt("pucko_vw_hang", 0); } internal static bool TryHang(Vine v, Vector3 unitLocal, bool parentOnFace, float relax, Tuning t, object[] args, float roll, float size, long retryKey) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00be: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_01af: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) if (!Cfg.DrapeEnabled.Value || !Cfg.DrapeHang.Value || !Guard.On("hang")) { return false; } try { Transform transform = ((Component)v).transform; Vector3 val = transform.rotation * unitLocal; Vector3 normalized = ((Vector3)(ref val)).normalized; int num = HangOf(v); int maxLength = GrowthPolicy.AgedCount(t.DrapeLength, relax, Cfg.DrapeAgeBonus.Value); if (!GrowthPolicy.CanHang(normalized.y, num, parentOnFace, maxLength, roll, t.DrapeChance, out var childHang)) { return false; } bool value = Cfg.LogProbes.Value; Quaternion val2 = Quaternion.FromToRotation(normalized, Vector3.down); float num2 = GrowthPolicy.HangScale(Cfg.HangTaper.Value); ProbeResult probeResult = new ProbeResult { CellPos = transform.position, Pos = transform.position + normalized * size, Rot = val2 * transform.rotation, Scale = transform.localScale * num2, StepUnit = unitLocal, HavePose = true, Allowed = true, Crowding = t.Crowding, Until = Time.time + Cfg.ShowSeconds.Value, Verdict = "HANG " + childHang + "/" + maxLength }; probeResult.UniformScale = Mathf.Max(probeResult.Scale.x, Mathf.Max(probeResult.Scale.y, probeResult.Scale.z)); if (Cfg.CoverRadius.Value > 0f && VineData.CoveredAt(v, probeResult.Pos, probeResult.Rot * Vector3.right, Cfg.CoverRadius.Value)) { Probe.Retry(retryKey, 3f); return true; } if (Caps.Check(probeResult.Pos, null, "drape") != null) { Probe.Retry(retryKey, 3f); return true; } string text = Probe.BlockedBy(v, probeResult); if (text != null) { if (value) { Plugin.Log.LogInfo((object)("hang not grown at " + ((Vector3)(ref probeResult.Pos)).ToString("0.00") + ": blocked by " + text)); } Probe.Retry(retryKey, 1f); return true; } Vine val3 = Probe.GrowAt(v, probeResult, args); if ((Object)(object)val3 == (Object)null) { if (value) { Plugin.Log.LogInfo((object)("hang grown at " + ((Vector3)(ref probeResult.Pos)).ToString("0.00") + " but the new cell was not found")); } return true; } VineData.ApplyScale(val3, probeResult.Scale); ZDO val4 = VineData.Zdo(val3); if (val4 != null) { val4.Set("pucko_vw_hang", childHang); } Lineage.OnGrown(v, val3, unitLocal, relax, t); Stats.Hangs++; if (value) { Plugin.Log.LogInfo((object)("HUNG at " + ((Vector3)(ref probeResult.Pos)).ToString("0.00") + " hang " + childHang + "/" + maxLength + " scale=" + ((Vector3)(ref probeResult.Scale)).ToString("0.00") + ((num == 0) ? " (below an edge)" : ""))); } return true; } catch (Exception e) { Guard.Fail("hang", e); return false; } } } [HarmonyPatch(typeof(Vine), "IsSupported")] internal static class SupportPatch { private static readonly FieldInfo FSize = AccessTools.Field(typeof(Vine), "m_size"); private static void Postfix(Vine __instance, ref bool __result) { //IL_005d: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b1: Unknown result type (might be due to invalid IL or missing references) if (__result) { return; } try { if (Drape.HangOf(__instance) <= 0) { return; } List<Vine> list = Lineage.All(); if (list == null) { return; } float num = ((FSize != null) ? ((float)FSize.GetValue(__instance)) : 1.5f); float num2 = num * 1.3f * (num * 1.3f); Vector3 position = ((Component)__instance).transform.position; for (int i = 0; i < list.Count; i++) { Vine val = list[i]; if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)__instance) { continue; } Vector3 position2 = ((Component)val).transform.position; if (position2.y > position.y + 0.3f) { Vector3 val2 = position2 - position; if (((Vector3)(ref val2)).sqrMagnitude <= num2) { __result = true; break; } } } } catch { } } } [HarmonyPatch(typeof(Vine), "CheckGrow")] internal static class ReliefPatch { private struct St { public bool Set; public float B; public float H; public float M; public float C; } private static readonly FieldInfo FBranch = AccessTools.Field(typeof(Vine), "m_closeEndChancePerBranch"); private static readonly FieldInfo FHeight = AccessTools.Field(typeof(Vine), "m_closeEndChancePerHeight"); private static readonly FieldInfo FMax = AccessTools.Field(typeof(Vine), "m_maxCloseEndChance"); private static readonly FieldInfo FBase = AccessTools.Field(typeof(Vine), "m_closeEndChance"); private static bool Prepare() { if (FBranch != null && FHeight != null && FMax != null) { return FBase != null; } return false; } private static void Prefix(Vine __instance, out St __state) { __state = default(St); try { if (!Cfg.Enabled.Value || !Cfg.ReliefOn.Value || !Guard.On("relief")) { return; } float num = Math.Max(Tune.Cur.Relief, Cfg.TipRelief.Value); if (!(num <= 0f)) { float relax = Probe.RelaxFor(Probe.AgeDays(__instance)); float num2 = GrowthPolicy.ReliefFactor(num, relax); if (!(num2 >= 0.999f)) { __state.Set = true; __state.B = (float)FBranch.GetValue(__instance); __state.H = (float)FHeight.GetValue(__instance); __state.M = (float)FMax.GetValue(__instance); __state.C = (float)FBase.GetValue(__instance); FBranch.SetValue(__instance, __state.B * num2); FHeight.SetValue(__instance, __state.H * num2); FMax.SetValue(__instance, __state.M * num2); FBase.SetValue(__instance, __state.C * num2); Stats.Relieved++; } } } catch (Exception e) { Guard.Fail("relief", e); } } private static void Finalizer(Vine __instance, St __state) { if (!__state.Set) { return; } try { FBranch.SetValue(__instance, __state.B); FHeight.SetValue(__instance, __state.H); FMax.SetValue(__instance, __state.M); FBase.SetValue(__instance, __state.C); } catch (Exception e) { Guard.Fail("relief", e); } } } [BepInPlugin("pucko.vinewrap", "VineWrap", "0.9.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "pucko.vinewrap"; public const string NAME = "VineWrap"; public const string VERSION = "0.9.2"; internal static ManualLogSource Log; private Harmony _harmony; private bool _drawing; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Cfg.Bind(((BaseUnityPlugin)this).Config); Tune.Hook(((BaseUnityPlugin)this).Config); _harmony = new Harmony("pucko.vinewrap"); if (!Probe.Ok()) { Log.LogWarning((object)"Vine fields changed in this game version; probe is off."); return; } _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)("VineWrap 0.9.2 loaded (wraps only where a real surface is under the new cell; SpawnWraps=false for probe only). Character=" + Cfg.CharacterPick.Value.ToString() + ", GrowthMode=" + Cfg.Growth.Value.ToString() + ", Deterministic=" + Cfg.Deterministic.Value + ", AgeCurve=" + Cfg.Curve.Value.ToString() + ", AgeDays=" + Cfg.AgeDays.Value + ", AgeSlowDays=" + Cfg.AgeSlowDays.Value + ", LineageAge=" + Cfg.LineageAge.Value + ", PretendAgeDays=" + Cfg.PretendAgeDays.Value + ", AgeSpeed=" + Cfg.AgeSpeed.Value + ", Drape=" + Cfg.DrapeEnabled.Value + " (Under " + Cfg.DrapeUnder.Value + ", Hang " + Cfg.DrapeHang.Value + "), Leads=" + Cfg.LeadEnabled.Value + ", Caps=" + Cfg.CapsEnabled.Value)); _ = Tune.Cur; } private void Update() { if (Cfg.ShowProbes == null) { return; } try { Stats.Tick(); } catch (Exception ex) { Log.LogWarning((object)("Stats failed: " + ex.Message)); } try { VineData.Tick(); } catch (Exception ex2) { Log.LogWarning((object)("Flat key failed: " + ex2.Message)); } if (!Cfg.ShowProbes.Value && !_drawing) { return; } try { ProbeDraw.Tick(); _drawing = Cfg.ShowProbes.Value; } catch (Exception ex3) { Log.LogWarning((object)("Probe view failed, switching it off: " + ex3.Message)); Cfg.ShowProbes.Value = false; _drawing = false; } } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } } internal class ProbeResult { public Vector3 CellPos; public Vector3 Face; public Vector3 Neighbour; public Vector3 SearchStart; public Vector3 SideHit; public Vector3 SideNormal; public bool Found; public string Verdict; public string Piece; public string FacePiece; public Vector3 Size; public WrapDir Dir; public bool Allowed; public float Until; public Vector3 Pos; public Quaternion Rot; public bool HavePose; public bool Quiet; public bool Wrapped; public Vector3 Scale = Vector3.one; public float UniformScale = 1f; public float WidthScale = 1f; public float Angle; public float Run; public int Kx; public int Ky; public int Kz; public int Gx; public int Gy; public int Gz; public int Rx; public int Ry; public int Rz; public SeamMethod Method; public Vector3 StepUnit; public int Hits; public int Total; public readonly List<Vector3> SampleFrom = new List<Vector3>(); public readonly List<Vector3> SampleTo = new List<Vector3>(); public readonly List<bool> SampleOk = new List<bool>(); public float AgeDays; public float Relax; public float MaxMid; public float MinSurface; public float MinRun; public float Crowding; public float Slide; public float[] Rnd; public Piece SidePiece; public bool Drape; public string AgeNote { get { if (!(Relax > 0.001f)) { return ""; } return " [age " + AgeDays.ToString("0.0") + " d, relaxed " + (Relax * 100f).ToString("0") + " %]"; } } } internal static class Probe { internal static int CoveredCount; internal static readonly List<ProbeResult> Recent = new List<ProbeResult>(); private static readonly FieldInfo FState = AccessTools.Field(typeof(Vine), "m_vineState"); private static readonly FieldInfo FGrow = AccessTools.Field(typeof(Vine), "m_sensorGrow"); private static readonly FieldInfo FCols = AccessTools.Field(typeof(Vine), "m_sensorGrowColliders"); private static readonly FieldInfo FMin = AccessTools.Field(typeof(Vine), "m_growCollidersMinimum"); private static readonly FieldInfo FSize = AccessTools.Field(typeof(Vine), "m_size"); private static readonly FieldInfo FPiece = AccessTools.Field(typeof(Vine), "s_pieceMask"); private static readonly FieldInfo FSolid = AccessTools.Field(typeof(Vine), "s_solidMask"); private static readonly FieldInfo FBlock = AccessTools.Field(typeof(Vine), "m_sensorBlockCollider"); internal static readonly FieldInfo FMinScale = AccessTools.Field(typeof(Vine), "m_minScale"); internal static readonly FieldInfo FMaxScale = AccessTools.Field(typeof(Vine), "m_maxScale"); internal static readonly FieldInfo FChance = AccessTools.Field(typeof(Vine), "m_growChance"); internal static readonly MethodInfo MGrow = AccessTools.Method(typeof(Vine), "Grow", (Type[])null, (Type[])null); private static readonly FieldInfo FDayLen = AccessTools.Field(typeof(EnvMan), "m_dayLengthSec"); private static readonly RaycastHit[] s_hits = (RaycastHit[])(object)new RaycastHit[64]; private static readonly Collider[] s_cols = (Collider[])(object)new Collider[128]; private static int s_terrainMask = -1; private static readonly Dictionary<long, float> s_retry = new Dictionary<long, float>(); private const float FaceReach = 0.6f; private const float SampleOut = 0.35f; private const float NormalCos = 0.866f; private static float s_cos = 0.866f; private const float BodyMidY = 0.8f; internal const int SOk = 0; internal const int SBuried = 1; internal const int SNoHit = 2; internal const int SNear = 3; internal const int STilt = 4; internal const int SGround = 5; private static readonly float[] OneLine = new float[1] { 0.5f }; private static readonly Dictionary<long, float> s_seen = new Dictionary<long, float>(); internal static int TerrainMask { get { if (s_terrainMask < 0) { s_terrainMask = LayerMask.GetMask(new string[1] { "terrain" }); } return s_terrainMask; } } internal static bool IsTerrain(Collider c) { if ((Object)(object)c == (Object)null) { return false; } if (((1 << ((Component)c).gameObject.layer) & TerrainMask) != 0) { return true; } if (!(((object)c).GetType().Name == "TerrainCollider")) { return (Object)(object)((Component)c).GetComponentInParent<Heightmap>() != (Object)null; } return true; } private static bool IsVine(Collider c) { if ((Object)(object)c != (Object)null) { return (Object)(object)((Component)c).GetComponentInParent<Vine>() != (Object)null; } return false; } internal static float AgeDays(Vine v) { ZDO val = VineData.Zdo(v); if (val == null || (Object)(object)ZNet.instance == (Object)null) { return -1f; } long ticks = ZNet.instance.GetTime().Ticks; float num = 1800f; try { if ((Object)(object)EnvMan.instance != (Object)null && FDayLen != null) { long num2 = Convert.ToInt64(FDayLen.GetValue(EnvMan.instance)); if (num2 > 0) { num = num2; } } } catch { } long num3 = val.GetLong(ZDOVars.s_plantTime, 0L); float cellAge = ((num3 > 0) ? ((float)((double)(ticks - num3) / 10000000.0 / (double)num)) : (-1f)); float lineageAge = -1f; if (Cfg.LineageAge.Value) { long num4 = val.GetLong("pucko_vw_born", 0L); if (num4 > 0) { lineageAge = (float)((double)(ticks - num4) / 10000000.0 / (double)num); } } return WrapPolicy.SpeedUp(GrowthPolicy.PickAge(cellAge, lineageAge, Cfg.LineageAge.Value), Cfg.AgeSpeed.Value); } internal static float RelaxFor(float ageDays) { return GrowthPolicy.Relax(Cfg.Curve.Value, ageDays, Cfg.AgeDays.Value, Cfg.AgeFastShare.Value, Cfg.AgeSlowDays.Value, Cfg.PretendAgeDays.Value); } internal static Vector3 Unit(Vector3 offsetArg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_004f: 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_0034: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(WrapPolicy.Dominant(offsetArg.x, offsetArg.y, offsetArg.z) switch { 1 => new Vector3(0f, Mathf.Sign(offsetArg.y), 0f), 0 => new Vector3(Mathf.Sign(offsetArg.x), 0f, 0f), _ => new Vector3(0f, 0f, Mathf.Sign(offsetArg.z)), }); } internal static float StepSize(Vine v) { return (float)FSize.GetValue(v); } internal static Vine GrowAt(Vine v, ProbeResult r, object[] args) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)v).transform; Vector3 position = transform.position; Quaternion rotation = transform.rotation; object value = FMinScale.GetValue(v); object value2 = FMaxScale.GetValue(v); CheckGrowPatch.Busy = true; try { transform.SetPositionAndRotation(r.Pos, r.Rot); FMinScale.SetValue(v, r.UniformScale); FMaxScale.SetValue(v, r.UniformScale); MGrow.Invoke(v, new object[5] { Vector3.zero, r.StepUnit, args[1], args[3], args[4] }); } finally { transform.SetPositionAndRotation(position, rotation); FMinScale.SetValue(v, value); FMaxScale.SetValue(v, value2); CheckGrowPatch.Busy = false; } return VineData.NewestNear(v, r.Pos, 1f); } internal static float Roll(ProbeResult r, int salt) { float result = WrapPolicy.Hash01(r.Kx, r.Ky, r.Kz, salt); if (r.Rnd == null || salt < 0 || salt >= r.Rnd.Length) { return result; } return r.Rnd[salt]; } internal static long RetryKey(Vine v, Vector3 offsetArg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0027: 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) int num = WrapPolicy.Dominant(offsetArg.x, offsetArg.y, offsetArg.z); float num2 = num switch { 1 => offsetArg.y, 0 => offsetArg.x, _ => offsetArg.z, }; return ((long)((Object)v).GetInstanceID() << 3) | (num * 2 + ((num2 > 0f) ? 1 : 0)); } internal static bool Waiting(long key) { if (s_retry.TryGetValue(key, out var value)) { return Time.time < value; } return false; } internal static void Retry(long key, float factor) { float num = Cfg.RecheckSeconds.Value * factor; if (!(num <= 0.01f)) { if (s_retry.Count > 5000) { s_retry.Clear(); } s_retry[key] = Time.time + num; } } internal static bool Ok() { if (FState != null && FGrow != null && FCols != null && FMin != null && FSize != null && FPiece != null && FSolid != null && FBlock != null && FMinScale != null && FMaxScale != null && FChance != null && MGrow != null) { return MGrow.GetParameters().Length == 5; } return false; } internal static ProbeResult Run(Vine v, Vector3 sensorBefore, Vector3 offsetArg, float ageDays, float relax, bool allowUnder, bool randomMode) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: 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_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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_01b9: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: 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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0216: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_089f: Unknown result type (might be due to invalid IL or missing references) //IL_08b2: Unknown result type (might be due to invalid IL or missing references) //IL_08c5: Unknown result type (might be due to invalid IL or missing references) //IL_08d6: Unknown result type (might be due to invalid IL or missing references) //IL_08dd: Unknown result type (might be due to invalid IL or missing references) //IL_08e4: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_095d: Unknown result type (might be due to invalid IL or missing references) //IL_095f: Unknown result type (might be due to invalid IL or missing references) //IL_0961: Unknown result type (might be due to invalid IL or missing references) //IL_0963: Unknown result type (might be due to invalid IL or missing references) //IL_0998: Unknown result type (might be due to invalid IL or missing references) //IL_099a: Unknown result type (might be due to invalid IL or missing references) //IL_099c: Unknown result type (might be due to invalid IL or missing references) //IL_099e: Unknown result type (might be due to invalid IL or missing references) //IL_09a0: Unknown result type (might be due to invalid IL or missing references) s_cos = 0.866f; BoxCollider val = (BoxCollider)FGrow.GetValue(v); if ((Object)(object)val == (Object)null) { return null; } Vector3 val2 = ((Component)val).transform.position - sensorBefore; if (((Vector3)(ref val2)).sqrMagnitude < 1E-08f) { return null; } int num = (int)FPiece.GetValue(null); List<BoxCollider> list = (List<BoxCollider>)FCols.GetValue(v); float num2 = (float)FMin.GetValue(v); float num3 = (float)FSize.GetValue(v); int num4 = 0; foreach (BoxCollider item in list) { if (Physics.CheckBox(((Component)val).transform.position, item.size / 2f, ((Component)val).transform.rotation, num)) { num4++; } } if ((float)num4 >= (float)list.Count * num2) { return null; } Vector3 position = ((Component)v).transform.position; int mask = num | TerrainMask; RaycastHit best; bool flag = Nearest(position, ((Component)v).transform.right, 0.6f, mask, out best); if (Nearest(position, -((Component)v).transform.right, 0.6f, mask, out var best2) && (!flag || ((RaycastHit)(ref best2)).distance < ((RaycastHit)(ref best)).distance)) { best = best2; flag = true; } if (!flag || IsTerrain(((RaycastHit)(ref best)).collider)) { return null; } Vector3 normal = ((RaycastHit)(ref best)).normal; if (((Vector3)(ref offsetArg)).sqrMagnitude < 1E-06f) { return null; } Vector3 val3 = Unit(offsetArg); Vector3 val4 = ((Component)v).transform.rotation * val3; val4 -= normal * Vector3.Dot(val4, normal); if (((Vector3)(ref val4)).sqrMagnitude < 1E-06f) { return null; } Vector3 normalized = ((Vector3)(ref val4)).normalized; Piece componentInParent = ((Component)((RaycastHit)(ref best)).collider).GetComponentInParent<Piece>(); ProbeResult probeResult = new ProbeResult { CellPos = position, Face = ((RaycastHit)(ref best)).point, Neighbour = position + normalized * num3, Until = Time.time + Cfg.ShowSeconds.Value, FacePiece = (((Object)(object)componentInParent != (Object)null) ? ((Object)componentInParent).name : ((Object)((Component)((RaycastHit)(ref best)).collider).gameObject).name), StepUnit = val3 }; probeResult.Quiet = Seen(position, normalized); probeResult.Kx = Mathf.RoundToInt(position.x * 4f); probeResult.Ky = Mathf.RoundToInt(position.y * 4f); probeResult.Kz = Mathf.RoundToInt(position.z * 4f); probeResult.Gx = Mathf.RoundToInt(position.x / 2f); probeResult.Gy = Mathf.RoundToInt(position.y / 2f); probeResult.Gz = Mathf.RoundToInt(position.z / 2f); if (!randomMode && !Cfg.Deterministic.Value) { probeResult.Rnd = new float[12]; for (int i = 0; i < probeResult.Rnd.Length; i++) { probeResult.Rnd[i] = Random.value; } } probeResult.AgeDays = ((Cfg.PretendAgeDays.Value >= 0f) ? Cfg.PretendAgeDays.Value : ageDays); probeResult.Relax = relax; Tuning cur = Tune.Cur; probeResult.MinSurface = WrapPolicy.Loosen((Tune.Cur.MinSurface > 0f) ? Tune.Cur.MinSurface : Cfg.MinSurface.Value, Cfg.AgedMinSurface.Value, probeResult.Relax, looserIsHigher: false); probeResult.MinRun = WrapPolicy.Loosen(Cfg.MinRun.Value, Cfg.AgedMinRun.Value, probeResult.Relax, looserIsHigher: false); probeResult.Crowding = WrapPolicy.Loosen(cur.Crowding, Cfg.AgedCrowding.Value, probeResult.Relax, looserIsHigher: true); probeResult.SearchStart = ((RaycastHit)(ref best)).point + normalized * num3 - normal * 0.2f; RaycastHit best3; bool flag2 = Nearest(probeResult.SearchStart, -normalized, num3, mask, out best3); if (!flag2 && (cur.RoofSearch | Cfg.RoofEdgeSearch.Value) && Guard.On("roof")) { flag2 = RoofSearch(((RaycastHit)(ref best)).point, normalized, normal, num3, mask, out best3); } if (!flag2) { probeResult.Verdict = "no side face found (end of piece or open air)"; Finish(probeResult); return probeResult; } probeResult.Found = true; probeResult.SideHit = ((RaycastHit)(ref best3)).point; probeResult.SideNormal = ((RaycastHit)(ref best3)).normal; Collider collider = ((RaycastHit)(ref best3)).collider; Piece componentInParent2 = ((Component)collider).GetComponentInParent<Piece>(); probeResult.Piece = (((Object)(object)componentInParent2 != (Object)null) ? ((Object)componentInParent2).name : ((Object)((Component)collider).gameObject).name); probeResult.SidePiece = componentInParent2; Vector3 val5 = (probeResult.Size = OrientedSize(collider)); if (IsTerrain(collider)) { probeResult.Verdict = "skip: side hit is the ground"; Finish(probeResult); return probeResult; } probeResult.Dir = WrapPolicy.Classify(((RaycastHit)(ref best3)).normal.y, Cfg.UnderAngle.Value); probeResult.Angle = WrapPolicy.TurnAngle(Vector3.Dot(normal, ((RaycastHit)(ref best3)).normal)); bool flag3 = WrapPolicy.NameMatches(Cfg.SizeExempt.Value, probeResult.Piece, emptyMatches: false); bool flag4 = WrapPolicy.NameMatches(Cfg.RoofList.Value, probeResult.Piece, emptyMatches: false); if (flag4 && Guard.On("roof")) { float num5 = ((cur.RoofTilt > 0f) ? cur.RoofTilt : Cfg.RoofTilt.Value); s_cos = Math.Min(0.866f, (float)Math.Cos((double)num5 * Math.PI / 180.0)); } float num6 = WrapPolicy.PieceLimit(flag3, flag4, Cfg.MaxMidEdge.Value, Cfg.RoofMaxMidEdge.Value); probeResult.MaxMid = (flag3 ? num6 : WrapPolicy.Loosen(num6, Cfg.AgedMaxMidEdge.Value, probeResult.Relax, looserIsHigher: true)); WrapDir wrapDir = Cfg.Directions.Value; if (allowUnder) { wrapDir |= WrapDir.Under; } probeResult.Drape = allowUnder && probeResult.Dir == WrapDir.Under && (Cfg.Directions.Value & WrapDir.Under) == 0; string text = WrapPolicy.Refusal(wrapDir, probeResult.Dir, val5.x, val5.y, val5.z, probeResult.MaxMid); if (text.Length == 0 && !WrapPolicy.NameMatches(Cfg.Plants.Value, ((Object)v).name, emptyMatches: true)) { text = "this vine is not in the Plants list"; } if (text.Length == 0 && !WrapPolicy.NameMatches(Cfg.PieceAllow.Value, probeResult.Piece, emptyMatches: true)) { text = "piece not in PieceAllowList"; } if (text.Length == 0 && WrapPolicy.NameMatches(Cfg.PieceDeny.Value, probeResult.Piece, emptyMatches: false)) { text = "piece in PieceDenyList"; } if (text.Length == 0 && !WrapPolicy.TurnAllowed(probeResult.Angle, Cfg.MinTurn.Value, Cfg.MaxTurn.Value)) { text = "bend " + probeResult.Angle.ToString("0") + " deg outside Min/MaxTurnAngle"; } if (text.Length == 0 && VineData.IsFlat(v)) { text = "this vine is marked flat"; } probeResult.Allowed = text.Length == 0; probeResult.Verdict = (probeResult.Allowed ? ("WOULD WRAP (" + probeResult.Dir.ToString() + (probeResult.Drape ? ", drape" : "") + ")") : ("skip: " + text + probeResult.AgeNote)); if (probeResult.Allowed && Cfg.RequireSamePiece.Value && ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent2 == (Object)null || (Object)(object)componentInParent != (Object)(object)componentInParent2)) { probeResult.Allowed = false; probeResult.Verdict = "skip: the face and the side belong to different pieces"; } if (probeResult.Allowed) { Vector3 val6 = (((Object)(object)componentInParent2 != (Object)null) ? ((Component)componentInParent2).transform.position : ((Component)collider).transform.position); probeResult.Rx = Mathf.RoundToInt(val6.x); probeResult.Ry = Mathf.RoundToInt(val6.y); probeResult.Rz = Mathf.RoundToInt(val6.z); float midEdge = WrapPolicy.MidEdge(val5.x, val5.y, val5.z); SeamMethod seamMethod = (probeResult.Method = WrapPolicy.PickMethod(WrapPolicy.StyleFor(midEdge, Cfg.CornerMinEdge.Value, Cfg.Style.Value, Cfg.ThickStyle.Value), Cfg.Method.Value, midEdge, Cfg.CornerMinEdge.Value, Cfg.MixShare.Value, Roll(probeResult, 2), Roll(probeResult, 3))); probeResult.Allowed = Pose(probeResult, best, best3, normal, normalized, position, num3, v, num, seamMethod); if (!probeResult.Allowed && seamMethod == SeamMethod.Mitre) { string verdict = probeResult.Verdic
plugins/EinsteinCrew-PuckosCarePackage/Trinket-AdrenalineTURBORemix/Trinket-AdrenalineTURBORemix.dll
Decompiled 2 weeks 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.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace TrinketRebalance; internal class TrinketDef { public string Prefab; public string Name; public ConfigEntry<float> Cost; public ConfigEntry<float> ProcDuration; public ConfigEntry<string> ProcEffects; public ConfigEntry<string> PassiveEffects; public ConfigEntry<string> Affinity; public ConfigEntry<string> ScalingEffects; public ConfigEntry<bool> OnlyOwnSources; public ConfigEntry<float> DrainMultiplier; public ConfigEntry<int> UnlockLevel; public ConfigEntry<bool> ScaleProcDuration; public ConfigEntry<float> AffinitySpread; public ConfigEntry<float> DurationFloor; public int ProcHash; public int PassiveHash; public SE_Stats ProcSE; public EffectSpec Proc; public EffectSpec Passive; public EffectSpec Scaling; public AffinitySpec Aff; public bool IsScaling { get { if (Scaling != null && !Scaling.Vanilla) { return !string.IsNullOrEmpty((ScalingEffects.Value ?? "").Trim()); } return false; } } } internal class MeadDef { public string Prefab; public string Name; public ConfigEntry<float> Duration; public ConfigEntry<string> Effects; public EffectSpec Spec; } internal static class Cfg { public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> DumpGameValues; public static ConfigEntry<bool> UnequipEndsProc; public static ConfigEntry<bool> CapStaminaReduction; public static ConfigEntry<bool> MeadPoisonIgnoresArmor; public static ConfigEntry<float> MeleeHit; public static ConfigEntry<float> ProjectileHitMultiplier; public static ConfigEntry<float> StaffUseMultiplier; public static ConfigEntry<float> MeleeMiss; public static ConfigEntry<float> UnblockedHit; public static ConfigEntry<float> Block; public static ConfigEntry<float> Parry; public static ConfigEntry<float> PerfectDodge; public static ConfigEntry<float> NormalDodge; public static ConfigEntry<float> Stagger; public static ConfigEntry<float> ForsakenPowerFlat; public static ConfigEntry<float> ForsakenPowerPerSecond; public static ConfigEntry<float> ForsakenPowerDuration; public static ConfigEntry<float> WorldAdrenalineRate; public static ConfigEntry<float> OneStarMultiplier; public static ConfigEntry<float> TwoStarMultiplier; public static ConfigEntry<float> DrainSpeedMultiplier; public static ConfigEntry<float> DrainDelayMultiplier; public static ConfigEntry<bool> UpgradesEnabled; public static ConfigEntry<int> MaxLevel; public static ConfigEntry<float> UpgradeCostMultiplier; public static ConfigEntry<float> UpgradeCostGrowth; public static ConfigEntry<bool> TrophyOnlyToCraft; public static ConfigEntry<float> AffinityLevelSpread; public static readonly List<TrinketDef> Trinkets = new List<TrinketDef>(); public static readonly List<MeadDef> Meads = new List<MeadDef>(); public const float CodeMeleeHit = 1f; public const float CodeBlock = 2f; public const float CodeParry = 5f; private const string EffectHelp = "Comma-separated effects, for example: Heal=50, HealthRegen=+40%, BlockStamina=-50%, Skill=Bows:15, Resist=Fire:Resistant, MaxHealth=+50. Full key list in BepInEx/plugins/Trinket-AdrenalineTURBORemix/README.md. 'vanilla' = the game's own values; empty = no effect."; private const string AffinityHelp = "Actions that fill this trinket's bar faster. Multipliers: MeleeHit, ProjectileHit, StaffAttack, Block, Parry, PerfectDodge, Dodge, Stagger, All (for example Block=2). Flat gains: HitTaken=3 (per unblocked creature hit), Swimming=3 (per second, before the world adrenaline rate). Flag: NoMissPenalty. Empty = none."; public static void Bind(ConfigFile c) { Enabled = B(c, "1 General", "Enabled", v: true, "Master switch. Off puts every trinket, mead and adrenaline value back to the game's own values (handy for comparing in playtests)."); DumpGameValues = B(c, "1 General", "DumpGameValues", v: false, "On world start, write the game's real adrenaline, trinket, mead and weapon values to the BepInEx log and to BepInEx/Trinket-AdrenalineTURBORemix-GameValues.txt."); UnequipEndsProc = B(c, "1 General", "UnequipEndsProc", v: true, "Taking off or swapping a trinket ends its active proc (no trinket stacking)."); CapStaminaReduction = B(c, "1 General", "CapStaminaReductionAt100", v: false, "Stacked block/parry stamina reductions past -100% give stamina back (game behaviour). Turn this on to stop at zero instead. Attacks, dodges, runs, jumps and swims already stop at zero in the game."); MeadPoisonIgnoresArmor = B(c, "1 General", "MeadPoisonIgnoresArmor", v: true, "Poison from InflictPoison (Tasty Mead) is reduced by poison resistance but not by body armor. Off = it goes through armor like a poison hit from a creature (60 armor turns 25 poison into about 3)."); MeleeHit = F(c, "2 Adrenaline gain", "MeleeHit", 2f, "Adrenaline per melee or area hit (game code default 1). Weapons with their own value are scaled by the same ratio (value x MeleeHit / 1). Multiplied by the enemy's adrenaline multiplier."); ProjectileHitMultiplier = F(c, "2 Adrenaline gain", "ProjectileHitMultiplier", 1f, "Multiplier on each projectile's own adrenaline value (bows, crossbows, thrown spears, staff projectiles)."); StaffUseMultiplier = F(c, "2 Adrenaline gain", "StaffUseMultiplier", 1f, "Multiplier on the adrenaline some weapons give just for attacking, hit or miss (for example the Trollstav)."); MeleeMiss = F(c, "2 Adrenaline gain", "MeleeMiss", 0f, "Adrenaline change when a melee swing hits nothing. Negative = penalty. Game value -5."); UnblockedHit = F(c, "2 Adrenaline gain", "UnblockedHit", 0f, "Adrenaline change when you take a hit without blocking. Negative = penalty. Game value -5."); Block = F(c, "2 Adrenaline gain", "Block", 2f, "Adrenaline per block (game code default 2). Shields with their own value are scaled by the same ratio (value x Block / 2)."); Parry = F(c, "2 Adrenaline gain", "Parry", 10f, "Adrenaline per parry / perfect block (game code default 5). Shields with their own value are scaled by the same ratio (value x Parry / 5)."); PerfectDodge = F(c, "2 Adrenaline gain", "PerfectDodge", 15f, "Adrenaline for dodging through an incoming attack. Game value 10."); NormalDodge = F(c, "2 Adrenaline gain", "NormalDodge", 2f, "Adrenaline per dodge roll. The game gives nothing for this."); Stagger = F(c, "2 Adrenaline gain", "Stagger", 10f, "Adrenaline for staggering an enemy, times the enemy's adrenaline multiplier. Game code value 5 (the real value is logged on start)."); ForsakenPowerFlat = F(c, "2 Adrenaline gain", "ForsakenPowerFlat", 0f, "Instant adrenaline when you activate your Forsaken power. Game value 10."); ForsakenPowerPerSecond = F(c, "2 Adrenaline gain", "ForsakenPowerPerSecond", 3f, "Adrenaline per second from the Forsaken Rush buff you get when you activate your Forsaken power. 0 turns the buff off."); ForsakenPowerDuration = F(c, "2 Adrenaline gain", "ForsakenPowerDuration", 10f, "Length of the Forsaken Rush buff in seconds."); WorldAdrenalineRate = F(c, "3 Adrenaline bar", "WorldAdrenalineRate", 150f, "Percent scaling on every adrenaline gain. 0 = use the world's own AdrenalineRate setting (default 100)."); OneStarMultiplier = F(c, "3 Adrenaline bar", "OneStarEnemyMultiplier", 1f, "Extra multiplier on adrenaline from 1-star enemies (hits and staggers)."); TwoStarMultiplier = F(c, "3 Adrenaline bar", "TwoStarEnemyMultiplier", 1f, "Extra multiplier on adrenaline from enemies with 2 or more stars."); DrainSpeedMultiplier = F(c, "3 Adrenaline bar", "DrainSpeedMultiplier", 1f, "Multiplier on how fast the bar drains. 1 = game curve."); DrainDelayMultiplier = F(c, "3 Adrenaline bar", "DrainDelayMultiplier", 1f, "Multiplier on how long the bar waits before draining. 1 = game curve."); UpgradesEnabled = B(c, "6 Upgrades", "Enabled", v: true, "Trinkets can be upgraded at their crafting station. Level n of N gives n/N of every numeric effect. Off = every trinket works at full power and can't be upgraded."); MaxLevel = I(c, "6 Upgrades", "Levels", 4, "Number of levels (the trinket's max quality). A trinket crafted at level 1 has 1/Levels of its power. Changing it moves the upgrade steps; items already in inventories follow when the config reloads."); UpgradeCostMultiplier = F(c, "6 Upgrades", "UpgradeCostMultiplier", 2f, "Cost of the first upgrade (level 1 to 2) as a multiple of the trinket's craft amounts: 2 = twice the craft amount of every material except trophies."); UpgradeCostGrowth = F(c, "6 Upgrades", "UpgradeCostGrowth", 1f, "How much each further upgrade step costs relative to the one before. 1 = every step costs the same as the first (default), 2 = each step doubles (x2, x4, x8)."); TrophyOnlyToCraft = B(c, "6 Upgrades", "TrophyOnlyToCraft", v: true, "Trophies in a trinket's recipe are only needed to craft it, not to upgrade it."); AffinityLevelSpread = F(c, "6 Upgrades", "AffinityLevelSpread", 20f, "How much weaker a level 1 trinket's affinity bonus is than a max level one, in percent. 20 = level 1 gets 80% of the bonus (the part on top of the base gain), max level 100%. 0 = the same at every level."); Trinket(c, 1, "TrinketBronzeHealth", "Heart of the Forest", 50f, 30f, "HealthRegen=+40%", "HealthRegen=+10%, Resist=Poison:Resistant", "Block=2"); Trinket(c, 2, "TrinketBronzeStamina", "Bronze Pendant", 50f, 30f, "StaminaRegen=+40%", "StaminaRegen=+10%", "MeleeHit=1.5"); Trinket(c, 3, "TrinketIronHealth", "Iron Brooch", 65f, 20f, "Heal=50, BlockArmor=+15, BlockStamina=-50%", "ParryBonus=+20%, BlockArmor=+10", "Block=2, Parry=2"); Trinket(c, 4, "TrinketIronStamina", "Nimble Anklet", 50f, 10f, "RestoreStamina=50, MoveSpeed=+10%", "RunStamina=-20%, JumpStamina=-20%, MoveSpeed=+5%", "Dodge=2, PerfectDodge=2"); Trinket(c, 5, "TrinketChitinSwim", "Fins of Destiny", 100f, 0f, "", "SwimStamina=-10%, SwimSpeed=+10%, PreventWet", "Swimming=3", "SwimSpeed=+40%, SwimStamina=-15%", onlyOwn: true, 2f); Trinket(c, 6, "TrinketSilverDamage", "Wolf Sight", 55f, 30f, "Skill=Bows:15, Skill=Spears:15, PierceDamage=+20%", "Skill=Bows:10, Skill=Spears:10", "ProjectileHit=2"); Trinket(c, 7, "TrinketSilverResist", "Crystal Heart", 75f, 30f, "Resist=Physical:SlightlyResistant", "MaxHealth=+50", "HitTaken=6", "", onlyOwn: false, 1f, scaleDuration: true, 50f, 50f); Trinket(c, 8, "TrinketBlackDamageHealth", "Bracelets of the Brave", 70f, 30f, "Heal=100, PhysicalDamage=+20%, StaminaUse=-20%", "CarryWeight=+50", "Stagger=2"); Trinket(c, 9, "TrinketBlackStamina", "Evasion Mantle", 75f, 45f, "DodgeStamina=-40%, ParryBonus=+50%, Skill=Dodge:20", "DodgeStamina=-10%, Skill=Dodge:5", "Parry=2, PerfectDodge=2"); Trinket(c, 10, "TrinketCarapaceEitr", "Pulsating Earrings", 75f, 45f, "EitrRegen=+40%", "EitrRegen=+10%", "StaffAttack=1.5"); Trinket(c, 11, "TrinketScaleStaminaDamage", "Resounding Shackle", 75f, 6f, "RestoreStamina=100, PhysicalDamage=+100%", "AttackStamina=-20%", "MeleeHit=2, NoMissPenalty"); Trinket(c, 12, "TrinketFlametalEitr", "Jormundling", 70f, 30f, "RestoreEitr=100, Skill=ElementalMagic:20, Skill=BloodMagic:20", "Skill=ElementalMagic:5, Skill=BloodMagic:5", "StaffAttack=2"); Trinket(c, 13, "TrinketFlametalStaminaHealth", "Brimstone", 100f, 30f, "Heal=100, RestoreStamina=100, FireDamage=+30%", "Resist=Fire:Resistant", "All=1.25"); Trinket(c, 14, "TrinketBloodGoldStamina", "Witch Crown", 75f, 20f, "RestoreStamina=50, RestoreEitr=50, HealthRegen=+20%, StaminaRegen=+20%, EitrRegen=+20%, AdrenalineGain=+20%", "HealthRegen=+10%, StaminaRegen=+10%, EitrRegen=+10%, AdrenalineGain=+10%", ""); Trinket(c, 15, "TrinketBloodGoldHealth", "Neckstabber", 75f, 20f, "PhysicalDamage=+30%, RestoreStamina=50, RunStamina=-20%, AttackStamina=-20%, Adrenaline=25", "MoveSpeed=+5%, RunStamina=-10%, AttackStamina=-10%", "MeleeHit=1.5"); Mead(c, 1, "MeadBzerker", "Berserkir Mead", 15f, "AttackStamina=-80%, BlockStamina=-80%, DodgeStamina=-80%, Resist=Physical:VeryWeak, IgnoreResistances, AdrenalineGain=+100%"); Mead(c, 2, "MeadTasty", "Tasty Mead", 60f, "StaminaRegen=+80%, HealthRegen=-50%, AdrenalineGain=+20%, InflictPoison=25"); Mead(c, 3, "MeadSwimmer", "Draught of Vananidir", 0f, "SwimStamina=-50%, SwimSpeed=+20%"); Mead(c, 4, "MeadLightfoot", "Lightfoot Mead", 0f, "vanilla"); Mead(c, 5, "MeadHasty", "Tonic of Ratatosk", 0f, "vanilla"); Mead(c, 6, "MeadStaminaLingering", "Lingering Stamina Mead", 0f, "vanilla"); } private static void Trinket(ConfigFile c, int n, string prefab, string name, float cost, float dur, string proc, string passive, string aff, string scaling = "", bool onlyOwn = false, float drain = 1f, bool scaleDuration = false, float affSpread = -1f, float durFloor = -1f) { string s = "4 Trinket " + n.ToString("00") + " " + name; TrinketDef trinketDef = new TrinketDef { Prefab = prefab, Name = name }; trinketDef.Cost = F(c, s, "Cost", cost, name + " (" + prefab + "): adrenaline needed to fill the bar."); trinketDef.ProcDuration = F(c, s, "ProcDuration", dur, "Seconds the proc buff lasts. 0 = instant (no lasting buff)."); trinketDef.ProcEffects = S(c, s, "ProcEffects", proc, "What happens when the bar is full. Comma-separated effects, for example: Heal=50, HealthRegen=+40%, BlockStamina=-50%, Skill=Bows:15, Resist=Fire:Resistant, MaxHealth=+50. Full key list in BepInEx/plugins/Trinket-AdrenalineTURBORemix/README.md. 'vanilla' = the game's own values; empty = no effect."); trinketDef.PassiveEffects = S(c, s, "PassiveEffects", passive, "Always active while the trinket is equipped. Comma-separated effects, for example: Heal=50, HealthRegen=+40%, BlockStamina=-50%, Skill=Bows:15, Resist=Fire:Resistant, MaxHealth=+50. Full key list in BepInEx/plugins/Trinket-AdrenalineTURBORemix/README.md. 'vanilla' = the game's own values; empty = no effect."); trinketDef.Affinity = S(c, s, "Affinity", aff, "Actions that fill this trinket's bar faster. Multipliers: MeleeHit, ProjectileHit, StaffAttack, Block, Parry, PerfectDodge, Dodge, Stagger, All (for example Block=2). Flat gains: HitTaken=3 (per unblocked creature hit), Swimming=3 (per second, before the world adrenaline rate). Flag: NoMissPenalty. Empty = none."); trinketDef.ScalingEffects = S(c, s, "ScalingEffects", scaling, "Scaling mode. When this is filled in the trinket has NO proc (ProcEffects and ProcDuration are ignored, the bar just stays full at max) and these effects are added on top of the passive in proportion to how full the bar is: 0% empty, full effect at a full bar. Only numeric effects scale (SwimSpeed, SwimStamina, MoveSpeed, regen, stamina use, armor, damage %, skills...). Empty = normal proc trinket. Comma-separated effects, for example: Heal=50, HealthRegen=+40%, BlockStamina=-50%, Skill=Bows:15, Resist=Fire:Resistant, MaxHealth=+50. Full key list in BepInEx/plugins/Trinket-AdrenalineTURBORemix/README.md. 'vanilla' = the game's own values; empty = no effect."); trinketDef.OnlyOwnSources = B(c, s, "OnlyOwnSources", onlyOwn, "On = the bar fills only from this trinket's own Affinity gains (Swimming, HitTaken). Hits, blocks, dodges and other sources give it nothing. Penalties and draining still apply."); trinketDef.DrainMultiplier = F(c, s, "DrainMultiplier", drain, "Extra multiplier on how fast this trinket's bar drains, on top of DrainSpeedMultiplier in section 3. 2 = twice as fast."); trinketDef.UnlockLevel = I(c, s, "UnlockLevel", 2, "Upgrade level at which this trinket's on/off effects switch on (stay dry, Wisplight, resistances, ignore-resistances, no miss penalty). Numeric effects scale with the level instead. 1 = always on."); trinketDef.ScaleProcDuration = B(c, s, "ScaleProcDuration", scaleDuration, "On = the proc's on/off effects (resistances) work at every level and the proc's duration is scaled by the level instead (level 1 of 4 = 25% of ProcDuration)."); trinketDef.AffinitySpread = F(c, s, "AffinitySpread", affSpread, "Overrides AffinityLevelSpread (section 6) for this trinket, in percent. -1 = use the global value."); trinketDef.DurationFloor = F(c, s, "DurationFloor", durFloor, "Only with ScaleProcDuration: the proc duration at level 1 as a percent of ProcDuration, rising evenly to 100% at max level. -1 = the level's share of its power (25% at level 1 of 4)."); Trinkets.Add(trinketDef); } private static void Mead(ConfigFile c, int n, string prefab, string name, float dur, string effects) { string s = "5 Mead " + n + " " + name; MeadDef meadDef = new MeadDef { Prefab = prefab, Name = name }; meadDef.Duration = F(c, s, "Duration", dur, name + " (" + prefab + "): buff length in seconds, which is also its cooldown. 0 = keep the game's value."); meadDef.Effects = S(c, s, "Effects", effects, "Comma-separated effects, for example: Heal=50, HealthRegen=+40%, BlockStamina=-50%, Skill=Bows:15, Resist=Fire:Resistant, MaxHealth=+50. Full key list in BepInEx/plugins/Trinket-AdrenalineTURBORemix/README.md. 'vanilla' = the game's own values; empty = no effect."); Meads.Add(meadDef); } private static ConfigurationManagerAttributes Admin() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true }; } private static ConfigEntry<bool> B(ConfigFile c, string s, string k, bool v, string d) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return c.Bind<bool>(s, k, v, new ConfigDescription(d, (AcceptableValueBase)null, new object[1] { Admin() })); } private static ConfigEntry<int> I(ConfigFile c, string s, string k, int v, string d) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return c.Bind<int>(s, k, v, new ConfigDescription(d, (AcceptableValueBase)null, new object[1] { Admin() })); } private static ConfigEntry<float> F(ConfigFile c, string s, string k, float v, string d) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return c.Bind<float>(s, k, v, new ConfigDescription(d, (AcceptableValueBase)null, new object[1] { Admin() })); } private static ConfigEntry<string> S(ConfigFile c, string s, string k, string v, string d) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return c.Bind<string>(s, k, v, new ConfigDescription(d, (AcceptableValueBase)null, new object[1] { Admin() })); } } internal static class Dump { private static bool s_done; private static readonly HashSet<string> SkipFields = new HashSet<string> { "m_character", "m_time", "m_startEffectInstances", "m_nameHash", "m_isNew", "m_msgTimer", "m_tickTimer", "m_healthOverTimeTimer", "m_healthOverTimeTicks", "m_healthOverTimeTickHP", "m_hitVariant", "m_timer", "m_damageLeft", "m_damagePerHit" }; public static void TryRun() { if (s_done || Cfg.DumpGameValues == null || !Cfg.DumpGameValues.Value) { return; } ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null || instance.m_items == null || instance.m_items.Count == 0 || (Object)(object)ZNetScene.instance == (Object)null) { return; } s_done = true; StringBuilder stringBuilder = new StringBuilder(); try { Build(stringBuilder, instance); } catch (Exception ex) { stringBuilder.AppendLine("Dump failed part-way: " + ex); } string text = stringBuilder.ToString(); Plugin.Log.LogInfo((object)("Game value dump (unmodified values):\n" + text)); try { string text2 = Path.Combine(Paths.BepInExRootPath, "Trinket-AdrenalineTURBORemix-GameValues.txt"); File.WriteAllText(text2, text); Plugin.Log.LogInfo((object)("Game value dump written to " + text2)); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Could not write dump file: " + ex2.Message)); } } private static void Build(StringBuilder sb, ObjectDB db) { //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01c5: 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_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Expected O, but got Unknown //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Expected O, but got Unknown //IL_0635: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Invalid comparison between Unknown and I4 sb.AppendLine("Trinket-AdrenalineTURBORemix 0.2.6 - game values before the mod changes them"); sb.AppendLine("Written " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)); sb.AppendLine(); sb.AppendLine("== Player prefab (adrenaline) =="); GameObject prefab = ZNetScene.instance.GetPrefab("Player"); Player val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Player>() : null); if ((Object)(object)val == (Object)null) { sb.AppendLine("Player prefab not found"); } else { Line(sb, "m_maxAdrenaline (added to the trinket cost)", val.m_maxAdrenaline); Line(sb, "m_perfectDodgeAdrenaline", val.m_perfectDodgeAdrenaline); Line(sb, "m_dodgeAdrenaline (unused by the game)", val.m_dodgeAdrenaline); Line(sb, "m_attackMissAdrenaline", val.m_attackMissAdrenaline); Line(sb, "m_nonBlockDamageAdrenaline", val.m_nonBlockDamageAdrenaline); Line(sb, "m_staggerEnemyAdrenaline", val.m_staggerEnemyAdrenaline); Line(sb, "m_adrenalineGuardianPower", Players.GuardianPower.Invoke(val)); Line(sb, "m_perfectDodgeStaminaReturnMultiplier", val.m_perfectDodgeStaminaReturnMultiplier); sb.AppendLine("m_adrenalineGainMultiplier curve (bar fill 0-1 -> gain x): " + Curve(val.m_adrenalineGainMultiplier)); sb.AppendLine("m_adrenalineDegenDelay curve (bar fill -> seconds before drain): " + Curve(val.m_adrenalineDegenDelay)); sb.AppendLine("m_adrenalineDegen curve (bar fill -> drain per second): " + Curve(val.m_adrenalineDegen)); sb.AppendLine("m_adrenalineEffects (bar level -> buff):"); if (val.m_adrenalineEffects == null || val.m_adrenalineEffects.Count == 0) { sb.AppendLine(" none"); } else { foreach (StatusEffectLevel adrenalineEffect in val.m_adrenalineEffects) { sb.AppendLine(" at " + F(adrenalineEffect.m_rate) + ": " + Describe(adrenalineEffect.m_se, adrenalineEffect.m_se)); } } } sb.AppendLine("World AdrenalineRate: " + (WorldRate.Known ? ((WorldRate.GameRate * 100f).ToString("0") + "%") : "not loaded yet (logged separately when the world starts)")); sb.AppendLine(); sb.AppendLine("== Trinkets =="); foreach (TrinketDef trinket in Cfg.Trinkets) { GameObject itemPrefab = db.GetItemPrefab(trinket.Prefab); ItemDrop val2 = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 == (Object)null) { sb.AppendLine(trinket.Prefab + ": NOT FOUND"); continue; } SharedData shared = val2.m_itemData.m_shared; Rebalance.ItemVanillaInfo itemVanillaInfo = Rebalance.VanillaItem(shared); sb.AppendLine(trinket.Prefab + " = \"" + Loc(shared.m_name) + "\" (expected " + trinket.Name + ")"); sb.AppendLine(" cost (m_maxAdrenaline): " + F(itemVanillaInfo.MaxAdrenaline)); StatusEffect fullAdrenalineSE = shared.m_fullAdrenalineSE; sb.AppendLine(" proc: " + Describe(fullAdrenalineSE, (StatusEffect)((fullAdrenalineSE is SE_Stats) ? ((object)Rebalance.VanillaOf((SE_Stats)fullAdrenalineSE)) : ((object)fullAdrenalineSE)))); sb.AppendLine(" equip effect: " + Describe(itemVanillaInfo.EquipSE, itemVanillaInfo.EquipSE)); sb.AppendLine(" description: " + Loc(Rebalance.VanillaDescription(shared)).Replace("\n", " / ")); } sb.AppendLine(); sb.AppendLine("== Meads =="); string text = null; string text2 = null; foreach (MeadDef mead in Cfg.Meads) { GameObject itemPrefab2 = db.GetItemPrefab(mead.Prefab); ItemDrop val3 = (((Object)(object)itemPrefab2 != (Object)null) ? itemPrefab2.GetComponent<ItemDrop>() : null); if ((Object)(object)val3 == (Object)null) { sb.AppendLine(mead.Prefab + ": NOT FOUND"); continue; } StatusEffect consumeStatusEffect = val3.m_itemData.m_shared.m_consumeStatusEffect; StatusEffect val4 = (StatusEffect)((consumeStatusEffect is SE_Stats) ? ((object)Rebalance.VanillaOf((SE_Stats)consumeStatusEffect)) : ((object)consumeStatusEffect)); sb.AppendLine(mead.Prefab + " = \"" + Loc(val3.m_itemData.m_shared.m_name) + "\": " + Describe(consumeStatusEffect, val4)); if ((Object)(object)val4 != (Object)null) { if (mead.Prefab == "MeadTasty") { text = val4.m_category; } if (mead.Prefab == "MeadBzerker") { text2 = val4.m_category; } } } if (text != null && text2 != null) { sb.AppendLine("Tasty Mead and Berserkir Mead " + ((!string.IsNullOrEmpty(text) && text == text2) ? ("SHARE category '" + text + "': they cannot be active together.") : ("have different categories ('" + text + "' / '" + text2 + "'): they can stack."))); } StatusEffect statusEffect = db.GetStatusEffect(SEMan.s_statusEffectPoison); sb.AppendLine("Poison effect: " + Describe(statusEffect, statusEffect)); sb.AppendLine(); sb.AppendLine("== Weapon / shield / projectile adrenaline (only values that differ from the code defaults) =="); sb.AppendLine("Code defaults: hit 1, use 0, block 2, parry 5, projectile 2"); int num = 0; int num2 = 0; foreach (GameObject item in db.m_items) { ItemDrop val5 = (((Object)(object)item != (Object)null) ? item.GetComponent<ItemDrop>() : null); if ((Object)(object)val5 == (Object)null) { continue; } SharedData shared2 = val5.m_itemData.m_shared; if (!IsCombatItem(shared2.m_itemType)) { continue; } num++; List<string> list = new List<string>(); AttackParts(list, "primary", shared2.m_attack); AttackParts(list, "secondary", shared2.m_secondaryAttack); if (shared2.m_blockPower > 0f || (int)shared2.m_itemType == 5) { if (shared2.m_blockAdrenaline != 2f) { list.Add("block " + F(shared2.m_blockAdrenaline)); } if (shared2.m_perfectBlockAdrenaline != 5f) { list.Add("parry " + F(shared2.m_perfectBlockAdrenaline)); } } if (list.Count > 0) { num2++; sb.AppendLine(" " + ((Object)item).name + " (" + Loc(shared2.m_name) + "): " + string.Join(", ", list.ToArray())); } } sb.AppendLine(" (" + num + " combat items checked, " + num2 + " listed; the rest use the defaults)"); sb.AppendLine(); sb.AppendLine("== Creatures with an adrenaline multiplier other than 1 =="); int num3 = 0; int num4 = 0; foreach (GameObject prefab2 in ZNetScene.instance.m_prefabs) { Character val6 = (((Object)(object)prefab2 != (Object)null) ? prefab2.GetComponent<Character>() : null); if (!((Object)(object)val6 == (Object)null)) { num3++; if (Math.Abs(val6.m_enemyAdrenalineMultiplier - 1f) > 0.0001f) { num4++; sb.AppendLine(" " + ((Object)prefab2).name + ": x" + F(val6.m_enemyAdrenalineMultiplier)); } } } sb.AppendLine(" (" + num3 + " creatures checked, " + num4 + " listed)"); } private static bool IsCombatItem(ItemType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0012: 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_0017: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_001e: 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_0023: Invalid comparison between Unknown and I4 if ((int)t <= 9) { if (t - 3 <= 2 || (int)t == 9) { goto IL_0025; } } else if (t - 14 <= 1 || (int)t == 19 || t - 22 <= 1) { goto IL_0025; } return false; IL_0025: return true; } private static void AttackParts(List<string> parts, string label, Attack a) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if (a == null || (int)a.m_attackType == 3) { return; } if (a.m_attackAdrenaline != 1f) { parts.Add(label + " hit " + F(a.m_attackAdrenaline)); } if (a.m_attackUseAdrenaline != 0f) { parts.Add(label + " use " + F(a.m_attackUseAdrenaline)); } if ((Object)(object)a.m_attackProjectile != (Object)null) { Projectile component = a.m_attackProjectile.GetComponent<Projectile>(); if ((Object)(object)component != (Object)null && component.m_adrenaline != 2f) { parts.Add(label + " projectile " + F(component.m_adrenaline)); } } } private static void Line(StringBuilder sb, string name, float v) { sb.AppendLine(name + ": " + F(v)); } private static string F(float v) { return v.ToString("0.###", CultureInfo.InvariantCulture); } private static string Loc(string s) { if (string.IsNullOrEmpty(s)) { return ""; } try { return (Localization.instance != null) ? Localization.instance.Localize(s) : s; } catch { return s; } } private static string Curve(AnimationCurve c) { //IL_002d: 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) if (c == null || c.keys == null || c.keys.Length == 0) { return "(empty)"; } List<string> list = new List<string>(); Keyframe[] keys = c.keys; for (int i = 0; i < keys.Length; i++) { Keyframe val = keys[i]; list.Add(F(((Keyframe)(ref val)).time) + "->" + F(((Keyframe)(ref val)).value)); } List<string> list2 = new List<string>(); for (int j = 0; j <= 4; j++) { list2.Add(F((float)j * 0.25f) + ":" + F(c.Evaluate((float)j * 0.25f))); } return "keys [" + string.Join(", ", list.ToArray()) + "]; sampled [" + string.Join(", ", list2.ToArray()) + "]"; } internal static string Describe(StatusEffect se, StatusEffect values) { if ((Object)(object)se == (Object)null || (Object)(object)values == (Object)null) { return "none"; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(((Object)se).name).Append(" [").Append(((object)se).GetType().Name) .Append("]"); ScriptableObject val = null; try { val = ScriptableObject.CreateInstance(((object)se).GetType()); Type type = ((object)se).GetType(); while (type != null && type != typeof(ScriptableObject)) { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (SkipFields.Contains(fieldInfo.Name)) { continue; } Type fieldType = fieldInfo.FieldType; if ((!typeof(Object).IsAssignableFrom(fieldType) || !(fieldType != typeof(Sprite))) && !(fieldType == typeof(EffectList))) { string text = Str(fieldInfo.GetValue(values)); string text2 = Str(fieldInfo.GetValue(val)); if (text != text2) { stringBuilder.Append(" ").Append(fieldInfo.Name).Append("=") .Append(text); } } } type = type.BaseType; } } catch (Exception ex) { stringBuilder.Append(" (error: ").Append(ex.Message).Append(")"); } finally { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } return stringBuilder.ToString(); } private unsafe static string Str(object o) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (o == null) { return "null"; } if (o is float) { return F((float)o); } if (o is string) { return "\"" + Loc((string)o).Replace("\n", " / ") + "\""; } if (o is Sprite) { if (!((Object)(Sprite)o != (Object)null)) { return "null"; } return "set"; } if (o is DamageTypes val) { List<string> list = new List<string>(); FieldInfo[] fields = typeof(DamageTypes).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType != typeof(float))) { float num = (float)fieldInfo.GetValue(val); if (num != 0f) { list.Add(fieldInfo.Name.Substring(2) + ":" + F(num)); } } } return "{" + string.Join(" ", list.ToArray()) + "}"; } if (o is DamageModPair val2) { return ((object)(*(DamageType*)(&val2.m_type))/*cast due to .constrained prefix*/).ToString() + ":" + ((object)(*(DamageModifier*)(&val2.m_modifier))/*cast due to .constrained prefix*/).ToString(); } if (o is AnimationCurve) { return Curve((AnimationCurve)o); } if (o is IList list2) { List<string> list3 = new List<string>(); foreach (object item in list2) { list3.Add(Str(item)); } return "[" + string.Join(", ", list3.ToArray()) + "]"; } return Convert.ToString(o, CultureInfo.InvariantCulture); } } internal class EffectSpec { public bool Vanilla; public readonly List<string> Errors = new List<string>(); public float Heal; public float RestoreStamina; public float RestoreEitr; public float HealOverTime; public float StaminaPerSecond; public float HealthRegen; public float StaminaRegen; public float EitrRegen; public float AdrenalineGain; public float MoveSpeed; public float SwimSpeed; public float AllStamina; public float AttackStamina; public float BlockStamina; public float DodgeStamina; public float RunStamina; public float JumpStamina; public float SwimStamina; public float SneakStamina; public float Armor; public float ParryBonus; public float CarryWeight; public DamageTypes DamagePct; public readonly List<KeyValuePair<SkillType, float>> SkillBonuses = new List<KeyValuePair<SkillType, float>>(); public readonly List<KeyValuePair<SkillType, float>> ExtraSkills = new List<KeyValuePair<SkillType, float>>(); public readonly List<DamageModPair> Mods = new List<DamageModPair>(); public float BlockArmor; public float MaxHealth; public float MaxStamina; public float MaxEitr; public float AdrenalineRefund; public float InflictPoison; public bool IgnoreResistances; public bool Wisplight; public bool PreventWet; public float HealInterval; private static FieldInfo[] s_floatFields; private static FieldInfo[] s_damageFields; public bool HasCustom { get { if (BlockArmor == 0f && MaxHealth == 0f && MaxStamina == 0f && MaxEitr == 0f && AdrenalineRefund == 0f && InflictPoison == 0f && !IgnoreResistances && !Wisplight && !PreventWet) { return ExtraSkills.Count > 0; } return true; } } internal bool HasUnlockables { get { if (!IgnoreResistances && !Wisplight && !PreventWet) { return Mods.Count > 0; } return true; } } public static EffectSpec Parse(string text, string context) { EffectSpec effectSpec = new EffectSpec(); if (text == null) { return effectSpec; } string text2 = Norm(text); if (text2.Length == 0) { return effectSpec; } if (text2.Equals("vanilla", StringComparison.OrdinalIgnoreCase)) { effectSpec.Vanilla = true; return effectSpec; } string[] array = text2.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text3 = array[i].Trim(); if (text3.Length == 0) { continue; } string text4 = text3; string v = ""; int num = text3.IndexOf('='); if (num >= 0) { text4 = text3.Substring(0, num).Trim(); v = text3.Substring(num + 1).Trim(); } string k = text4.ToLowerInvariant().Replace(" ", "").Replace("_", ""); try { if (!effectSpec.ApplyToken(k, v)) { effectSpec.Errors.Add(context + ": unknown effect '" + text3 + "'"); } } catch (Exception ex) { effectSpec.Errors.Add(context + ": could not read '" + text3 + "' (" + ex.Message + ")"); } } if (effectSpec.SkillBonuses.Count > 2) { effectSpec.ExtraSkills.AddRange(effectSpec.SkillBonuses.GetRange(2, effectSpec.SkillBonuses.Count - 2)); effectSpec.SkillBonuses.RemoveRange(2, effectSpec.SkillBonuses.Count - 2); } return effectSpec; } private bool ApplyToken(string k, string v) { switch (k) { case "heal": case "heals": case "healupfront": Heal += Num(v); return true; case "restorestamina": case "staminaupfront": case "stamina": RestoreStamina += Num(v); return true; case "eitr": case "restoreeitr": case "eitrupfront": RestoreEitr += Num(v); return true; case "healovertime": case "hot": HealOverTime += Num(v); return true; case "staminapersecond": case "staminapersec": case "staminaovertime": StaminaPerSecond += Num(v); return true; case "hotinterval": case "healinterval": case "healovertimeinterval": { float num2 = Num(v); if (num2 <= 0f) { throw new FormatException("must be above 0 seconds"); } HealInterval = num2; return true; } case "wisp": case "wisplight": case "demister": Wisplight = v.Length == 0 || Bool(v); return true; case "nowet": case "staydry": case "preventwet": case "waterproof": PreventWet = v.Length == 0 || Bool(v); return true; case "healthregen": HealthRegen += Pct(v); return true; case "staminaregen": StaminaRegen += Pct(v); return true; case "eitrregen": EitrRegen += Pct(v); return true; case "adrenalinegain": case "adrenalinemodifier": AdrenalineGain += Pct(v); return true; case "speed": case "movementspeed": case "movespeed": MoveSpeed += Pct(v); return true; case "swimspeed": SwimSpeed += Pct(v); return true; case "staminauseall": case "staminause": case "allstamina": AllStamina += Pct(v); return true; case "attackstamina": AttackStamina += Pct(v); return true; case "blockstamina": case "parrystamina": BlockStamina += Pct(v); return true; case "dodgestamina": DodgeStamina += Pct(v); return true; case "runstamina": RunStamina += Pct(v); return true; case "jumpstamina": JumpStamina += Pct(v); return true; case "swimstamina": SwimStamina += Pct(v); return true; case "sneakstamina": SneakStamina += Pct(v); return true; case "armor": Armor += Num(v); return true; case "blockarmor": case "blockpower": BlockArmor += Num(v); return true; case "parrybonus": ParryBonus += Pct(v); return true; case "carryweight": CarryWeight += Num(v); return true; case "maxhealth": case "health": MaxHealth += Num(v); return true; case "maxstamina": MaxStamina += Num(v); return true; case "maxeitr": MaxEitr += Num(v); return true; case "adrenalinerefund": case "adrenaline": AdrenalineRefund += Num(v); return true; case "inflictpoison": PoisonOnStart(v); return true; case "ignoreresistances": IgnoreResistances = v.Length == 0 || Bool(v); return true; case "skill": AddSkill(v); return true; case "modifier": case "resistance": case "resist": AddResist(v); return true; default: if (k.EndsWith("damage")) { string text = k.Substring(0, k.Length - "damage".Length); float num = Pct(v); switch (text) { case "every": case "all": DamagePct.m_blunt += num; DamagePct.m_slash += num; DamagePct.m_pierce += num; DamagePct.m_fire += num; DamagePct.m_frost += num; DamagePct.m_lightning += num; DamagePct.m_poison += num; DamagePct.m_spirit += num; return true; case "physical": DamagePct.m_blunt += num; DamagePct.m_slash += num; DamagePct.m_pierce += num; return true; case "elemental": DamagePct.m_fire += num; DamagePct.m_frost += num; DamagePct.m_lightning += num; return true; case "blunt": DamagePct.m_blunt += num; return true; case "slash": DamagePct.m_slash += num; return true; case "pierce": DamagePct.m_pierce += num; return true; case "chop": DamagePct.m_chop += num; return true; case "pickaxe": DamagePct.m_pickaxe += num; return true; case "fire": DamagePct.m_fire += num; return true; case "frost": DamagePct.m_frost += num; return true; case "lightning": DamagePct.m_lightning += num; return true; case "poison": DamagePct.m_poison += num; return true; case "spirit": DamagePct.m_spirit += num; return true; } } return false; } } private void PoisonOnStart(string v) { InflictPoison += Num(v); } private void AddSkill(string v) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) int num = v.IndexOf(':'); if (num < 0) { throw new FormatException("use Skill=Name:amount"); } string name = v.Substring(0, num).Trim(); float value = Num(v.Substring(num + 1)); SkillBonuses.Add(new KeyValuePair<SkillType, float>(SkillByName(name), value)); } private static SkillType SkillByName(string name) { //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) string text = name.ToLowerInvariant().Replace(" ", ""); switch (text) { case "bow": text = "bows"; break; case "spear": text = "spears"; break; case "sword": text = "swords"; break; case "knife": text = "knives"; break; case "clubs": case "maces": case "club": case "mace": text = "clubs"; break; case "axe": text = "axes"; break; case "polearm": case "atgeir": text = "polearms"; break; case "crossbow": text = "crossbows"; break; case "elemental": case "elementalmagic": text = "elementalmagic"; break; case "blood": case "bloodmagic": text = "bloodmagic"; break; case "block": text = "blocking"; break; case "fists": case "fist": text = "unarmed"; break; case "swimming": text = "swim"; break; case "running": text = "run"; break; } foreach (SkillType value in Enum.GetValues(typeof(SkillType))) { if (((object)value/*cast due to .constrained prefix*/).ToString().ToLowerInvariant() == text) { return value; } } throw new FormatException("unknown skill '" + name + "'"); } private void AddResist(string v) { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) int num = v.IndexOf(':'); if (num < 0) { throw new FormatException("use Resist=Type:Level"); } string text = v.Substring(0, num).Trim().ToLowerInvariant(); string text2 = v.Substring(num + 1).Trim().ToLowerInvariant() .Replace(" ", ""); DamageModifier modifier = (DamageModifier)(text2 switch { "normal" => 0, "resistant" => 1, "veryresistant" => 5, "slightlyresistant" => 7, "weak" => 2, "veryweak" => 6, "slightlyweak" => 8, "immune" => 3, "ignore" => 4, _ => throw new FormatException("unknown level '" + text2 + "'"), }); DamageType[] array; switch (text) { case "every": case "all": { DamageType[] array4 = new DamageType[8]; RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); array = (DamageType[])(object)array4; break; } case "physical": { DamageType[] array3 = new DamageType[3]; RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); array = (DamageType[])(object)array3; break; } case "elemental": { DamageType[] array2 = new DamageType[3]; RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); array = (DamageType[])(object)array2; break; } case "blunt": array = (DamageType[])(object)new DamageType[1] { (DamageType)1 }; break; case "slash": array = (DamageType[])(object)new DamageType[1] { (DamageType)2 }; break; case "pierce": array = (DamageType[])(object)new DamageType[1] { (DamageType)4 }; break; case "chop": array = (DamageType[])(object)new DamageType[1] { (DamageType)8 }; break; case "pickaxe": array = (DamageType[])(object)new DamageType[1] { (DamageType)16 }; break; case "fire": array = (DamageType[])(object)new DamageType[1] { (DamageType)32 }; break; case "frost": array = (DamageType[])(object)new DamageType[1] { (DamageType)64 }; break; case "lightning": array = (DamageType[])(object)new DamageType[1] { (DamageType)128 }; break; case "poison": array = (DamageType[])(object)new DamageType[1] { (DamageType)256 }; break; case "spirit": array = (DamageType[])(object)new DamageType[1] { (DamageType)512 }; break; default: throw new FormatException("unknown damage type '" + text + "'"); } DamageType[] array5 = array; foreach (DamageType type in array5) { Mods.Add(new DamageModPair { m_type = type, m_modifier = modifier }); } } internal static string Norm(string s) { return s.Replace('−', '-').Replace('–', '-').Replace('×', 'x') .Trim(); } internal static float Num(string v) { string text = Norm(v).Replace("%", "").Replace(" ", ""); if (text.StartsWith("+")) { text = text.Substring(1); } if (text.EndsWith("s")) { text = text.Substring(0, text.Length - 1); } if (text.StartsWith("x") || text.StartsWith("X")) { text = text.Substring(1); } return float.Parse(text, NumberStyles.Float, CultureInfo.InvariantCulture); } private static float Pct(string v) { return Num(v) / 100f; } private static bool Bool(string v) { string text = v.Trim().ToLowerInvariant(); switch (text) { default: return text == "on"; case "true": case "yes": case "1": return true; } } public void ApplyTo(SE_Stats se) { //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) se.m_healthUpFront = Heal; se.m_staminaUpFront = RestoreStamina; se.m_eitrUpFront = RestoreEitr; se.m_healthOverTime = HealOverTime; se.m_staminaOverTime = ((StaminaPerSecond > 0f) ? (StaminaPerSecond * ((StatusEffect)se).m_ttl) : 0f); se.m_staminaOverTimeDuration = 0f; se.m_staminaOverTimeIsFraction = false; if (HealInterval > 0f) { se.m_healthOverTimeInterval = HealInterval; } se.m_healthRegenMultiplier = 1f + HealthRegen; se.m_staminaRegenMultiplier = 1f + StaminaRegen; se.m_eitrRegenMultiplier = 1f + EitrRegen; se.m_adrenalineModifier = AdrenalineGain; se.m_speedModifier = MoveSpeed; se.m_swimSpeedModifier = SwimSpeed; se.m_attackStaminaUseModifier = AllStamina + AttackStamina; se.m_blockStaminaUseModifier = AllStamina + BlockStamina; se.m_dodgeStaminaUseModifier = AllStamina + DodgeStamina; se.m_runStaminaDrainModifier = AllStamina + RunStamina; se.m_runStaminaUseModifier = 0f; se.m_jumpStaminaUseModifier = AllStamina + JumpStamina; se.m_swimStaminaUseModifier = AllStamina + SwimStamina; se.m_sneakStaminaUseModifier = AllStamina + SneakStamina; se.m_addArmor = Armor; se.m_timedBlockBonus = ParryBonus; se.m_addMaxCarryWeight = CarryWeight; se.m_percentigeDamageModifiers = DamagePct; se.m_skillLevel = (SkillType)((SkillBonuses.Count > 0) ? ((int)SkillBonuses[0].Key) : 0); se.m_skillLevelModifier = ((SkillBonuses.Count > 0) ? SkillBonuses[0].Value : 0f); se.m_skillLevel2 = (SkillType)((SkillBonuses.Count > 1) ? ((int)SkillBonuses[1].Key) : 0); se.m_skillLevelModifier2 = ((SkillBonuses.Count > 1) ? SkillBonuses[1].Value : 0f); se.m_mods = new List<DamageModPair>(Mods); } public string CustomTooltip() { //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); if (AllStamina != 0f) { stringBuilder.AppendFormat("All stamina use: <color=orange>{0}%</color>\n", Signed(AllStamina * 100f)); } if (MaxHealth != 0f) { stringBuilder.AppendFormat("Max health: <color=orange>{0}</color>\n", Signed(MaxHealth)); } if (MaxStamina != 0f) { stringBuilder.AppendFormat("Max stamina: <color=orange>{0}</color>\n", Signed(MaxStamina)); } if (MaxEitr != 0f) { stringBuilder.AppendFormat("Max eitr: <color=orange>{0}</color>\n", Signed(MaxEitr)); } if (BlockArmor != 0f) { stringBuilder.AppendFormat("$item_blockarmor: <color=orange>{0}</color> (on the item you block with)\n", Signed(BlockArmor)); } if (AdrenalineRefund != 0f) { stringBuilder.AppendFormat("Adrenaline kept after the proc: <color=orange>{0}</color>\n", Fmt(AdrenalineRefund)); } if (InflictPoison != 0f) { stringBuilder.AppendFormat("Poisons you when drunk: <color=orange>{0}</color>\n", Fmt(InflictPoison)); } if (IgnoreResistances) { stringBuilder.Append("<color=orange>Weakness ignores resistances</color>\n"); } if (HealOverTime > 0f && HealInterval > 0f) { stringBuilder.AppendFormat("Heal over time: <color=orange>{0}</color> in total, a tick every <color=orange>{1}s</color>\n", Fmt(HealOverTime), Fmt(HealInterval)); } if (Wisplight) { stringBuilder.Append("Summons a <color=orange>Wisplight</color> (clears Mistlands mist)\n"); } if (PreventWet) { stringBuilder.Append("You <color=orange>don't get wet</color>\n"); } foreach (KeyValuePair<SkillType, float> extraSkill in ExtraSkills) { stringBuilder.AppendFormat("$skill_{0} <color=orange>{1}</color>\n", ((object)extraSkill.Key/*cast due to .constrained prefix*/).ToString().ToLower(), extraSkill.Value.ToString("+0;-0", CultureInfo.InvariantCulture)); } return stringBuilder.ToString().TrimEnd('\n'); } private static FieldInfo[] FloatFields() { if (s_floatFields == null) { List<FieldInfo> list = new List<FieldInfo>(); FieldInfo[] fields = typeof(EffectSpec).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(float)) { list.Add(fieldInfo); } } s_floatFields = list.ToArray(); } return s_floatFields; } private static FieldInfo[] DamageFields() { if (s_damageFields == null) { List<FieldInfo> list = new List<FieldInfo>(); FieldInfo[] fields = typeof(DamageTypes).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(float)) { list.Add(fieldInfo); } } s_damageFields = list.ToArray(); } return s_damageFields; } internal static EffectSpec Blend(EffectSpec baseSpec, EffectSpec extra, float f) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) EffectSpec effectSpec = new EffectSpec(); baseSpec = baseSpec ?? new EffectSpec(); effectSpec.IgnoreResistances = baseSpec.IgnoreResistances; effectSpec.Wisplight = baseSpec.Wisplight; effectSpec.PreventWet = baseSpec.PreventWet; effectSpec.SkillBonuses.AddRange(baseSpec.SkillBonuses); effectSpec.ExtraSkills.AddRange(baseSpec.ExtraSkills); effectSpec.Mods.AddRange(baseSpec.Mods); FieldInfo[] array = FloatFields(); foreach (FieldInfo fieldInfo in array) { fieldInfo.SetValue(effectSpec, (float)fieldInfo.GetValue(baseSpec) + f * ((extra != null) ? ((float)fieldInfo.GetValue(extra)) : 0f)); } effectSpec.HealInterval = ((baseSpec.HealInterval > 0f) ? baseSpec.HealInterval : (extra?.HealInterval ?? 0f)); object obj = baseSpec.DamagePct; object obj2 = ((extra != null) ? ((object)extra.DamagePct) : ((object)default(DamageTypes))); array = DamageFields(); foreach (FieldInfo fieldInfo2 in array) { fieldInfo2.SetValue(obj, (float)fieldInfo2.GetValue(obj) + f * (float)fieldInfo2.GetValue(obj2)); } effectSpec.DamagePct = (DamageTypes)obj; if (extra != null) { foreach (KeyValuePair<SkillType, float> skillBonuse in extra.SkillBonuses) { effectSpec.AddScaledSkill(skillBonuse.Key, skillBonuse.Value * f); } foreach (KeyValuePair<SkillType, float> extraSkill in extra.ExtraSkills) { effectSpec.AddScaledSkill(extraSkill.Key, extraSkill.Value * f); } } return effectSpec; } internal static EffectSpec ForLevel(EffectSpec spec, float f, bool unlocked) { EffectSpec effectSpec = Blend(new EffectSpec(), spec, f); effectSpec.Vanilla = spec.Vanilla; if (unlocked) { effectSpec.IgnoreResistances = spec.IgnoreResistances; effectSpec.Wisplight = spec.Wisplight; effectSpec.PreventWet = spec.PreventWet; effectSpec.Mods.AddRange(spec.Mods); } return effectSpec; } internal unsafe List<string> UnlockNames() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); if (IgnoreResistances) { list.Add("weakness ignores resistances"); } if (Wisplight) { list.Add("a Wisplight"); } if (PreventWet) { list.Add("you don't get wet"); } foreach (DamageModPair mod in Mods) { DamageModifier modifier = mod.m_modifier; string text = ((object)(*(DamageModifier*)(&modifier))/*cast due to .constrained prefix*/).ToString().Replace("VeryResistant", "very resistant").Replace("Resistant", "resistant") .ToLowerInvariant(); DamageType type = mod.m_type; list.Add(text + " to $inventory_" + ((object)(*(DamageType*)(&type))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant()); } return list; } private void AddScaledSkill(SkillType key, float amount) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0078: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < SkillBonuses.Count; i++) { if (SkillBonuses[i].Key == key) { SkillBonuses[i] = new KeyValuePair<SkillType, float>(key, SkillBonuses[i].Value + amount); return; } } for (int j = 0; j < ExtraSkills.Count; j++) { if (ExtraSkills[j].Key == key) { ExtraSkills[j] = new KeyValuePair<SkillType, float>(key, ExtraSkills[j].Value + amount); return; } } KeyValuePair<SkillType, float> item = new KeyValuePair<SkillType, float>(key, amount); if (SkillBonuses.Count < 2) { SkillBonuses.Add(item); } else { ExtraSkills.Add(item); } } internal static string Readable(string text) { if (string.IsNullOrEmpty(text)) { return ""; } List<string> list = new List<string>(); string[] array = Norm(text).Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length != 0) { int num = text2.IndexOf('='); string input = ((num >= 0) ? text2.Substring(0, num).Trim() : text2); string text3 = ((num >= 0) ? text2.Substring(num + 1).Trim() : ""); input = Regex.Replace(input, "(?<=[a-z])(?=[A-Z])", " ").ToLowerInvariant(); list.Add((text3.Length > 0) ? (input + " " + text3.Replace(":", " ").ToLowerInvariant()) : input); } } return string.Join(", ", list.ToArray()); } internal static string Signed(float v) { return v.ToString("+0.#;-0.#", CultureInfo.InvariantCulture); } internal static string Fmt(float v) { return v.ToString("0.##", CultureInfo.InvariantCulture); } } internal enum Act { None, MeleeHit, ProjectileHit, StaffAttack, Block, Parry, PerfectDodge, Dodge, Stagger } internal class AffinitySpec { public readonly float[] Mult = new float[9] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f }; public float All = 1f; public float HitTaken; public float SwimPerSecond; public bool NoMissPenalty; public readonly List<string> Errors = new List<string>(); private readonly List<string> _desc = new List<string>(); public float Get(Act a) { return Mult[(int)a] * All; } public static AffinitySpec Parse(string text, string context) { AffinitySpec affinitySpec = new AffinitySpec(); string text2 = EffectSpec.Norm(text ?? ""); if (text2.Length == 0 || text2.Equals("none", StringComparison.OrdinalIgnoreCase)) { return affinitySpec; } string[] array = text2.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text3 = array[i].Trim(); if (text3.Length == 0) { continue; } string text4 = text3; string v = ""; int num = text3.IndexOf('='); if (num >= 0) { text4 = text3.Substring(0, num).Trim(); v = text3.Substring(num + 1).Trim(); } string k = text4.ToLowerInvariant().Replace(" ", "").Replace("_", ""); try { if (!affinitySpec.Token(k, v)) { affinitySpec.Errors.Add(context + ": unknown affinity '" + text3 + "'"); } } catch (Exception ex) { affinitySpec.Errors.Add(context + ": could not read '" + text3 + "' (" + ex.Message + ")"); } } return affinitySpec; } private bool Token(string k, string v) { Act act; string text; switch (k) { case "meleehit": case "melee": case "meleehits": act = Act.MeleeHit; text = "melee hits"; break; case "projectilehit": case "projectile": case "bow": case "bows": case "projectilehits": act = Act.ProjectileHit; text = "bow and projectile hits"; break; case "staff": case "magic": case "staffattack": case "staffs": act = Act.StaffAttack; text = "staff attacks"; break; case "blocking": case "block": act = Act.Block; text = "blocking"; break; case "parrying": case "parry": case "parries": act = Act.Parry; text = "parrying"; break; case "perfectdodge": act = Act.PerfectDodge; text = "perfect dodges"; break; case "dodge": case "normaldodge": case "dodging": act = Act.Dodge; text = "dodging"; break; case "staggering": case "stagger": act = Act.Stagger; text = "staggering enemies"; break; case "all": All *= EffectSpec.Num(v); _desc.Add("all actions (x" + EffectSpec.Fmt(EffectSpec.Num(v)) + ")"); return true; case "hittaken": case "takinghits": HitTaken += EffectSpec.Num(v); _desc.Add("taking hits (+" + EffectSpec.Fmt(EffectSpec.Num(v)) + " each)"); return true; case "swimming": case "swim": SwimPerSecond += EffectSpec.Num(v); _desc.Add("time spent swimming (+" + EffectSpec.Fmt(EffectSpec.Num(v)) + " per second)"); return true; case "nomisspenalty": NoMissPenalty = true; _desc.Add("no penalty for missed swings"); return true; default: return false; } float num = ((v.Length == 0) ? 2f : EffectSpec.Num(v)); Mult[(int)act] *= num; _desc.Add(text + " (x" + EffectSpec.Fmt(num) + ")"); return true; } public string Description() { if (_desc.Count == 0) { return ""; } return "Fills fastest from " + string.Join(", ", _desc.ToArray()) + "."; } } [HarmonyPatch(typeof(SE_Stats), "ModifySkillLevel")] internal static class SE_Stats_ModifySkillLevel_Extra { private static void Postfix(SE_Stats __instance, SkillType skill, ref float value) { //IL_0042: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 if (!Rebalance.Active || !Rebalance.SpecByHash.TryGetValue(((StatusEffect)__instance).NameHash(), out var value2) || value2.ExtraSkills.Count == 0) { return; } foreach (KeyValuePair<SkillType, float> extraSkill in value2.ExtraSkills) { if (extraSkill.Key == skill || (int)extraSkill.Key == 999) { value += extraSkill.Value; } } } } internal static class ActiveSpecs { internal static bool Any(SEMan seman, Func<EffectSpec, bool> test) { if (seman == null || !Rebalance.Active || Rebalance.SpecByHash.Count == 0) { return false; } List<StatusEffect> statusEffects = seman.GetStatusEffects(); if (statusEffects == null) { return false; } for (int i = 0; i < statusEffects.Count; i++) { StatusEffect val = statusEffects[i]; if (val != null && Rebalance.SpecByHash.TryGetValue(val.NameHash(), out var value) && test(value)) { return true; } } return false; } } [HarmonyPatch(typeof(SEMan), "Internal_AddStatusEffect")] internal static class SEMan_InternalAddStatusEffect_NoWet { private static bool Prefix(SEMan __instance, int nameHash, ref StatusEffect __result) { if (nameHash != NoWet.WetHash) { return true; } if ((Object)(object)Player.m_localPlayer == (Object)null || (object)NoWet.Owner(__instance) != Player.m_localPlayer) { return true; } if (!NoWet.Blocks(__instance)) { return true; } NoWet.LogOnce(); __result = null; return false; } } [HarmonyPatch(typeof(Humanoid), "UpdateEquipmentStatusEffects")] internal static class Humanoid_UpdateEquipmentStatusEffects_NoWet { private static void Postfix(Humanoid __instance) { if ((object)__instance != Player.m_localPlayer) { return; } try { NoWet.DryOff(((Character)__instance).GetSEMan()); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class NoWet { private static int s_wetHash; private static bool s_logged; private static readonly FieldRef<SEMan, Character> s_character = AccessTools.FieldRefAccess<SEMan, Character>("m_character"); internal static int WetHash { get { if (s_wetHash == 0) { s_wetHash = (int)AccessTools.Field(typeof(SEMan), "s_statusEffectWet").GetValue(null); } return s_wetHash; } } internal static Character Owner(SEMan seman) { return s_character.Invoke(seman); } internal static bool Blocks(SEMan seman) { return ActiveSpecs.Any(seman, (EffectSpec s) => s.PreventWet); } internal static void DryOff(SEMan seman) { if (seman != null && Blocks(seman) && seman.HaveStatusEffect(WetHash)) { seman.RemoveStatusEffect(WetHash, true); } } internal static void LogOnce() { if (!s_logged) { s_logged = true; Plugin.Log.LogInfo((object)"PreventWet: blocking the Wet status on the local player"); } } } internal enum Src { Unknown, AttackUse, AreaHit, MeleeHit, MeleeMiss, ProjectileHit, Block, Parry, HitTaken, Stagger, StaggerRpc, PerfectDodge, GuardianPower, Drain, Dodge, Swimming, ForsakenTick } internal static class Gain { private class Site { public Type Type; public string Method; public Type[] Args; public Src[] Sources; public int CtxArg; } private static readonly Site[] Sites = new Site[12] { new Site { Type = typeof(Attack), Method = "OnAttackTrigger", Sources = new Src[1] { Src.AttackUse } }, new Site { Type = typeof(Attack), Method = "FireProjectileBurst", Sources = new Src[1] { Src.AttackUse } }, new Site { Type = typeof(Attack), Method = "DoAreaAttack", Sources = new Src[1] { Src.AreaHit } }, new Site { Type = typeof(Attack), Method = "DoMeleeAttack", Sources = new Src[2] { Src.MeleeHit, Src.MeleeMiss } }, new Site { Type = typeof(Projectile), Method = "OnHit", Sources = new Src[1] { Src.ProjectileHit } }, new Site { Type = typeof(Humanoid), Method = "BlockAttack", Sources = new Src[2] { Src.Block, Src.Parry } }, new Site { Type = typeof(Character), Method = "RPC_Damage", Sources = new Src[1] { Src.HitTaken }, CtxArg = 2 }, new Site { Type = typeof(Character), Method = "AddStaggerDamage", Sources = new Src[1] { Src.Stagger } }, new Site { Type = typeof(Character), Method = "RPC_AddAdrenaline", Sources = new Src[1] { Src.StaggerRpc } }, new Site { Type = typeof(Player), Method = "RPC_HitWhileDodging", Sources = new Src[1] { Src.PerfectDodge } }, new Site { Type = typeof(Player), Method = "ActivateGuardianPower", Sources = new Src[1] { Src.GuardianPower } }, new Site { Type = typeof(Player), Method = "UpdateStats", Args = new Type[1] { typeof(float) }, Sources = new Src[1] { Src.Drain } } }; private static readonly Dictionary<string, Site> s_byKey = new Dictionary<string, Site>(); private static readonly MethodInfo s_helper = AccessTools.Method(typeof(Gain), "AddFrom", (Type[])null, (Type[])null); private static readonly MethodInfo s_enemyMult = AccessTools.Method(typeof(Gain), "EnemyMult", (Type[])null, (Type[])null); private static readonly FieldRef<Attack, ItemData> AttackWeapon = AccessTools.FieldRefAccess<Attack, ItemData>("m_weapon"); private static readonly FieldRef<Projectile, ItemData> ProjectileWeapon = AccessTools.FieldRefAccess<Projectile, ItemData>("m_weapon"); internal static readonly FieldRef<Humanoid, ItemData> TrinketItem = AccessTools.FieldRefAccess<Humanoid, ItemData>("m_trinketItem"); private static bool s_loggedError; private static string Key(MethodBase m) { return m.DeclaringType.FullName + "::" + m.Name; } public static void Patch(Harmony h) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(Gain), "SiteTranspiler", (Type[])null, (Type[])null)); Site[] sites = Sites; foreach (Site site in sites) { MethodInfo methodInfo = AccessTools.Method(site.Type, site.Method, site.Args, (Type[])null); if (methodInfo == null) { Plugin.Log.LogError((object)("Adrenaline call site not found: " + site.Type.Name + "." + site.Method)); continue; } s_byKey[Key(methodInfo)] = site; try { h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not patch " + site.Type.Name + "." + site.Method + ": " + ex.Message)); } } HarmonyMethod val2 = new HarmonyMethod(AccessTools.Method(typeof(Gain), "EnemyMultTranspiler", (Type[])null, (Type[])null)); List<MethodBase> list = new List<MethodBase>(); foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(Attack))) { if (ReadsEnemyMult(declaredMethod)) { list.Add(declaredMethod); } } MethodInfo methodInfo2 = AccessTools.Method(typeof(Character), "AddStaggerDamage", (Type[])null, (Type[])null); if (methodInfo2 != null && ReadsEnemyMult(methodInfo2)) { list.Add(methodInfo2); } foreach (MethodBase item in list) { try { h.Patch(item, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex2) { Plugin.Log.LogError((object)("Could not patch " + item.Name + ": " + ex2.Message)); } } Plugin.Log.LogInfo((object)("Enemy adrenaline multiplier hooked in " + list.Count + " methods")); } private static bool ReadsEnemyMult(MethodBase m) { try { if (m.IsAbstract || m.GetMethodBody() == null) { return false; } foreach (KeyValuePair<OpCode, object> item in PatchProcessor.ReadMethodBody(m)) { if (item.Key == OpCodes.Ldfld && IsEnemyMultField(item.Value)) { return true; } } } catch { } return false; } private static IEnumerable<CodeInstruction> SiteTranspiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown s_byKey.TryGetValue(Key(original), out var value); int num = 0; List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<CodeInstruction> list2 = new List<CodeInstruction>(); foreach (CodeInstruction item in list) { MethodInfo methodInfo = item.operand as MethodInfo; if (value != null && (item.opcode == OpCodes.Callvirt || item.opcode == OpCodes.Call) && methodInfo != null && methodInfo.Name == "AddAdrenaline" && methodInfo.GetParameters().Length == 1 && typeof(Character).IsAssignableFrom(methodInfo.DeclaringType)) { Src src = ((num < value.Sources.Length) ? value.Sources[num] : Src.Unknown); num++; CodeInstruction val = new CodeInstruction((value.CtxArg == 2) ? OpCodes.Ldarg_2 : ((value.CtxArg == 1) ? OpCodes.Ldarg_1 : OpCodes.Ldarg_0), (object)null); val.labels.AddRange(item.labels); val.blocks.AddRange(item.blocks); list2.Add(val); list2.Add(new CodeInstruction(OpCodes.Ldc_I4, (object)(int)src)); list2.Add(new CodeInstruction(OpCodes.Call, (object)s_helper)); } else { list2.Add(item); } } if (value != null && num != value.Sources.Length) { Plugin.Log.LogWarning((object)("Adrenaline call sites in " + original.Name + ": expected " + value.Sources.Length + ", found " + num + ". A game update may have changed this method; keeping the game's own code there (gains from it are not attributed).")); return list; } return list2; } private static IEnumerable<CodeInstruction> EnemyMultTranspiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldfld && IsEnemyMultField(instruction.operand)) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)s_enemyMult); val.labels.AddRange(instruction.labels); val.blocks.AddRange(instruction.blocks); yield return val; } else { yield return instruction; } } } private static bool IsEnemyMultField(object operand) { FieldInfo fieldInfo = operand as FieldInfo; if (fieldInfo != null && fieldInfo.Name == "m_enemyAdrenalineMultiplier") { return fieldInfo.DeclaringType == typeof(Character); } return false; } public static float EnemyMult(Character c) { float num = c.m_enemyAdrenalineMultiplier; if (!Rebalance.Active) { return num; } int level = c.GetLevel(); if (level == 2) { num *= Cfg.OneStarMultiplier.Value; } else if (level >= 3) { num *= Cfg.TwoStarMultiplier.Value; } return num; } public static void AddFrom(Character c, float v, object ctx, int src) { if ((Object)(object)c == (Object)null) { return; } Player val = (Player)(object)((c is Player) ? c : null); if (!Rebalance.Active || (Object)(object)val == (Object)null) { c.AddAdrenaline(v); return; } try { Act a = Act.None; TrinketDef trinketDef = Trinket((Humanoid)(object)val); int level = ((trinketDef != null) ? Levels.LevelOf(TrinketItem.Invoke((Humanoid)(object)val)) : 0); float num = ((trinketDef != null) ? Levels.AffinityFraction(trinketDef, level) : 1f); switch ((Src)src) { case Src.AttackUse: v *= Cfg.StaffUseMultiplier.Value; a = (IsMagic(Weapon((Attack)((ctx is Attack) ? ctx : null))) ? Act.StaffAttack : Act.None); break; case Src.AreaHit: case Src.MeleeHit: v *= Cfg.MeleeHit.Value / 1f; a = ((!IsMagic(Weapon((Attack)((ctx is Attack) ? ctx : null)))) ? Act.MeleeHit : Act.StaffAttack); break; case Src.MeleeMiss: if (v < 0f && trinketDef != null && trinketDef.Aff.NoMissPenalty && Levels.Unlocked(trinketDef, level)) { return; } break; case Src.ProjectileHit: { v *= Cfg.ProjectileHitMultiplier.Value; Projectile val4 = (Projectile)((ctx is Projectile) ? ctx : null); a = (IsMagic(((Object)(object)val4 != (Object)null) ? ProjectileWeapon.Invoke(val4) : null) ? Act.StaffAttack : Act.ProjectileHit); break; } case Src.Block: v *= Cfg.Block.Value / 2f; a = Act.Block; break; case Src.Parry: v *= Cfg.Parry.Value / 5f; a = Act.Parry; break; case Src.HitTaken: if (trinketDef != null && trinketDef.Aff.HitTaken != 0f) { HitData val2 = (HitData)((ctx is HitData) ? ctx : null); Character val3 = ((val2 != null) ? val2.GetAttacker() : null); if ((Object)(object)val3 != (Object)null && (object)val3 != val) { v = trinketDef.Aff.HitTaken * num; } } break; case Src.Stagger: case Src.StaggerRpc: a = Act.Stagger; break; case Src.PerfectDodge: a = Act.PerfectDodge; break; case Src.Dodge: a = Act.Dodge; break; case Src.Drain: ((Character)val).AddAdrenaline(v * Cfg.DrainSpeedMultiplier.Value * ((trinketDef != null) ? Mathf.Max(0f, trinketDef.DrainMultiplier.Value) : 1f)); return; } if (!(v > 0f) || trinketDef == null || !trinketDef.OnlyOwnSources.Value || IsOwnSource(trinketDef, (Src)src)) { if (v > 0f && trinketDef != null) { v *= 1f + (trinketDef.Aff.Get(a) - 1f) * num; } if (v != 0f) { ((Character)val).AddAdrenaline(v); } } } catch (Exception ex) { if (!s_loggedError) { s_loggedError = true; ManualLogSource log = Plugin.Log; Src src2 = (Src)src; log.LogError((object)("Adrenaline gain error (" + src2.ToString() + "): " + ex)); } c.AddAdrenaline(v); } } private static bool IsOwnSource(TrinketDef t, Src src) { return src switch { Src.Swimming => t.Aff.SwimPerSecond > 0f, Src.HitTaken => t.Aff.HitTaken > 0f, _ => false, }; } private static ItemData Weapon(Attack a) { if (a == null) { return null; } return AttackWeapon.Invoke(a); } private static bool IsMagic(ItemData w) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 if (w == null || w.m_shared == null) { return false; } SkillType skillType = w.m_shared.m_skillType; if ((int)skillType != 9) { return (int)skillType == 10; } return true; } internal static TrinketDef Trinket(Humanoid h) { if ((Object)(object)h == (Object)null) { return null; } return Rebalance.TrinketOf(TrinketItem.Invoke(h)); } } internal static class Levels { private static readonly Dictionary<string, EffectSpec> s_cache = new Dictionary<string, EffectSpec>(); private static int s_cacheVersion = -1; private static TrinketDef s_lastDef; private static int s_lastLevel = -1; private static int s_lastStep = -1; private static int s_lastVersion = -1; private static SE_Stats s_lastClone; private static SharedData s_descShared; private static string s_descOriginal; internal static bool Enabled { get { if (Rebalance.Active && Cfg.UpgradesEnabled != null) { return Cfg.UpgradesEnabled.Value; } return false; } } internal static int Max => Math.Max(1, Cfg.MaxLevel.Value); internal static int LevelOf(ItemData item) { if (!Enabled || item == null) { return Max; } return Mathf.Clamp(item.m_quality, 1, Max); } internal static float Fraction(int level) { return Mathf.Clamp01((float)level / (float)Max); } internal static float AffinityFraction(int level) { return AffinityFraction(null, level); } internal static float AffinityFraction(TrinketDef t, int level) { if (Max <= 1 || level >= Max) { return 1f; } float num = ((t != null && t.AffinitySpread != null) ? t.AffinitySpread.Value : (-1f)); float num2 = Mathf.Clamp((num >= 0f) ? num : Cfg.AffinityLevelSpread.Value, 0f, 100f) / 100f; return 1f - num2 * (float)(Max - level) / (float)(Max - 1); } internal static float DurationFraction(TrinketDef t, int level) { float num = ((t != null && t.DurationFloor != null) ? t.DurationFloor.Value : (-1f)); if (num < 0f || Max <= 1) { return Fraction(level); } num = Mathf.Clamp01(num / 100f); return num + (1f - num) * Mathf.Clamp01((float)(level - 1) / (float)(Max - 1)); } internal static bool Unlocked(TrinketDef t, int level) { return level >= t.UnlockLevel.Value; } private static string Key(TrinketDef t, bool proc, int level) { return t.Prefab + (proc ? "|proc|" : "|passive|") + level; } internal static EffectSpec Effective(TrinketDef t, bool proc, int level) { if (s_cacheVersion != Rebalance.Version) { s_cache.Clear(); s_cacheVersion = Rebalance.Version; } string key = Key(t, proc, level); if (s_cache.TryGetValue(key, out var value)) { return value; } EffectSpec effectSpec = (proc ? t.Proc : t.Passive); if (effectSpec == null) { effectSpec = new EffectSpec(); } if (effectSpec.Vanilla) { effectSpec = new EffectSpec(); } bool unlocked = Unlocked(t, level) || (proc && t.ScaleProcDuration.Value); value = EffectSpec.ForLevel(effectSpec, Fraction(level), unlocked); s_cache[key] = value; return value; } internal static string Percent(int level) { return Mathf.RoundToInt(Fraction(level) * 100f).ToString(CultureInfo.InvariantCulture); } internal static string UnlockList(TrinketDef t) { List<string> list = new List<string>(); if (t.Passive != null && !t.Passive.Vanilla) { list.AddRange(t.Passive.UnlockNames()); } if (t.Proc != null && !t.Proc.Vanilla) { list.AddRange(t.Proc.UnlockNames()); } return string.Join(", ", list.ToArray()); } internal static string LevelLine(TrinketDef t, int level, EffectSpec fullSpec) { string text = "Trinket level <color=orange>" + level + "/" + Max + "</color>: <color=orange>" + Percent(level) + "%</color> of full power"; if (fullSpec != null && fullSpec.HasUnlockables && !Unlocked(t, level)) { string text2 = UnlockList(t); text = text + "\nUnlocks at level <color=orange>" + t.UnlockLevel.Value + "</color>" + ((text2.Length > 0) ? (": " + text2) : ""); } else if (t.ScaleProcDuration.Value && t.Proc != null && !t.Proc.Vanilla && level < Max) { text += "\nThe proc lasts longer with each level"; } return text; } internal static void Refresh(Player p, TrinketDef t, bool force) { if (t == null || !Rebalance.Active || t.Passive == null) { s_lastDef = null; return; } int num = LevelOf(Gain.TrinketItem.Invoke((Humanoid)(object)p)); SE_Stats val = Rebalance.PassiveOf(t); SE_Stats val2 = (SE_Stats)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); float num2 = 1f; int num3 = 100; if (t.IsScaling) { float maxAdrenaline = ((Character)p).GetMaxAdrenaline(); num2 = ((maxAdrenaline > 0f) ? Mathf.Clamp01(p.GetAdrenaline() / maxAdrenaline) : 0f); num3 = Mathf.RoundToInt(num2 * 100f); num2 = (float)num3 / 100f; } if (!force && s_lastDef == t && s_lastLevel == num && s_lastStep == num3 && s_lastVersion == Rebalance.Version && s_lastClone == val2) { return; } s_lastDef = t; s_lastLevel = num; s_lastStep = num3; s_lastVersion = Rebalance.Version; s_lastClone = val2; EffectSpec effectSpec = Effective(t, proc: false, num); if (t.IsScaling) { effectSpec = EffectSpec.Blend(effectSpec, t.Scaling, Fraction(num) * num2); } if (t.PassiveHash != 0) { Rebalance.SpecByHash[t.PassiveHash] = effectSpec; } if (t.ProcHash != 0 && t.Proc != null) { EffectSpec effectSpec2 = Effective(t, proc: true, num); Rebalance.SpecByHash[t.ProcHash] = effectSpec2; if (effectSpec2.AdrenalineRefund > 0f) { Rebalance.RefundByProcHash[t.ProcHash] = effectSpec2.AdrenalineRefund; } else { Rebalance.RefundByProcHash.Remove(t.ProcHash); } } if ((Object)(object)val2 != (Object)null) { effectSpec.ApplyTo(val2); string text = LevelLine(t, num, t.Passive); if (t.IsScaling) { text = text + "\nAdrenaline bar: <color=orange>" + num3 + "%</color>"; } string text2 = effectSpec.CustomTooltip(); ((StatusEffect)val2).m_tooltip = ((text2.Length > 0) ? (text + "\n" + text2) : text); } } internal static void OnSetup(SE_Stats se, TrinketDef t) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || t == null) { return; } int num = ((StatusEffect)se).NameHash(); if (num == t.PassiveHash && t.PassiveHash != 0) { Refresh(localPlayer, t, force: true); } else if (num == t.ProcHash && t.Proc != null && !t.Proc.Vanilla) { int level = LevelOf(Gain.TrinketItem.Invoke((Humanoid)(object)localPlayer)); EffectSpec effectSpec = Effective(t, proc: true, level); effectSpec.ApplyTo(se); string text = effectSpec.CustomTooltip(); string text2 = LevelLine(t, level, t.Proc); ((StatusEffect)se).m_tooltip = ((text.Length > 0) ? (text2 + "\n" + text) : text2); float num2 = Mathf.Max(0f, t.ProcDuration.Value); ((StatusEffect)se).m_ttl = (t.ScaleProcDuration.Value ? (num2 * DurationFraction(t, level)) : num2); Rebalance.SpecByHash[num] = effectSpec; if (effectSpec.AdrenalineRefund > 0f) { Rebalance.RefundByProcHash[num] = effectSpec.AdrenalineRefund; } else { Rebalance.RefundByProcHash.Remove(num); } } } internal static void TooltipBegin(ItemData item, int quality) { RestoreDescription(); TrinketDef trinketDef = Rebalance.TrinketOf(item); if (trinketDef != null && Enabled) { int level = Mathf.Clamp(quality, 1, Max); Show(trinketDef, level); RestoreDescription(); string text = TooltipLine(item, quality); if (text != null && item.m_shared != null) { s_descShared = item.m_shared; s_descOriginal = item.m_shared.m_description; item.m_shared.m_description = s_descOriginal + "\n\n<color=#9FD3FF>" + text.Replace("<color=orange>", "<color=#ffcc66>") + "</color>"; } } } private static void RestoreDescription() { if (s_descShared != null) { s_descShared.m_description = s_descOriginal; } s_descShared = null; s_descOriginal = null; } internal static void TooltipEnd(ItemData item) { RestoreDescription(); TrinketDef trinketDef = Rebalance.TrinketOf(item); if (trinketDef != null && Enabled) { Show(trinketDef, Max); } } private static void Show(TrinketDef t, int level) { SE_Stats val = Rebalance.PassiveOf(t); if ((Object)(object)val != (Object)null && !t.Passive.Vanilla) { EffectSpec effectSpec = Effective(t, proc: false, level); effectSpec.ApplyTo(val); ((StatusEffect)val).m_tooltip = effectSpec.CustomTooltip(); } if ((Object)(object)t.ProcSE != (Object)null && !t.IsScaling && !t.Proc.Vanilla) { EffectSpec effectSpec2 = Effective(t, proc: true, level); effectSpec2.ApplyTo(t.ProcSE); ((StatusEffect)t.ProcSE).m_tooltip = effectSpec2.CustomTooltip(); ((StatusEffect)t.ProcSE).m_ttl = (t.ScaleProcDuration.Value ? (Mathf.Max(0f, t.ProcDuration.Value) * DurationFraction(t, level)) : Mathf.Max(0f, t.ProcDuration.Value)); } } internal static string TooltipLine(ItemData item, int quality) { TrinketDef trinketDef = Rebalance.TrinketOf(item); if (trinketDef == null || !Enabled) { return null; } int level = Mathf.Clamp(quality, 1, Max); return LevelLine(trinketDef, level, trinketDef.Passive.HasUnlockables ? trinketDef.Passive : (trinketDef.Proc ?? trinketDef.Passive)); } } [HarmonyPatch(typeof(SE_Stats), "Setup")] internal static class SE_Stats_Setup_Levels { private static void Prefix(SE_Stats __instance, Character character) { if (!Rebalance.Active || (Object)(object)character == (Object)null || (object)character != Player.m_localPlayer) { return; } try { if (Rebalance.DefByEffectHash.TryGetValue(((StatusEffect)__instance).NameHash(), out var value)) { Levels.OnSetup(__instance, value); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int), typeof(bool) })] internal static class ItemData_GetTooltip_Levels { private static void Prefix(ItemData item, int qualityLevel) { try { Levels.TooltipBegin(item, qualityLevel); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } private static void Postfix(ItemData item, int qualityLevel, ref string __result) { try { Levels.TooltipEnd(item); if (__result != null && Rebalance.TrinketOf(item) != null) { string text = TooltipLayout.Apply(__result); if ((object)text == __result || text == __result) { TooltipLayout.NoteUnchanged(__result); } __result = text; } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(Requirement), "GetAmount")] internal static class Requirement_GetAmount { internal static readonly HashSet<Requirement> Trinket = new HashSet<Requirement>(); private static void Postfix(Requirement __instance, int qualityLevel, ref int __result) { if (qualityLevel > 1 && Trinket.Count != 0 && Levels.Enabled && Trinket.Contains(__instance)) { ItemDrop resItem = __instance.m_resItem; if (Cfg.TrophyOnlyToCraft.Value && resItem != null && Object.op_Implicit((Object)(object)resItem) && ((Object)resItem).name.StartsWith("Trophy", StringComparison.Ordinal)) { __result = 0; return; } double num = Math.Max(0.0, Cfg.UpgradeCostMultiplier.Value); double x = Math.Max(0.0, Cfg.UpgradeCostGrowth.Value); __result = (int)Math.Round((double)__instance.m_amount * num * Math.Pow(x, qualityLevel - 2), MidpointRounding.AwayFromZero); } } } [HarmonyPatch(typeof(Player), "Awake")] internal static class Player_Awake { private static void Postfix(Player __instance) { try { Players.OnAwake(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(Game), "UpdateWorldRates")] internal static class Game_UpdateWorldRates { private static void Postfix() { try { WorldRate.OnGameUpdated(); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake { private static void Postfix() { Plugin.MarkDirty(); } } internal static class Procs { private static int s_depth; private static readonly float[] s_refund = new float[16]; internal static readonly FieldRef<Player, float> Adrenaline = AccessTools.FieldRefAccess<Player, float>("m_adrenaline"); private static readonly FieldRef<Player, float> DegenTimer = AccessTools.FieldRefAccess<Player, float>("m_adrenalineDegenTimer"); public static void Enter() { if (s_depth < s_refund.Length) { s_refund[s_depth] = 0f; } s_depth++; } public static void Abort() { if (s_depth > 0) { s_depth--; } if (s_depth < s_refund.Length) { s_refund[s_depth] = 0f; } } public static void Exit(Player p, float v) { if (s_depth > 0) { s_depth--; } if (!Rebalance.Active) { return; } float num = ((s_depth < s_refund.Length) ? s_refund[s_depth] : 0f); if (num > 0f) { float maxAdrenaline = ((Character)p).GetMaxAdrenaline(); float num2 = Mathf.Min(num, maxAdrenaline * 0.99f); if (Adrenaline.Invoke(p) < num2) { Adrenaline.Invoke(p) = num2; } } float value = Cfg.DrainDelayMultiplier.Value; if (v > 0f && value != 1f && ((Character)p).GetMaxAdrenaline() > 0f) { DegenTimer.Invoke(p) *= Mathf.Max(0f, value); } } public static void OnStatusEffectStarted(int hash) { if (s_depth > 0 && Rebalance.RefundByProcHash.TryGetValue(hash, out var value) && s_depth - 1 < s_refund.Length) { s_refund[s_depth - 1] += value; } } } [HarmonyPatch(typeof(Player), "AddAdrenaline")] internal static class Player_AddAdrenaline { private static void Prefix(float v, out float __state) { __state = v; Procs.Enter(); } private static Exception Finalizer(Player __instance, float __state, Exception __exception) { try { if (__exception != null) { Procs.Abort(); } else { Procs.Exit(__instance, __state); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } return __exception; } } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(StatusEffect), typeof(bool), typeof(int), typeof(float), typeof(short) })] internal static class SEMan_AddStatusEffect { private static void Postfix(StatusEffect statusEffect, StatusEffect __result) { if ((Object)(object)__result != (Object)null && (Object)(object)statusEffect != (Object)null) { Procs.OnStatusEffectStarted(statusEffect.NameHash()); } } } [HarmonyPatch(typeof(SE_Stats), "ResetTime")] internal static class SE_Stats_ResetTime { private static void Prefix(SE_Stats __instance) { Procs.OnStatusEffectStarted(((StatusEffect)__instance).NameHash()); } } [HarmonyPatch(typeof(Humanoid), "UnequipItem", new Type[] { typeof(ItemData), typeof(bool) })] internal static class Humanoid_UnequipItem { private static void Prefix(Humanoid __instance, ItemData item, out StatusEffect __state) { __state = null; if (item != null && item.m_shared != null && !((Object)(object)item.m_shared.m_fullAdrenalineSE == (Object)null) && (object)__instance == Player.m_localPlayer && __instance.IsItemEquiped(item)) { __state = item.m_shared.m_fullAdrenalineSE; } } private static void Postfix(Humanoid __instance, StatusEffect __state) { if ((Object)(object)__state == (Object)null || !Rebalance.Active || !Cfg.UnequipEndsProc.Value) { return; } try { ((Character)__instance).GetSEMan().RemoveStatusEffect(__state.NameHash(), true); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(Player), "UpdateDodge")] internal static class Player_UpdateDodge { private static readonly FieldRef<Player, float> Queued = AccessTools.FieldRefAccess<Player, float>("m_queuedDodgeTimer"); private static void Prefix(Player __instance, float dt, out bool __state) { __state = Queued.Invoke(__instance) - dt > 0f; } private static void Postfix(Player __instance, bool __state) { if (__state && Queued.Invoke(__instance) == 0f && Rebalance.Active && __instance == Player.m_localPlayer) { float value = Cfg.NormalDodge.Value; if (value != 0f) { Gain.AddFrom((Character)(object)__instance, value, null, 14); } } } } [HarmonyPatch(typeof(Player), "ActivateGuardianPower")] internal static class Player_ActivateGuardianPower { internal static readonly FieldRef<Player, StatusEffect> GuardianSE = AccessTools.FieldRefAccess<Player, StatusEffect>("m_guardianSE"); private static void Prefix(Player __instance, out bool __state) { __state = __instance.m_guardianPowerCooldown <= 0f && (Object)(object)GuardianSE.Invoke(__instance) != (Object)null; } private static void Postfix(Player __instance, bool __state) { if (!__state || !Rebalance.Active) { return; } try { Runtime.StartForsakenRush(__instance, GuardianSE.Invoke(__instance)); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] internal static class Player_GetTotalFoodValue { private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr) { if (!Rebalance.Active || Rebalance.SpecByHash.Count == 0) { return; } foreach (StatusEffect statusEffect in ((Character)__instance).GetSEMan().GetStatusEffects()) { if (!((Object)(object)statusEffect == (Object)null) && Rebalance.SpecByHash.TryGetValue(statusEffect.NameHash(), out var value)) { hp += value.MaxHealth; stamina += value.MaxStamina; eitr += value.MaxEitr; } } if (hp < 1f) { hp = 1f; } if (stamina < 0f) { stamina = 0f; } if (eitr < 0f) { eitr = 0f; } } } [HarmonyPatch(typeof(ItemData), "GetBaseBlockPower", new Type[] { typeof(int) })] internal static class ItemData_GetBaseBlockPower { private static readonly Func<Humanoid, ItemData> CurrentBlocker = AccessTools.MethodDelegate<Func<Humanoid, ItemData>>(AccessTools.Method(typeof(Humanoid), "GetCurrentBlocker", (Type[])null, (Type[])null), (object)null, true); private static void Postfix(ItemData __instance, ref float __result) { if (!Rebalance.Active || Rebalance.SpecByHash.Count == 0) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } float num = 0f; foreach (StatusEffect statusEffect in ((Character)localPlayer).GetSEMan().GetStatusEffects()) { if ((Object)(object)statusEffect != (Object)null && Rebalance.SpecByHash.TryGetValue(statusEffect.NameHash(), out var value)) { num += value.BlockArmor; } } if (num != 0f && CurrentBlocker((Humanoid)(object)localPlayer) == __instance) { __result += num; } } } [HarmonyPatch(typeof(Character), "GetDamageModifiers")] internal static class Character_GetDamageModifiers { private static void Postfix(Character __instance, ref DamageModifiers __result) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Invalid comparison between Unknown and I4 if (!Rebalance.Active || Rebalance.SpecByHash.Count == 0 || !(__instance is Player)) { return; } foreach (StatusEffect statusEffect in __instance.GetSEMan().GetStatusEffects()) { if ((Object)(object)statusEffect == (Object)null || !Rebalance.SpecByHash.TryGetValue(statusEffect.NameHash(), out var value) || !value.IgnoreResistances) { continue; } foreach (DamageModPair mod in value.Mods) { DamageModifier modifier = mod.m_modifier; if ((int)modifier == 2 || (int)modifier == 6 || (int)modifier == 8) { Force(ref __result, mod.m_type, modifier); } } } } private static void Force(ref DamageModifiers mods, DamageType type, DamageModifier m) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected I4, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing re