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 EliteCrafting v0.11.4
plugins\EliteCrafting.dll
Decompiled a month 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.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BundlePrefabs; using Charter; using ConfigReload; using EliteCrafting.Affixes; using EliteCrafting.Commands; using EliteCrafting.Config; using EliteCrafting.Core; using EliteCrafting.Display; using EliteCrafting.Display.Backdrops; using EliteCrafting.Effects; using EliteCrafting.Effects.Combat3; using EliteCrafting.Items; using EliteCrafting.Loot; using EliteCrafting.Rolling; using EliteCrafting.Rules; using EliteCrafting.Sockets; using EliteCrafting.Stones; using EliteCrafting.Tables.Window; using EliteCrafting.Text; using HarmonyLib; using Microsoft.CodeAnalysis; using PatchGuard; using StatusTemplates; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; using Valheim.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.RepresentationModel; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Gerald Glasgow")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) Gerald Glasgow. Licensed under the GNU General Public License v3.0.")] [assembly: AssemblyDescription("EliteCrafting: crafting stones and magic item inscriptions across six rarities")] [assembly: AssemblyFileVersion("0.11.4.0")] [assembly: AssemblyInformationalVersion("0.11.4+e7ca4864809d9f204073765b3e1ac294711fc925")] [assembly: AssemblyProduct("EliteCrafting")] [assembly: AssemblyTitle("EliteCrafting")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.11.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 EliteCrafting { [BepInPlugin("com.EliteCrafting", "EliteCrafting", "0.11.4")] public sealed class EliteCraftingPlugin : BaseUnityPlugin { public const string PluginGuid = "com.EliteCrafting"; public const string PluginName = "EliteCrafting"; public const string PluginVersion = "0.11.4"; private void Awake() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown Log.Bind(((BaseUnityPlugin)this).Logger); ConfigReloader.HoldSaves(((BaseUnityPlugin)this).Config); ServerBinding.Create(((BaseUnityPlugin)this).Config, "com.EliteCrafting", "0.11.4"); ActiveRules.Initialise(ServerBinding.Charter); ModSettings.Bind(((BaseUnityPlugin)this).Config); Words.Initialise(); InitFeatures(); Harmony harmony = new Harmony("com.EliteCrafting"); PatchEach(harmony); InitArea("EffectsFeature.Register", delegate { EffectsFeature.Register(harmony); }); global::Charter.Charter.Install(harmony); Guard.Install(harmony, ((BaseUnityPlugin)this).Logger, Assembly.GetExecutingAssembly()); Words.InstallNow(); ConfigReloader.Setup(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EliteCrafting 0.11.4 ready."); } private static void InitFeatures() { InitArea("ItemsFeature.Init", ItemsFeature.Init); InitArea("StonesFeature.Init", StonesFeature.Init); InitArea("EffectsFeature.Init", EffectsFeature.Init); InitArea("DisplayFeature.Init", DisplayFeature.Init); InitArea("LootFeature.Init", LootFeature.Init); InitArea("CommandsFeature.Init", CommandsFeature.Init); } private static void InitArea(string name, Action init) { try { Guard.Run(name, init); } catch (Exception) { } } private static void PatchEach(Harmony harmony) { Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(Assembly.GetExecutingAssembly()); foreach (Type type in typesFromAssembly) { try { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Length != 0) { harmony.CreateClassProcessor(type).Patch(); } } catch (Exception arg) { Log.Error($"patch {type.FullName} failed to apply, its feature is off: {arg}"); } } } } } namespace EliteCrafting.Tables { internal static class BowlChamber { private const string Effect = "ecf_essence_chamber"; private const float AuthoredRadius = 0.217f; private static GameObject? _effect; private static bool _tried; public static GameObject? Make(Transform bowl) { GameObject val = Prepared(); if (!((Object)(object)val != (Object)null)) { return null; } return Object.Instantiate<GameObject>(val, bowl, false); } public static void Fit(GameObject chamber, float radius) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) float num = radius / 0.217f; chamber.transform.localScale = Vector3.one * num; ParticleSystem[] componentsInChildren = chamber.GetComponentsInChildren<ParticleSystem>(true); ParticleSystem[] componentsInChildren2 = _effect.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length && i < componentsInChildren2.Length; i++) { Thin(componentsInChildren[i].emission, componentsInChildren2[i].emission, num * num); } } private static void Thin(EmissionModule emission, EmissionModule authored, float share) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0039: Unknown result type (might be due to invalid IL or missing references) ((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref authored)).rateOverTimeMultiplier * share; for (int i = 0; i < ((EmissionModule)(ref emission)).burstCount; i++) { Burst burst = ((EmissionModule)(ref emission)).GetBurst(i); Burst burst2 = ((EmissionModule)(ref authored)).GetBurst(i); ((Burst)(ref burst)).probability = ((Burst)(ref burst2)).probability * share; ((EmissionModule)(ref emission)).SetBurst(i, burst); } } private static GameObject? Prepared() { if (_tried || (Object)(object)ZNetScene.instance == (Object)null) { return _effect; } _tried = true; try { _effect = BundleEffects.Prepare(EmbeddedBundle.Load(typeof(BowlChamber).Assembly, "ecf_tablefx"), "ecf_essence_chamber"); } catch (Exception ex) { Log.Warn("the Rune Table's essence chamber did not load, the essence shows without it: " + ex.Message); } return _effect; } } internal sealed class Essence { public int Index { get; } public string Id { get; } public string IconItem { get; } public Color Color { get; } public ISet<string> Inscriptions { get; } public string NameKey => "$ecf_essence_" + Id; public Essence(int index, string id, string iconItem, Color color, params string[] inscriptions) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Index = index; Id = id; IconItem = iconItem; Color = color; Inscriptions = new HashSet<string>(inscriptions); } } [HarmonyPatch] internal static class EssenceItem { public const string PrefabName = "ECF_Essence"; private const string Base = "Wisp"; private const int Stack = 100; private static GameObject? _holder; public static GameObject? Prefab { get; private set; } public static bool Is(ItemData? item) { if ((Object)(object)item?.m_dropPrefab != (Object)null) { return ((Object)item.m_dropPrefab).name == "ECF_Essence"; } return false; } [HarmonyPatch(typeof(ZNetScene), "Awake")] [HarmonyPrefix] private static void SceneAwake(ZNetScene __instance) { Guard(delegate { AddTo(__instance.m_prefabs, null); }); } [HarmonyPatch(typeof(ObjectDB), "Awake")] [HarmonyPostfix] [HarmonyPriority(0)] private static void DatabaseAwake(ObjectDB __instance) { Guard(delegate { AddTo(__instance.m_items, __instance); }); } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] [HarmonyPostfix] [HarmonyPriority(0)] private static void DatabaseCopy(ObjectDB __instance) { Guard(delegate { AddTo(__instance.m_items, __instance); }); } private static void AddTo(List<GameObject> list, ObjectDB? database) { if ((Object)(object)Prefab == (Object)null) { Prefab = Build(list.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == "Wisp")); } if (!((Object)(object)Prefab == (Object)null) && !list.Contains(Prefab)) { list.Add(Prefab); if (database != null) { database.UpdateRegisters(); } } } private static GameObject? Build(GameObject? wisp) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if ((Object)(object)wisp == (Object)null || (Object)(object)wisp.GetComponent<ItemDrop>() == (Object)null) { return null; } _holder = new GameObject("EliteCrafting_Essence"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); GameObject val = Object.Instantiate<GameObject>(wisp, _holder.transform, false); ((Object)val).name = "ECF_Essence"; StripMistClearing(val); Configure(val.GetComponent<ItemDrop>(), val); Log.Info("pure essence item built"); return val; } private static void Configure(ItemDrop drop, GameObject prefab) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) SharedData shared = drop.m_itemData.m_shared; shared.m_name = "$ecf_essence_item"; shared.m_description = "$ecf_essence_item_desc"; shared.m_maxStackSize = 100; shared.m_weight = 0.1f; shared.m_teleportable = true; shared.m_itemType = (ItemType)1; Sprite val = EssenceIcons.Item(); if ((Object)(object)val != (Object)null) { shared.m_icons = (Sprite[])(object)new Sprite[1] { val }; } drop.m_itemData.m_dropPrefab = prefab; } private static void StripMistClearing(GameObject copy) { Component[] componentsInChildren = copy.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if ((Object)(object)val != (Object)null && (((object)val).GetType().Name == "Demister" || ((object)val).GetType().Name == "ParticleSystemForceField")) { Object.DestroyImmediate((Object)(object)val); } } } private static void Guard(Action work) { try { work(); } catch (Exception arg) { Log.Error($"the pure essence item could not be made: {arg}"); } } } internal static class Essences { public const int CostPerLevel = 10; public static readonly Essence[] All = new Essence[5] { new Essence(0, "beast", "WolfFang", new Color(0.86f, 0.62f, 0.38f), "honed_might", "keen_edge", "needlepoint", "keen_eye", "brutal_strikes", "slayer_beasts", "slayer_sea", "ambusher", "cruel_opening", "sundering", "deathblow", "nightstalker", "glass_cannon", "wind_siphon", "reaper", "endurance", "second_wind", "balanced_grip", "quickened", "swift_casting", "swift_string", "quick_windlass", "true_flight", "volley", "twincast", "long_reach", "sweeping_arc"), new Essence(1, "stone", "Stone", new Color(0.72f, 0.72f, 0.66f), "hardened", "padded", "mailed", "riveted", "ironclad", "arrowward", "resolute", "ironroot", "quick_recovery", "stalwart", "repelling_guard", "perfect_guard", "tireless_guard", "anchored_guard", "keen_guard", "bramblehide", "vigor", "stout_heart", "forsaken_ward", "bonebreaker", "staggering_blows", "dazing_blows", "mighty_blows", "press_the_advantage", "heavy_hand", "troll_blood", "mending"), new Essence(2, "elemental", "SurtlingCore", new Color(0.6f, 0.9f, 1f), "emberbrand", "rimebrand", "stormbrand", "venombrand", "primal_fury", "thors_chain", "numbing_blow", "bursting_shot", "lingering_wounds", "hamstring", "flameward", "frostward", "stormward", "venomward", "elemental_ward", "bulwark_fire", "bulwark_frost", "bulwark_lightning", "bulwark_poison", "ember_skin", "quench", "ashen_skin", "emberheart", "coldblood", "winterborn", "purity"), new Essence(3, "spirit", "Wisp", new Color(0.8f, 0.74f, 1f), "spiritbrand", "spiritward", "wrath", "wellspring", "seidr_flow", "restless_mind", "seidr_thrift", "seidr_siphon", "soul_reaper", "seidr_riposte", "runic_ward", "mist_veil", "rune_edge"), new Essence(4, "grave", "BoneFragments", new Color(0.9f, 0.88f, 0.78f), "blood_drinker", "blood_thrift", "blood_price", "slayer_undead", "grave_vigor", "grave_command", "shield_mend", "berserkergang") }; private static readonly Dictionary<string, Essence> ById = Index(); public static Essence? Get(string? id) { if (id == null || !ById.TryGetValue(id, out Essence value)) { return null; } return value; } public static int CostFor(int itemLevel) { return 10 * Mathf.Clamp(itemLevel, 1, 8); } private static Dictionary<string, Essence> Index() { Dictionary<string, Essence> dictionary = new Dictionary<string, Essence>(); Essence[] all = All; foreach (Essence essence in all) { dictionary[essence.Id] = essence; } return dictionary; } } internal static class RuneStash { public static int StoreAll(TableStore store, Inventory inventory) { if (!store.Writable) { return 0; } int num = 0; string[] allIds = StoneCatalog.AllIds; foreach (string runeId in allIds) { int num2 = RuneBag.Count(inventory, runeId); RuneBag.Remove(inventory, runeId, num2); store.AddRunes(runeId, num2); num += num2; } int num3 = RuneBag.CountPrefab(inventory, "ECF_Essence"); RuneBag.RemovePrefab(inventory, "ECF_Essence", num3); store.AddEssence(num3); return num + num3; } public static int StoreStack(TableStore store, Inventory inventory, ItemData item) { string text = StoneIdOf(item); bool flag = EssenceItem.Is(item); if (!store.Writable || (text == null && !flag) || !inventory.ContainsItem(item)) { return 0; } int stack = item.m_stack; inventory.RemoveItem(item); if (text != null) { store.AddRunes(text, stack); } else { store.AddEssence(stack); } return stack; } public static int TakeOut(TableStore store, Inventory inventory, string runeId, int amount) { int num = (store.Writable ? Mathf.Min(store.Runes(runeId), amount) : 0); int num2 = ((num > 0) ? Give(inventory, StonePrefabs.Get(runeId), num) : 0); if (num2 <= 0 || !store.TakeRunes(runeId, num2)) { return 0; } return num2; } public static int TakeEssence(TableStore store, Inventory inventory, int amount) { int num = (store.Writable ? Mathf.Min(store.Essence, amount) : 0); int num2 = ((num > 0) ? Give(inventory, EssenceItem.Prefab, num) : 0); if (num2 <= 0 || !store.TakeEssence(num2)) { return 0; } return num2; } private static int Give(Inventory inventory, GameObject? prefab, int count) { ItemDrop val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { return 0; } int num = RuneBag.CountPrefab(inventory, ((Object)prefab).name); int num2 = Mathf.Max(1, val.m_itemData.m_shared.m_maxStackSize); int num3 = count; while (num3 > 0 && inventory.AddItem(Stack(val, prefab, Mathf.Min(num3, num2)))) { num3 -= num2; } return RuneBag.CountPrefab(inventory, ((Object)prefab).name) - num; } public static string? StoneIdOf(ItemData? item) { string text = (((Object)(object)item?.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : null); string[] allIds = StoneCatalog.AllIds; foreach (string text2 in allIds) { if (text == StoneCatalog.PrefabFor(text2)) { return text2; } } return null; } public static int Carried(Inventory inventory) { int num = 0; string[] allIds = StoneCatalog.AllIds; foreach (string runeId in allIds) { num += RuneBag.Count(inventory, runeId); } return num + RuneBag.CountPrefab(inventory, "ECF_Essence"); } public static void DropAll(TableStore store, Vector3 at) { //IL_0038: 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) if (!store.Writable) { return; } string[] allIds = StoneCatalog.AllIds; foreach (string text in allIds) { int num = store.Runes(text); if (num > 0 && store.TakeRunes(text, num)) { Drop(StonePrefabs.Get(text), num, at); } } int essence = store.Essence; if (essence > 0 && store.TakeEssence(essence)) { Drop(EssenceItem.Prefab, essence, at); } } private static ItemData Stack(ItemDrop drop, GameObject prefab, int count) { ItemData obj = drop.m_itemData.Clone(); obj.m_dropPrefab = prefab; obj.m_stack = count; obj.m_worldLevel = (byte)Game.m_worldLevel; return obj; } private static void Drop(GameObject? prefab, int count, Vector3 at) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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) ItemDrop val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null); if (!((Object)(object)val == (Object)null)) { int num = Mathf.Max(1, val.m_itemData.m_shared.m_maxStackSize); for (int num2 = count; num2 > 0; num2 -= num) { ItemData obj = Stack(val, prefab, Mathf.Min(num2, num)); Vector3 val2 = at + Vector3.up * 0.5f + Random.insideUnitSphere * 0.3f; ItemDrop.DropItem(obj, 0, val2, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)); } } } } internal sealed class RuneTable : MonoBehaviour, Hoverable, Interactable { private const string OpenRpc = "ECF_RT_Open"; private const string OpenedRpc = "ECF_RT_Opened"; public const float UseDistance = 3f; private ZNetView? _view; public TableStore Store { get; private set; } public bool IsValid { get { if ((Object)(object)_view != (Object)null) { return _view.IsValid(); } return false; } } private void Awake() { _view = ((Component)this).GetComponent<ZNetView>(); Store = new TableStore(_view); if (!((Object)(object)_view == (Object)null) && _view.GetZDO() != null) { _view.Register<long>("ECF_RT_Open", (Action<long, long>)RPC_Open); _view.Register<bool>("ECF_RT_Opened", (Action<long, bool>)RPC_Opened); WearNTear component = ((Component)this).GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_onDestroyed = (Action)Delegate.Combine(component.m_onDestroyed, new Action(DropStash)); } } } private void DropStash() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) try { RuneStash.DropAll(Store, ((Component)this).transform.position); } catch (Exception arg) { Log.Error($"the Rune Table's runes could not be dropped: {arg}"); } } public string GetHoverText() { string text = "$ecf_table_name"; if (!ModSettings.RuneTable.Value) { return Localization.instance.Localize(text + "\n<color=#888888>$ecf_table_off</color>"); } return Localization.instance.Localize(text + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use"); } public string GetHoverName() { return "$ecf_table_name"; } public float GetHoverOffset() { return 0f; } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer || !IsValid) { return false; } if (!ModSettings.RuneTable.Value) { ((Character)user).Message((MessageType)2, "$ecf_table_off", 0, (Sprite)null, false); return false; } if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return true; } _view.InvokeRPC("ECF_RT_Open", new object[1] { Game.instance.GetPlayerProfile().GetPlayerID() }); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } private void RPC_Open(long sender, long playerId) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (_view.IsOwner()) { if (TableWindow.IsOpenAt(this) && sender != ZNet.GetUID()) { _view.InvokeRPC(sender, "ECF_RT_Opened", new object[1] { false }); return; } ZDOMan.instance.ForceSendZDO(sender, _view.GetZDO().m_uid); _view.GetZDO().SetOwner(sender); _view.InvokeRPC(sender, "ECF_RT_Opened", new object[1] { true }); } } private void RPC_Opened(long sender, bool granted) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { if (!granted) { ((Character)localPlayer).Message((MessageType)2, "$msg_inuse", 0, (Sprite)null, false); } else { TableWindow.Open(this); } } } public bool InReach(Player player) { //IL_000f: 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) if ((Object)(object)player != (Object)null) { return Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) <= 4f; } return false; } } internal sealed class TableBowl : MonoBehaviour { private const float Every = 0.5f; private const int Step = 50; private const int Steps = 10; private const float BowlMiddle = 1.105f; private const float Lowest = 1.1f; private const float Highest = 1.185f; private const float Margin = 0.94f; private static readonly Vector2[] Inside = (Vector2[])(object)new Vector2[3] { new Vector2(1.095f, 0.13f), new Vector2(1.13f, 0.21f), new Vector2(1.195f, 0.235f) }; private ZNetView? _view; private TableStore? _store; private Transform? _bowl; private Material? _glow; private GameObject? _surface; private GameObject? _chamber; private uint _seen = uint.MaxValue; private int _level = -1; private float _next; private void Awake() { _view = ((Component)this).GetComponent<ZNetView>(); _store = (((Object)(object)_view != (Object)null) ? new TableStore(_view) : null); _bowl = TableShelf.Find(((Component)this).transform, "col_box_bowl"); Transform? obj = TableShelf.Find(((Component)this).transform, "glow"); object glow; if (obj == null) { glow = null; } else { MeshRenderer component = ((Component)obj).GetComponent<MeshRenderer>(); glow = ((component != null) ? ((Renderer)component).sharedMaterial : null); } _glow = (Material?)glow; ((Behaviour)this).enabled = (Object)(object)_bowl != (Object)null && (Object)(object)_glow != (Object)null && !StoneVisuals.Headless; } private void Update() { if (!(Time.time < _next) && _store != null && _store.Valid) { _next = Time.time + 0.5f; uint dataRevision = _view.GetZDO().DataRevision; if (dataRevision != _seen) { _seen = dataRevision; Show(Mathf.Min(_store.Essence / 50, 10)); } } } private void Show(int level) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (level == _level) { return; } _level = level; if (level > 0 && (Object)(object)_surface == (Object)null) { _surface = BowlSurface.Make(_bowl, _glow); _chamber = BowlChamber.Make(_bowl); } if (!((Object)(object)_surface == (Object)null)) { float height = Mathf.Lerp(1.1f, 1.185f, ((float)Mathf.Max(level, 1) - 1f) / 9f); float num = RadiusAt(height) * 0.94f; Place(_surface, level, height); _surface.transform.localScale = new Vector3(2f * num, 1f, 2f * num); if ((Object)(object)_chamber != (Object)null) { Place(_chamber, level, height); BowlChamber.Fit(_chamber, num); } } } private static void Place(GameObject part, int level, float height) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) part.SetActive(level > 0); part.transform.localPosition = new Vector3(0f, height - 1.105f, 0f); } private static float RadiusAt(float height) { for (int i = 1; i < Inside.Length; i++) { if (height <= Inside[i].x) { float num = Mathf.InverseLerp(Inside[i - 1].x, Inside[i].x, height); return Mathf.Lerp(Inside[i - 1].y, Inside[i].y, num); } } return Inside[Inside.Length - 1].y; } } internal static class BowlSurface { private const int Sides = 24; private static Mesh? _disc; private static Material? _material; public static GameObject Make(Transform bowl, Material glow) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown GameObject val = new GameObject("ecf_bowl_essence") { layer = ((Component)bowl).gameObject.layer }; val.transform.SetParent(bowl, false); val.AddComponent<MeshFilter>().sharedMesh = _disc ?? (_disc = Disc()); MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = _material ?? (_material = Whiten(glow)); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; return val; } private static Mesh Disc() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a1: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[25]; int[] array2 = new int[72]; for (int i = 0; i < 24; i++) { float num = (float)Math.PI * 2f * (float)i / 24f; array[i + 1] = new Vector3(0.5f * Mathf.Cos(num), 0f, 0.5f * Mathf.Sin(num)); array2[i * 3] = 0; array2[i * 3 + 1] = (i + 1) % 24 + 1; array2[i * 3 + 2] = i + 1; } Mesh val = new Mesh { name = "ecf_bowl_essence", vertices = array, triangles = array2 }; val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static Material Whiten(Material glow) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_003b: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown Material val = new Material(glow) { name = "ecf_bowl_essence", color = new Color(0.78f, 0.81f, 0.86f) }; val.SetFloat("_Glossiness", 0.45f); val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", new Color(0.2f, 0.23f, 0.27f)); return val; } } internal sealed class TableCast : MonoBehaviour { private const float Every = 0.1f; private static readonly Vector3 SlabTop = new Vector3(0.08f, 1.02f, 0f); private ZNetView? _view; private TableStore? _store; private Transform? _model; private int _seen = -1; private float _next; private void Awake() { _view = ((Component)this).GetComponent<ZNetView>(); _store = (((Object)(object)_view != (Object)null) ? new TableStore(_view) : null); Transform? obj = TableShelf.Find(((Component)this).transform, "col_box_table"); _model = ((obj != null) ? obj.parent : null); ((Behaviour)this).enabled = !StoneVisuals.Headless; } private void Update() { if (Time.time < _next || _store == null || !_store.Valid) { return; } _next = Time.time + 0.1f; int casts = _store.Casts; if (casts != _seen) { bool num = _seen < 0; _seen = casts; if (!num) { Play(_store.CastStone); } } } private void Play(string stoneId) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_003c: Unknown result type (might be due to invalid IL or missing references) Vector3 at = (((Object)(object)_model != (Object)null) ? _model.TransformPoint(SlabTop) : (((Component)this).transform.position + Vector3.up)); TableSound.Play(at); TableVortex.Spawn(at, StoneVisuals.Tint(stoneId)); } } internal sealed class TableGems : MonoBehaviour { private const float Every = 0.5f; private const float Top = 1f; private const float Widest = 0.16f; private static readonly Vector2[] Spots = (Vector2[])(object)new Vector2[11] { new Vector2(-0.64f, 0.38f), new Vector2(-0.87f, 0.38f), new Vector2(-1.1f, 0.38f), new Vector2(-1.33f, 0.38f), new Vector2(-0.755f, 0.15f), new Vector2(-0.985f, 0.15f), new Vector2(-1.215f, 0.15f), new Vector2(-0.64f, -0.08f), new Vector2(-0.87f, -0.08f), new Vector2(-1.1f, -0.08f), new Vector2(-1.33f, -0.08f) }; private readonly GameObject?[] _gems = (GameObject?[])(object)new GameObject[StoneCatalog.GemIds.Length]; private ZNetView? _view; private TableStore? _store; private Transform? _model; private uint _seen = uint.MaxValue; private float _next; private void Awake() { _view = ((Component)this).GetComponent<ZNetView>(); _store = (((Object)(object)_view != (Object)null) ? new TableStore(_view) : null); Transform? obj = TableShelf.Find(((Component)this).transform, "col_box_table"); _model = ((obj != null) ? obj.parent : null); ((Behaviour)this).enabled = (Object)(object)_model != (Object)null && !StoneVisuals.Headless; } private void Update() { if (Time.time < _next || _store == null || !_store.Valid) { return; } _next = Time.time + 0.5f; uint dataRevision = _view.GetZDO().DataRevision; if (dataRevision != _seen) { _seen = dataRevision; for (int i = 0; i < _gems.Length && i < Spots.Length; i++) { Show(i, _store.Runes(StoneCatalog.GemIds[i]) > 0); } } } private void Show(int index, bool on) { if (on && (Object)(object)_gems[index] == (Object)null) { _gems[index] = Make(index); } if ((Object)(object)_gems[index] != (Object)null && _gems[index].activeSelf != on) { _gems[index].SetActive(on); } } private GameObject? Make(int index) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) string text = StoneCatalog.GemIds[index]; GameObject val = StonePrefabs.Get(text); Transform val2 = (((Object)(object)val != (Object)null) ? val.transform.Find("attach/model") : null); if ((Object)(object)val2 == (Object)null) { return null; } GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, _model, false); ((Object)val3).name = "ecf_table_" + text; Collider[] componentsInChildren = val3.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } val3.transform.localRotation = Quaternion.Euler(0f, (float)index * 137f % 360f, 0f); Settle(val3, Spots[index]); return val3; } private void Settle(GameObject gem, Vector2 spot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) gem.transform.localPosition = new Vector3(spot.x, 1f, spot.y); Bounds val = WorldBounds(gem); float num = Mathf.Max(((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.z); if (num > 0.16f) { Transform transform = gem.transform; transform.localScale *= 0.16f / num; val = WorldBounds(gem); } Vector3 val2 = _model.TransformPoint(new Vector3(spot.x, 1f, spot.y)); Transform transform2 = gem.transform; transform2.position += new Vector3(val2.x - ((Bounds)(ref val)).center.x, val2.y - ((Bounds)(ref val)).min.y, val2.z - ((Bounds)(ref val)).center.z); } private static Bounds WorldBounds(GameObject gem) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003b: 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) Renderer[] componentsInChildren = gem.GetComponentsInChildren<Renderer>(true); Bounds result = (Bounds)((componentsInChildren.Length != 0) ? componentsInChildren[0].bounds : new Bounds(gem.transform.position, Vector3.zero)); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { ((Bounds)(ref result)).Encapsulate(val.bounds); } return result; } } [HarmonyPatch] internal static class TableHammer { private const string Hammer = "Hammer"; private static readonly (string Item, int Amount)[] Cost = new(string, int)[3] { ("Wood", 10), ("Stone", 10), ("GreydwarfEye", 5) }; private static bool _hooked; [HarmonyPatch(typeof(ObjectDB), "Awake")] [HarmonyPostfix] [HarmonyPriority(0)] private static void DatabaseAwake() { Refresh(); } [HarmonyPatch(typeof(ZNetScene), "Awake")] [HarmonyPostfix] private static void SceneAwake() { Refresh(); } public static void Refresh() { try { Hook(); Apply(ObjectDB.instance); } catch (Exception ex) { Log.Error("the Rune Table could not be put in the hammer: " + ex.Message); } } private static void Hook() { if (!_hooked && ModSettings.RuneTable != null) { _hooked = true; ModSettings.RuneTable.SettingChanged += delegate { Refresh(); }; } } private static void Apply(ObjectDB? database) { Piece piece = TablePrefab.Piece; PieceTable val = HammerTable(database); if (!((Object)(object)piece == (Object)null) && !((Object)(object)val == (Object)null)) { piece.m_resources = Requirements(database); bool value = ModSettings.RuneTable.Value; if (value && !val.m_pieces.Contains(((Component)piece).gameObject)) { val.m_pieces.Add(((Component)piece).gameObject); } else if (!value) { val.m_pieces.Remove(((Component)piece).gameObject); } } } private static PieceTable? HammerTable(ObjectDB? database) { GameObject val = (((Object)(object)database != (Object)null) ? database.GetItemPrefab("Hammer") : null); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if (!((Object)(object)val2 != (Object)null)) { return null; } return val2.m_itemData.m_shared.m_buildPieces; } private static Requirement[] Requirements(ObjectDB database) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); (string, int)[] cost = Cost; for (int i = 0; i < cost.Length; i++) { (string, int) tuple = cost[i]; string item = tuple.Item1; int item2 = tuple.Item2; GameObject itemPrefab = database.GetItemPrefab(item); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val != (Object)null) { list.Add(new Requirement { m_resItem = val, m_amount = item2, m_recover = true }); } } return list.ToArray(); } } internal static class TableModel { public const string Bundle = "ecf_runetable"; private const string Asset = "ecf_runetable"; private const string GlowPart = "glow"; private const string BodyRenderer = "high"; private const float Gloss = 0.1f; private static AssetBundle? _bundle; private static bool _tried; public static Sprite? Icon { get; private set; } public static bool Wear(GameObject piece) { AssetBundle? obj = Load(); GameObject val = ((obj != null) ? obj.LoadAsset<GameObject>("ecf_runetable") : null); if ((Object)(object)val == (Object)null) { return false; } Material wood = GameMaterials.Borrow(piece, "high"); Strip(piece); GameObject val2 = Object.Instantiate<GameObject>(val, piece.transform, false); ((Object)val2).name = "runetable"; Dress(val2, wood); SetLayer(val2.transform, piece.layer); Point(piece.GetComponent<WearNTear>(), val2); Icon = _bundle.LoadAsset<Sprite>("ecf_runetable_icon"); return true; } private static AssetBundle? Load() { if (_tried) { return _bundle; } _tried = true; try { _bundle = EmbeddedBundle.Load(typeof(TableModel).Assembly, "ecf_runetable"); } catch (Exception ex) { Log.Warn("the Rune Table's model did not load, it keeps the workbench's look: " + ex.Message); } return _bundle; } private static void Strip(GameObject piece) { for (int num = piece.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)piece.transform.GetChild(num)).gameObject); } Type[] array = new Type[4] { typeof(LODGroup), typeof(Renderer), typeof(MeshFilter), typeof(Collider) }; foreach (Type type in array) { Component[] components = piece.GetComponents(type); for (int j = 0; j < components.Length; j++) { Object.DestroyImmediate((Object)(object)components[j]); } } } private static void Dress(GameObject placed, Material? wood) { Renderer[] componentsInChildren = placed.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (IsGlow(((Component)val).transform, placed.transform)) { val.sharedMaterials = Array.ConvertAll(val.sharedMaterials, Glow); } else if (!((Object)(object)wood == (Object)null)) { Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { sharedMaterials[j] = (Material)(((Object)(object)sharedMaterials[j] == (Object)null) ? ((object)wood) : ((object)GameMaterials.Plain(GameMaterials.Dress(wood, sharedMaterials[j]), 0.1f))); } val.sharedMaterials = sharedMaterials; } } } private static Material Glow(Material placeholder) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Material val = new Material(placeholder); Shader val2 = Shader.Find("Standard"); if ((Object)(object)val2 != (Object)null) { val.shader = val2; val.EnableKeyword("_EMISSION"); } return val; } private static bool IsGlow(Transform part, Transform root) { Transform val = part; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) { if (((Object)val).name == "glow") { return true; } val = val.parent; } return false; } private static void SetLayer(Transform part, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown ((Component)part).gameObject.layer = layer; foreach (Transform item in part) { SetLayer(item, layer); } } private static void Point(WearNTear? wear, GameObject placed) { if (!((Object)(object)wear == (Object)null)) { wear.m_new = placed; wear.m_worn = placed; wear.m_broken = placed; wear.m_wet = null; wear.m_fragmentRoots = null; } } } [HarmonyPatch] internal static class TablePrefab { public const string PrefabName = "ECF_RuneTable"; private const string Source = "piece_workbench"; public static GameObject? Prefab { get; private set; } public static Piece? Piece { get { if (!((Object)(object)Prefab != (Object)null)) { return null; } return Prefab.GetComponent<Piece>(); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] [HarmonyPrefix] private static void SceneAwake(ZNetScene __instance) { try { AddTo(__instance.m_prefabs); } catch (Exception arg) { Log.Error($"the Rune Table could not be made: {arg}"); } } private static void AddTo(List<GameObject> prefabs) { if ((Object)(object)Prefab == (Object)null) { Prefab = Build(prefabs.Find((GameObject p) => (Object)(object)p != (Object)null && ((Object)p).name == "piece_workbench")); } if ((Object)(object)Prefab != (Object)null && !prefabs.Contains(Prefab)) { prefabs.Add(Prefab); } } private static GameObject? Build(GameObject? workbench) { if ((Object)(object)workbench == (Object)null || (Object)(object)workbench.GetComponent<Piece>() == (Object)null) { Log.Warn("the game's piece_workbench was not found: there is no Rune Table"); return null; } GameObject val = PrefabBench.Copy(workbench, "ECF_RuneTable"); Object.DestroyImmediate((Object)(object)val.GetComponent<CraftingStation>()); CircleProjector[] componentsInChildren = val.GetComponentsInChildren<CircleProjector>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)((Component)componentsInChildren[i]).gameObject); } TableModel.Wear(val); Configure(val.GetComponent<Piece>(), workbench); val.AddComponent<RuneTable>(); val.AddComponent<TableShelf>(); val.AddComponent<TableBowl>(); val.AddComponent<TableGems>(); val.AddComponent<TableCast>(); return val; } private static void Configure(Piece piece, GameObject workbench) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) piece.m_name = "$ecf_table_name"; piece.m_description = "$ecf_table_desc"; piece.m_category = (PieceCategory)1; piece.m_enabled = true; piece.m_craftingStation = workbench.GetComponent<CraftingStation>(); if ((Object)(object)TableModel.Icon != (Object)null) { piece.m_icon = TableModel.Icon; } } } internal sealed class TableShelf : MonoBehaviour { private const float Every = 0.5f; private const int Anchors = 7; private static readonly int First = Math.Max(0, (7 - StoneCatalog.BuiltInIds.Length) / 2); private readonly Transform?[] _anchors = (Transform?[])(object)new Transform[StoneCatalog.BuiltInIds.Length]; private readonly GameObject?[] _tablets = (GameObject?[])(object)new GameObject[StoneCatalog.BuiltInIds.Length]; private ZNetView? _view; private TableStore? _store; private uint _seen = uint.MaxValue; private float _next; private void Awake() { _view = ((Component)this).GetComponent<ZNetView>(); _store = (((Object)(object)_view != (Object)null) ? new TableStore(_view) : null); bool flag = false; for (int i = 0; i < _anchors.Length; i++) { _anchors[i] = Find(((Component)this).transform, "shelf_" + (i + First)); flag |= (Object)(object)_anchors[i] != (Object)null; } ((Behaviour)this).enabled = flag && !StoneVisuals.Headless; } private void Update() { if (Time.time < _next || _store == null || !_store.Valid) { return; } _next = Time.time + 0.5f; uint dataRevision = _view.GetZDO().DataRevision; if (dataRevision != _seen) { _seen = dataRevision; for (int i = 0; i < _anchors.Length; i++) { Show(i, _store.Runes(StoneCatalog.BuiltInIds[i]) > 0); } } } private void Show(int index, bool on) { if (on && (Object)(object)_tablets[index] == (Object)null && (Object)(object)_anchors[index] != (Object)null) { _tablets[index] = Make(StoneCatalog.BuiltInIds[index], _anchors[index]); } if ((Object)(object)_tablets[index] != (Object)null && _tablets[index].activeSelf != on) { _tablets[index].SetActive(on); } } private static GameObject? Make(string runeId, Transform anchor) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) MeshFilter val = TabletMesh(runeId); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, anchor, false); ((Object)val2).name = "ecf_shelf_" + runeId; Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } Bounds bounds = val.sharedMesh.bounds; val2.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); val2.transform.localPosition = new Vector3(0f - ((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.z, 0f - ((Bounds)(ref bounds)).min.y); val2.transform.localScale = Vector3.one; return val2; } private static MeshFilter? TabletMesh(string runeId) { GameObject val = StonePrefabs.Get(runeId); Transform val2 = (((Object)(object)val != (Object)null) ? val.transform.Find("attach/model") : null); MeshFilter val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponentInChildren<MeshFilter>(true) : null); if (!((Object)(object)val3 != (Object)null) || !((Object)(object)val3.sharedMesh != (Object)null)) { return null; } return val3; } internal static Transform? Find(Transform root, string name) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == name) { return val; } } return null; } } internal static class TableSound { private const string Sound = "sfx_levelup"; private const float Life = 6f; private static GameObject? _template; private static bool _tried; public static void Play(Vector3 at) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) GameObject val = Template(); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)Object.Instantiate<GameObject>(val, at, Quaternion.identity), 6f); } } private static GameObject? Template() { if (_tried || (Object)(object)ZNetScene.instance == (Object)null) { return _template; } _tried = true; GameObject prefab = ZNetScene.instance.GetPrefab("Player"); GameObject val = Find((prefab != null) ? prefab.GetComponent<Player>() : null); if ((Object)(object)val == (Object)null) { Log.Warn("the game's sfx_levelup was not found; Rune Table uses play no sound"); return null; } _template = PrefabBench.Copy(val, "ecf_table_levelup"); Object.DestroyImmediate((Object)(object)_template.GetComponent<ZNetView>()); Place(_template.GetComponent<AudioSource>()); return _template; } private static GameObject? Find(Player? player) { EffectData[] array = (EffectData[])(((Object)(object)player != (Object)null) ? ((Array)player.m_skillLevelupEffects.m_effectPrefabs) : ((Array)new EffectData[0])); foreach (EffectData val in array) { if ((Object)(object)val.m_prefab != (Object)null && ((Object)val.m_prefab).name == "sfx_levelup") { return val.m_prefab; } } return null; } private static void Place(AudioSource? source) { if (!((Object)(object)source == (Object)null)) { source.spatialBlend = 1f; source.rolloffMode = (AudioRolloffMode)1; source.minDistance = 4f; source.maxDistance = 20f; } } } internal sealed class TableStore { private static readonly Dictionary<string, int> RuneKeys = new Dictionary<string, int>(); private static readonly int EssenceKey = StringExtensionMethods.GetStableHashCode("ecf_rt_essence"); private static readonly int CastKey = StringExtensionMethods.GetStableHashCode("ecf_rt_cast"); private static readonly int CastStoneKey = StringExtensionMethods.GetStableHashCode("ecf_rt_cast_stone"); private readonly ZNetView _view; public bool Valid { get { if ((Object)(object)_view != (Object)null) { return _view.IsValid(); } return false; } } public bool Writable { get { if (Valid) { return _view.IsOwner(); } return false; } } public int Essence { get { if (!Valid) { return 0; } return _view.GetZDO().GetInt(EssenceKey, 0); } } public int Casts { get { if (!Valid) { return 0; } return _view.GetZDO().GetInt(CastKey, 0); } } public string CastStone { get { if (!Valid) { return ""; } return _view.GetZDO().GetString(CastStoneKey, ""); } } public static IEnumerable<string> RuneIds => StoneCatalog.BuiltInIds; public TableStore(ZNetView view) { _view = view; } public int Runes(string runeId) { if (!Valid) { return 0; } return _view.GetZDO().GetInt(RuneKey(runeId), 0); } public void MarkCast(string stoneId) { if (Writable) { ZDO zDO = _view.GetZDO(); zDO.Set(CastStoneKey, stoneId); zDO.Set(CastKey, zDO.GetInt(CastKey, 0) + 1, false); } } public bool AddRunes(string runeId, int count) { return Change(RuneKey(runeId), count); } public bool TakeRunes(string runeId, int count) { if (Runes(runeId) >= count) { return Change(RuneKey(runeId), -count); } return false; } public bool AddEssence(int amount) { return Change(EssenceKey, amount); } public bool TakeEssence(int amount) { if (Essence >= amount) { return Change(EssenceKey, -amount); } return false; } private bool Change(int key, int delta) { if (!Writable || delta == 0) { return Writable; } ZDO zDO = _view.GetZDO(); zDO.Set(key, Math.Max(0, zDO.GetInt(key, 0) + delta), false); return true; } private static int RuneKey(string runeId) { return KeyOf(RuneKeys, "ecf_rt_rune_", runeId); } private static int KeyOf(Dictionary<string, int> cache, string prefix, string id) { if (!cache.TryGetValue(id, out var value)) { value = (cache[id] = StringExtensionMethods.GetStableHashCode(prefix + id)); } return value; } } internal sealed class TableSupply : IRuneSupply { private readonly TableStore _store; private readonly Essence? _essence; public ISet<string>? Favoured => _essence?.Inscriptions; public TableSupply(TableStore store, Essence? essence) { _store = store; _essence = essence; } public int Held(string? runeId) { if (runeId != null) { return _store.Runes(runeId); } return 0; } public int EssenceHeld() { return _store.Essence; } public StoneMessage? Shortfall(StoneJob job) { if (!_store.Writable) { return new StoneMessage("table_lost", new string[0]); } if (_essence == null) { return null; } int num = Essences.CostFor(ItemTier.Of(job.Target)); if (EssenceHeld() < num) { return new StoneMessage("not_enough_essence", new string[1] { num.ToString() }); } return null; } public void Pay(StoneJob job) { string text = job.Def?.Id; if (text != null && job.Cost > 0) { _store.TakeRunes(text, job.Cost); } if (text != null) { _store.MarkCast(text); } if (_essence != null) { _store.TakeEssence(Essences.CostFor(ItemTier.Of(job.Target))); } } } internal static class RuneBag { public static int Count(Inventory inventory, string runeId) { return CountPrefab(inventory, StoneCatalog.PrefabFor(runeId)); } public static void Remove(Inventory inventory, string runeId, int count) { RemovePrefab(inventory, StoneCatalog.PrefabFor(runeId), count); } public static int CountPrefab(Inventory inventory, string prefab) { int num = 0; foreach (ItemData allItem in inventory.GetAllItems()) { if (ItemTier.PrefabName(allItem) == prefab) { num += allItem.m_stack; } } return num; } public static void RemovePrefab(Inventory inventory, string prefab, int count) { List<ItemData> allItems = inventory.GetAllItems(); int num = allItems.Count - 1; while (num >= 0 && count > 0) { ItemData val = allItems[num]; if (!(ItemTier.PrefabName(val) != prefab)) { int num2 = Math.Min(val.m_stack, count); inventory.RemoveItem(val, num2); count -= num2; } num--; } } } internal static class TableVortex { internal const string Bundle = "ecf_tablefx"; private const string Effect = "ecf_rune_vortex"; private const float Life = 4f; private const float Rise = 0.5f; private static readonly Dictionary<string, float> FootAlpha = new Dictionary<string, float> { ["ring"] = 0.8f, ["puff"] = 0.5f }; private static readonly Dictionary<int, GameObject> Templates = new Dictionary<int, GameObject>(); private static GameObject? _effect; private static bool _tried; public static void Spawn(Vector3 at, Color colour) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) GameObject val = Template(Color32.op_Implicit(colour)); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)Object.Instantiate<GameObject>(val, at, Quaternion.identity), 4f); } } private static GameObject? Template(Color32 colour) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) int num = (colour.r << 16) | (colour.g << 8) | colour.b; if (Templates.TryGetValue(num, out GameObject value) && (Object)(object)value != (Object)null) { return value; } GameObject val = Prepared(); if ((Object)(object)val == (Object)null) { return null; } value = PrefabBench.Copy(val, string.Format("{0}_{1:X6}", "ecf_rune_vortex", num)); ParticleRetint.Tint(value, Color32.op_Implicit(colour)); Templates[num] = value; return value; } private static GameObject? Prepared() { if (_tried || (Object)(object)ZNetScene.instance == (Object)null) { return _effect; } _tried = true; try { _effect = BundleEffects.Prepare(EmbeddedBundle.Load(typeof(TableVortex).Assembly, "ecf_tablefx"), "ecf_rune_vortex"); Settle(_effect); } catch (Exception ex) { Log.Warn("the Rune Table's vortex did not load, its uses only sound: " + ex.Message); } return _effect; } private static void Settle(GameObject? effect) { //IL_0030: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) ParticleSystem[] array = (ParticleSystem[])(((Object)(object)effect != (Object)null) ? ((Array)effect.GetComponentsInChildren<ParticleSystem>(true)) : ((Array)new ParticleSystem[0])); foreach (ParticleSystem val in array) { Unfade(((Component)val).GetComponent<ParticleSystemRenderer>()); VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime; if (((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled) { ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).yMultiplier = ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).yMultiplier * 0.5f; } if (FootAlpha.TryGetValue(((Object)val).name, out var value)) { MainModule main = val.main; MinMaxGradient startColor = ((MainModule)(ref main)).startColor; Color color = ((MinMaxGradient)(ref startColor)).color; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(color.r, color.g, color.b, value)); } } } private static void Unfade(ParticleSystemRenderer? renderer) { if ((Object)(object)renderer == (Object)null) { return; } foreach (Material item in ((Renderer)renderer).sharedMaterials.Append(renderer.trailMaterial)) { if ((Object)(object)item != (Object)null && item.HasProperty("_SoftNearFade")) { item.SetFloat("_SoftNearFade", 0f); } } } } internal static class TableWords { public const string Name = "$ecf_table_name"; public const string Description = "$ecf_table_desc"; public static string Colored(string text, Color color) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return "<color=#" + ColorUtility.ToHtmlStringRGB(color) + ">" + text + "</color>"; } public static string EssenceName(Essence essence) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Colored(Words.Localize(essence.NameKey), essence.Color); } public static string ClassName(ClassInfo info) { return DisplayWords.Name(info.Class?.Name, info.ClassId ?? ""); } public static string Biome(int level) { return Words.Localize("$ecf_table_level_" + Mathf.Clamp(level, 1, 8)); } } internal static class TrophyYields { private static readonly Dictionary<string, int> Yields = new Dictionary<string, int> { ["TrophyBoar"] = 2, ["TrophyNeck"] = 2, ["TrophyDeer"] = 2, ["TrophyGreydwarf"] = 4, ["TrophyBjorn"] = 4, ["TrophyGreydwarfBrute"] = 4, ["TrophyFrostTroll"] = 4, ["TrophyGreydwarfShaman"] = 4, ["TrophyGhost"] = 4, ["TrophySkeleton"] = 4, ["TrophySkeletonPoison"] = 4, ["TrophySurtling"] = 6, ["TrophyBlob"] = 6, ["TrophyLeech"] = 6, ["TrophyAbomination"] = 6, ["TrophyWraith"] = 6, ["TrophyDraugr"] = 6, ["TrophyDraugrElite"] = 6, ["TrophyDraugrFem"] = 6, ["TrophySerpent"] = 6, ["TrophyWolf"] = 8, ["TrophyHatchling"] = 8, ["TrophyUlv"] = 8, ["TrophyFenring"] = 8, ["TrophyCultist"] = 8, ["TrophySGolem"] = 8, ["TrophyLox"] = 10, ["TrophyGoblin"] = 10, ["TrophyGoblinBrute"] = 10, ["TrophyGoblinShaman"] = 10, ["TrophyDeathsquito"] = 10, ["TrophyGrowth"] = 10, ["TrophyBjornUndead"] = 10, ["TrophyHare"] = 12, ["TrophySeekerBrute"] = 12, ["TrophyGjall"] = 12, ["TrophySeeker"] = 12, ["TrophyTick"] = 12, ["TrophyDvergr"] = 12, ["TrophyAsksvin"] = 14, ["TrophyVolture"] = 14, ["TrophyMorgen"] = 14, ["TrophyCharredArcher"] = 14, ["TrophyCharredMage"] = 14, ["TrophyCharredMelee"] = 14, ["TrophyFallenValkyrie"] = 14 }; private static readonly Dictionary<string, int> Bosses = new Dictionary<string, int> { ["TrophyEikthyr"] = 20, ["TrophyTheElder"] = 30, ["TrophyBonemass"] = 40, ["TrophyDragonQueen"] = 50, ["TrophyGoblinKing"] = 60, ["TrophySeekerQueen"] = 70, ["TrophyFader"] = 80 }; public static bool TryGet(ItemData? item, out int amount) { amount = 0; string text = Prefab(item); if (text != null) { if (!Yields.TryGetValue(text, out amount)) { return Bosses.TryGetValue(text, out amount); } return true; } return false; } public static bool IsBoss(ItemData? item) { string text = Prefab(item); if (text != null) { return Bosses.ContainsKey(text); } return false; } private static string? Prefab(ItemData? item) { if (!((Object)(object)item?.m_dropPrefab != (Object)null)) { return null; } return ((Object)item.m_dropPrefab).name; } } } namespace EliteCrafting.Tables.Window { internal sealed class CostRow { public const int Most = 2; private readonly List<Slot> _slots = new List<Slot>(); public GameObject? Template { get { if (_slots.Count <= 0) { return null; } return _slots[0].Root; } } public IReadOnlyList<Slot> Slots => _slots; public CostRow(RectTransform? requirements) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if ((Object)(object)requirements == (Object)null) { return; } foreach (Transform item in (Transform)requirements) { Transform val = item; if (((Object)val).name.StartsWith("res_bkg") && _slots.Count < 2) { _slots.Add(new Slot(((Component)val).gameObject)); } else { ((Component)val).gameObject.SetActive(false); } } } public void Clear() { foreach (Slot slot in _slots) { slot.Clear(); slot.Root.SetActive(false); } } public void Add(Sprite? icon, string name, int amount, bool enough) { foreach (Slot slot in _slots) { if (!slot.Root.activeSelf) { slot.Root.SetActive(true); slot.Show(icon, null, amount.ToString(), enough, dim: false); slot.Tooltip("", name); break; } } } } internal sealed class CraftingCover { private readonly struct Hidden { public CanvasGroup Group { get; } public bool Added { get; } public float Alpha { get; } public bool Blocks { get; } public bool Interactable { get; } public Hidden(CanvasGroup group, bool added, float alpha, bool blocks, bool interactable) { Group = group; Added = added; Alpha = alpha; Blocks = blocks; Interactable = interactable; } } private readonly List<Hidden> _hidden = new List<Hidden>(); public void Cover(Transform crafting, Transform keep) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown Uncover(); foreach (Transform item in crafting) { Transform val = item; if (!((Object)(object)val == (Object)(object)keep)) { CanvasGroup component = ((Component)val).GetComponent<CanvasGroup>(); bool added = (Object)(object)component == (Object)null; CanvasGroup val2 = (((Object)(object)component != (Object)null) ? component : ((Component)val).gameObject.AddComponent<CanvasGroup>()); _hidden.Add(new Hidden(val2, added, val2.alpha, val2.blocksRaycasts, val2.interactable)); val2.alpha = 0f; val2.blocksRaycasts = false; val2.interactable = false; } } } public void Uncover() { foreach (Hidden item in _hidden) { if (!((Object)(object)item.Group == (Object)null)) { if (item.Added) { Object.Destroy((Object)(object)item.Group); continue; } item.Group.alpha = item.Alpha; item.Group.blocksRaycasts = item.Blocks; item.Group.interactable = item.Interactable; } } _hidden.Clear(); } } internal static class EssenceIcons { private const string Prefix = "EliteCrafting.assets.icons.ecf_essence_"; private static readonly Dictionary<string, Sprite?> Made = new Dictionary<string, Sprite>(); private static readonly Dictionary<string, Sprite?> Greyed = new Dictionary<string, Sprite>(); private static readonly MethodInfo? LoadImage = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[3] { typeof(Texture2D), typeof(byte[]), typeof(bool) }); private const string ItemId = "item"; public static Sprite? Item() { if (!Made.TryGetValue("item", out Sprite value)) { value = Decode("item"); Made["item"] = value; } return value; } public static Sprite? Of(Essence essence) { if (!Made.TryGetValue(essence.Id, out Sprite value)) { value = Decode(essence.Id); Made[essence.Id] = value; } if (!((Object)(object)value != (Object)null)) { return GameIcon(essence); } return value; } public static Sprite? Grey(Essence essence) { if (!Greyed.TryGetValue(essence.Id, out Sprite value)) { value = Decode(essence.Id, grey: true); Greyed[essence.Id] = value; } return value; } private static Sprite? Decode(string id, bool grey = false) { //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_0045: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) byte[] array = Embedded.Bytes("EliteCrafting.assets.icons.ecf_essence_" + id + ".png"); if (array == null) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = "ecf_essence_" + id + (grey ? "_grey" : "") }; if (!(LoadImage == null)) { object obj = LoadImage.Invoke(null, new object[3] { val, array, !grey }); if (obj is bool && (bool)obj) { if (grey) { ToGrey(val); } ((Texture)val).filterMode = (FilterMode)0; ((Texture)val).wrapMode = (TextureWrapMode)1; Sprite obj2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)obj2).name = ((Object)val).name; return obj2; } } Log.Warn("the " + id + " essence icon did not decode; it shows its game item's icon"); return null; } private static void ToGrey(Texture2D texture) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Color32[] pixels = texture.GetPixels32(); for (int i = 0; i < pixels.Length; i++) { Color32 val = pixels[i]; byte b = (byte)(((float)(int)val.r * 0.299f + (float)(int)val.g * 0.587f + (float)(int)val.b * 0.114f) * 0.8f); pixels[i] = new Color32(b, b, b, val.a); } texture.SetPixels32(pixels); texture.Apply(false, true); } private static Sprite? GameIcon(Essence essence) { GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(essence.IconItem) : null); if (!((Object)(object)val != (Object)null)) { return null; } ItemDrop component = val.GetComponent<ItemDrop>(); if (component == null) { return null; } return component.m_itemData.GetIcon(); } } internal readonly struct Pill { public string Name { get; } public string Text { get; } public Pill(string name, string text) { Name = name; Text = text; } } internal static class EssencePills { private static readonly List<PoolEntry> Entries = new List<PoolEntry>(); private static readonly List<AffixTierDef> Tiers = new List<AffixTierDef>(); public static List<Pill> Of(ItemData item, Essence essence, StoneDef rune) { List<Pill> list = new List<Pill>(); ItemState itemState = ItemState.Read(item); RuleSet current = ActiveRules.Current; RarityDef rarityDef = Raised(itemState, current.Economy); if (rarityDef == null) { return list; } RollContext rollContext = RollContext.For(item, rune.TierFloor); rollContext.Favoured = essence.Inscriptions; ItemStateBuilder itemStateBuilder = itemState.ToBuilder(); itemStateBuilder.SetRarity(rarityDef.Id); new AffixDraw(itemStateBuilder, rollContext).Candidates(Entries); foreach (PoolEntry entry in Entries) { TierEligibility.Eligible(entry.Def, entry.Fit, rollContext, Tiers); list.Add(Word(entry.Def, rollContext.Class.DamageScale)); } return list; } private static RarityDef? Raised(ItemState state, EconomyRules economy) { RarityDef rarityDef = state.Rarity ?? economy.BaseRarity; RarityDef rarityDef2 = ((rarityDef != null) ? economy.Next(rarityDef) : null); if (state.Rarity == null && rarityDef2 != null) { rarityDef2 = economy.Next(rarityDef2) ?? rarityDef2; } return rarityDef2 ?? state.Rarity; } private static Pill Word(AffixDef def, float scale) { string name = DisplayWords.Name(def.Name, def.Id); if (Tiers.Count == 0) { return new Pill(name, ""); } AffixTierDef affixTierDef = Tiers[0]; AffixTierDef affixTierDef2 = Tiers[0]; float num = float.MaxValue; float num2 = float.MinValue; foreach (AffixTierDef tier in Tiers) { affixTierDef = ((tier.Grade < affixTierDef.Grade) ? tier : affixTierDef); affixTierDef2 = ((tier.Grade > affixTierDef2.Grade) ? tier : affixTierDef2); num = Math.Min(num, Scaled(def, tier.Min, tier, scale)); num2 = Math.Max(num2, Scaled(def, tier.Max, tier, scale)); } return new Pill(name, Describe(def, num, num2, def.ShownTier(affixTierDef.Grade), def.ShownTier(affixTierDef2.Grade))); } private static string Describe(AffixDef def, float min, float max, int weakest, int strongest) { string text = Words.Localize((def.Kind == AffixKind.Prefix) ? "$ecf_table_pill_prefix" : "$ecf_table_pill_suffix"); string text2 = AffixLines.Sentence(def.Id, max, def); if (def.Value == AffixValueType.Flag) { return text2 + "\n" + text; } string text3 = Words.Localize("$ecf_table_pill_rolls", DisplayWords.Plain(min), DisplayWords.Plain(max), "T" + weakest, "T" + strongest); return text2 + "\n" + text3 + "\n" + text; } private static float Scaled(AffixDef def, float value, AffixTierDef tier, float scale) { if (!def.Scaled) { return value; } return RollMath.Scale(value, scale, tier.Decimals); } } internal static class HoverBox { private const float Gap = 8f; private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4]; private static GameObject? _prefab; private static GameObject? _box; private static TipHover? _owner; public static void Remember(GameObject? prefab) { if ((Object)(object)_prefab == (Object)null && (Object)(object)prefab != (Object)null) { _prefab = prefab; } } public static void Show(TipHover owner) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown Hide(); Canvas componentInParent = ((Component)owner).GetComponentInParent<Canvas>(); GameObject val = BoxPrefab(); if (!((Object)(object)val == (Object)null) && !((Object)(object)componentInParent == (Object)null)) { _box = Object.Instantiate<GameObject>(val, ((Component)componentInParent.rootCanvas).transform); _box.transform.SetAsLastSibling(); _owner = owner; Write(owner); Place((RectTransform)((Component)owner).transform, componentInParent.rootCanvas.scaleFactor); } } private static GameObject? BoxPrefab() { InventoryGrid val = (((Object)(object)InventoryGui.instance != (Object)null) ? InventoryGui.instance.m_playerGrid : null); UITooltip val2 = (((Object)(object)val != (Object)null && (Object)(object)val.m_elementPrefab != (Object)null) ? val.m_elementPrefab.GetComponent<UITooltip>() : null); if (!((Object)(object)val2 != (Object)null) || !((Object)(object)val2.m_tooltipPrefab != (Object)null)) { return _prefab; } return val2.m_tooltipPrefab; } public static void Refresh(TipHover owner) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (!((Object)(object)_owner != (Object)(object)owner) && !((Object)(object)_box == (Object)null)) { if (owner.Empty) { Hide(); return; } Write(owner); Place((RectTransform)((Component)owner).transform, _box.GetComponentInParent<Canvas>().scaleFactor); } } public static void Hide(TipHover? owner = null) { if (!((Object)(object)owner != (Object)null) || !((Object)(object)owner != (Object)(object)_owner)) { if ((Object)(object)_box != (Object)null) { Object.Destroy((Object)(object)_box); } _box = null; _owner = null; } } private static void Write(TipHover owner) { Text(_box.transform, "Topic", owner.Topic); Text(_box.transform, "Text", owner.Text); } private static void Text(Transform root, string name, string text) { Transform val = Utils.FindChild(root, name, (IterativeSearchType)0); TMP_Text val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<TMP_Text>() : null); if ((Object)(object)val2 != (Object)null) { val2.text = text; ((Component)val2).gameObject.SetActive(text.Length > 0); } } private static void Place(RectTransform target, float scale) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)_box.transform.GetChild(0); LayoutRebuilder.ForceRebuildLayoutImmediate(val); target.GetWorldCorners(Corners); Vector3 val2 = Corners[1]; Vector3 val3 = Corners[2]; val.GetWorldCorners(Corners); float num = Corners[2].x - Corners[1].x; float num2 = val3.x + 8f * scale; if (num2 + num > (float)Screen.width) { num2 = val2.x - 8f * scale - num; } Transform transform = _box.transform; transform.position += new Vector3(num2 - Corners[1].x, val2.y - Corners[1].y, 0f); Utils.ClampUIToScreen(val); } } internal sealed class TipHover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public string Topic { get; private set; } = ""; public string Text { get; private set; } = ""; public bool Empty { get { if (Topic.Length == 0) { return Text.Length == 0; } return false; } } public void Set(string topic, string text) { if (!(topic == Topic) || !(text == Text)) { Topic = topic; Text = text; HoverBox.Refresh(this); } } public void OnPointerEnter(PointerEventData eventData) { if (!Empty) { HoverBox.Show(this); } } public void OnPointerExit(PointerEventData eventData) { HoverBox.Hide(this); } private void OnDisable() { HoverBox.Hide(this); } } internal static class InscribePane { public static void Fill(TableView view, InscribeChoice choice) { PanelParts parts = view.Parts; ItemData? item = choice.Item; PaneText.Header(parts, (item != null) ? item.GetIcon() : null, (choice.Item != null) ? NameOf(choice.Item) : Words.Localize("$ecf_table_no_gear"), choice.Item); PaneText.Body(parts, (choice.Item != null) ? InscribeText.Describe(choice) : Words.Localize("$ecf_table_no_gear_desc")); PaneText.Labels(parts, "$ecf_table_label_rune", "$ecf_table_label_essence"); FillRunes(view, choice); FillEssences(view, choice); FillPills(parts, choice); bool flag = FillCost(view, choice); PaneText.Button(parts, "$ecf_table_inscribe", flag && TableUse.Works(view, choice.Item, choice.Rune, choice.Steering)); PaneText.Extra(parts, "$ecf_table_store_all", RuneStash.Carried(view.Inventory) > 0 && view.Store.Writable); } private static void FillPills(PanelParts parts, InscribeChoice choice) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) Essence essence = choice.Essence; if (choice.Item != null && essence != null && choice.Def != null && TableIcons.Steers(choice.Def)) { PaneText.Pills(parts, EssencePills.Of(choice.Item, essence, choice.Def), essence.Color); } } public static string Held(int stored) { if (stored <= 0) { return ""; } return stored.ToString(); } public static int Have(TableView view) { return view.Store.Essence; } public static string NameOf(ItemData item) { return Words.Localize(DisplayCache.Topic(ItemState.Read(item), item) ?? item.m_shared.m_name); } private static void FillRunes(TableView view, InscribeChoice choice) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) SlotRow runes = view.Parts.Runes; if (runes != null) { runes.Show(on: true); runes.Fit(StoneCatalog.BuiltInIds.Length); for (int i = 0; i < runes.Count && i < StoneCatalog.BuiltInIds.Length; i++) { string text = StoneCatalog.BuiltInIds[i]; int num = view.Store.Runes(text); bool flag = StoneVerbs.IsUsable(TableIcons.Def(text)); runes[i].Show(TableIcons.Rune(text), null, Held(num), enough: true, !flag || num == 0); runes[i].Choose(text == choice.Rune, StoneVisuals.Tint(text)); } } } private static void FillEssences(TableView view, InscribeChoice choice) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) SlotRow essences = view.Parts.Essences; if (essences != null) { essences.Show(on: true); int num = Have(view); essences[0].Show(TableIcons.EssenceItem(), null, Held(view.Store.Essence), enough: true, num == 0); essences[0].Choose(chosen: false); bool flag = TableIcons.Steers(choice.Def); bool flag2 = choice.Item != null && num < choice.EssenceCost; for (int i = 1; i < essences.Count && i <= Essences.All.Length; i++) { Essence essence = Essences.All[i - 1]; Sprite val = (flag ? null : TableIcons.EssenceGrey(essence)); bool flag3 = (Object)(object)val != (Object)null; essences[i].Show((Sprite?)(flag3 ? ((object)val) : ((object)TableIcons.Essence(essence))), null, "", enough: true, (!flag && !flag3) || flag2); essences[i].Choose(essence == choice.Essence && flag, essence.Color); } } } private static bool FillCost(TableView view, InscribeChoice choice) { CostRow cost = view.Parts.Cost; cost?.Clear(); if (choice.Item == null || cost == null) { return false; } int num = view.Store.Runes(choice.Rune); bool flag = num >= choice.RuneCost && StoneVerbs.IsUsable(choice.Def); cost.Add(TableIcons.Rune(choice.Rune), Words.Localize(choice.Def?.Name ?? ""), choice.RuneCost, num >= choice.RuneCost); if (choice.Steering != null) { bool flag2 = Have(view) >= choice.EssenceCost; cost.Add(TableIcons.EssenceItem(), Words.Localize("$ecf_essence_item"), choice.EssenceCost, flag2); flag = flag && flag2; } return flag; } } internal sealed class InscribeTab : TableTab { private readonly List<ItemData> _gear = new List<ItemData>(); private readonly List<ListRow> _rows = new List<ListRow>(); private ItemData? _item; private string _rune = StoneCatalog.BuiltInIds[0]; private Essence? _essence; public override string Label => "$ecf_table_tab_inscribe"; public override void Fill(TableView view) { Gather(view.Inventory); if (_item == null || !_gear.Contains(_item)) { _item = ((_gear.Count > 0) ? _gear[0] : null); } _rows.Clear(); foreach (ItemData item in _gear) { ItemData chosen = item; _rows.Add(new ListRow(item.GetIcon(), InscribePane.NameOf(item), item.m_quality.ToString(), Durability(item), item == _item, dim: false, delegate { Choose(chosen); }, item)); } view.Parts.List?.Fill(_rows); InscribePane.Fill(view, new InscribeChoice(_item, _rune, _essence)); } public override void Extra(TableView view) { TableTab.StoreAll(view); } public override void PickRune(int index) { _rune = StoneCatalog.BuiltInIds[index]; if (TableWindow.ShiftHeld) { TableTab.TakeOut(_rune); } TableWindow.MarkDirty(); } public override void PickEssence(int index) { if (index == 0 && TableWindow.ShiftHeld) { TableTab.TakeEssence(); } else if (index >= 1 && index <= Essences.All.Length && TableIcons.Steers(TableIcons.Def(_rune))) { Essence essence = Essences.All[index - 1]; _essence = ((_essence == essence) ? null : essence); TableWindow.MarkDirty(); } } public override void Act(TableView view, bool all) { ItemData val = TableIcons.RuneItem(_rune); if (_item != null && val != null) { Essence essence = (TableIcons.Steers(TableIcons.Def(_rune)) ? _essence : null); TableSupply supply = new TableSupply(view.Store, essence); StoneJob job = StoneJob.Create(view.Player, val, _item, supply); StoneResult stoneResult = StonePipeline.Evaluate(job); if (stoneResult.Refused) { StoneFeedback.Show(view.Player, stoneResult.Refusal); } else { ConfirmGate.Pass(job, stoneResult, all); } } } private void Choose(ItemData item) { _item = item; TableWindow.MarkDirty(); } private void Gather(Inventory inventory) { _gear.Clear(); foreach (ItemData allItem in inventory.GetAllItems()) { if (ItemClasses.IsMagicBase(allItem)) { _gear.Add(allItem); } } _gear.Sort((ItemData a, ItemData b) => (a.m_gridPos.y == b.m_gridPos.y) ? a.m_gridPos.x.CompareTo(b.m_gridPos.x) : a.m_gridPos.y.CompareTo(b.m_gridPos.y)); } private static float? Durability(ItemData item) { if (!item.m_shared.m_useDurability || !(item.m_durability < item.GetMaxDurability())) { return null; } return item.GetDurabilityPercentage(); } } internal readonly struct InscribeChoice { public ItemData? Item { get; } public string Rune { get; } public Essence? Essence { get; } public StoneDef? Def => TableIcons.Def(Rune); public Essence? Steering { get { if (!TableIcons.Steers(Def)) { return null; } return Essence; } } public int EssenceCost { get { if (Item == null) { return 0; } return Essences.CostFor(ItemTier.Of(Item)); } } public int RuneCost { get { StoneDef def = Def; ItemState itemState = ((Item != null) ? ItemState.Read(Item) : null); string rarityId = ((itemState != null && itemState.IsMagic) ? (itemState.RarityId ?? "") : (ActiveRules.Current.Economy.BaseRarity?.Id ?? "")); if (def == null) { return 1; } return Math.Max(def.CostFor(rarityId), 0); } } public InscribeChoice(ItemData? item, string rune, Essence? essence) { Item = item; Rune = rune; Essence = essence; } } internal static class InscribeText { private const string Gold = "<color=#FFB75C>"; public static string Describe(InscribeChoice choice) { ItemData item = choice.Item; ItemState itemState = ItemState.Read(item); ClassInfo info = ItemClasses.Classify(item); int level = ItemTier.Of(item); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Words.Localize("$ecf_table_gear_line", TableWords.ClassName(info), level.ToString(), TableWords.Biome(level))); stringBuilder.Append("\n\n"); string text = (itemState.IsMagic ? DisplayCache.Block(itemState, item) : ""); stringBuilder.Append((text.Length > 0) ? text.Trim(new char[1] { '\n' }) : Words.Localize("$ecf_table_plain")); stringBuilder.Append("\n\n").Append(RuneLine(choice.Def)); stringBuilder.Append('\n').Append(SteerLine(choice, info)); return stringBuilder.ToString(); } public static string RuneTip(StoneDef? def, int stored, int carried) { return ((def != null) ? Words.Localize(def.Description) : "") + "\n\n" + Words.Localize("$ecf_table_rune_counts", stored.ToString(), carried.ToString()); } private static string RuneLine(StoneDef? def) { if (def == null) { return ""; } return "<color=#FFB75C>" + Words.Localize(def.Name) + "</color>: " + Words.Localize(def.Description); } private static bool AscensionTakes(InscribeChoice choice) { string text = ItemState.Read(choice.Item).RarityId ?? ActiveRules.Current.Economy.BaseRarity?.Id; if (text != null && choice.Def != null) { return choice.Def.AppliesToRarity(text); } return false; } private static string SteerLine(InscribeChoice choice, ClassInfo info) { if (!TableIcons.Steers(choice.Def)) { return Words.Localize("$ecf_table_no_steer"); } Essence essence = choice.Essence; if (essence == null) { return Words.Localize("$ecf_table_pick_essence", choice.EssenceCost.ToString()); } var (num, num2) = Share(essence, info.ClassId); if (num == 0) { return Words.Localize("$ecf_table_steer_none", TableWords.EssenceName(essence)); } if (!AscensionTakes(choice)) { return Words.Localize("$ecf_table_steer_magic_only", TableWords.EssenceName(essence)); } return Words.Localize("$ecf_table_steer", TableWords.EssenceName(essence), num.ToString(), num2.ToString(), choice.EssenceCost.ToString()); } private static (int Favoured, int Total) Share(Essence essence, string? classId) { int num = 0; int num2 = 0; foreach (PoolEntry item in ActiveRules.Current.Affixes.Pool(classId)) { if (item.Def.Enabled && !(item.Def.Weight <= 0f)) { num2++; if (essence.Inscriptions.Contains(item.Def.Id)) { num++; } } } return (Favoured: num, Total: num2); } } internal readonly struct ListRow { public ItemData? Item { get; } public Sprite? Icon { get; } public string Name { get; } public string? Badge { get; } public float? Durability { get; } public bool Selected { get; } public bool Dim { get; } public Action Click { get; } public ListRow(Sprite? icon, string name, string? badge, float? durability, bool selected, bool dim, Action click, ItemData? item = null) { Item = item; Icon = icon; Name = name; Badge = badge; Durability = durability; Selected = selected; Dim = dim; Click = click; } } internal sealed class ListRows { private static readonly Color Grey = new Color(0.66f, 0.66f, 0.66f, 1f); private readonly GameObject _template; private readonly RectTransform? _root; private readonly float _space; private readonly float _baseHeight; private readonly List<GameObject> _rows = new List<GameObject>(); public ListRows(GameObject template, ScrollRect? scroll, float space) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) _template = template; _root = (((Object)(object)scroll != (Object)null) ? scroll.content : null); _space = space; float baseHeight; if (!((Object)(object)scroll != (Object)null)) { baseHeight = 0f; } else { Rect rect = ((RectTransform)((Component)scroll).transform).rect; baseHeight = ((Rect)(ref rect)).height; } _baseHeight = baseHeight; } public void Fill(IReadOnlyList<ListRow> rows) { foreach (GameObject row in _rows) { Object.Destroy((Object)(object)row); } _rows.Clear(); if ((Object)(object)_root == (Object)null) { return; } foreach (ListRow row2 in rows) { _rows.Add(Make(row2, _rows.Count)); } _root.SetSizeWithCurrentAnchors((Axis)1, Mathf.Max(_baseHeight, (float)_rows.Count * _space)); } private GameObject Make(ListRow row, int index) { //IL_0024: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_00f5: 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) GameObject obj = Object.Instantiate<GameObject>(_template, (Transform)(object)_root); obj.SetActive(true); ((RectTransform)obj.transform).anchoredPosition = new Vector2(0f, (float)index * (0f - _space)); Transform obj2 = obj.transform.Find("icon"); Image val = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null); if ((Object)(object)val != (Object)null) { val.sprite = row.Icon; ((Graphic)val).color = (Color)(row.Dim ? new Color(1f, 1f, 1f, 0.5f) : Color.white); IconBackdrop.Set(val, row.Item); } Transform obj3 = obj.transform.Find("name"); TMP_Text val2 = ((obj3 != null) ? ((Component)obj3).GetComponent<TMP_Text>() : null); if ((Object)(object)val2 != (Object)null) { val2.text = row.Name; ((Graphic)val2).color = (row.Dim ? Grey : Color.white); } Decorate(obj.transform, row); Action click = row.Click; Button component = obj.GetComponent<Button>(); if (component != null) { ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { click(); }); return obj; } return obj; } private static void Decorate(Transform element, ListRow row) { Transform obj = element.Find("Durability"); GuiBar val = ((obj != null) ? ((Component)obj).GetComponent<GuiBar>() : null); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(row.Durability.HasValue); val.SetValue(row.Durability.GetValueOrDefault()); } Transform obj2 = element.Find("QualityLevel"); TMP_Text val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(row.Badge != null); val2.text = row.Badge ?? ""; } Transform obj3 = element.Find("selected"); if (obj3 != null) { ((Component)obj3).gameObject.SetActive(row.Selected); } } } internal static class PanelBuilder { private static readonly string[] Keep = new string[13] { "Darken", "Bkg", "topic", "TabsButtons/Craft", "TabsButtons/TabBorder", "RecipeList/Recipes", "RecipeList/RecipeScroll", "Decription/Icon", "Decription/Name", "Decription/Description", "Decription/requirements", "Decription/craft_button_panel/CraftButton", "Decription/SelectVariant" }; private const string PackPanelSkin = "PackPanel_timberwood"; private static readonly HashSet<string> Foreign = new HashSet<string> { "UIGroupHandler", "UIGamePad", "UIInputHint", "EventTrigger", "Localize", "UIInputHandler", "GridLayoutGroup", "VerticalLayoutGroup", "HorizontalLayoutGroup", "ContentSizeFitter" }; public static GameObject Build(RectTransform crafting) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown GameObject val = new GameObject("ECF_RuneTableHolder"); val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(((Component)crafting).gameObject, val.transform, false); ((Object)val2).name = "ECF_RuneTab