Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Reforged Classes v0.5.1
plugins/ValheimReforged.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ValheimReforged { public enum Eff { None, MaxHealth, MaxStamina, MaxEitr, MoveSpeed, Damage, AbilityPower, HealthRegen, StaminaRegen, EitrRegen, LifeSteal, Cooldown, Crit, Resist, MeleeDamage, RangedDamage, MagicDamage, Execute, Opening, KillHeal, StaminaCost, SwordDamage, KnifeDamage, AxeDamage, ClubDamage, BowDamage, CrossbowDamage, ElementalDamage, BloodDamage, Experience, ArmorBonus, MiningDamage, ChoppingDamage, HarvestYield, FoodDuration, FishingSkill, ElementalResist, AmmoSave, FreeAmmo } public class Ability { public string Id; public string Glyph; public RpgClass Class; public int Col; public int Row; public string Parent; public int MaxRank = 5; public Eff Effect; public float PerRank; public int Cost = 1; public float Power = 1f; public float Cooldown; public Func<Player, int, bool> Cast; public Func<int, string> Preview; public string Name => L.T("ability." + Id + ".name"); public string Desc { get { if (!Active) { return L.F("ui.per_rank", Stats.Describe(Effect, PerRank)); } return L.T("ability." + Id + ".desc"); } } public string Info { get { string key = "ability." + Id + ".info"; if (!L.Has(key)) { return null; } return L.T(key); } } public bool Active => Cast != null; } public class Buff { public string Id; public string Name; public float Expires; public float Duration; public Dictionary<Eff, float> Mods = new Dictionary<Eff, float>(); } public static class Buffs { public static readonly List<Buff> Active = new List<Buff>(); public static void Add(string id, string name, float duration, params KeyValuePair<Eff, float>[] mods) { Active.RemoveAll((Buff b) => b.Id == id); Buff buff = new Buff { Id = id, Name = name, Expires = Time.time + duration, Duration = duration }; for (int num = 0; num < mods.Length; num++) { KeyValuePair<Eff, float> keyValuePair = mods[num]; buff.Mods[keyValuePair.Key] = keyValuePair.Value; } Active.Add(buff); } public static KeyValuePair<Eff, float> M(Eff e, float v) { return new KeyValuePair<Eff, float>(e, v); } public static float Get(Eff e) { float num = 0f; for (int num2 = Active.Count - 1; num2 >= 0; num2--) { float value; if (Active[num2].Expires <= Time.time) { Active.RemoveAt(num2); } else if (Active[num2].Mods.TryGetValue(e, out value)) { num += value; } } return num; } public static void Clear() { Active.Clear(); } } public static class Stats { private static readonly Dictionary<Eff, float> Caps = new Dictionary<Eff, float> { { Eff.MoveSpeed, 0.6f }, { Eff.Crit, 0.75f }, { Eff.LifeSteal, 0.3f }, { Eff.Cooldown, 0.5f }, { Eff.StaminaCost, 0.6f }, { Eff.Resist, 0.8f }, { Eff.ElementalResist, 0.75f }, { Eff.AmmoSave, 0.75f } }; public static float Get(Eff e) { RpgData data = Plugin.Data; if (data == null || data.Class == RpgClass.None) { return 0f; } float num = Buffs.Get(e) + Talents.Bonus(e); foreach (Ability item in Abilities.For(data.Class)) { if (item.Effect == e) { num += item.PerRank * (float)data.Rank(item.Id); } } if (!Caps.TryGetValue(e, out var value)) { return num; } return Mathf.Min(num, value); } public static float GetPassive(Eff e) { return GetTree(e) + Talents.Bonus(e); } public static float GetTree(Eff e) { RpgData data = Plugin.Data; if (data == null || data.Class == RpgClass.None) { return 0f; } float num = 0f; foreach (Ability item in Abilities.For(data.Class)) { if (item.Effect == e) { num += item.PerRank * (float)data.Rank(item.Id); } } return num; } public static string Describe(Eff e, float amount) { string text; switch (e) { case Eff.None: return ""; case Eff.MaxHealth: case Eff.MaxStamina: case Eff.MaxEitr: case Eff.FishingSkill: text = amount.ToString("0.#"); break; case Eff.HealthRegen: case Eff.StaminaRegen: case Eff.EitrRegen: text = amount.ToString("0.0"); break; default: text = (amount * 100f).ToString("0.#"); break; } return L.F("eff." + e, text); } } public static class Dash { private static Vector3 dir; private static float speed; private static float left; public static void Start(Player p, Vector3 direction, float distance, float duration) { //IL_000e: 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) direction.y = 0f; dir = ((Vector3)(ref direction)).normalized; speed = distance / duration; left = duration; } public static void Step(Player p) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) if (left <= 0f) { return; } float fixedDeltaTime = Time.fixedDeltaTime; left -= fixedDeltaTime; float num = speed * fixedDeltaTime; RaycastHit val = default(RaycastHit); if (Physics.Raycast(((Component)p).transform.position + Vector3.up * 0.9f, dir, ref val, num + 0.5f)) { left = 0f; return; } Rigidbody component = ((Component)p).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.position += dir * num; return; } Transform transform = ((Component)p).transform; transform.position += dir * num; } } public static class Abilities { public static readonly List<Ability> All; private static readonly Dictionary<RpgClass, List<Ability>> byClass; private static readonly Dictionary<string, float> ready; private static readonly Dictionary<string, float> total; private static float CurrentPower; public static List<Ability> For(RpgClass c) { if (!byClass.TryGetValue(c, out var value)) { return new List<Ability>(); } return value; } public static Ability Find(string id) { return All.FirstOrDefault((Ability a) => a.Id == id); } public static float CooldownLeft(string id) { if (!ready.TryGetValue(id, out var value)) { return 0f; } return Mathf.Max(0f, value - Time.time); } public static float CooldownTotal(string id) { if (!total.TryGetValue(id, out var value)) { return 1f; } return value; } public static void Cast(Player p, RpgData d, int slot) { string text = d.Slots[slot]; Ability ability = ((text == null) ? null : Find(text)); if (ability == null || !ability.Active) { return; } int num = d.Rank(ability.Id); if (num <= 0) { return; } if (CooldownLeft(ability.Id) > 0f) { ((Character)p).Message((MessageType)1, L.F("msg.cooldown", ability.Name), 0, (Sprite)null, false); return; } CurrentPower = ability.Power; if (ability.Cast(p, num)) { float num2 = ability.Cooldown * (1f - Mathf.Min(0.5f, Stats.Get(Eff.Cooldown))); ready[ability.Id] = Time.time + num2; total[ability.Id] = num2; } } private static float FrenzyTime(int rank) { return 6f + (float)rank; } private static float FrenzyDamage(int rank) { return (0.2f + 0.06f * (float)rank) * CurrentPower; } private static float Scale(int rank, float basis, float perRank) { return (basis + perRank * (float)rank) * (1f + 0.02f * (float)((Plugin.Data == null) ? 1 : Plugin.Data.Level)) * (1f + Stats.Get(Eff.AbilityPower)) * Plugin.AbilityDamage.Value * CurrentPower; } private static void Burst(Player p, Vector3 center, float radius, DamageTypes dmg, float push) { //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_0043: 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) Character[] array = Character.GetAllCharacters().ToArray(); foreach (Character val in array) { if (!((Object)(object)val == (Object)(object)p) && !val.IsDead() && BaseAI.IsEnemy((Character)(object)p, val) && !(Vector3.Distance(((Component)val).transform.position, center) > radius)) { Strike(p, val, center, dmg, push); } } } private static void Strike(Player p, Character c, Vector3 from, DamageTypes dmg, float push) { //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_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown HitData val = new HitData { m_damage = dmg, m_attacker = ((Character)p).GetZDOID(), m_point = c.GetCenterPoint() }; Vector3 val2 = ((Component)c).transform.position - from; val.m_dir = ((Vector3)(ref val2)).normalized; val.m_pushForce = push; HitData val3 = val; c.Damage(val3); } private static Vector3 AimPoint(Player p, float max) { //IL_0021: 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_003f: 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_004b: 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_0038: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform : ((Component)p).transform); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val.position, val.forward, ref val2, max)) { return ((RaycastHit)(ref val2)).point; } return val.position + val.forward * max; } private static ItemData FindArrows(Player p, int count) { foreach (ItemData allItem in ((Humanoid)p).GetInventory().GetAllItems()) { if (allItem.m_shared.m_ammoType == "$ammo_arrows" && allItem.m_stack >= count) { return allItem; } } return null; } private static bool Eitr(Player p, float cost) { if (!((Character)p).HaveEitr(cost)) { ((Character)p).Message((MessageType)2, L.T("msg.no_eitr"), 0, (Sprite)null, false); return false; } ((Character)p).UseEitr(cost); return true; } private static float TakeArrows(Player p, int cost) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) ItemData val = FindArrows(p, cost); if (val == null) { ((Character)p).Message((MessageType)2, L.F("msg.need_arrows", cost), 0, (Sprite)null, false); return -1f; } float pierce = val.GetDamage().m_pierce; ((Humanoid)p).GetInventory().RemoveItem(val, cost); return pierce; } private static Ability P(RpgClass cls, string id, int col, int row, string parent, Eff e, float per, string glyph) { Ability obj = new Ability { Id = id, Class = cls, Col = col, Row = row, Parent = parent, Effect = e, PerRank = per, Glyph = glyph }; Add(obj); return obj; } private static Ability A(RpgClass cls, string id, int col, int row, string parent, float cd, string glyph, Func<Player, int, bool> cast) { Ability ability = new Ability { Id = id, Class = cls, Col = col, Row = row, Parent = parent, Cooldown = cd, Glyph = glyph, Cast = cast }; if (row == 4) { ability.MaxRank = 3; } Add(ability); return ability; } private static void Tip(string id, Func<int, string> preview) { Find(id).Preview = delegate(int r) { float currentPower = CurrentPower; CurrentPower = Find(id).Power; try { return preview(r); } finally { CurrentPower = currentPower; } }; } private static void Add(Ability a) { All.Add(a); if (!byClass.TryGetValue(a.Class, out var value)) { value = (byClass[a.Class] = new List<Ability>()); } value.Add(a); } static Abilities() { All = new List<Ability>(); byClass = new Dictionary<RpgClass, List<Ability>>(); ready = new Dictionary<string, float>(); total = new Dictionary<string, float>(); CurrentPower = 1f; RpgClass cls = RpgClass.Archer; RpgClass cls2 = RpgClass.Mage; RpgClass cls3 = RpgClass.Rogue; P(RpgClass.Warrior, "w_str1", 0, 1, null, Eff.Damage, 0.02f, "sword"); A(RpgClass.Warrior, "w_shock", 0, 2, "w_str1", 18f, "w_shock", delegate(Player p, int r) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Vfx.Cast("w_shock", ((Component)p).transform.position, ((Component)p).transform.position); Burst(p, ((Component)p).transform.position, 6f, new DamageTypes { m_blunt = Scale(r, 25f, 15f) }, 40f); return true; }); P(RpgClass.Warrior, "w_crit", 0, 3, "w_shock", Eff.Crit, 0.02f, "crit"); P(RpgClass.Warrior, "w_rage", 0, 4, "w_crit", Eff.MeleeDamage, 0.06f, "sword"); P(RpgClass.Warrior, "w_iron", 1, 1, null, Eff.MaxHealth, 10f, "heart"); A(RpgClass.Warrior, "w_wind", 1, 2, "w_iron", 45f, "w_wind", delegate(Player p, int r) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vfx.Cast("w_wind", ((Component)p).transform.position, ((Component)p).transform.position); ((Character)p).Heal(((Character)p).GetMaxHealth() * (0.15f + 0.05f * (float)r), true); ((Character)p).AddStamina(((Character)p).GetMaxStamina()); return true; }); P(RpgClass.Warrior, "w_regen", 1, 3, "w_wind", Eff.HealthRegen, 0.25f, "w_wind"); P(RpgClass.Warrior, "w_wall", 1, 4, "w_regen", Eff.Resist, 0.05f, "w_iron"); P(RpgClass.Warrior, "w_stam", 2, 1, null, Eff.MaxStamina, 6f, "a_endur"); P(RpgClass.Warrior, "w_cry", 2, 2, "w_stam", Eff.StaminaCost, 0.03f, "r_reflex"); P(RpgClass.Warrior, "w_drain", 2, 3, "w_cry", Eff.LifeSteal, 0.015f, "m_well"); P(RpgClass.Warrior, "w_quake", 2, 4, "w_drain", Eff.Execute, 0.15f, "w_shock"); P(cls, "a_sharp", 0, 1, null, Eff.Damage, 0.02f, "sword"); A(cls, "a_rain", 0, 2, "a_sharp", 22f, "a_rain", delegate(Player p, int r) { //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_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_0035: 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_0062: Unknown result type (might be due to invalid IL or missing references) float num = TakeArrows(p, 5); if (num < 0f) { return false; } Vector3 val = AimPoint(p, 40f); Vfx.Cast("a_rain", ((Component)p).transform.position, val); Burst(p, val, 7f, new DamageTypes { m_pierce = Scale(r, 30f, 15f) + num * 2f }, 10f); return true; }); P(cls, "a_crit", 0, 3, "a_rain", Eff.Crit, 0.02f, "crit"); P(cls, "a_volley", 0, 4, "a_crit", Eff.RangedDamage, 0.06f, "a_rain"); P(cls, "a_endur", 1, 1, null, Eff.MaxStamina, 4f, "a_endur"); A(cls, "a_leap", 1, 2, "a_endur", 25f, "a_leap", delegate(Player p, int r) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vfx.Cast("a_leap", ((Component)p).transform.position, ((Component)p).transform.position); float v = FrenzyDamage(r); Buffs.Add("a_leap", L.T("ability.a_leap.name"), FrenzyTime(r), Buffs.M(Eff.BowDamage, v), Buffs.M(Eff.CrossbowDamage, v), Buffs.M(Eff.FreeAmmo, 1f)); return true; }); P(cls, "a_swift", 1, 3, "a_leap", Eff.MoveSpeed, 0.02f, "r_reflex"); P(cls, "a_focus", 1, 4, "a_swift", Eff.Opening, 0.15f, "crit"); P(cls, "a_vigor", 2, 1, null, Eff.MaxHealth, 6f, "heart"); P(cls, "a_herbs", 2, 2, "a_vigor", Eff.KillHeal, 0.01f, "w_wind"); P(cls, "a_second", 2, 3, "a_herbs", Eff.StaminaRegen, 0.4f, "a_endur"); P(cls, "a_frost", 2, 4, "a_second", Eff.Execute, 0.15f, "snow"); P(cls2, "m_power", 0, 1, null, Eff.AbilityPower, 0.03f, "m_blast"); A(cls2, "m_blast", 0, 2, "m_power", 14f, "m_blast", delegate(Player p, int r) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0057: Unknown result type (might be due to invalid IL or missing references) if (!Eitr(p, 25f)) { return false; } Vector3 val = AimPoint(p, 35f); Vfx.Cast("m_blast", ((Component)p).transform.position, val); Burst(p, val, 5f, new DamageTypes { m_lightning = Scale(r, 35f, 20f) }, 20f); return true; }); P(cls2, "m_crit", 0, 3, "m_blast", Eff.Crit, 0.02f, "crit"); P(cls2, "m_storm", 0, 4, "m_crit", Eff.MagicDamage, 0.06f, "m_blast"); P(cls2, "m_arcana", 1, 1, null, Eff.MaxEitr, 8f, "m_arcana"); A(cls2, "m_well", 1, 2, "m_arcana", 40f, "m_well", delegate(Player p, int r) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vfx.Cast("m_well", ((Component)p).transform.position, ((Component)p).transform.position); ((Character)p).AddEitr(((Character)p).GetMaxEitr() * (0.3f + 0.1f * (float)r)); return true; }); P(cls2, "m_flow", 1, 3, "m_well", Eff.EitrRegen, 0.4f, "m_well"); P(cls2, "m_shield", 1, 4, "m_flow", Eff.Resist, 0.05f, "w_iron"); P(cls2, "m_vit", 2, 1, null, Eff.MaxHealth, 5f, "heart"); P(cls2, "m_frost", 2, 2, "m_vit", Eff.KillHeal, 0.01f, "snow"); P(cls2, "m_cool", 2, 3, "m_frost", Eff.Cooldown, 0.03f, "clock"); P(cls2, "m_meteor", 2, 4, "m_cool", Eff.AbilityPower, 0.08f, "fire"); P(cls3, "r_blade", 0, 1, null, Eff.Damage, 0.02f, "sword"); A(cls3, "r_step", 0, 2, "r_blade", 20f, "r_reflex", delegate(Player p, int r) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vfx.Cast("r_step", ((Component)p).transform.position, ((Component)p).transform.position); Buffs.Add("r_step", "Disparada", 5f + (float)r, Buffs.M(Eff.MoveSpeed, 0.2f + 0.05f * (float)r)); return true; }); P(cls3, "r_crit", 0, 3, "r_step", Eff.Crit, 0.03f, "crit"); P(cls3, "r_execute", 0, 4, "r_crit", Eff.Execute, 0.15f, "crit"); P(cls3, "r_reflex", 1, 1, null, Eff.MoveSpeed, 0.02f, "r_reflex"); P(cls3, "r_smoke", 1, 2, "r_reflex", Eff.Resist, 0.03f, "r_venom"); P(cls3, "r_agile", 1, 3, "r_smoke", Eff.StaminaRegen, 0.4f, "a_endur"); P(cls3, "r_shadow", 1, 4, "r_agile", Eff.Opening, 0.15f, "r_step"); P(cls3, "r_vit", 2, 1, null, Eff.MaxHealth, 4f, "heart"); A(cls3, "r_venom", 2, 2, "r_vit", 20f, "r_venom", delegate(Player p, int r) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Vfx.Cast("r_venom", ((Component)p).transform.position, ((Component)p).transform.position); Burst(p, ((Component)p).transform.position, 5f, new DamageTypes { m_poison = Scale(r, 60f, 30f), m_pierce = Scale(r, 15f, 8f) }, 0f); return true; }); P(cls3, "r_leech", 2, 3, "r_venom", Eff.LifeSteal, 0.01f, "m_well"); P(cls3, "r_plague", 2, 4, "r_leech", Eff.AbilityPower, 0.08f, "r_venom"); Tip("w_shock", (int r) => L.F("ability.w_shock.preview", Scale(r, 25f, 15f).ToString("0"))); Tip("w_wind", (int r) => L.F("ability.w_wind.preview", ((0.15f + 0.05f * (float)r) * 100f).ToString("0"))); Tip("a_rain", (int r) => L.F("ability.a_rain.preview", Scale(r, 30f, 15f).ToString("0"))); Tip("a_leap", (int r) => L.F("ability.a_leap.preview", FrenzyTime(r).ToString("0"), Mathf.RoundToInt(FrenzyDamage(r) * 100f))); Tip("m_blast", (int r) => L.F("ability.m_blast.preview", Scale(r, 35f, 20f).ToString("0"))); Tip("m_well", (int r) => L.F("ability.m_well.preview", ((0.3f + 0.1f * (float)r) * 100f).ToString("0"))); Tip("r_step", (int r) => L.F("ability.r_step.preview", ((0.2f + 0.05f * (float)r) * 100f).ToString("0"), 5 + r)); Tip("r_venom", (int r) => L.F("ability.r_venom.preview", Scale(r, 60f, 30f).ToString("0"), Scale(r, 15f, 8f).ToString("0"))); foreach (Ability item in All) { if (!item.Active && item.Row == 4) { item.MaxRank = 3; } } } } public static class AutoRepair { private static CraftingStation lastStation; private static float nextTick; public static void Tick() { if (!Plugin.AutoRepairEnabled.Value || Time.realtimeSinceStartup < nextTick) { return; } nextTick = Time.realtimeSinceStartup + 0.3f; Player localPlayer = Player.m_localPlayer; InventoryGui instance = InventoryGui.instance; CraftingStation val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetCurrentCraftingStation() : null); if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null || (Object)(object)val == (Object)null || !InventoryGui.IsVisible()) { lastStation = null; } else { if ((Object)(object)val == (Object)(object)lastStation) { return; } lastStation = val; Traverse val2 = Traverse.Create((object)instance); Plugin.Log.LogInfo((object)("Auto repair: station " + ((Object)val).name + ", has repairable items: " + (val2.Method("HaveRepairableItems", Array.Empty<object>()).MethodExists() ? val2.Method("HaveRepairableItems", Array.Empty<object>()).GetValue<bool>().ToString() : "method not found"))); int num = 0; for (int i = 0; i < 200; i++) { Traverse val3 = val2.Method("HaveRepairableItems", Array.Empty<object>()); if (!val3.MethodExists() || !val3.GetValue<bool>()) { break; } val2.Method("RepairOneItem", Array.Empty<object>()).GetValue(); num++; } if (num > 0) { Plugin.Log.LogInfo((object)("Auto repair: " + num + " item(s) repaired")); } } } } public static class AutoStore { private static float nextKey; private static bool hoverLogged; public static bool Store(ItemData item) { Container stored; return Store(item, out stored); } public static bool Store(ItemData item, out Container stored) { stored = null; if (item == null || item.m_shared == null) { return false; } foreach (Container item2 in ChestCrafting.Within(Plugin.AutoStoreRange.Value)) { Inventory inventory = item2.GetInventory(); if ((!Plugin.AutoStoreOnlyWithItem.Value || inventory.HaveItem(item.m_shared.m_name, false)) && inventory.CanAddItem(item, item.m_stack)) { ChestCrafting.Claim(item2); if (inventory.AddItem(item)) { ChestCrafting.Save(item2); stored = item2; return true; } } } return false; } public static void Animate(Container c, ItemData item, int stack) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) try { GameObject open = c.m_open; GameObject closed = c.m_closed; if ((Object)(object)open != (Object)null) { open.SetActive(true); } if ((Object)(object)closed != (Object)null) { closed.SetActive(false); } Vector3 position = ((Component)c).transform.position; Vfx.Ring(position + Vector3.up * 0.4f, 1.1f, new Color(1f, 0.85f, 0.35f)); Floaters.Add(position + Vector3.up * 1.6f, "+" + stack + " " + Localization.instance.Localize(item.m_shared.m_name), Floaters.XpColor, 14, 1.4f); Vfx.After(0.9f, delegate { if (!((Object)(object)c == (Object)null) && !c.IsInUse()) { if ((Object)(object)open != (Object)null) { open.SetActive(false); } if ((Object)(object)closed != (Object)null) { closed.SetActive(true); } } }); } catch (Exception ex) { Plugin.Log.LogWarning((object)("AutoStore animation: " + ex.Message)); } } private static RectTransform SlotRect(object el) { Traverse val = Traverse.Create(el); RectTransform value = val.Field("m_touchRect").GetValue<RectTransform>(); if ((Object)(object)value != (Object)null) { return value; } Component value2 = val.Field("m_button").GetValue<Component>(); if (!((Object)(object)value2 != (Object)null)) { return null; } Transform transform = value2.transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } private static Vector2i SlotPos(object el) { //IL_002e: 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) Traverse val = Traverse.Create(el); Traverse val2 = val.Property("Position", (object[])null); if (val2.PropertyExists()) { return val2.GetValue<Vector2i>(); } return val.Field("<Position>k__BackingField").GetValue<Vector2i>(); } private static bool Contains(RectTransform rt, Camera cam) { //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_0076: 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_008a: Unknown result type (might be due to invalid IL or missing references) if (RectTransformUtility.RectangleContainsScreenPoint(rt, Vector2.op_Implicit(Input.mousePosition), cam)) { return true; } Vector3[] array = (Vector3[])(object)new Vector3[4]; rt.GetWorldCorners(array); Rect val = default(Rect); ((Rect)(ref val))..ctor(array[0].x, array[0].y, array[2].x - array[0].x, array[2].y - array[0].y); return ((Rect)(ref val)).Contains(new Vector2(Input.mousePosition.x, Input.mousePosition.y)); } internal unsafe static ItemData HoveredItem() { //IL_0076: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || !InventoryGui.IsVisible() || (Object)(object)instance.m_playerGrid == (Object)null) { return null; } IList value = Traverse.Create((object)instance.m_playerGrid).Field("m_elements").GetValue<IList>(); if (value == null) { Plugin.Log.LogInfo((object)"Hover lookup: m_elements not found"); return null; } Canvas val = ((Component)instance).GetComponentInParent<Canvas>(); if ((Object)(object)val != (Object)null) { val = val.rootCanvas; } Camera cam = (((Object)(object)val != (Object)null && (int)val.renderMode != 0) ? (val.worldCamera ?? Camera.main) : null); Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); if (!hoverLogged && value.Count > 0) { hoverLogged = true; object obj = value[0]; string text = string.Join(", ", (from f in obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) select f.Name + ":" + f.FieldType.Name).ToArray()); Plugin.Log.LogInfo((object)("Hover lookup: " + value.Count + " slots, canvas " + (((Object)(object)val != (Object)null) ? ((object)val.renderMode/*cast due to .constrained prefix*/).ToString() : "none") + "; element fields: " + text)); } foreach (object item in value) { RectTransform val2 = SlotRect(item); if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy && Contains(val2, cam)) { Vector2i val3 = SlotPos(item); return inventory.GetItemAt(val3.x, val3.y); } } RectTransform val4 = ((value.Count > 0) ? SlotRect(value[0]) : null); if ((Object)(object)val4 != (Object)null) { Vector3[] array = (Vector3[])(object)new Vector3[4]; val4.GetWorldCorners(array); ManualLogSource log = Plugin.Log; string[] obj2 = new string[8] { "Hover lookup: no slot under mouse ", ((object)Input.mousePosition/*cast due to .constrained prefix*/).ToString(), "; slot 0 corners ", null, null, null, null, null }; Vector3 val5 = array[0]; obj2[3] = ((object)(*(Vector3*)(&val5))/*cast due to .constrained prefix*/).ToString(); obj2[4] = " .. "; val5 = array[2]; obj2[5] = ((object)(*(Vector3*)(&val5))/*cast due to .constrained prefix*/).ToString(); obj2[6] = " active="; obj2[7] = ((Component)val4).gameObject.activeInHierarchy.ToString(); log.LogInfo((object)string.Concat(obj2)); } else { Plugin.Log.LogInfo((object)"Hover lookup: slot 0 has no rectangle"); } return null; } public static void Tick() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((int)Plugin.AutoStoreKey.Value == 0 || (Object)(object)Player.m_localPlayer == (Object)null || Ui.Open || !Input.GetKeyDown(Plugin.AutoStoreKey.Value) || Time.realtimeSinceStartup < nextKey) { return; } nextKey = Time.realtimeSinceStartup + 0.2f; ItemData val = HoveredItem(); Plugin.Log.LogInfo((object)("Store item key: " + ((val == null) ? "no item under the mouse" : (val.m_shared.m_name + " x" + val.m_stack + (val.m_equipped ? " (equipped)" : ""))) + "; chests in range: " + ChestCrafting.Within(Plugin.AutoStoreRange.Value).Count)); if (val != null && !val.m_equipped) { ItemData obj = val.Clone(); obj.m_dropPrefab = val.m_dropPrefab; int stack = obj.m_stack; if (Store(obj, out var stored)) { ((Humanoid)Player.m_localPlayer).GetInventory().RemoveItem(val); Animate(stored, val, stack); } else { ((Character)Player.m_localPlayer).Message((MessageType)1, L.T("autostore.none"), 0, (Sprite)null, false); } } } } [HarmonyPatch(typeof(Humanoid), "Pickup")] internal static class PickupAutoStore { private static bool Prefix(Humanoid __instance, GameObject __0, bool __2, ref bool __result) { if (!Plugin.AutoStoreEnabled.Value || !Plugin.AutoStoreOnPickup.Value || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || (Object)(object)__0 == (Object)null) { return true; } try { ItemDrop component = __0.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || !component.CanPickup(__2)) { return true; } ItemData itemData = component.m_itemData; int stack = itemData.m_stack; if (!AutoStore.Store(itemData, out var stored)) { return true; } ZNetView value = Traverse.Create((object)component).Field("m_nview").GetValue<ZNetView>(); if ((Object)(object)value != (Object)null && value.IsValid()) { value.ClaimOwnership(); ZNetScene.instance.Destroy(__0); } AutoStore.Animate(stored, itemData, stack); if (Plugin.AutoStoreMessage.Value) { ((Character)Player.m_localPlayer).Message((MessageType)1, L.F("autostore.stored", Localization.instance.Localize(itemData.m_shared.m_name)), 0, (Sprite)null, false); } __result = true; return false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("AutoStore pickup: " + ex.Message)); return true; } } } public static class ExtraRows { public static int BaseRows = 4; private static int applied = -1; private static float nextTick; public static int Rows => BaseRows + Mathf.Clamp(Plugin.ExtraInventoryRows.Value, 0, 6) + EquipSlots.Reserved; private static Inventory Inv { get { if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return null; } return ((Humanoid)Player.m_localPlayer).GetInventory(); } } public static void Apply() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) Inventory inv = Inv; if (inv == null) { return; } int rows = Rows; if (inv.GetHeight() == rows) { applied = rows; return; } Traverse.Create((object)inv).Field("m_height").SetValue((object)rows); foreach (ItemData item in (from i in inv.GetAllItems() where i.m_gridPos.y >= rows select i).ToList()) { inv.RemoveItem(item); if (!inv.AddItem(item)) { ItemDrop.DropItem(item, item.m_stack, ((Component)Player.m_localPlayer).transform.position + Vector3.up, Quaternion.identity); } } applied = rows; Traverse.Create((object)inv).Field("m_onChanged").GetValue<Action>()?.Invoke(); Plugin.Log.LogInfo((object)("Inventory rows: " + rows)); } public static void Tick() { if (!(Time.realtimeSinceStartup < nextTick)) { nextTick = Time.realtimeSinceStartup + 1f; if ((Object)(object)Player.m_localPlayer != (Object)null && applied != Rows) { Apply(); } } } public static void Reset() { applied = -1; } } [HarmonyPatch(typeof(Player), "Load")] internal static class ExtraRowsOnLoad { private static void Prefix(Player __instance) { Inventory inventory = ((Humanoid)__instance).GetInventory(); if (inventory != null) { Traverse.Create((object)inventory).Field("m_height").SetValue((object)ExtraRows.Rows); } } private static void Postfix() { ExtraRows.Reset(); } } [HarmonyPatch(typeof(Inventory), "SetHeight")] internal static class ExtraRowsSetHeight { private static void Prefix(Inventory __instance, ref int __0) { if (__instance.GetWidth() == 8 && !(__instance.GetName() != "Inventory")) { ExtraRows.BaseRows = __0; __0 = ExtraRows.Rows; } } } [HarmonyPatch] internal static class ExtraRowsOnInventoryLoad { public const int MaxRows = 18; private static bool logged; private static IEnumerable<MethodBase> TargetMethods() { MethodInfo[] methods = typeof(Inventory).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == "Load") { yield return methodInfo; } } } private static void Prefix(Inventory __instance, ref int __state) { __state = -1; if (__instance != null && __instance.GetWidth() == 8 && __instance.GetHeight() >= 4) { __state = __instance.GetHeight(); Traverse.Create((object)__instance).Field("m_height").SetValue((object)18); if (!logged) { logged = true; Plugin.Log.LogInfo((object)("Inventory.Load: '" + __instance.GetName() + "' " + __instance.GetWidth() + "x" + __state + " loaded with " + 18 + " rows")); } } } private static void Postfix(Inventory __instance, int __state) { if (__state >= 0) { if (__instance.GetName() == "Inventory") { ExtraRows.Reset(); } else { Traverse.Create((object)__instance).Field("m_height").SetValue((object)__state); } } } } [HarmonyPatch] internal static class ExtraRowsOnProfileLoad { private static IEnumerable<MethodBase> TargetMethods() { MethodInfo methodInfo = AccessTools.Method(typeof(PlayerProfile), "LoadPlayerData", (Type[])null, (Type[])null); if (methodInfo != null) { yield return methodInfo; } else { Plugin.Log.LogWarning((object)"Extra rows: PlayerProfile.LoadPlayerData not found"); } } private static void Prefix(Player __0) { Inventory val = (((Object)(object)__0 != (Object)null) ? ((Humanoid)__0).GetInventory() : null); if (val != null) { Traverse.Create((object)val).Field("m_height").SetValue((object)ExtraRows.Rows); } } } [HarmonyPatch(typeof(Player), "OnSpawned")] internal static class ExtraRowsOnSpawn { private static void Postfix() { ExtraRows.Reset(); } } [HarmonyPatch(typeof(InventoryGui), "Update")] internal static class ExtraRowsGui { private static readonly Dictionary<RectTransform, float> baseHeight = new Dictionary<RectTransform, float>(); private static bool dumped; private static void Resize(RectTransform rt, float add) { //IL_0028: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!baseHeight.TryGetValue(rt, out var value)) { value = (baseHeight[rt] = rt.sizeDelta.y); } if (!Mathf.Approximately(rt.sizeDelta.y, value + add)) { rt.sizeDelta = new Vector2(rt.sizeDelta.x, value + add); } } private static void Postfix(InventoryGui __instance) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_0249: 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_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) try { Ui.PlaceRepairButton(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Repair button placement: " + ex.Message)); } try { RectTransform player = __instance.m_player; InventoryGrid playerGrid = __instance.m_playerGrid; if ((Object)(object)player == (Object)null || (Object)(object)playerGrid == (Object)null) { return; } int num = Mathf.Clamp(Plugin.ExtraInventoryRows.Value, 0, 6); float add = (float)num * playerGrid.m_elementSpace; if (player.anchorMin.y == player.anchorMax.y) { Resize(player, add); } foreach (Transform item in (Transform)player) { object obj = (object)item; RectTransform val = (RectTransform)((obj is RectTransform) ? obj : null); if (!((Object)(object)val == (Object)null) && val.anchorMin.y == val.anchorMax.y) { string text = ((Object)val).name.ToLowerInvariant(); if (val.sizeDelta.y >= 150f && (text.Contains("bkg") || text.Contains("background") || text.Contains("panel") || text.Contains("bg"))) { Resize(val, add); } } } if (num <= 0 || dumped || !InventoryGui.IsVisible()) { return; } dumped = true; StringBuilder stringBuilder = new StringBuilder("Inventory panel layout: " + ((Object)player).name + " size " + ((object)player.sizeDelta/*cast due to .constrained prefix*/).ToString() + " anchors " + ((object)player.anchorMin/*cast due to .constrained prefix*/).ToString() + "/" + ((object)player.anchorMax/*cast due to .constrained prefix*/).ToString()); foreach (Transform item2 in (Transform)player) { object obj2 = (object)item2; RectTransform val2 = (RectTransform)((obj2 is RectTransform) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { stringBuilder.Append("\n " + ((Object)val2).name + " size " + ((object)val2.sizeDelta/*cast due to .constrained prefix*/).ToString() + " anchors " + ((object)val2.anchorMin/*cast due to .constrained prefix*/).ToString() + "/" + ((object)val2.anchorMax/*cast due to .constrained prefix*/).ToString()); } } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("ExtraRowsGui: " + ex2.Message)); } } } public static class Blueprints { public class Bp { public long Id; public long AuthorPid; public string Name = ""; public string Author = ""; public int Count; public string Data = ""; } public class BpPiece { public GameObject Prefab; public Vector3 Pos; public Quaternion Rot; } public const string Rpc = "VR_Blueprint"; public const string HammerName = "VR_BlueprintHammer"; private const int MaxPieces = 2000; private const int MaxData = 400000; private static GameObject hammer; private static GameObject holder; private static readonly Dictionary<long, Bp> store = new Dictionary<long, Bp>(); private static long nextId = 1L; private static string loadedPath; public static readonly List<Bp> List = new List<Bp>(); public static string ActiveName; private static readonly List<BpPiece> active = new List<BpPiece>(); private static float listAt = -99f; private static float radius = 8f; private static float rotation; private static GameObject circle; private static GameObject ghost; private static LineRenderer ring; private static bool wasEquipped; public static bool Equipped { get { Player localPlayer = Player.m_localPlayer; ItemData val = (((Object)(object)localPlayer != (Object)null) ? Traverse.Create((object)localPlayer).Field("m_rightItem").GetValue<ItemData>() : null); if (val != null && (Object)(object)val.m_dropPrefab != (Object)null) { return ((Object)val.m_dropPrefab).name == "VR_BlueprintHammer"; } return false; } } public static bool HasActive => active.Count > 0; public static string Hint { get { if (!Equipped || Ui.Open) { return null; } if (!HasActive) { return L.F("bp.hint_copy", Mathf.RoundToInt(radius)); } return L.F("bp.hint_place", ActiveName, active.Count); } } public static void RegisterItem() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_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_0273: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null) { return; } if ((Object)(object)hammer == (Object)null) { GameObject itemPrefab = instance.GetItemPrefab("Hammer"); if ((Object)(object)itemPrefab == (Object)null) { return; } holder = new GameObject("VR_BlueprintHolder"); holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)holder); hammer = Object.Instantiate<GameObject>(itemPrefab, holder.transform); ((Object)hammer).name = "VR_BlueprintHammer"; ItemDrop component = hammer.GetComponent<ItemDrop>(); MethodInfo method = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic); component.m_itemData.m_shared = (SharedData)method.Invoke(component.m_itemData.m_shared, null); SharedData shared = component.m_itemData.m_shared; shared.m_name = "Blueprint Hammer"; shared.m_description = "Copies the buildings around a point into a blueprint and builds saved blueprints. Mouse wheel: radius or rotation. Left click: copy or build. Right click: cancel."; shared.m_buildPieces = null; Renderer[] componentsInChildren = hammer.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] materials = val.materials; Material[] array = materials; foreach (Material val2 in array) { if (val2.HasProperty("_Color")) { val2.color = new Color(0.35f, 0.9f, 0.4f); } } val.materials = materials; } } if (!instance.m_items.Contains(hammer)) { instance.m_items.Add(hammer); } Dictionary<int, GameObject> value = Traverse.Create((object)instance).Field("m_itemByHash").GetValue<Dictionary<int, GameObject>>(); if (value != null) { value[StringExtensionMethods.GetStableHashCode("VR_BlueprintHammer")] = hammer; } ItemDrop item = hammer.GetComponent<ItemDrop>(); GameObject itemPrefab2 = instance.GetItemPrefab("Wood"); if ((Object)(object)itemPrefab2 != (Object)null && !instance.m_recipes.Any((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item == (Object)(object)item)) { Recipe val3 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val3).name = "Recipe_VR_BlueprintHammer"; val3.m_item = item; val3.m_amount = 1; val3.m_enabled = true; val3.m_craftingStation = null; val3.m_minStationLevel = 1; val3.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = itemPrefab2.GetComponent<ItemDrop>(), m_amount = 5, m_recover = true } }; instance.m_recipes.Add(val3); } if ((Object)(object)ZNetScene.instance != (Object)null) { List<GameObject> value2 = Traverse.Create((object)ZNetScene.instance).Field("m_prefabs").GetValue<List<GameObject>>(); if (value2 != null && !value2.Contains(hammer)) { value2.Add(hammer); } Dictionary<int, GameObject> value3 = Traverse.Create((object)ZNetScene.instance).Field("m_namedPrefabs").GetValue<Dictionary<int, GameObject>>(); if (value3 != null) { value3[StringExtensionMethods.GetStableHashCode("VR_BlueprintHammer")] = hammer; } } } private static string StorePath() { string text = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetWorldName() : "world"); char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { text = text.Replace(oldChar, '_'); } string text2 = Path.Combine(Paths.BepInExRootPath, "ValheimReforgedData"); Directory.CreateDirectory(text2); return Path.Combine(text2, "blueprints_" + text + ".dat"); } private static void EnsureStore() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown string text = StorePath(); if (loadedPath == text) { return; } loadedPath = text; store.Clear(); nextId = 1L; if (!File.Exists(text)) { return; } try { ZPackage val = new ZPackage(File.ReadAllBytes(text)); nextId = val.ReadLong(); int num = val.ReadInt(); for (int i = 0; i < num; i++) { Bp bp = new Bp { Id = val.ReadLong(), AuthorPid = val.ReadLong(), Name = val.ReadString(), Author = val.ReadString(), Count = val.ReadInt(), Data = val.ReadString() }; store[bp.Id] = bp; } Plugin.Log.LogInfo((object)("Blueprints: " + store.Count + " loaded from " + text)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Blueprints: could not read " + text + ": " + ex.Message)); } } private static void SaveStore() { //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(); val.Write(nextId); val.Write(store.Count); foreach (Bp value in store.Values) { val.Write(value.Id); val.Write(value.AuthorPid); val.Write(value.Name); val.Write(value.Author); val.Write(value.Count); val.Write(value.Data); } string text = StorePath(); string text2 = text + ".tmp"; File.WriteAllBytes(text2, val.GetArray()); if (File.Exists(text)) { File.Delete(text); } File.Move(text2, text); } private static ZPackage ListPkg() { //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(); val.Write("list"); val.Write(store.Count); foreach (Bp item in store.Values.OrderBy((Bp x) => x.Name)) { val.Write(item.Id); val.Write(item.AuthorPid); val.Write(item.Name); val.Write(item.Author); val.Write(item.Count); } return val; } private static ZPackage Msg(string key) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write("msg"); val.Write(key); return val; } private static void Server(string op, long pid, string name, ZPackage z, Action<ZPackage> reply) { //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown EnsureStore(); switch (op) { case "list": reply(ListPkg()); break; case "save": { Bp bp = new Bp { AuthorPid = pid, Author = (name ?? ""), Name = z.ReadString(), Count = z.ReadInt(), Data = z.ReadString() }; if (bp.Data.Length == 0 || bp.Data.Length > 400000 || bp.Count <= 0 || bp.Count > 2000) { reply(Msg("bp.err.size")); break; } if (bp.Name.Length > 60) { bp.Name = bp.Name.Substring(0, 60); } bp.Id = nextId++; store[bp.Id] = bp; try { SaveStore(); } catch (Exception ex2) { store.Remove(bp.Id); Plugin.Log.LogWarning((object)("Blueprints: save failed: " + ex2.Message)); reply(Msg("bp.err.server")); break; } reply(Msg("bp.saved")); reply(ListPkg()); break; } case "get": { if (!store.TryGetValue(z.ReadLong(), out var value2)) { reply(Msg("bp.err.missing")); break; } ZPackage val = new ZPackage(); val.Write("data"); val.Write(value2.Id); val.Write(value2.Name); val.Write(value2.Data); reply(val); break; } case "delete": { if (!store.TryGetValue(z.ReadLong(), out var value)) { reply(Msg("bp.err.missing")); break; } if (value.AuthorPid != pid) { reply(Msg("bp.err.owner")); break; } store.Remove(value.Id); try { SaveStore(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Blueprints: save failed: " + ex.Message)); } reply(Msg("bp.deleted")); reply(ListPkg()); break; } } } public static void RPC(ZRpc rpc, ZPackage z) { try { string op = z.ReadString(); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { long pid = z.ReadLong(); ZNetPeer val = ((IEnumerable<ZNetPeer>)ZNet.instance.GetPeers()).FirstOrDefault((Func<ZNetPeer, bool>)((ZNetPeer x) => x.m_rpc == rpc)); if (val != null) { Server(op, pid, val.m_playerName, z, delegate(ZPackage r) { rpc.Invoke("VR_Blueprint", new object[1] { r }); }); } } else { Client(op, z); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Blueprint RPC: " + ex.Message)); } } private static void ToServer(string op, Action<ZPackage> write) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)ZNet.instance == (Object)null) { return; } ZPackage val = new ZPackage(); val.Write(op); val.Write(localPlayer.GetPlayerID()); write?.Invoke(val); if (ZNet.instance.IsServer()) { ZPackage val2 = new ZPackage(val.GetArray()); val2.ReadString(); val2.ReadLong(); Server(op, localPlayer.GetPlayerID(), localPlayer.GetPlayerName(), val2, delegate(ZPackage reply) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown ZPackage val3 = new ZPackage(reply.GetArray()); Client(val3.ReadString(), val3); }); } else { ZRpc serverRPC = ZNet.instance.GetServerRPC(); if (serverRPC != null) { serverRPC.Invoke("VR_Blueprint", new object[1] { val }); } } } public static void RequestList(bool force = false) { if (force || !(Time.realtimeSinceStartup - listAt < 5f)) { listAt = Time.realtimeSinceStartup; ToServer("list", null); } } public static void Select(Bp b) { ToServer("get", delegate(ZPackage z) { z.Write(b.Id); }); } public static void Delete(Bp b) { ToServer("delete", delegate(ZPackage z) { z.Write(b.Id); }); } public static void ClearActive() { active.Clear(); ActiveName = null; DestroyGhost(); } private static void Client(string op, ZPackage z) { switch (op) { case "list": { List.Clear(); int num = z.ReadInt(); for (int i = 0; i < num; i++) { List.Add(new Bp { Id = z.ReadLong(), AuthorPid = z.ReadLong(), Name = z.ReadString(), Author = z.ReadString(), Count = z.ReadInt() }); } break; } case "data": { z.ReadLong(); string text = z.ReadString(); int missing; List<BpPiece> collection = Parse(z.ReadString(), out missing); ClearActive(); active.AddRange(collection); ActiveName = text; rotation = 0f; Ui.BlueprintToast((missing > 0) ? L.F("bp.selected_missing", text, missing) : L.F("bp.selected", text)); break; } case "msg": Ui.BlueprintToast(L.T(z.ReadString())); break; } } private static string F(float v) { return v.ToString("0.###", CultureInfo.InvariantCulture); } private static List<BpPiece> Parse(string data, out int missing) { //IL_00e7: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) missing = 0; List<BpPiece> list = new List<BpPiece>(); string[] array = data.Split(new char[1] { '\n' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '|' }); if (array2.Length != 8) { continue; } GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(array2[0]) : null); if ((Object)(object)val == (Object)null || (Object)(object)val.GetComponent<Piece>() == (Object)null) { missing++; continue; } float[] array3 = new float[7]; bool flag = true; for (int j = 0; j < 7; j++) { flag &= float.TryParse(array2[j + 1], NumberStyles.Float, CultureInfo.InvariantCulture, out array3[j]); } if (!flag) { missing++; continue; } list.Add(new BpPiece { Prefab = val, Pos = new Vector3(array3[0], array3[1], array3[2]), Rot = new Quaternion(array3[3], array3[4], array3[5], array3[6]) }); } return list; } private static bool Aim(out Vector3 point) { //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) point = Vector3.zero; Camera mainCamera = Utils.GetMainCamera(); if ((Object)(object)mainCamera == (Object)null) { return false; } int mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" }); RaycastHit val = default(RaycastHit); if (!Physics.Raycast(((Component)mainCamera).transform.position, ((Component)mainCamera).transform.forward, ref val, 60f, mask, (QueryTriggerInteraction)1)) { return false; } point = ((RaycastHit)(ref val)).point; return true; } public static void Tick() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) if (!Equipped || Ui.Open || Ui.BlockedByOtherUi()) { if (wasEquipped) { HideCircle(); if ((Object)(object)ghost != (Object)null) { ghost.SetActive(false); } } wasEquipped = false; return; } wasEquipped = true; Player localPlayer = Player.m_localPlayer; float y = Input.mouseScrollDelta.y; Vector3 point; bool flag = Aim(out point); if (HasActive) { HideCircle(); if (y != 0f) { rotation += Mathf.Sign(y) * 15f; } if (Input.GetMouseButtonDown(1)) { ClearActive(); Ui.BlueprintToast(L.T("bp.cancelled")); return; } if (!flag) { if ((Object)(object)ghost != (Object)null) { ghost.SetActive(false); } return; } Quaternion rot = Quaternion.Euler(0f, ((Component)localPlayer).transform.eulerAngles.y + rotation, 0f); point.y = RestHeight(point, rot); ShowGhost(point, rot); if (Input.GetMouseButtonDown(0)) { Build(localPlayer, point, rot); } return; } if ((Object)(object)ghost != (Object)null) { ghost.SetActive(false); } if (y != 0f) { radius = Mathf.Clamp(radius + Mathf.Sign(y), 2f, Plugin.BlueprintMaxRadius.Value); } if (!flag) { HideCircle(); return; } ShowCircle(point); if (Input.GetMouseButtonDown(0)) { Copy(localPlayer, point); } } private static float RestHeight(Vector3 at, Quaternion rot) { //IL_00a0: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) float minY = active.Min((BpPiece b) => b.Pos.y); IEnumerable<BpPiece> enumerable = active.Where((BpPiece b) => b.Pos.y <= minY + 0.5f).Take(64); int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" }); float num = float.MinValue; RaycastHit val2 = default(RaycastHit); foreach (BpPiece item in enumerable) { Vector3 val = at + rot * item.Pos; if (Physics.Raycast(new Vector3(val.x, at.y + 40f, val.z), Vector3.down, ref val2, 80f, mask, (QueryTriggerInteraction)1)) { num = Mathf.Max(num, ((RaycastHit)(ref val2)).point.y); } } if (!(num > float.MinValue)) { return at.y; } return num - minY; } private static void Copy(Player p, Vector3 center) { //IL_001d: 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_0036: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_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_00de: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) HashSet<Piece> hashSet = new HashSet<Piece>(); StringBuilder stringBuilder = new StringBuilder(); Quaternion val = Quaternion.Inverse(Quaternion.Euler(0f, ((Component)p).transform.eulerAngles.y, 0f)); int count = 0; Collider[] array = Physics.OverlapSphere(center, radius); for (int i = 0; i < array.Length; i++) { Piece componentInParent = ((Component)array[i]).GetComponentInParent<Piece>(); if ((Object)(object)componentInParent == (Object)null || !hashSet.Add(componentInParent) || componentInParent.GetCreator() == 0L || Vector3.Distance(((Component)componentInParent).transform.position, center) > radius) { continue; } ZNetView component = ((Component)componentInParent).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { string prefabName = Utils.GetPrefabName(((Component)componentInParent).gameObject); Vector3 val2 = val * (((Component)componentInParent).transform.position - center); Quaternion val3 = val * ((Component)componentInParent).transform.rotation; stringBuilder.Append(prefabName).Append('|').Append(F(val2.x)) .Append('|') .Append(F(val2.y)) .Append('|') .Append(F(val2.z)) .Append('|') .Append(F(val3.x)) .Append('|') .Append(F(val3.y)) .Append('|') .Append(F(val3.z)) .Append('|') .Append(F(val3.w)) .Append('\n'); if (++count >= 2000) { break; } } } if (count == 0) { Ui.BlueprintToast(L.T("bp.nothing")); return; } string bpName = L.F("bp.default_name", DateTime.Now.ToString("dd/MM HH:mm"), count); string data = stringBuilder.ToString(); ToServer("save", delegate(ZPackage z) { z.Write(bpName); z.Write(count); z.Write(data); }); Ui.BlueprintToast(L.F("bp.copied", count)); } private static void ShowCircle(Vector3 c) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)circle == (Object)null) { circle = new GameObject("VR_BlueprintCircle"); ring = circle.AddComponent<LineRenderer>(); ((Renderer)ring).material = new Material(Shader.Find("Sprites/Default")); LineRenderer obj = ring; float startWidth = (ring.endWidth = 0.08f); obj.startWidth = startWidth; LineRenderer obj2 = ring; LineRenderer obj3 = ring; Color val = default(Color); ((Color)(ref val))..ctor(0.4f, 1f, 0.5f, 0.9f); obj3.endColor = val; obj2.startColor = val; ring.loop = true; ring.useWorldSpace = true; ring.positionCount = 64; } circle.SetActive(true); for (int i = 0; i < 64; i++) { float num2 = (float)i / 64f * (float)Math.PI * 2f; Vector3 val2 = c + new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * radius; if ((Object)(object)ZoneSystem.instance != (Object)null) { val2.y = ZoneSystem.instance.GetGroundHeight(val2); } ring.SetPosition(i, val2 + Vector3.up * 0.15f); } } private static void HideCircle() { if ((Object)(object)circle != (Object)null) { circle.SetActive(false); } } private static void ShowGhost(Vector3 at, Quaternion rot) { //IL_0145: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_005b: 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) if ((Object)(object)ghost == (Object)null) { ghost = new GameObject("VR_BlueprintGhost"); ZNetView.m_forceDisableInit = true; try { foreach (BpPiece item in active) { GameObject val = Object.Instantiate<GameObject>(item.Prefab, ghost.transform, false); val.transform.localPosition = item.Pos; val.transform.localRotation = item.Rot; Joint[] componentsInChildren = val.GetComponentsInChildren<Joint>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren<Rigidbody>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } Collider[] componentsInChildren3 = val.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].enabled = false; } MonoBehaviour[] componentsInChildren4 = val.GetComponentsInChildren<MonoBehaviour>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { ((Behaviour)componentsInChildren4[i]).enabled = false; } } } finally { ZNetView.m_forceDisableInit = false; } } ghost.SetActive(true); ghost.transform.SetPositionAndRotation(at, rot); } private static void DestroyGhost() { if ((Object)(object)ghost != (Object)null) { Object.Destroy((Object)(object)ghost); } ghost = null; } private static void Build(Player p, Vector3 at, Quaternion rot) { //IL_02be: 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_02c2: 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_02cc: 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_02d4: 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_030a: 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_0360: 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) Dictionary<string, int> dictionary = new Dictionary<string, int>(); Dictionary<string, string> dictionary2 = new Dictionary<string, string>(); foreach (BpPiece item in active) { Piece component = item.Prefab.GetComponent<Piece>(); if ((Object)(object)component == (Object)null || component.m_resources == null) { continue; } Requirement[] resources = component.m_resources; foreach (Requirement val in resources) { if (!((Object)(object)val.m_resItem == (Object)null) && val.m_amount > 0) { string name = val.m_resItem.m_itemData.m_shared.m_name; dictionary.TryGetValue(name, out var value); dictionary[name] = value + val.m_amount; dictionary2[name] = Localization.instance.Localize(name); } } } Inventory inventory = ((Humanoid)p).GetInventory(); bool enabled = ChestCrafting.Enabled; foreach (KeyValuePair<string, int> item2 in dictionary) { ChestCrafting.Raw++; int num; try { num = inventory.CountItems(item2.Key, -1, true); } finally { ChestCrafting.Raw--; } if (enabled) { num += ChestCrafting.CountInChests(item2.Key, -1, matchWorldLevel: false); } if (num < item2.Value) { Ui.BlueprintToast(L.F("bp.missing", dictionary2[item2.Key], item2.Value - num, item2.Value)); return; } } foreach (KeyValuePair<string, int> item3 in dictionary) { ChestCrafting.Raw++; int num2; try { num2 = inventory.CountItems(item3.Key, -1, true); int num3 = Mathf.Min(num2, item3.Value); if (num3 > 0) { inventory.RemoveItem(item3.Key, num3, -1, true); } } finally { ChestCrafting.Raw--; } int num4 = item3.Value - Mathf.Min(num2, item3.Value); if (num4 > 0 && enabled) { ChestCrafting.TakeFromChests(item3.Key, num4, -1, matchWorldLevel: false); } } bool flag = true; foreach (BpPiece item4 in active.OrderBy((BpPiece x) => x.Pos.y)) { GameObject val2 = Object.Instantiate<GameObject>(item4.Prefab, at + rot * item4.Pos, rot * item4.Rot); Piece component2 = val2.GetComponent<Piece>(); if (!((Object)(object)component2 == (Object)null)) { component2.SetCreator(p.GetPlayerID(), ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID); WearNTear component3 = val2.GetComponent<WearNTear>(); if ((Object)(object)component3 != (Object)null) { component3.OnPlaced(); } if (flag) { component2.m_placeEffect.Create(val2.transform.position, val2.transform.rotation, val2.transform, 1f, -1, default(ZDOID)); flag = false; } } } Ui.BlueprintToast(L.F("bp.built", active.Count)); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class BlueprintObjectDb { private static void Postfix() { Blueprints.RegisterItem(); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class BlueprintObjectDbCopy { private static void Postfix() { Blueprints.RegisterItem(); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class BlueprintZNetScene { private static void Postfix() { Blueprints.RegisterItem(); } } [HarmonyPatch(typeof(Humanoid), "StartAttack")] internal static class BlueprintNoAttack { private static bool Prefix(Humanoid __instance, ref bool __result) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Blueprints.Equipped) { return true; } __result = false; return false; } } public static class Ui { private class TipLine { public string T; public int Size; public Color C; public bool Bold; } private static string bpMsg; private static float bpMsgUntil; private static Vector2 bpScroll; private static bool clockDragging; private static Vector2 clockGrab; private static string compMsg; private static float compMsgUntil; private static string pickerSlot; private static readonly Color WoodBg = new Color(0.235f, 0.17f, 0.15f, 0.99f); private static readonly Color WoodEdge = new Color(0.6f, 0.4f, 0.2f, 1f); private static readonly Color SlotBg = new Color(0.145f, 0.1f, 0.09f, 1f); private static readonly Color SlotEdge = new Color(0.42f, 0.29f, 0.19f, 1f); private static readonly Color Orange = new Color(1f, 0.67f, 0.18f, 1f); private static readonly Color Tan = new Color(0.8f, 0.68f, 0.56f, 1f); private const float EqSlot = 56f; private const float EqGap = 6f; private const float EqPad = 8f; private static string mailMsg; private static float mailMsgUntil; private static float mailFetchedAt; private static Vector2 inboxScroll; private static Vector2 attachScroll; private static long selectedMail; private static long mailTo = -1L; private static string mailText = ""; private static readonly HashSet<ItemData> attached = new HashSet<ItemData>(); private static bool typingMail; private static GUIStyle mailField; private const float HudW = 236f; private const float RowH = 44f; private const float HeadH = 20f; private static bool hudDragging; private static Vector2 hudGrab; private static bool optMode; private static string selectedOpt; private static Vector2 optScroll; private static bool optTrackerDragging; private static Vector2 optTrackerGrab; private static string selectedQuest; private static string questMsg; private static float questMsgUntil; private static Vector2 questScroll; private static Vector2 trackerGrab; private static bool trackerDragging; private static string shopMsg; private static float shopMsgUntil; private static Vector2 shopScroll; public static bool Open; private static readonly Color Gold = new Color(0.83f, 0.68f, 0.32f); private static readonly Color GoldBright = new Color(1f, 0.86f, 0.42f); private static readonly Color Parchment = new Color(0.93f, 0.88f, 0.75f); private static readonly Color Muted = new Color(0.66f, 0.62f, 0.54f); private static readonly Color Silver = new Color(0.74f, 0.76f, 0.8f); private static readonly Color Locked = new Color(0.3f, 0.29f, 0.28f); private static readonly Color Red = new Color(1f, 0.52f, 0.46f); private static readonly Color Green = new Color(0.55f, 0.92f, 0.55f); private static GUIStyle lbl; private static float uiScale = 1f; private static float tzoom = 0.42f; private static int modal; private static readonly string[] buildNames = new string[6]; private static GUIStyle nameField; private static bool typingBuilds; private static Vector2 tpan; private static Vector2 tDragLast; private static bool tInit; private static bool tDragging; private static Material glMat; private static int tab; private static float zoom = 0.85f; private static Vector2 pan; private static bool treeInit; private static bool dragging; private static Vector2 dragLast; private static int lastDrawFrame; private static string toast; private static float toastUntil; private static readonly float[] prevCd = new float[2]; private static readonly float[] flashUntil = new float[2]; private static bool maximized; private static string partyMsg; private static float partyMsgUntil; private const float RowPitch = 124f; private static readonly float[] ColX = new float[3] { 150f, 410f, 670f }; public static bool HudDragHeld { get { //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (((Plugin.PartyHud.Value && Party.InParty) || (Plugin.QuestTracker.Value && Plugin.QuestsEnabled.Value) || Plugin.ClockHud.Value) && !Open && Input.GetKey(Plugin.PartyHudDragKey.Value)) { return !BlockedByOtherUi(); } return false; } } public static bool Typing { get { if (!typingBuilds) { return typingMail; } return true; } } public static void BlueprintToast(string msg) { bpMsg = msg; bpMsgUntil = Time.realtimeSinceStartup + 5f; if ((Object)(object)Player.m_localPlayer != (Object)null && !Open) { ((Character)Player.m_localPlayer).Message((MessageType)1, msg, 0, (Sprite)null, false); } } private static void BlueprintView(RpgData d, Rect p, Color accent) { //IL_0032: 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_005f: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: 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_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_023c: 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_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_038e: 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_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref p)).x + 40f; float num2 = ((Rect)(ref p)).y + 150f; float num3 = ((Rect)(ref p)).width - 80f; Text(new Rect(num, num2, num3, 26f), L.T("bp.title"), 20, Parchment, (TextAnchor)3, bold: true, wrap: false, shadow: true); Text(new Rect(num, num2 + 28f, num3, 40f), L.T("bp.rules"), 13, Muted, (TextAnchor)0, bold: false, wrap: true); Img(new Rect(num, num2 + 70f, num3, 14f), Tex.Divider, Gold); Blueprints.RequestList(); float num4 = num2 + 96f; Text(new Rect(num, num4, num3 - 260f, 30f), Blueprints.HasActive ? L.F("bp.active", Blueprints.ActiveName) : L.T("bp.none_active"), 14, Gold, (TextAnchor)3, bold: true); if (RawBtn(new Rect(num + num3 - 240f, num4 - 2f, 240f, 34f), L.T("bp.clear"), new Color(0.2f, 0.17f, 0.14f), Blueprints.HasActive, 13)) { Blueprints.ClearActive(); } num4 += 44f; Rect r = default(Rect); ((Rect)(ref r))..ctor(num, num4, num3, ((Rect)(ref p)).yMax - num4 - 90f); Fill(new Rect(((Rect)(ref r)).x - 2f, ((Rect)(ref r)).y - 2f, ((Rect)(ref r)).width + 4f, ((Rect)(ref r)).height + 4f), new Color(Gold.r * 0.45f, Gold.g * 0.45f, Gold.b * 0.45f)); Fill(r, new Color(0.06f, 0.055f, 0.05f, 0.96f)); List<Blueprints.Bp> list = Blueprints.List; if (list.Count == 0) { Text(new Rect(((Rect)(ref r)).x + 14f, ((Rect)(ref r)).y + 12f, ((Rect)(ref r)).width - 28f, 40f), L.T("bp.empty"), 14, Muted, (TextAnchor)0, bold: false, wrap: true); } float num5 = 46f; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x + 4f, ((Rect)(ref r)).y + 4f, ((Rect)(ref r)).width - 8f, ((Rect)(ref r)).height - 8f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, 0f, ((Rect)(ref val)).width - 18f, Mathf.Max(((Rect)(ref val)).height, (float)list.Count * num5)); bpScroll = GUI.BeginScrollView(val, bpScroll, val2); long num6 = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetPlayerID() : 0); Rect r2 = default(Rect); for (int i = 0; i < list.Count; i++) { Blueprints.Bp bp = list[i]; ((Rect)(ref r2))..ctor(4f, (float)i * num5 + 2f, ((Rect)(ref val2)).width - 8f, num5 - 6f); Fill(r2, new Color(1f, 1f, 1f, 0.04f)); Text(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 2f, ((Rect)(ref r2)).width - 330f, 22f), bp.Name, 15, GoldBright, (TextAnchor)3, bold: true); Text(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 22f, ((Rect)(ref r2)).width - 330f, 18f), L.F("bp.row_info", bp.Count, bp.Author), 11, Silver, (TextAnchor)3); if (RawBtn(new Rect(((Rect)(ref r2)).xMax - 300f, ((Rect)(ref r2)).y + 4f, 140f, 32f), L.T("bp.use"), new Color(0.15f, 0.3f, 0.18f), enabled: true, 13)) { Blueprints.Select(bp); } if (RawBtn(new Rect(((Rect)(ref r2)).xMax - 150f, ((Rect)(ref r2)).y + 4f, 140f, 32f), L.T("bp.delete"), new Color(0.35f, 0.12f, 0.1f), bp.AuthorPid == num6, 13)) { Blueprints.Delete(bp); } } GUI.EndScrollView(); if (bpMsg != null && Time.realtimeSinceStartup < bpMsgUntil) { Text(new Rect(num, ((Rect)(ref p)).yMax - 62f, num3, 26f), bpMsg, 15, GoldBright, (TextAnchor)3, bold: true, wrap: false, shadow: true); } } private static void BlueprintHud(float vw, float vh) { //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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) string hint = Blueprints.Hint; if (hint != null) { Rect r = new Rect(vw / 2f - 300f, vh - 170f, 600f, 26f); Fill(r, new Color(0.05f, 0.045f, 0.04f, 0.7f)); Text(r, hint, 13, Parchment, (TextAnchor)4, bold: true); } } private static void ClockHud(float vw, float vh) { //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Invalid comparison between Unknown and I4 //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Invalid comparison between Unknown and I4 //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: 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_021a: 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_01bc: 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_01d9: 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_02d1: 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_0316: 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_0320: 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_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) if (Plugin.ClockHud.Value && !((Object)(object)EnvMan.instance == (Object)null)) { int num = Mathf.FloorToInt(EnvMan.instance.GetDayFraction() * 24f * 60f) % 1440; int num2 = num / 60; int num3 = num % 60; string text = (Plugin.Clock24h.Value ? (num2.ToString("00") + ":" + num3.ToString("00")) : (((num2 % 12 == 0) ? 12 : (num2 % 12)) + ":" + num3.ToString("00") + ((num2 < 12) ? " AM" : " PM"))); string t = L.T("clock.day") + " " + EnvMan.instance.GetDay(ZNet.instance.GetTimeSeconds()) + " " + text; float num4 = 150f; float num5 = 26f; float num6 = ((Plugin.ClockHudX.Value < 0f) ? (vw - num4 - 24f) : Plugin.ClockHudX.Value); num6 = Mathf.Clamp(num6, 0f, Mathf.Max(0f, vw - num4)); float num7 = Mathf.Clamp(Plugin.ClockHudY.Value, 0f, Mathf.Max(0f, vh - num5)); Rect r = default(Rect); ((Rect)(ref r))..ctor(num6, num7, num4, num5); bool num8 = Cursor.visible || (int)Cursor.lockState == 0 || HudDragHeld; Event current = Event.current; if (num8 && (int)current.type == 0 && current.button == 0 && ((Rect)(ref r)).Contains(current.mousePosition)) { clockDragging = true; clockGrab = current.mousePosition - new Vector2(num6, num7); current.Use(); } else if (clockDragging && (int)current.type == 3) { Vector2 val = current.mousePosition - clockGrab; Plugin.ClockHudX.Value = Mathf.Clamp(val.x, 0f, Mathf.Max(0f, vw - num4)); Plugin.ClockHudY.Value = Mathf.Clamp(val.y, 0f, Mathf.Max(0f, vh - num5)); current.Use(); } if ((int)current.rawType == 1) { clockDragging = false; } bool flag = num8 && (clockDragging || ((Rect)(ref r)).Contains(current.mousePosition)); Fill(new Rect(((Rect)(ref r)).x - 1f, ((Rect)(ref r)).y - 1f, ((Rect)(ref r)).width + 2f, ((Rect)(ref r)).height + 2f), (Color)(flag ? GoldBright : new Color(Gold.r * 0.5f, Gold.g * 0.5f, Gold.b * 0.5f, 0.8f))); Fill(r, new Color(0.05f, 0.045f, 0.04f, 0.7f)); Text(r, t, 13, Gold, (TextAnchor)4, bold: true); } } private static void CompanionView(RpgData d, Rect p, Color accent) { //IL_0032: 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_005f: 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_00a4: 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_00df: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_02ae: 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_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0303: 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_0352: 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) //IL_037f: 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_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_0806: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Unknown result type (might be due to invalid IL or missing references) //IL_0714: Unknown result type (might be due to invalid IL or missing references) //IL_0672: Unknown result type (might be due to invalid IL or missing references) //IL_076a: Unknown result type (might be due to invalid IL or missing references) //IL_0788: Unknown result type (might be due to invalid IL or missing references) //IL_072a: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_06b4: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref p)).x + 40f; float num2 = ((Rect)(ref p)).y + 150f; float num3 =