using System; using System.Collections; 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.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Pilgrim")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ec505d5eb0f2ae61b41ece9163da03e8bc7f6e0e")] [assembly: AssemblyProduct("Pilgrim")] [assembly: AssemblyTitle("Pilgrim")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace EnvReporter { [BepInPlugin("com.ctogle.pilgrim", "Pilgrim", "0.5.4")] public class Plugin : BaseUnityPlugin { internal struct LegendaryDef { public string Key; public string Prefab; public string DefaultIngredient; public SkillType SkillType; public string SkillLabel; public string DefaultActivateMsg; public string DefaultDeactivateMsg; } internal struct HuntDef { public string Key; public string Prefab; public string DefaultIngredient; public Biome Biome; public float Scale; public string DefaultHoverText; public string DefaultMessage; public float DefaultDistance; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func <>9__84_0; public static Func <>9__88_0; public static Func <>9__91_0; public static Func <>9__92_0; public static Func <>9__95_1; public static Action <>9__95_0; public static Func <>9__96_0; public static FileSystemEventHandler <>9__180_0; public static ConsoleEvent <>9__188_0; public static Func <>9__188_25; public static ConsoleEvent <>9__188_1; public static ConsoleEvent <>9__188_2; public static ConsoleEvent <>9__188_3; public static Func <>9__188_26; public static Func <>9__188_27; public static ConsoleEvent <>9__188_4; public static ConsoleEvent <>9__188_5; public static ConsoleEvent <>9__188_6; public static ConsoleEvent <>9__188_7; public static ConsoleEvent <>9__188_8; public static ConsoleEvent <>9__188_9; public static ConsoleEvent <>9__188_10; public static ConsoleEvent <>9__188_11; public static ConsoleEvent <>9__188_12; public static ConsoleEvent <>9__188_13; public static Func <>9__188_28; public static Func <>9__188_29; public static Func, string> <>9__188_31; public static Func, string> <>9__188_33; public static Func <>9__188_32; public static ConsoleEvent <>9__188_14; public static Func <>9__188_35; public static Func <>9__188_36; public static ConsoleEvent <>9__188_15; public static Func, string> <>9__188_37; public static ConsoleEvent <>9__188_16; public static ConsoleEvent <>9__188_17; public static ConsoleEvent <>9__188_18; public static Func <>9__188_38; public static Func <>9__188_39; public static Func <>9__188_40; public static Func <>9__188_41; public static ConsoleEvent <>9__188_19; public static ConsoleEvent <>9__188_20; public static ConsoleEvent <>9__188_21; public static ConsoleEvent <>9__188_22; public static ConsoleEvent <>9__188_23; public static ConsoleEvent <>9__188_24; public static Predicate <>9__209_0; public static Predicate <>9__217_0; public static Predicate <>9__220_0; public static Predicate <>9__221_0; public static Predicate <>9__225_0; public static Action <>9__228_0; public static Action <>9__240_0; public static Action <>9__240_1; public static Func <>9__246_0; public static Func <>9__246_1; public static Action <>9__249_0; public static Func <>9__259_0; public static Func <>9__259_2; public static Action <>9__265_0; public static Func <>9__271_0; public static Func <>9__271_2; public static Func <>9__271_3; public static Func <>9__271_4; public static Func <>9__271_5; public static Func <>9__271_6; public static Func <>9__271_7; public static Func <>9__272_0; public static Func <>9__272_2; public static Func <>9__272_3; public static Func <>9__272_4; public static Func <>9__272_5; public static Func <>9__272_6; public static Func <>9__272_7; public static Predicate <>9__278_0; public static Func <>9__281_0; public static Predicate <>9__283_0; internal bool b__84_0(ItemData i) { return i.m_shared.m_name == "Pilgrim's Cache"; } internal float b__88_0(ItemData i) { return (float)i.m_stack * i.m_shared.m_weight; } internal bool b__91_0(GameObject g) { if ((Object)(object)g != (Object)null) { return ((Object)g).name == "PilgrimCrate"; } return false; } internal bool b__92_0(Recipe r) { if ((Object)(object)r != (Object)null) { return ((Object)r).name == "Recipe_PilgrimCrate"; } return false; } internal void b__95_0() { if (_crateItem != null && _crateInventory != null) { float num = _crateInventory.GetAllItems().Sum((ItemData i) => (float)i.m_stack * i.m_shared.m_weight); _crateItem.m_customData["pilgrim_crate_weight"] = num.ToString(CultureInfo.InvariantCulture); } } internal float b__95_1(ItemData i) { return (float)i.m_stack * i.m_shared.m_weight; } internal float b__96_0(ItemData i) { return (float)i.m_stack * i.m_shared.m_weight; } internal void b__180_0(object _, FileSystemEventArgs __) { _cfgDirty = true; } internal void b__188_0(ConsoleEventArgs args) { //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: 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_0330: Unknown result type (might be due to invalid IL or missing references) EnvMan instance = EnvMan.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("EnvMan not ready."); return; } float tod = GetTod(); string todLabel = GetTodLabel(tod); string text = GetEnvSetupName(instance, "m_currentEnv") ?? "unknown"; string text2 = GetEnvSetupName(instance, "m_nextEnv") ?? "unknown"; string text3 = instance.m_debugEnv ?? ""; string text4 = (((Object)(object)Scheduler != (Object)null && Scheduler.Active) ? $"ON (prob {Scheduler.Probability:P0})" : "OFF"); double num = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTimeSeconds() : 0.0); args.Context.AddString("=== World State ==="); args.Context.AddString($"TOD : {tod:F2} ({todLabel}) [ZNet raw: {num:F0}s mod1800={num % 1800.0:F0}]"); args.Context.AddString("Current env : " + text + ((text3.Length > 0) ? (" [forced: " + text3 + "]") : "")); args.Context.AddString("Next env : " + text2); args.Context.AddString($"Is wet : {EnvMan.IsWet()}"); args.Context.AddString($"Is cold : {EnvMan.IsCold()}"); args.Context.AddString($"Is freezing : {EnvMan.IsFreezing()}"); args.Context.AddString($"Wind : {instance.GetWindIntensity():F2} dir {instance.GetWindDir()}"); args.Context.AddString("Scheduler : " + text4); RandEventSystem instance2 = RandEventSystem.instance; if ((Object)(object)instance2 != (Object)null) { object obj = AnyField(instance2, "m_activeEvent", "m_currentEvent"); if (obj != null && (!(AnyField(instance2, "m_haveActiveEvent") is bool flag) || flag) && obj != null) { string arg = (AnyField(obj, "m_name") as string) ?? "?"; float num2 = ((AnyField(instance2, "m_eventTimer", "m_timer") is float num3) ? num3 : 0f); string arg2 = ((AnyField(instance2, "m_eventPos", "m_pos") is Vector3 val) ? $"({val.x:F0},{val.z:F0})" : "?"); args.Context.AddString($"Active raid : {arg} | {num2:F0}s | @ {arg2}"); } else { args.Context.AddString("Active raid : none"); } } } internal void b__188_1(ConsoleEventArgs args) { //IL_0098: 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_00a0: 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_0197: 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_020c: 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) List allPlayers = Player.GetAllPlayers(); if (allPlayers == null || allPlayers.Count == 0) { args.Context.AddString("No players found."); return; } args.Context.AddString($"=== Players ({allPlayers.Count}) ==="); List list = new List(); foreach (Player item in allPlayers) { string playerName = item.GetPlayerName(); float health = ((Character)item).GetHealth(); float maxHealth = ((Character)item).GetMaxHealth(); float stamina = item.GetStamina(); float maxStamina = ((Character)item).GetMaxStamina(); float eitr = item.GetEitr(); float maxEitr = ((Character)item).GetMaxEitr(); Vector3 position = ((Component)item).transform.position; list.Add(position); string arg = ((object)item.GetCurrentBiome()/*cast due to .constrained prefix*/).ToString(); SEMan sEMan = ((Character)item).GetSEMan(); List list2 = ((sEMan != null) ? sEMan.GetStatusEffects() : null); string text = ((list2 != null && list2.Count > 0) ? string.Join(", ", list2.Select((StatusEffect e) => (!string.IsNullOrEmpty(e.m_name)) ? e.m_name : ((Object)e).name)) : "none"); args.Context.AddString("--- " + playerName + " ---"); args.Context.AddString($" HP {health:F0}/{maxHealth:F0} | Stamina {stamina:F0}/{maxStamina:F0} | Eitr {eitr:F0}/{maxEitr:F0}"); args.Context.AddString($" Biome: {arg} | Pos: ({position.x:F0},{position.z:F0})"); args.Context.AddString(" Effects: " + text); } if (list.Count <= 1) { return; } float num = 0f; for (int num2 = 0; num2 < list.Count; num2++) { for (int num3 = num2 + 1; num3 < list.Count; num3++) { float num4 = Vector3.Distance(list[num2], list[num3]); if (num4 > num) { num = num4; } } } args.Context.AddString($"Party spread: {num:F0}m"); } internal string b__188_25(StatusEffect e) { if (!string.IsNullOrEmpty(e.m_name)) { return e.m_name; } return ((Object)e).name; } internal void b__188_2(ConsoleEventArgs args) { ClearSkiesExpiry = 0f; RainExpiry = 0f; GiantRainExpiry = 0f; WaterWalkExpiry = 0f; SeekEnvExpiry = 0f; DungeonEnvExpiry = 0f; HomeEnvExpiry = 0f; if (GiantExpiry > 0f) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { DeactivateGiant(localPlayer); } else { GiantExpiry = 0f; } } if ((Object)(object)EnvMan.instance != (Object)null) { EnvMan.instance.m_debugEnv = ""; } EnvMan instance = EnvMan.instance; if (instance != null) { instance.ResetDebugWind(); } args.Context.AddString("Weather overrides cleared."); } internal void b__188_3(ConsoleEventArgs args) { ActivateSeek(args.Context); } internal void b__188_4(ConsoleEventArgs args) { EnvScheduler scheduler = Scheduler; if ((Object)(object)scheduler == (Object)null) { args.Context.AddString("Scheduler not ready."); return; } if (args.Length < 2) { PrintSchedule(args, scheduler); return; } switch (args[1].ToLower()) { case "on": scheduler.Active = true; args.Context.AddString("Scheduler ON"); break; case "off": scheduler.Active = false; args.Context.AddString("Scheduler OFF"); break; case "prob": { if (args.Length >= 3 && float.TryParse(args[2], out var result)) { scheduler.Probability = Mathf.Clamp01(result); args.Context.AddString($"Probability → {scheduler.Probability:P0}"); } break; } case "night": if (args.Length >= 3) { scheduler.NightPool = (from x in args[2].Split(',') select x.Trim()).ToList(); args.Context.AddString("Night pool → " + string.Join(", ", scheduler.NightPool)); } break; case "noon": if (args.Length >= 3) { scheduler.NoonPool = (from x in args[2].Split(',') select x.Trim()).ToList(); args.Context.AddString("Noon pool → " + string.Join(", ", scheduler.NoonPool)); } break; default: PrintSchedule(args, scheduler); break; } } internal string b__188_26(string x) { return x.Trim(); } internal string b__188_27(string x) { return x.Trim(); } internal void b__188_5(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { args.Context.AddString("No local player."); return; } ActivateWaterWalk(localPlayer); args.Context.AddString("Water walk active."); } internal void b__188_6(ConsoleEventArgs args) { //IL_0073: 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_00be: 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_00a1: 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_00b8: 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) if ((Object)(object)Scheduler == (Object)null) { args.Context.AddString("Scheduler not ready."); return; } string text = ((args.Length > 1) ? args[1].ToLower() : "n"); BroadcastBird((Vector3)(text switch { "s" => new Vector3(0f, 0f, -1f), "e" => new Vector3(1f, 0f, 0f), "w" => new Vector3(-1f, 0f, 0f), _ => new Vector3(0f, 0f, 1f), })); args.Context.AddString("Bird away (" + text + ")."); } internal void b__188_7(ConsoleEventArgs args) { //IL_0050: 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_0075: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { args.Context.AddString("No player."); return; } args.Context.AddString("=== Trader State ==="); string[] traderLocations = TraderLocations; foreach (string text in traderLocations) { bool flag = HasMetTrader(text); Vector3 result; string text2 = (FindClosestLocation(text, ((Component)localPlayer).transform.position, out result) ? $"{Vector3.Distance(((Component)localPlayer).transform.position, result):F0}m" : "not found"); args.Context.AddString($" {text}: met={flag} dist={text2} pos={result}"); } } internal void b__188_8(ConsoleEventArgs args) { args.Context.AddString("=== Campfire Rituals ==="); args.Context.AddString(" " + SeekFood + " (Boar Meat) → Guiding Wind — seek next boss altar"); args.Context.AddString(" Mushroom* (Yellow Mushroom) → Reset forsaken power cooldown"); args.Context.AddString(" " + HomeFood + " (Dandelion) → Guiding Wind — find your bed"); args.Context.AddString(" " + FeatherFood + " (Feathers) → Feather Fall — no fall damage 60s"); args.Context.AddString(" Any Trophy → Dungeon Seeker — find nearest dungeon"); args.Context.AddString($"Global cooldown: {RitualCooldownDuration}s. Hold item in slot 1, look at burning campfire, press 1."); } internal void b__188_9(ConsoleEventArgs args) { ShowHintsEnabled = ((args.Args.Length > 1) ? (args.Args[1].ToLower() == "on") : (!ShowHintsEnabled)); args.Context.AddString("Ritual hints: " + (ShowHintsEnabled ? "ON" : "OFF")); } internal void b__188_10(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } string text = ((args.Args.Length > 1) ? args.Args[1].ToLower() : "all"); (string, bool, string, string)[] ritualItemMap = RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { (string, bool, string, string) tuple = ritualItemMap[i]; string item = tuple.Item3; string item2 = tuple.Item4; if (!(text != "all") || !(item != text)) { LearnRitual(localPlayer, item, item2); } } args.Context.AddString((text == "all") ? "All rituals learned." : ("Learned: " + text)); } internal void b__188_11(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } int num = 0; int num2 = 0; HashSet hashSet = new HashSet(); (string, bool, string, string)[] ritualItemMap = RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { (string, bool, string, string) tuple = ritualItemMap[i]; string item = tuple.Item1; bool item2 = tuple.Item2; string item3 = tuple.Item3; RitualItemConfig value; string text = ((!item2) ? item : (Cfg.Rituals.Items.TryGetValue(item3, out value) ? value.Item.TrimEnd('*') : item)); if (hashSet.Add(text)) { if (((Humanoid)localPlayer).GetInventory().AddItem(text, 1, 1, 0, 0L, "", false) != null) { num++; } else { num2++; } } } args.Context.AddString($"Ritual kit: {num} items added, {num2} prefabs not found."); } internal void b__188_12(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } string text = ((args.Args.Length > 1) ? args.Args[1].ToLower() : "all"); (string, bool, string, string)[] ritualItemMap = RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { string item = ritualItemMap[i].Item3; if (!(text != "all") || !(item != text)) { localPlayer.m_customData.Remove("ath_known_" + item); } } args.Context.AddString((text == "all") ? "All rituals forgotten." : ("Forgotten: " + text)); } internal void b__188_13(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } List list = new List(); (string, bool, string, string)[] ritualItemMap = RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { string item = ritualItemMap[i].Item3; string key = "ath_uses_" + item; if (localPlayer.m_customData.TryGetValue(key, out var value)) { list.Add(" " + item + ": " + value); } } if (list.Count == 0) { args.Context.AddString("No rituals performed yet."); return; } list.Sort(); args.Context.AddString("Ritual usage:"); foreach (string item2 in list) { args.Context.AddString(item2); } } internal void b__188_14(ConsoleEventArgs args) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_01e6: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0638: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_061e: Unknown result type (might be due to invalid IL or missing references) //IL_06fd: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass188_0 CS$<>8__locals4 = new <>c__DisplayClass188_0 { player = Player.m_localPlayer }; if ((Object)(object)CS$<>8__locals4.player == (Object)null) { return; } WearNTear val = (from c in Physics.OverlapSphere(((Component)CS$<>8__locals4.player).transform.position, 5f) select ((Component)c).GetComponentInParent() into w where (Object)(object)w != (Object)null && (Object)(object)((Component)w).GetComponent() != (Object)null orderby Vector3.Distance(((Component)w).transform.position, ((Component)CS$<>8__locals4.player).transform.position) select w).FirstOrDefault(); if ((Object)(object)val == (Object)null) { args.Context.AddString("[inspect] No structure within 5m."); return; } HashSet hashSet = FloodFillStructure(val); SortedDictionary sortedDictionary = new SortedDictionary(); SortedDictionary sortedDictionary2 = new SortedDictionary(); Bounds val2 = default(Bounds); bool flag = false; int num = 0; float num2 = 0f; int num3 = 0; float num4 = float.MaxValue; float num5 = float.MinValue; int num6 = 0; FieldInfo field = typeof(WearNTear).GetField("m_support", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); MethodInfo method = typeof(WearNTear).GetMethod("GetMaxSupport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int mask = LayerMask.GetMask(new string[1] { "terrain" }); RaycastHit val4 = default(RaycastHit); foreach (WearNTear item in hashSet) { string text = ((Object)((Component)item).gameObject).name.Replace("(Clone)", "").Trim().ToLower(); string key = ((Object)((Component)item).gameObject).name.Replace("(Clone)", "").Trim(); sortedDictionary.TryGetValue(key, out var value); sortedDictionary[key] = value + 1; Collider[] componentsInChildren = ((Component)item).GetComponentsInChildren(); foreach (Collider val3 in componentsInChildren) { if (!val3.isTrigger) { Bounds bounds = val3.bounds; if (!flag) { val2 = bounds; flag = true; } else { ((Bounds)(ref val2)).Encapsulate(bounds); } } } float y = ((Component)item).transform.position.y; float num8 = y; if (Physics.Raycast(new Vector3(((Component)item).transform.position.x, y + 50f, ((Component)item).transform.position.z), Vector3.down, ref val4, 200f, mask)) { num8 = ((RaycastHit)(ref val4)).point.y; } if (y <= num8 + 1f) { num++; } if (text.Contains("roof")) { num3++; } if (field != null) { float num9 = (float)(field.GetValue(item) ?? ((object)0f)); float num10 = ((method != null) ? ((float)(method.Invoke(item, null) ?? ((object)num9))) : num9); if (num9 < num4) { num4 = num9; } if (num9 > num5) { num5 = num9; } if (num10 > 0f && num9 >= num10 * 0.99f) { num6++; } } ZNetView component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { float num11 = num2; ZDO zDO = component.GetZDO(); num2 = num11 + ((((zDO != null) ? new float?(zDO.GetFloat(ZDOVars.s_health, item.m_health)) : ((float?)null)) / item.m_health) ?? 1f); } else { num2 += 1f; } Piece component2 = ((Component)item).GetComponent(); if (component2?.m_resources == null) { continue; } Requirement[] resources = component2.m_resources; foreach (Requirement val5 in resources) { if (val5?.m_resItem?.m_itemData?.m_shared?.m_name != null && val5.m_amount > 0) { string key2 = ((Object)((Component)val5.m_resItem).gameObject).name.Replace("(Clone)", "").Trim(); sortedDictionary2.TryGetValue(key2, out var value2); sortedDictionary2[key2] = value2 + val5.m_amount; } } } int num12 = 0; SortedDictionary sortedDictionary3 = new SortedDictionary(); foreach (WearNTear item2 in hashSet) { Piece component3 = ((Component)item2).GetComponent(); if ((Object)(object)component3 != (Object)null && component3.m_comfort > num12) { num12 = component3.m_comfort; } if ((Object)(object)((Component)item2).GetComponent() != (Object)null || (Object)(object)((Component)item2).GetComponent() != (Object)null) { string key3 = ((Object)((Component)item2).gameObject).name.Replace("(Clone)", "").Trim(); sortedDictionary3.TryGetValue(key3, out var value3); sortedDictionary3[key3] = value3 + 1; } } int count = hashSet.Count; float num13 = (flag ? ((Bounds)(ref val2)).size.y : 0f); float num14 = (flag ? ((Bounds)(ref val2)).size.x : 0f); float num15 = (flag ? ((Bounds)(ref val2)).size.z : 0f); float num16 = Mathf.Sqrt(num14 * num14 + num15 * num15); string text2 = ((num16 < 0.1f) ? "point" : ((num13 / num16 > 1.5f) ? "tower" : ((num13 / num16 > 0.6f) ? "balanced" : "hall"))); float num17 = ((count > 0) ? (num2 / (float)count * 100f) : 0f); int num18 = 0; int num19 = 0; if (flag) { float num20 = 1f; Vector3 center = ((Bounds)(ref val2)).center; ZoneSystem instance = ZoneSystem.instance; float num21 = ((instance != null) ? instance.GetSolidHeight(new Vector3(center.x, center.y, center.z)) : ((Bounds)(ref val2)).min.y) + 1f; float num24 = default(float); bool flag2 = default(bool); for (float num22 = ((Bounds)(ref val2)).min.x; num22 <= ((Bounds)(ref val2)).max.x; num22 += num20) { for (float num23 = ((Bounds)(ref val2)).min.z; num23 <= ((Bounds)(ref val2)).max.z; num23 += num20) { Cover.GetCoverForPoint(new Vector3(num22, num21, num23), ref num24, ref flag2, 0.5f); num19++; if (num24 > 0f) { num18++; } } } } float num25 = ((num19 > 0) ? ((float)num18 / (float)num19 * 100f) : 0f); args.Context.AddString($"[inspect dbg] bounds={((Bounds)(ref val2)).min:F1} to {((Bounds)(ref val2)).max:F1} sampleY={((Bounds)(ref val2)).min.y + 0.5f:F1} sheltered={num18}/{num19}"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine($"── Structure ({count} pieces) ──"); stringBuilder.AppendLine($"Height: {num13:F1}m Footprint: {num14:F0}x{num15:F0}m Shape: {text2}"); stringBuilder.AppendLine($"Ground: {num} Roof: {num3} Shelter: {num25:F0}% Health: {num17:F0}%"); if (field != null) { stringBuilder.AppendLine($"Support: full={num6}/{count} min={num4:F0} max={num5:F0}"); } stringBuilder.AppendLine($"Comfort: {num12}"); string text3 = string.Join(" ", sortedDictionary2.Select((KeyValuePair kv) => $"{kv.Key}×{kv.Value}")); stringBuilder.AppendLine("Materials: " + text3); if (sortedDictionary3.Count > 0) { string text4 = string.Join(" ", sortedDictionary3.Select((KeyValuePair kv) => $"{kv.Key}×{kv.Value}")); stringBuilder.AppendLine("Stations: " + text4); } stringBuilder.AppendLine("────────────────"); foreach (KeyValuePair item3 in sortedDictionary) { stringBuilder.AppendLine($" {item3.Key}: {item3.Value}"); } string text5 = stringBuilder.ToString().TrimEnd(); args.Context.AddString(text5); MessageHudTimerPatch.ExtendNextCenter = true; ((Character)CS$<>8__locals4.player).Message((MessageType)2, text5, 0, (Sprite)null); ((MonoBehaviour)plugin).StartCoroutine(FlashPieces(hashSet.Select((WearNTear w) => ((Component)w).gameObject).ToList())); } internal WearNTear b__188_28(Collider c) { return ((Component)c).GetComponentInParent(); } internal bool b__188_29(WearNTear w) { if ((Object)(object)w != (Object)null) { return (Object)(object)((Component)w).GetComponent() != (Object)null; } return false; } internal string b__188_31(KeyValuePair kv) { return $"{kv.Key}×{kv.Value}"; } internal string b__188_33(KeyValuePair kv) { return $"{kv.Key}×{kv.Value}"; } internal GameObject b__188_32(WearNTear w) { return ((Component)w).gameObject; } internal void b__188_15(ConsoleEventArgs args) { <>c__DisplayClass188_1 CS$<>8__locals4 = new <>c__DisplayClass188_1(); ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("ZNetScene not ready."); return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (!(typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary dictionary)) { args.Context.AddString("Could not read prefab list."); return; } CS$<>8__locals4.pattern = ((args.Length > 1) ? args[1].ToLower() : ""); List list = (from g in dictionary.Values where (Object)(object)g != (Object)null && (string.IsNullOrEmpty(CS$<>8__locals4.pattern) || ((Object)g).name.ToLower().Contains(CS$<>8__locals4.pattern)) select ((Object)g).name into n orderby n select n).ToList(); args.Context.AddString($"=== {list.Count} prefabs matching '{CS$<>8__locals4.pattern}' ==="); foreach (string item in list) { args.Context.AddString(" " + item); } } internal string b__188_35(GameObject g) { return ((Object)g).name; } internal string b__188_36(string n) { return n; } internal void b__188_16(ConsoleEventArgs args) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("ZNetScene not ready."); return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (!(typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary dictionary)) { args.Context.AddString("Could not read prefab list."); return; } Dictionary dictionary2 = new Dictionary(); foreach (GameObject value in dictionary.Values) { if ((Object)(object)value == (Object)null) { continue; } Renderer[] componentsInChildren = value.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val == (Object)null || (Object)(object)val.shader == (Object)null) { continue; } string name = ((Object)val.shader).name; if (val.renderQueue >= 2450 || name.Contains("Transparent") || name.Contains("Alpha") || name.Contains("Particle") || name.Contains("Unlit")) { string key = ((Object)val).name + " | " + name; if (!dictionary2.ContainsKey(key)) { dictionary2[key] = ((Object)value).name; } } } } } args.Context.AddString($"=== {dictionary2.Count} transparent materials ==="); foreach (KeyValuePair item in dictionary2.OrderBy((KeyValuePair k) => k.Key)) { args.Context.AddString(" " + item.Key + " (eg: " + item.Value + ")"); } } internal string b__188_37(KeyValuePair k) { return k.Key; } internal void b__188_17(ConsoleEventArgs args) { if (args.Length < 2) { args.Context.AddString("Usage: ath_mats "); return; } ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(args[1]) : null); if ((Object)(object)val == (Object)null) { args.Context.AddString("Prefab '" + args[1] + "' not found."); return; } Renderer[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { Material[] sharedMaterials = val2.sharedMaterials; foreach (Material val3 in sharedMaterials) { if ((Object)(object)val3 != (Object)null) { Terminal context = args.Context; string[] obj = new string[6] { " ", ((Object)((Component)val2).gameObject).name, " | ", ((Object)val3).name, " | ", null }; Shader shader = val3.shader; obj[5] = ((shader != null) ? ((Object)shader).name : null); context.AddString(string.Concat(obj)); } } } } internal void b__188_18(ConsoleEventArgs args) { //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { args.Context.AddString("Usage: ath_wardmat "); return; } Renderer activeCampfireWardRend = ActiveCampfireWardRend; if ((Object)(object)activeCampfireWardRend == (Object)null) { args.Context.AddString("[wardmat] No active campfire ward."); return; } string text = args[1].ToLower(); ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("ZNetScene not ready."); return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (!(typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary dictionary)) { args.Context.AddString("Could not read prefab list."); return; } Material val = null; string text2 = null; foreach (GameObject value in dictionary.Values) { if ((Object)(object)value == (Object)null) { continue; } Renderer[] componentsInChildren = value.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name.ToLower() == text) { val = val2; text2 = ((Object)value).name; break; } } } if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { args.Context.AddString("[wardmat] Material '" + args[1] + "' not found in any prefab."); return; } Material val3 = new Material(val); val3.SetInt("_Cull", 0); if (val3.HasProperty("_Color")) { val3.color = new Color(0.55f, 0f, 1f, 0.15f); } if (val3.HasProperty("_TintColor")) { val3.SetColor("_TintColor", new Color(0.55f, 0f, 1f, 0.15f)); } activeCampfireWardRend.material = val3; Terminal context = args.Context; string[] obj = new string[6] { "[wardmat] Applied '", ((Object)val).name, "' (shader: ", null, null, null }; Shader shader = val.shader; obj[3] = ((shader != null) ? ((Object)shader).name : null); obj[4] = ") from "; obj[5] = text2; context.AddString(string.Concat(obj)); } internal void b__188_19(ConsoleEventArgs args) { //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("ZNetScene not ready."); return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Dictionary dictionary = typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) as Dictionary; if (args.Length < 2 || args[1] == "list") { if (dictionary == null) { args.Context.AddString("Could not read prefab list."); return; } List list = (from g in dictionary.Values where (Object)(object)g != (Object)null select ((Object)g).name into n where n.StartsWith("vfx_") || n.StartsWith("fx_") || n.StartsWith("sfx_") orderby n select n).ToList(); args.Context.AddString($"=== {list.Count} VFX prefabs ==="); { foreach (string item in list) { args.Context.AddString(" " + item); } return; } } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { GameObject prefab = instance.GetPrefab(args[1]); if ((Object)(object)prefab == (Object)null) { args.Context.AddString("Prefab '" + args[1] + "' not found."); return; } Object.Instantiate(prefab, ((Component)localPlayer).transform.position, Quaternion.identity); args.Context.AddString("Spawned " + args[1]); } } internal bool b__188_38(GameObject g) { return (Object)(object)g != (Object)null; } internal string b__188_39(GameObject g) { return ((Object)g).name; } internal bool b__188_40(string n) { if (!n.StartsWith("vfx_") && !n.StartsWith("fx_")) { return n.StartsWith("sfx_"); } return true; } internal string b__188_41(string n) { return n; } internal void b__188_20(ConsoleEventArgs args) { if (args.Length < 2) { args.Context.AddString("Usage: ath_cleanup_vfx "); return; } string text = args[1]; ZNetScene instance = ZNetScene.instance; ZDOMan instance2 = ZDOMan.instance; if ((Object)(object)instance == (Object)null || instance2 == null) { args.Context.AddString("Not ready."); return; } List list = new List(); int num = 0; int num2 = 0; while (!instance2.GetAllZDOsWithPrefabIterative(text, list, ref num)) { } foreach (ZDO item in list) { ZNetView val = instance.FindInstance(item); if ((Object)(object)val != (Object)null) { ZNetScene.instance.Destroy(((Component)val).gameObject); num2++; } else { instance2.DestroyZDO(item); num2++; } } args.Context.AddString($"Destroyed {num2} instances of '{text}'."); } internal void b__188_21(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { Vagon val = CartUpgrade.FindNearest(localPlayer, 10f); if ((Object)(object)val == (Object)null) { args.Context.AddString("No cart within 10m."); } else { CartUpgrade.Upgrade(localPlayer, val, args); } } } internal void b__188_22(ConsoleEventArgs args) { EnvMan instance = EnvMan.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("EnvMan not ready."); return; } args.Context.AddString($"=== Environments ({instance.m_environments.Count}) ==="); foreach (EnvSetup environment in instance.m_environments) { args.Context.AddString(" " + environment.m_name); } } internal void b__188_23(ConsoleEventArgs args) { //IL_0053: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } int num = 0; MonoBehaviour[] array = Object.FindObjectsOfType(); foreach (MonoBehaviour val in array) { if ((Object)(object)val == (Object)null || ((object)val).GetType().Name != "RandomFlyingBird" || Vector3.Distance(((Component)val).transform.position, ((Component)localPlayer).transform.position) > 60f) { continue; } num++; args.Context.AddString($"--- Bird {num} ({((Object)((Component)val).gameObject).name}) ---"); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo[] fields = ((object)val).GetType().GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { try { args.Context.AddString($" {fieldInfo.FieldType.Name} {fieldInfo.Name} = {fieldInfo.GetValue(val)}"); } catch { } } Component[] componentsInChildren = ((Component)val).GetComponentsInChildren(); foreach (Component val2 in componentsInChildren) { PropertyInfo propertyInfo = ((object)val2)?.GetType().GetProperty("parameters"); if (propertyInfo == null || !(propertyInfo.GetValue(val2) is Array array2)) { continue; } foreach (object item in array2) { PropertyInfo property = item.GetType().GetProperty("name"); PropertyInfo property2 = item.GetType().GetProperty("type"); args.Context.AddString($" Anim param: {property?.GetValue(item)} ({property2?.GetValue(item)})"); } } } if (num == 0) { args.Context.AddString("No birds within 60m."); } } internal void b__188_24(ConsoleEventArgs args) { EnvMan instance = EnvMan.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("EnvMan not ready."); return; } FieldInfo[] fields = typeof(EnvMan).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { string name = fieldInfo.Name; if (name.ToLower().Contains("env") || name.ToLower().Contains("current") || name.ToLower().Contains("debug") || name.ToLower().Contains("time")) { object value = fieldInfo.GetValue(instance); string text = ((value == null) ? "null" : value.ToString()); EnvSetup val = (EnvSetup)((value is EnvSetup) ? value : null); if (val != null) { text = "EnvSetup(" + val.m_name + ")"; } args.Context.AddString(fieldInfo.FieldType.Name + " " + name + " = " + text); } } } internal bool b__209_0(StatusEffect s) { return ((Object)s).name == "SE_GuidingWind"; } internal bool b__217_0(StatusEffect s) { return ((Object)s).name == "SE_GuidingWind"; } internal bool b__220_0(StatusEffect s) { return ((Object)s).name == "SE_WaterWalk"; } internal bool b__221_0(StatusEffect s) { return ((Object)s).name == "SE_Giant"; } internal bool b__225_0(StatusEffect s) { return ((Object)s).name == "SE_Burden"; } internal void b__228_0(long sender, float duration) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ApplyShieldBubble(localPlayer, duration); } } internal void b__240_0(long sender, Vector3 pos, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) SpawnCampfireWard(pos, duration, null); } internal void b__240_1(long sender) { CampfireWardExpiry = 0f; if ((Object)(object)ActiveCampfireWard != (Object)null) { Object.Destroy((Object)(object)ActiveCampfireWard); ActiveCampfireWard = null; } } internal WearNTear b__246_0(Collider c) { return ((Component)c).GetComponentInParent(); } internal bool b__246_1(WearNTear w) { if ((Object)(object)w != (Object)null) { return (Object)(object)((Component)w).GetComponent() != (Object)null; } return false; } internal void b__249_0(long sender, ZPackage pkg) { //IL_0015: 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) int num = pkg.ReadInt(); List list = new List(num); for (int i = 0; i < num; i++) { list.Add(pkg.ReadVector3()); } float duration = pkg.ReadSingle(); int seHash = pkg.ReadInt(); float fireDamage = pkg.ReadSingle(); string vfxPrefabName = pkg.ReadString(); float vfxScale = pkg.ReadSingle(); string vfxPrefabName2 = pkg.ReadString(); Color tint = default(Color); ((Color)(ref tint))..ctor(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); float lightMult = pkg.ReadSingle(); float smokeInterval = pkg.ReadSingle(); ((MonoBehaviour)plugin).StartCoroutine(StructureRitualTick(list, duration, seHash, fireDamage, vfxPrefabName, null, null, null, vfxScale, tint, lightMult, vfxPrefabName2, smokeInterval)); } internal WearNTear b__259_0(Collider c) { return ((Component)c).GetComponentInParent(); } internal GameObject b__259_2(WearNTear w) { return ((Component)w).gameObject; } internal void b__265_0(long _, Vector3 pos, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) SpawnDemisterLocal(pos, duration); } internal WearNTear b__271_0(Collider c) { return ((Component)c).GetComponentInParent(); } internal Vector3 b__271_2(WearNTear w) { //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) return ProjectToTerrain(((Component)w).transform.position); } internal ZNetView b__271_3(WearNTear w) { return ((Component)w).GetComponent(); } internal bool b__271_4(ZNetView zv) { if ((Object)(object)zv != (Object)null) { return zv.IsValid(); } return false; } internal ZDOID b__271_5(ZNetView zv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return zv.GetZDO().m_uid; } internal string b__271_6(ZDOID id) { return $"{((ZDOID)(ref id)).UserID}:{((ZDOID)(ref id)).ID}"; } internal string b__271_7(Vector3 p) { //IL_0005: 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_001b: Unknown result type (might be due to invalid IL or missing references) return $"{p.x:F2},{p.y:F2},{p.z:F2}"; } internal WearNTear b__272_0(Collider c) { return ((Component)c).GetComponentInParent(); } internal Vector3 b__272_2(WearNTear w) { //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) return ProjectToTerrain(((Component)w).transform.position); } internal ZNetView b__272_3(WearNTear w) { return ((Component)w).GetComponent(); } internal bool b__272_4(ZNetView zv) { if ((Object)(object)zv != (Object)null) { return zv.IsValid(); } return false; } internal ZDOID b__272_5(ZNetView zv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return zv.GetZDO().m_uid; } internal string b__272_6(ZDOID id) { return $"{((ZDOID)(ref id)).UserID}:{((ZDOID)(ref id)).ID}"; } internal string b__272_7(Vector3 p) { //IL_0005: 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_001b: Unknown result type (might be due to invalid IL or missing references) return $"{p.x:F2},{p.y:F2},{p.z:F2}"; } internal bool b__278_0(StatusEffect s) { return ((Object)s).name == "SE_LegendaryWeapon"; } internal bool b__281_0(ItemData i) { GameObject dropPrefab = i.m_dropPrefab; return ((dropPrefab != null) ? ((Object)dropPrefab).name : null) == _legendaryActivePrefab; } internal bool b__283_0(StatusEffect s) { return s is SE_Shield; } } [CompilerGenerated] private sealed class <>c__DisplayClass188_0 { public Player player; internal float b__30(WearNTear w) { //IL_0006: 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) return Vector3.Distance(((Component)w).transform.position, ((Component)player).transform.position); } } [CompilerGenerated] private sealed class <>c__DisplayClass188_1 { public string pattern; internal bool b__34(GameObject g) { if ((Object)(object)g != (Object)null) { if (!string.IsNullOrEmpty(pattern)) { return ((Object)g).name.ToLower().Contains(pattern); } return true; } return false; } } internal static Plugin plugin = null; internal static ManualLogSource Log = null; internal static EnvScheduler? Scheduler; internal static SE_GuidingWind? GuidingWindSE; internal static SE_WaterWalk? WaterWalkSE; internal static SE_Giant? GiantSE; internal static SE_Burden? BurdenSE; internal static SE_LegendaryWeapon? LegendarySE; internal static SE_Shield? ShieldBubbleSE; internal static Material? WardSphereMat; internal static PilgrimConfig Cfg = PilgrimConfig.Default(); private static bool _cfgDirty = false; private static FileSystemWatcher? _cfgWatcher; internal static readonly Dictionary TreeStandSeeds = new Dictionary { { "FirCone", "FirTree" }, { "PineCone", "Pinetree_01" }, { "Acorn", "Oak1" }, { "BeechSeeds", "Beech1" }, { "BirchSeeds", "Birch1" } }; internal static Vector3? SeekOverrideTarget = null; internal static Vector3? BossSeekTarget = null; internal const string CratePrefabName = "PilgrimCrate"; internal const string CrateDataKey = "pilgrim_crate"; internal static readonly string[] CrateMetals = new string[8] { "Copper", "Tin", "Bronze", "Iron", "Silver", "BlackMetal", "Flametal", "Coins" }; internal static GameObject? _cratePrefabGo; internal static bool _suppressZNetViewAwake = false; internal static bool _suppressContainerAwake = false; internal static ItemData? _crateItem; internal static Inventory? _crateInventory; internal static Container? _fakeCrateContainer; internal static GameObject? _fakeCrateGo; internal static bool _closingCrateUI = false; internal static bool _crateUIOpen = false; internal static bool _openingCrateUI = false; internal static bool _hidingInventory = false; internal static Container? _previousContainer = null; internal static bool _suppressSpawnSet = false; internal static Recipe? _crateRecipe = null; internal static Requirement[]? _crateCraftResources = null; internal static readonly (string prefab, int amount)[] CrateUpgrades = new(string, int)[6] { ("", 0), ("", 0), ("Bronze", 5), ("Iron", 4), ("Silver", 6), ("BlackMetal", 8) }; private static Inventory? _closedCrateInvCache; private static string? _closedCrateInvCacheKey; internal static readonly (string Match, bool Prefix, string Key, string Display)[] RitualItemMap = new(string, bool, string, string)[46] { ("BjornMeat", false, "seek_altar", "Bear Meat"), ("Dandelion", false, "seek_bed", "Dandelion"), ("Coins", false, "seek_trader", "Coins"), ("Trophy", true, "seek_dungeon", "Trophy"), ("Flint", false, "seek_player", "Flint"), ("Mushroom", true, "restore_power", "Mushroom"), ("Feathers", false, "feather_fall", "Feathers"), ("GreydwarfEye", false, "clear_skies", "Greydwarf Eye"), ("Stone", false, "water_walk", "Stone"), ("AncientSeed", false, "growth", "Ancient Seed"), ("FirCone", false, "tree_stand", "Tree Seeds"), ("PineCone", false, "tree_stand", "a tree seed"), ("Acorn", false, "tree_stand", "a tree seed"), ("BeechSeeds", false, "tree_stand", "a tree seed"), ("BirchSeeds", false, "tree_stand", "a tree seed"), ("WitheredBone", false, "rock_stand", "Withered Bone"), ("Entrails", false, "prime", "Entrails"), ("BoneFragments", false, "tame_flock", "Bone Fragments"), ("Barley", false, "mead_ripen", "Barley"), ("Resin", false, "kindle", "Resin"), ("Coal", false, "repair", "Coal"), ("YmirRemains", false, "giant", "Ymir Flesh"), ("RawMeat", false, "burden", "Boar Meat"), ("Amber", false, "ward_bubble", "Amber"), ("AmberPearl", false, "campfire_ward", "Amber Pearl"), ("Obsidian", false, "tar_moat", "Obsidian"), ("Chitin", false, "seek_corpse", "Chitin"), ("Wisp", false, "clear_mist", "Wisp"), ("Ruby", false, "fire_wall", "Ruby"), ("DeerHide", false, "seek_deer", "Deer Hide"), ("LeatherScraps", false, "seek_boar", "Leather Scraps"), ("BjornHide", false, "seek_bear", "Bear Hide"), ("TrollHide", false, "seek_troll", "Troll Hide"), ("Root", false, "seek_abomination", "Root"), ("SerpentScale", false, "seek_serpent", "Serpent Scale"), ("WolfPelt", false, "seek_wolf", "Wolf Pelt"), ("LoxPelt", false, "seek_lox", "Lox Pelt"), ("HareMeat", false, "seek_misthare", "Hare Meat"), ("AskHide", false, "seek_asksvin", "Asksvin Hide"), ("SurtlingCore", false, "flaming_sword", "Surtling Core"), ("Ooze", false, "jotun_bane", "Ooze"), ("Copper", false, "krom", "Copper"), ("Iron", false, "slayer", "Iron"), ("Bloodbag", false, "skull_splittur", "Blood Bag"), ("Tin", false, "himminafl", "Tin"), ("Crystal", false, "mistwalker", "Crystal") }; internal static readonly HuntDef[] HuntDefs = new HuntDef[10] { new HuntDef { Key = "seek_deer", Prefab = "Deer", DefaultIngredient = "DeerHide", Biome = (Biome)1, Scale = 1.8f, DefaultHoverText = "Hunt the deer", DefaultMessage = "He thinks he's alone.", DefaultDistance = 150f }, new HuntDef { Key = "seek_boar", Prefab = "Boar", DefaultIngredient = "LeatherScraps", Biome = (Biome)1, Scale = 1.8f, DefaultHoverText = "Hunt the boar", DefaultMessage = "The boar roots nearby.", DefaultDistance = 150f }, new HuntDef { Key = "seek_bear", Prefab = "Bjorn", DefaultIngredient = "BjornHide", Biome = (Biome)8, Scale = 1.8f, DefaultHoverText = "Hunt the bear", DefaultMessage = "A great shadow waits in the trees.", DefaultDistance = 150f }, new HuntDef { Key = "seek_troll", Prefab = "Troll", DefaultIngredient = "TrollHide", Biome = (Biome)8, Scale = 1.8f, DefaultHoverText = "Hunt the troll", DefaultMessage = "The earth shudders.", DefaultDistance = 150f }, new HuntDef { Key = "seek_abomination", Prefab = "Abomination", DefaultIngredient = "Root", Biome = (Biome)2, Scale = 1.8f, DefaultHoverText = "Hunt the abomination", DefaultMessage = "Something ancient stirs in the roots.", DefaultDistance = 150f }, new HuntDef { Key = "seek_wolf", Prefab = "Wolf", DefaultIngredient = "WolfPelt", Biome = (Biome)4, Scale = 1.8f, DefaultHoverText = "Hunt the wolf", DefaultMessage = "The pack circles.", DefaultDistance = 150f }, new HuntDef { Key = "seek_lox", Prefab = "Lox", DefaultIngredient = "LoxPelt", Biome = (Biome)16, Scale = 1.8f, DefaultHoverText = "Hunt the lox", DefaultMessage = "The plains tremble beneath it.", DefaultDistance = 150f }, new HuntDef { Key = "seek_misthare", Prefab = "Hare", DefaultIngredient = "HareMeat", Biome = (Biome)512, Scale = 1.8f, DefaultHoverText = "Hunt the hare", DefaultMessage = "It darts through the mist.", DefaultDistance = 150f }, new HuntDef { Key = "seek_asksvin", Prefab = "Asksvin", DefaultIngredient = "AskHide", Biome = (Biome)32, Scale = 1.8f, DefaultHoverText = "Hunt the asksvin", DefaultMessage = "Ash and ember — it hungers.", DefaultDistance = 150f }, new HuntDef { Key = "seek_serpent", Prefab = "Serpent", DefaultIngredient = "SerpentScale", Biome = (Biome)256, Scale = 1.8f, DefaultHoverText = "Hunt the serpent", DefaultMessage = "Something vast stirs beneath the waves.", DefaultDistance = 150f } }; internal static readonly LegendaryDef[] LegendaryDefs = new LegendaryDef[7] { new LegendaryDef { Key = "flaming_sword", Prefab = "SwordIronFire", DefaultIngredient = "SurtlingCore", SkillType = (SkillType)1, SkillLabel = "sword", DefaultActivateMsg = "Dyrnwyn answers. Let it burn.", DefaultDeactivateMsg = "The flame fades." }, new LegendaryDef { Key = "jotun_bane", Prefab = "AxeJotunBane", DefaultIngredient = "Ooze", SkillType = (SkillType)7, SkillLabel = "axe", DefaultActivateMsg = "Jotun Bane answers the call.", DefaultDeactivateMsg = "The axe rests." }, new LegendaryDef { Key = "krom", Prefab = "THSwordKrom", DefaultIngredient = "Copper", SkillType = (SkillType)1, SkillLabel = "sword", DefaultActivateMsg = "Krom rises from the deep.", DefaultDeactivateMsg = "Krom is stilled." }, new LegendaryDef { Key = "slayer", Prefab = "THSwordSlayer", DefaultIngredient = "Iron", SkillType = (SkillType)1, SkillLabel = "sword", DefaultActivateMsg = "Slayer hungers.", DefaultDeactivateMsg = "The slayer rests." }, new LegendaryDef { Key = "skull_splittur", Prefab = "BattleaxeSkullSplittur", DefaultIngredient = "Bloodbag", SkillType = (SkillType)7, SkillLabel = "axe", DefaultActivateMsg = "Skull Splittur demands a reckoning.", DefaultDeactivateMsg = "The axe is sated." }, new LegendaryDef { Key = "himminafl", Prefab = "AtgeirHimminAfl", DefaultIngredient = "Tin", SkillType = (SkillType)4, SkillLabel = "polearm", DefaultActivateMsg = "Himminafl crackles with thunder.", DefaultDeactivateMsg = "The thunder fades." }, new LegendaryDef { Key = "mistwalker", Prefab = "SwordMistwalker", DefaultIngredient = "Crystal", SkillType = (SkillType)1, SkillLabel = "sword", DefaultActivateMsg = "Mistwalker parts the veil.", DefaultDeactivateMsg = "The mist returns." } }; internal static readonly string[] CampfirePrefabs = new string[5] { "fire_pit", "fire_pit_iron", "hearth", "bonfire", "piece_brazier" }; internal static float RitualCooldownRemaining = 0f; internal static float FeatherRitualExpiry = 0f; internal static bool FeatherJumpActive = false; internal const float FeatherJumpMult = 1.5f; internal static float ClearSkiesExpiry = 0f; internal static float RainExpiry = 0f; internal static float GiantRainExpiry = 0f; internal static float WaterWalkExpiry = 0f; internal static float SeekEnvExpiry = 0f; internal static float DungeonEnvExpiry = 0f; internal static float HomeEnvExpiry = 0f; internal static bool GrowthBlessingActive = false; internal static bool ShowHintsEnabled = true; internal static int HintPage = 0; internal const int HintPageSize = 15; internal static bool TameBlessingActive = false; internal static bool MeadBlessingActive = false; internal const string TreeStandKey = "ath_tree_stand_positions"; internal const string TreeStandPiecesKey = "ath_tree_stand_pieces"; internal const string RockStandKey = "ath_rock_stand_positions"; internal const string RockStandPiecesKey = "ath_rock_stand_pieces"; internal const string PrimeDayKey = "pilgrim_prime_day"; internal static float FlamingSwordExpiry = 0f; internal static LegendaryDef _activeLegendaryDef; internal static ItemData? _legendaryActiveItem = null; internal static string? _legendaryActivePrefab = null; private static ItemData? _legendaryOrigItem = null; internal static float GiantExpiry = 0f; internal static float BurdenExpiry = 0f; internal static float ShieldBubbleExpiry = 0f; internal static float CampfireWardExpiry = 0f; internal static Coroutine? ActiveStructureRitual = null; internal static Action? ActiveStructureRitualCleanup = null; internal static GameObject? ActiveCampfireWard = null; internal static Renderer? ActiveCampfireWardRend = null; internal static float GiantTargetScale = 1f; internal const float GiantCarryBonus = 300f; internal const float GiantScale = 3f; internal const float GiantWalkMult = 1.5f; internal const float GiantRunMult = 2.5f; internal const float GiantJumpMult = 1.2f; internal static bool GiantSpeedApplied = false; private static DamageTypes _origUnarmedDmg; private static short _origUnarmedTier; private static float _origAttackRange; private static float _origAttackHeight; private static float _origAttackOffset; private static float _origAutoPickupRange; private static float _origSwimDepth; internal static readonly Dictionary TrophyToPower = new Dictionary { { "TrophyEikthyr", "GP_Eikthyr" }, { "TrophyTheElder", "GP_TheElder" }, { "TrophyBonemass", "GP_Bonemass" }, { "TrophyDragonQueen", "GP_Moder" }, { "TrophyGoblinKing", "GP_Yagluth" }, { "TrophySeekerQueen", "GP_Queen" }, { "TrophyFader", "GP_Fader" } }; private static readonly Random Rng = new Random(); private static string? _seekPendingBossName; private static string? _seekPendingMessage; private static float _seekPendingMult; private static Terminal? _seekPendingCtx; private static string? _seekPendingIngredient; private static readonly string[] DungeonLocations = new string[16] { "Crypt2", "Crypt3", "Crypt4", "TrollCave02", "SunkenCrypt4", "MountainCave02", "GoblinCamp2", "Hildir_crypt", "Hildir_cave", "Hildir_plainsfortress", "Mistlands_DvergrTownEntrance1", "Mistlands_DvergrTownEntrance2", "CharredFortress", "MorgenHole1", "MorgenHole2", "MorgenHole3" }; private static readonly string[] TraderLocations = new string[3] { "Vendor_BlackForest", "Hildir_camp", "BogWitch_Camp" }; private const string TraderMetPrefix = "pilgrim_met_"; private static MethodInfo? _isExploredMethod; internal static Action>>? _pendingLocationsCallback; internal const string ShieldBubbleRPC = "Pilgrim_ShieldBubble"; private static Material? s_wardSphereMat; internal const string CampfireWardRPC = "Pilgrim_CampfireWard"; internal const string CampfireWardCancelRPC = "Pilgrim_CampfireWardCancel"; internal const float CampfireWardRadius = 10f; internal const string StructureRitualRPC = "Pilgrim_StructureRitual"; internal static readonly HashSet StructureRitualKeys = new HashSet { "tar_moat", "fire_wall" }; internal const bool StructureRitualDebug = true; private static GameObject? s_smokePrefab; internal const string ClearMistRPC = "Pilgrim_ClearMist"; internal const float ClearMistRadius = 100f; internal static Action? _pendingCorpseCallback; private static Dictionary? _zdoManObjects; private static readonly (string boss, string prefab)[] BossChain = new(string, string)[7] { ("Eikthyr", "Eikthyrnir"), ("The Elder", "GDKing"), ("Bonemass", "Bonemass"), ("Moder", "Dragonqueen"), ("Yagluth", "GoblinKing"), ("The Queen", "Mistlands_DvergrBossEntrance1"), ("Fader", "FaderLocation") }; private static readonly string[] BossKeys = new string[7] { "defeated_eikthyr", "defeated_gdking", "defeated_bonemass", "defeated_dragon", "defeated_goblinking", "defeated_queen", "defeated_fader" }; private static readonly string[] BossTrophies = new string[7] { "TrophyEikthyr", "TrophyTheElder", "TrophyBonemass", "TrophyDragonQueen", "TrophyGoblinKing", "TrophySeekerQueen", "TrophyFader" }; internal static string ConfigPath => Path.Combine(Paths.ConfigPath, "Pilgrim.yaml"); internal static string SeekFood => Cfg.Rituals.Items.GetValueOrDefault("seek_altar")?.Item ?? "RawMeat"; internal static string HomeFood => Cfg.Rituals.Items.GetValueOrDefault("seek_bed")?.Item ?? "Dandelion"; internal static string FeatherFood => Cfg.Rituals.Items.GetValueOrDefault("feather_fall")?.Item ?? "Feathers"; internal static string TraderFood => Cfg.Rituals.Items.GetValueOrDefault("seek_trader")?.Item ?? "Coins"; internal static string GrowthFood => Cfg.Rituals.Items.GetValueOrDefault("growth")?.Item ?? "AncientSeed"; internal static string PlayerSeekFood => Cfg.Rituals.Items.GetValueOrDefault("seek_player")?.Item ?? "Flint"; internal static string KindleFood => Cfg.Rituals.Items.GetValueOrDefault("kindle")?.Item ?? "Resin"; internal static string TameFood => Cfg.Rituals.Items.GetValueOrDefault("tame_flock")?.Item ?? "BoneFragments"; internal static string MeadFood => Cfg.Rituals.Items.GetValueOrDefault("mead_ripen")?.Item ?? "Barley"; internal static string GiantFood => Cfg.Rituals.Items.GetValueOrDefault("giant")?.Item ?? "YmirRemains"; internal static string BurdenFood => Cfg.Rituals.Items.GetValueOrDefault("burden")?.Item ?? "RawMeat"; internal static string WardFood => Cfg.Rituals.Items.GetValueOrDefault("ward_bubble")?.Item ?? "Ruby"; internal static string CampfireWardFood => Cfg.Rituals.Items.GetValueOrDefault("campfire_ward")?.Item ?? "AmberPearl"; internal static string RepairFood => Cfg.Rituals.Items.GetValueOrDefault("repair")?.Item ?? "Coal"; internal static string TarMoatFood => Cfg.Rituals.Items.GetValueOrDefault("tar_moat")?.Item ?? "Obsidian"; internal static string FireWallFood => Cfg.Rituals.Items.GetValueOrDefault("fire_wall")?.Item ?? "FlametalNew"; internal static string CorpseFood => Cfg.Rituals.Items.GetValueOrDefault("seek_corpse")?.Item ?? "Chitin"; internal static string MistFood => Cfg.Rituals.Items.GetValueOrDefault("clear_mist")?.Item ?? "Wisp"; internal static string TreeStandFood => Cfg.Rituals.Items.GetValueOrDefault("tree_stand")?.Item ?? "FirCone"; internal static string PrimeFood => Cfg?.Rituals?.Items?.GetValueOrDefault("prime")?.Item ?? "Entrails"; internal static float RitualCooldownDuration => Cfg.Rituals.Cooldown; internal static float ClearSkiesDuration => Cfg.Rituals.Items.GetValueOrDefault("clear_skies")?.Duration ?? 900f; internal static float RainDuration => Cfg.Rituals.Items.GetValueOrDefault("restore_power")?.Duration ?? 600f; internal static float WaterWalkDuration => Cfg.Rituals.Items.GetValueOrDefault("water_walk")?.Duration ?? 60f; internal static float SeekEnvDuration => 60f; internal static float DungeonEnvDuration => 60f; internal static float HomeEnvDuration => 60f; internal static float LegendaryExpiry => FlamingSwordExpiry; internal static float BurdenCarryBonus => Cfg?.Rituals?.Items?.GetValueOrDefault("burden")?.CarryBonus ?? 1000f; internal static void LoadConfig() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown try { if (!File.Exists(ConfigPath)) { string contents = ((BuilderSkeleton)new SerializerBuilder()).WithNamingConvention(UnderscoredNamingConvention.Instance).Build().Serialize((object)PilgrimConfig.Default()); File.WriteAllText(ConfigPath, contents); Log.LogInfo((object)("[Pilgrim] Wrote default config to " + ConfigPath)); } Cfg = ((BuilderSkeleton)new DeserializerBuilder()).WithNamingConvention(UnderscoredNamingConvention.Instance).IgnoreUnmatchedProperties().Build() .Deserialize(File.ReadAllText(ConfigPath)); PilgrimConfig pilgrimConfig = PilgrimConfig.Default(); bool flag = false; foreach (var (key, value) in pilgrimConfig.Rituals.Items) { if (!Cfg.Rituals.Items.ContainsKey(key)) { Cfg.Rituals.Items[key] = value; flag = true; } } if (flag) { string contents2 = ((BuilderSkeleton)new SerializerBuilder()).WithNamingConvention(UnderscoredNamingConvention.Instance).Build().Serialize((object)Cfg); File.WriteAllText(ConfigPath, contents2); Log.LogInfo((object)"[Pilgrim] Backfilled missing ritual config keys."); } Log.LogInfo((object)"[Pilgrim] Config loaded."); } catch (Exception ex) { Log.LogError((object)("[Pilgrim] Config load failed: " + ex.Message + " — using defaults.")); Cfg = PilgrimConfig.Default(); } } internal static string HuntIngredient(HuntDef def) { return Cfg.Rituals.Items.GetValueOrDefault(def.Key)?.Item ?? def.DefaultIngredient; } internal static string? LegendaryIngredientMatch(string prefab) { LegendaryDef[] legendaryDefs = LegendaryDefs; for (int i = 0; i < legendaryDefs.Length; i++) { LegendaryDef legendaryDef = legendaryDefs[i]; if (prefab == (Cfg.Rituals.Items.GetValueOrDefault(legendaryDef.Key)?.Item ?? legendaryDef.DefaultIngredient)) { return legendaryDef.Key; } } return null; } internal static string EnsureCrateId(ItemData item) { if (string.IsNullOrEmpty(item.m_crafterName) || !item.m_crafterName.StartsWith("PC_")) { item.m_crafterName = "PC_" + Guid.NewGuid().ToString("N").Substring(0, 8); } return item.m_crafterName; } internal static string CratePlayerKey(ItemData item) { return "pilgrim_crate_" + EnsureCrateId(item); } internal static void WriteCrate(Player player, ItemData item, string b64) { item.m_customData["pilgrim_crate"] = b64; player.m_customData[CratePlayerKey(item)] = b64; } internal static string? ReadCrate(Player player, ItemData item) { if (item.m_customData.TryGetValue("pilgrim_crate", out var value) && !string.IsNullOrEmpty(value)) { return value; } player.m_customData.TryGetValue(CratePlayerKey(item), out var value2); return value2; } internal static string CrateMetalSeenKey(string prefab) { return "pilgrim_metal_" + prefab.ToLower(); } internal static bool IsCrateMetalSeen(Player p, string prefab) { return p.m_customData.ContainsKey(CrateMetalSeenKey(prefab)); } internal static ItemData? FindCacheItem(Player player) { if (player == null) { return null; } return ((IEnumerable)((Humanoid)player).GetInventory().GetAllItems()).FirstOrDefault((Func)((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache")); } internal static Inventory? GetCrateInvForRead(Player player) { //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_0062: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_006f: Expected O, but got Unknown if (_crateInventory != null) { return _crateInventory; } ItemData val = FindCacheItem(player); if (val == null) { _closedCrateInvCache = null; _closedCrateInvCacheKey = null; return null; } string text = ReadCrate(player, val); if (_closedCrateInvCache != null && _closedCrateInvCacheKey == text) { return _closedCrateInvCache; } Inventory val2 = new Inventory("tmp", (Sprite)null, 6, val.m_quality * 2); DeserializeCrate(val2, text); _closedCrateInvCache = val2; _closedCrateInvCacheKey = text; return val2; } internal static void SaveCrateInvIfClosed(Player player, Inventory inv) { if (_crateInventory != null) { return; } ItemData val = FindCacheItem(player); if (val != null) { string text = SerializeCrate(inv); WriteCrate(player, val, text); _closedCrateInvCache = inv; _closedCrateInvCacheKey = text; float num = inv.GetAllItems().Sum((ItemData i) => (float)i.m_stack * i.m_shared.m_weight); val.m_customData["pilgrim_crate_weight"] = num.ToString(CultureInfo.InvariantCulture); } } internal static string SerializeCrate(Inventory inv) { //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(); List allItems = inv.GetAllItems(); val.Write(allItems.Count); foreach (ItemData item in allItems) { val.Write(ItemUtil.PrefabName(item)); val.Write(item.m_stack); val.Write(item.m_quality); val.Write(item.m_gridPos.x); val.Write(item.m_gridPos.y); } return Convert.ToBase64String(val.GetArray()); } internal static void DeserializeCrate(Inventory inv, string? b64) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(b64)) { return; } try { ZPackage val = new ZPackage(Convert.FromBase64String(b64)); int num = val.ReadInt(); int width = inv.GetWidth(); int height = inv.GetHeight(); for (int i = 0; i < num; i++) { string text = val.ReadString(); int num2 = val.ReadInt(); int num3 = val.ReadInt(); int num4 = Mathf.Clamp(val.ReadInt(), 0, width - 1); int num5 = Mathf.Clamp(val.ReadInt(), 0, height - 1); if (!string.IsNullOrEmpty(text) && num2 > 0) { ItemData val2 = inv.AddItem(text, num2, num3, 0, 0L, "", false); if (val2 != null) { val2.m_gridPos = new Vector2i(num4, num5); } } } } catch (Exception ex) { Log.LogWarning((object)("[Pilgrim] Crate deserialize failed: " + ex.Message)); } } internal static void RegisterCrateItem(ObjectDB db) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (db.m_items.Any((GameObject g) => (Object)(object)g != (Object)null && ((Object)g).name == "PilgrimCrate")) { return; } GameObject itemPrefab = db.GetItemPrefab("Coins"); if ((Object)(object)itemPrefab == (Object)null) { Log.LogWarning((object)"[Pilgrim] Crate: Coins template not found"); return; } _suppressZNetViewAwake = true; GameObject val = Object.Instantiate(itemPrefab); _suppressZNetViewAwake = false; ((Object)val).name = "PilgrimCrate"; Object.DontDestroyOnLoad((Object)(object)val); _cratePrefabGo = val; ItemDrop component = val.GetComponent(); component.m_itemData.m_shared.m_name = "Pilgrim's Cache"; component.m_itemData.m_shared.m_description = "Holds a little bit of everything. Right-click to open."; component.m_itemData.m_shared.m_weight = 5f; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_value = 0; component.m_itemData.m_shared.m_itemType = (ItemType)1; component.m_itemData.m_shared.m_maxQuality = 5; component.m_itemData.m_dropPrefab = val; component.m_autoPickup = false; db.m_items.Add(val); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic; if (typeof(ObjectDB).GetField("m_itemByHash", bindingAttr)?.GetValue(db) is Dictionary dictionary) { dictionary[StringExtensionMethods.GetStableHashCode(((Object)val).name)] = val; } if (typeof(ObjectDB).GetField("m_itemByData", bindingAttr)?.GetValue(db) is Dictionary dictionary2) { dictionary2[component.m_itemData.m_shared] = val; } AddCrateToZNetScene(val); Log.LogInfo((object)"[Pilgrim] Registered PilgrimCrate"); } internal static void RegisterCrateRecipe(ObjectDB db, ZNetScene zns) { //IL_00ec: 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_0103: 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_0113: Expected O, but got Unknown //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_012c: 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_013b: Expected O, but got Unknown if (!(Cfg?.Cache?.Enabled ?? true)) { return; } if ((Object)(object)db != (Object)null && !db.m_recipes.Any((Recipe r) => (Object)(object)r != (Object)null && ((Object)r).name == "Recipe_PilgrimCrate")) { GameObject? cratePrefabGo = _cratePrefabGo; ItemDrop val = ((cratePrefabGo != null) ? cratePrefabGo.GetComponent() : null); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[Pilgrim] Recipe: _cratePrefabGo null"); return; } Recipe val2 = ScriptableObject.CreateInstance(); ((Object)val2).name = "Recipe_PilgrimCrate"; val2.m_item = val; val2.m_amount = 1; val2.m_minStationLevel = 1; val2.m_craftingStation = null; val2.m_resources = (Requirement[])(object)new Requirement[2] { new Requirement { m_resItem = Res("Copper"), m_amount = 10, m_amountPerLevel = 0 }, new Requirement { m_resItem = Res("LeatherScraps"), m_amount = 6, m_amountPerLevel = 0 } }; _crateRecipe = val2; _crateCraftResources = val2.m_resources; db.m_recipes.Add(val2); Log.LogInfo((object)"[Pilgrim] Registered Recipe_PilgrimCrate"); } if ((Object)(object)zns != (Object)null && (Object)(object)_crateRecipe != (Object)null && (Object)(object)_crateRecipe.m_craftingStation == (Object)null) { GameObject prefab = zns.GetPrefab("forge"); CraftingStation val3 = ((prefab != null) ? prefab.GetComponent() : null); _crateRecipe.m_craftingStation = val3; Log.LogInfo((object)$"[Pilgrim] Recipe: forge station={(Object)(object)val3 != (Object)null}"); } ItemDrop Res(string name) { GameObject itemPrefab = db.GetItemPrefab(name); ItemDrop obj = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); if ((Object)(object)obj == (Object)null) { Log.LogWarning((object)("[Pilgrim] Recipe: ingredient '" + name + "' not found")); } return obj; } } internal static void AddCrateToZNetScene(GameObject go) { ZNetScene instance = ZNetScene.instance; if (!((Object)(object)instance == (Object)null)) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic; if (typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary dictionary) { dictionary[StringExtensionMethods.GetStableHashCode(((Object)go).name)] = go; } if (!instance.m_prefabs.Contains(go)) { instance.m_prefabs.Add(go); } SetupCrateVisuals(instance, go); } } internal static void SetupCrateVisuals(ZNetScene zns, GameObject go) { //IL_00d4: 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_0138: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = zns.GetPrefab("piece_chest_barrel"); if ((Object)(object)prefab == (Object)null) { Log.LogWarning((object)"[Pilgrim] piece_chest_barrel prefab not found"); return; } ItemDrop component = go.GetComponent(); MeshFilter componentInChildren = prefab.GetComponentInChildren(); MeshFilter componentInChildren2 = go.GetComponentInChildren(); MeshRenderer componentInChildren3 = go.GetComponentInChildren(); MeshRenderer componentInChildren4 = prefab.GetComponentInChildren(); Sprite val = prefab.GetComponent()?.m_icon; if ((Object)(object)val != (Object)null) { component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { val }; } if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.sharedMesh = componentInChildren.sharedMesh; } if ((Object)(object)componentInChildren4 != (Object)null && (Object)(object)componentInChildren3 != (Object)null) { ((Renderer)componentInChildren3).sharedMaterials = ((Renderer)componentInChildren4).sharedMaterials; } if ((Object)(object)componentInChildren3 != (Object)null) { ((Component)componentInChildren3).transform.localScale = Vector3.one * 0.5f; } Collider[] componentsInChildren = go.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } CapsuleCollider obj = go.AddComponent(); obj.radius = 0.22f; obj.height = 0.42f; obj.center = new Vector3(0f, 0.21f, 0f); Rigidbody component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.constraints = (RigidbodyConstraints)80; component2.angularDamping = 10f; component2.mass = 5f; } } internal static void OpenCrateUI(Player player, ItemData item) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null) { return; } int num = 6; int num2 = item.m_quality * 2; Inventory val = new Inventory("Pilgrim's Cache", (Sprite)null, num, num2); DeserializeCrate(val, ReadCrate(player, item)); if ((Object)(object)_fakeCrateGo != (Object)null) { Object.Destroy((Object)(object)_fakeCrateGo); } _fakeCrateGo = new GameObject("PilgrimCrateContainer"); _fakeCrateGo.AddComponent(); _fakeCrateGo.transform.position = ((Component)player).transform.position; Object.DontDestroyOnLoad((Object)(object)_fakeCrateGo); _suppressContainerAwake = true; _fakeCrateContainer = _fakeCrateGo.AddComponent(); _suppressContainerAwake = false; typeof(Container).GetField("m_inventory", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_fakeCrateContainer, val); _crateItem = item; _crateInventory = val; _crateUIOpen = true; val.m_onChanged = (Action)Delegate.Combine(val.m_onChanged, (Action)delegate { if (_crateItem != null && _crateInventory != null) { float num3 = _crateInventory.GetAllItems().Sum((ItemData i) => (float)i.m_stack * i.m_shared.m_weight); _crateItem.m_customData["pilgrim_crate_weight"] = num3.ToString(CultureInfo.InvariantCulture); } }); instance.Show(_fakeCrateContainer, 1); } internal static void SaveAndCloseCrateUI() { if (_closingCrateUI) { return; } _closingCrateUI = true; bool crateUIOpen = _crateUIOpen; if (_crateInventory != null && (Object)(object)Player.m_localPlayer != (Object)null) { ItemData crateItem = _crateItem; if (crateItem != null) { WriteCrate(Player.m_localPlayer, crateItem, SerializeCrate(_crateInventory)); float num = _crateInventory.GetAllItems().Sum((ItemData i) => (float)i.m_stack * i.m_shared.m_weight); crateItem.m_customData["pilgrim_crate_weight"] = num.ToString(CultureInfo.InvariantCulture); } } _crateItem = null; _crateInventory = null; InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance != (Object)null && !_hidingInventory) { typeof(InventoryGui).GetMethod("CloseContainer", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(instance, null); } _crateUIOpen = false; _fakeCrateContainer = null; if ((Object)(object)_fakeCrateGo != (Object)null) { Object.Destroy((Object)(object)_fakeCrateGo); _fakeCrateGo = null; } Container previousContainer = _previousContainer; _previousContainer = null; if (crateUIOpen && (Object)(object)previousContainer != (Object)null && Object.op_Implicit((Object)(object)previousContainer)) { _openingCrateUI = true; InventoryGui instance2 = InventoryGui.instance; if (instance2 != null) { instance2.Show(previousContainer, 1); } _openingCrateUI = false; } _closingCrateUI = false; } internal static bool IsRitualKnown(Player player, string key) { return player.m_customData.ContainsKey("ath_known_" + key); } internal static void RecordRitualUse(Player player, string key) { string key2 = "ath_uses_" + key; string value; int result; int num = ((player.m_customData.TryGetValue(key2, out value) && int.TryParse(value, out result)) ? result : 0); player.m_customData[key2] = (num + 1).ToString(); } internal static void LearnRitual(Player player, string key, string itemDisplayName) { if (!IsRitualKnown(player, key)) { player.m_customData["ath_known_" + key] = "1"; if (Cfg.Rituals.Items.TryGetValue(key, out RitualItemConfig value)) { ((Character)player).Message((MessageType)1, "Ritual discovered: " + value.HoverText, 0, (Sprite)null); string text = "Ritual discovered\n" + value.HoverText + "\nOffer " + itemDisplayName + " at a burning campfire."; MessageHudTimerPatch.ExtendNextCenter = true; ((Character)player).Message((MessageType)2, text, 0, (Sprite)null); } } } internal static float RitualMultiplier(Fireplace fp, Player player) { string text = ((Object)((Component)fp).gameObject).name.ToLower().Replace("(clone)", "").Trim(); float num = 1f; int num2 = 0; foreach (KeyValuePair fireMultiplier in Cfg.Rituals.FireMultipliers) { if (text.StartsWith(fireMultiplier.Key) && fireMultiplier.Key.Length > num2) { num2 = fireMultiplier.Key.Length; num = fireMultiplier.Value; } } float comfortPeakMultiplier = Cfg.Rituals.ComfortPeakMultiplier; int comfortLevel = player.GetComfortLevel(); float num3 = 1f + (float)(comfortLevel - 1) * (comfortPeakMultiplier - 1f) / 19f; return num * num3; } internal static bool IsPrimed(Fireplace fp) { ZNetView component = ((Component)fp).GetComponent(); ZDO val = ((component != null) ? component.GetZDO() : null); if (val == null) { return false; } return !string.IsNullOrEmpty(val.GetString("pilgrim_prime_day", "")); } internal static float PrimeMultiplier(Fireplace fp) { RitualItemConfig ritualItemConfig = Cfg?.Rituals?.Items?.GetValueOrDefault("prime"); if (ritualItemConfig == null || !ritualItemConfig.Enabled) { return 1f; } ZNetView component = ((Component)fp).GetComponent(); ZDO val = ((component != null) ? component.GetZDO() : null); if (val == null) { return 1f; } string text = val.GetString("pilgrim_prime_day", ""); if (string.IsNullOrEmpty(text) || !float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return 1f; } float num = Mathf.Max(0f, (float)(ZNet.instance.GetTimeSeconds() / (double)EnvMan.instance.m_dayLengthSec) - result); float multiplierA = ritualItemConfig.MultiplierA; float multiplierB = ritualItemConfig.MultiplierB; return Mathf.Clamp(1f + multiplierA * num + multiplierB * num * num, 1f, 5f); } private void Awake() { //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_00a6: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) plugin = this; Log = ((BaseUnityPlugin)this).Logger; LoadConfig(); _cfgWatcher = new FileSystemWatcher(Paths.ConfigPath, "Pilgrim.yaml") { NotifyFilter = NotifyFilters.LastWrite, EnableRaisingEvents = true }; _cfgWatcher.Changed += delegate { _cfgDirty = true; }; try { new Harmony("com.ctogle.pilgrim").PatchAll(); } catch (Exception ex) { Log.LogError((object)("[Pilgrim] Harmony patch failed: " + ex.Message)); } RegisterCommands(); GameObject val = new GameObject("AthScheduler"); Object.DontDestroyOnLoad((Object)val); Scheduler = val.AddComponent(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Pilgrim loaded."); } internal static void BroadcastBird(Vector3 direction, float speed = 10f) { //IL_000b: 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) Scheduler?.SendBird(direction, speed); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Pilgrim_SendBird", new object[2] { direction, speed }); } } internal static void BroadcastVfx(Vector3 pos, string prefabName, float destroyDelay = 4f, Quaternion? rot = null) { //IL_0014: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) Quaternion val = (Quaternion)(((??)rot) ?? Quaternion.identity); ZNetScene instance = ZNetScene.instance; GameObject val2 = ((instance != null) ? instance.GetPrefab(prefabName) : null); if ((Object)(object)val2 != (Object)null) { SpawnVfxLocal(val2, pos, val, destroyDelay); } ZRoutedRpc instance2 = ZRoutedRpc.instance; if (instance2 != null) { instance2.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Pilgrim_SpawnVfx", new object[4] { pos, val, prefabName, destroyDelay }); } } internal static void SpawnVfxLocal(GameObject prefab, Vector3 pos, Quaternion rot, float destroyDelay) { //IL_0008: 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) prefab.SetActive(false); GameObject val = Object.Instantiate(prefab, pos, rot); prefab.SetActive(true); string[] array = new string[5] { "ZNetView", "ZSyncTransform", "ZSyncAnimation", "ZSFX", "TimedDestruction" }; MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren(true); foreach (MonoBehaviour val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && Array.IndexOf(array, ((object)val2).GetType().Name) >= 0) { Object.DestroyImmediate((Object)(object)val2); } } val.SetActive(true); if (destroyDelay > 0f) { Object.Destroy((Object)(object)val, destroyDelay); } } internal static void BroadcastEnv(string name, string vanillaFallback = "") { SetDebugEnvSafe(name, vanillaFallback); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Pilgrim_SetEnv", new object[2] { name, vanillaFallback }); } } internal static void BroadcastWind(float angle, float intensity) { ApplyWind(angle, intensity); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Pilgrim_SetWind", new object[2] { angle, intensity }); } } internal static void ApplyWind(float angle, float intensity) { if (!((Object)(object)EnvMan.instance == (Object)null)) { if (intensity < 0f) { EnvMan.instance.ResetDebugWind(); } else { EnvMan.instance.SetDebugWind(angle, intensity); } } } private void Update() { if (_cfgDirty) { _cfgDirty = false; LoadConfig(); } } private void RegisterCommands() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_006a: 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_0061: Expected O, but got Unknown //IL_00a2: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00da: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0112: 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_0109: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0141: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0179: Expected O, but got Unknown //IL_01ba: 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_01b1: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_022a: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_0262: 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_0259: Expected O, but got Unknown //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_02d2: 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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Expected O, but got Unknown //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_032e: 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_0339: Expected O, but got Unknown //IL_037a: 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_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Expected O, but got Unknown //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Expected O, but got Unknown //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Expected O, but got Unknown //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Expected O, but got Unknown //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Expected O, but got Unknown //IL_0492: 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_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Expected O, but got Unknown //IL_04ca: 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_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Expected O, but got Unknown //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Expected O, but got Unknown //IL_053a: 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_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Expected O, but got Unknown //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Expected O, but got Unknown object obj = <>c.<>9__188_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: 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_0330: Unknown result type (might be due to invalid IL or missing references) EnvMan instance = EnvMan.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("EnvMan not ready."); } else { float tod = GetTod(); string todLabel = GetTodLabel(tod); string text = GetEnvSetupName(instance, "m_currentEnv") ?? "unknown"; string text2 = GetEnvSetupName(instance, "m_nextEnv") ?? "unknown"; string text3 = instance.m_debugEnv ?? ""; string text4 = (((Object)(object)Scheduler != (Object)null && Scheduler.Active) ? $"ON (prob {Scheduler.Probability:P0})" : "OFF"); double num = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTimeSeconds() : 0.0); args.Context.AddString("=== World State ==="); args.Context.AddString($"TOD : {tod:F2} ({todLabel}) [ZNet raw: {num:F0}s mod1800={num % 1800.0:F0}]"); args.Context.AddString("Current env : " + text + ((text3.Length > 0) ? (" [forced: " + text3 + "]") : "")); args.Context.AddString("Next env : " + text2); args.Context.AddString($"Is wet : {EnvMan.IsWet()}"); args.Context.AddString($"Is cold : {EnvMan.IsCold()}"); args.Context.AddString($"Is freezing : {EnvMan.IsFreezing()}"); args.Context.AddString($"Wind : {instance.GetWindIntensity():F2} dir {instance.GetWindDir()}"); args.Context.AddString("Scheduler : " + text4); RandEventSystem instance2 = RandEventSystem.instance; if ((Object)(object)instance2 != (Object)null) { object obj26 = AnyField(instance2, "m_activeEvent", "m_currentEvent"); if (obj26 != null && (!(AnyField(instance2, "m_haveActiveEvent") is bool flag) || flag) && obj26 != null) { string arg = (AnyField(obj26, "m_name") as string) ?? "?"; float num2 = ((AnyField(instance2, "m_eventTimer", "m_timer") is float num3) ? num3 : 0f); string arg2 = ((AnyField(instance2, "m_eventPos", "m_pos") is Vector3 val26) ? $"({val26.x:F0},{val26.z:F0})" : "?"); args.Context.AddString($"Active raid : {arg} | {num2:F0}s | @ {arg2}"); } else { args.Context.AddString("Active raid : none"); } } } }; <>c.<>9__188_0 = val; obj = (object)val; } new ConsoleCommand("ath_envstate", "world env, TOD, raid, wind", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__188_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { //IL_0098: 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_00a0: 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_0197: 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_020c: 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) List allPlayers = Player.GetAllPlayers(); if (allPlayers == null || allPlayers.Count == 0) { args.Context.AddString("No players found."); } else { args.Context.AddString($"=== Players ({allPlayers.Count}) ==="); List list = new List(); foreach (Player item4 in allPlayers) { string playerName = item4.GetPlayerName(); float health = ((Character)item4).GetHealth(); float maxHealth = ((Character)item4).GetMaxHealth(); float stamina = item4.GetStamina(); float maxStamina = ((Character)item4).GetMaxStamina(); float eitr = item4.GetEitr(); float maxEitr = ((Character)item4).GetMaxEitr(); Vector3 position = ((Component)item4).transform.position; list.Add(position); string arg = ((object)item4.GetCurrentBiome()/*cast due to .constrained prefix*/).ToString(); SEMan sEMan = ((Character)item4).GetSEMan(); List list2 = ((sEMan != null) ? sEMan.GetStatusEffects() : null); string text = ((list2 != null && list2.Count > 0) ? string.Join(", ", list2.Select((StatusEffect e) => (!string.IsNullOrEmpty(e.m_name)) ? e.m_name : ((Object)e).name)) : "none"); args.Context.AddString("--- " + playerName + " ---"); args.Context.AddString($" HP {health:F0}/{maxHealth:F0} | Stamina {stamina:F0}/{maxStamina:F0} | Eitr {eitr:F0}/{maxEitr:F0}"); args.Context.AddString($" Biome: {arg} | Pos: ({position.x:F0},{position.z:F0})"); args.Context.AddString(" Effects: " + text); } if (list.Count > 1) { float num = 0f; for (int num2 = 0; num2 < list.Count; num2++) { for (int num3 = num2 + 1; num3 < list.Count; num3++) { float num4 = Vector3.Distance(list[num2], list[num3]); if (num4 > num) { num = num4; } } } args.Context.AddString($"Party spread: {num:F0}m"); } } }; <>c.<>9__188_1 = val2; obj2 = (object)val2; } new ConsoleCommand("ath_playerstats", "all players stats + party spread", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__188_2; if (obj3 == null) { ConsoleEvent val3 = delegate(ConsoleEventArgs args) { ClearSkiesExpiry = 0f; RainExpiry = 0f; GiantRainExpiry = 0f; WaterWalkExpiry = 0f; SeekEnvExpiry = 0f; DungeonEnvExpiry = 0f; HomeEnvExpiry = 0f; if (GiantExpiry > 0f) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { DeactivateGiant(localPlayer); } else { GiantExpiry = 0f; } } if ((Object)(object)EnvMan.instance != (Object)null) { EnvMan.instance.m_debugEnv = ""; } EnvMan instance = EnvMan.instance; if (instance != null) { instance.ResetDebugWind(); } args.Context.AddString("Weather overrides cleared."); }; <>c.<>9__188_2 = val3; obj3 = (object)val3; } new ConsoleCommand("ath_clearenv", "cancel all Pilgrim weather overrides", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj4 = <>c.<>9__188_3; if (obj4 == null) { ConsoleEvent val4 = delegate(ConsoleEventArgs args) { ActivateSeek(args.Context); }; <>c.<>9__188_3 = val4; obj4 = (object)val4; } new ConsoleCommand("ath_seek", "point wind toward next boss altar", (ConsoleEvent)obj4, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj5 = <>c.<>9__188_4; if (obj5 == null) { ConsoleEvent val5 = delegate(ConsoleEventArgs args) { EnvScheduler scheduler = Scheduler; if ((Object)(object)scheduler == (Object)null) { args.Context.AddString("Scheduler not ready."); } else if (args.Length < 2) { PrintSchedule(args, scheduler); } else { switch (args[1].ToLower()) { case "on": scheduler.Active = true; args.Context.AddString("Scheduler ON"); break; case "off": scheduler.Active = false; args.Context.AddString("Scheduler OFF"); break; case "prob": { if (args.Length >= 3 && float.TryParse(args[2], out var result)) { scheduler.Probability = Mathf.Clamp01(result); args.Context.AddString($"Probability → {scheduler.Probability:P0}"); } break; } case "night": if (args.Length >= 3) { scheduler.NightPool = (from x in args[2].Split(',') select x.Trim()).ToList(); args.Context.AddString("Night pool → " + string.Join(", ", scheduler.NightPool)); } break; case "noon": if (args.Length >= 3) { scheduler.NoonPool = (from x in args[2].Split(',') select x.Trim()).ToList(); args.Context.AddString("Noon pool → " + string.Join(", ", scheduler.NoonPool)); } break; default: PrintSchedule(args, scheduler); break; } } }; <>c.<>9__188_4 = val5; obj5 = (object)val5; } new ConsoleCommand("ath_schedule", "ath_schedule [on|off|prob <0-1>|night |noon ]", (ConsoleEvent)obj5, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj6 = <>c.<>9__188_5; if (obj6 == null) { ConsoleEvent val6 = delegate(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { args.Context.AddString("No local player."); } else { ActivateWaterWalk(localPlayer); args.Context.AddString("Water walk active."); } }; <>c.<>9__188_5 = val6; obj6 = (object)val6; } new ConsoleCommand("ath_waterwalk", "walk on water for 2 minutes", (ConsoleEvent)obj6, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj7 = <>c.<>9__188_6; if (obj7 == null) { ConsoleEvent val7 = delegate(ConsoleEventArgs args) { //IL_0073: 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_00be: 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_00a1: 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_00b8: 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) if ((Object)(object)Scheduler == (Object)null) { args.Context.AddString("Scheduler not ready."); } else { string text = ((args.Length > 1) ? args[1].ToLower() : "n"); BroadcastBird((Vector3)(text switch { "s" => new Vector3(0f, 0f, -1f), "e" => new Vector3(1f, 0f, 0f), "w" => new Vector3(-1f, 0f, 0f), _ => new Vector3(0f, 0f, 1f), })); args.Context.AddString("Bird away (" + text + ")."); } }; <>c.<>9__188_6 = val7; obj7 = (object)val7; } new ConsoleCommand("ath_bird", "ath_bird [n|s|e|w] — send a crow flying in a direction (default: north)", (ConsoleEvent)obj7, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj8 = <>c.<>9__188_7; if (obj8 == null) { ConsoleEvent val8 = delegate(ConsoleEventArgs args) { //IL_0050: 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_0075: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { args.Context.AddString("No player."); } else { args.Context.AddString("=== Trader State ==="); string[] traderLocations = TraderLocations; foreach (string text in traderLocations) { bool flag = HasMetTrader(text); Vector3 result; string text2 = (FindClosestLocation(text, ((Component)localPlayer).transform.position, out result) ? $"{Vector3.Distance(((Component)localPlayer).transform.position, result):F0}m" : "not found"); args.Context.AddString($" {text}: met={flag} dist={text2} pos={result}"); } } }; <>c.<>9__188_7 = val8; obj8 = (object)val8; } new ConsoleCommand("ath_traders", "show trader met status and distances", (ConsoleEvent)obj8, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj9 = <>c.<>9__188_8; if (obj9 == null) { ConsoleEvent val9 = delegate(ConsoleEventArgs args) { args.Context.AddString("=== Campfire Rituals ==="); args.Context.AddString(" " + SeekFood + " (Boar Meat) → Guiding Wind — seek next boss altar"); args.Context.AddString(" Mushroom* (Yellow Mushroom) → Reset forsaken power cooldown"); args.Context.AddString(" " + HomeFood + " (Dandelion) → Guiding Wind — find your bed"); args.Context.AddString(" " + FeatherFood + " (Feathers) → Feather Fall — no fall damage 60s"); args.Context.AddString(" Any Trophy → Dungeon Seeker — find nearest dungeon"); args.Context.AddString($"Global cooldown: {RitualCooldownDuration}s. Hold item in slot 1, look at burning campfire, press 1."); }; <>c.<>9__188_8 = val9; obj9 = (object)val9; } new ConsoleCommand("ath_rituals", "list available campfire rituals", (ConsoleEvent)obj9, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj10 = <>c.<>9__188_9; if (obj10 == null) { ConsoleEvent val10 = delegate(ConsoleEventArgs args) { ShowHintsEnabled = ((args.Args.Length > 1) ? (args.Args[1].ToLower() == "on") : (!ShowHintsEnabled)); args.Context.AddString("Ritual hints: " + (ShowHintsEnabled ? "ON" : "OFF")); }; <>c.<>9__188_9 = val10; obj10 = (object)val10; } new ConsoleCommand("ath_hints", "ath_hints [on|off] — toggle campfire ritual hover hint text", (ConsoleEvent)obj10, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj11 = <>c.<>9__188_10; if (obj11 == null) { ConsoleEvent val11 = delegate(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { string text = ((args.Args.Length > 1) ? args.Args[1].ToLower() : "all"); (string, bool, string, string)[] ritualItemMap = RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { (string, bool, string, string) tuple = ritualItemMap[i]; string item = tuple.Item3; string item2 = tuple.Item4; if (!(text != "all") || !(item != text)) { LearnRitual(localPlayer, item, item2); } } args.Context.AddString((text == "all") ? "All rituals learned." : ("Learned: " + text)); } }; <>c.<>9__188_10 = val11; obj11 = (object)val11; } new ConsoleCommand("ath_learn", "ath_learn [ritual|all] — unlock ritual discovery (for testing)", (ConsoleEvent)obj11, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj12 = <>c.<>9__188_11; if (obj12 == null) { ConsoleEvent val12 = delegate(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { int num = 0; int num2 = 0; HashSet hashSet = new HashSet(); (string, bool, string, string)[] ritualItemMap = RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { (string, bool, string, string) tuple = ritualItemMap[i]; string item = tuple.Item1; bool item2 = tuple.Item2; string item3 = tuple.Item3; RitualItemConfig value; string text = ((!item2) ? item : (Cfg.Rituals.Items.TryGetValue(item3, out value) ? value.Item.TrimEnd('*') : item)); if (hashSet.Add(text)) { if (((Humanoid)localPlayer).GetInventory().AddItem(text, 1, 1, 0, 0L, "", false) != null) { num++; } else { num2++; } } } args.Context.AddString($"Ritual kit: {num} items added, {num2} prefabs not found."); } }; <>c.<>9__188_11 = val12; obj12 = (object)val12; } new ConsoleCommand("ath_ritual_kit", "ath_ritual_kit — spawn one of each ritual ingredient into your inventory", (ConsoleEvent)obj12, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj13 = <>c.<>9__188_12; if (obj13 == null) { ConsoleEvent val13 = delegate(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { string text = ((args.Args.Length > 1) ? args.Args[1].ToLower() : "all"); (string, bool, string, string)[] ritualItemMap = RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { string item = ritualItemMap[i].Item3; if (!(text != "all") || !(item != text)) { localPlayer.m_customData.Remove("ath_known_" + item); } } args.Context.AddString((text == "all") ? "All rituals forgotten." : ("Forgotten: " + text)); } }; <>c.<>9__188_12 = val13; obj13 = (object)val13; } new ConsoleCommand("ath_forget", "ath_forget [ritual|all] — reset ritual discovery", (ConsoleEvent)obj13, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj14 = <>c.<>9__188_13; if (obj14 == null) { ConsoleEvent val14 = delegate(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { List list = new List(); (string, bool, string, string)[] ritualItemMap = RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { string item = ritualItemMap[i].Item3; string key = "ath_uses_" + item; if (localPlayer.m_customData.TryGetValue(key, out var value)) { list.Add(" " + item + ": " + value); } } if (list.Count != 0) { list.Sort(); args.Context.AddString("Ritual usage:"); { foreach (string item5 in list) { args.Context.AddString(item5); } return; } } args.Context.AddString("No rituals performed yet."); } }; <>c.<>9__188_13 = val14; obj14 = (object)val14; } new ConsoleCommand("ath_rituals", "ath_rituals — print ritual usage history for this character", (ConsoleEvent)obj14, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj15 = <>c.<>9__188_14; if (obj15 == null) { ConsoleEvent val15 = delegate(ConsoleEventArgs args) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_01e6: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0638: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_061e: Unknown result type (might be due to invalid IL or missing references) //IL_06fd: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) Player player = Player.m_localPlayer; if (!((Object)(object)player == (Object)null)) { WearNTear val26 = (from c in Physics.OverlapSphere(((Component)player).transform.position, 5f) select ((Component)c).GetComponentInParent() into w where (Object)(object)w != (Object)null && (Object)(object)((Component)w).GetComponent() != (Object)null orderby Vector3.Distance(((Component)w).transform.position, ((Component)player).transform.position) select w).FirstOrDefault(); if ((Object)(object)val26 == (Object)null) { args.Context.AddString("[inspect] No structure within 5m."); } else { HashSet hashSet = FloodFillStructure(val26); SortedDictionary sortedDictionary = new SortedDictionary(); SortedDictionary sortedDictionary2 = new SortedDictionary(); Bounds val27 = default(Bounds); bool flag = false; int num = 0; float num2 = 0f; int num3 = 0; float num4 = float.MaxValue; float num5 = float.MinValue; int num6 = 0; FieldInfo field = typeof(WearNTear).GetField("m_support", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); MethodInfo method = typeof(WearNTear).GetMethod("GetMaxSupport", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int mask = LayerMask.GetMask(new string[1] { "terrain" }); RaycastHit val29 = default(RaycastHit); foreach (WearNTear item6 in hashSet) { string text = ((Object)((Component)item6).gameObject).name.Replace("(Clone)", "").Trim().ToLower(); string key = ((Object)((Component)item6).gameObject).name.Replace("(Clone)", "").Trim(); sortedDictionary.TryGetValue(key, out var value); sortedDictionary[key] = value + 1; Collider[] componentsInChildren = ((Component)item6).GetComponentsInChildren(); foreach (Collider val28 in componentsInChildren) { if (!val28.isTrigger) { Bounds bounds = val28.bounds; if (!flag) { val27 = bounds; flag = true; } else { ((Bounds)(ref val27)).Encapsulate(bounds); } } } float y = ((Component)item6).transform.position.y; float num8 = y; if (Physics.Raycast(new Vector3(((Component)item6).transform.position.x, y + 50f, ((Component)item6).transform.position.z), Vector3.down, ref val29, 200f, mask)) { num8 = ((RaycastHit)(ref val29)).point.y; } if (y <= num8 + 1f) { num++; } if (text.Contains("roof")) { num3++; } if (field != null) { float num9 = (float)(field.GetValue(item6) ?? ((object)0f)); float num10 = ((method != null) ? ((float)(method.Invoke(item6, null) ?? ((object)num9))) : num9); if (num9 < num4) { num4 = num9; } if (num9 > num5) { num5 = num9; } if (num10 > 0f && num9 >= num10 * 0.99f) { num6++; } } ZNetView component = ((Component)item6).GetComponent(); if ((Object)(object)component != (Object)null) { float num11 = num2; ZDO zDO = component.GetZDO(); num2 = num11 + ((((zDO != null) ? new float?(zDO.GetFloat(ZDOVars.s_health, item6.m_health)) : ((float?)null)) / item6.m_health) ?? 1f); } else { num2 += 1f; } Piece component2 = ((Component)item6).GetComponent(); if (component2?.m_resources != null) { Requirement[] resources = component2.m_resources; foreach (Requirement val30 in resources) { if (val30?.m_resItem?.m_itemData?.m_shared?.m_name != null && val30.m_amount > 0) { string key2 = ((Object)((Component)val30.m_resItem).gameObject).name.Replace("(Clone)", "").Trim(); sortedDictionary2.TryGetValue(key2, out var value2); sortedDictionary2[key2] = value2 + val30.m_amount; } } } } int num12 = 0; SortedDictionary sortedDictionary3 = new SortedDictionary(); foreach (WearNTear item7 in hashSet) { Piece component3 = ((Component)item7).GetComponent(); if ((Object)(object)component3 != (Object)null && component3.m_comfort > num12) { num12 = component3.m_comfort; } if ((Object)(object)((Component)item7).GetComponent() != (Object)null || (Object)(object)((Component)item7).GetComponent() != (Object)null) { string key3 = ((Object)((Component)item7).gameObject).name.Replace("(Clone)", "").Trim(); sortedDictionary3.TryGetValue(key3, out var value3); sortedDictionary3[key3] = value3 + 1; } } int count = hashSet.Count; float num13 = (flag ? ((Bounds)(ref val27)).size.y : 0f); float num14 = (flag ? ((Bounds)(ref val27)).size.x : 0f); float num15 = (flag ? ((Bounds)(ref val27)).size.z : 0f); float num16 = Mathf.Sqrt(num14 * num14 + num15 * num15); string text2 = ((num16 < 0.1f) ? "point" : ((num13 / num16 > 1.5f) ? "tower" : ((num13 / num16 > 0.6f) ? "balanced" : "hall"))); float num17 = ((count > 0) ? (num2 / (float)count * 100f) : 0f); int num18 = 0; int num19 = 0; if (flag) { float num20 = 1f; Vector3 center = ((Bounds)(ref val27)).center; ZoneSystem instance = ZoneSystem.instance; float num21 = ((instance != null) ? instance.GetSolidHeight(new Vector3(center.x, center.y, center.z)) : ((Bounds)(ref val27)).min.y) + 1f; float num24 = default(float); bool flag2 = default(bool); for (float num22 = ((Bounds)(ref val27)).min.x; num22 <= ((Bounds)(ref val27)).max.x; num22 += num20) { for (float num23 = ((Bounds)(ref val27)).min.z; num23 <= ((Bounds)(ref val27)).max.z; num23 += num20) { Cover.GetCoverForPoint(new Vector3(num22, num21, num23), ref num24, ref flag2, 0.5f); num19++; if (num24 > 0f) { num18++; } } } } float num25 = ((num19 > 0) ? ((float)num18 / (float)num19 * 100f) : 0f); args.Context.AddString($"[inspect dbg] bounds={((Bounds)(ref val27)).min:F1} to {((Bounds)(ref val27)).max:F1} sampleY={((Bounds)(ref val27)).min.y + 0.5f:F1} sheltered={num18}/{num19}"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine($"── Structure ({count} pieces) ──"); stringBuilder.AppendLine($"Height: {num13:F1}m Footprint: {num14:F0}x{num15:F0}m Shape: {text2}"); stringBuilder.AppendLine($"Ground: {num} Roof: {num3} Shelter: {num25:F0}% Health: {num17:F0}%"); if (field != null) { stringBuilder.AppendLine($"Support: full={num6}/{count} min={num4:F0} max={num5:F0}"); } stringBuilder.AppendLine($"Comfort: {num12}"); string text3 = string.Join(" ", sortedDictionary2.Select((KeyValuePair kv) => $"{kv.Key}×{kv.Value}")); stringBuilder.AppendLine("Materials: " + text3); if (sortedDictionary3.Count > 0) { string text4 = string.Join(" ", sortedDictionary3.Select((KeyValuePair kv) => $"{kv.Key}×{kv.Value}")); stringBuilder.AppendLine("Stations: " + text4); } stringBuilder.AppendLine("────────────────"); foreach (KeyValuePair item8 in sortedDictionary) { stringBuilder.AppendLine($" {item8.Key}: {item8.Value}"); } string text5 = stringBuilder.ToString().TrimEnd(); args.Context.AddString(text5); MessageHudTimerPatch.ExtendNextCenter = true; ((Character)player).Message((MessageType)2, text5, 0, (Sprite)null); ((MonoBehaviour)plugin).StartCoroutine(FlashPieces(hashSet.Select((WearNTear w) => ((Component)w).gameObject).ToList())); } } }; <>c.<>9__188_14 = val15; obj15 = (object)val15; } new ConsoleCommand("ath_inspect", "ath_inspect — identify the nearest structure and report its composition", (ConsoleEvent)obj15, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj16 = <>c.<>9__188_15; if (obj16 == null) { ConsoleEvent val16 = delegate(ConsoleEventArgs args) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("ZNetScene not ready."); } else { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary dictionary) { string pattern = ((args.Length > 1) ? args[1].ToLower() : ""); List list = (from g in dictionary.Values where (Object)(object)g != (Object)null && (string.IsNullOrEmpty(pattern) || ((Object)g).name.ToLower().Contains(pattern)) select ((Object)g).name into n orderby n select n).ToList(); args.Context.AddString($"=== {list.Count} prefabs matching '{pattern}' ==="); { foreach (string item9 in list) { args.Context.AddString(" " + item9); } return; } } args.Context.AddString("Could not read prefab list."); } }; <>c.<>9__188_15 = val16; obj16 = (object)val16; } new ConsoleCommand("ath_prefabs", "ath_prefabs — list registered ZNetScene prefab names matching pattern", (ConsoleEvent)obj16, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj17 = <>c.<>9__188_16; if (obj17 == null) { ConsoleEvent val17 = delegate(ConsoleEventArgs args) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("ZNetScene not ready."); } else { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary dictionary) { Dictionary dictionary2 = new Dictionary(); foreach (GameObject value4 in dictionary.Values) { if (!((Object)(object)value4 == (Object)null)) { Renderer[] componentsInChildren = value4.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val26 in sharedMaterials) { if (!((Object)(object)val26 == (Object)null) && !((Object)(object)val26.shader == (Object)null)) { string name = ((Object)val26.shader).name; if (val26.renderQueue >= 2450 || name.Contains("Transparent") || name.Contains("Alpha") || name.Contains("Particle") || name.Contains("Unlit")) { string key = ((Object)val26).name + " | " + name; if (!dictionary2.ContainsKey(key)) { dictionary2[key] = ((Object)value4).name; } } } } } } } args.Context.AddString($"=== {dictionary2.Count} transparent materials ==="); { foreach (KeyValuePair item10 in dictionary2.OrderBy((KeyValuePair k) => k.Key)) { args.Context.AddString(" " + item10.Key + " (eg: " + item10.Value + ")"); } return; } } args.Context.AddString("Could not read prefab list."); } }; <>c.<>9__188_16 = val17; obj17 = (object)val17; } new ConsoleCommand("ath_transmats", "ath_transmats — list all unique transparent/translucent materials across all prefabs", (ConsoleEvent)obj17, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj18 = <>c.<>9__188_17; if (obj18 == null) { ConsoleEvent val18 = delegate(ConsoleEventArgs args) { if (args.Length < 2) { args.Context.AddString("Usage: ath_mats "); } else { ZNetScene instance = ZNetScene.instance; GameObject val26 = ((instance != null) ? instance.GetPrefab(args[1]) : null); if ((Object)(object)val26 == (Object)null) { args.Context.AddString("Prefab '" + args[1] + "' not found."); } else { Renderer[] componentsInChildren = val26.GetComponentsInChildren(true); foreach (Renderer val27 in componentsInChildren) { Material[] sharedMaterials = val27.sharedMaterials; foreach (Material val28 in sharedMaterials) { if ((Object)(object)val28 != (Object)null) { Terminal context = args.Context; string[] obj26 = new string[6] { " ", ((Object)((Component)val27).gameObject).name, " | ", ((Object)val28).name, " | ", null }; Shader shader = val28.shader; obj26[5] = ((shader != null) ? ((Object)shader).name : null); context.AddString(string.Concat(obj26)); } } } } } }; <>c.<>9__188_17 = val18; obj18 = (object)val18; } new ConsoleCommand("ath_mats", "ath_mats — list all renderers and shader names on a prefab", (ConsoleEvent)obj18, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj19 = <>c.<>9__188_18; if (obj19 == null) { ConsoleEvent val19 = delegate(ConsoleEventArgs args) { //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { args.Context.AddString("Usage: ath_wardmat "); } else { Renderer activeCampfireWardRend = ActiveCampfireWardRend; if ((Object)(object)activeCampfireWardRend == (Object)null) { args.Context.AddString("[wardmat] No active campfire ward."); } else { string text = args[1].ToLower(); ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("ZNetScene not ready."); } else { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (!(typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) is Dictionary dictionary)) { args.Context.AddString("Could not read prefab list."); } else { Material val26 = null; string text2 = null; foreach (GameObject value5 in dictionary.Values) { if (!((Object)(object)value5 == (Object)null)) { Renderer[] componentsInChildren = value5.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val27 in sharedMaterials) { if ((Object)(object)val27 != (Object)null && ((Object)val27).name.ToLower() == text) { val26 = val27; text2 = ((Object)value5).name; break; } } } if ((Object)(object)val26 != (Object)null) { break; } } } if ((Object)(object)val26 == (Object)null) { args.Context.AddString("[wardmat] Material '" + args[1] + "' not found in any prefab."); } else { Material val28 = new Material(val26); val28.SetInt("_Cull", 0); if (val28.HasProperty("_Color")) { val28.color = new Color(0.55f, 0f, 1f, 0.15f); } if (val28.HasProperty("_TintColor")) { val28.SetColor("_TintColor", new Color(0.55f, 0f, 1f, 0.15f)); } activeCampfireWardRend.material = val28; Terminal context = args.Context; string[] obj26 = new string[6] { "[wardmat] Applied '", ((Object)val26).name, "' (shader: ", null, null, null }; Shader shader = val26.shader; obj26[3] = ((shader != null) ? ((Object)shader).name : null); obj26[4] = ") from "; obj26[5] = text2; context.AddString(string.Concat(obj26)); } } } } } }; <>c.<>9__188_18 = val19; obj19 = (object)val19; } new ConsoleCommand("ath_wardmat", "ath_wardmat — hot-swap the active campfire ward sphere material", (ConsoleEvent)obj19, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj20 = <>c.<>9__188_19; if (obj20 == null) { ConsoleEvent val20 = delegate(ConsoleEventArgs args) { //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("ZNetScene not ready."); } else { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Dictionary dictionary = typeof(ZNetScene).GetField("m_namedPrefabs", bindingAttr)?.GetValue(instance) as Dictionary; if (args.Length < 2 || args[1] == "list") { if (dictionary != null) { List list = (from g in dictionary.Values where (Object)(object)g != (Object)null select ((Object)g).name into n where n.StartsWith("vfx_") || n.StartsWith("fx_") || n.StartsWith("sfx_") orderby n select n).ToList(); args.Context.AddString($"=== {list.Count} VFX prefabs ==="); { foreach (string item11 in list) { args.Context.AddString(" " + item11); } return; } } args.Context.AddString("Could not read prefab list."); } else { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { GameObject prefab = instance.GetPrefab(args[1]); if ((Object)(object)prefab == (Object)null) { args.Context.AddString("Prefab '" + args[1] + "' not found."); } else { Object.Instantiate(prefab, ((Component)localPlayer).transform.position, Quaternion.identity); args.Context.AddString("Spawned " + args[1]); } } } } }; <>c.<>9__188_19 = val20; obj20 = (object)val20; } new ConsoleCommand("ath_vfx", "ath_vfx — preview a VFX at your position, or list all vfx_ prefabs", (ConsoleEvent)obj20, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj21 = <>c.<>9__188_20; if (obj21 == null) { ConsoleEvent val21 = delegate(ConsoleEventArgs args) { if (args.Length < 2) { args.Context.AddString("Usage: ath_cleanup_vfx "); } else { string text = args[1]; ZNetScene instance = ZNetScene.instance; ZDOMan instance2 = ZDOMan.instance; if ((Object)(object)instance == (Object)null || instance2 == null) { args.Context.AddString("Not ready."); } else { List list = new List(); int num = 0; int num2 = 0; while (!instance2.GetAllZDOsWithPrefabIterative(text, list, ref num)) { } foreach (ZDO item12 in list) { ZNetView val26 = instance.FindInstance(item12); if ((Object)(object)val26 != (Object)null) { ZNetScene.instance.Destroy(((Component)val26).gameObject); num2++; } else { instance2.DestroyZDO(item12); num2++; } } args.Context.AddString($"Destroyed {num2} instances of '{text}'."); } } }; <>c.<>9__188_20 = val21; obj21 = (object)val21; } new ConsoleCommand("ath_cleanup_vfx", "ath_cleanup_vfx — destroy all ZNet instances of a prefab in the world", (ConsoleEvent)obj21, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj22 = <>c.<>9__188_21; if (obj22 == null) { ConsoleEvent val22 = delegate(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { Vagon val26 = CartUpgrade.FindNearest(localPlayer, 10f); if ((Object)(object)val26 == (Object)null) { args.Context.AddString("No cart within 10m."); } else { CartUpgrade.Upgrade(localPlayer, val26, args); } } }; <>c.<>9__188_21 = val22; obj22 = (object)val22; } new ConsoleCommand("ath_upgradecart", "upgrade nearest cart capacity (or Shift+E on cart)", (ConsoleEvent)obj22, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj23 = <>c.<>9__188_22; if (obj23 == null) { ConsoleEvent val23 = delegate(ConsoleEventArgs args) { EnvMan instance = EnvMan.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("EnvMan not ready."); return; } args.Context.AddString($"=== Environments ({instance.m_environments.Count}) ==="); foreach (EnvSetup environment in instance.m_environments) { args.Context.AddString(" " + environment.m_name); } }; <>c.<>9__188_22 = val23; obj23 = (object)val23; } new ConsoleCommand("ath_envlist", "lists all registered environments", (ConsoleEvent)obj23, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj24 = <>c.<>9__188_23; if (obj24 == null) { ConsoleEvent val24 = delegate(ConsoleEventArgs args) { //IL_0053: 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) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { int num = 0; MonoBehaviour[] array = Object.FindObjectsOfType(); foreach (MonoBehaviour val26 in array) { if (!((Object)(object)val26 == (Object)null) && !(((object)val26).GetType().Name != "RandomFlyingBird") && !(Vector3.Distance(((Component)val26).transform.position, ((Component)localPlayer).transform.position) > 60f)) { num++; args.Context.AddString($"--- Bird {num} ({((Object)((Component)val26).gameObject).name}) ---"); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo[] fields = ((object)val26).GetType().GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { try { args.Context.AddString($" {fieldInfo.FieldType.Name} {fieldInfo.Name} = {fieldInfo.GetValue(val26)}"); } catch { } } Component[] componentsInChildren = ((Component)val26).GetComponentsInChildren(); foreach (Component val27 in componentsInChildren) { PropertyInfo propertyInfo = ((object)val27)?.GetType().GetProperty("parameters"); if (!(propertyInfo == null) && propertyInfo.GetValue(val27) is Array array2) { foreach (object item13 in array2) { PropertyInfo property = item13.GetType().GetProperty("name"); PropertyInfo property2 = item13.GetType().GetProperty("type"); args.Context.AddString($" Anim param: {property?.GetValue(item13)} ({property2?.GetValue(item13)})"); } } } } } if (num == 0) { args.Context.AddString("No birds within 60m."); } } }; <>c.<>9__188_23 = val24; obj24 = (object)val24; } new ConsoleCommand("ath_birdparams", "dump RandomFlyingBird fields and animator params on nearby birds", (ConsoleEvent)obj24, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj25 = <>c.<>9__188_24; if (obj25 == null) { ConsoleEvent val25 = delegate(ConsoleEventArgs args) { EnvMan instance = EnvMan.instance; if ((Object)(object)instance == (Object)null) { args.Context.AddString("EnvMan not ready."); } else { FieldInfo[] fields = typeof(EnvMan).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { string name = fieldInfo.Name; if (name.ToLower().Contains("env") || name.ToLower().Contains("current") || name.ToLower().Contains("debug") || name.ToLower().Contains("time")) { object value = fieldInfo.GetValue(instance); string text = ((value == null) ? "null" : value.ToString()); EnvSetup val26 = (EnvSetup)((value is EnvSetup) ? value : null); if (val26 != null) { text = "EnvSetup(" + val26.m_name + ")"; } args.Context.AddString(fieldInfo.FieldType.Name + " " + name + " = " + text); } } } }; <>c.<>9__188_24 = val25; obj25 = (object)val25; } new ConsoleCommand("ath_envdump", "dumps env-related EnvMan fields", (ConsoleEvent)obj25, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } internal static void SetDebugEnvSafe(string name, string vanillaFallback = "") { if (!((Object)(object)EnvMan.instance == (Object)null)) { bool flag = EnvMan.instance.m_environments?.Exists((EnvSetup e) => e.m_name == name) ?? false; EnvMan.instance.m_debugEnv = (flag ? name : vanillaFallback); } } internal static void ActivateSeek(Terminal? ctx = null, string message = "The wind stirs.", float mult = 1f, string? ingredient = null) { //IL_00d7: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } SeekOverrideTarget = null; BossSeekTarget = null; var (text, text2) = GetNextBoss(localPlayer); if (text == null) { Msg(ctx, "All known bosses defeated. The path is your own."); return; } _seekPendingBossName = text; _seekPendingMessage = message; _seekPendingMult = mult; _seekPendingCtx = ctx; _seekPendingIngredient = ingredient; if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { Vector3 altarPos = Vector3.zero; LocationInstance val = default(LocationInstance); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.FindClosestLocation(text2, ((Component)localPlayer).transform.position, ref val)) { altarPos = val.m_position; } CompleteSeek(altarPos); } else { ZRoutedRpc.instance.InvokeRoutedRPC("Pilgrim_SeekAltarRequest", new object[2] { text2, ((Component)localPlayer).transform.position }); } } internal static void CompleteSeek(Vector3 altarPos) { //IL_0054: 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_00a7: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } string text = _seekPendingBossName ?? "???"; string text2 = _seekPendingMessage ?? "The wind stirs."; float seekPendingMult = _seekPendingMult; Terminal seekPendingCtx = _seekPendingCtx; string seekPendingIngredient = _seekPendingIngredient; _seekPendingBossName = null; _seekPendingCtx = null; _seekPendingIngredient = null; if (!(altarPos != Vector3.zero)) { if (seekPendingIngredient != null) { ((Humanoid)localPlayer).GetInventory().AddItem(seekPendingIngredient, 1, 1, 0, 0L, "", false); RitualCooldownRemaining = 0f; } ((Character)localPlayer).Message((MessageType)2, "Seeking " + text + " — altar not yet revealed.", 0, (Sprite)null); return; } BroadcastSeekTarget("boss", altarPos, SeekEnvDuration * seekPendingMult, "LastLight", "Twilight_Clear"); Vector3 position = ((Component)localPlayer).transform.position; float num = altarPos.x - position.x; float num2 = altarPos.z - position.z; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Atan2(num, num2) * 57.29578f; if (num4 < 0f) { num4 += 360f; } if ((Object)(object)seekPendingCtx != (Object)null) { Msg(seekPendingCtx, "=== Guiding Wind ==="); Msg(seekPendingCtx, "Seek : " + text); Msg(seekPendingCtx, $"Distance : {num3:F0}m ({num3 / 1000f:F1}km)"); Msg(seekPendingCtx, $"Bearing : {num4:F0}°"); Msg(seekPendingCtx, "Follow the wind."); } else { ((Character)localPlayer).Message((MessageType)2, text2.Replace("{boss}", text), 0, (Sprite)null); } } internal static void ActivateCooldownReset(Player player, string message = "The flame accepts your offering. {power} is ready.", float mult = 1f) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = typeof(Player).GetField("m_guardianPower", bindingAttr); FieldInfo field2 = typeof(Player).GetField("m_guardianPowerCooldown", bindingAttr); string powerName = field?.GetValue(player) as string; if (string.IsNullOrEmpty(powerName)) { ((Character)player).Message((MessageType)2, "No forsaken power to reset.", 0, (Sprite)null); return; } if (((field2?.GetValue(player) is float num) ? num : 0f) <= 0f) { ((Character)player).Message((MessageType)2, "Your power is already ready.", 0, (Sprite)null); return; } field2?.SetValue(player, 0f); string newValue = (ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == powerName))?.m_name ?? powerName; ((Character)player).Message((MessageType)2, message.Replace("{power}", newValue), 0, (Sprite)null); RainExpiry = Time.time + RainDuration * mult; BroadcastEnv("Rain", "Rain"); } internal static bool HasMetTrader(string locationName) { string key = "pilgrim_met_" + locationName; return Player.m_localPlayer?.m_customData.ContainsKey(key) ?? false; } internal static void MarkTraderMet(Vector3 traderPos) { //IL_002f: 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_003a: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } string text = ""; float num = float.MaxValue; string[] traderLocations = TraderLocations; foreach (string text2 in traderLocations) { if (FindClosestLocation(text2, traderPos, out var result)) { float num2 = Vector3.Distance(traderPos, result); if (num2 < num) { num = num2; text = text2; } } } if (text != "" && num < 500f) { localPlayer.m_customData["pilgrim_met_" + text] = "1"; Log.LogInfo((object)$"[Trader] Marked met: {text} (dist={num:F0}m)"); } else { Log.LogWarning((object)$"[Trader] MarkTraderMet called but no match: pos={traderPos} bestLoc='{text}' bestDist={num:F0}m"); } } private static bool IsUnexplored(Vector3 pos) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null) { return true; } if ((object)_isExploredMethod == null) { _isExploredMethod = typeof(Minimap).GetMethod("IsExplored", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_isExploredMethod == null) { return true; } if (_isExploredMethod.Invoke(Minimap.instance, new object[1] { pos }) is bool flag) { return !flag; } return false; } private static bool FindNearestUnexplored(string[] locationNames, Vector3 from, out Vector3 bestPos, out string bestName, out float bestDist) { //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_0025: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) bestPos = Vector3.zero; bestName = ""; bestDist = float.MaxValue; foreach (string text in locationNames) { if (FindClosestLocation(text, from, out var result) && IsUnexplored(result)) { float num = Vector3.Distance(from, result); if (num < bestDist) { bestDist = num; bestPos = result; bestName = text; } } } return bestDist < float.MaxValue; } internal static Dictionary> GatherAllLocations(string[] prefabNames) { //IL_005f: 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) Dictionary> dictionary = new Dictionary>(); foreach (string key in prefabNames) { dictionary[key] = new List(); } ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { return dictionary; } HashSet hashSet = new HashSet(prefabNames); foreach (KeyValuePair locationInstance in instance.m_locationInstances) { string prefabName = locationInstance.Value.m_location.m_prefabName; if (hashSet.Contains(prefabName)) { dictionary[prefabName].Add(locationInstance.Value.m_position); } } return dictionary; } internal static void RequestLocations(string[] prefabNames, Vector3 refPos, Action>> callback) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { callback(GatherAllLocations(prefabNames)); return; } _pendingLocationsCallback = callback; ZPackage val = new ZPackage(); val.Write(prefabNames.Length); foreach (string text in prefabNames) { val.Write(text); } ZRoutedRpc.instance.InvokeRoutedRPC("Pilgrim_SeekLocationsRequest", new object[1] { val }); } internal static void ApplySeekTargetLocal(string seekType, Vector3 target, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0027: Unknown result type (might be due to invalid IL or missing references) bool flag = target != Vector3.zero; if (seekType == "boss") { BossSeekTarget = (flag ? new Vector3?(target) : ((Vector3?)null)); SeekEnvExpiry = Time.time + duration; } else { SeekOverrideTarget = (flag ? new Vector3?(target) : ((Vector3?)null)); DungeonEnvExpiry = Time.time + duration; } StatusEffect val = (StatusEffect)(((object)ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == "SE_GuidingWind")) ?? ((object)GuidingWindSE)); if ((Object)(object)val != (Object)null) { val.m_ttl = duration; Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).GetSEMan().AddStatusEffect(val, true, 0, 0f); } } } internal static void BroadcastSeekTarget(string seekType, Vector3 target, float duration, string envName, string envFallback) { //IL_0001: 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: Expected O, but got Unknown //IL_006d: 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_0085: Unknown result type (might be due to invalid IL or missing references) ApplySeekTargetLocal(seekType, target, duration); SetDebugEnvSafe(envName, envFallback); if ((Object)(object)ZNet.instance == (Object)null) { return; } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "Pilgrim_SetEnv", new object[2] { envName, envFallback }); ZPackage val = new ZPackage(); val.Write(seekType); val.Write(target.x); val.Write(target.y); val.Write(target.z); val.Write(duration); ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "Pilgrim_SetSeekTarget", new object[1] { val }); } } private static List? GetAllPins() { if ((Object)(object)Minimap.instance == (Object)null) { return null; } return typeof(Minimap).GetField("m_pins", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(Minimap.instance) as List; } private static bool HasPinNamed(string name) { List allPins = GetAllPins(); if (allPins == null) { return false; } foreach (PinData item in allPins) { if (item.m_save && string.Equals(item.m_name, name, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } internal static void ActivateDungeonSeek(Player player, string trophyPrefab, string message = "The veil parts — something stirs nearby.") { //IL_0014: 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_0024: Unknown result type (might be due to invalid IL or missing references) Vector3 from = ((Component)player).transform.position; RequestLocations(DungeonLocations, from, delegate(Dictionary> results) { //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_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_005e: 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) Vector3 target = Vector3.zero; string arg = ""; float num = float.MaxValue; foreach (KeyValuePair> result in results) { foreach (Vector3 item in result.Value) { if (IsUnexplored(item)) { float num2 = Vector3.Distance(from, item); if (num2 < num) { num = num2; target = item; arg = result.Key; } } } } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { if (num == float.MaxValue) { ((Character)localPlayer).Message((MessageType)2, "The spirits do not answer. No unexplored dungeon found.", 0, (Sprite)null); } else { BroadcastSeekTarget("dungeon", target, DungeonEnvDuration, "VoidWhisper", "ThunderStorm"); ((Character)localPlayer).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[EnvR] Dungeon seek: {arg} at {num:F0}m"); } } }); } internal static void ActivateTraderSeek(Player player) { //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_001d: Unknown result type (might be due to invalid IL or missing references) Vector3 from = ((Component)player).transform.position; RequestLocations(TraderLocations, from, delegate(Dictionary> results) { //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_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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_005b: 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_0090: 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_007a: 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_018f: 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_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_01aa: 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_01c7: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; float num2 = float.MaxValue; Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; string text = ""; string text2 = ""; foreach (KeyValuePair> result in results) { foreach (Vector3 item in result.Value) { float num3 = Vector3.Distance(from, item); if (!HasMetTrader(result.Key)) { if (num3 < num) { num = num3; val = item; text = result.Key; } } else if (num3 < num2) { num2 = num3; val2 = item; text2 = result.Key; } } } Vector3 val3 = ((text != "") ? val : val2); string arg = ((text != "") ? text : text2); float num4 = ((text != "") ? num : num2); Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { if (num4 == float.MaxValue) { ((Character)localPlayer).Message((MessageType)2, "The merchants are beyond reach.", 0, (Sprite)null); } else { ((Character)localPlayer).Message((MessageType)2, Cfg.Rituals.Items.GetValueOrDefault("seek_trader")?.Message ?? "Gold calls to gold...", 0, (Sprite)null); Log.LogInfo((object)$"[EnvR] Trader seek: {arg} at {num4:F0}m"); Vector3 val4 = val3 - from; val4.y = 0f; if (val4 != Vector3.zero && (Object)(object)Scheduler != (Object)null) { BroadcastBird(((Vector3)(ref val4)).normalized); } } } }); } internal static void ActivateKindle(Player player, string message = "The darkness yields.") { //IL_0018: 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) int num = 0; Fireplace[] array = Object.FindObjectsOfType(); foreach (Fireplace val in array) { if (!(Vector3.Distance(((Component)val).transform.position, ((Component)player).transform.position) > 300f)) { ZNetView component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { component.InvokeRPC(ZNetView.Everybody, "RPC_SetFuelAmount", new object[1] { val.m_maxFuel }); num++; } } } string text = ((num > 0) ? message : "No fires nearby to kindle."); ((Character)player).Message((MessageType)2, text, 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] Kindle: lit {num} fires within {300f}m"); } internal static void ActivatePlayerSeek(Player player) { //IL_002e: 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_0088: 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) //IL_009d: 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_00ab: 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) Player val = null; float num = float.MaxValue; foreach (Player allPlayer in Player.GetAllPlayers()) { if (!((Object)(object)allPlayer == (Object)(object)player)) { float num2 = Vector3.Distance(((Component)player).transform.position, ((Component)allPlayer).transform.position); if (num2 < num) { num = num2; val = allPlayer; } } } if ((Object)(object)val == (Object)null) { ((Character)player).Message((MessageType)2, "You are alone...", 0, (Sprite)null); return; } Vector3 val2 = ((Component)val).transform.position - ((Component)player).transform.position; val2.y = 0f; if (val2 != Vector3.zero && (Object)(object)Scheduler != (Object)null) { BroadcastBird(((Vector3)(ref val2)).normalized); } ((Character)player).Message((MessageType)2, "Find fellowship.", 0, (Sprite)null); Log.LogInfo((object)$"[EnvR] Player seek: {val.GetPlayerName()} at {num:F0}m"); } internal static void ActivateHomeSeek(Player player, string message = "The flower carries you home...") { //IL_00a1: 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_00a6: 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_0066: 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_00d3: 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_00ef: 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_01a3: Unknown result type (might be due to invalid IL or missing references) Bed val = null; float num = float.MaxValue; Bed[] array = Object.FindObjectsOfType(); foreach (Bed val2 in array) { object obj = typeof(Bed).GetMethod("IsMine", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val2, null); if (obj is bool && (bool)obj) { float num2 = Vector3.Distance(((Component)player).transform.position, ((Component)val2).transform.position); if (num2 < num) { num = num2; val = val2; } } } Vector3 val3 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); Log.LogInfo((object)$"[EnvR] HomeSeek: bed={((val != null) ? ((Object)val).name : null)} pos={val3} dist={num:F0}m"); if (val3 == Vector3.zero) { ((Character)player).Message((MessageType)2, "No bed found in loaded area — travel closer to home.", 0, (Sprite)null); return; } SeekOverrideTarget = val3; HomeEnvExpiry = Time.time + HomeEnvDuration; BroadcastEnv("DreamWalk", "Meadows_Clouds"); StatusEffect val4 = (StatusEffect)(((object)ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == "SE_GuidingWind")) ?? ((object)GuidingWindSE)); if ((Object)(object)val4 != (Object)null) { ((Character)player).GetSEMan().AddStatusEffect(val4, true, 0, 0f); } float num3 = Vector3.Distance(((Component)player).transform.position, val3); ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[EnvR] Home seek: bed at {val3}, dist {num3:F0}m"); } internal static void ActivateFeatherRitual(Player player, string message = "Light as a feather — fall without fear.", float mult = 1f, bool jumpBoost = false) { ZNetScene instance = ZNetScene.instance; GameObject obj = ((instance != null) ? instance.GetPrefab("CapeFeather") : null); StatusEffect val = ((obj != null) ? obj.GetComponent() : null)?.m_itemData?.m_shared?.m_equipStatusEffect; if ((Object)(object)val == (Object)null) { ((Character)player).Message((MessageType)2, "The feathers scatter in the wind... (feather SE not found)", 0, (Sprite)null); Log.LogWarning((object)"[EnvR] CapeFeather SE not found — check prefab name"); return; } StatusEffect val2 = Object.Instantiate(val); ((Object)val2).name = "SE_PilgrimFeather"; float num = (val2.m_ttl = 60f * mult); val2.m_startMessage = ""; val2.m_stopMessage = ""; ((Character)player).GetSEMan().AddStatusEffect(val2, true, 0, 0f); FeatherRitualExpiry = Time.time + num; if (jumpBoost && !FeatherJumpActive) { ((Character)player).m_jumpForce = ((Character)player).m_jumpForce * 1.5f; FeatherJumpActive = true; } ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } internal static void ActivateClearSkies(Player player, string message = "The clouds part.", float mult = 1f) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) ClearSkiesExpiry = Time.time + ClearSkiesDuration * mult; BroadcastEnv("Clear", "Clear"); float y = ((Component)player).transform.eulerAngles.y; BroadcastWind(y, 0.8f); ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] Clear skies active for {ClearSkiesDuration}s, wind angle {y:F0}°"); } internal static void ActivateWaterWalk(Player player, string message = "The sea grows still beneath your feet.", float mult = 1f) { WaterWalkExpiry = Time.time + WaterWalkDuration * mult; BroadcastWind(0f, 0f); StatusEffect val = (StatusEffect)(((object)ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == "SE_WaterWalk")) ?? ((object)WaterWalkSE)); if ((Object)(object)val != (Object)null) { ((Character)player).GetSEMan().AddStatusEffect(val, true, 0, 0f); } ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } internal static void ActivateGiant(Player player, string message = "The mountain answers. You are vast.", float mult = 1f) { //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) float num = (Cfg.Rituals.Items.GetValueOrDefault("giant")?.Duration ?? 180f) * mult; GiantExpiry = Time.time + num; GiantTargetScale = 3f; ZNetView component = ((Component)player).GetComponent(); if (component != null) { ZDO zDO = component.GetZDO(); if (zDO != null) { zDO.Set("ath_scale", 3f); } } player.m_maxCarryWeight += 300f; StatusEffect val = (StatusEffect)(((object)ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == "SE_Giant")) ?? ((object)GiantSE)); if ((Object)(object)val != (Object)null) { val.m_ttl = num; ((Character)player).GetSEMan().AddStatusEffect(val, true, 0, 0f); } ApplyGiantSpeed(player); SharedData val2 = ((Humanoid)player).m_unarmedWeapon?.m_itemData?.m_shared; if (val2 != null) { _origUnarmedDmg = val2.m_damages; _origUnarmedTier = (short)val2.m_toolTier; _origAttackRange = val2.m_attack.m_attackRange; _origAttackHeight = val2.m_attack.m_attackHeight; _origAttackOffset = val2.m_attack.m_attackOffset; val2.m_damages.m_blunt = 200f; val2.m_damages.m_chop = 200f; val2.m_damages.m_pickaxe = 200f; val2.m_toolTier = 100; val2.m_attack.m_attackRange = _origAttackRange * 3f; val2.m_attack.m_attackHeight = _origAttackHeight * 3f; val2.m_attack.m_attackOffset = _origAttackOffset * 3f; } VdsSwimSuppressor.Suppress(); BroadcastEnv("WarmSnow", "WarmSnow"); ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } internal static void ApplyGiantSpeed(Player player) { if (!GiantSpeedApplied) { ((Character)player).m_walkSpeed = ((Character)player).m_walkSpeed * 1.5f; ((Character)player).m_runSpeed = ((Character)player).m_runSpeed * 2.5f; ((Character)player).m_swimSpeed = ((Character)player).m_swimSpeed * 1.5f; ((Character)player).m_jumpForce = ((Character)player).m_jumpForce * 1.2f; _origAutoPickupRange = player.m_autoPickupRange; player.m_autoPickupRange = 0f; _origSwimDepth = ((Character)player).m_swimDepth; ((Character)player).m_swimDepth = _origSwimDepth * 3f; GiantSpeedApplied = true; ((Character)player).Message((MessageType)1, "Auto-pickup disabled while giant.", 0, (Sprite)null); } } internal static void RemoveGiantSpeed(Player player) { if (GiantSpeedApplied) { ((Character)player).m_walkSpeed = ((Character)player).m_walkSpeed / 1.5f; ((Character)player).m_runSpeed = ((Character)player).m_runSpeed / 2.5f; ((Character)player).m_swimSpeed = ((Character)player).m_swimSpeed / 1.5f; ((Character)player).m_jumpForce = ((Character)player).m_jumpForce / 1.2f; player.m_autoPickupRange = _origAutoPickupRange; ((Character)player).m_swimDepth = _origSwimDepth; GiantSpeedApplied = false; } } internal static void DeactivateGiant(Player player) { //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) GiantExpiry = 0f; GiantTargetScale = 1f; ZNetView component = ((Component)player).GetComponent(); if (component != null) { ZDO zDO = component.GetZDO(); if (zDO != null) { zDO.Set("ath_scale", 1f); } } RemoveGiantSpeed(player); SharedData val = ((Humanoid)player).m_unarmedWeapon?.m_itemData?.m_shared; if (val != null) { val.m_damages = _origUnarmedDmg; val.m_toolTier = _origUnarmedTier; val.m_attack.m_attackRange = _origAttackRange; val.m_attack.m_attackHeight = _origAttackHeight; val.m_attack.m_attackOffset = _origAttackOffset; } player.m_maxCarryWeight = Mathf.Max(player.m_maxCarryWeight - 300f, 300f); SEMan sEMan = ((Character)player).GetSEMan(); SE_Giant? giantSE = GiantSE; sEMan.RemoveStatusEffect((giantSE != null) ? ((StatusEffect)giantSE).NameHash() : 0, false); VdsSwimSuppressor.Restore(); if (EnvMan.instance?.m_debugEnv == "WarmSnow") { EnvMan.instance.m_debugEnv = "Rain"; } GiantRainExpiry = Time.time + 600f; ((Character)player).Message((MessageType)1, "You return to mortal scale.", 0, (Sprite)null); } internal static void ActivateBurden(Player player, string message, float mult = 1f) { float num = (Cfg.Rituals.Items.GetValueOrDefault("burden")?.Duration ?? 60f) * mult; BurdenExpiry = Time.time + num; player.m_maxCarryWeight += BurdenCarryBonus; StatusEffect val = (StatusEffect)(((object)ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == "SE_Burden")) ?? ((object)BurdenSE)); if ((Object)(object)val != (Object)null) { val.m_ttl = num; ((Character)player).GetSEMan().AddStatusEffect(val, true, 0, 0f); } ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } internal static void DeactivateBurden(Player player) { BurdenExpiry = 0f; player.m_maxCarryWeight = Mathf.Max(player.m_maxCarryWeight - BurdenCarryBonus, 300f); SEMan sEMan = ((Character)player).GetSEMan(); SE_Burden? burdenSE = BurdenSE; sEMan.RemoveStatusEffect((burdenSE != null) ? ((StatusEffect)burdenSE).NameHash() : 0, false); ((Character)player).Message((MessageType)1, "The burden lifts.", 0, (Sprite)null); } internal static void RegisterShieldBubbleRPC() { ZRoutedRpc.instance.Register("Pilgrim_ShieldBubble", (Action)delegate(long sender, float duration) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ApplyShieldBubble(localPlayer, duration); } }); } internal static void ApplyShieldBubble(Player player, float duration) { SE_Shield val = ShieldBubbleSE; if ((Object)(object)val == (Object)null) { ObjectDB instance = ObjectDB.instance; object obj; if (instance == null) { obj = null; } else { GameObject itemPrefab = instance.GetItemPrefab("StaffShield"); obj = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); } ItemDrop val2 = (ItemDrop)obj; StatusEffect obj2 = val2?.m_itemData?.m_shared?.m_attackStatusEffect; val = (SE_Shield)(((object)((obj2 is SE_Shield) ? obj2 : null)) ?? ((object)/*isinst with value type is only supported in some contexts*/)); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[Pilgrim] SE_Shield not found on StaffShield"); return; } val.m_ttlPerItemLevel = 0; ShieldBubbleSE = val; } ((StatusEffect)val).m_ttl = duration; val.m_absorbDamage = 100f; ((Character)player).GetSEMan().AddStatusEffect((StatusEffect)(object)val, true, 0, 0f); ShieldBubbleExpiry = Time.time + duration; TweakPlayerBubble(player); } private static void TweakPlayerBubble(Player player) { ((MonoBehaviour)plugin).StartCoroutine(TweakPlayerBubbleRoutine(player)); } private static IEnumerator FlashPieces(List pieces) { WaitForSeconds wait = new WaitForSeconds(0.4f); for (int pulse = 0; pulse < 5; pulse++) { List<(Renderer r, Color[] cols)> saved = new List<(Renderer, Color[])>(); foreach (GameObject piece in pieces) { if ((Object)(object)piece == (Object)null) { continue; } Renderer[] componentsInChildren = piece.GetComponentsInChildren(); foreach (Renderer val in componentsInChildren) { Color[] array = (Color[])(object)new Color[val.materials.Length]; for (int j = 0; j < val.materials.Length; j++) { array[j] = val.materials[j].color; } saved.Add((val, array)); Material[] materials = val.materials; foreach (Material val2 in materials) { if (val2.HasProperty("_Color")) { val2.color = new Color(0f, 1f, 0.2f, val2.color.a); } } } } yield return wait; foreach (var (val3, array2) in saved) { if ((Object)(object)val3 == (Object)null) { continue; } for (int l = 0; l < val3.materials.Length && l < array2.Length; l++) { if (val3.materials[l].HasProperty("_Color")) { val3.materials[l].color = array2[l]; } } } yield return wait; } } private static IEnumerator TweakPlayerBubbleRoutine(Player player) { yield return null; bool flag = false; Renderer[] componentsInChildren = ((Component)player).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!(((Object)((Component)val).gameObject).name != "Sphere")) { flag = true; ((Component)val).transform.localScale = new Vector3(3f, 3f, 3f); val.material.color = new Color(0.6f, 0f, 1f, 0.15f); ManualLogSource log = Log; Shader shader = val.material.shader; log.LogInfo((object)$"[Pilgrim] Bubble tweaked: shader={((shader != null) ? ((Object)shader).name : null)} color={val.material.color}"); } } if (!flag) { Log.LogWarning((object)"[Pilgrim] TweakPlayerBubble: Sphere not found on player"); } } internal static void ActivateWard(Player player, Fireplace fp, string message, float mult = 1f) { //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_006a: 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) float num = (Cfg.Rituals.Items.GetValueOrDefault("ward_bubble")?.Duration ?? 120f) * mult; ApplyShieldBubble(player, num); ZNet instance = ZNet.instance; foreach (ZNetPeer item in ((instance != null) ? instance.GetPeers() : null) ?? new List()) { Vector3 refPos = item.GetRefPos(); if (Vector3.Distance(((Component)fp).transform.position, refPos) <= 20f) { ZRoutedRpc.instance.InvokeRoutedRPC(item.m_uid, "Pilgrim_ShieldBubble", new object[1] { num }); } } ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] Shield bubble applied to nearby players for {num}s"); } internal static void TickWard() { } private static Material? GetWardSphereMat() { if ((Object)(object)s_wardSphereMat != (Object)null) { return s_wardSphereMat; } ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab("fx_guardstone_activate") : null); if ((Object)(object)val == (Object)null) { return null; } Renderer[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { Material sharedMaterial = val2.sharedMaterial; if (((sharedMaterial != null) ? ((Object)sharedMaterial).name : null) == "shield") { s_wardSphereMat = val2.sharedMaterial; break; } } return s_wardSphereMat; } internal static void RegisterCampfireWardRPC() { ZRoutedRpc.instance.Register("Pilgrim_CampfireWard", (Action)delegate(long sender, Vector3 pos, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) SpawnCampfireWard(pos, duration, null); }); ZRoutedRpc.instance.Register("Pilgrim_CampfireWardCancel", (Action)delegate { CampfireWardExpiry = 0f; if ((Object)(object)ActiveCampfireWard != (Object)null) { Object.Destroy((Object)(object)ActiveCampfireWard); ActiveCampfireWard = null; } }); } internal static void ActivateCampfireWard(Player player, Fireplace fp, string message, float duration) { //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_000c: 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_0098: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)fp).transform.position; SpawnCampfireWard(position, duration, player); ZNet instance = ZNet.instance; foreach (ZNetPeer item in ((instance != null) ? instance.GetPeers() : null) ?? new List()) { ZRoutedRpc.instance.InvokeRoutedRPC(item.m_uid, "Pilgrim_CampfireWard", new object[2] { position, duration }); } ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] Campfire ward raised at {position} for {duration}s"); } internal static void SpawnCampfireWard(Vector3 pos, float duration, Player? countdownFor) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0018: 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) //IL_006a: 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_0084: 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: Expected O, but got Unknown //IL_00ce: 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_0136: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Pilgrim_CampfireWard"); val.SetActive(false); val.transform.position = pos; SphereCollider obj = val.AddComponent(); obj.radius = 10f; ((Collider)obj).isTrigger = true; val.AddComponent().m_type = (Type)32; GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)obj2.GetComponent()); obj2.transform.SetParent(val.transform); obj2.transform.localPosition = Vector3.zero; obj2.transform.localScale = Vector3.one * 20f; Renderer component = obj2.GetComponent(); Material wardSphereMat = GetWardSphereMat(); if ((Object)(object)wardSphereMat != (Object)null) { Material val2 = new Material(wardSphereMat); val2.SetInt("_Cull", 0); val2.color = new Color(0.55f, 0f, 1f, 0.1f); if (val2.HasProperty("_TintColor")) { val2.SetColor("_TintColor", new Color(0.55f, 0f, 1f, 0.15f)); } ManualLogSource log = Log; Shader shader = val2.shader; log.LogInfo((object)string.Format("[Pilgrim] Ward sphere: shader={0} cull={1} color={2}", (shader != null) ? ((Object)shader).name : null, val2.GetInt("_Cull"), val2.color)); component.material = val2; } else { Log.LogWarning((object)"[Pilgrim] fireplace_ash_glowing_purple not found on MountainKit_brazier_purple"); } component.shadowCastingMode = (ShadowCastingMode)0; component.receiveShadows = false; val.SetActive(true); Object.Destroy((Object)(object)val, duration); if ((Object)(object)countdownFor != (Object)null) { ActiveCampfireWard = val; ActiveCampfireWardRend = component; CampfireWardExpiry = Time.time + duration; Log.LogInfo((object)$"[Pilgrim] CampfireWardExpiry set to {CampfireWardExpiry:F1} (now={Time.time:F1})"); ((MonoBehaviour)plugin).StartCoroutine(WardCountdown(countdownFor, duration)); } } private static IEnumerator WardCountdown(Player player, float duration) { for (float remaining = duration; remaining > 0f; remaining -= 1f) { if (CampfireWardExpiry <= 0f) { yield break; } ((Character)player).Message((MessageType)1, $"Ward: {Mathf.CeilToInt(remaining)}s", 0, (Sprite)null); yield return (object)new WaitForSeconds(1f); } ((Character)player).Message((MessageType)1, "The ward fades.", 0, (Sprite)null); } internal static HashSet FloodFillStructure(WearNTear seed, float stepRadius = 5f) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); Queue queue = new Queue(); hashSet.Add(seed); queue.Enqueue(seed); while (queue.Count > 0) { Collider[] array = Physics.OverlapSphere(((Component)queue.Dequeue()).transform.position, stepRadius); for (int i = 0; i < array.Length; i++) { WearNTear componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)((Component)componentInParent).GetComponent() != (Object)null && hashSet.Add(componentInParent)) { queue.Enqueue(componentInParent); } } } return hashSet; } internal static bool ActivateHunt(HuntDef def, Player player, Fireplace fp, string message) { //IL_005a: 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_0065: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00fa: Invalid comparison between Unknown and I4 //IL_017c: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: 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_0211: 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_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0325: 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_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) WorldGenerator instance = WorldGenerator.instance; if (instance == null) { ((Character)player).Message((MessageType)2, "The wilds do not answer.", 0, (Sprite)null); return false; } float num = Cfg.Rituals.Items.GetValueOrDefault(def.Key)?.Distance ?? def.DefaultDistance; if (num <= 0f) { num = def.DefaultDistance; } Vector3 position = ((Component)player).transform.position; Vector3 zero = Vector3.zero; bool flag = false; float num2 = Random.value * MathF.PI * 2f; for (int i = 0; i < 24; i++) { float num3 = num2 + (float)i / 24f * MathF.PI * 2f; float num4 = num + Random.Range(-20f, 20f); float num5 = position.x + Mathf.Cos(num3) * num4; float num6 = position.z + Mathf.Sin(num3) * num4; if (instance.GetBiome(num5, num6, 0.02f, false) != def.Biome) { continue; } float num7; if ((int)def.Biome == 256) { num7 = 1f; } else { ZoneSystem instance2 = ZoneSystem.instance; num7 = ((instance2 != null) ? instance2.GetSolidHeight(new Vector3(num5, 0f, num6)) : position.y); if (num7 < -100f || num7 > 2000f) { num7 = position.y; } num7 += 0.5f; } ((Vector3)(ref zero))..ctor(num5, num7, num6); flag = true; break; } if (!flag) { ((Character)player).Message((MessageType)2, $"You are too far from the {def.Biome}.", 0, (Sprite)null); return false; } ZNetScene instance3 = ZNetScene.instance; GameObject val = ((instance3 != null) ? instance3.GetPrefab(def.Prefab) : null); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)("[Pilgrim] Hunt prefab not found: " + def.Prefab)); return false; } GameObject val2 = Object.Instantiate(val, zero, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; val2.transform.localScale = Vector3.one * def.Scale; ZNetView component = val2.GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.GetZDO().Set("scale", def.Scale); component.GetZDO().Set(ZDOVars.s_level, 2, false); } Character component2 = val2.GetComponent(); if (component2 != null) { component2.SetLevel(2); } AnimalAI component3 = val2.GetComponent(); if ((Object)(object)component3 != (Object)null) { typeof(AnimalAI).GetMethod("SetAlerted", bindingAttr)?.Invoke(component3, new object[1] { false }); typeof(AnimalAI).GetField("m_fleeTarget", bindingAttr)?.SetValue(component3, null); } BaseAI component4 = val2.GetComponent(); if ((Object)(object)component4 != (Object)null) { typeof(BaseAI).GetMethod("SetAlerted", bindingAttr)?.Invoke(component4, new object[1] { false }); } Vector3 direction = zero - position; direction.y = 0f; ((Vector3)(ref direction)).Normalize(); BroadcastBird(direction); float num8 = Vector3.Distance(position, zero); ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] Hunt {def.Prefab} spawned at {zero} ({num8:F0}m, scale {def.Scale:F1}x)"); return true; } internal static void ActivateRepair(Player player, Fireplace fp, string message) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) WearNTear val = (from c in Physics.OverlapSphere(((Component)player).transform.position, 5f) select ((Component)c).GetComponentInParent() into w where (Object)(object)w != (Object)null && (Object)(object)((Component)w).GetComponent() != (Object)null orderby Vector3.Distance(((Component)w).transform.position, ((Component)player).transform.position) select w).FirstOrDefault(); if ((Object)(object)val == (Object)null) { ((Character)player).Message((MessageType)2, "No structure nearby to mend.", 0, (Sprite)null); return; } HashSet hashSet = FloodFillStructure(val); int num = 0; foreach (WearNTear item in hashSet) { ZNetView component = ((Component)item).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner() && item.Repair()) { num++; } } ((Character)player).Message((MessageType)2, $"{message} ({num}/{hashSet.Count} pieces)", 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] Repair ritual: seed={((Object)((Component)val).gameObject).name} flood={hashSet.Count} repaired={num}"); } internal static void RegisterStructureRitualRPC() { ZRoutedRpc.instance.Register("Pilgrim_StructureRitual", (Action)delegate(long sender, ZPackage pkg) { //IL_0015: 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) int num = pkg.ReadInt(); List list = new List(num); for (int i = 0; i < num; i++) { list.Add(pkg.ReadVector3()); } float duration = pkg.ReadSingle(); int seHash = pkg.ReadInt(); float fireDamage = pkg.ReadSingle(); string vfxPrefabName = pkg.ReadString(); float vfxScale = pkg.ReadSingle(); string vfxPrefabName2 = pkg.ReadString(); Color tint = default(Color); ((Color)(ref tint))..ctor(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); float lightMult = pkg.ReadSingle(); float smokeInterval = pkg.ReadSingle(); ((MonoBehaviour)plugin).StartCoroutine(StructureRitualTick(list, duration, seHash, fireDamage, vfxPrefabName, null, null, null, vfxScale, tint, lightMult, vfxPrefabName2, smokeInterval)); }); } internal static List GetStructureFootprint(IEnumerable seeds, out HashSet visited, float spacing = 2f) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_025a: 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) //IL_02bf: 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_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: 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_014b: 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) visited = new HashSet(); Queue queue = new Queue(); foreach (WearNTear seed in seeds) { if (visited.Add(seed)) { queue.Enqueue(seed); } } while (queue.Count > 0) { WearNTear val = queue.Dequeue(); Piece component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { continue; } List list = new List(); component.GetSnapPoints(list); foreach (Transform item in list) { Vector3 position = item.position; Collider[] array = Physics.OverlapSphere(position, 0.85f); for (int i = 0; i < array.Length; i++) { WearNTear componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent == (Object)(object)val || !visited.Add(componentInParent)) { continue; } Piece component2 = ((Component)componentInParent).GetComponent(); if ((Object)(object)component2 == (Object)null || (Object)(object)((Component)componentInParent).GetComponent() != (Object)null || (Object)(object)((Component)componentInParent).GetComponent() != (Object)null) { visited.Remove(componentInParent); continue; } List list2 = new List(); component2.GetSnapPoints(list2); bool flag = false; float num = float.MaxValue; foreach (Transform item2 in list2) { float num2 = Vector3.Distance(item2.position, position); if (num2 < num) { num = num2; } if (num2 <= 0.35f) { flag = true; break; } } if (flag) { Log.LogInfo((object)$"[Pilgrim] BFS: '{((Object)((Component)val).gameObject).name}'→'{((Object)((Component)componentInParent).gameObject).name}' snap dist={num:F3}m at {position:F1}"); queue.Enqueue(componentInParent); } else { visited.Remove(componentInParent); } } } } List list3 = new List(); foreach (WearNTear item3 in visited) { Collider componentInChildren = ((Component)item3).GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { list3.Add(((Component)item3).transform.position); continue; } Bounds bounds = componentInChildren.bounds; float x = ((Bounds)(ref bounds)).size.x; float z = ((Bounds)(ref bounds)).size.z; if (x <= spacing && z <= spacing) { list3.Add(((Bounds)(ref bounds)).center); continue; } Vector3 val2; float num3; if (x >= z) { val2 = Vector3.right; num3 = x; } else { val2 = Vector3.forward; num3 = z; } int num4 = Mathf.Max(1, Mathf.RoundToInt(num3 / spacing)); Vector3 val3 = ((Bounds)(ref bounds)).center - val2 * (num3 * 0.5f); for (int j = 0; j <= num4; j++) { list3.Add(val3 + val2 * ((float)j / (float)num4 * num3)); } } return list3; } internal static List SpawnPrefabsAt(IEnumerable positions, string prefabName, float scaleMin = 1f, float scaleMax = 1f) { //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0074: Unknown result type (might be due to invalid IL or missing references) List list = new List(); ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(prefabName) : null); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)("[Pilgrim] Prefab not found: " + prefabName)); return list; } bool flag = scaleMax > scaleMin; foreach (Vector3 position in positions) { GameObject val2 = Object.Instantiate(val, position, Quaternion.identity); if (flag) { val2.transform.localScale = Vector3.one * Random.Range(scaleMin, scaleMax); } list.Add(val2); } return list; } internal static GameObject? GetSmokePrefab() { if ((Object)(object)s_smokePrefab != (Object)null) { return s_smokePrefab; } s_smokePrefab = Object.FindObjectOfType()?.m_smokePrefab; if ((Object)(object)s_smokePrefab != (Object)null) { Log.LogInfo((object)("[Pilgrim] Smoke prefab: " + ((Object)s_smokePrefab).name)); } else { Log.LogWarning((object)"[Pilgrim] No SmokeSpawner found in scene — no smoke"); } return s_smokePrefab; } internal static void TintVfx(GameObject go, Color tint, float lightMult) { //IL_0000: 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_0024: 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) if (tint.a > 0f) { ParticleSystem[] componentsInChildren = go.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { MainModule main = componentsInChildren[i].main; ((MainModule)(ref main)).startColor = new MinMaxGradient(tint); } } if (lightMult != 1f) { Light[] componentsInChildren2 = go.GetComponentsInChildren(true); foreach (Light obj in componentsInChildren2) { obj.intensity *= lightMult; } } } internal static Vector3 ProjectToTerrain(Vector3 pos) { //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_0026: 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_0031: 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_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_0063: 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_0072: 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_008e: 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) int mask = LayerMask.GetMask(new string[1] { "terrain" }); RaycastHit val = default(RaycastHit); if (Physics.Raycast(new Vector3(pos.x, pos.y + 10f, pos.z), Vector3.down, ref val, 25f, mask)) { return new Vector3(pos.x, ((RaycastHit)(ref val)).point.y + 0.05f, pos.z); } ZoneSystem instance = ZoneSystem.instance; float num = ((instance != null) ? instance.GetSolidHeight(pos) : pos.y); return new Vector3(pos.x, num + 0.05f, pos.z); } internal static void RefillTrench(IEnumerable positions, float radius) { //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_0010: 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_0030: 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_0083: Expected O, but got Unknown foreach (Vector3 position in positions) { TerrainComp val = TerrainComp.FindTerrainCompiler(position); if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("Pilgrim_TrenchFill"); val2.transform.position = position; TerrainOp val3 = val2.AddComponent(); val3.m_settings.m_level = true; val3.m_settings.m_levelRadius = radius * 1.15f; val3.m_settings.m_levelOffset = 0f; val3.m_settings.m_square = false; val.ApplyOperation(val3); Object.Destroy((Object)val2); } } Log.LogInfo((object)$"[Pilgrim] RefillTrench: restored {positions.Count()} points"); } internal static void DigTrench(IEnumerable positions, float radius = 0.5f, float depth = 0.25f) { //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_0013: 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_0030: 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_00ae: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) foreach (Vector3 position in positions) { TerrainComp val = TerrainComp.FindTerrainCompiler(position); if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("Pilgrim_TrenchOp"); val2.transform.position = position; TerrainOp val3 = val2.AddComponent(); val3.m_settings.m_level = true; val3.m_settings.m_levelRadius = radius; val3.m_settings.m_levelOffset = 0f - depth; val3.m_settings.m_square = false; val3.m_settings.m_smooth = true; val3.m_settings.m_smoothRadius = radius * 1.5f; val3.m_settings.m_smoothPower = 2f; val.ApplyOperation(val3); Object.Destroy((Object)val2); Log.LogInfo((object)$"[Pilgrim] DigTrench at {position:F1} r={radius} d={depth}"); } } } internal static void ActivateStructureRitual(Player player, Fireplace fp, string? netPrefabName, string? vfxPrefabName, int seHash, float fireDamage, float duration, string logLabel, string message, string? indicator = null, float spacing = 2f, bool projectToTerrain = false, float xzNoise = 0f, float netScaleMin = 1f, float netScaleMax = 1f, float vfxScale = 1f, bool digTrench = false, float trenchRadius = 0.5f, float trenchDepth = 0.25f, Color tint = default(Color), float lightMult = 1f, string? vfxPrefabName2 = null, int netPrefabMax = 0, float smokeInterval = 0f, bool consumeStructure = false, bool refillTrench = false) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_00f0: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_026e: 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_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //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_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: 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_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Expected O, but got Unknown //IL_0375: 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_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) Vector3 fpPos = ((Component)fp).transform.position; List list = (from c in Physics.OverlapSphere(fpPos, 2f) select ((Component)c).GetComponentInParent()).Where(delegate(WearNTear w) { //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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 if ((Object)(object)w != (Object)null && (Object)(object)((Component)w).gameObject != (Object)(object)((Component)fp).gameObject && Vector3.Distance(((Component)w).transform.position, fpPos) <= 2f) { Piece component2 = ((Component)w).GetComponent(); if (component2 == null) { return true; } return (int)component2.m_category != 1; } return false; }).Distinct().ToList(); if (list.Count == 0) { ((Character)player).Message((MessageType)2, "No structure found at the fire.", 0, (Sprite)null); return; } Log.LogInfo((object)$"[Pilgrim] {logLabel}: fire at {((Component)fp).transform.position:F1}, {list.Count} seed(s):"); foreach (WearNTear item in list) { Log.LogInfo((object)$"[Pilgrim] seed '{((Object)((Component)item).gameObject).name}' at {((Component)item).transform.position:F1} dist={Vector3.Distance(((Component)item).transform.position, ((Component)fp).transform.position):F2}m"); } HashSet visited; List structureFootprint = GetStructureFootprint(list, out visited, spacing); Log.LogInfo((object)$"[Pilgrim] {logLabel}: {visited.Count} pieces → {structureFootprint.Count} footprint points"); foreach (WearNTear item2 in visited) { Log.LogInfo((object)$"[Pilgrim] piece '{((Object)((Component)item2).gameObject).name}' at {((Component)item2).transform.position:F1}"); } if (consumeStructure) { foreach (WearNTear item3 in visited) { ZNetView component = ((Component)item3).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { ZNetScene.instance.Destroy(((Component)item3).gameObject); } else { Object.Destroy((Object)(object)((Component)item3).gameObject); } } Log.LogInfo((object)$"[Pilgrim] {logLabel}: consumed {visited.Count} structure pieces"); } for (int num = 0; num < structureFootprint.Count; num++) { Vector3 val = structureFootprint[num]; if (xzNoise > 0f) { val += new Vector3(Random.Range(0f - xzNoise, xzNoise), 0f, Random.Range(0f - xzNoise, xzNoise)); } if (projectToTerrain) { val = ProjectToTerrain(val); } structureFootprint[num] = val; } if (digTrench) { DigTrench(structureFootprint, trenchRadius, trenchDepth); } ((MonoBehaviour)plugin).StartCoroutine(FlashPieces(visited.Select((WearNTear w) => ((Component)w).gameObject).ToList())); IEnumerable positions = structureFootprint; if (netPrefabMax > 0 && structureFootprint.Count > netPrefabMax) { List list2 = new List(netPrefabMax); for (int num2 = 0; num2 < netPrefabMax; num2++) { list2.Add(structureFootprint[num2 * structureFootprint.Count / netPrefabMax]); } positions = list2; } List list3 = ((netPrefabName != null) ? SpawnPrefabsAt(positions, netPrefabName, netScaleMin, netScaleMax) : null); if (list3 != null && (tint.a > 0f || lightMult != 1f)) { foreach (GameObject item4 in list3) { TintVfx(item4, tint, lightMult); } } ZPackage val2 = new ZPackage(); val2.Write(structureFootprint.Count); foreach (Vector3 item5 in structureFootprint) { val2.Write(item5); } val2.Write(duration); val2.Write(seHash); val2.Write(fireDamage); val2.Write(vfxPrefabName ?? ""); val2.Write(vfxScale); val2.Write(vfxPrefabName2 ?? ""); val2.Write(tint.r); val2.Write(tint.g); val2.Write(tint.b); val2.Write(tint.a); val2.Write(lightMult); val2.Write(smokeInterval); ZNet instance = ZNet.instance; foreach (ZNetPeer item6 in ((instance != null) ? instance.GetPeers() : null) ?? new List()) { ZRoutedRpc.instance.InvokeRoutedRPC(item6.m_uid, "Pilgrim_StructureRitual", new object[1] { val2 }); } ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] {logLabel} raised at {((Component)fp).transform.position} ({structureFootprint.Count} points)"); List vfxSnapshot = new List(); List netSnapshot = list3; List posSnapshot = (refillTrench ? new List(structureFootprint) : null); float snapTrenchRad = trenchRadius; ActiveStructureRitualCleanup = delegate { foreach (GameObject item7 in vfxSnapshot) { if ((Object)(object)item7 != (Object)null) { Object.Destroy((Object)(object)item7); } } if (netSnapshot != null) { foreach (GameObject item8 in netSnapshot) { if (!((Object)(object)item8 == (Object)null)) { ZNetView component2 = item8.GetComponent(); if ((Object)(object)component2 != (Object)null && component2.IsValid()) { ZNetScene.instance.Destroy(item8); } else { Object.Destroy((Object)(object)item8); } } } } if (posSnapshot != null) { RefillTrench(posSnapshot, snapTrenchRad); } }; ActiveStructureRitual = ((MonoBehaviour)plugin).StartCoroutine(StructureRitualTick(structureFootprint, duration, seHash, fireDamage, vfxPrefabName, list3, indicator, vfxSnapshot, vfxScale, tint, lightMult, vfxPrefabName2, smokeInterval)); } private static IEnumerator StructureRitualTick(List positions, float duration, int seHash, float fireDamage, string? vfxPrefabName = null, List? netSpawned = null, string? indicator = null, List? vfxSnapshot = null, float vfxScale = 1f, Color tint = default(Color), float lightMult = 1f, string? vfxPrefabName2 = null, float smokeInterval = 0f) { //IL_0043: 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) WaitForSeconds tick = new WaitForSeconds(0.5f); float elapsed = 0f; float remaining = duration; int charMask = LayerMask.GetMask(new string[3] { "character", "character_net", "character_ghost" }); List list = vfxSnapshot ?? new List(); bool flag = tint.a > 0f || lightMult != 1f; if (!string.IsNullOrEmpty(vfxPrefabName)) { ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(vfxPrefabName) : null); if ((Object)(object)val != (Object)null) { foreach (Vector3 position in positions) { GameObject val2 = Object.Instantiate(val, position, Quaternion.identity); if (vfxScale != 1f) { val2.transform.localScale = Vector3.one * Random.Range(vfxScale, vfxScale * 1.35f); } if (flag) { TintVfx(val2, tint, lightMult); } list.Add(val2); } } } if (!string.IsNullOrEmpty(vfxPrefabName2)) { ZNetScene instance2 = ZNetScene.instance; GameObject val3 = ((instance2 != null) ? instance2.GetPrefab(vfxPrefabName2) : null); if ((Object)(object)val3 != (Object)null) { foreach (Vector3 position2 in positions) { list.Add(Object.Instantiate(val3, position2, Quaternion.identity)); } } } if (indicator != null) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, $"{indicator}: {(int)remaining}s", 0, (Sprite)null); } } float nextSmoke = ((smokeInterval > 0f) ? smokeInterval : float.MaxValue); while (elapsed < duration) { yield return tick; elapsed += 0.5f; remaining -= 0.5f; if (indicator != null && (int)remaining % 10 == 0 && remaining > 0f) { Player localPlayer2 = Player.m_localPlayer; if (localPlayer2 != null) { ((Character)localPlayer2).Message((MessageType)1, $"{indicator}: {(int)remaining}s", 0, (Sprite)null); } } nextSmoke -= 0.5f; if (nextSmoke <= 0f) { nextSmoke = smokeInterval; GameObject smokePrefab = GetSmokePrefab(); if ((Object)(object)smokePrefab != (Object)null) { foreach (Vector3 position3 in positions) { Object.Instantiate(smokePrefab, position3 + Vector3.up * 0.3f, Quaternion.identity); } } } if (seHash == 0 && fireDamage <= 0f) { continue; } foreach (Vector3 position4 in positions) { Collider[] array = Physics.OverlapSphere(position4, 1.5f, charMask); for (int i = 0; i < array.Length; i++) { Character componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { continue; } ZNetView component = ((Component)componentInParent).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner()) { if (seHash != 0) { componentInParent.GetSEMan().AddStatusEffect(seHash, true, 0, 0f); } if (fireDamage > 0f) { HitData val4 = new HitData(); val4.m_damage.m_fire = fireDamage; val4.m_point = ((Component)componentInParent).transform.position; val4.m_dir = Vector3.zero; componentInParent.ApplyDamage(val4, true, true, (DamageModifier)0); } } } } } ActiveStructureRitualCleanup?.Invoke(); ActiveStructureRitual = null; ActiveStructureRitualCleanup = null; } internal static void ActivateTarMoat(Player player, Fireplace fp, string message) { //IL_006f: 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) float duration = Cfg.Rituals.Items.GetValueOrDefault("tar_moat")?.Duration ?? 60f; ActivateStructureRitual(player, fp, "TarLiquid", null, SEMan.s_statusEffectTared, 0f, duration, "Tar moat", message, "Tar moat", 100f, projectToTerrain: true, 0f, 0.25f, 0.35f, 1f, digTrench: true, 1f, 2f, default(Color), 1f, null, 5, 0f, consumeStructure: true, refillTrench: true); } internal static void ActivateFireWall(Player player, Fireplace fp, string message) { //IL_006f: 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) float duration = Cfg.Rituals.Items.GetValueOrDefault("fire_wall")?.Duration ?? 60f; ActivateStructureRitual(player, fp, "vfx_Burning", null, SEMan.s_statusEffectBurning, 5f, duration, "Fire wall", message, "Fire wall", 2.5f, projectToTerrain: true, 0.3f, 1.5f, 2f, 1f, digTrench: false, 0.5f, 0.25f, default(Color), 0.2f, null, 0, 1.5f, consumeStructure: true); } internal static void RegisterClearMistRPC() { ZRoutedRpc.instance.Register("Pilgrim_ClearMist", (Action)delegate(long _, Vector3 pos, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) SpawnDemisterLocal(pos, duration); }); } internal static void SpawnDemisterLocal(Vector3 pos, float duration) { //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_0010: 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_0035: 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_0051: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Pilgrim_Demister"); val.transform.position = pos; ParticleSystemForceField val2 = val.AddComponent(); val2.shape = (ParticleSystemForceFieldShape)0; val2.endRange = 5f; val2.gravity = new MinMaxCurve(-2f); val.AddComponent().m_forceField = val2; Object.Destroy((Object)val, duration); ((MonoBehaviour)plugin).StartCoroutine(ExpandDemister(val2, 5f, 100f, 20f)); Log.LogInfo((object)$"[Pilgrim] Demister spawned at {pos} radius {100f}m for {duration}s"); } private static IEnumerator ExpandDemister(ParticleSystemForceField ff, float from, float to, float expandTime) { float elapsed = 0f; while (elapsed < expandTime && (Object)(object)ff != (Object)null) { elapsed += Time.deltaTime; ff.endRange = Mathf.Lerp(from, to, elapsed / expandTime); yield return null; } if ((Object)(object)ff != (Object)null) { ff.endRange = to; } } internal static void ActivateClearMist(Player player, Fireplace fp, string message, float mult = 1f) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) float num = (Cfg.Rituals.Items.GetValueOrDefault("clear_mist")?.Duration ?? 120f) * mult; Vector3 position = ((Component)fp).transform.position; SpawnDemisterLocal(position, num); ZNet instance = ZNet.instance; foreach (ZNetPeer item in ((instance != null) ? instance.GetPeers() : null) ?? new List()) { ZRoutedRpc.instance.InvokeRoutedRPC(item.m_uid, "Pilgrim_ClearMist", new object[2] { position, num }); } ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] Clear mist ritual at {position} for {num}s"); } internal static void ActivateCorpseSeek(Player player, string message) { //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_004a: Unknown result type (might be due to invalid IL or missing references) long playerID = Game.instance.GetPlayerProfile().GetPlayerID(); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { Vector3 pos = FindNewestTombstonePos(playerID); CompleteCorpseSeek(player, pos, message); return; } _pendingCorpseCallback = delegate(Vector3 pos2) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) CompleteCorpseSeek(player, pos2, message); }; ZRoutedRpc.instance.InvokeRoutedRPC("Pilgrim_CorpseSeekRequest", new object[1] { playerID }); } internal static void ActivateTreeStand(Player player, Fireplace fp, string seedPrefab, string message) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Vector3 fpPos = ((Component)fp).transform.position; List list = (from c in Physics.OverlapSphere(fpPos, 2f) select ((Component)c).GetComponentInParent()).Where(delegate(WearNTear w) { //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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 if ((Object)(object)w != (Object)null && (Object)(object)((Component)w).gameObject != (Object)(object)((Component)fp).gameObject && Vector3.Distance(((Component)w).transform.position, fpPos) <= 2f) { Piece component = ((Component)w).GetComponent(); if (component == null) { return true; } return (int)component.m_category != 1; } return false; }).Distinct().ToList(); if (list.Count == 0) { ((Character)player).Message((MessageType)2, "Build a structure around this fire first.", 0, (Sprite)null); return; } GetStructureFootprint(list, out HashSet visited); List source = visited.Select((WearNTear w) => ProjectToTerrain(((Component)w).transform.position)).ToList(); List source2 = (from w in visited select ((Component)w).GetComponent() into zv where (Object)(object)zv != (Object)null && zv.IsValid() select zv.GetZDO().m_uid).ToList(); string value = string.Join("|", source2.Select((ZDOID id) => $"{((ZDOID)(ref id)).UserID}:{((ZDOID)(ref id)).ID}")); player.m_customData["ath_tree_stand_pieces"] = value; string text = string.Join("|", source.Select((Vector3 p) => $"{p.x:F2},{p.y:F2},{p.z:F2}")); player.m_customData["ath_tree_stand_positions"] = seedPrefab + ";" + text; ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } internal static void ActivateRockStand(Player player, Fireplace fp, string message) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Vector3 fpPos = ((Component)fp).transform.position; List list = (from c in Physics.OverlapSphere(fpPos, 2f) select ((Component)c).GetComponentInParent()).Where(delegate(WearNTear w) { //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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 if ((Object)(object)w != (Object)null && (Object)(object)((Component)w).gameObject != (Object)(object)((Component)fp).gameObject && Vector3.Distance(((Component)w).transform.position, fpPos) <= 2f) { Piece component = ((Component)w).GetComponent(); if (component == null) { return true; } return (int)component.m_category != 1; } return false; }).Distinct().ToList(); if (list.Count == 0) { ((Character)player).Message((MessageType)2, "Build a structure around this fire first.", 0, (Sprite)null); return; } GetStructureFootprint(list, out HashSet visited); List source = visited.Select((WearNTear w) => ProjectToTerrain(((Component)w).transform.position)).ToList(); List source2 = (from w in visited select ((Component)w).GetComponent() into zv where (Object)(object)zv != (Object)null && zv.IsValid() select zv.GetZDO().m_uid).ToList(); string value = string.Join("|", source2.Select((ZDOID id) => $"{((ZDOID)(ref id)).UserID}:{((ZDOID)(ref id)).ID}")); player.m_customData["ath_rock_stand_pieces"] = value; string value2 = string.Join("|", source.Select((Vector3 p) => $"{p.x:F2},{p.y:F2},{p.z:F2}")); player.m_customData["ath_rock_stand_positions"] = value2; ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); } private static Dictionary? GetAllZDOs() { if (_zdoManObjects != null) { return _zdoManObjects; } _zdoManObjects = typeof(ZDOMan).GetField("m_objectsByID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(ZDOMan.instance) as Dictionary; return _zdoManObjects; } internal static Vector3 FindNewestTombstonePos(long playerID) { //IL_0009: 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_0089: Unknown result type (might be due to invalid IL or missing references) Dictionary allZDOs = GetAllZDOs(); if (allZDOs == null) { return Vector3.zero; } int stableHashCode = StringExtensionMethods.GetStableHashCode("Player_tombstone"); ZDO val = null; long num = 0L; foreach (ZDO value in allZDOs.Values) { if (value.GetPrefab() == stableHashCode && value.GetLong(ZDOVars.s_owner, 0L) == playerID) { long num2 = value.GetLong(ZDOVars.s_timeOfDeath, 0L); if (num2 > num) { num = num2; val = value; } } } if (val == null) { return Vector3.zero; } return val.GetPosition(); } internal static void CompleteCorpseSeek(Player player, Vector3 pos, string message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) if (pos == Vector3.zero) { ((Character)player).Message((MessageType)2, "No grave found in this world.", 0, (Sprite)null); return; } ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); ((Character)player).TeleportTo(pos + Vector3.up, ((Component)player).transform.rotation, true); ((MonoBehaviour)plugin).StartCoroutine(CorpseGraceRoutine(player)); } private static IEnumerator CorpseGraceRoutine(Player player) { float duration = 30f; ((Character)player).m_aiSkipTarget = true; ((Character)player).Message((MessageType)1, $"Grace: {(int)duration}s", 0, (Sprite)null); while (duration > 0f) { yield return (object)new WaitForSeconds(1f); duration -= 1f; if ((Object)(object)player == (Object)null) { yield break; } if ((int)duration % 10 == 0 && duration > 0f) { ((Character)player).Message((MessageType)1, $"Grace: {(int)duration}s", 0, (Sprite)null); } } if ((Object)(object)player != (Object)null) { ((Character)player).m_aiSkipTarget = false; } } internal static void ActivateLegendaryWeapon(LegendaryDef def, Player player, string message, float mult = 1f) { //IL_0069: 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_007b: 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_02a8: 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_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: 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) if (FlamingSwordExpiry > 0f) { DeactivateLegendaryWeapon(player, immediate: true); } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; object? obj = typeof(Humanoid).GetField("m_rightItem", bindingAttr)?.GetValue(player); ItemData val = (ItemData)((obj is ItemData) ? obj : null); if (val?.m_shared?.m_skillType != (SkillType?)def.SkillType) { ((Character)player).Message((MessageType)2, "You must hold a " + def.SkillLabel + " to answer the call.", 0, (Sprite)null); return; } if (val != null) { ((Humanoid)player).UnequipItem(val, true); ((Humanoid)player).GetInventory().RemoveItem(val); } ItemData val2 = ((Humanoid)player).GetInventory().AddItem(def.Prefab, 1, 1, 0, 0L, "", false); if (val2 == null) { ((Character)player).Message((MessageType)2, "No room in your pack.", 0, (Sprite)null); if (val != null) { ((Humanoid)player).GetInventory().AddItem(val); ((Humanoid)player).EquipItem(val, true); } return; } _activeLegendaryDef = def; _legendaryOrigItem = val; _legendaryActiveItem = val2; _legendaryActivePrefab = def.Prefab; ((Humanoid)player).EquipItem(val2, true); SpawnSmokePuff(player); float num = (Cfg.Rituals.Items.GetValueOrDefault(def.Key)?.Duration ?? 60f) * mult; FlamingSwordExpiry = Time.time + num; long num2 = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + (long)num; player.m_customData["ath_legendary_key"] = def.Key; player.m_customData["ath_legendary_expiry"] = num2.ToString(); Dictionary customData = player.m_customData; object obj2; if (val == null) { obj2 = null; } else { GameObject dropPrefab = val.m_dropPrefab; obj2 = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); } if (obj2 == null) { obj2 = ""; } customData["ath_legendary_orig"] = (string)obj2; player.m_customData["ath_legendary_orig_level"] = (val?.m_quality ?? 1).ToString(); StatusEffect val3 = (StatusEffect)(((object)ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == "SE_LegendaryWeapon")) ?? ((object)LegendarySE)); if ((Object)(object)val3 != (Object)null) { val3.m_ttl = num; ((Character)player).GetSEMan().AddStatusEffect(val3, true, 0, 0f); } TryPlayEmote(player, "cheer"); Transform val4 = ((Component)player).transform.Find("Visual/Armature/Hips/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm/RightHand/RightHandMiddle1") ?? ((Component)player).transform; Vector3 strike = val4.position + Vector3.up * 0.5f + ((Component)player).transform.forward * 0.5f; Scheduler?.RunDelayed(0.5f, delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) BroadcastVfx(strike, "fx_chainlightning_hit"); }); ((Character)player).Message((MessageType)2, message, 0, (Sprite)null); Log.LogInfo((object)$"[Pilgrim] Legendary: swapped in {def.Prefab} for {num}s"); } private static void TryPlayEmote(Player player, string emoteName) { try { if (!((Object)(object)player != (Object)(object)Player.m_localPlayer)) { player.StartEmote(emoteName, true); } } catch (Exception ex) { Log.LogWarning((object)("[Pilgrim] TryPlayEmote failed: " + ex.Message)); } } internal static void DeactivateLegendaryWeapon(Player player, bool immediate = false) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) FlamingSwordExpiry = 0f; player.m_customData.Remove("ath_legendary_key"); player.m_customData.Remove("ath_legendary_expiry"); player.m_customData.Remove("ath_legendary_orig"); player.m_customData.Remove("ath_legendary_orig_level"); BroadcastVfx(((Component)player).transform.position, "fx_fireskeleton_nova", 0f); if (immediate) { FinishLegendarySwapBack(player); return; } Scheduler?.RunDelayed(0.5f, delegate { FinishLegendarySwapBack(player); }); } private static void FinishLegendarySwapBack(Player player) { if (_legendaryActivePrefab != null) { Inventory inventory = ((Humanoid)player).GetInventory(); ItemData val = ((IEnumerable)inventory.GetAllItems()).FirstOrDefault((Func)delegate(ItemData i) { GameObject dropPrefab = i.m_dropPrefab; return ((dropPrefab != null) ? ((Object)dropPrefab).name : null) == _legendaryActivePrefab; }); if (val != null) { ((Humanoid)player).UnequipItem(val, true); inventory.RemoveItem(val); } if (_legendaryOrigItem != null) { inventory.AddItem(_legendaryOrigItem); ((Humanoid)player).EquipItem(_legendaryOrigItem, true); } _legendaryActiveItem = null; _legendaryActivePrefab = null; _legendaryOrigItem = null; } SpawnSmokePuff(player); SEMan sEMan = ((Character)player).GetSEMan(); SE_LegendaryWeapon? legendarySE = LegendarySE; sEMan.RemoveStatusEffect((legendarySE != null) ? ((StatusEffect)legendarySE).NameHash() : 0, false); string text = Cfg.Rituals.Items.GetValueOrDefault(_activeLegendaryDef.Key)?.Message ?? _activeLegendaryDef.DefaultDeactivateMsg; ((Character)player).Message((MessageType)1, text, 0, (Sprite)null); } internal static bool HasAnyActiveRitual(Player player) { if (GiantExpiry > 0f) { return true; } if (BurdenExpiry > 0f) { return true; } if (FlamingSwordExpiry > 0f) { return true; } if (FeatherRitualExpiry > 0f) { return true; } if (WaterWalkExpiry > 0f) { return true; } if (ClearSkiesExpiry > 0f) { return true; } if (RainExpiry > 0f) { return true; } if (SeekEnvExpiry > 0f) { return true; } if (DungeonEnvExpiry > 0f) { return true; } if (HomeEnvExpiry > 0f) { return true; } if (ShieldBubbleExpiry > 0f && Time.time < ShieldBubbleExpiry) { return true; } if ((Object)(object)ActiveCampfireWard != (Object)null) { return true; } if (ActiveStructureRitual != null) { return true; } SEMan sEMan = ((Character)player).GetSEMan(); SE_GuidingWind? guidingWindSE = GuidingWindSE; if (sEMan.HaveStatusEffect((guidingWindSE != null) ? ((StatusEffect)guidingWindSE).NameHash() : 0)) { return true; } return false; } internal static void RelinquishAll(Player player) { if (!HasAnyActiveRitual(player)) { return; } if (GiantExpiry > 0f) { DeactivateGiant(player); } if (BurdenExpiry > 0f) { DeactivateBurden(player); } if (FlamingSwordExpiry > 0f) { DeactivateLegendaryWeapon(player, immediate: true); } if (ShieldBubbleExpiry > 0f) { ShieldBubbleExpiry = 0f; SE_Shield? shieldBubbleSE = ShieldBubbleSE; int num = ((shieldBubbleSE != null) ? ((StatusEffect)shieldBubbleSE).NameHash() : 0); if (num != 0) { ((Character)player).GetSEMan().RemoveStatusEffect(num, false); } StatusEffect val = ((Character)player).GetSEMan().GetStatusEffects()?.Find((StatusEffect s) => s is SE_Shield); if ((Object)(object)val != (Object)null) { ((Character)player).GetSEMan().RemoveStatusEffect(val.NameHash(), false); } } if ((Object)(object)ActiveCampfireWard != (Object)null) { Object.Destroy((Object)(object)ActiveCampfireWard); ActiveCampfireWard = null; CampfireWardExpiry = 0f; ZNet instance = ZNet.instance; foreach (ZNetPeer item in ((instance != null) ? instance.GetPeers() : null) ?? new List()) { ZRoutedRpc.instance.InvokeRoutedRPC(item.m_uid, "Pilgrim_CampfireWardCancel", Array.Empty()); } } if (FeatherRitualExpiry > 0f) { FeatherRitualExpiry = 0f; ((Character)player).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_PilgrimFeather"), false); if (FeatherJumpActive) { ((Character)player).m_jumpForce = ((Character)player).m_jumpForce / 1.5f; FeatherJumpActive = false; } } if (WaterWalkExpiry > 0f) { WaterWalkExpiry = 0f; SEMan sEMan = ((Character)player).GetSEMan(); SE_WaterWalk? waterWalkSE = WaterWalkSE; sEMan.RemoveStatusEffect((waterWalkSE != null) ? ((StatusEffect)waterWalkSE).NameHash() : 0, false); BroadcastWind(0f, -1f); } int num2; if (!(SeekEnvExpiry > 0f)) { SEMan sEMan2 = ((Character)player).GetSEMan(); SE_GuidingWind? guidingWindSE = GuidingWindSE; num2 = (sEMan2.HaveStatusEffect((guidingWindSE != null) ? ((StatusEffect)guidingWindSE).NameHash() : 0) ? 1 : 0); if (num2 == 0) { goto IL_0243; } } else { num2 = 1; } SeekEnvExpiry = 0f; BossSeekTarget = null; SEMan sEMan3 = ((Character)player).GetSEMan(); SE_GuidingWind? guidingWindSE2 = GuidingWindSE; sEMan3.RemoveStatusEffect((guidingWindSE2 != null) ? ((StatusEffect)guidingWindSE2).NameHash() : 0, false); goto IL_0243; IL_0243: if (ActiveStructureRitual != null) { ((MonoBehaviour)plugin).StopCoroutine(ActiveStructureRitual); ActiveStructureRitualCleanup?.Invoke(); ActiveStructureRitual = null; ActiveStructureRitualCleanup = null; } bool num3 = num2 != 0 || ClearSkiesExpiry > 0f || RainExpiry > 0f || DungeonEnvExpiry > 0f || HomeEnvExpiry > 0f; ClearSkiesExpiry = 0f; RainExpiry = 0f; DungeonEnvExpiry = 0f; HomeEnvExpiry = 0f; if (num3) { BroadcastEnv(""); } ((Character)player).Message((MessageType)2, "The ritual ends.", 0, (Sprite)null); } private static void SpawnSmokePuff(Player player) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) BroadcastVfx((((Component)player).transform.Find("Visual/Armature/Hips/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm/RightHand/RightHandMiddle1") ?? ((Component)player).transform).position, "vfx_Smoked", 3f); } internal static void GrantTrophyPower(Player player, string trophyPrefab, Terminal? ctx = null, Vector3? vfxPos = null) { //IL_007e: 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) if (TrophyToPower.TryGetValue(trophyPrefab, out string value)) { player.SetGuardianPower(value); trophyPrefab.Replace("Trophy", "").Replace("TheElder", "The Elder").Replace("DragonQueen", "Moder") .Replace("GoblinKing", "Yagluth") .Replace("SeekerQueen", "The Queen"); SpawnTrophyVFX((Vector3)(((??)vfxPos) ?? ((Component)player).transform.position)); ((Character)player).Message((MessageType)1, "You claim the power of the forsaken.", 0, (Sprite)null); } } internal static void SpawnRitualVFX(Vector3 firePos, Vector3 playerPos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0007: 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_0027: 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_0039: 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_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) Vector3 val = firePos - playerPos; val.y = 0f; if (val == Vector3.zero) { val = Vector3.forward; } BroadcastVfx(firePos, "fx_batteringram_fire", 4f, Quaternion.LookRotation(((Vector3)(ref val)).normalized)); BroadcastVfx(firePos, "fx_fireskeleton_nova", 0f); } private static void SpawnTrophyVFX(Vector3 pos) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[4] { Cfg.Trophies.Vfx, "vfx_guardianpower_activate", "vfx_offering", "vfx_lootspawn" }; foreach (string text in array) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)((instance != null) ? instance.GetPrefab(text) : null) != (Object)null) { BroadcastVfx(pos, text, 0f); Log.LogInfo((object)("[Pilgrim] Trophy VFX: " + text)); break; } } } internal static (string? boss, string? prefab) GetNextBoss(Player? player = null) { ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { return (boss: null, prefab: null); } int num = 0; while (num < BossChain.Length) { bool num2; if (!((Object)(object)player != (Object)null) || num >= BossTrophies.Length) { if (num >= BossKeys.Length) { goto IL_005e; } num2 = instance.GetGlobalKey(BossKeys[num]); } else { num2 = player.GetTrophies().Contains(BossTrophies[num]); } if (num2) { num++; continue; } goto IL_005e; IL_005e: return (boss: BossChain[num].boss, prefab: BossChain[num].prefab); } return (boss: null, prefab: null); } internal static bool FindClosestLocation(string prefabName, Vector3 refPos, out Vector3 result) { //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_001e: 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_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) result = Vector3.zero; ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { return false; } LocationInstance val = default(LocationInstance); if (instance.FindClosestLocation(prefabName, refPos, ref val)) { result = val.m_position; return true; } return false; } private static void PrintSchedule(ConsoleEventArgs args, EnvScheduler s) { args.Context.AddString(string.Format("Scheduler : {0} | prob {1:P0}", s.Active ? "ON" : "OFF", s.Probability)); args.Context.AddString("Night pool: " + string.Join(", ", s.NightPool)); args.Context.AddString("Noon pool : " + string.Join(", ", s.NoonPool)); } private static string? GetEnvSetupName(EnvMan em, string fieldName) { object? obj = typeof(EnvMan).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(em); EnvSetup val = (EnvSetup)((obj is EnvSetup) ? obj : null); if (val != null && !string.IsNullOrEmpty(val.m_name)) { return val.m_name; } return null; } private static object? AnyField(object obj, params string[] names) { Type type = obj.GetType(); foreach (string name in names) { object obj2 = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj); if (obj2 != null) { return obj2; } } return null; } private static void Msg(Terminal? ctx, string text) { if ((Object)(object)ctx != (Object)null) { ctx.AddString(text); return; } MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)1, text, 0, (Sprite)null, false); } } private static void Announce(string text) { if ((Object)(object)Chat.instance != (Object)null) { Chat.instance.SendText((Type)1, text); } } internal static float GetTod() { EnvMan instance = EnvMan.instance; if ((Object)(object)instance != (Object)null) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo? field = typeof(EnvMan).GetField("m_debugTimeOfDay", bindingAttr); FieldInfo field2 = typeof(EnvMan).GetField("m_debugTime", bindingAttr); object obj = field?.GetValue(instance); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { obj = field2?.GetValue(instance); if (obj is float) { return (float)obj; } } } if ((Object)(object)ZNet.instance == (Object)null) { return 0f; } return (float)(ZNet.instance.GetTimeSeconds() % 1800.0 / 1800.0); } private static string GetTodLabel(float t) { if (t < 0.25f) { return "night"; } if (t < 0.32f) { return "dawn"; } if (t < 0.5f) { return "morning"; } if (t < 0.68f) { return "afternoon"; } if (t < 0.75f) { return "dusk"; } return "night"; } internal static Random GetRng() { return Rng; } } [HarmonyPatch(typeof(Character), "ApplyDamage")] internal class FeatherFallPatch { private static void Prefix(Character __instance, ref HitData hit) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !(Time.time > Plugin.FeatherRitualExpiry) && (int)hit.m_hitType == 3) { hit.m_damage.m_damage = 0f; } } } [HarmonyPatch(typeof(Character), "IsOnGround")] internal class WaterWalkGroundPatch { private static bool Prefix(Character __instance, ref bool __result) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (Plugin.WaterWalkExpiry <= 0f || Time.time >= Plugin.WaterWalkExpiry) { return true; } WaterVolume val = null; float waterLevel = Floating.GetWaterLevel(((Component)__instance).transform.position, ref val); if (((Component)__instance).transform.position.y <= waterLevel + 0.02f) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(Character), "IsSwimming")] internal class WaterWalkSwimPatch { private static bool Prefix(ref bool __result) { if (Plugin.WaterWalkExpiry > 0f && Time.time < Plugin.WaterWalkExpiry) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(Character), "UpdateWater")] internal class WaterWalkUpdatePatch { private static bool Prefix() { if (Plugin.WaterWalkExpiry > 0f) { return !(Time.time < Plugin.WaterWalkExpiry); } return true; } } [HarmonyPatch(typeof(Character), "Jump")] internal class WaterWalkJumpPatch { private static void Postfix(Character __instance) { //IL_002f: 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_0085: 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) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || Plugin.WaterWalkExpiry <= 0f || Time.time >= Plugin.WaterWalkExpiry) { return; } WaterVolume val = null; float waterLevel = Floating.GetWaterLevel(((Component)__instance).transform.position, ref val); if (!(((Component)__instance).transform.position.y > waterLevel + 0.5f)) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic; object? obj = typeof(Character).GetField("m_body", bindingAttr)?.GetValue(__instance); Rigidbody val2 = (Rigidbody)((obj is Rigidbody) ? obj : null); if (val2 != null) { val2.AddForce(Vector3.up * 4f, (ForceMode)2); } } } } [HarmonyPatch(typeof(Fireplace), "GetHoverText")] internal class FireplaceHoverPatch { private static readonly Dictionary _structureTag = new Dictionary(); private static readonly Dictionary _structureNext = new Dictionary(); private static void Postfix(Fireplace __instance, ref string __result) { //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsBurning()) { return; } string goName = ((Object)((Component)__instance).gameObject).name.ToLower().Replace("(clone)", "").Trim(); if (!Array.Exists(Plugin.CampfirePrefabs, (string p) => goName.StartsWith(p)) || !Plugin.Cfg.Rituals.Enabled) { return; } Player player = Player.m_localPlayer; Dictionary items = Plugin.Cfg.Rituals.Items; Dictionary> dictionary = new Dictionary>(); List list = new List(); HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); HashSet hashSet3 = new HashSet(); (string, bool, string, string)[] ritualItemMap = Plugin.RitualItemMap; for (int num = 0; num < ritualItemMap.Length; num++) { (string, bool, string, string) tuple = ritualItemMap[num]; string item = tuple.Item3; string item2 = tuple.Item4; if (!hashSet3.Add(item) || !items.TryGetValue(item, out RitualItemConfig value) || !value.Enabled) { continue; } hashSet.Add(item); if ((Object)(object)player != (Object)null && Plugin.IsRitualKnown(player, item)) { hashSet2.Add(item); } if (KnownAndEnabled(item)) { string text = (string.IsNullOrEmpty(value.Domain) ? "Blessings" : value.Domain); if (!dictionary.ContainsKey(text)) { dictionary[text] = new List<(string, string, string)>(); list.Add(text); } dictionary[text].Add((item, item2, value.HoverText)); } } if (list.Count == 0) { return; } int count = list.Count; Plugin.HintPage %= count; string text2 = list[Plugin.HintPage]; List<(string, string, string)> list2 = dictionary[text2]; int num2 = 0; int num3 = 0; HashSet hashSet4 = new HashSet(); ritualItemMap = Plugin.RitualItemMap; for (int num = 0; num < ritualItemMap.Length; num++) { string item3 = ritualItemMap[num].Item3; if (hashSet4.Add(item3) && items.TryGetValue(item3, out RitualItemConfig value2) && value2.Enabled && !((string.IsNullOrEmpty(value2.Domain) ? "Blessings" : value2.Domain) != text2)) { num3++; if ((Object)(object)player != (Object)null && Plugin.IsRitualKnown(player, item3)) { num2++; } } } string text3 = ((Plugin.RitualCooldownRemaining > 0f) ? $" ({Plugin.RitualCooldownRemaining:F0}s)" : ""); string text4 = string.Format(" {1}/{2}", (hashSet2.Count < hashSet.Count) ? "yellow" : "green", hashSet2.Count, hashSet.Count); float num4 = Plugin.PrimeMultiplier(__instance); string text5 = (Plugin.IsPrimed(__instance) ? $" [×{num4:F2}]" : ""); __result = __result + "\n── Offerings" + text4 + text3 + " ──" + text5; if (Plugin.ShowHintsEnabled) { string text6 = ""; if (text2 == "Weapons") { float num5 = (((Object)(object)player != (Object)null) ? Plugin.RitualMultiplier(__instance, player) : 1f); foreach (var item8 in list2) { string item4 = item8.Item1; if (items.TryGetValue(item4, out RitualItemConfig value3) && value3.Duration > 0f) { int num6 = Mathf.RoundToInt(value3.Duration * num5); text6 = $" (~{num6}s)"; break; } } } string text7 = string.Format(" {1}/{2}", (num2 < num3) ? "yellow" : "green", num2, num3); __result = __result + "\n" + text2 + text7 + text6 + ""; foreach (var item9 in list2) { string item5 = item9.Item1; string item6 = item9.Item2; string item7 = item9.Item3; string value4 = ""; if (Plugin.StructureRitualKeys.Contains(item5)) { int id = ((Object)__instance).GetInstanceID(); float time = Time.time; _structureTag.TryGetValue(id, out value4); if (!_structureNext.TryGetValue(id, out var value5) || time >= value5) { _structureNext[id] = time + 2f; Vector3 fpPos = ((Component)__instance).transform.position; GameObject fpGo = ((Component)__instance).gameObject; List allWnt = (from c in Physics.OverlapSphere(fpPos, 60f) select ((Component)c).GetComponentInParent() into w where (Object)(object)w != (Object)null && (Object)(object)((Component)w).gameObject != (Object)(object)fpGo select w).Distinct().ToList(); allWnt.Select((WearNTear w) => ((Component)w).transform.position).ToArray(); Vector3[][] snapLists = allWnt.Select(delegate(WearNTear w) { List list3 = new List(); Piece component = ((Component)w).GetComponent(); if (component != null) { component.GetSnapPoints(list3); } return list3.Select((Transform s) => s.position).ToArray(); }).ToArray(); List seedIdxs = (from x in allWnt.Select((WearNTear w, int i) => (w: w, i: i)) where Vector3.Distance(((Component)x.w).transform.position, fpPos) <= 2f select x.i).ToList(); Task.Run(delegate { //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_00b2: 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) string value6; if (seedIdxs.Count == 0) { value6 = "\n ↳ build a structure around this fire"; } else { HashSet hashSet5 = new HashSet(); Queue queue = new Queue(seedIdxs); foreach (int item10 in seedIdxs) { hashSet5.Add(item10); } while (queue.Count > 0) { int num7 = queue.Dequeue(); Vector3[] array = snapLists[num7]; foreach (Vector3 val in array) { for (int j = 0; j < allWnt.Count; j++) { if (!hashSet5.Contains(j)) { bool flag = false; Vector3[] array2 = snapLists[j]; for (int k = 0; k < array2.Length; k++) { if (Vector3.Distance(array2[k], val) <= 0.35f) { flag = true; break; } } if (flag) { hashSet5.Add(j); queue.Enqueue(j); } } } } } value6 = $"\n ↳ {hashSet5.Count} pieces connected — will be consumed"; } _structureTag[id] = value6; }); } } __result = __result + "\n " + item6 + " — " + item7 + value4; } string text8 = ((count > 1) ? $" ({Plugin.HintPage + 1}/{count})" : ""); string text9 = ((count > 1) ? " [R] Next page" : ""); __result = __result + "\n[H] Hide" + text9 + text8 + ""; } else { __result += "\n[H] Show"; } bool KnownAndEnabled(string key) { if (items.TryGetValue(key, out RitualItemConfig value6) && value6.Enabled) { if (!((Object)(object)player == (Object)null)) { return Plugin.IsRitualKnown(player, key); } return true; } return false; } } } [HarmonyPatch(typeof(Player), "UseHotbarItem")] internal class UseHotbarItemPatch { private static bool Prefix(Player __instance, int index) { //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0f1b: Unknown result type (might be due to invalid IL or missing references) //IL_0f29: Unknown result type (might be due to invalid IL or missing references) //IL_0f2e: Unknown result type (might be due to invalid IL or missing references) //IL_0f32: Unknown result type (might be due to invalid IL or missing references) //IL_0f37: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } GameObject hoverObject = ((Humanoid)__instance).GetHoverObject(); if ((Object)(object)hoverObject == (Object)null) { return true; } Fireplace fp = hoverObject.GetComponentInParent(); if ((Object)(object)fp == (Object)null || !fp.IsBurning()) { return true; } string goName = ((Object)((Component)fp).gameObject).name.ToLower().Replace("(clone)", "").Trim(); if (!Array.Exists(Plugin.CampfirePrefabs, (string p) => goName.StartsWith(p))) { return true; } if (!Plugin.Cfg.Rituals.Enabled) { return true; } ItemData item = ((Humanoid)__instance).GetInventory().GetItemAt(index - 1, 0); if (item == null) { return true; } GameObject dropPrefab = item.m_dropPrefab; string prefab = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; if (string.IsNullOrEmpty(prefab)) { GameObject val = ObjectDB.instance?.m_items?.Find((GameObject go) => go.GetComponent()?.m_itemData?.m_shared?.m_name == item.m_shared?.m_name); prefab = ((val != null) ? ((Object)val).name : null) ?? ""; } if (string.IsNullOrEmpty(prefab)) { return true; } Dictionary ritualItems = Plugin.Cfg.Rituals.Items; if ((!(prefab == Plugin.SeekFood) || !RitualEnabled("seek_altar")) && (!prefab.StartsWith("Mushroom") || !RitualEnabled("restore_power")) && (!(prefab == Plugin.HomeFood) || !RitualEnabled("seek_bed")) && (!(prefab == Plugin.FeatherFood) || !RitualEnabled("feather_fall")) && (!(prefab == Plugin.TraderFood) || !RitualEnabled("seek_trader")) && (!prefab.StartsWith("Trophy") || !RitualEnabled("seek_dungeon")) && (!(prefab == "GreydwarfEye") || !RitualEnabled("clear_skies")) && (!(prefab == "Stone") || !RitualEnabled("water_walk")) && (!(prefab == Plugin.GrowthFood) || !RitualEnabled("growth")) && (!(prefab == Plugin.PlayerSeekFood) || !RitualEnabled("seek_player")) && (!(prefab == Plugin.KindleFood) || !RitualEnabled("kindle")) && (!(prefab == Plugin.TameFood) || !RitualEnabled("tame_flock")) && (!(prefab == Plugin.MeadFood) || !RitualEnabled("mead_ripen")) && (!(prefab == Plugin.GiantFood) || !RitualEnabled("giant")) && (!(prefab == Plugin.BurdenFood) || !RitualEnabled("burden")) && (!(prefab == Plugin.WardFood) || !RitualEnabled("ward_bubble")) && (!(prefab == Plugin.CampfireWardFood) || !RitualEnabled("campfire_ward")) && (!(prefab == Plugin.RepairFood) || !RitualEnabled("repair")) && (!(prefab == Plugin.TarMoatFood) || !RitualEnabled("tar_moat")) && (!(prefab == Plugin.FireWallFood) || !RitualEnabled("fire_wall")) && (!(prefab == Plugin.CorpseFood) || !RitualEnabled("seek_corpse")) && (!(prefab == Plugin.MistFood) || !RitualEnabled("clear_mist")) && (!Plugin.TreeStandSeeds.ContainsKey(prefab) || !RitualEnabled("tree_stand")) && (!(prefab == "WitheredBone") || !RitualEnabled("rock_stand")) && (!(prefab == Plugin.PrimeFood) || !RitualEnabled("prime")) && !Plugin.HuntDefs.Any((Plugin.HuntDef d) => prefab == Plugin.HuntIngredient(d) && RitualEnabled(d.Key))) { string text = Plugin.LegendaryIngredientMatch(prefab); if (text == null || !RitualEnabled(text)) { return true; } } if (Plugin.RitualCooldownRemaining > 0f) { ((Character)__instance).Message((MessageType)2, "The fire is not ready...", 0, (Sprite)null); return false; } Plugin.SpawnRitualVFX(((Component)fp).transform.position, ((Component)__instance).transform.position); float num = Plugin.PrimeMultiplier(fp); float num2 = Plugin.RitualMultiplier(fp, __instance) * num; if (prefab == Plugin.SeekFood) { SEMan sEMan = ((Character)__instance).GetSEMan(); SE_GuidingWind? guidingWindSE = Plugin.GuidingWindSE; if (sEMan.HaveStatusEffect((guidingWindSE != null) ? ((StatusEffect)guidingWindSE).NameHash() : 0)) { ((Character)__instance).Message((MessageType)2, "The wind already guides you.", 0, (Sprite)null); return false; } Consume("seek_altar"); Plugin.ActivateSeek(null, RitualMsg("seek_altar", "The wind stirs."), num2, prefab); return false; } if (prefab.StartsWith("Mushroom")) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (((typeof(Player).GetField("m_guardianPowerCooldown", bindingAttr)?.GetValue(__instance) is float num3) ? num3 : 0f) <= 0f) { ((Character)__instance).Message((MessageType)2, "Your power is already ready.", 0, (Sprite)null); return false; } Consume("restore_power"); Plugin.ActivateCooldownReset(__instance, RitualMsg("restore_power", "The storm answers."), num2); return false; } if (prefab == Plugin.HomeFood) { Consume("seek_bed"); Plugin.ActivateHomeSeek(__instance, RitualMsg("seek_bed", "The flower carries you home...")); return false; } if (prefab == Plugin.FeatherFood) { Consume("feather_fall"); Plugin.ActivateFeatherRitual(__instance, RitualMsg("feather_fall", "The feathers catch the wind."), num2, num > 1f); return false; } if (prefab == Plugin.TraderFood) { Consume("seek_trader"); Plugin.ActivateTraderSeek(__instance); return false; } if (prefab.StartsWith("Trophy")) { Consume("seek_dungeon"); Plugin.ActivateDungeonSeek(__instance, prefab, RitualMsg("seek_dungeon", "The veil parts — something stirs nearby.")); return false; } if (prefab == "GreydwarfEye") { Consume("clear_skies"); Plugin.ActivateClearSkies(__instance, RitualMsg("clear_skies", "The clouds part."), num2); return false; } if (prefab == "Stone") { Consume("water_walk"); Plugin.ActivateWaterWalk(__instance, RitualMsg("water_walk", "The sea grows still beneath your feet."), num2); return false; } if (prefab == Plugin.GrowthFood) { if (Plugin.GrowthBlessingActive) { ((Character)__instance).Message((MessageType)2, "The seed's blessing already waits in your dreams.", 0, (Sprite)null); return false; } Consume("growth"); Plugin.GrowthBlessingActive = true; ((Character)__instance).Message((MessageType)2, RitualMsg("growth", "The seed remembers the earth. Sleep, and your crops will answer."), 0, (Sprite)null); return false; } if (prefab == Plugin.PlayerSeekFood) { Consume("seek_player"); Plugin.ActivatePlayerSeek(__instance); return false; } if (prefab == Plugin.KindleFood) { Consume("kindle"); Plugin.ActivateKindle(__instance, RitualMsg("kindle", "The darkness yields.")); return false; } if (prefab == Plugin.TameFood) { if (Plugin.TameBlessingActive) { ((Character)__instance).Message((MessageType)2, "The bond already waits in your dreams.", 0, (Sprite)null); return false; } Consume("tame_flock"); Plugin.TameBlessingActive = true; ((Character)__instance).Message((MessageType)2, RitualMsg("tame_flock", "The bones remember loyalty. Sleep, and your flock will answer."), 0, (Sprite)null); return false; } if (prefab == Plugin.MeadFood) { if (Plugin.MeadBlessingActive) { ((Character)__instance).Message((MessageType)2, "The mead already ripens in your dreams.", 0, (Sprite)null); return false; } Consume("mead_ripen"); Plugin.MeadBlessingActive = true; ((Character)__instance).Message((MessageType)2, RitualMsg("mead_ripen", "The grain remembers the harvest. Sleep, and your mead will answer."), 0, (Sprite)null); return false; } if (prefab == Plugin.GiantFood && RitualEnabled("giant")) { Consume("giant"); Plugin.ActivateGiant(__instance, RitualMsg("giant", "The mountain answers. You are vast."), num2); return false; } if (prefab == Plugin.BurdenFood && RitualEnabled("burden")) { Consume("burden"); Plugin.ActivateBurden(__instance, RitualMsg("burden", "The weight is yours to bear."), num2); return false; } if (prefab == Plugin.WardFood) { Consume("ward_bubble"); Plugin.ActivateWard(__instance, fp, RitualMsg("ward_bubble", "A ward rises. None shall pass.")); return false; } if (prefab == Plugin.CampfireWardFood && RitualEnabled("campfire_ward")) { float duration = (Plugin.Cfg.Rituals.Items.GetValueOrDefault("campfire_ward")?.Duration ?? 60f) * num2; Consume("campfire_ward"); Plugin.ActivateCampfireWard(__instance, fp, RitualMsg("campfire_ward", "A sanctuary rises. None shall enter."), duration); return false; } if (prefab == Plugin.RepairFood && RitualEnabled("repair")) { Consume("repair"); Plugin.ActivateRepair(__instance, fp, RitualMsg("repair", "The fire remembers. Your works are mended.")); return false; } if (prefab == Plugin.TarMoatFood && RitualEnabled("tar_moat")) { Consume("tar_moat"); Plugin.ActivateTarMoat(__instance, fp, RitualMsg("tar_moat", "The earth bleeds black. None shall cross.")); return false; } if (prefab == Plugin.FireWallFood && RitualEnabled("fire_wall")) { Consume("fire_wall"); Plugin.ActivateFireWall(__instance, fp, RitualMsg("fire_wall", "The structure burns. None shall pass.")); return false; } if (prefab == Plugin.CorpseFood && RitualEnabled("seek_corpse")) { Consume("seek_corpse"); Plugin.ActivateCorpseSeek(__instance, RitualMsg("seek_corpse", "The bones remember. Return to what was lost.")); return false; } if (prefab == Plugin.MistFood && RitualEnabled("clear_mist")) { Consume("clear_mist"); Plugin.ActivateClearMist(__instance, fp, RitualMsg("clear_mist", "The wisp answers. Mist retreats."), num2); return false; } if (Plugin.TreeStandSeeds.ContainsKey(prefab) && RitualEnabled("tree_stand")) { if (__instance.m_customData.ContainsKey("ath_tree_stand_positions")) { ((Character)__instance).Message((MessageType)2, "The forest already waits in your dreams.", 0, (Sprite)null); return false; } Consume("tree_stand"); Plugin.ActivateTreeStand(__instance, fp, prefab, RitualMsg("tree_stand", "The seeds remember the earth. Sleep, and the forest will answer.")); return false; } if (prefab == "WitheredBone" && RitualEnabled("rock_stand")) { if (__instance.m_customData.ContainsKey("ath_rock_stand_positions")) { ((Character)__instance).Message((MessageType)2, "A stand of stones already awaits your rest.", 0, (Sprite)null); return false; } Consume("rock_stand"); Plugin.ActivateRockStand(__instance, fp, RitualMsg("rock_stand", "The bones remember stone. Sleep, and the earth will answer.")); return false; } if (prefab == Plugin.PrimeFood && RitualEnabled("prime")) { ZNetView component = ((Component)fp).GetComponent(); ZDO val2 = ((component != null) ? component.GetZDO() : null); if (!string.IsNullOrEmpty(((val2 != null) ? val2.GetString("pilgrim_prime_day", "") : null) ?? "")) { ((Character)__instance).Message((MessageType)2, "The gods already listen.", 0, (Sprite)null); return false; } Consume("prime", clearPrime: false); if (val2 != null) { val2.Set("pilgrim_prime_day", ((float)(ZNet.instance.GetTimeSeconds() / (double)EnvMan.instance.m_dayLengthSec)).ToString("F4", CultureInfo.InvariantCulture)); } ((Character)__instance).Message((MessageType)2, RitualMsg("prime", "The offering is made. The gods will answer."), 0, (Sprite)null); return false; } Plugin.HuntDef def = Array.Find(Plugin.HuntDefs, (Plugin.HuntDef d) => prefab == Plugin.HuntIngredient(d) && RitualEnabled(d.Key)); if (def.Key != null) { if (Plugin.ActivateHunt(def, __instance, fp, RitualMsg(def.Key, def.DefaultMessage))) { Consume(def.Key); } return false; } string legendaryKey = Plugin.LegendaryIngredientMatch(prefab); if (legendaryKey != null && RitualEnabled(legendaryKey)) { Plugin.LegendaryDef def2 = Array.Find(Plugin.LegendaryDefs, (Plugin.LegendaryDef d) => d.Key == legendaryKey); BindingFlags bindingAttr2 = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; object? obj = typeof(Humanoid).GetField("m_rightItem", bindingAttr2)?.GetValue(__instance); if (((ItemData)(((obj is ItemData) ? obj : null)?)).m_shared?.m_skillType != (SkillType?)def2.SkillType) { ((Character)__instance).Message((MessageType)2, "You must hold a " + def2.SkillLabel + " to answer the call.", 0, (Sprite)null); return false; } Consume(legendaryKey); Plugin.ActivateLegendaryWeapon(def2, __instance, RitualMsg(legendaryKey, def2.DefaultActivateMsg), num2); return false; } (string, bool, string, string)[] ritualItemMap = Plugin.RitualItemMap; for (int num4 = 0; num4 < ritualItemMap.Length; num4++) { var (text2, flag, text3, _) = ritualItemMap[num4]; if (flag ? prefab.StartsWith(text2) : (prefab == text2)) { if (ritualItems.TryGetValue(text3, out RitualItemConfig value) && value.Enabled && Plugin.IsRitualKnown(__instance, text3)) { Plugin.Log.LogWarning((object)("[Pilgrim] Ritual '" + text3 + "' matched but not handled above — check UseHotbarItemPatch")); } else { ((Character)__instance).Message((MessageType)2, "You sense a ritual here, but don't yet understand this offering.", 0, (Sprite)null); } return false; } } return true; void ClearPrime() { ZNetView component2 = ((Component)fp).GetComponent(); ZDO val3 = ((component2 != null) ? component2.GetZDO() : null); if (val3 != null) { val3.Set("pilgrim_prime_day", ""); } } void Consume(string ritualKey = "", bool clearPrime = true) { CartUpgrade.RemoveByPrefab(((Humanoid)__instance).GetInventory(), prefab, 1); Plugin.RitualCooldownRemaining = Plugin.RitualCooldownDuration; if (!string.IsNullOrEmpty(ritualKey)) { Plugin.RecordRitualUse(__instance, ritualKey); } if (clearPrime) { ClearPrime(); } } bool RitualEnabled(string key) { if (ritualItems.TryGetValue(key, out RitualItemConfig value2) && value2.Enabled) { return Plugin.IsRitualKnown(__instance, key); } return false; } string RitualMsg(string key, string fallback) { if (!ritualItems.TryGetValue(key, out RitualItemConfig value2)) { return fallback; } return value2.Message; } } } [HarmonyPatch(typeof(Player), "SetSleeping")] internal class GrowthBlessingPatch { private static void Postfix(Player __instance, bool sleep) { //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_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_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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) if (!sleep || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } Vector3 position = ((Component)__instance).transform.position; if (Plugin.GrowthBlessingActive) { Plugin.GrowthBlessingActive = false; int num = 0; Plant[] array = Object.FindObjectsOfType(); foreach (Plant val in array) { if (!(Vector3.Distance(((Component)val).transform.position, position) > 50f)) { ZNetView component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner()) { long ticks = (ZNet.instance.GetTime() - TimeSpan.FromSeconds(10000.0)).Ticks; component.GetZDO().Set(ZDOVars.s_plantTime, ticks); val.Grow(); num++; } } } if (num > 0) { ((Character)__instance).Message((MessageType)1, $"{num} crops answered the blessing.", 0, (Sprite)null); } } if (Plugin.TameBlessingActive) { Plugin.TameBlessingActive = false; int num2 = 0; Tameable[] array2 = Object.FindObjectsOfType(); foreach (Tameable val2 in array2) { if (Vector3.Distance(((Component)val2).transform.position, position) > 50f) { continue; } ZNetView component2 = ((Component)val2).GetComponent(); if (!((Object)(object)component2 == (Object)null) && component2.IsValid() && component2.IsOwner() && !(component2.GetZDO().GetFloat(ZDOVars.s_tameTimeLeft, -1f) < 0f)) { Character component3 = ((Component)val2).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.SetTamed(true); } num2++; } } if (num2 > 0) { ((Character)__instance).Message((MessageType)1, $"{num2} creatures answered the bond.", 0, (Sprite)null); } } if (!Plugin.MeadBlessingActive) { return; } Plugin.MeadBlessingActive = false; int num3 = 0; Fermenter[] array3 = Object.FindObjectsOfType(); foreach (Fermenter val3 in array3) { if (Vector3.Distance(((Component)val3).transform.position, position) > 50f) { continue; } ZNetView component4 = ((Component)val3).GetComponent(); if ((Object)(object)component4 == (Object)null || !component4.IsValid() || string.IsNullOrEmpty(component4.GetZDO().GetString(ZDOVars.s_content, ""))) { continue; } long num4 = component4.GetZDO().GetLong(ZDOVars.s_startTime, 0L); if (num4 != 0L) { DateTime dateTime = new DateTime(num4); if (!((ZNet.instance.GetTime() - dateTime).TotalSeconds >= (double)val3.m_fermentationDuration)) { component4.ClaimOwnership(); long ticks2 = (ZNet.instance.GetTime() - TimeSpan.FromSeconds(val3.m_fermentationDuration)).Ticks; component4.GetZDO().Set(ZDOVars.s_startTime, ticks2); num3++; } } } if (num3 > 0) { ((Character)__instance).Message((MessageType)1, $"{num3} fermenters answered the blessing.", 0, (Sprite)null); } } } [HarmonyPatch(typeof(Player), "SetSleeping")] internal class TreeStandWakePatch { private static void Postfix(Player __instance, bool sleep) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if (sleep) { if (!__instance.m_customData.TryGetValue("ath_tree_stand_pieces", out var value)) { return; } __instance.m_customData.Remove("ath_tree_stand_pieces"); string[] array = value.Split('|'); ZDOID val = default(ZDOID); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(':'); if (array2.Length == 2 && long.TryParse(array2[0], out var result) && uint.TryParse(array2[1], out var result2)) { ((ZDOID)(ref val))..ctor(result, result2); ZNetScene instance = ZNetScene.instance; GameObject val2 = ((instance != null) ? instance.FindInstance(val) : null); if ((Object)(object)val2 != (Object)null) { ZNetScene.instance.Destroy(val2); } } } } else { if (!__instance.m_customData.TryGetValue("ath_tree_stand_positions", out var value2)) { return; } __instance.m_customData.Remove("ath_tree_stand_positions"); ZNetScene instance2 = ZNetScene.instance; if ((Object)(object)instance2 == (Object)null) { return; } string[] array3 = value2.Split(';'); string text = ((array3.Length != 0) ? array3[0] : "FirCone"); string text2 = ((array3.Length > 1) ? array3[1] : value2); if (!Plugin.TreeStandSeeds.TryGetValue(text, out string value3)) { value3 = "FirTree"; } GameObject prefab = instance2.GetPrefab(value3); if ((Object)(object)prefab == (Object)null) { Plugin.Log.LogWarning((object)("[Pilgrim] Tree prefab '" + value3 + "' not found")); return; } List list = (from s in text2.Split('|') select s.Split(',') into p where p.Length == 3 select p).Select((Func)((string[] p) => new Vector3(float.Parse(p[0]), float.Parse(p[1]), float.Parse(p[2])))).ToList(); int num = 0; foreach (Vector3 item in list) { Vector3 val3 = Plugin.ProjectToTerrain(item); Quaternion val4 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); float num2 = Random.Range(0.95f, 1.05f); GameObject obj = Object.Instantiate(prefab, val3, val4); ZNetView component = obj.GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.GetZDO().Set(ZDOVars.s_scaleHash, num2); } obj.transform.localScale = Vector3.one * num2; num++; } string arg = text switch { "FirCone" => "fir trees", "PineCone" => "pine trees", "Acorn" => "oaks", "BeechSeeds" => "beech trees", "BirchSeeds" => "birch trees", _ => "trees", }; if (num > 0) { ((Character)__instance).Message((MessageType)1, $"A stand of {num} {arg} has taken root.", 0, (Sprite)null); } Plugin.Log.LogInfo((object)$"[Pilgrim] Tree stand: spawned {num} {value3}"); } } } [HarmonyPatch(typeof(Player), "SetSleeping")] internal class RockStandWakePatch { private static readonly string[] RockPrefabs = new string[6] { "RockDolmen_1", "RockDolmen_2", "RockDolmen_3", "Rock_3", "Rock_4", "Rock_7" }; private static void Postfix(Player __instance, bool sleep) { //IL_008b: 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_01a2: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: 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_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026b: 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_029e: 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 ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if (sleep) { if (!__instance.m_customData.TryGetValue("ath_rock_stand_pieces", out var value)) { return; } __instance.m_customData.Remove("ath_rock_stand_pieces"); string[] array = value.Split('|'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(':'); if (array2.Length == 2 && long.TryParse(array2[0], out var result) && uint.TryParse(array2[1], out var result2)) { ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.FindInstance(new ZDOID(result, result2)) : null); if ((Object)(object)val != (Object)null) { ZNetScene.instance.Destroy(val); } } } } else { if (!__instance.m_customData.TryGetValue("ath_rock_stand_positions", out var value2)) { return; } __instance.m_customData.Remove("ath_rock_stand_positions"); ZNetScene instance2 = ZNetScene.instance; if ((Object)(object)instance2 == (Object)null) { return; } List list = (from s in value2.Split('|') select s.Split(',') into p where p.Length == 3 select p).Select((Func)((string[] p) => new Vector3(float.Parse(p[0]), float.Parse(p[1]), float.Parse(p[2])))).ToList(); Plugin.Log.LogInfo((object)$"[Pilgrim] Rock stand wake: {list.Count} positions encoded"); int num = 0; foreach (Vector3 item in list) { string text = RockPrefabs[Random.Range(0, RockPrefabs.Length)]; GameObject prefab = instance2.GetPrefab(text); Plugin.Log.LogInfo((object)("[Pilgrim] Rock stand: GetPrefab(" + text + ") = " + (((Object)(object)prefab == (Object)null) ? "NULL" : "found"))); if (!((Object)(object)prefab == (Object)null)) { Vector3 val2 = Plugin.ProjectToTerrain(item); Quaternion val3 = Quaternion.Euler(Random.Range(-15f, 15f), Random.Range(0f, 360f), Random.Range(-15f, 15f)); float num2 = Random.Range(2.5f, 3.5f); GameObject val4 = Object.Instantiate(prefab, val2, val3); Transform transform = val4.transform; transform.localScale *= num2; val2.y -= val4.transform.localScale.y * 0.2f; val4.transform.position = val2; ZNetView component = val4.GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.GetZDO().Set(ZDOVars.s_scaleHash, val4.transform.localScale.x); } num++; } } if (num > 0) { ((Character)__instance).Message((MessageType)1, $"A stand of {num} stones has risen.", 0, (Sprite)null); } Plugin.Log.LogInfo((object)$"[Pilgrim] Rock stand: spawned {num} rocks"); } } } [HarmonyPatch(typeof(ItemStand), "Interact")] internal class ItemStandPatch { private static bool Prefix(ItemStand __instance, Humanoid user, bool hold, bool alt) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Cfg.Trophies.Enabled) { return true; } if (hold || !alt) { return true; } if (!__instance.HaveAttachment()) { return true; } string text = __instance.GetAttachedItem() ?? ""; Console instance = Console.instance; if (instance != null) { ((Terminal)instance).AddString($"[EnvR] ItemStand attached='{text}' hasAttach={__instance.HaveAttachment()}"); } if (string.IsNullOrEmpty(text)) { return true; } if (!Plugin.TrophyToPower.ContainsKey(text)) { Console instance2 = Console.instance; if (instance2 != null) { ((Terminal)instance2).AddString("[EnvR] '" + text + "' not in TrophyToPower map"); } return true; } Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null) { return true; } Plugin.GrantTrophyPower(val, text, null, ((Component)val).transform.position); return false; } } [HarmonyPatch(typeof(Bed), "GetHoverText")] [HarmonyPriority(0)] internal static class BedHoverTextPatch { private static void Postfix(Bed __instance, ref string __result) { //IL_0030: 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) if (Plugin.Cfg.Beds.SleepWithoutSpawn) { Game instance = Game.instance; PlayerProfile val = ((instance != null) ? instance.GetPlayerProfile() : null); if (val == null || !val.HaveCustomSpawnPoint() || !(Vector3.Distance(val.GetCustomSpawnPoint(), ((Component)__instance).transform.position) < 1f)) { __result += "\n[Shift+E] Sleep only"; } } } } [HarmonyPatch(typeof(Bed), "Interact")] internal static class BedSleepNoSpawnPatch { private static void Prefix() { if (Plugin.Cfg.Beds.SleepWithoutSpawn && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { Plugin._suppressSpawnSet = true; } } private static void Postfix() { Plugin._suppressSpawnSet = false; } } [HarmonyPatch(typeof(Bed), "IsCurrent")] internal static class BedIsCurrentPatch { private static bool Prefix(ref bool __result) { if (!Plugin._suppressSpawnSet) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(PlayerProfile), "SetCustomSpawnPoint")] internal static class PlayerSetSpawnPointPatch { private static bool Prefix() { return !Plugin._suppressSpawnSet; } } public class SE_GuidingWind : StatusEffect { private float _windTimer; public override void Setup(Character character) { ((StatusEffect)this).Setup(character); string[] array = new string[1] { "Rested" }; foreach (string candidate in array) { StatusEffect val = ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == candidate); if ((Object)(object)val?.m_icon != (Object)null) { base.m_icon = val.m_icon; Plugin.Log.LogInfo((object)("[Pilgrim] GuidingWind icon from " + candidate)); break; } } if ((Object)(object)base.m_icon == (Object)null) { Plugin.Log.LogWarning((object)"[Pilgrim] GuidingWind: no icon found from any candidate"); } RefreshWind(); } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); _windTimer -= dt; if (_windTimer <= 0f) { _windTimer = 3f; RefreshWind(); } } public override void Stop() { ((StatusEffect)this).Stop(); EnvMan instance = EnvMan.instance; if ((Object)(object)instance != (Object)null) { instance.ResetDebugWind(); if (instance.m_debugEnv == "WarmSnow") { instance.m_debugEnv = ""; } if (instance.m_debugEnv == "DreamWalk" && Plugin.HomeEnvExpiry <= 0f) { instance.m_debugEnv = ""; } if (instance.m_debugEnv == "LastLight" && Plugin.SeekEnvExpiry <= 0f) { instance.m_debugEnv = ""; } if (instance.m_debugEnv == "VoidWhisper" && Plugin.DungeonEnvExpiry <= 0f) { instance.m_debugEnv = ""; } Plugin.SeekOverrideTarget = null; } } public override string GetIconText() { float num = Mathf.Max(0f, base.m_ttl - base.m_time); int num2 = (int)(num / 60f); int num3 = (int)(num % 60f); if (num2 <= 0) { return $"{num3}s"; } return $"{num2}m {num3:D2}s"; } private void RefreshWind() { //IL_0034: 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_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_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_0086: 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_0093: Unknown result type (might be due to invalid IL or missing references) Character character = base.m_character; Player val = (Player)(object)((character is Player) ? character : null); if ((Object)(object)val == (Object)null || (Object)(object)EnvMan.instance == (Object)null) { return; } Vector3 value; if (Plugin.SeekOverrideTarget.HasValue) { value = Plugin.SeekOverrideTarget.Value; Plugin.BroadcastEnv("VoidWhisper", "ThunderStorm"); } else { if (!Plugin.BossSeekTarget.HasValue) { return; } value = Plugin.BossSeekTarget.Value; Plugin.BroadcastEnv("LastLight", "Twilight_Clear"); } Vector3 position = ((Component)val).transform.position; float num = Mathf.Atan2(value.x - position.x, value.z - position.z) * 57.29578f; if (num < 0f) { num += 360f; } EnvMan.instance.SetDebugWind(num, 1f); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal class ObjectDBAwakePatch { private static bool _done; private static void Postfix(ObjectDB __instance) { //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown if (_done) { return; } _done = true; SE_GuidingWind sE_GuidingWind = ScriptableObject.CreateInstance(); ((Object)sE_GuidingWind).name = "SE_GuidingWind"; ((StatusEffect)sE_GuidingWind).m_name = "Guiding Wind"; ((StatusEffect)sE_GuidingWind).m_tooltip = "The gods guide your path. Follow the wind."; ((StatusEffect)sE_GuidingWind).m_ttl = 60f; ((StatusEffect)sE_GuidingWind).m_startMessage = ""; ((StatusEffect)sE_GuidingWind).m_stopMessage = ""; __instance.m_StatusEffects.Add((StatusEffect)(object)sE_GuidingWind); Plugin.GuidingWindSE = sE_GuidingWind; Plugin.Log.LogInfo((object)"[EnvR] Registered SE_GuidingWind"); SE_WaterWalk sE_WaterWalk = ScriptableObject.CreateInstance(); ((Object)sE_WaterWalk).name = "SE_WaterWalk"; ((StatusEffect)sE_WaterWalk).m_name = "Still Waters"; ((StatusEffect)sE_WaterWalk).m_tooltip = "The sea is glass beneath your feet."; ((StatusEffect)sE_WaterWalk).m_ttl = 0f; ((StatusEffect)sE_WaterWalk).m_startMessage = ""; ((StatusEffect)sE_WaterWalk).m_stopMessage = ""; __instance.m_StatusEffects.Add((StatusEffect)(object)sE_WaterWalk); Plugin.WaterWalkSE = sE_WaterWalk; SE_Giant sE_Giant = ScriptableObject.CreateInstance(); ((Object)sE_Giant).name = "SE_Giant"; ((StatusEffect)sE_Giant).m_name = "Ymir's Fury"; ((StatusEffect)sE_Giant).m_tooltip = "You walk as a mountain. Carry more, strike fear."; ((StatusEffect)sE_Giant).m_ttl = 180f; ((StatusEffect)sE_Giant).m_startMessage = ""; ((StatusEffect)sE_Giant).m_stopMessage = ""; __instance.m_StatusEffects.Add((StatusEffect)(object)sE_Giant); Plugin.GiantSE = sE_Giant; SE_Burden sE_Burden = ScriptableObject.CreateInstance(); ((Object)sE_Burden).name = "SE_Burden"; ((StatusEffect)sE_Burden).m_name = "Beast of Burden"; ((StatusEffect)sE_Burden).m_tooltip = "You carry more than any mortal should."; ((StatusEffect)sE_Burden).m_ttl = 60f; ((StatusEffect)sE_Burden).m_startMessage = ""; ((StatusEffect)sE_Burden).m_stopMessage = ""; __instance.m_StatusEffects.Add((StatusEffect)(object)sE_Burden); Plugin.BurdenSE = sE_Burden; SE_LegendaryWeapon sE_LegendaryWeapon = ScriptableObject.CreateInstance(); ((Object)sE_LegendaryWeapon).name = "SE_LegendaryWeapon"; ((StatusEffect)sE_LegendaryWeapon).m_name = "Legendary Weapon"; ((StatusEffect)sE_LegendaryWeapon).m_tooltip = "A blade of fire, summoned and bound to flicker out in time."; ((StatusEffect)sE_LegendaryWeapon).m_ttl = 60f; ((StatusEffect)sE_LegendaryWeapon).m_startMessage = ""; ((StatusEffect)sE_LegendaryWeapon).m_stopMessage = ""; __instance.m_StatusEffects.Add((StatusEffect)(object)sE_LegendaryWeapon); Plugin.LegendarySE = sE_LegendaryWeapon; StatusEffect? obj = __instance.m_StatusEffects.Find((StatusEffect s) => s is SE_Shield); SE_Shield val = (SE_Shield)(object)((obj is SE_Shield) ? obj : null); if (!((Object)(object)val != (Object)null)) { return; } val.m_ttlPerItemLevel = 0; Plugin.ShieldBubbleSE = val; EffectData[] effectPrefabs = ((StatusEffect)val).m_startEffects.m_effectPrefabs; foreach (EffectData val2 in effectPrefabs) { if (!((Object)(object)val2.m_prefab == (Object)null)) { Renderer componentInChildren = val2.m_prefab.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && ((Object)((Component)componentInChildren).gameObject).name == "Sphere") { Plugin.WardSphereMat = new Material(componentInChildren.sharedMaterial); break; } } } } } public class SE_WaterWalk : StatusEffect { public override void Setup(Character character) { ((StatusEffect)this).Setup(character); StatusEffect val = ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == "Rested"); if ((Object)(object)val?.m_icon != (Object)null) { base.m_icon = val.m_icon; } } public override string GetIconText() { float num = Mathf.Max(0f, Plugin.WaterWalkExpiry - Time.time); int num2 = (int)(num / 60f); int num3 = (int)(num % 60f); if (num2 <= 0) { return $"{num3}s"; } return $"{num2}m {num3:D2}s"; } } public class SE_Giant : StatusEffect { public override void Setup(Character character) { ((StatusEffect)this).Setup(character); string[] array = new string[5] { "GP_Yagluth", "GP_Bonemass", "GP_Eikthyr", "SE_Burning", "Rested" }; foreach (string c in array) { StatusEffect val = ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == c); if ((Object)(object)val?.m_icon != (Object)null) { base.m_icon = val.m_icon; break; } } } public override string GetIconText() { float num = Mathf.Max(0f, Plugin.GiantExpiry - Time.time); int num2 = (int)(num / 60f); int num3 = (int)(num % 60f); if (num2 <= 0) { return $"{num3}s"; } return $"{num2}m {num3:D2}s"; } } public class SE_Burden : StatusEffect { public override void Setup(Character character) { ((StatusEffect)this).Setup(character); ObjectDB instance = ObjectDB.instance; GameObject obj = ((instance != null) ? instance.GetItemPrefab("BeltStrength") : null); Sprite val = ((obj == null) ? null : obj.GetComponent()?.m_itemData?.m_shared?.m_icons?.FirstOrDefault()); if ((Object)(object)val != (Object)null) { base.m_icon = val; return; } string[] array = new string[3] { "GP_Bonemass", "GP_Yagluth", "Rested" }; foreach (string c in array) { StatusEffect val2 = ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == c); if ((Object)(object)val2?.m_icon != (Object)null) { base.m_icon = val2.m_icon; break; } } } public override string GetIconText() { float num = Mathf.Max(0f, Plugin.BurdenExpiry - Time.time); int num2 = (int)(num / 60f); int num3 = (int)(num % 60f); if (num2 <= 0) { return $"{num3}s"; } return $"{num2}m {num3:D2}s"; } } public class SE_LegendaryWeapon : StatusEffect { public override void Setup(Character character) { ((StatusEffect)this).Setup(character); ZNetScene instance = ZNetScene.instance; GameObject obj = ((instance != null) ? instance.GetPrefab(Plugin._activeLegendaryDef.Prefab) : null); SharedData val = ((obj == null) ? null : obj.GetComponent()?.m_itemData?.m_shared); if (val?.m_icons != null && val.m_icons.Length != 0) { base.m_icon = val.m_icons[0]; return; } string[] array = new string[3] { "SE_Burning", "GP_Eikthyr", "Rested" }; foreach (string c in array) { StatusEffect val2 = ObjectDB.instance?.m_StatusEffects?.Find((StatusEffect s) => ((Object)s).name == c); if ((Object)(object)val2?.m_icon != (Object)null) { base.m_icon = val2.m_icon; break; } } } public override string GetIconText() { float num = Mathf.Max(0f, Plugin.FlamingSwordExpiry - Time.time); int num2 = (int)(num / 60f); int num3 = (int)(num % 60f); if (num2 <= 0) { return $"{num3}s"; } return $"{num2}m {num3:D2}s"; } } [HarmonyPatch(typeof(Character), "RPC_Damage")] internal class GiantDamageResistPatch { private static void Prefix(Character __instance, HitData hit) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !(Plugin.GiantExpiry <= 0f) && !(Time.time > Plugin.GiantExpiry)) { if ((int)hit.m_hitType == 3) { hit.m_damage.m_damage *= 0.2f; return; } hit.m_damage.m_blunt *= 0.1f; hit.m_damage.m_slash *= 0.1f; hit.m_damage.m_pierce *= 0.1f; hit.m_damage.m_chop *= 0.1f; hit.m_damage.m_pickaxe *= 0.1f; hit.m_damage.m_fire *= 0.1f; hit.m_damage.m_frost *= 0.1f; hit.m_damage.m_lightning *= 0.1f; hit.m_damage.m_poison *= 0.1f; hit.m_damage.m_spirit *= 0.1f; } } } [HarmonyPatch(typeof(WaterVolume), "GetWaterSurface")] internal class GiantWaterSurfacePatch { private static void Postfix(ref float __result) { if (!(Plugin.GiantExpiry <= 0f) && !(Time.time >= Plugin.GiantExpiry)) { __result -= 2.4f; } } } internal static class VdsSwimSuppressor { private const string VdsGuid = "blacks7ar.VikingsDoSwim"; private static readonly Harmony _h = new Harmony("com.ctogle.pilgrim.vdssuppressor"); private static readonly MethodInfo _target = typeof(Character).GetMethod("OnSwimming", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly List<(MethodInfo method, HarmonyPatchType type)> _saved = new List<(MethodInfo, HarmonyPatchType)>(); internal static void Suppress() { if (_target == null) { return; } Patches patchInfo = Harmony.GetPatchInfo((MethodBase)_target); if (patchInfo == null) { return; } _saved.Clear(); foreach (Patch prefix in patchInfo.Prefixes) { if (prefix.owner == "blacks7ar.VikingsDoSwim") { _h.Unpatch((MethodBase)_target, prefix.PatchMethod); _saved.Add((prefix.PatchMethod, (HarmonyPatchType)1)); } } foreach (Patch postfix in patchInfo.Postfixes) { if (postfix.owner == "blacks7ar.VikingsDoSwim") { _h.Unpatch((MethodBase)_target, postfix.PatchMethod); _saved.Add((postfix.PatchMethod, (HarmonyPatchType)2)); } } foreach (Patch transpiler in patchInfo.Transpilers) { if (transpiler.owner == "blacks7ar.VikingsDoSwim") { _h.Unpatch((MethodBase)_target, transpiler.PatchMethod); _saved.Add((transpiler.PatchMethod, (HarmonyPatchType)3)); } } } internal static void Restore() { //IL_0029: 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) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0036: 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: Expected I4, but got Unknown if (_target == null) { return; } foreach (var item3 in _saved) { MethodInfo item = item3.method; HarmonyPatchType item2 = item3.type; HarmonyMethod val = new HarmonyMethod(item); switch (item2 - 1) { case 0: _h.Patch((MethodBase)_target, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); break; case 1: _h.Patch((MethodBase)_target, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); break; case 2: _h.Patch((MethodBase)_target, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); break; } } _saved.Clear(); } } [HarmonyPatch(typeof(Vagon), "Interact")] internal class VagonInteractPatch { private static bool Prefix(Vagon __instance, Humanoid character, bool hold, bool alt) { if (!Plugin.Cfg.Carts.Enabled) { return true; } if (!alt) { return true; } Player val = (Player)(object)((character is Player) ? character : null); if ((Object)(object)val == (Object)null) { return true; } CartUpgrade.Upgrade(val, __instance); return false; } } [HarmonyPatch(typeof(Vagon), "GetHoverText")] internal class VagonHoverPatch { private static void Postfix(Vagon __instance, ref string __result) { if (!Plugin.Cfg.Carts.Enabled) { return; } ZNetView component = ((Component)__instance).GetComponent(); int? obj; if (component == null) { obj = null; } else { ZDO zDO = component.GetZDO(); obj = ((zDO != null) ? new int?(zDO.GetInt("ath_cart_level", 0)) : ((int?)null)); } int? num = obj; int valueOrDefault = num.GetValueOrDefault(); __result = __result.Replace("Cart", (valueOrDefault == 0) ? "Cart" : $"Cart - Tier {valueOrDefault}"); _ = CartUpgrade.Heights[Mathf.Clamp(valueOrDefault, 0, CartUpgrade.Heights.Length - 1)]; bool? obj2; if (component == null) { obj2 = null; } else { ZDO zDO2 = component.GetZDO(); obj2 = ((zDO2 != null) ? new bool?(zDO2.GetBool("ath_cart_brake", false)) : ((bool?)null)); } bool? flag = obj2; string text = ((flag == true) ? "[B] Handbrake ON" : "[B] Handbrake"); if (valueOrDefault >= CartUpgrade.Heights.Length - 1) { __result += "\nCart fully reinforced"; __result = __result + "\n" + text; __result += "\n[G] Release cart"; return; } (string item, int amount)[] obj3 = CartUpgrade.Costs[valueOrDefault]; __result += "\n[Shift+E] Reinforce cart"; (string, int)[] array = obj3; for (int i = 0; i < array.Length; i++) { var (prefab, num2) = array[i]; __result += $"\n {num2}x {CartUpgrade.DisplayName(prefab)}"; } __result = __result + "\n" + text; __result += "\n[G] Release cart"; } } [HarmonyPatch(typeof(ItemStand), "GetHoverText")] internal class ItemStandHoverPatch { private static Exception Finalizer(Exception __exception, ItemStand __instance, ref string __result) { if (Plugin.Cfg.Trophies.Enabled && __instance.HaveAttachment()) { string key = __instance.GetAttachedItem() ?? ""; if (Plugin.TrophyToPower.ContainsKey(key) && !__result.Contains("Shift+E")) { __result += "\n[Shift+E] Claim Forsaken Power"; } } return __exception; } } [HarmonyPatch(typeof(Vagon), "FixedUpdate")] internal static class VagonFixedUpdatePatch { private static readonly BindingFlags RF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; internal static readonly Dictionary _cartPins = new Dictionary(); private static float _pinUpdateTimer = 0f; private static readonly Dictionary _origDrags = new Dictionary(); private static MethodInfo? _addPinMethod; internal static void EnsurePin(Vagon vagon) { //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_007e: 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_00b6: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null) { return; } ZNetView component = ((Component)vagon).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return; } ZDOID uid = component.GetZDO().m_uid; int num = component.GetZDO().GetInt("ath_cart_level", 0); string label = ((num > 0) ? $"Cart - Tier {num}" : "Cart"); bool flag = vagon.IsAttached((Character)(object)Player.m_localPlayer); if (_cartPins.TryGetValue(uid, out PinData value) && value != null) { if (flag) { Minimap.instance.RemovePin(value); _cartPins.Remove(uid); } else { value.m_pos = ((Component)vagon).transform.position; value.m_name = label; } } else { if (flag) { return; } if (typeof(Minimap).GetField("m_pins", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(Minimap.instance) is List list) { PinData val = list.Find((PinData p) => p.m_name == label && p.m_save); if (val != null) { Minimap.instance.RemovePin(val); } } if ((object)_addPinMethod == null) { _addPinMethod = typeof(Minimap).GetMethod("AddPin", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (!(_addPinMethod == null)) { ParameterInfo[] parameters = _addPinMethod.GetParameters(); object[] array = new object[parameters.Length]; array[0] = ((Component)vagon).transform.position; array[1] = (object)(PinType)0; array[2] = label; array[3] = true; array[4] = false; for (int num2 = 5; num2 < array.Length; num2++) { array[num2] = parameters[num2].DefaultValue ?? Activator.CreateInstance(parameters[num2].ParameterType); } object? obj = _addPinMethod.Invoke(Minimap.instance, array); PinData val2 = (PinData)((obj is PinData) ? obj : null); if (val2 != null) { _cartPins[uid] = val2; } } } } private static void Postfix(Vagon __instance) { //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_0048: 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_0055: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return; } if (component.IsOwner()) { Rigidbody component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null) { ZDOID uid = component.GetZDO().m_uid; if (!_origDrags.ContainsKey(uid)) { _origDrags[uid] = (component2.drag, component2.angularDrag); } (float, float) tuple = _origDrags[uid]; ZDO zDO = component.GetZDO(); bool flag = zDO != null && zDO.GetBool("ath_cart_brake", false); float drag; if (!flag) { (drag, _) = tuple; } else { drag = 80f; } component2.drag = drag; component2.angularDrag = (flag ? 80f : tuple.Item2); } } _pinUpdateTimer -= Time.fixedDeltaTime; if (!(_pinUpdateTimer > 0f)) { _pinUpdateTimer = 2f; EnsurePin(__instance); } } } [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] internal static class FakeCratePositionSyncPatch { private static void Prefix() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (Plugin._crateUIOpen && (Object)(object)Plugin._fakeCrateGo != (Object)null) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { Plugin._fakeCrateGo.transform.position = ((Component)localPlayer).transform.position; } } } } [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] internal static class ContainerWindowResizePatch { private static readonly BindingFlags RF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static int _lastRows = -1; private static float _defaultH = 0f; private static readonly string[] _topCenterChildren = new string[5] { "TakeAll", "StackAll", "createGroupBtn", "sunken", "ContainerScroll" }; private static readonly Dictionary _origPos = new Dictionary(); private static readonly Dictionary _origSize = new Dictionary(); private static void Postfix(InventoryGui __instance) { //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_026e: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_0321: 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_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) try { object? obj = typeof(InventoryGui).GetField("m_currentContainer", RF)?.GetValue(__instance); Container val = (Container)((obj is Container) ? obj : null); if ((Object)(object)val == (Object)null) { return; } bool num = (Object)(object)((Component)val).GetComponentInParent() != (Object)null; bool flag = false; if (!num) { Ship componentInParent = ((Component)val).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { string key = ((Object)((Component)componentInParent).gameObject).name.ToLower().Replace("(clone)", "").Trim(); flag = ShipStoragePatch.ShipLevels.ContainsKey(key); } } bool flag2 = (Object)(object)((Component)val).GetComponent() != (Object)null; if (!num && !flag && !flag2) { RestorePanel(__instance); return; } Inventory inventory = val.GetInventory(); int num2 = ((inventory != null) ? inventory.GetHeight() : 3); if (num2 == _lastRows) { return; } _lastRows = num2; object? obj2 = typeof(InventoryGui).GetField("m_containerGrid", RF)?.GetValue(__instance); InventoryGrid obj3 = (InventoryGrid)((obj2 is InventoryGrid) ? obj2 : null); float num3 = 64f; if (typeof(InventoryGrid).GetField("m_elementSpace", RF)?.GetValue(obj3) is Vector2 val2) { num3 = val2.y; } RectTransform val3 = null; object obj4 = typeof(InventoryGui).GetField("m_container", RF)?.GetValue(__instance); RectTransform val4 = (RectTransform)((obj4 is RectTransform) ? obj4 : null); if (val4 != null) { val3 = val4; } else { GameObject val5 = (GameObject)((obj4 is GameObject) ? obj4 : null); if (val5 != null) { val3 = val5.GetComponent(); } } if ((Object)(object)val3 == (Object)null) { return; } if (_defaultH == 0f) { _defaultH = val3.sizeDelta.y; for (int i = 0; i < ((Transform)val3).childCount; i++) { Transform child = ((Transform)val3).GetChild(i); RectTransform val6 = (RectTransform)(object)((child is RectTransform) ? child : null); if ((Object)(object)val6 != (Object)null && Array.IndexOf(_topCenterChildren, ((Object)val6).name) >= 0) { _origPos[((Object)val6).name] = val6.anchoredPosition; _origSize[((Object)val6).name] = val6.sizeDelta; } } } float num4 = (float)num2 * num3 + 110f; float num5 = 8f * num3 + 110f; float num6 = Mathf.Min(num4, num5); val3.sizeDelta = new Vector2(val3.sizeDelta.x, num6); float num7 = (num6 - _defaultH) / 2f; for (int j = 0; j < ((Transform)val3).childCount; j++) { Transform child2 = ((Transform)val3).GetChild(j); RectTransform val7 = (RectTransform)(object)((child2 is RectTransform) ? child2 : null); if ((Object)(object)val7 == (Object)null) { continue; } Vector2 value2; if (((Object)val7).name == "ContainerScroll") { if (_origSize.TryGetValue(((Object)val7).name, out var value)) { val7.sizeDelta = new Vector2(value.x, value.y + num7 * 2f); } } else if (_origPos.TryGetValue(((Object)val7).name, out value2)) { val7.anchoredPosition = new Vector2(value2.x, value2.y + num7); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Resize] " + ex.Message)); } } private static void RestorePanel(InventoryGui gui) { //IL_0069: 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_00b7: 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) if (_defaultH == 0f || _lastRows == -1) { return; } object obj = typeof(InventoryGui).GetField("m_container", RF)?.GetValue(gui); RectTransform val = null; RectTransform val2 = (RectTransform)((obj is RectTransform) ? obj : null); if (val2 != null) { val = val2; } else { GameObject val3 = (GameObject)((obj is GameObject) ? obj : null); if (val3 != null) { val = val3.GetComponent(); } } if ((Object)(object)val == (Object)null) { return; } val.sizeDelta = new Vector2(val.sizeDelta.x, _defaultH); for (int i = 0; i < ((Transform)val).childCount; i++) { Transform child = ((Transform)val).GetChild(i); RectTransform val4 = (RectTransform)(object)((child is RectTransform) ? child : null); if (!((Object)(object)val4 == (Object)null)) { if (_origPos.TryGetValue(((Object)val4).name, out var value)) { val4.anchoredPosition = value; } if (_origSize.TryGetValue(((Object)val4).name, out var value2)) { val4.sizeDelta = value2; } } } _lastRows = -1; } internal static void Reset() { if ((Object)(object)InventoryGui.instance != (Object)null) { RestorePanel(InventoryGui.instance); } else { _lastRows = -1; } } } [HarmonyPatch(typeof(Inventory), "MoveAll")] internal static class MoveAllExpandedPatch { private static readonly BindingFlags RF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly FieldInfo _gpf = typeof(ItemData).GetField("m_gridPos", RF); private static readonly FieldInfo _gxf = _gpf?.FieldType.GetField("x", RF); private static readonly FieldInfo _gyf = _gpf?.FieldType.GetField("y", RF); private static readonly Dictionary _saved = new Dictionary(); private static void Prefix(Inventory fromInventory) { if (!InventorySavePatch.Contains(fromInventory) || _gxf == null || _gyf == null) { return; } _saved.Clear(); foreach (ItemData allItem in fromInventory.GetAllItems()) { object value = _gpf.GetValue(allItem); int item = (int)_gxf.GetValue(value); int item2 = (int)_gyf.GetValue(value); _saved[allItem] = (item, item2); _gxf.SetValue(value, -1); _gpf.SetValue(allItem, value); } } private static void Postfix(Inventory fromInventory) { if (_saved.Count == 0) { return; } if (_gxf == null || _gyf == null) { _saved.Clear(); return; } foreach (ItemData allItem in fromInventory.GetAllItems()) { if (_saved.TryGetValue(allItem, out (int, int) value)) { object value2 = _gpf.GetValue(allItem); _gxf.SetValue(value2, value.Item1); _gyf.SetValue(value2, value.Item2); _gpf.SetValue(allItem, value2); } } _saved.Clear(); } } [HarmonyPatch(typeof(InventoryGui), "Hide")] internal static class ContainerGuiHidePatch { private static void Postfix() { ContainerWindowResizePatch.Reset(); } } [HarmonyPatch(typeof(Container), "Awake")] internal static class ContainerAwakePatch { private static void Postfix(Container __instance) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown if (!Plugin.Cfg.Carts.Enabled || (Object)(object)((Component)__instance).GetComponentInParent() == (Object)null) { return; } ZNetView componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || !componentInParent.IsValid()) { return; } ZDO zDO = componentInParent.GetZDO(); if (zDO == null) { return; } int num = zDO.GetInt("ath_cart_level", 0); if (num <= 0) { return; } Inventory inventory = __instance.GetInventory(); if (inventory != null) { CartUpgrade.ResizeInventory(inventory, num); byte[] byteArray = zDO.GetByteArray("items", (byte[])null); if (byteArray != null && byteArray.Length != 0) { ZPackage val = new ZPackage(byteArray); inventory.Load(val); Plugin.Log.LogWarning((object)$"[Cart] ContainerAwake: reloaded items at tier {num}"); } InventorySavePatch.CartViews[inventory] = componentInParent; } } } [HarmonyPatch(typeof(Inventory), "Save")] internal static class InventorySavePatch { internal static readonly Dictionary CartViews = new Dictionary(); internal static readonly Dictionary FixedLevels = new Dictionary(); internal static int GetLevel(Inventory inv) { if (CartViews.TryGetValue(inv, out ZNetView value)) { ZDO zDO = value.GetZDO(); if (zDO == null) { return 0; } return zDO.GetInt("ath_cart_level", 0); } if (FixedLevels.TryGetValue(inv, out var value2)) { return value2; } return 0; } internal static bool Contains(Inventory inv) { if (!CartViews.ContainsKey(inv)) { return FixedLevels.ContainsKey(inv); } return true; } private static void Prefix(Inventory __instance) { int level = GetLevel(__instance); if (level > 0) { CartUpgrade.ResizeInventory(__instance, level); } } } [HarmonyPatch(typeof(Inventory), "Load")] internal static class InventoryLoadPatch { private static readonly BindingFlags _rf = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly FieldInfo _itemsField = typeof(Inventory).GetField("m_items", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo _widthField = typeof(Inventory).GetField("m_width", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo _heightField = typeof(Inventory).GetField("m_height", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo _gridPosField = typeof(ItemData).GetField("m_gridPos", _rf); private static readonly FieldInfo _gridPosX = _gridPosField?.FieldType.GetField("x", _rf); private static readonly FieldInfo _gridPosY = _gridPosField?.FieldType.GetField("y", _rf); private static void Prefix(Inventory __instance) { int level = InventorySavePatch.GetLevel(__instance); if (level > 0) { CartUpgrade.ResizeInventory(__instance, level); } } private static void Postfix(Inventory __instance) { if (!(_itemsField?.GetValue(__instance) is List list) || _widthField == null || _heightField == null || _gridPosField == null || _gridPosX == null || _gridPosY == null) { return; } int num = (int)_widthField.GetValue(__instance); int num2 = (int)_heightField.GetValue(__instance); HashSet<(int, int)> hashSet = new HashSet<(int, int)>(); foreach (ItemData item in list) { object value = _gridPosField.GetValue(item); int num3 = (int)_gridPosX.GetValue(value); int num4 = (int)_gridPosY.GetValue(value); if (num3 >= 0 && num3 < num && num4 >= 0 && num4 < num2) { hashSet.Add((num3, num4)); } } foreach (ItemData item2 in list) { object value2 = _gridPosField.GetValue(item2); int num5 = (int)_gridPosX.GetValue(value2); int num6 = (int)_gridPosY.GetValue(value2); if (num5 >= 0 && num5 < num && num6 >= 0 && num6 < num2) { continue; } bool flag = false; for (int i = 0; i < num2; i++) { if (flag) { break; } for (int j = 0; j < num; j++) { if (flag) { break; } if (!hashSet.Contains((j, i))) { hashSet.Add((j, i)); _gridPosX.SetValue(value2, j); _gridPosY.SetValue(value2, i); _gridPosField.SetValue(item2, value2); Plugin.Log.LogInfo((object)$"[EnvR] Relocated '{item2.m_shared.m_name}' from ({num5},{num6}) → ({j},{i})"); flag = true; } } } if (!flag) { Plugin.Log.LogWarning((object)$"[EnvR] No empty slot for out-of-bounds item '{item2.m_shared.m_name}' ({num5},{num6}) in {num}x{num2} inv"); } } } } [HarmonyPatch(typeof(Vagon), "Awake")] internal class VagonAwakePatch { private static void Postfix(Vagon __instance) { ((MonoBehaviour)__instance).StartCoroutine(RestoreAfterLoad(__instance)); } private static IEnumerator RestoreAfterLoad(Vagon vagon) { yield return null; ZNetView component = ((Component)vagon).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); int num = ((zDO != null) ? zDO.GetInt("ath_cart_level", 0) : 0); if (num > 0) { CartUpgrade.ApplySize(vagon, num); } CartUpgrade.ApplyTint(vagon, num); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; object? obj = typeof(Vagon).GetField("m_container", bindingAttr)?.GetValue(vagon); object? obj2 = ((obj is Container) ? obj : null); Inventory val = ((obj2 != null) ? ((Container)obj2).GetInventory() : null); if (val != null) { InventorySavePatch.CartViews[val] = component; } VagonFixedUpdatePatch.EnsurePin(vagon); } } } [HarmonyPatch(typeof(Container), "Awake")] internal static class ShipStoragePatch { internal static readonly Dictionary ShipLevels = new Dictionary { { "karve", 3 }, { "vikingship", 3 }, { "vikingship_ashlands", 3 } }; private static void Postfix(Container __instance) { if (!Plugin.Cfg.Ships.Enabled) { return; } Ship componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return; } string key = ((Object)((Component)componentInParent).gameObject).name.ToLower().Replace("(clone)", "").Trim(); if (ShipLevels.TryGetValue(key, out var value)) { Inventory inventory = __instance.GetInventory(); if (inventory != null) { CartUpgrade.ResizeInventory(inventory, value); InventorySavePatch.FixedLevels[inventory] = value; } ((MonoBehaviour)__instance).StartCoroutine(RestoreAfterLoad(__instance, value)); } } private static IEnumerator RestoreAfterLoad(Container container, int level) { yield return null; ZNetView componentInParent = ((Component)container).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || !componentInParent.IsValid()) { yield break; } Inventory inventory = container.GetInventory(); if (inventory != null) { CartUpgrade.ResizeInventory(inventory, level); InventorySavePatch.FixedLevels[inventory] = level; ZDO zDO = componentInParent.GetZDO(); byte[] array = ((zDO != null) ? zDO.GetByteArray("items", (byte[])null) : null); if (array != null && array.Length != 0) { inventory.Load(new ZPackage(array)); } } } } [HarmonyPatch(typeof(Ship), "CustomFixedUpdate")] internal static class ShipPinPatch { private static PinData? _shipPin; private static float _updateTimer; private static MethodInfo? _addPinMethod; private static void Postfix(Ship __instance) { //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_00ec: 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_01d7: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Cfg.Ships.Enabled) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !__instance.IsPlayerInBoat(localPlayer)) { return; } _updateTimer -= Time.fixedDeltaTime; if (_updateTimer > 0f) { return; } _updateTimer = 2f; if ((Object)(object)Minimap.instance == (Object)null) { return; } Vector3 position = ((Component)__instance).transform.position; string text = ((Object)((Component)__instance).gameObject).name.ToLower().Replace("(clone)", "").Trim() switch { "karve" => "Karve", "vikingship" => "Longship", "vikingship_ashlands" => "Ashlands Longship", _ => "Ship", }; if (_shipPin != null) { _shipPin.m_pos = position; _shipPin.m_name = text; return; } if (typeof(Minimap).GetField("m_pins", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(Minimap.instance) is List list) { foreach (PinData item in list.FindAll(delegate(PinData p) { bool flag; switch (p.m_name) { case "Karve": case "Longship": case "Ashlands Longship": case "Ship": flag = true; break; default: flag = false; break; } return flag && p.m_save; })) { Minimap.instance.RemovePin(item); } } if ((object)_addPinMethod == null) { _addPinMethod = typeof(Minimap).GetMethod("AddPin", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (!(_addPinMethod == null)) { ParameterInfo[] parameters = _addPinMethod.GetParameters(); object[] array = new object[parameters.Length]; array[0] = position; array[1] = (object)(PinType)0; array[2] = text; array[3] = true; array[4] = false; for (int num = 5; num < array.Length; num++) { array[num] = parameters[num].DefaultValue ?? Activator.CreateInstance(parameters[num].ParameterType); } object? obj = _addPinMethod.Invoke(Minimap.instance, array); _shipPin = (PinData?)((obj is PinData) ? obj : null); } } } [HarmonyPatch(typeof(WearNTear), "Awake")] internal class VagonDestroyPatch { private static void Postfix(WearNTear __instance) { if (!Plugin.Cfg.Carts.Enabled || (Object)(object)((Component)__instance).GetComponent() == (Object)null) { return; } WearNTear obj = __instance; obj.m_onDestroyed = (Action)Delegate.Combine(obj.m_onDestroyed, (Action)delegate { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_00ef: 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_00fb: 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_0105: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDOID uid = component.GetZDO().m_uid; if (VagonFixedUpdatePatch._cartPins.TryGetValue(uid, out PinData value) && value != null) { Minimap instance = Minimap.instance; if (instance != null) { instance.RemovePin(value); } VagonFixedUpdatePatch._cartPins.Remove(uid); } if (component.IsOwner()) { ZDO zDO = component.GetZDO(); int num = ((zDO != null) ? zDO.GetInt("ath_cart_level", 0) : 0); if (num > 0) { ZNetScene instance2 = ZNetScene.instance; if (!((Object)(object)instance2 == (Object)null)) { Vector3 position = ((Component)__instance).transform.position; for (int i = 0; i < num && i < CartUpgrade.Costs.Length; i++) { (string, int)[] array = CartUpgrade.Costs[i]; for (int j = 0; j < array.Length; j++) { (string, int) tuple = array[j]; string item = tuple.Item1; int item2 = tuple.Item2; GameObject prefab = instance2.GetPrefab(item); if (!((Object)(object)prefab == (Object)null)) { for (int k = 0; k < item2; k++) { instance2.SpawnObject(position + Random.insideUnitSphere * 0.5f, Quaternion.identity, prefab); } } } } } } } } }); } } [HarmonyPatch(typeof(Player), "AddKnownItem")] [HarmonyPatch(typeof(Game), "Start")] [HarmonyPatch(typeof(StoreGui), "Show")] internal static class TraderInteractPatch { private static void Postfix(Trader trader) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)trader == (Object)null)) { Plugin.MarkTraderMet(((Component)trader).transform.position); } } } [HarmonyPatch(typeof(ZNet), "Start")] internal static class GameStartRpcPatch { private static void Postfix() { Plugin.RegisterShieldBubbleRPC(); Plugin.RegisterCampfireWardRPC(); Plugin.RegisterStructureRitualRPC(); Plugin.RegisterClearMistRPC(); ZRoutedRpc.instance.Register("Pilgrim_SendBird", (Action)delegate(long _, Vector3 dir, float speed) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Plugin.Scheduler?.SendBird(dir, speed); }); ZRoutedRpc.instance.Register("Pilgrim_SpawnVfx", (Method)delegate(long _, Vector3 pos, Quaternion rot, string prefabName, float destroyDelay) { //IL_001f: 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) ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(prefabName) : null); if (!((Object)(object)val == (Object)null)) { Plugin.SpawnVfxLocal(val, pos, rot, destroyDelay); } }); ZRoutedRpc.instance.Register("Pilgrim_SetEnv", (Action)delegate(long _, string envName, string fallback) { Plugin.SetDebugEnvSafe(envName, fallback); }); ZRoutedRpc.instance.Register("Pilgrim_SetWind", (Action)delegate(long _, float angle, float intensity) { Plugin.ApplyWind(angle, intensity); }); ZRoutedRpc.instance.Register("Pilgrim_SeekAltarRequest", (Action)delegate(long senderPeer, string prefabName, Vector3 refPos) { //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_003d: 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_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; LocationInstance val2 = default(LocationInstance); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.FindClosestLocation(prefabName, refPos, ref val2)) { val = val2.m_position; } ZRoutedRpc.instance.InvokeRoutedRPC(senderPeer, "Pilgrim_SeekAltarResponse", new object[1] { val }); }); ZRoutedRpc.instance.Register("Pilgrim_SeekAltarResponse", (Action)delegate(long _, Vector3 altarPos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Plugin.CompleteSeek(altarPos); }); ZRoutedRpc.instance.Register("Pilgrim_SeekLocationsRequest", (Action)delegate(long senderPeer, ZPackage pkg) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //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_00b7: 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_00d3: Unknown result type (might be due to invalid IL or missing references) int num = pkg.ReadInt(); string[] array = new string[num]; for (int i = 0; i < num; i++) { array[i] = pkg.ReadString(); } Dictionary> dictionary = Plugin.GatherAllLocations(array); int num2 = 0; foreach (KeyValuePair> item2 in dictionary) { num2 += item2.Value.Count; } ZPackage val = new ZPackage(); val.Write(num2); foreach (KeyValuePair> item3 in dictionary) { foreach (Vector3 item4 in item3.Value) { val.Write(item3.Key); val.Write(item4.x); val.Write(item4.y); val.Write(item4.z); } } ZRoutedRpc.instance.InvokeRoutedRPC(senderPeer, "Pilgrim_SeekLocationsResponse", new object[1] { val }); }); ZRoutedRpc.instance.Register("Pilgrim_SeekLocationsResponse", (Action)delegate(long _, ZPackage pkg) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) int num = pkg.ReadInt(); Dictionary> dictionary = new Dictionary>(); Vector3 item = default(Vector3); for (int i = 0; i < num; i++) { string key = pkg.ReadString(); ((Vector3)(ref item))..ctor(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new List()); } value.Add(item); } Plugin._pendingLocationsCallback?.Invoke(dictionary); Plugin._pendingLocationsCallback = null; }); ZRoutedRpc.instance.Register("Pilgrim_CorpseSeekRequest", (Action)delegate(long senderPeer, long playerID) { //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_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Plugin.FindNewestTombstonePos(playerID); ZRoutedRpc.instance.InvokeRoutedRPC(senderPeer, "Pilgrim_CorpseSeekResponse", new object[1] { val }); }); ZRoutedRpc.instance.Register("Pilgrim_CorpseSeekResponse", (Action)delegate(long _, Vector3 pos) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { string message = Plugin.Cfg.Rituals.Items.GetValueOrDefault("seek_corpse")?.Message ?? "The bones remember. Return to what was lost."; Plugin.CompleteCorpseSeek(localPlayer, pos, message); Plugin._pendingCorpseCallback = null; } }); ZRoutedRpc.instance.Register("Pilgrim_SetSeekTarget", (Action)delegate(long _, ZPackage pkg) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) string seekType = pkg.ReadString(); Vector3 target = default(Vector3); ((Vector3)(ref target))..ctor(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); Plugin.ApplySeekTargetLocal(duration: pkg.ReadSingle(), seekType: seekType, target: target); }); } } [HarmonyPatch(typeof(Character), "ShowPickupMessage")] internal class RitualDiscoveryPatch { private static void Postfix(Character __instance, ItemData item) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer || !Plugin.Cfg.Rituals.Enabled) { return; } GameObject dropPrefab = item.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; if (string.IsNullOrEmpty(text)) { GameObject? obj = ObjectDB.instance?.m_items?.Find((GameObject go) => go.GetComponent()?.m_itemData?.m_shared?.m_name == item.m_shared?.m_name); text = ((obj != null) ? ((Object)obj).name : null) ?? ""; if (!string.IsNullOrEmpty(text)) { Plugin.Log.LogInfo((object)("[Pilgrim] RitualDiscovery: resolved '" + text + "' via ObjectDB (m_dropPrefab was null)")); } else { Plugin.Log.LogWarning((object)("[Pilgrim] RitualDiscovery: m_dropPrefab null and ObjectDB lookup failed for '" + item.m_shared?.m_name + "'")); } } if (string.IsNullOrEmpty(text)) { return; } if (text == "TrophyEikthyr" && string.IsNullOrEmpty(val.GetGuardianPowerName())) { val.SetGuardianPower("GP_Eikthyr"); ((Character)val).Message((MessageType)2, "Eikthyr's power is yours.", 0, (Sprite)null); Plugin.Log.LogInfo((object)"[Pilgrim] Auto-granted GP_Eikthyr on TrophyEikthyr pickup."); } (string, bool, string, string)[] ritualItemMap = Plugin.RitualItemMap; for (int num = 0; num < ritualItemMap.Length; num++) { var (text2, flag, key, itemDisplayName) = ritualItemMap[num]; if ((flag ? text.StartsWith(text2) : (text == text2)) && Plugin.Cfg.Rituals.Items.TryGetValue(key, out RitualItemConfig value) && value.Enabled && !Plugin.IsRitualKnown(val, key)) { Plugin.LearnRitual(val, key, itemDisplayName); } } val.m_customData[Plugin.CrateMetalSeenKey(text)] = "1"; } } [HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[] { typeof(Inventory), typeof(ItemData) })] internal class RitualDiscoveryChestPatch { private static void Postfix(Inventory __instance, ItemData item) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || __instance != ((Humanoid)localPlayer).GetInventory() || !Plugin.Cfg.Rituals.Enabled) { return; } GameObject dropPrefab = item.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; if (string.IsNullOrEmpty(text)) { return; } (string, bool, string, string)[] ritualItemMap = Plugin.RitualItemMap; for (int i = 0; i < ritualItemMap.Length; i++) { var (text2, flag, key, itemDisplayName) = ritualItemMap[i]; if ((flag ? text.StartsWith(text2) : (text == text2)) && Plugin.Cfg.Rituals.Items.TryGetValue(key, out RitualItemConfig value) && value.Enabled && !Plugin.IsRitualKnown(localPlayer, key)) { Plugin.LearnRitual(localPlayer, key, itemDisplayName); } } localPlayer.m_customData[Plugin.CrateMetalSeenKey(text)] = "1"; } } [HarmonyPatch(typeof(Player), "OnSpawned")] internal class RitualBackfillPatch { private static void Postfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } Plugin.RegisterCrateRecipe(ObjectDB.instance, ZNetScene.instance); if (!Plugin.Cfg.Rituals.Enabled) { return; } Inventory inventory = ((Humanoid)__instance).GetInventory(); if (inventory == null) { return; } if (__instance.m_customData.TryGetValue("ath_legendary_key", out var legKey) && __instance.m_customData.TryGetValue("ath_legendary_expiry", out var value) && long.TryParse(value, out var result)) { long num = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); Plugin.LegendaryDef def = Array.Find(Plugin.LegendaryDefs, (Plugin.LegendaryDef d) => d.Key == legKey); if (num >= result || def.Prefab == null) { ItemData val = ((IEnumerable)inventory.GetAllItems()).FirstOrDefault((Func)delegate(ItemData i) { GameObject dropPrefab2 = i.m_dropPrefab; return ((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null) == def.Prefab; }); if (val != null) { ((Humanoid)__instance).UnequipItem(val, true); inventory.RemoveItem(val); } __instance.m_customData.TryGetValue("ath_legendary_orig", out var value2); __instance.m_customData.TryGetValue("ath_legendary_orig_level", out var value3); if (!string.IsNullOrEmpty(value2)) { ZNetScene instance = ZNetScene.instance; if ((Object)(object)((instance != null) ? instance.GetPrefab(value2) : null) != (Object)null) { int.TryParse(value3, out var result2); if (result2 < 1) { result2 = 1; } ItemData val2 = inventory.AddItem(value2, 1, result2, 0, 0L, "", false); if (val2 != null) { ((Humanoid)__instance).EquipItem(val2, true); } Plugin.Log.LogInfo((object)$"[Pilgrim] Restored original weapon {value2} q{result2}"); } } __instance.m_customData.Remove("ath_legendary_key"); __instance.m_customData.Remove("ath_legendary_expiry"); __instance.m_customData.Remove("ath_legendary_orig"); __instance.m_customData.Remove("ath_legendary_orig_level"); Plugin.Log.LogInfo((object)("[Pilgrim] Stripped expired legendary " + def.Prefab + " on load")); } else { Plugin._activeLegendaryDef = def; Plugin._legendaryActiveItem = ((IEnumerable)inventory.GetAllItems()).FirstOrDefault((Func)delegate(ItemData i) { GameObject dropPrefab2 = i.m_dropPrefab; return ((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null) == def.Prefab; }); Plugin._legendaryActivePrefab = def.Prefab; Plugin.FlamingSwordExpiry = Time.time + (float)(result - num); Plugin.Log.LogInfo((object)$"[Pilgrim] Restored legendary {def.Prefab} with {result - num}s remaining"); } } foreach (ItemData invItem in inventory.GetAllItems()) { GameObject dropPrefab = invItem.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; if (string.IsNullOrEmpty(text)) { GameObject? obj = ObjectDB.instance?.m_items?.Find((GameObject g) => g.GetComponent()?.m_itemData?.m_shared?.m_name == invItem.m_shared?.m_name); text = ((obj != null) ? ((Object)obj).name : null) ?? ""; } if (string.IsNullOrEmpty(text)) { continue; } (string, bool, string, string)[] ritualItemMap = Plugin.RitualItemMap; for (int num2 = 0; num2 < ritualItemMap.Length; num2++) { var (text2, flag, text3, _) = ritualItemMap[num2]; if (!Plugin.IsRitualKnown(__instance, text3) && Plugin.Cfg.Rituals.Items.TryGetValue(text3, out RitualItemConfig value4) && value4.Enabled && (flag ? text.StartsWith(text2) : (text == text2))) { __instance.m_customData["ath_known_" + text3] = "1"; } } __instance.m_customData[Plugin.CrateMetalSeenKey(text)] = "1"; } } } [HarmonyPatch(typeof(Player), "OnDeath")] internal static class PlayerDeathRelinquishPatch { private static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { Plugin.RelinquishAll(__instance); } } } [HarmonyPatch(typeof(Player), "CreateTombStone")] internal static class CacheSurvivesDeathPatch { private static ItemData? _stashedCache; private static void Prefix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && Plugin.Cfg?.Cache?.SurvivesDeath == true) { Inventory inventory = ((Humanoid)__instance).GetInventory(); _stashedCache = ((IEnumerable)inventory.GetAllItems()).FirstOrDefault((Func)((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache")); if (_stashedCache != null) { inventory.RemoveItem(_stashedCache); } } } private static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && _stashedCache != null) { ((Humanoid)__instance).GetInventory().AddItem(_stashedCache); _stashedCache = null; } } } [HarmonyPatch(typeof(Player), "Update")] internal static class RelinquishKeyPatch { private static float _holdTime = 0f; private static int _lastTick = -1; private static void Postfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Plugin.Cfg.Rituals.Enabled) { return; } if (Plugin.FeatherJumpActive && Time.time > Plugin.FeatherRitualExpiry) { ((Character)__instance).m_jumpForce = ((Character)__instance).m_jumpForce / 1.5f; Plugin.FeatherJumpActive = false; } if (Input.GetKey((KeyCode)122) && Plugin.HasAnyActiveRitual(__instance)) { _holdTime += Time.deltaTime; int num = Mathf.CeilToInt(3f - _holdTime); int num2 = Mathf.FloorToInt(_holdTime); if (num2 != _lastTick) { _lastTick = num2; if (_holdTime < 3f) { ((Character)__instance).Message((MessageType)1, $"Relinquish ritual... {num}", 0, (Sprite)null); } } if (_holdTime >= 3f) { _holdTime = 0f; _lastTick = -1; Plugin.RelinquishAll(__instance); } } else { _holdTime = 0f; _lastTick = -1; } } } [HarmonyPatch(typeof(Player), "Update")] internal static class PlayerHintsTogglePatch { private static void Postfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Plugin.Cfg.Rituals.Enabled) { return; } bool keyDown = Input.GetKeyDown((KeyCode)104); bool keyDown2 = Input.GetKeyDown((KeyCode)114); if (!keyDown && !keyDown2) { return; } GameObject hoverObject = ((Humanoid)__instance).GetHoverObject(); if ((Object)(object)hoverObject == (Object)null) { return; } Fireplace componentInParent = hoverObject.GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || !componentInParent.IsBurning()) { return; } string goName = ((Object)((Component)componentInParent).gameObject).name.ToLower().Replace("(clone)", "").Trim(); if (Array.Exists(Plugin.CampfirePrefabs, (string p) => goName.StartsWith(p))) { if (keyDown) { Plugin.ShowHintsEnabled = !Plugin.ShowHintsEnabled; ((Character)__instance).Message((MessageType)1, Plugin.ShowHintsEnabled ? "Offerings shown." : "Offerings hidden.", 0, (Sprite)null); } else if (keyDown2 && Plugin.ShowHintsEnabled) { Plugin.HintPage++; } } } } [HarmonyPatch(typeof(MessageHud), "ShowMessage")] internal static class MessageHudTimerPatch { internal static bool ExtendNextCenter; private static void Postfix(MessageHud __instance, MessageType type) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if (ExtendNextCenter && (int)type == 2) { ExtendNextCenter = false; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic; if (typeof(MessageHud).GetField("_crossFadeTextBuffer", bindingAttr)?.GetValue(__instance) is IList { Count: >0 } list) { object obj = list[list.Count - 1]; obj?.GetType().GetField("time")?.SetValue(obj, 8f); } } } } internal static class ItemUtil { internal static string PrefabName(ItemData item) { if ((Object)(object)item.m_dropPrefab != (Object)null) { return ((Object)item.m_dropPrefab).name; } GameObject? obj = ObjectDB.instance?.m_items?.Find((GameObject g) => g.GetComponent()?.m_itemData?.m_shared?.m_name == item.m_shared?.m_name); return ((obj != null) ? ((Object)obj).name : null) ?? ""; } public static int CountByPrefab(Inventory inv, string prefab) { return (from i in inv.GetAllItems() where PrefabName(i) == prefab select i).Sum((ItemData i) => i.m_stack); } public static void RemoveByPrefab(Inventory inv, string prefab, int amount) { foreach (ItemData item in (from i in inv.GetAllItems() where PrefabName(i) == prefab select i).ToList()) { int num = Mathf.Min(amount, item.m_stack); item.m_stack -= num; amount -= num; if (item.m_stack <= 0) { inv.RemoveItem(item); } if (amount <= 0) { break; } } } } internal static class CartUpgrade { public const int BaseWidth = 6; public static readonly int[] Heights = new int[11] { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; internal static readonly (string item, int amount)[][] Costs = new(string, int)[10][] { new(string, int)[2] { ("Wood", 20), ("BronzeNails", 20) }, new(string, int)[2] { ("RoundLog", 20), ("BronzeNails", 20) }, new(string, int)[2] { ("FineWood", 10), ("BronzeNails", 20) }, new(string, int)[2] { ("FineWood", 20), ("BronzeNails", 20) }, new(string, int)[2] { ("ElderBark", 20), ("IronNails", 20) }, new(string, int)[2] { ("Chain", 8), ("IronNails", 20) }, new(string, int)[2] { ("Silver", 10), ("IronNails", 20) }, new(string, int)[3] { ("LinenThread", 10), ("BlackMetal", 10), ("IronNails", 20) }, new(string, int)[3] { ("YggdrasilWood", 20), ("Copper", 5), ("IronNails", 20) }, new(string, int)[2] { ("AshWood", 20), ("Flametal", 5) } }; private static readonly Color[] LevelTints = (Color[])(object)new Color[11] { new Color(1f, 1f, 1f), new Color(1f, 0.82f, 0.55f), new Color(0.55f, 0.38f, 0.22f), new Color(0.95f, 0.88f, 0.72f), new Color(0.88f, 0.78f, 0.58f), new Color(0.4f, 0.45f, 0.35f), new Color(0.55f, 0.57f, 0.6f), new Color(0.88f, 0.94f, 1f), new Color(0.25f, 0.22f, 0.2f), new Color(0.45f, 0.55f, 0.75f), new Color(0.8f, 0.4f, 0.15f) }; private static readonly BindingFlags _rf = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static FieldInfo? _wf; private static FieldInfo? _hf; internal static string DisplayName(string prefab) { return prefab switch { "RoundLog" => "Core Wood", "BronzeNails" => "Bronze Nails", "IronNails" => "Iron Nails", "FineWood" => "Fine Wood", "ElderBark" => "Elder Bark", "LinenThread" => "Linen Thread", "BlackMetal" => "Black Metal", "YggdrasilWood" => "Yggdrasil Wood", "AshWood" => "Ash Wood", _ => prefab, }; } public static void ApplyTint(Vagon vagon, int level) { //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_004e: Unknown result type (might be due to invalid IL or missing references) level = Mathf.Clamp(level, 0, LevelTints.Length - 1); Color color = LevelTints[level]; Renderer[] componentsInChildren = ((Component)vagon).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] materials = componentsInChildren[i].materials; foreach (Material val in materials) { if (val.HasProperty("_Color")) { val.color = color; } } } } public static bool ResizeInventory(Inventory inv, int level) { level = Mathf.Clamp(level, 0, Heights.Length - 1); if ((object)_wf == null) { _wf = typeof(Inventory).GetField("m_width", _rf); } if ((object)_hf == null) { _hf = typeof(Inventory).GetField("m_height", _rf); } if (_wf == null || _hf == null) { return false; } _wf.SetValue(inv, 6); _hf.SetValue(inv, Heights[level]); return true; } public static void ApplySize(Vagon vagon, int level) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) level = Mathf.Clamp(level, 0, Heights.Length - 1); object? obj = typeof(Vagon).GetField("m_container", _rf)?.GetValue(vagon); object? obj2 = ((obj is Container) ? obj : null); Inventory val = ((obj2 != null) ? ((Container)obj2).GetInventory() : null); if (val == null) { Plugin.Log.LogWarning((object)"[EnvR] Could not get cart inventory via m_container"); return; } if (!ResizeInventory(val, level)) { Plugin.Log.LogWarning((object)"[EnvR] Inventory m_width/m_height fields not found"); return; } val.m_onChanged?.Invoke(); Plugin.BroadcastVfx(((Component)vagon).transform.position, "vfx_Place_cart", 0f); InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance != (Object)null && instance.IsContainerOpen()) { instance.Hide(); } } public static int CountByPrefab(Inventory inv, string prefab) { return ItemUtil.CountByPrefab(inv, prefab); } public static void RemoveByPrefab(Inventory inv, string prefab, int amount) { ItemUtil.RemoveByPrefab(inv, prefab, amount); } public static void Upgrade(Player player, Vagon cart, ConsoleEventArgs? args = null) { ZNetView component = ((Component)cart).GetComponent(); if ((Object)(object)component == (Object)null) { if (args != null) { args.Context.AddString("Cart has no network view."); } return; } ZDO zDO = component.GetZDO(); int num = ((zDO != null) ? zDO.GetInt("ath_cart_level", 0) : 0); int num2 = num + 1; if (num2 >= Heights.Length) { string text = "The cart is already fully reinforced."; if (args != null) { args.Context.AddString(text); } else { ((Character)player).Message((MessageType)2, text, 0, (Sprite)null); } return; } (string, int)[] array = Costs[num]; Inventory inventory = ((Humanoid)player).GetInventory(); (string, int)[] array2 = array; for (int i = 0; i < array2.Length; i++) { var (prefab, num3) = array2[i]; if (CountByPrefab(inventory, prefab) < num3) { string text2 = "You lack the " + DisplayName(prefab) + "."; if (args != null) { args.Context.AddString(text2); } else { ((Character)player).Message((MessageType)2, text2, 0, (Sprite)null); } return; } } array2 = array; for (int i = 0; i < array2.Length; i++) { var (prefab2, amount) = array2[i]; RemoveByPrefab(inventory, prefab2, amount); } component.ClaimOwnership(); component.GetZDO().Set("ath_cart_level", num2); ApplySize(cart, num2); ApplyTint(cart, num2); _ = Heights[num2]; string text3 = "Cart reinforced."; if (args != null) { args.Context.AddString(text3); } ((Character)player).Message((MessageType)2, text3, 0, (Sprite)null); } public static Vagon? FindNearest(Player player, float maxDist = 5f) { //IL_0019: 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) Vagon result = null; float num = maxDist; Vagon[] array = Object.FindObjectsOfType(); foreach (Vagon val in array) { float num2 = Vector3.Distance(((Component)player).transform.position, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } return result; } } public class EnvScheduler : MonoBehaviour { public bool Active; public float Probability = 0.6f; public List NightPool = new List { "DreamWalk", "VoidWhisper", "MidnightVeil" }; public List NoonPool = new List { "Twilight_Clear", "PilgrimDawn", "TropicalHaze" }; private bool _lastNight; private bool _noonRolled; private string? _setByUs; private long _lastNightPeriod = -1L; private long _lastNoonPeriod = -1L; private readonly Random _rng = new Random(); private static readonly KeyCode[] HotbarKeys; public void RunDelayed(float delay, Action action) { ((MonoBehaviour)this).StartCoroutine(DelayedAction(delay, action)); } private IEnumerator DelayedAction(float delay, Action action) { yield return (object)new WaitForSeconds(delay); action(); } private void Update() { //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_0668: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06dd: Unknown result type (might be due to invalid IL or missing references) //IL_06e7: Unknown result type (might be due to invalid IL or missing references) //IL_074f: Unknown result type (might be due to invalid IL or missing references) if (Plugin.RitualCooldownRemaining > 0f) { Plugin.RitualCooldownRemaining -= Time.deltaTime; } if (Plugin.ClearSkiesExpiry > 0f) { EnvMan instance = EnvMan.instance; if (Time.time >= Plugin.ClearSkiesExpiry) { if ((Object)(object)instance != (Object)null && instance.m_debugEnv == "Clear") { Plugin.BroadcastEnv(""); } Plugin.ClearSkiesExpiry = 0f; Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, "The skies begin to darken again.", 0, (Sprite)null); } } else if ((Object)(object)instance != (Object)null && instance.m_debugEnv != "Clear") { Plugin.ClearSkiesExpiry = 0f; } } if (Plugin.GiantRainExpiry > 0f) { EnvMan instance2 = EnvMan.instance; if (Time.time >= Plugin.GiantRainExpiry) { if ((Object)(object)instance2 != (Object)null && instance2.m_debugEnv == "Rain") { Plugin.BroadcastEnv(""); } Plugin.GiantRainExpiry = 0f; } else if ((Object)(object)instance2 != (Object)null && instance2.m_debugEnv != "Rain") { Plugin.GiantRainExpiry = 0f; } } if (Plugin.RainExpiry > 0f) { EnvMan instance3 = EnvMan.instance; if (Time.time >= Plugin.RainExpiry) { if ((Object)(object)instance3 != (Object)null && instance3.m_debugEnv == "Rain") { Plugin.BroadcastEnv(""); } Plugin.RainExpiry = 0f; Player localPlayer2 = Player.m_localPlayer; if (localPlayer2 != null) { ((Character)localPlayer2).Message((MessageType)1, "The rain passes.", 0, (Sprite)null); } } else if ((Object)(object)instance3 != (Object)null && instance3.m_debugEnv != "Rain") { Plugin.RainExpiry = 0f; } } if (Plugin.SeekEnvExpiry > 0f) { EnvMan instance4 = EnvMan.instance; if (Time.time >= Plugin.SeekEnvExpiry) { if ((Object)(object)instance4 != (Object)null && instance4.m_debugEnv == "LastLight") { instance4.m_debugEnv = ""; } Plugin.SeekEnvExpiry = 0f; } else if ((Object)(object)instance4 != (Object)null && instance4.m_debugEnv != "LastLight") { Plugin.SeekEnvExpiry = 0f; } } if (Plugin.DungeonEnvExpiry > 0f) { EnvMan instance5 = EnvMan.instance; if (Time.time >= Plugin.DungeonEnvExpiry) { if ((Object)(object)instance5 != (Object)null && instance5.m_debugEnv == "VoidWhisper") { instance5.m_debugEnv = ""; } Plugin.DungeonEnvExpiry = 0f; } else if ((Object)(object)instance5 != (Object)null && instance5.m_debugEnv != "VoidWhisper") { Plugin.DungeonEnvExpiry = 0f; } } if (Plugin.HomeEnvExpiry > 0f) { EnvMan instance6 = EnvMan.instance; if (Time.time >= Plugin.HomeEnvExpiry) { if ((Object)(object)instance6 != (Object)null && instance6.m_debugEnv == "DreamWalk") { instance6.m_debugEnv = ""; } Plugin.HomeEnvExpiry = 0f; } else if ((Object)(object)instance6 != (Object)null && instance6.m_debugEnv != "DreamWalk") { Plugin.HomeEnvExpiry = 0f; } } if (Plugin.GiantExpiry > 0f && Time.time >= Plugin.GiantExpiry) { Player localPlayer3 = Player.m_localPlayer; if ((Object)(object)localPlayer3 != (Object)null) { Plugin.DeactivateGiant(localPlayer3); } else { Plugin.GiantExpiry = 0f; Plugin.GiantTargetScale = 1f; } } if (Plugin.BurdenExpiry > 0f && Time.time >= Plugin.BurdenExpiry) { Player localPlayer4 = Player.m_localPlayer; if ((Object)(object)localPlayer4 != (Object)null) { Plugin.DeactivateBurden(localPlayer4); } else { Plugin.BurdenExpiry = 0f; } } if (Plugin.FlamingSwordExpiry > 0f && Time.time >= Plugin.FlamingSwordExpiry) { Player localPlayer5 = Player.m_localPlayer; if ((Object)(object)localPlayer5 != (Object)null) { Plugin.DeactivateLegendaryWeapon(localPlayer5); } else { Plugin.FlamingSwordExpiry = 0f; } } Player localPlayer6 = Player.m_localPlayer; if ((Object)(object)localPlayer6 != (Object)null) { ZNetView component = ((Component)localPlayer6).GetComponent(); ZDO val = ((component != null) ? component.GetZDO() : null); if (val != null) { val.Set("ath_scale", Plugin.GiantTargetScale); } } foreach (Player allPlayer in Player.GetAllPlayers()) { if (!((Object)(object)allPlayer == (Object)null)) { ZNetView component2 = ((Component)allPlayer).GetComponent(); float? obj; if (component2 == null) { obj = null; } else { ZDO zDO = component2.GetZDO(); obj = ((zDO != null) ? new float?(zDO.GetFloat("ath_scale", 1f)) : ((float?)null)); } float num = obj ?? 1f; float x = ((Component)allPlayer).transform.localScale.x; if (!Mathf.Approximately(x, num)) { float num2 = Mathf.MoveTowards(x, num, Time.deltaTime * 0.4f); ((Component)allPlayer).transform.localScale = Vector3.one * num2; } } } if (Plugin.WaterWalkExpiry > 0f) { if (Time.time >= Plugin.WaterWalkExpiry) { Plugin.WaterWalkExpiry = 0f; EnvMan instance7 = EnvMan.instance; if (instance7 != null) { instance7.ResetDebugWind(); } Player localPlayer7 = Player.m_localPlayer; if ((Object)(object)localPlayer7 != (Object)null) { SEMan sEMan = ((Character)localPlayer7).GetSEMan(); SE_WaterWalk? waterWalkSE = Plugin.WaterWalkSE; sEMan.RemoveStatusEffect((waterWalkSE != null) ? ((StatusEffect)waterWalkSE).NameHash() : 0, false); ((Character)localPlayer7).Message((MessageType)1, "The sea stirs once more.", 0, (Sprite)null); } } Player localPlayer8 = Player.m_localPlayer; if ((Object)(object)localPlayer8 != (Object)null && Plugin.WaterWalkExpiry > 0f) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic; typeof(Character).GetField("m_inWater", bindingAttr)?.SetValue(localPlayer8, false); typeof(Character).GetField("m_swimming", bindingAttr)?.SetValue(localPlayer8, false); object? obj2 = typeof(Character).GetField("m_body", bindingAttr)?.GetValue(localPlayer8); Rigidbody val2 = (Rigidbody)((obj2 is Rigidbody) ? obj2 : null); if (val2 != null) { WaterVolume val3 = null; float num3 = Floating.GetWaterLevel(((Component)localPlayer8).transform.position, ref val3) - ((Component)localPlayer8).transform.position.y; bool flag = num3 > -0.02f; if (num3 > 0.05f && val2.velocity.y <= 0f) { val2.velocity = new Vector3(val2.velocity.x, Mathf.Min(num3 * 10f, 5f), val2.velocity.z); } else if (flag && val2.velocity.y < 0f) { val2.velocity = new Vector3(val2.velocity.x, 0f, val2.velocity.z); } if (flag && val2.velocity.y <= 0f) { typeof(Character).GetField("m_groundContact", bindingAttr)?.SetValue(localPlayer8, true); typeof(Character).GetField("m_groundContactNormal", bindingAttr)?.SetValue(localPlayer8, Vector3.up); } } } } Player localPlayer9 = Player.m_localPlayer; if ((Object)(object)localPlayer9 == (Object)null) { return; } Vagon[] array; if (Input.GetKeyDown((KeyCode)103)) { Vagon val4 = null; float num4 = 15f; array = Object.FindObjectsOfType(); foreach (Vagon val5 in array) { float num5 = Vector3.Distance(((Component)localPlayer9).transform.position, ((Component)val5).transform.position); if (num5 < num4) { num4 = num5; val4 = val5; } } if ((Object)(object)val4 != (Object)null) { val4.Interact((Humanoid)(object)localPlayer9, false, false); ((Character)localPlayer9).Message((MessageType)1, "Cart released.", 0, (Sprite)null); } else { ((Character)localPlayer9).Message((MessageType)1, "[G] No cart nearby.", 0, (Sprite)null); } } if (!Input.GetKeyDown((KeyCode)98)) { return; } Vagon val6 = null; array = Object.FindObjectsOfType(); foreach (Vagon val7 in array) { if (val7.IsAttached((Character)(object)localPlayer9)) { val6 = val7; break; } } if ((Object)(object)val6 != (Object)null) { ZNetView component3 = ((Component)val6).GetComponent(); if ((Object)(object)component3 != (Object)null && component3.IsValid()) { component3.ClaimOwnership(); ZDO zDO2 = component3.GetZDO(); bool flag2 = zDO2 != null && zDO2.GetBool("ath_cart_brake", false); component3.GetZDO().Set("ath_cart_brake", !flag2); ((Character)localPlayer9).Message((MessageType)1, (!flag2) ? "Handbrake ON." : "Handbrake OFF.", 0, (Sprite)null); } } } private void Start() { ((MonoBehaviour)this).StartCoroutine(Loop()); } public void SendBird(Vector3 direction, float speed = 10f) { //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_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_010c: 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_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_0124: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0140: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_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_0168: 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_0172: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_01a0: 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_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_01bb: 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_01c3: 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_01d8: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: 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_021b: 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_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027d: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: 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_02a1: 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_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: 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_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: 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_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: 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_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: 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_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0341: 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_034c: 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_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: 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_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0381: 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_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: 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_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: 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_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041d: 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_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: 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_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_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0459: 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_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047c: 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_0486: Unknown result type (might be due to invalid IL or missing references) //IL_0490: 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_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: 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_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: 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_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04da: 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_04ef: 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) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0520: 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_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: 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_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: 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_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: 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_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0638: 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_0056: 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_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_00f0: 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) Vector3 normalized = ((Vector3)(ref direction)).normalized; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { MonoBehaviour[] array = Object.FindObjectsOfType(); foreach (MonoBehaviour val in array) { if (!((Object)(object)val == (Object)null) && !(((object)val).GetType().Name != "RandomFlyingBird") && !(Vector3.Distance(((Component)val).transform.position, ((Component)localPlayer).transform.position) > 150f)) { ((MonoBehaviour)this).StartCoroutine(DelayedRedirect(((Component)val).gameObject, normalized, speed, 10f)); } } } ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance != (Object)null && (Object)(object)localPlayer != (Object)null) { GameObject prefab = instance.GetPrefab("sfx_crow_death"); if ((Object)(object)prefab != (Object)null) { for (int j = 0; j < 3; j++) { Object.Instantiate(prefab, ((Component)localPlayer).transform.position + Random.insideUnitSphere * 3f, Quaternion.identity); } } } Vector3 val2 = Vector3.Cross(Vector3.up, normalized); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; Vector3[] array2 = (Vector3[])(object)new Vector3[30] { Vector3.zero, -normalized2 * 3f + normalized * -4f, normalized2 * 3f + normalized * -4f, -normalized2 * 6f + normalized * -8f, normalized2 * 6f + normalized * -8f, -normalized2 * 9f + normalized * -12f, normalized2 * 9f + normalized * -12f, -normalized2 * 12f + normalized * -16f, normalized2 * 12f + normalized * -16f, -normalized2 * 2f + normalized * -6f, normalized2 * 2f + normalized * -6f, -normalized2 * 5f + normalized * -10f, normalized2 * 5f + normalized * -10f, -normalized2 * 8f + normalized * -14f, normalized2 * 8f + normalized * -14f, -normalized2 * 11f + normalized * -18f, normalized2 * 11f + normalized * -18f, -normalized2 * 14f + normalized * -20f, normalized2 * 14f + normalized * -20f, Vector3.up * 4f + normalized * -2f, -normalized2 * 4f + normalized * -5f + Vector3.up * 1.5f, normalized2 * 4f + normalized * -5f + Vector3.up * 1.5f, -normalized2 * 7f + normalized * -9f + Vector3.up * 1f, normalized2 * 7f + normalized * -9f + Vector3.up * 1f, -normalized2 * 10f + normalized * -13f + Vector3.up * 2f, normalized2 * 10f + normalized * -13f + Vector3.up * 2f, -normalized2 * 13f + normalized * -17f + Vector3.up * 1f, normalized2 * 13f + normalized * -17f + Vector3.up * 1f, -normalized2 * 1f + normalized * -3f + Vector3.up * 2.5f, normalized2 * 1f + normalized * -3f + Vector3.up * 2.5f }; for (int k = 0; k < array2.Length; k++) { ((MonoBehaviour)this).StartCoroutine(SingleBird(normalized, speed, array2[k], 3f + (float)k * 0.25f)); } } private IEnumerator DelayedRedirect(GameObject bird, Vector3 dir, float speed, float delay) { //IL_0015: 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) yield return (object)new WaitForSeconds(delay); if ((Object)(object)bird != (Object)null) { ((MonoBehaviour)this).StartCoroutine(RedirectWorldBird(bird, dir, speed)); } } private IEnumerator RedirectWorldBird(GameObject bird, Vector3 dir, float speed) { //IL_000e: 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) if ((Object)(object)bird == (Object)null) { yield break; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; MonoBehaviour[] componentsInChildren = bird.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !(((object)val).GetType().Name != "RandomFlyingBird")) { object? obj = ((object)val).GetType().GetField("m_flyingModel", bindingAttr)?.GetValue(val); GameObject val2 = (GameObject)((obj is GameObject) ? obj : null); object? obj2 = ((object)val).GetType().GetField("m_landedModel", bindingAttr)?.GetValue(val); GameObject val3 = (GameObject)((obj2 is GameObject) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { val2.SetActive(true); } if ((Object)(object)val3 != (Object)null) { val3.SetActive(false); } break; } } string[] array = new string[3] { "RandomFlyingBird", "ZSyncAnimation", "ZSFX" }; componentsInChildren = bird.GetComponentsInChildren(true); foreach (MonoBehaviour val4 in componentsInChildren) { if ((Object)(object)val4 != (Object)null && Array.IndexOf(array, ((object)val4).GetType().Name) >= 0) { ((Behaviour)val4).enabled = false; } } BaseAI[] componentsInChildren2 = bird.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } Component[] componentsInChildren3 = bird.GetComponentsInChildren(); foreach (Component val5 in componentsInChildren3) { MethodInfo methodInfo = ((object)val5)?.GetType().GetMethod("SetBool", new Type[2] { typeof(string), typeof(bool) }); if (methodInfo != null) { methodInfo.Invoke(val5, new object[2] { "flapping", true }); break; } } yield return (object)new WaitForSeconds(0.3f); if ((Object)(object)bird == (Object)null) { yield break; } float elapsed = 0f; float wobbleOffset = Random.Range(0f, MathF.PI * 2f); while ((Object)(object)bird != (Object)null && elapsed < 200f / speed) { elapsed += Time.deltaTime; Vector3 val6 = Vector3.Cross(Vector3.up, dir); if (((Vector3)(ref val6)).sqrMagnitude < 0.001f) { val6 = Vector3.right; } else { ((Vector3)(ref val6)).Normalize(); } Vector3 val7 = val6 * Mathf.Sin(elapsed * 1.3f + wobbleOffset) * 0.4f + Vector3.up * Mathf.Sin(elapsed * 0.9f + wobbleOffset + 1f) * 0.2f; Transform transform = bird.transform; transform.position += (dir + val7) * speed * Time.deltaTime; Vector3 val8 = dir + val7 * 0.5f; if (((Vector3)(ref val8)).sqrMagnitude > 0.001f) { bird.transform.rotation = Quaternion.LookRotation(val8); } yield return null; } if (!((Object)(object)bird != (Object)null)) { yield break; } if ((Object)(object)ZNetScene.instance != (Object)null) { MethodInfo methodInfo2 = null; MethodInfo[] methods = typeof(ZNetScene).GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo3 in methods) { if (!(methodInfo3.Name != "Destroy")) { ParameterInfo[] parameters = methodInfo3.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == typeof(GameObject)) { methodInfo2 = methodInfo3; break; } } } if (methodInfo2 != null) { methodInfo2.Invoke(ZNetScene.instance, new object[1] { bird }); } else { Object.Destroy((Object)(object)bird); } } else { Object.Destroy((Object)(object)bird); } } private IEnumerator SingleBird(Vector3 dir, float speed, Vector3 formationOffset, float delay) { //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_0015: 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) ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { yield break; } GameObject prefab = instance.GetPrefab("Crow"); if ((Object)(object)prefab == (Object)null) { yield break; } Player player = Player.m_localPlayer; if ((Object)(object)player == (Object)null) { yield break; } yield return (object)new WaitForSeconds(delay); float num = Random.Range(22f, 28f); Vector3 val = ((Component)player).transform.position + Vector3.up * num - dir * 100f + formationOffset; prefab.SetActive(false); GameObject bird = Object.Instantiate(prefab, val, Quaternion.LookRotation(dir)); prefab.SetActive(true); string[] array = new string[5] { "ZNetView", "ZSyncAnimation", "ZSyncTransform", "RandomFlyingBird", "ZSFX" }; MonoBehaviour[] componentsInChildren = bird.GetComponentsInChildren(true); foreach (MonoBehaviour val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && Array.IndexOf(array, ((object)val2).GetType().Name) >= 0) { Object.DestroyImmediate((Object)(object)val2); } } ZNetView[] componentsInChildren2 = bird.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } BaseAI[] componentsInChildren3 = bird.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Behaviour)componentsInChildren3[i]).enabled = false; } bird.SetActive(true); Component val3 = ((IEnumerable)bird.GetComponentsInChildren()).FirstOrDefault((Func)((Component c) => ((object)c).GetType().Name == "Animator")); ((object)val3)?.GetType().GetMethod("SetBool", new Type[2] { typeof(string), typeof(bool) })?.Invoke(val3, new object[2] { "flapping", true }); float elapsed = 0f; float wobbleOffset = Random.Range(0f, MathF.PI * 2f); while ((Object)(object)bird != (Object)null && elapsed < 250f / speed) { elapsed += Time.deltaTime; Vector3 val4 = Vector3.Cross(Vector3.up, dir); if (((Vector3)(ref val4)).sqrMagnitude < 0.001f) { val4 = Vector3.right; } else { ((Vector3)(ref val4)).Normalize(); } Vector3 val5 = val4 * Mathf.Sin(elapsed * 1.3f + wobbleOffset) * 0.4f + Vector3.up * Mathf.Sin(elapsed * 0.9f + wobbleOffset + 1f) * 0.2f; Transform transform = bird.transform; transform.position += (dir + val5) * speed * Time.deltaTime; Vector3 val6 = dir + val5 * 0.5f; if (((Vector3)(ref val6)).sqrMagnitude > 0.001f) { bird.transform.rotation = Quaternion.LookRotation(val6); } yield return null; } if ((Object)(object)bird != (Object)null) { Object.Destroy((Object)(object)bird); } } private IEnumerator Loop() { yield return (object)new WaitForSeconds(10f); while (true) { yield return (object)new WaitForSeconds(5f); if (!Active || (Object)(object)EnvMan.instance == (Object)null || (Object)(object)ZNet.instance == (Object)null) { continue; } bool flag = EnvMan.IsNight(); float tod = Plugin.GetTod(); long num = (long)(ZNet.instance.GetTimeSeconds() / 1800.0); if (flag) { if (_lastNightPeriod != num) { _lastNightPeriod = num; ClearIfOurs(); TrySet(NightPool); } } else { if (_lastNight) { ClearIfOurs(); } if (tod >= 0.47f && tod <= 0.53f && _lastNoonPeriod != num) { _lastNoonPeriod = num; ClearIfOurs(); TrySet(NoonPool); } } _lastNight = flag; } } private void TrySet(List pool) { if (pool.Count != 0 && !(_rng.NextDouble() > (double)Probability) && (!(Plugin.ClearSkiesExpiry > 0f) || !(Time.time < Plugin.ClearSkiesExpiry)) && (!(Plugin.RainExpiry > 0f) || !(Time.time < Plugin.RainExpiry))) { string text = pool[_rng.Next(pool.Count)]; EnvMan.instance.m_debugEnv = text; _setByUs = text; } } private void ClearIfOurs() { EnvMan instance = EnvMan.instance; if ((Object)(object)instance != (Object)null && instance.m_debugEnv == _setByUs) { instance.m_debugEnv = ""; } _setByUs = null; } static EnvScheduler() { KeyCode[] array = new KeyCode[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); HotbarKeys = (KeyCode[])(object)array; } } internal class PilgrimCrateMarker : MonoBehaviour { private void Update() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ((Component)this).transform.position = ((Component)localPlayer).transform.position; } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class CrateCopyDbPatch { private static void Postfix(ObjectDB __instance) { Plugin.RegisterCrateItem(__instance); Plugin.RegisterCrateRecipe(__instance, ZNetScene.instance); } } [HarmonyPatch(typeof(ZNetView), "Awake")] internal static class CratePrefabZNetViewPatch { private static bool Prefix() { return !Plugin._suppressZNetViewAwake; } } [HarmonyPatch(typeof(ObjectDB), "GetItemPrefab", new Type[] { typeof(string) })] internal static class CrateGetItemPrefabPatch { private static void Postfix(string name, ref GameObject __result) { if ((Object)(object)__result == (Object)null && (name == "Pilgrim's Cache" || name == "PilgrimCrate") && (Object)(object)Plugin._cratePrefabGo != (Object)null) { __result = Plugin._cratePrefabGo; } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class CrateZNetScenePatch { private static void Postfix(ZNetScene __instance) { if ((Object)(object)Plugin._cratePrefabGo != (Object)null) { Plugin.AddCrateToZNetScene(Plugin._cratePrefabGo); } ObjectDB db = ObjectDB.instance ?? Object.FindObjectOfType(); Plugin.RegisterCrateItem(db); Plugin.RegisterCrateRecipe(db, __instance); } } [HarmonyPatch(typeof(Container), "Awake")] internal static class FakeContainerAwakePatch { private static bool Prefix() { return !Plugin._suppressContainerAwake; } } [HarmonyPatch(typeof(Container), "Save")] internal static class FakeContainerSavePatch { private static bool Prefix(Container __instance) { if (Plugin._crateUIOpen) { return !((Object)(object)__instance == (Object)(object)Plugin._fakeCrateContainer); } return true; } } [HarmonyPatch(typeof(Container), "Load")] internal static class FakeContainerLoadPatch { private static bool Prefix(Container __instance) { if (Plugin._crateUIOpen) { return !((Object)(object)__instance == (Object)(object)Plugin._fakeCrateContainer); } return true; } } [HarmonyPatch(typeof(Container), "IsOwner")] internal static class FakeContainerIsOwnerPatch { private static bool Prefix(Container __instance, ref bool __result) { if (!Plugin._crateUIOpen) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(Container), "IsInUse")] internal static class FakeContainerIsInUsePatch { private static bool Prefix(Container __instance, ref bool __result) { if (!Plugin._crateUIOpen) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Container), "SetInUse")] internal static class FakeContainerSetInUsePatch { private static bool Prefix(Container __instance) { return !Plugin._crateUIOpen; } } [HarmonyPatch(typeof(Humanoid), "UseItem", new Type[] { typeof(Inventory), typeof(ItemData), typeof(bool) })] internal static class CrateUseItemPatch { private static readonly BindingFlags RF = BindingFlags.Instance | BindingFlags.NonPublic; private static bool Prefix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return true; } if (item?.m_shared?.m_name != "Pilgrim's Cache") { return true; } if (Plugin._crateUIOpen) { Plugin.SaveAndCloseCrateUI(); } else { object? obj = typeof(InventoryGui).GetField("m_currentContainer", RF)?.GetValue(InventoryGui.instance); Container val2 = (Container)((obj is Container) ? obj : null); Plugin._previousContainer = (((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)Plugin._fakeCrateContainer) ? val2 : null); Plugin.OpenCrateUI(val, item); } return false; } } [HarmonyPatch(typeof(Inventory), "GetTotalWeight")] internal static class CrateWeightPatch { private static void Postfix(Inventory __instance, ref float __result) { if (!(Plugin.Cfg?.Cache?.WeightContents ?? true)) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Humanoid)localPlayer).GetInventory() != __instance) { return; } foreach (ItemData allItem in __instance.GetAllItems()) { if (!(allItem.m_shared.m_name != "Pilgrim's Cache") && allItem.m_customData.TryGetValue("pilgrim_crate_weight", out var value) && float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { float num = Mathf.Clamp01(Plugin.Cfg?.Cache?.WeightScale ?? 1f); __result += result * num; } } } } [HarmonyPatch(typeof(InventoryGui), "UpdateContainerWeight")] internal static class CrateContainerWeightDisplayPatch { private static void Postfix(InventoryGui __instance) { if ((Object)(object)Plugin._fakeCrateContainer == (Object)null) { return; } object? obj = typeof(InventoryGui).GetField("m_currentContainer", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance); Container val = (Container)((obj is Container) ? obj : null); if (val == null || (Object)(object)val != (Object)(object)Plugin._fakeCrateContainer) { return; } float num = Mathf.Clamp01(Plugin.Cfg?.Cache?.WeightScale ?? 1f); if (!Mathf.Approximately(num, 1f)) { object obj2 = typeof(InventoryGui).GetField("m_containerWeight", BindingFlags.Instance | BindingFlags.Public)?.GetValue(__instance); if (obj2 != null) { Inventory? crateInventory = Plugin._crateInventory; float num2 = ((crateInventory != null) ? crateInventory.GetTotalWeight() : 0f); obj2.GetType().GetProperty("text")?.SetValue(obj2, Mathf.CeilToInt(num2 * num).ToString()); } } } } [HarmonyPatch(typeof(Humanoid), "DropItem")] internal static class LegendaryDropBlockPatch { private static bool Prefix(Humanoid __instance, ItemData item, ref bool __result) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return true; } if (Plugin._legendaryActivePrefab == null) { return true; } GameObject dropPrefab = item.m_dropPrefab; if (((dropPrefab != null) ? ((Object)dropPrefab).name : null) != Plugin._legendaryActivePrefab) { return true; } ((Character)val).Message((MessageType)2, "You cannot drop a legendary weapon.", 0, (Sprite)null); __result = false; return false; } } [HarmonyPatch(typeof(InventoryGrid), "DropItem")] internal static class CrateGridDropBlockPatch { private static bool Prefix(InventoryGrid __instance, ItemData item) { if (item?.m_shared?.m_name != "Pilgrim's Cache") { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } if (__instance.GetInventory() != ((Humanoid)localPlayer).GetInventory()) { return true; } if (!((Humanoid)localPlayer).GetInventory().GetAllItems().Any((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache" && i != item)) { return true; } ((Character)localPlayer).Message((MessageType)2, "You can only carry one Pilgrim's Cache.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[] { typeof(Inventory), typeof(ItemData) })] internal static class CrateMoveBlockPatch { private static bool Prefix(Inventory __instance, ItemData item) { if (item?.m_shared?.m_name != "Pilgrim's Cache") { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } if (__instance != ((Humanoid)localPlayer).GetInventory()) { return true; } if (!((Humanoid)localPlayer).GetInventory().GetAllItems().Any((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache" && i != item)) { return true; } ((Character)localPlayer).Message((MessageType)2, "You can only carry one Pilgrim's Cache.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(InventoryGrid), "DropItem")] internal static class LegendaryGridDropBlockPatch { private static bool Prefix(InventoryGrid __instance, ItemData item) { if (Plugin._legendaryActivePrefab == null) { return true; } GameObject dropPrefab = item.m_dropPrefab; if (((dropPrefab != null) ? ((Object)dropPrefab).name : null) != Plugin._legendaryActivePrefab) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } if (__instance.GetInventory() == ((Humanoid)localPlayer).GetInventory()) { return true; } ((Character)localPlayer).Message((MessageType)2, "You cannot transfer a legendary weapon.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[] { typeof(Inventory), typeof(ItemData) })] internal static class LegendaryMoveBlockPatch { private static bool Prefix(Inventory __instance, ItemData item) { if (Plugin._legendaryActivePrefab == null) { return true; } GameObject dropPrefab = item.m_dropPrefab; if (((dropPrefab != null) ? ((Object)dropPrefab).name : null) != Plugin._legendaryActivePrefab) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } if (__instance == ((Humanoid)localPlayer).GetInventory()) { return true; } ((Character)localPlayer).Message((MessageType)2, "You cannot transfer a legendary weapon.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[] { typeof(Inventory), typeof(ItemData), typeof(int), typeof(int), typeof(int) })] internal static class LegendaryMoveBlockPatch2 { private static bool Prefix(Inventory __instance, ItemData item) { if (Plugin._legendaryActivePrefab == null) { return true; } GameObject dropPrefab = item.m_dropPrefab; if (((dropPrefab != null) ? ((Object)dropPrefab).name : null) != Plugin._legendaryActivePrefab) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } if (__instance == ((Humanoid)localPlayer).GetInventory()) { return true; } ((Character)localPlayer).Message((MessageType)2, "You cannot transfer a legendary weapon.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(ItemDrop), "Awake")] internal static class CrateWakeOnLoadPatch { private static void Postfix(ItemDrop __instance) { if (!(__instance.m_itemData?.m_shared?.m_name != "Pilgrim's Cache")) { Rigidbody component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { ((MonoBehaviour)__instance).StartCoroutine(WakeNextFrame(component)); } } } private static IEnumerator WakeNextFrame(Rigidbody rb) { yield return null; if ((Object)(object)rb != (Object)null) { rb.WakeUp(); } } } [HarmonyPatch(typeof(Inventory), "GetAmmoItem")] internal static class CrateAmmoGetPatch { private static void Postfix(Inventory __instance, string ammoName, ref ItemData __result) { if (__result == null) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance == ((Humanoid)localPlayer).GetInventory()) { Inventory crateInvForRead = Plugin.GetCrateInvForRead(localPlayer); __result = ((crateInvForRead != null) ? crateInvForRead.GetAmmoItem(ammoName, (string)null) : null); } } } } [HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(ItemData), typeof(int) })] internal static class CrateAmmoRemovePatch { private static bool Prefix(Inventory __instance, ItemData item, int amount, ref bool __result) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || __instance != ((Humanoid)localPlayer).GetInventory()) { return true; } if (__instance.ContainsItem(item)) { return true; } Inventory crateInvForRead = Plugin.GetCrateInvForRead(localPlayer); if (crateInvForRead == null || !crateInvForRead.ContainsItem(item)) { return true; } crateInvForRead.RemoveItem(item, amount); Plugin.SaveCrateInvIfClosed(localPlayer, crateInvForRead); __result = true; return false; } } [HarmonyPatch(typeof(WearNTear), "ApplyDamage")] internal static class ShipNoPlayerNoDamagePatch { private static bool Prefix(WearNTear __instance) { //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) if (!Plugin.Cfg.Ships.NoDamageFilter) { return true; } bool num = (Object)(object)((Component)__instance).GetComponentInParent() != (Object)null; bool flag = (Object)(object)((Component)__instance).GetComponentInParent() != (Object)null; if (!num && !flag) { return true; } float noDamageRadius = Plugin.Cfg.Ships.NoDamageRadius; foreach (Player allPlayer in Player.GetAllPlayers()) { if (Vector3.Distance(((Component)allPlayer).transform.position, ((Component)__instance).transform.position) <= noDamageRadius) { return true; } } return false; } } [HarmonyPatch(typeof(Inventory), "HaveItem", new Type[] { typeof(string), typeof(bool) })] internal static class CrateHaveItemPatch { private static void Postfix(Inventory __instance, string name, ref bool __result) { if (__result) { return; } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance == ((Humanoid)localPlayer).GetInventory()) { Inventory crateInvForRead = Plugin.GetCrateInvForRead(localPlayer); if (crateInvForRead != null) { __result = crateInvForRead.HaveItem(name, true); } } } } [HarmonyPatch(typeof(Inventory), "CountItems")] internal static class CrateCountForCraftingPatch { private static void Postfix(Inventory __instance, string name, ref int __result) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance == ((Humanoid)localPlayer).GetInventory()) { Inventory crateInvForRead = Plugin.GetCrateInvForRead(localPlayer); if (crateInvForRead != null) { __result += crateInvForRead.CountItems(name, -1, true); } } } } [HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(string), typeof(int), typeof(int), typeof(bool) })] internal static class CrateRemoveForCraftingPatch { private static int _hadBefore; private static void Prefix(Inventory __instance, string name) { _hadBefore = 0; Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance == ((Humanoid)localPlayer).GetInventory()) { _hadBefore = (from i in __instance.GetAllItems() where i.m_shared.m_name == name select i).Sum((ItemData i) => i.m_stack); } } private static void Postfix(Inventory __instance, string name, int amount) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || __instance != ((Humanoid)localPlayer).GetInventory()) { return; } int num = amount - Math.Min(_hadBefore, amount); if (num > 0) { Inventory crateInvForRead = Plugin.GetCrateInvForRead(localPlayer); if (crateInvForRead != null) { crateInvForRead.RemoveItem(name, num, -1, true); Plugin.SaveCrateInvIfClosed(localPlayer, crateInvForRead); } } } } [HarmonyPatch(typeof(Player), "HaveRequirements", new Type[] { typeof(Recipe), typeof(bool), typeof(int), typeof(int) })] internal static class CrateCraftLimitPatch { private static bool Prefix(Player __instance, Recipe recipe, bool discover, int qualityLevel, int amount, ref bool __result) { if ((Object)(object)recipe != (Object)(object)Plugin._crateRecipe) { return true; } if (qualityLevel <= 1) { if (((Humanoid)__instance).GetInventory().GetAllItems().Any((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache")) { __result = false; return false; } __result = ((Humanoid)__instance).GetInventory().CountItems("Copper", -1, true) >= 10 * amount && ((Humanoid)__instance).GetInventory().CountItems("LeatherScraps", -1, true) >= 6 * amount; return false; } if (qualityLevel >= Plugin.CrateUpgrades.Length) { __result = false; return false; } (string prefab, int amount) tuple = Plugin.CrateUpgrades[qualityLevel]; string item = tuple.prefab; int item2 = tuple.amount; __result = !string.IsNullOrEmpty(item) && ((Humanoid)__instance).GetInventory().CountItems(item, -1, true) >= item2 * amount; return false; } } [HarmonyPatch(typeof(Player), "ConsumeResources")] internal static class CrateUpgradeConsumePatch { private static bool Prefix(Player __instance, Requirement[] requirements, int qualityLevel, int itemQuality, int multiplier) { if ((Object)(object)Plugin._crateRecipe == (Object)null || requirements != Plugin._crateRecipe.m_resources) { return true; } if (qualityLevel <= 1) { ((Humanoid)__instance).GetInventory().RemoveItem("Copper", 10 * multiplier, -1, true); ((Humanoid)__instance).GetInventory().RemoveItem("LeatherScraps", 6 * multiplier, -1, true); return false; } if (qualityLevel >= Plugin.CrateUpgrades.Length) { return false; } var (text, num) = Plugin.CrateUpgrades[qualityLevel]; if (!string.IsNullOrEmpty(text)) { ((Humanoid)__instance).GetInventory().RemoveItem(text, num * multiplier, -1, true); } return false; } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] internal static class CrateUpgradeDataPreservePatch { private static Dictionary? _saved; private static bool Prefix(InventoryGui __instance) { _saved = null; FieldInfo? field = typeof(InventoryGui).GetField("m_craftUpgradeItem", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(InventoryGui).GetField("m_craftRecipe", BindingFlags.Instance | BindingFlags.NonPublic); object? obj = field?.GetValue(__instance); ItemData val = (ItemData)((obj is ItemData) ? obj : null); object? obj2 = field2?.GetValue(__instance); Recipe val2 = (Recipe)((obj2 is Recipe) ? obj2 : null); if (val == null && (Object)(object)val2 == (Object)(object)Plugin._crateRecipe) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && ((Humanoid)localPlayer).GetInventory().GetAllItems().Any((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache")) { ((Character)localPlayer).Message((MessageType)2, "You already carry a Pilgrim's Cache.", 0, (Sprite)null); return false; } } if (val?.m_shared?.m_name == "Pilgrim's Cache") { _saved = new Dictionary(val.m_customData); } return true; } private static void Postfix(Player player) { if (_saved == null || (Object)(object)player == (Object)null) { return; } ItemData val = ((IEnumerable)((Humanoid)player).GetInventory().GetAllItems()).FirstOrDefault((Func)((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache")); if (val != null) { foreach (KeyValuePair item in _saved) { val.m_customData[item.Key] = item.Value; } } _saved = null; } } [HarmonyPatch(typeof(InventoryGui), "SetupRequirementList")] internal static class CrateUpgradeUIRequirementsPatch { private static readonly FieldInfo _fSelectedRecipe = typeof(InventoryGui).GetField("m_selectedRecipe", BindingFlags.Instance | BindingFlags.NonPublic); private static void Prefix(InventoryGui __instance, int quality) { //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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown if ((Object)(object)Plugin._crateRecipe == (Object)null || Plugin._crateCraftResources == null) { return; } object obj = _fSelectedRecipe?.GetValue(__instance); object? obj2 = obj?.GetType().GetProperty("Recipe")?.GetValue(obj); if ((Object)((obj2 is Recipe) ? obj2 : null) != (Object)(object)Plugin._crateRecipe) { return; } object? obj3 = obj?.GetType().GetProperty("ItemData")?.GetValue(obj); ItemData val = (ItemData)((obj3 is ItemData) ? obj3 : null); if (val?.m_shared?.m_name == "Pilgrim's Cache") { int num = val.m_quality + 1; if (num < 2 || num >= Plugin.CrateUpgrades.Length) { Plugin._crateRecipe.m_resources = Plugin._crateCraftResources; return; } (string prefab, int amount) tuple = Plugin.CrateUpgrades[num]; string item = tuple.prefab; int item2 = tuple.amount; ObjectDB instance = ObjectDB.instance; object obj4; if (instance == null) { obj4 = null; } else { GameObject itemPrefab = instance.GetItemPrefab(item); obj4 = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); } ItemDrop val2 = (ItemDrop)obj4; if ((Object)(object)val2 == (Object)null) { Plugin._crateRecipe.m_resources = Plugin._crateCraftResources; return; } int amountPerLevel = item2 / (num - 1); Plugin._crateRecipe.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = val2, m_amount = 0, m_amountPerLevel = amountPerLevel } }; } else { Plugin._crateRecipe.m_resources = Plugin._crateCraftResources; } } } [HarmonyPatch(typeof(Humanoid), "Pickup")] internal static class CratePickupLimitPatch { private static bool Prefix(Humanoid __instance, GameObject go) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return true; } ItemDrop val2 = ((go != null) ? go.GetComponent() : null); if (val2?.m_itemData?.m_shared?.m_name != "Pilgrim's Cache") { return true; } if (((Humanoid)val).GetInventory().GetAllItems().Any((ItemData i) => i.m_shared.m_name == "Pilgrim's Cache")) { ((Character)val).Message((MessageType)2, "You can only carry one Pilgrim's Cache.", 0, (Sprite)null); return false; } Plugin.EnsureCrateId(val2.m_itemData); return true; } } [HarmonyPatch(typeof(InventoryGui), "Hide")] internal static class CrateGuiHidePatch { private static void Prefix() { Plugin._hidingInventory = true; } private static void Postfix() { Plugin.SaveAndCloseCrateUI(); Plugin._hidingInventory = false; } } [HarmonyPatch(typeof(InventoryGui), "Show")] internal static class CrateAutoOpenPatch { private static void Postfix(InventoryGui __instance, Container container) { if (Plugin._openingCrateUI) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } if ((Object)(object)container != (Object)null && (Object)(object)container != (Object)(object)Plugin._fakeCrateContainer) { if (Plugin._crateUIOpen) { Plugin._previousContainer = null; Plugin.SaveAndCloseCrateUI(); } Plugin._previousContainer = container; } else if ((Object)(object)container == (Object)null) { Plugin._previousContainer = null; ItemData val = Plugin.FindCacheItem(localPlayer); if (val != null) { Plugin._openingCrateUI = true; Plugin.OpenCrateUI(localPlayer, val); Plugin._openingCrateUI = false; } } } } [HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(ItemData) })] internal static class CrateItemRemovedPatch { private static void Postfix(ItemData item) { if (item == Plugin._crateItem) { Plugin.SaveAndCloseCrateUI(); } } } internal static class CrateFilter { internal static bool Allow(Inventory inv, ItemData item, int x = -1, int y = -1) { Player localPlayer = Player.m_localPlayer; string prefab = ItemUtil.PrefabName(item); if (item.m_shared.m_name == "Pilgrim's Cache") { return false; } bool flag; if (x >= 0 && y >= 0) { ItemData itemAt = inv.GetItemAt(x, y); flag = itemAt != null && ItemUtil.PrefabName(itemAt) == prefab; } else { ItemData val = ((IEnumerable)inv.GetAllItems()).FirstOrDefault((Func)((ItemData i) => ItemUtil.PrefabName(i) == prefab)); flag = val != null && val.m_stack < val.m_shared.m_maxStackSize; } if (!flag && inv.GetAllItems().Any((ItemData i) => ItemUtil.PrefabName(i) == prefab)) { if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, "The cache already holds one stack of that.", 0, (Sprite)null); } return false; } return true; } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData), typeof(int), typeof(int), typeof(int) })] internal static class CrateAddItemPatch { private static bool Prefix(Inventory __instance, ItemData item, int amount, int x, int y, ref bool __result) { if (__instance != Plugin._crateInventory) { return true; } if (__instance.ContainsItem(item)) { return true; } if (CrateFilter.Allow(__instance, item, x, y)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })] internal static class CrateAddItemNoPosPatch { private static bool Prefix(Inventory __instance, ItemData item, ref bool __result) { if (__instance != Plugin._crateInventory) { return true; } if (__instance.ContainsItem(item)) { return true; } if (!CrateFilter.Allow(__instance, item)) { __result = false; return false; } string prefab = ItemUtil.PrefabName(item); ItemData val = ((IEnumerable)__instance.GetAllItems()).FirstOrDefault((Func)((ItemData i) => ItemUtil.PrefabName(i) == prefab)); if (val == null) { return true; } int num = val.m_shared.m_maxStackSize - val.m_stack; if (num <= 0) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, "The cache already holds one stack of that.", 0, (Sprite)null); } __result = false; return false; } int num2 = Mathf.Min(item.m_stack, num); val.m_stack += num2; item.m_stack -= num2; __result = item.m_stack == 0; __instance.m_onChanged?.Invoke(); return false; } } [HarmonyPatch(typeof(InventoryGrid), "DropItem")] internal static class CrateDropItemSwapPatch { private static bool Prefix(InventoryGrid __instance, Inventory fromInventory, ItemData item, int amount, Vector2i pos, ref bool __result) { //IL_0041: 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) Inventory inventory = __instance.GetInventory(); if (inventory == Plugin._crateInventory && item.m_shared.m_name == "Pilgrim's Cache") { __result = false; return false; } if (fromInventory != Plugin._crateInventory) { return true; } if (inventory == Plugin._crateInventory) { return true; } ItemData itemAt = inventory.GetItemAt(pos.x, pos.y); if (itemAt == null || itemAt == item || item.m_stack != amount) { return true; } if (!CrateFilter.Allow(fromInventory, itemAt)) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(Player), "ToggleEquipped")] internal static class InstantEquipWhileMovingPatch { private static bool Prefix(Player __instance, ItemData item, ref bool __result) { if (!Plugin.Cfg.Equipment.InstantEquipWhileMoving) { return true; } if (!item.IsEquipable()) { return true; } if (((Character)__instance).InAttack()) { __result = true; return false; } Traverse obj = Traverse.Create((object)__instance); bool value = obj.Field("m_run").Value; bool value2 = obj.Field("m_blocking").Value; if (!value && !value2) { return true; } if (((Humanoid)__instance).IsItemEquiped(item)) { ((Humanoid)__instance).UnequipItem(item, true); } else { ((Humanoid)__instance).EquipItem(item, true); } __result = true; return false; } } public class PilgrimConfig { public TrophiesConfig Trophies { get; set; } = new TrophiesConfig(); public BedsConfig Beds { get; set; } = new BedsConfig(); public CacheConfig Cache { get; set; } = new CacheConfig(); public CartsConfig Carts { get; set; } = new CartsConfig(); public ShipsConfig Ships { get; set; } = new ShipsConfig(); public EquipmentConfig Equipment { get; set; } = new EquipmentConfig(); public RitualsConfig Rituals { get; set; } = new RitualsConfig(); public static PilgrimConfig Default() { return new PilgrimConfig { Trophies = new TrophiesConfig { Enabled = true, Vfx = "fx_fireskeleton_nova" }, Beds = new BedsConfig { SleepWithoutSpawn = true }, Cache = new CacheConfig { Enabled = true, WeightContents = true }, Carts = new CartsConfig { Enabled = true }, Ships = new ShipsConfig { Enabled = true, NoDamageFilter = true, NoDamageRadius = 10f }, Equipment = new EquipmentConfig { InstantEquipWhileMoving = true }, Rituals = new RitualsConfig { Enabled = true, Cooldown = 60f, ComfortPeakMultiplier = 4f, FireMultipliers = new Dictionary { ["fire_pit"] = 1f, ["fire_pit_iron"] = 1.5f, ["piece_brazier"] = 1.5f, ["hearth"] = 2f, ["bonfire"] = 2.5f }, Items = new Dictionary { ["seek_altar"] = new RitualItemConfig { Enabled = true, Item = "BjornMeat", HoverText = "Seek the next altar", Message = "The wind stirs — {boss} awaits.", Domain = "Navigation" }, ["seek_bed"] = new RitualItemConfig { Enabled = true, Item = "Dandelion", HoverText = "Seek your bed", Message = "The flower carries you home...", Domain = "Navigation" }, ["seek_trader"] = new RitualItemConfig { Enabled = true, Item = "Coins", HoverText = "Seek a merchant", Message = "Gold calls to gold...", Domain = "Navigation" }, ["seek_dungeon"] = new RitualItemConfig { Enabled = true, Item = "Trophy*", HoverText = "Seek the nearest dungeon", Message = "The veil parts — something stirs nearby.", Domain = "Navigation" }, ["seek_player"] = new RitualItemConfig { Enabled = true, Item = "Flint", HoverText = "Seek a fellow pilgrim", Message = "Find fellowship.", Domain = "Navigation" }, ["restore_power"] = new RitualItemConfig { Enabled = true, Item = "Mushroom*", HoverText = "Restore your power", Message = "The flame accepts your offering. {power} is ready.", Duration = 600f, Domain = "Blessings" }, ["feather_fall"] = new RitualItemConfig { Enabled = true, Item = "Feathers", HoverText = "Fall without fear", Message = "Light as a feather — fall without fear.", Domain = "Blessings" }, ["clear_skies"] = new RitualItemConfig { Enabled = true, Item = "GreydwarfEye", HoverText = "Clear the skies", Message = "The clouds part.", Duration = 900f, Domain = "Blessings" }, ["water_walk"] = new RitualItemConfig { Enabled = true, Item = "Stone", HoverText = "Walk on water", Message = "The sea grows still beneath your feet.", Duration = 60f, Domain = "Blessings" }, ["growth"] = new RitualItemConfig { Enabled = true, Item = "AncientSeed", HoverText = "Bless your crops", Message = "The seed remembers the earth. Sleep, and your crops will answer.", Domain = "Blessings" }, ["tame_flock"] = new RitualItemConfig { Enabled = true, Item = "BoneFragments", HoverText = "Tame the flock", Message = "The bones remember loyalty. Sleep, and your flock will answer.", Domain = "Blessings" }, ["mead_ripen"] = new RitualItemConfig { Enabled = true, Item = "Barley", HoverText = "Ripen the mead", Message = "The grain remembers the harvest. Sleep, and your mead will answer.", Domain = "Blessings" }, ["kindle"] = new RitualItemConfig { Enabled = true, Item = "Resin", HoverText = "Kindle nearby fires", Message = "The darkness yields.", Domain = "Blessings" }, ["repair"] = new RitualItemConfig { Enabled = true, Item = "Coal", HoverText = "Mend your works", Message = "The fire remembers. Your works are mended.", Domain = "Blessings" }, ["giant"] = new RitualItemConfig { Enabled = true, Item = "YmirRemains", HoverText = "Become the mountain", Message = "The mountain answers. You are vast.", Duration = 60f, Domain = "Blessings" }, ["burden"] = new RitualItemConfig { Enabled = true, Item = "RawMeat", HoverText = "Carry great burdens", Message = "The weight is yours to bear.", Duration = 60f, CarryBonus = 1000f, Domain = "Blessings" }, ["ward_bubble"] = new RitualItemConfig { Enabled = true, Item = "Amber", HoverText = "Carry the shield", Message = "A ward rises. None shall pass.", Duration = 300f, Domain = "Blessings" }, ["campfire_ward"] = new RitualItemConfig { Enabled = true, Item = "AmberPearl", HoverText = "Raise a sanctuary", Message = "A sanctuary rises. None shall enter.", Duration = 60f, Domain = "Blessings" }, ["clear_mist"] = new RitualItemConfig { Enabled = true, Item = "Wisp", HoverText = "Push the mist away", Message = "The wisp answers. Mist retreats.", Duration = 120f, Domain = "Blessings" }, ["seek_corpse"] = new RitualItemConfig { Enabled = true, Item = "Chitin", HoverText = "Seek your corpse", Message = "The bones remember. Return to what was lost.", Domain = "Navigation" }, ["tar_moat"] = new RitualItemConfig { Enabled = false, Item = "Obsidian", HoverText = "Raise a tar moat", Message = "The earth bleeds black. None shall cross.", Duration = 60f, Domain = "Blessings" }, ["fire_wall"] = new RitualItemConfig { Enabled = true, Item = "Ruby", HoverText = "Ignite the structure", Message = "The structure burns. None shall pass.", Duration = 60f, Domain = "Blessings" }, ["tree_stand"] = new RitualItemConfig { Enabled = true, Item = "FirCone", HoverText = "Raise a stand of trees", Message = "The seeds remember the earth. Sleep, and the forest will answer.", Domain = "Blessings" }, ["prime"] = new RitualItemConfig { Enabled = true, Item = "Entrails", HoverText = "Call to the gods", Message = "The offering is made. The gods will answer.", MultiplierA = 0.5f, MultiplierB = 0.25f, Domain = "Blessings" }, ["rock_stand"] = new RitualItemConfig { Enabled = true, Item = "WitheredBone", HoverText = "Raise stone", Message = "The bones remember stone. Sleep, and the earth will answer.", Domain = "Blessings" }, ["seek_deer"] = new RitualItemConfig { Enabled = true, Item = "DeerHide", HoverText = "Hunt the deer", Message = "He thinks he's alone.", Distance = 150f, Domain = "Navigation" }, ["seek_boar"] = new RitualItemConfig { Enabled = true, Item = "LeatherScraps", HoverText = "Hunt the boar", Message = "The boar roots nearby.", Distance = 150f, Domain = "Navigation" }, ["seek_bear"] = new RitualItemConfig { Enabled = true, Item = "BjornHide", HoverText = "Hunt the bear", Message = "A great shadow waits in the trees.", Distance = 150f, Domain = "Navigation" }, ["seek_troll"] = new RitualItemConfig { Enabled = true, Item = "TrollHide", HoverText = "Hunt the troll", Message = "The earth shudders.", Distance = 150f, Domain = "Navigation" }, ["seek_abomination"] = new RitualItemConfig { Enabled = true, Item = "Root", HoverText = "Hunt the abomination", Message = "Something ancient stirs in the roots.", Distance = 150f, Domain = "Navigation" }, ["seek_wolf"] = new RitualItemConfig { Enabled = true, Item = "WolfPelt", HoverText = "Hunt the wolf", Message = "The pack circles.", Distance = 150f, Domain = "Navigation" }, ["seek_lox"] = new RitualItemConfig { Enabled = true, Item = "LoxPelt", HoverText = "Hunt the lox", Message = "The plains tremble beneath it.", Distance = 150f, Domain = "Navigation" }, ["seek_misthare"] = new RitualItemConfig { Enabled = true, Item = "HareMeat", HoverText = "Hunt the hare", Message = "It darts through the mist.", Distance = 150f, Domain = "Navigation" }, ["seek_asksvin"] = new RitualItemConfig { Enabled = true, Item = "AskHide", HoverText = "Hunt the asksvin", Message = "Ash and ember — it hungers.", Distance = 150f, Domain = "Navigation" }, ["seek_serpent"] = new RitualItemConfig { Enabled = true, Item = "SerpentScale", HoverText = "Hunt the serpent", Message = "Something vast stirs beneath the waves.", Distance = 150f, Domain = "Navigation" }, ["flaming_sword"] = new RitualItemConfig { Enabled = true, Item = "SurtlingCore", HoverText = "Summon Dyrnwyn", Message = "Dyrnwyn answers. Let it burn.", Duration = 60f, Domain = "Weapons" }, ["jotun_bane"] = new RitualItemConfig { Enabled = true, Item = "Ooze", HoverText = "Summon Jotun Bane", Message = "Jotun Bane answers the call.", Duration = 60f, Domain = "Weapons" }, ["krom"] = new RitualItemConfig { Enabled = true, Item = "Copper", HoverText = "Summon Krom", Message = "Krom rises from the deep.", Duration = 60f, Domain = "Weapons" }, ["slayer"] = new RitualItemConfig { Enabled = true, Item = "Iron", HoverText = "Summon Slayer", Message = "Slayer hungers.", Duration = 60f, Domain = "Weapons" }, ["skull_splittur"] = new RitualItemConfig { Enabled = true, Item = "Bloodbag", HoverText = "Summon Skull Splittur", Message = "Skull Splittur demands a reckoning.", Duration = 60f, Domain = "Weapons" }, ["himminafl"] = new RitualItemConfig { Enabled = true, Item = "Tin", HoverText = "Summon Himminafl", Message = "Himminafl crackles with thunder.", Duration = 60f, Domain = "Weapons" }, ["mistwalker"] = new RitualItemConfig { Enabled = true, Item = "Crystal", HoverText = "Summon Mistwalker", Message = "Mistwalker parts the veil.", Duration = 60f, Domain = "Weapons" } } } }; } } public class TrophiesConfig { public bool Enabled { get; set; } = true; public string Vfx { get; set; } = "fx_fireskeleton_nova"; } public class CacheConfig { public bool Enabled { get; set; } = true; public bool WeightContents { get; set; } = true; public float WeightScale { get; set; } = 1f; public bool SurvivesDeath { get; set; } } public class CartsConfig { public bool Enabled { get; set; } = true; } public class EquipmentConfig { public bool InstantEquipWhileMoving { get; set; } = true; } public class BedsConfig { public bool SleepWithoutSpawn { get; set; } = true; } public class ShipsConfig { public bool Enabled { get; set; } = true; public bool NoDamageFilter { get; set; } = true; public float NoDamageRadius { get; set; } = 10f; } public class RitualsConfig { public bool Enabled { get; set; } = true; public float Cooldown { get; set; } = 60f; public bool ShowHints { get; set; } = true; public float ComfortPeakMultiplier { get; set; } = 4f; public Dictionary FireMultipliers { get; set; } = new Dictionary { ["fire_pit"] = 1f, ["fire_pit_iron"] = 1.5f, ["piece_brazier"] = 1.5f, ["hearth"] = 2f, ["bonfire"] = 2.5f }; public Dictionary Items { get; set; } = new Dictionary(); } public class RitualItemConfig { public bool Enabled { get; set; } = true; public string Item { get; set; } = ""; public string HoverText { get; set; } = ""; public string Message { get; set; } = ""; public float Duration { get; set; } public float Distance { get; set; } public float CarryBonus { get; set; } public float MultiplierA { get; set; } = 2f; public float MultiplierB { get; set; } = 2f; public string Domain { get; set; } = "Blessings"; } }