Decompiled source of Niflheim v0.0.3
NorthernAssets.dll
Decompiled 6 hours 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.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; 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 HarmonyLib; using ItemManager; using JetBrains.Annotations; using Managers; using Microsoft.CodeAnalysis; using NorthernAssets; using NorthernAssets.Behaviors; using NorthernAssets.Managers; using NorthernAssets.StatusEffects; using NorthernAssets.prefabs; using PieceManager; using ServerSync; using SoftReferenceableAssets; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("NorthernAssets")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("NorthernAssets")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("0.0.3")] [assembly: AssemblyCompany("RustyMods")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.3.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<cf2f391e-8410-4aff-a693-47e0fbc1bbdf>Embedded] internal sealed class <cf2f391e-8410-4aff-a693-47e0fbc1bbdf>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<cf2f391e-8410-4aff-a693-47e0fbc1bbdf>Embedded] internal sealed class <48fcde38-c513-4970-bafc-a1e9080f5a46>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <48fcde38-c513-4970-bafc-a1e9080f5a46>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <48fcde38-c513-4970-bafc-a1e9080f5a46>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<cf2f391e-8410-4aff-a693-47e0fbc1bbdf>Embedded] [CompilerGenerated] internal sealed class <26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContextAttribute : Attribute { public readonly byte Flag; public <26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace PieceManager { [PublicAPI] public enum CraftingTable { None, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("piece_magetable")] MageTable, [InternalName("blackforge")] BlackForge, [InternalName("piece_preptable")] FoodPreparationTable, [InternalName("piece_MeadCauldron")] MeadKetill, Custom } [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [PublicAPI] public class ExtensionList { public readonly List<ExtensionConfig> ExtensionStations = new List<ExtensionConfig>(); public void Set(CraftingTable table, int maxStationDistance = 5) { ExtensionStations.Add(new ExtensionConfig { Table = table, maxStationDistance = maxStationDistance }); } public void Set(string customTable, int maxStationDistance = 5) { ExtensionStations.Add(new ExtensionConfig { Table = CraftingTable.Custom, custom = customTable, maxStationDistance = maxStationDistance }); } } public struct ExtensionConfig { public CraftingTable Table; public float maxStationDistance; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] public string custom; } [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] [PublicAPI] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] public class CraftingStationList { public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>(); public void Set(CraftingTable table) { Stations.Add(new CraftingStationConfig { Table = table }); } public void Set(string customTable) { Stations.Add(new CraftingStationConfig { Table = CraftingTable.Custom, custom = customTable }); } } public struct CraftingStationConfig { public CraftingTable Table; public int level; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] public string custom; } [PublicAPI] public enum BuildPieceCategory { Misc = 0, Crafting = 1, BuildingWorkbench = 2, BuildingStonecutter = 3, Furniture = 4, All = 100, Custom = 99 } [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [PublicAPI] public class RequiredResourcesList { public readonly List<Requirement> Requirements = new List<Requirement>(); public void Add(string item, int amount, bool recover) { Requirements.Add(new Requirement { itemName = item, amount = amount, recover = recover }); } } public struct Requirement { [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(1)] public string itemName; public int amount; public bool recover; } public struct SpecialProperties { [Description("Admins should be the only ones that can build this piece.")] public bool AdminOnly; [Description("Turns off generating a config for this build piece.")] public bool NoConfig; } [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [PublicAPI] [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] public class BuildingPieceCategory { public BuildPieceCategory Category; public string custom = ""; public void Set(BuildPieceCategory category) { Category = category; } public void Set(string customCategory) { Category = BuildPieceCategory.Custom; custom = customCategory; } } [PublicAPI] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] public class PieceTool { public readonly HashSet<string> Tools = new HashSet<string>(); public void Add(string tool) { Tools.Add(tool); } } [PublicAPI] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] public class BuildPiece { [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] internal class PieceConfig { public ConfigEntry<string> craft = null; public ConfigEntry<BuildPieceCategory> category = null; public ConfigEntry<string> customCategory = null; public ConfigEntry<string> tools = null; public ConfigEntry<CraftingTable> extensionTable = null; public ConfigEntry<string> customExtentionTable = null; public ConfigEntry<float> maxStationDistance = null; public ConfigEntry<CraftingTable> table = null; public ConfigEntry<string> customTable = null; } [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [HarmonyPatch(typeof(Piece), "Awake")] private static class Piece_Awake_Patch { private static void Postfix(Piece __instance) { BuildPieces.AddAnimatedChestComponent(__instance); BuildPieces.AddDoubleDoorComponent(__instance); UpdateEffects(__instance); } private static void UpdateEffects(Piece __instance) { if (__instance.m_placeEffect.m_effectPrefabs.Length != 0 || !buildPieceMap.TryGetValue(Helpers.GetNormalizedName(((Object)__instance).name), out var value)) { return; } UpdateEffectList(value.PlaceEffects, ref __instance.m_placeEffect); RandomSpeak val = default(RandomSpeak); if (((Component)__instance).TryGetComponent<RandomSpeak>(ref val)) { UpdateEffectList(value.RandomSpeakEffects, ref val.m_speakEffects); } WearNTear val2 = default(WearNTear); if (((Component)__instance).TryGetComponent<WearNTear>(ref val2)) { UpdateEffectList(value.DestroyedEffects, ref val2.m_destroyedEffect); UpdateEffectList(value.HitEffects, ref val2.m_hitEffect); UpdateEffectList(value.SwitchEffects, ref val2.m_switchEffect); } Container val3 = default(Container); if (((Component)__instance).TryGetComponent<Container>(ref val3)) { UpdateEffectList(value.OpenEffects, ref val3.m_openEffects); UpdateEffectList(value.CloseEffects, ref val3.m_closeEffects); } if (!Utility.IsNullOrWhiteSpace(value.CloneDoorEffectsFrom)) { GameObject prefab = ZNetScene.instance.GetPrefab(value.CloneDoorEffectsFrom); Door val4 = default(Door); if (prefab != null && prefab.TryGetComponent<Door>(ref val4)) { Door val5 = default(Door); if (((Component)__instance).TryGetComponent<Door>(ref val5)) { val5.m_openEffects = val4.m_openEffects; val5.m_closeEffects = val4.m_closeEffects; val5.m_lockedEffects = val4.m_lockedEffects; if (!Utility.IsNullOrWhiteSpace(value.KeyItem)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(value.KeyItem); ItemDrop keyItem = default(ItemDrop); if (itemPrefab != null && itemPrefab.TryGetComponent<ItemDrop>(ref keyItem)) { val5.m_keyItem = keyItem; } } } DoubleDoor doubleDoor = default(DoubleDoor); if (((Component)__instance).TryGetComponent<DoubleDoor>(ref doubleDoor)) { doubleDoor.m_openEffects = val4.m_openEffects; doubleDoor.m_closeEffects = val4.m_closeEffects; doubleDoor.m_lockedEffects = val4.m_lockedEffects; if (!Utility.IsNullOrWhiteSpace(value.KeyItem)) { GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(value.KeyItem); ItemDrop keyItem2 = default(ItemDrop); if (itemPrefab2 != null && itemPrefab2.TryGetComponent<ItemDrop>(ref keyItem2)) { doubleDoor.m_keyItem = keyItem2; } } } } } BossStone val6 = default(BossStone); if (Object.op_Implicit((Object)(object)ZNetScene.instance) && !Utility.IsNullOrWhiteSpace(value.CloneBossStoneEffectsFrom) && ((Component)__instance).TryGetComponent<BossStone>(ref val6)) { ItemStand itemStand = val6.m_itemStand; if (itemStand != null) { if (val6.m_activateStep1.m_effectPrefabs.Length != 0) { return; } GameObject prefab2 = ZNetScene.instance.GetPrefab(value.CloneBossStoneEffectsFrom); BossStone val7 = default(BossStone); if (prefab2 != null && prefab2.TryGetComponent<BossStone>(ref val7)) { val6.m_activateStep1 = val7.m_activateStep1; val6.m_activateStep2 = val7.m_activateStep2; val6.m_activateStep3 = val7.m_activateStep3; ItemStand itemStand2 = val7.m_itemStand; if (itemStand2 != null) { itemStand.m_effects = itemStand2.m_effects; itemStand.m_activatePowerEffects = itemStand2.m_activatePowerEffects; if (!Utility.IsNullOrWhiteSpace(value.BossTrophy)) { GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab(value.BossTrophy); ItemDrop val8 = default(ItemDrop); if (itemPrefab3 != null && itemPrefab3.TryGetComponent<ItemDrop>(ref val8)) { itemStand.m_supportedItems.Add(val8); StatusEffect guardianPower = value.GuardianPower; if (guardianPower != null) { guardianPower.m_icon = val8.m_itemData.GetIcon(); if (!ObjectDB.instance.m_StatusEffects.Contains(guardianPower)) { ObjectDB.instance.m_StatusEffects.Add(guardianPower); } itemStand.m_guardianPower = guardianPower; } } } } } } } Fireplace val9 = default(Fireplace); if (Object.op_Implicit((Object)(object)ZNetScene.instance) && !Utility.IsNullOrWhiteSpace(value.CloneFireplaceEffectsFrom) && ((Component)__instance).TryGetComponent<Fireplace>(ref val9)) { GameObject prefab3 = ZNetScene.instance.GetPrefab(value.CloneFireplaceEffectsFrom); Fireplace val10 = default(Fireplace); if (prefab3 != null && prefab3.TryGetComponent<Fireplace>(ref val10)) { val9.m_fuelAddedEffects = val10.m_fuelAddedEffects; val9.m_toggleOnEffects = val10.m_fuelAddedEffects; val9.m_fireworkItemList = val10.m_fireworkItemList; val9.m_fuelItem = val10.m_fuelItem; } } } } [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] public string Category; [UsedImplicitly] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(new byte[] { 2, 1 })] public Action<ConfigEntryBase> CustomDrawer; } [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] private class SerializedRequirements { public readonly List<Requirement> Reqs; public SerializedRequirements(List<Requirement> reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) { Reqs = reqs.Split(new char[1] { ',' }).Select([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); Requirement result = default(Requirement); result.itemName = array[0]; result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2); bool result3 = default(bool); result.recover = array.Length <= 2 || !bool.TryParse(array[2], out result3) || result3; return result; }).ToList(); } public override string ToString() { return string.Join(",", Reqs.Select([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}:{r.recover}")); } [return: <48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] public static ItemDrop fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)(((!string.IsNullOrWhiteSpace(((Object)plugin).name)) ? ("[" + ((Object)plugin).name + "]") : "") + " The required item '" + name + "' does not exist.")); } return val; } public static Requirement[] toPieceReqs(SerializedRequirements craft) { Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Requirement r) => { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ItemDrop val = ResItem(r); return (val == null) ? ((Requirement)null) : new Requirement { m_amount = r.amount, m_resItem = val, m_recover = r.recover }; })); return dictionary.Values.Where([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Requirement v) => v != null).ToArray(); [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(2)] static ItemDrop ResItem(Requirement r) { return fetchByName(ObjectDB.instance, r.itemName); } } } internal static readonly List<BuildPiece> registeredPieces = new List<BuildPiece>(); private static readonly Dictionary<Piece, BuildPiece> pieceMap = new Dictionary<Piece, BuildPiece>(); public static readonly Dictionary<string, BuildPiece> buildPieceMap = new Dictionary<string, BuildPiece>(); internal static Dictionary<BuildPiece, PieceConfig> pieceConfigs = new Dictionary<BuildPiece, PieceConfig>(); internal List<Conversion> Conversions = new List<Conversion>(); internal List<ItemConversion> conversions = new List<ItemConversion>(); [Description("Disables generation of the configs for your pieces. This is global, this turns it off for all pieces in your mod.")] public static bool ConfigurationEnabled = true; public readonly GameObject Prefab; public List<string> PlaceEffects = new List<string>(); public List<string> HitEffects = new List<string>(); public List<string> DestroyedEffects = new List<string>(); public List<string> SwitchEffects = new List<string>(); public List<string> RandomSpeakEffects = new List<string>(); public List<string> OpenEffects = new List<string>(); public List<string> CloseEffects = new List<string>(); public List<string> FuelAddedEffects = new List<string>(); public List<string> ToggleOnEffects = new List<string>(); public string CloneFireplaceEffectsFrom = ""; public string CloneDoorEffectsFrom = ""; public string KeyItem = ""; public string CloneBossStoneEffectsFrom = ""; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] public StatusEffect GuardianPower; public string BossTrophy = ""; [Description("Specifies the resources needed to craft the piece.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the building piece should need.")] public readonly RequiredResourcesList RequiredItems = new RequiredResourcesList(); [Description("Sets the category for the building piece.")] public readonly BuildingPieceCategory Category = new BuildingPieceCategory(); [Description("Specifies the tool needed to build your piece.\nUse .Add to add a tool.")] public readonly PieceTool Tool = new PieceTool(); [Description("Specifies the crafting station needed to build your piece.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.")] public CraftingStationList Crafting = new CraftingStationList(); [Description("Makes this piece a station extension")] public ExtensionList Extension = new ExtensionList(); [Description("Change the extended/special properties of your build piece.")] public SpecialProperties SpecialProperties; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] [Description("Specifies a config entry which toggles whether a recipe is active.")] public ConfigEntryBase RecipeIsActive = null; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] private LocalizeKey _name; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] private LocalizeKey _description; internal string[] activeTools = null; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] private static object configManager; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] private static Localization _english; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] internal static BaseUnityPlugin _plugin = null; private static bool hasConfigSync = true; [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] private static object _configSync; public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } Piece component = Prefab.GetComponent<Piece>(); if (component.m_name.StartsWith("$")) { _name = new LocalizeKey(component.m_name); } else { string text = "$piece_" + ((Object)Prefab).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(component.m_name); component.m_name = text; } return _name; } } public LocalizeKey Description { get { LocalizeKey description = _description; if (description != null) { return description; } Piece component = Prefab.GetComponent<Piece>(); if (component.m_description.StartsWith("$")) { _description = new LocalizeKey(component.m_description); } else { string text = "$piece_" + ((Object)Prefab).name.Replace(" ", "_") + "_description"; _description = new LocalizeKey(text).English(component.m_description); component.m_description = text; } return _description; } } private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); internal static BaseUnityPlugin plugin { get { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown if (_plugin != null) { return _plugin; } IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); return _plugin; } } [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] private static object configSync { [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(2)] get { if (_configSync != null || !hasConfigSync) { return _configSync; } Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " PieceManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } return _configSync; } } public void UpdateEffects() { UpdateEffectList(PlaceEffects, ref Prefab.GetComponent<Piece>().m_placeEffect); RandomSpeak val = default(RandomSpeak); if (Prefab.TryGetComponent<RandomSpeak>(ref val)) { UpdateEffectList(RandomSpeakEffects, ref val.m_speakEffects); } WearNTear val2 = default(WearNTear); if (Prefab.TryGetComponent<WearNTear>(ref val2)) { UpdateEffectList(DestroyedEffects, ref val2.m_destroyedEffect); UpdateEffectList(HitEffects, ref val2.m_hitEffect); UpdateEffectList(SwitchEffects, ref val2.m_switchEffect); } Container val3 = default(Container); if (Prefab.TryGetComponent<Container>(ref val3)) { UpdateEffectList(OpenEffects, ref val3.m_openEffects); UpdateEffectList(CloseEffects, ref val3.m_closeEffects); } Door val4 = default(Door); if (Object.op_Implicit((Object)(object)ZNetScene.instance) && !Utility.IsNullOrWhiteSpace(CloneDoorEffectsFrom) && Prefab.TryGetComponent<Door>(ref val4)) { GameObject prefab = ZNetScene.instance.GetPrefab(CloneDoorEffectsFrom); Door val5 = default(Door); if (Object.op_Implicit((Object)(object)prefab) && prefab.TryGetComponent<Door>(ref val5)) { val4.m_openEffects = val5.m_openEffects; val4.m_closeEffects = val5.m_closeEffects; val4.m_lockedEffects = val5.m_lockedEffects; } if (!Utility.IsNullOrWhiteSpace(KeyItem)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(KeyItem); ItemDrop keyItem = default(ItemDrop); if (itemPrefab != null && itemPrefab.TryGetComponent<ItemDrop>(ref keyItem)) { val4.m_keyItem = keyItem; } } } DoubleDoor doubleDoor = default(DoubleDoor); if (Object.op_Implicit((Object)(object)ZNetScene.instance) && !Utility.IsNullOrWhiteSpace(CloneDoorEffectsFrom) && Prefab.TryGetComponent<DoubleDoor>(ref doubleDoor)) { GameObject prefab2 = ZNetScene.instance.GetPrefab(CloneDoorEffectsFrom); Door val6 = default(Door); if (Object.op_Implicit((Object)(object)prefab2) && prefab2.TryGetComponent<Door>(ref val6)) { doubleDoor.m_openEffects = val6.m_openEffects; doubleDoor.m_closeEffects = val6.m_closeEffects; doubleDoor.m_lockedEffects = val6.m_lockedEffects; } if (!Utility.IsNullOrWhiteSpace(KeyItem)) { GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(KeyItem); ItemDrop keyItem2 = default(ItemDrop); if (itemPrefab2 != null && itemPrefab2.TryGetComponent<ItemDrop>(ref keyItem2)) { doubleDoor.m_keyItem = keyItem2; } } } BossStone val7 = default(BossStone); if (Object.op_Implicit((Object)(object)ZNetScene.instance) && !Utility.IsNullOrWhiteSpace(CloneBossStoneEffectsFrom) && Prefab.TryGetComponent<BossStone>(ref val7)) { ItemStand itemStand = val7.m_itemStand; if (itemStand != null) { GameObject prefab3 = ZNetScene.instance.GetPrefab(CloneBossStoneEffectsFrom); BossStone val8 = default(BossStone); if (prefab3 != null && prefab3.TryGetComponent<BossStone>(ref val8)) { val7.m_activateStep1 = val8.m_activateStep1; val7.m_activateStep2 = val8.m_activateStep2; val7.m_activateStep3 = val8.m_activateStep3; ItemStand itemStand2 = val8.m_itemStand; if (itemStand2 != null) { itemStand.m_effects = itemStand2.m_effects; itemStand.m_activatePowerEffects = itemStand2.m_activatePowerEffects; if (!Utility.IsNullOrWhiteSpace(BossTrophy)) { GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab(BossTrophy); ItemDrop val9 = default(ItemDrop); if (itemPrefab3 != null && itemPrefab3.TryGetComponent<ItemDrop>(ref val9)) { itemStand.m_supportedItems.Add(val9); StatusEffect guardianPower = GuardianPower; if (guardianPower != null) { guardianPower.m_icon = val9.m_itemData.GetIcon(); if (!ObjectDB.instance.m_StatusEffects.Contains(guardianPower)) { ObjectDB.instance.m_StatusEffects.Add(guardianPower); } itemStand.m_guardianPower = guardianPower; } } } } } } } Fireplace val10 = default(Fireplace); if (Object.op_Implicit((Object)(object)ZNetScene.instance) && !Utility.IsNullOrWhiteSpace(CloneFireplaceEffectsFrom) && Prefab.TryGetComponent<Fireplace>(ref val10)) { GameObject prefab4 = ZNetScene.instance.GetPrefab(CloneFireplaceEffectsFrom); Fireplace val11 = default(Fireplace); if (prefab4 != null && prefab4.TryGetComponent<Fireplace>(ref val11)) { val10.m_fuelAddedEffects = val11.m_fuelAddedEffects; val10.m_toggleOnEffects = val11.m_fuelAddedEffects; val10.m_fireworkItemList = val11.m_fireworkItemList; val10.m_fuelItem = val11.m_fuelItem; } } } private static void UpdateEffectList(List<string> effects, ref EffectList list) { if (effects.Count != 0 && !((Object)(object)ZNetScene.instance == (Object)null)) { list.m_effectPrefabs = list.m_effectPrefabs.Concat((from effect in ((IEnumerable<string>)effects).Select((Func<string, GameObject>)ZNetScene.instance.GetPrefab) where (Object)(object)effect != (Object)null select effect).Select((Func<GameObject, EffectData>)([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (GameObject effect) => new EffectData { m_prefab = effect, m_enabled = true }))).ToArray(); } } public BuildPiece(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PiecePrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public BuildPiece(AssetBundle bundle, string prefabName) { Prefab = PiecePrefabManager.RegisterPrefab(bundle, prefabName); registeredPieces.Add(this); buildPieceMap[prefabName] = this; } internal static void Patch_FejdStartup(FejdStartup __instance) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Expected O, but got Unknown //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Expected O, but got Unknown //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Expected O, but got Unknown //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_08f4: Expected O, but got Unknown //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Expected O, but got Unknown //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Expected O, but got Unknown //IL_095f: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Expected O, but got Unknown //IL_0b7e: Unknown result type (might be due to invalid IL or missing references) //IL_0b88: Expected O, but got Unknown //IL_0c18: Unknown result type (might be due to invalid IL or missing references) //IL_0c22: Expected O, but got Unknown Type configManagerType = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((configManagerType == null) ? null : Chainloader.ManagerObject.GetComponent(configManagerType)); foreach (BuildPiece registeredPiece in registeredPieces) { registeredPiece.activeTools = registeredPiece.Tool.Tools.DefaultIfEmpty("Hammer").ToArray(); if (registeredPiece.Category.Category != BuildPieceCategory.Custom) { registeredPiece.Prefab.GetComponent<Piece>().m_category = (PieceCategory)registeredPiece.Category.Category; } else { registeredPiece.Prefab.GetComponent<Piece>().m_category = PiecePrefabManager.GetCategory(registeredPiece.Category.custom); } } if (!ConfigurationEnabled) { return; } bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (BuildPiece registeredPiece2 in registeredPieces) { BuildPiece piece = registeredPiece2; if (piece.SpecialProperties.NoConfig) { continue; } PieceConfig pieceConfig2 = (pieceConfigs[piece] = new PieceConfig()); PieceConfig cfg = pieceConfig2; Piece piecePrefab2 = piece.Prefab.GetComponent<Piece>(); string pieceName = piecePrefab2.m_name; string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(pieceName), "").Trim(); string localizedName = Localization.instance.Localize(pieceName).Trim(); int order = 0; cfg.category = config(englishName, "Build Table Category", piece.Category.Category, new ConfigDescription("Build Category where " + localizedName + " is available.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Category = localizedName } })); ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = (cfg.category.Value == BuildPieceCategory.Custom), Category = localizedName }; cfg.customCategory = config(englishName, "Custom Build Category", piece.Category.custom, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.category.SettingChanged += BuildTableConfigChanged; cfg.customCategory.SettingChanged += BuildTableConfigChanged; if (cfg.category.Value == BuildPieceCategory.Custom) { piecePrefab2.m_category = PiecePrefabManager.GetCategory(cfg.customCategory.Value); } else { piecePrefab2.m_category = (PieceCategory)cfg.category.Value; } cfg.tools = config(englishName, "Tools", string.Join(", ", piece.activeTools), new ConfigDescription("Comma separated list of tools where " + localizedName + " is available.", (AcceptableValueBase)null, new object[1] { customTableAttributes })); piece.activeTools = (from s in cfg.tools.Value.Split(new char[1] { ',' }) select s.Trim()).ToArray(); cfg.tools.SettingChanged += [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (object _, EventArgs _) => { Inventory[] source = (from c in Player.s_players.Select([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType<Container>() select c.GetInventory()) where c != null select c).ToArray(); Dictionary<string, List<PieceTable>> dictionary = (from kv in (from i in (from p in ObjectDB.instance.m_items select p.GetComponent<ItemDrop>() into c where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent<ZNetView>()) select c).Concat(ItemDrop.s_instances) select new KeyValuePair<string, ItemData>(Utils.GetPrefabName(((Component)i).gameObject), i.m_itemData)).Concat(from i in source.SelectMany([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Inventory i) => i.GetAllItems()) select new KeyValuePair<string, ItemData>(((Object)i.m_dropPrefab).name, i)) where Object.op_Implicit((Object)(object)kv.Value.m_shared.m_buildPieces) group kv by kv.Key).ToDictionary([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (IGrouping<string, KeyValuePair<string, ItemData>> g) => g.Key, [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (IGrouping<string, KeyValuePair<string, ItemData>> g) => g.Select([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (KeyValuePair<string, ItemData> kv) => kv.Value.m_shared.m_buildPieces).Distinct().ToList()); string[] array5 = piece.activeTools; foreach (string key in array5) { if (dictionary.TryGetValue(key, out var value3)) { foreach (PieceTable item3 in value3) { item3.m_pieces.Remove(piece.Prefab); } } } piece.activeTools = (from s in cfg.tools.Value.Split(new char[1] { ',' }) select s.Trim()).ToArray(); if (Object.op_Implicit((Object)(object)ObjectDB.instance)) { string[] array6 = piece.activeTools; foreach (string key2 in array6) { if (dictionary.TryGetValue(key2, out var value4)) { foreach (PieceTable item4 in value4) { if (!item4.m_pieces.Contains(piece.Prefab)) { item4.m_pieces.Add(piece.Prefab); } } } } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { PiecePrefabManager.CategoryRefreshNeeded = true; ((Humanoid)Player.m_localPlayer).SetPlaceMode(Player.m_localPlayer.m_buildPieces); } } }; StationExtension pieceExtensionComp; List<ConfigurationManagerAttributes> hideWhenNoneAttributes2; if (piece.Extension.ExtensionStations.Count > 0) { pieceExtensionComp = piece.Prefab.GetOrAddComponent<StationExtension>(); PieceConfig pieceConfig3 = cfg; string group = englishName; CraftingTable table = piece.Extension.ExtensionStations.First().Table; string text = "Crafting station that " + localizedName + " extends."; object[] array = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes(); int num = order - 1; order = num; configurationManagerAttributes.Order = num; array[0] = configurationManagerAttributes; pieceConfig3.extensionTable = config(group, "Extends Station", table, new ConfigDescription(text, (AcceptableValueBase)null, array)); cfg.customExtentionTable = config(englishName, "Custom Extend Station", piece.Extension.ExtensionStations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); PieceConfig pieceConfig4 = cfg; string group2 = englishName; float maxStationDistance = piece.Extension.ExtensionStations.First().maxStationDistance; string text2 = "Distance from the station that " + localizedName + " can be placed."; object[] array2 = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes2.Order = num; array2[0] = configurationManagerAttributes2; pieceConfig4.maxStationDistance = config(group2, "Max Station Distance", maxStationDistance, new ConfigDescription(text2, (AcceptableValueBase)null, array2)); hideWhenNoneAttributes2 = new List<ConfigurationManagerAttributes>(); cfg.extensionTable.SettingChanged += ExtensionTableConfigChanged; cfg.customExtentionTable.SettingChanged += ExtensionTableConfigChanged; cfg.maxStationDistance.SettingChanged += ExtensionTableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes3.Order = num; configurationManagerAttributes3.Browsable = cfg.extensionTable.Value != CraftingTable.None; ConfigurationManagerAttributes item = configurationManagerAttributes3; hideWhenNoneAttributes2.Add(item); } List<ConfigurationManagerAttributes> hideWhenNoneAttributes; if (piece.Crafting.Stations.Count > 0) { hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>(); PieceConfig pieceConfig5 = cfg; string group3 = englishName; CraftingTable table2 = piece.Crafting.Stations.First().Table; string text3 = "Crafting station where " + localizedName + " is available."; object[] array3 = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes4 = new ConfigurationManagerAttributes(); int num = order - 1; order = num; configurationManagerAttributes4.Order = num; array3[0] = configurationManagerAttributes4; pieceConfig5.table = config(group3, "Crafting Station", table2, new ConfigDescription(text3, (AcceptableValueBase)null, array3)); cfg.customTable = config(englishName, "Custom Crafting Station", piece.Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.table.SettingChanged += TableConfigChanged; cfg.customTable.SettingChanged += TableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes5 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes5.Order = num; configurationManagerAttributes5.Browsable = cfg.table.Value != CraftingTable.None; ConfigurationManagerAttributes item2 = configurationManagerAttributes5; hideWhenNoneAttributes.Add(item2); } cfg.craft = itemConfig("Crafting Costs", new SerializedRequirements(piece.RequiredItems.Requirements).ToString(), "Item costs to craft " + localizedName); cfg.craft.SettingChanged += [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (object _, EventArgs _) => { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") != (Object)null) { Requirement[] resources = SerializedRequirements.toPieceReqs(new SerializedRequirements(cfg.craft.Value)); piecePrefab2.m_resources = resources; Piece[] array4 = Object.FindObjectsOfType<Piece>(); foreach (Piece val in array4) { if (val.m_name == pieceName) { val.m_resources = resources; } } } }; for (int j = 0; j < piece.Conversions.Count; j++) { string text4 = ((piece.Conversions.Count > 1) ? $"{j + 1}. " : ""); Conversion conversion = piece.Conversions[j]; conversion.config = new Conversion.ConversionConfig(); int index = j; conversion.config.input = config(englishName, text4 + "Conversion Input Item", conversion.Input, new ConfigDescription("Conversion input item within " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName } })); conversion.config.input.SettingChanged += [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (object _, EventArgs _) => { if (index < piece.conversions.Count) { ObjectDB instance2 = ObjectDB.instance; if (instance2 != null) { ItemDrop from = SerializedRequirements.fetchByName(instance2, conversion.config.input.Value); piece.conversions[index].m_from = from; } } }; conversion.config.output = config(englishName, text4 + "Conversion Output Item", conversion.Output, new ConfigDescription("Conversion output item within " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName } })); conversion.config.output.SettingChanged += [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (object _, EventArgs _) => { if (index < piece.conversions.Count) { ObjectDB instance = ObjectDB.instance; if (instance != null) { ItemDrop to = SerializedRequirements.fetchByName(instance, conversion.config.output.Value); piece.conversions[index].m_to = to; } } }; } void BuildTableConfigChanged(object o, EventArgs e) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (registeredPieces.Count > 0) { if (cfg.category.Value == BuildPieceCategory.Custom) { piecePrefab2.m_category = PiecePrefabManager.GetCategory(cfg.customCategory.Value); } else { piecePrefab2.m_category = (PieceCategory)cfg.category.Value; } if (Object.op_Implicit((Object)(object)Hud.instance)) { PiecePrefabManager.CategoryRefreshNeeded = true; PiecePrefabManager.CreateCategoryTabs(); } } customTableAttributes.Browsable = cfg.category.Value == BuildPieceCategory.Custom; ReloadConfigDisplay(); } void ExtensionTableConfigChanged(object o, EventArgs e) { if (piece.RequiredItems.Requirements.Count > 0) { CraftingTable value2 = cfg.extensionTable.Value; CraftingTable craftingTable = value2; if (craftingTable == CraftingTable.Custom) { StationExtension obj2 = pieceExtensionComp; GameObject prefab2 = ZNetScene.instance.GetPrefab(cfg.customExtentionTable.Value); obj2.m_craftingStation = ((prefab2 != null) ? prefab2.GetComponent<CraftingStation>() : null); } else { pieceExtensionComp.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.extensionTable.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent<CraftingStation>(); } pieceExtensionComp.m_maxStationDistance = cfg.maxStationDistance.Value; } customTableAttributes.Browsable = cfg.extensionTable.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item5 in hideWhenNoneAttributes2) { item5.Browsable = cfg.extensionTable.Value != CraftingTable.None; } ReloadConfigDisplay(); plugin.Config.Save(); } void TableConfigChanged(object o, EventArgs e) { if (piece.RequiredItems.Requirements.Count > 0) { switch (cfg.table.Value) { case CraftingTable.None: piecePrefab2.m_craftingStation = null; break; case CraftingTable.Custom: { Piece obj = piecePrefab2; GameObject prefab = ZNetScene.instance.GetPrefab(cfg.customTable.Value); obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null); break; } default: piecePrefab2.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.table.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent<CraftingStation>(); break; } } customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item6 in hideWhenNoneAttributes) { item6.Browsable = cfg.table.Value != CraftingTable.None; } ReloadConfigDisplay(); plugin.Config.Save(); } ConfigEntry<string> itemConfig(string name, string value, string desc) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes6 = new ConfigurationManagerAttributes { CustomDrawer = DrawConfigTable, Order = (order -= 1), Category = localizedName }; return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes6 })); } } foreach (BuildPiece registeredPiece3 in registeredPieces) { ConfigEntryBase enabledCfg = registeredPiece3.RecipeIsActive; Piece piecePrefab; if (enabledCfg != null) { piecePrefab = registeredPiece3.Prefab.GetComponent<Piece>(); ConfigChanged(null, null); ((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged)); } registeredPiece3.InitializeNewRegisteredPiece(registeredPiece3); [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(2)] void ConfigChanged(object o, EventArgs e) { piecePrefab.m_enabled = (int)enabledCfg.BoxedValue != 0; } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } void ReloadConfigDisplay() { object obj3 = configManagerType?.GetProperty("DisplayingWindow").GetValue(configManager); if (obj3 is bool && (bool)obj3) { configManagerType.GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>()); } } } private void InitializeNewRegisteredPiece(BuildPiece piece) { ConfigEntryBase recipeIsActive = piece.RecipeIsActive; PieceConfig cfg; Piece piecePrefab; string pieceName; if (recipeIsActive != null) { pieceConfigs.TryGetValue(piece, out cfg); piecePrefab = piece.Prefab.GetComponent<Piece>(); pieceName = piecePrefab.m_name; ((object)recipeIsActive).GetType().GetEvent("SettingChanged").AddEventHandler(recipeIsActive, new EventHandler(ConfigChanged)); } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") != (Object)null && cfg != null) { Requirement[] resources = SerializedRequirements.toPieceReqs(new SerializedRequirements(cfg.craft.Value)); piecePrefab.m_resources = resources; Piece[] array = Object.FindObjectsOfType<Piece>(); foreach (Piece val in array) { if (val.m_name == pieceName) { val.m_resources = resources; } } } } } [HarmonyPriority(700)] internal static void Patch_ObjectDBInit(ObjectDB __instance) { //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Expected O, but got Unknown if ((Object)(object)__instance.GetItemPrefab("YmirRemains") == (Object)null) { return; } foreach (BuildPiece registeredPiece in registeredPieces) { pieceConfigs.TryGetValue(registeredPiece, out var value); registeredPiece.Prefab.GetComponent<Piece>().m_resources = SerializedRequirements.toPieceReqs((value == null) ? new SerializedRequirements(registeredPiece.RequiredItems.Requirements) : new SerializedRequirements(value.craft.Value)); foreach (ExtensionConfig extensionStation in registeredPiece.Extension.ExtensionStations) { switch ((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.Table : value.extensionTable.Value) { case CraftingTable.None: registeredPiece.Prefab.GetComponent<StationExtension>().m_craftingStation = null; break; case CraftingTable.Custom: { GameObject prefab = ZNetScene.instance.GetPrefab((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.custom : value.customExtentionTable.Value); if (prefab != null) { registeredPiece.Prefab.GetComponent<StationExtension>().m_craftingStation = prefab.GetComponent<CraftingStation>(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.custom : value.customExtentionTable.Value) + "' does not exist")); } break; } default: if (value != null && value.table.Value == CraftingTable.None) { registeredPiece.Prefab.GetComponent<StationExtension>().m_craftingStation = null; } else { registeredPiece.Prefab.GetComponent<StationExtension>().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.Table : value.extensionTable.Value).ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent<CraftingStation>(); } break; } } foreach (CraftingStationConfig station in registeredPiece.Crafting.Stations) { switch ((value == null || registeredPiece.Crafting.Stations.Count > 0) ? station.Table : value.table.Value) { case CraftingTable.None: registeredPiece.Prefab.GetComponent<Piece>().m_craftingStation = null; break; case CraftingTable.Custom: { GameObject prefab2 = ZNetScene.instance.GetPrefab((value == null || registeredPiece.Crafting.Stations.Count > 0) ? station.custom : value.customTable.Value); if (prefab2 != null) { registeredPiece.Prefab.GetComponent<Piece>().m_craftingStation = prefab2.GetComponent<CraftingStation>(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((value == null || registeredPiece.Crafting.Stations.Count > 0) ? station.custom : value.customTable.Value) + "' does not exist")); } break; } default: if (value != null && value.table.Value == CraftingTable.None) { registeredPiece.Prefab.GetComponent<Piece>().m_craftingStation = null; } else { registeredPiece.Prefab.GetComponent<Piece>().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Crafting.Stations.Count > 0) ? station.Table : value.table.Value).ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent<CraftingStation>(); } break; } } registeredPiece.conversions = new List<ItemConversion>(); for (int i = 0; i < registeredPiece.Conversions.Count; i++) { Conversion conversion = registeredPiece.Conversions[i]; registeredPiece.conversions.Add(new ItemConversion { m_from = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.input.Value ?? conversion.Input), m_to = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.output.Value ?? conversion.Output) }); if (registeredPiece.conversions[i].m_from != null && registeredPiece.conversions[i].m_to != null) { registeredPiece.Prefab.GetComponent<Smelter>().m_conversion.Add(registeredPiece.conversions[i]); } } } } public void Snapshot(float lightIntensity = 1.3f, Quaternion? cameraRotation = null) { SnapshotPiece(Prefab, lightIntensity, cameraRotation); } internal void SnapshotPiece(GameObject prefab, float lightIntensity = 1.3f, Quaternion? cameraRotation = null) { //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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab == (Object)null) && (prefab.GetComponentsInChildren<Renderer>().Any() || prefab.GetComponentsInChildren<MeshFilter>().Any())) { Camera component = new GameObject("CameraIcon", new Type[1] { typeof(Camera) }).GetComponent<Camera>(); component.backgroundColor = Color.clear; component.clearFlags = (CameraClearFlags)2; ((Component)component).transform.position = new Vector3(10000f, 10000f, 10000f); ((Component)component).transform.rotation = (Quaternion)(((??)cameraRotation) ?? Quaternion.Euler(0f, 180f, 0f)); component.fieldOfView = 0.5f; component.farClipPlane = 100000f; component.cullingMask = 8; Light component2 = new GameObject("LightIcon", new Type[1] { typeof(Light) }).GetComponent<Light>(); ((Component)component2).transform.position = new Vector3(10000f, 10000f, 10000f); ((Component)component2).transform.rotation = Quaternion.Euler(5f, 180f, 5f); component2.type = (LightType)1; component2.cullingMask = 8; component2.intensity = lightIntensity; GameObject val = Object.Instantiate<GameObject>(prefab); Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(); foreach (Transform val2 in componentsInChildren) { ((Component)val2).gameObject.layer = 3; } val.transform.position = Vector3.zero; val.transform.rotation = Quaternion.Euler(23f, 51f, 25.8f); ((Object)val).name = ((Object)prefab).name; MeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren<MeshRenderer>(); Vector3 val3 = componentsInChildren2.Aggregate(Vector3.positiveInfinity, [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Vector3 cur, MeshRenderer renderer) => { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Bounds bounds2 = ((Renderer)renderer).bounds; return Vector3.Min(cur, ((Bounds)(ref bounds2)).min); }); Vector3 val4 = componentsInChildren2.Aggregate(Vector3.negativeInfinity, [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (Vector3 cur, MeshRenderer renderer) => { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = ((Renderer)renderer).bounds; return Vector3.Max(cur, ((Bounds)(ref bounds)).max); }); val.transform.position = new Vector3(10000f, 10000f, 10000f) - (val3 + val4) / 2f; Vector3 val5 = val4 - val3; TimedDestruction val6 = val.AddComponent<TimedDestruction>(); val6.Trigger(1f); Rect val7 = default(Rect); ((Rect)(ref val7))..ctor(0f, 0f, 128f, 128f); component.targetTexture = RenderTexture.GetTemporary((int)((Rect)(ref val7)).width, (int)((Rect)(ref val7)).height); component.fieldOfView = 20f; float num = Mathf.Max(val5.x, val5.y) + 0.1f; float num2 = num / Mathf.Tan(component.fieldOfView * (MathF.PI / 180f)) * 1.1f; ((Component)component).transform.position = new Vector3(10000f, 10000f, 10000f) + new Vector3(0f, 0f, num2); component.Render(); RenderTexture active = RenderTexture.active; RenderTexture.active = component.targetTexture; Texture2D val8 = new Texture2D((int)((Rect)(ref val7)).width, (int)((Rect)(ref val7)).height, (TextureFormat)4, false); val8.ReadPixels(new Rect(0f, 0f, (float)(int)((Rect)(ref val7)).width, (float)(int)((Rect)(ref val7)).height), 0, 0); val8.Apply(); RenderTexture.active = active; prefab.GetComponent<Piece>().m_icon = Sprite.Create(val8, new Rect(0f, 0f, (float)(int)((Rect)(ref val7)).width, (float)(int)((Rect)(ref val7)).height), Vector2.one / 2f); ((Component)component2).gameObject.SetActive(false); component.targetTexture.Release(); ((Component)component).gameObject.SetActive(false); val.SetActive(false); Object.DestroyImmediate((Object)(object)val); Object.Destroy((Object)(object)component); Object.Destroy((Object)(object)component2); Object.Destroy((Object)(object)((Component)component).gameObject); Object.Destroy((Object)(object)((Component)component2).gameObject); } } private static void DrawConfigTable(ConfigEntryBase cfg) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); List<Requirement> list = new List<Requirement>(); bool flag = false; int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true) .Invoke(configManager, Array.Empty<object>()) ?? ((object)130)); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); foreach (Requirement req in new SerializedRequirements((string)cfg.BoxedValue).Reqs) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int num2 = req.amount; if (int.TryParse(GUILayout.TextField(num2.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 40f }, Array.Empty<GUILayoutOption>()), out var result) && result != num2 && !valueOrDefault) { num2 = result; flag = true; } string text = GUILayout.TextField(req.itemName, new GUIStyle(GUI.skin.textField) { fixedWidth = num - 40 - 67 - 21 - 21 - 12 }, Array.Empty<GUILayoutOption>()); string text2 = (valueOrDefault ? req.itemName : text); flag = flag || text2 != req.itemName; bool flag2 = req.recover; if (GUILayout.Toggle(req.recover, "Recover", new GUIStyle(GUI.skin.toggle) { fixedWidth = 67f }, Array.Empty<GUILayoutOption>()) != req.recover) { flag2 = !flag2; flag = true; } if (GUILayout.Button("x", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault) { flag = true; } else { list.Add(new Requirement { amount = num2, itemName = text2, recover = flag2 }); } if (GUILayout.Button("+", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault) { flag = true; list.Add(new Requirement { amount = 1, itemName = "", recover = false }); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = new SerializedRequirements(list).ToString(); } } private static ConfigEntry<T> config<[<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] T>(string group, string name, T value, ConfigDescription description) { ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description); configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T)) .Invoke(configSync, new object[1] { val }); return val; } private static ConfigEntry<T> config<[<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] T>(string group, string name, T value, string description) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } } public static class GoExtensions { [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] public static T GetOrAddComponent<[<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] T>(this GameObject gameObject) where T : Component { return gameObject.GetComponent<T>() ?? gameObject.AddComponent<T>(); } } [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [PublicAPI] public class LocalizeKey { public static readonly List<LocalizeKey> keys = new List<LocalizeKey>(); public readonly string Key; public readonly Dictionary<string, string> Localizations = new Dictionary<string, string>(); public LocalizeKey(string key) { Key = key.Replace("$", ""); keys.Add(this); } public void Alias(string alias) { Localizations.Clear(); if (!alias.Contains("$")) { alias = "$" + alias; } Localizations["alias"] = alias; Localization.instance.AddWord(Key, Localization.instance.Localize(alias)); } public LocalizeKey English(string key) { return addForLang("English", key); } public LocalizeKey Swedish(string key) { return addForLang("Swedish", key); } public LocalizeKey French(string key) { return addForLang("French", key); } public LocalizeKey Italian(string key) { return addForLang("Italian", key); } public LocalizeKey German(string key) { return addForLang("German", key); } public LocalizeKey Spanish(string key) { return addForLang("Spanish", key); } public LocalizeKey Russian(string key) { return addForLang("Russian", key); } public LocalizeKey Romanian(string key) { return addForLang("Romanian", key); } public LocalizeKey Bulgarian(string key) { return addForLang("Bulgarian", key); } public LocalizeKey Macedonian(string key) { return addForLang("Macedonian", key); } public LocalizeKey Finnish(string key) { return addForLang("Finnish", key); } public LocalizeKey Danish(string key) { return addForLang("Danish", key); } public LocalizeKey Norwegian(string key) { return addForLang("Norwegian", key); } public LocalizeKey Icelandic(string key) { return addForLang("Icelandic", key); } public LocalizeKey Turkish(string key) { return addForLang("Turkish", key); } public LocalizeKey Lithuanian(string key) { return addForLang("Lithuanian", key); } public LocalizeKey Czech(string key) { return addForLang("Czech", key); } public LocalizeKey Hungarian(string key) { return addForLang("Hungarian", key); } public LocalizeKey Slovak(string key) { return addForLang("Slovak", key); } public LocalizeKey Polish(string key) { return addForLang("Polish", key); } public LocalizeKey Dutch(string key) { return addForLang("Dutch", key); } public LocalizeKey Portuguese_European(string key) { return addForLang("Portuguese_European", key); } public LocalizeKey Portuguese_Brazilian(string key) { return addForLang("Portuguese_Brazilian", key); } public LocalizeKey Chinese(string key) { return addForLang("Chinese", key); } public LocalizeKey Japanese(string key) { return addForLang("Japanese", key); } public LocalizeKey Korean(string key) { return addForLang("Korean", key); } public LocalizeKey Hindi(string key) { return addForLang("Hindi", key); } public LocalizeKey Thai(string key) { return addForLang("Thai", key); } public LocalizeKey Abenaki(string key) { return addForLang("Abenaki", key); } public LocalizeKey Croatian(string key) { return addForLang("Croatian", key); } public LocalizeKey Georgian(string key) { return addForLang("Georgian", key); } public LocalizeKey Greek(string key) { return addForLang("Greek", key); } public LocalizeKey Serbian(string key) { return addForLang("Serbian", key); } public LocalizeKey Ukrainian(string key) { return addForLang("Ukrainian", key); } private LocalizeKey addForLang(string lang, string value) { Localizations[lang] = value; if (Localization.instance.GetSelectedLanguage() == lang) { Localization.instance.AddWord(Key, value); } else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key)) { Localization.instance.AddWord(Key, value); } return this; } [HarmonyPriority(300)] internal static void AddLocalizedKeys(Localization __instance, string language) { foreach (LocalizeKey key in keys) { string value2; if (key.Localizations.TryGetValue(language, out var value) || key.Localizations.TryGetValue("English", out value)) { __instance.AddWord(key.Key, value); } else if (key.Localizations.TryGetValue("alias", out value2)) { __instance.AddWord(key.Key, Localization.instance.Localize(value2)); } } } } [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] public static class LocalizationCache { private static readonly Dictionary<string, Localization> localizations = new Dictionary<string, Localization>(); internal static void LocalizationPostfix(Localization __instance, string language) { string key = localizations.FirstOrDefault([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (KeyValuePair<string, Localization> l) => l.Value == __instance).Key; if (key != null) { localizations.Remove(key); } if (!localizations.ContainsKey(language)) { localizations.Add(language, __instance); } } public static Localization ForLanguage([<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(2)] string language = null) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (localizations.TryGetValue(language ?? PlayerPrefs.GetString("language", "English"), out var value)) { return value; } value = new Localization(); if (language != null) { value.SetupLanguage(language); } return value; } } [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] public class AdminSyncing { private static bool isServer; internal static bool registeredOnClient; [HarmonyPriority(700)] internal static void AdminStatusSync(ZNet __instance) { isServer = __instance.IsServer(); if (BuildPiece._plugin != null) { if (isServer) { ZRoutedRpc.instance.Register<ZPackage>(BuildPiece._plugin.Info.Metadata.Name + " PMAdminStatusSync", (Action<long, ZPackage>)RPC_AdminPieceAddRemove); } else if (!registeredOnClient) { ZRoutedRpc.instance.Register<ZPackage>(BuildPiece._plugin.Info.Metadata.Name + " PMAdminStatusSync", (Action<long, ZPackage>)RPC_AdminPieceAddRemove); registeredOnClient = true; } } if (isServer) { ((MonoBehaviour)ZNet.instance).StartCoroutine(WatchAdminListChanges()); } static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(isAdmin); ((MonoBehaviour)ZNet.instance).StartCoroutine(sendZPackage(peers, val)); } static IEnumerator WatchAdminListChanges() { List<string> currentList = new List<string>(ZNet.instance.m_adminList.GetList()); while (true) { yield return (object)new WaitForSeconds(30f); if (!ZNet.instance.m_adminList.GetList().SequenceEqual(currentList)) { currentList = new List<string>(ZNet.instance.m_adminList.GetList()); List<ZNetPeer> adminPeer = (from p in ZNet.instance.GetPeers() where ZNet.instance.ListContainsId(ZNet.instance.m_adminList, p.m_rpc.GetSocket().GetHostName()) select p).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } private static IEnumerator sendZPackage(List<ZNetPeer> peers, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { yield break; } byte[] rawData = package.GetArray(); if (rawData != null && rawData.LongLength > 10000) { ZPackage compressedPackage = new ZPackage(); compressedPackage.Write(4); MemoryStream output = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(output, CompressionLevel.Optimal)) { deflateStream.Write(rawData, 0, rawData.Length); } compressedPackage.Write(output.ToArray()); package = compressedPackage; } List<IEnumerator<bool>> writers = (from peer in peers where peer.IsReady() select peer into p select TellPeerAdminStatus(p, package)).ToList(); writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); while (writers.Count > 0) { yield return null; writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); } } private static IEnumerator<bool> TellPeerAdminStatus(ZNetPeer peer, ZPackage package) { ZRoutedRpc rpc = ZRoutedRpc.instance; if (rpc != null) { SendPackage(package); } void SendPackage(ZPackage pkg) { BaseUnityPlugin plugin = BuildPiece._plugin; string text = ((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync"; if (isServer) { peer.m_rpc.Invoke(text, new object[1] { pkg }); } else { rpc.InvokeRoutedRPC(peer.m_server ? 0 : peer.m_uid, text, new object[1] { pkg }); } } yield break; } internal static void RPC_AdminPieceAddRemove(long sender, ZPackage package) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown ZNetPeer peer = ZNet.instance.GetPeer(sender); bool flag = false; try { flag = package.ReadBool(); } catch { } if (isServer) { ZRoutedRpc instance = ZRoutedRpc.instance; long everybody = ZRoutedRpc.Everybody; BaseUnityPlugin plugin = BuildPiece._plugin; instance.InvokeRoutedRPC(everybody, ((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { (object)new ZPackage() }); if (ZNet.instance.ListContainsId(ZNet.instance.m_adminList, peer.m_rpc.GetSocket().GetHostName())) { ZPackage val = new ZPackage(); val.Write(true); ZRpc rpc = peer.m_rpc; BaseUnityPlugin plugin2 = BuildPiece._plugin; rpc.Invoke(((plugin2 != null) ? plugin2.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { val }); } return; } foreach (BuildPiece registeredPiece in BuildPiece.registeredPieces) { if (!registeredPiece.SpecialProperties.AdminOnly) { continue; } Piece component = registeredPiece.Prefab.GetComponent<Piece>(); string name = component.m_name; string text = Localization.instance.Localize(name).Trim(); if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") == (Object)null) { continue; } Piece[] array = Object.FindObjectsOfType<Piece>(); foreach (Piece val2 in array) { if (flag) { if (val2.m_name == name) { val2.m_enabled = true; } } else if (val2.m_name == name) { val2.m_enabled = false; } } List<GameObject> pieces = ObjectDB.instance.GetItemPrefab("Hammer").GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces; if (flag) { if (!pieces.Contains(ZNetScene.instance.GetPrefab(((Object)component).name))) { pieces.Add(ZNetScene.instance.GetPrefab(((Object)component).name)); } } else if (pieces.Contains(ZNetScene.instance.GetPrefab(((Object)component).name))) { pieces.Remove(ZNetScene.instance.GetPrefab(((Object)component).name)); } } } } [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] [HarmonyPatch(typeof(ZNet), "OnNewConnection")] [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] internal class RegisterClientRPCPatch { private static void Postfix(ZNet __instance, ZNetPeer peer) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown if (!__instance.IsServer()) { ZRpc rpc = peer.m_rpc; BaseUnityPlugin plugin = BuildPiece._plugin; rpc.Register<ZPackage>(((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync", (Action<ZRpc, ZPackage>)RPC_InitialAdminSync); return; } ZPackage val = new ZPackage(); val.Write(__instance.ListContainsId(__instance.m_adminList, peer.m_rpc.GetSocket().GetHostName())); ZRpc rpc2 = peer.m_rpc; BaseUnityPlugin plugin2 = BuildPiece._plugin; rpc2.Invoke(((plugin2 != null) ? plugin2.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { val }); } private static void RPC_InitialAdminSync(ZRpc rpc, ZPackage package) { AdminSyncing.RPC_AdminPieceAddRemove(0L, package); } } [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] [<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(1)] public static class PiecePrefabManager { [<48fcde38-c513-4970-bafc-a1e9080f5a46>Nullable(0)] private struct BundleId { [UsedImplicitly] public string assetBundleFileName; [UsedImplicitly] public string folderName; } private static readonly Dictionary<BundleId, AssetBundle> bundleCache; private static readonly List<GameObject> piecePrefabs; private static readonly Dictionary<string, PieceCategory> PieceCategories; private static readonly Dictionary<string, PieceCategory> OtherPieceCategories; private static readonly Dictionary<PieceCategory, string> VanillaLabels; internal static bool CategoryRefreshNeeded; static PiecePrefabManager() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02eb: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Expected O, but got Unknown //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Expected O, but got Unknown //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Expected O, but got Unknown bundleCache = new Dictionary<BundleId, AssetBundle>(); piecePrefabs = new List<GameObject>(); PieceCategories = new Dictionary<string, PieceCategory>(); OtherPieceCategories = new Dictionary<string, PieceCategory>(); VanillaLabels = new Dictionary<PieceCategory, string>(); Harmony val = new Harmony("org.bepinex.helpers.PieceManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(BuildPiece), "Patch_FejdStartup", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizeKey), "AddLocalizedKeys", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizationCache), "LocalizationPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(BuildPiece), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "CopyOtherDB", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNet), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(AdminSyncing), "AdminStatusSync", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RefFixPatch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PieceTable), "UpdateAvailable", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Transpiler", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PieceTable), "UpdateAvailable", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetPlaceMode", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_SetPlaceMode", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Hud_AwakeCreateTabs", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "UpdateBuild", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RepositionCatsIfNeeded", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "LateUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RepositionCatsIfNeeded", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Enum), "GetValues", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "EnumGetValuesPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Enum), "GetNames", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "EnumGetNamesPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static AssetBundle RegisterAssetBundle(string assetBundleFileName, string folderName = "assets") { BundleId bundleId = default(BundleId); bundleId.assetBundleFileName = assetBundleFileName; bundleId.folderName = folderName; BundleId key = bundleId; if (!bundleCache.TryGetValue(key, out var value)) { Dictionary<BundleId, AssetBundle> dictionary = bundleCache; AssetBundle? obj = ((IEnumerable<AssetBundle>)Resources.FindObjectsOfTypeAll<AssetBundle>()).FirstOrDefault((Func<AssetBundle, bool>)([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (AssetBundle a) => ((Object)a).name == assetBundleFileName)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + folderName + "." + assetBundleFileName)); AssetBundle result = obj; dictionary[key] = obj; return result; } return value; } public static IEnumerable<GameObject> FixRefs(AssetBundle assetBundle) { return assetBundle.LoadAllAssets<GameObject>(); } public static GameObject RegisterPrefab(string assetBundleFileName, string prefabName, string folderName = "assets") { return RegisterPrefab(RegisterAssetBundle(assetBundleFileName, folderName), prefabName); } public static GameObject RegisterPrefab(AssetBundle assets, string prefabName) { if ((Object)(object)assets == (Object)null) { Debug.LogError((object)"Failed to load asset bundle. Please make sure to mark all asset bundles as embedded resources."); return null; } GameObject val = assets.LoadAsset<GameObject>(prefabName); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("Failed to load prefab " + prefabName + " from asset bundle " + ((Object)assets).name)); return null; } piecePrefabs.Add(val); return val; } public static Sprite RegisterSprite(string assetBundleFileName, string prefabName, string folderName = "assets") { return RegisterSprite(RegisterAssetBundle(assetBundleFileName, folderName), prefabName); } public static Sprite RegisterSprite(AssetBundle assets, string prefabName) { return assets.LoadAsset<Sprite>(prefabName); } private static void EnumGetValuesPatch(Type enumType, ref Array __result) { if (!(enumType != typeof(PieceCategory)) && PieceCategories.Count != 0) { PieceCategory[] array = (PieceCategory[])(object)new PieceCategory[__result.Length + PieceCategories.Count]; __result.CopyTo(array, 0); PieceCategories.Values.CopyTo(array, __result.Length); __result = array; } } private static void EnumGetNamesPatch(Type enumType, ref string[] __result) { if (!(enumType != typeof(PieceCategory)) && PieceCategories.Count != 0) { __result = CollectionExtensions.AddRangeToArray<string>(__result, PieceCategories.Keys.ToArray()); } } public static Dictionary<PieceCategory, string> GetPieceCategoriesMap() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Array values = Enum.GetValues(typeof(PieceCategory)); string[] names = Enum.GetNames(typeof(PieceCategory)); Dictionary<PieceCategory, string> dictionary = new Dictionary<PieceCategory, string>(); for (int i = 0; i < values.Length; i++) { dictionary[(PieceCategory)values.GetValue(i)] = names[i]; } return dictionary; } public static PieceCategory GetCategory(string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (Enum.TryParse<PieceCategory>(name, ignoreCase: true, out PieceCategory result)) { return result; } if (PieceCategories.TryGetValue(name, out result)) { return result; } if (OtherPieceCategories.TryGetValue(name, out result)) { return result; } Dictionary<PieceCategory, string> pieceCategoriesMap = GetPieceCategoriesMap(); foreach (KeyValuePair<PieceCategory, string> item in pieceCategoriesMap) { if (item.Value == name) { result = item.Key; OtherPieceCategories[name] = result; return result; } } result = (PieceCategory)(pieceCategoriesMap.Count - 1); PieceCategories[name] = result; string categoryToken = GetCategoryToken(name); Localization.instance.AddWord(categoryToken, name); return result; } internal static void CreateCategoryTabs() { if (Object.op_Implicit((Object)(object)Hud.instance)) { int num = ModifiedMaxCategory(); for (int i = Hud.instance.m_pieceCategoryTabs.Length; i < num; i++) { GameObject val = CreateCategoryTab(); Hud.instance.m_pieceCategoryTabs = CollectionExtensions.AddItem<GameObject>((IEnumerable<GameObject>)Hud.instance.m_pieceCategoryTabs, val).ToArray(); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { RepositionCategories(Player.m_localPlayer.m_buildPieces); Player.m_localPlayer.UpdateAvailablePiecesList(); } } } private static GameObject CreateCategoryTab() { //IL_0084: 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) GameObject val = Hud.instance.m_pieceCategoryTabs[0]; GameObject val2 = Object.Instantiate<GameObject>(Hud.instance.m_pieceCategoryTabs[0], val.transform.parent); val2.SetActive(false); UIInputHandler orAddComponent = val2.GetOrAddComponent<UIInputHandler>(); orAddComponent.m_onLeftDown = (Action<UIInputHandler>)Delegate.Combine(orAddComponent.m_onLeftDown, new Action<UIInputHandler>(Hud.instance.OnLeftClickCategory)); TMP_Text[] componentsInChildren = val2.GetComponentsInChildren<TMP_Text>(); foreach (TMP_Text val3 in componentsInChildren) { val3.rectTransform.offsetMin = new Vector2(3f, 1f); val3.rectTransform.offsetMax = new Vector2(-3f, -1f); val3.enableAutoSizing = true; val3.fontSizeMin = 12f; val3.fontSizeMax = 20f; val3.lineSpacing = 0.8f; val3.textWrappingMode = (TextWrappingModes)1; val3.overflowMode = (TextOverflowModes)3; } return val2; } private static int ModifiedMaxCategory() { return Enum.GetValues(typeof(PieceCategory)).Length - 1; } private static int GetMaxCategoryOrDefault() { try { return (int)Enum.Parse(typeof(PieceCategory), "Max"); } catch (ArgumentException) { Debug.LogWarning((object)"Could not find Piece.PieceCategory.Max, using fallback value 4"); return 4; } } private static List<CodeInstruction> TranspileMaxCategory(IEnumerable<CodeInstruction> instructions, int maxOffset) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown int num = GetMaxCategoryOrDefault() + maxOffset; List<CodeInstruction> list = new List<CodeInstruction>(); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.LoadsConstant(instruction, (long)num)) { list.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "ModifiedMaxCategory", (Type[])null, (Type[])null))); if (maxOffset != 0) { list.Add(new CodeInstruction(OpCodes.Ldc_I4, (object)maxOffset)); list.Add(new CodeInstruction(OpCodes.Add, (object)null)); } } else { list.Add(instruction); } } return list; } private static IEnumerable<CodeInstruction> UpdateAvailable_Transpiler(IEnumerable<CodeInstruction> instructions) { return TranspileMaxCategory(instructions, 0); } private static HashSet<PieceCategory> CategoriesInPieceTable(PieceTable pieceTable) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) HashSet<PieceCategory> hashSet = new HashSet<PieceCategory>(); Piece val = default(Piece); foreach (GameObject item in pieceTable.m_pieces.Where([<26d0bfab-9eba-4707-80d0-500298e9c4f7>NullableContext(0)] (GameObject pieceFab) => (Object)(object)pieceFab != (Object)null)) { if (item.TryGetComponent<Piece>(ref val)) { hashSet.Add(val.m_category); } } return hashSet; } private static void RepositionCatsIfNeeded() { if (CategoryRefreshNeeded) { CategoryRefreshNeeded = false; CreateCategoryTabs(); RepositionCats(); } } private static void RepositionCats() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { RepositionCategories(Player.m_localPlayer.m_buildPieces); } } private static void RepositionCategories(PieceTable pieceTable) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing
RavenQuests.dll
Decompiled 6 hours 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.Cryptography; 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 HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using RavenQuests.API; using RavenQuests.Solution; using RavenQuests.Solution.Behaviors; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; 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: AssemblyFileVersion("0.0.1")] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyProduct("RavenQuests")] [assembly: AssemblyCompany("RustyMods")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("RavenQuests")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<c1429d6d-3efd-4d13-9b9c-cc0bb27689d6>Embedded] internal sealed class <c1429d6d-3efd-4d13-9b9c-cc0bb27689d6>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<c1429d6d-3efd-4d13-9b9c-cc0bb27689d6>Embedded] [CompilerGenerated] internal sealed class <03f138a6-931d-4acc-a711-e8e94d3b7f2b>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <03f138a6-931d-4acc-a711-e8e94d3b7f2b>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <03f138a6-931d-4acc-a711-e8e94d3b7f2b>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<c1429d6d-3efd-4d13-9b9c-cc0bb27689d6>Embedded] [CompilerGenerated] internal sealed class <21190bcf-0860-4029-83e9-c85e99fc529c>NullableContextAttribute : Attribute { public readonly byte Flag; public <21190bcf-0860-4029-83e9-c85e99fc529c>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] [PublicAPI] public class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] [return: <03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(1)] (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.ContainsKey(language)) { text2 = File.ReadAllText(dictionary[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.ContainsKey("English")) { text2 = File.ReadAllText(dictionary["English"]); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string> { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace RavenQuests { [BepInDependency(/*Could not decode attribute arguments.*/)] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [BepInPlugin("RustyMods.RavenQuests", "RavenQuests", "0.0.1")] public class RavenQuestsPlugin : BaseUnityPlugin { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] public enum Toggle { On = 1, Off = 0 } [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Patch { private static void Postfix() { InitRaven(); } } [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] [UsedImplicitly] public string Category; [UsedImplicitly] [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(new byte[] { 2, 1 })] public Action<ConfigEntryBase> CustomDrawer; } internal const string ModName = "RavenQuests"; internal const string ModVersion = "0.0.1"; internal const string Author = "RustyMods"; private const string ModGUID = "RustyMods.RavenQuests"; private static string ConfigFileName = "RustyMods.RavenQuests.cfg"; private static string ConfigFileFullPath; internal static string ConnectionError; private readonly Harmony _harmony = new Harmony("RustyMods.RavenQuests"); public static readonly ManualLogSource RavenQuestsLogger; public static readonly ConfigSync ConfigSync; public static RavenQuestsPlugin Plugin; private static AssetBundle Assets; public static GameObject m_thirdEye; public static GameObject m_root; public static GameObject m_raven; private static ConfigEntry<Toggle> _serverConfigLocked; public static ConfigEntry<Vector2> _hudPosition; public static ConfigEntry<float> _UIScale; private static ConfigEntry<KeyCode> _spawnRavenKey; private static AssetBundle GetAssetBundle(string fileName) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single([<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (string str) => str.EndsWith(fileName)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } private void InitConfigs() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown _serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only."); ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); _hudPosition = config<Vector2>("2 - Settings", "HUD Overlay", new Vector2(820f, 250f), "Set position of HUD overlay"); _UIScale = config("2 - Settings", "UI Scale", 1f, new ConfigDescription("Set scale of UI", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); _spawnRavenKey = config<KeyCode>("2 - Settings", "Spawn Key", (KeyCode)285, "Set the key code to spawn/despawn quest raven"); } private static void InitRaven() { GameObject val = Resources.FindObjectsOfTypeAll<GameObject>().ToList().Find([<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (GameObject x) => ((Object)x).name == "Ravens" && ((Object)x.transform.GetChild(0)).name == "Hugin"); if (val != null) { m_raven = Object.Instantiate<GameObject>(((Component)val.transform.GetChild(0)).gameObject, m_root.transform, false); QuestRaven questRaven = m_raven.AddComponent<QuestRaven>(); Raven val2 = default(Raven); if (m_raven.TryGetComponent<Raven>(ref val2)) { questRaven.m_visual = val2.m_visual; questRaven.m_exclamation = val2.m_exclamation; questRaven.m_idleEffect = val2.m_idleEffect; questRaven.m_deSpawnEffect = val2.m_despawnEffect; Object.Destroy((Object)(object)val2); } } } public void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Plugin = this; Localizer.Load(); m_root = new GameObject("root"); Object.DontDestroyOnLoad((Object)(object)m_root); m_root.SetActive(false); InitConfigs(); DefaultQuests.Setup(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); SetupWatcher(); } private void Update() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Player.m_localPlayer.m_knownBiome.Contains((Biome)64)) { if (Input.GetKeyDown(_spawnRavenKey.Value)) { QuestRaven.ToggleFly(); } UI.Update(); } } public void SpawnBounty() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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) QuestManager.Quest currentQuest = QuestManager.m_currentQuest; if (currentQuest == null) { return; } QuestManager.Quest.QuestData data = currentQuest.Data; if (data == null) { return; } Bounty.BountyModifiers bountyData = data.BountyData; if (bountyData != null) { GameObject critter = bountyData.m_critter; if (critter != null) { GameObject val = Object.Instantiate<GameObject>(critter, currentQuest.Data.BountyData.m_pos, Quaternion.identity); ((Object)val).name = "Bounty"; Bounty bounty = val.AddComponent<Bounty>(); bounty.ApplyModifiers(currentQuest.Data.BountyData); Bounty.DoneSpawnEffectList.Create(val.transform.position, Quaternion.identity, (Transform)null, 1f, -1); currentQuest.m_currentBounty = bounty; } } } public void Spawn() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) QuestManager.Quest currentQuest = QuestManager.m_currentQuest; if (currentQuest != null) { GameObject prefab = ZNetScene.instance.GetPrefab(currentQuest.Data.PrefabName); if (prefab != null) { Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position, Quaternion.identity); Bounty.DoneSpawnEffectList.Create(prefab.transform.position, Quaternion.identity, (Transform)null, 1f, -1); } } } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { RavenQuestsLogger.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { RavenQuestsLogger.LogError((object)("There was an issue loading your " + ConfigFileName)); RavenQuestsLogger.LogError((object)"Please check your config entries for spelling and format!"); } } private ConfigEntry<T> config<[<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val); SyncedConfigEntry<T> syncedConfigEntry = ConfigSync.AddConfigEntry<T>(val2); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val2; } private ConfigEntry<T> config<[<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } static RavenQuestsPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; ConnectionError = ""; RavenQuestsLogger = Logger.CreateLogSource("RavenQuests"); ConfigSync = new ConfigSync("RustyMods.RavenQuests") { DisplayName = "RavenQuests", CurrentVersion = "0.0.1", MinimumRequiredVersion = "0.0.1" }; Plugin = null; Assets = GetAssetBundle("ravenquestbundle"); m_thirdEye = Assets.LoadAsset<GameObject>("thirdeye"); m_root = null; m_raven = null; _serverConfigLocked = null; _hudPosition = null; _UIScale = null; _spawnRavenKey = null; } } public static class KeyboardExtensions { public static bool IsKeyDown(this KeyboardShortcut shortcut) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey); } public static bool IsKeyHeld(this KeyboardShortcut shortcut) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey); } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] public static class RegisterAndCheckVersion { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown RavenQuestsPlugin.RavenQuestsLogger.LogDebug((object)"Registering version RPC handler"); peer.m_rpc.Register<ZPackage>("RavenQuests_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_RavenQuests_Version); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)"Invoking version check"); ZPackage val = new ZPackage(); val.Write("0.0.1"); peer.m_rpc.Invoke("RavenQuests_VersionCheck", new object[1] { val }); } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] public static class VerifyClient { private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance) { if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc)) { return true; } RavenQuestsPlugin.RavenQuestsLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting")); rpc.Invoke("Error", new object[1] { 3 }); return false; } private static void Postfix(ZNet __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RavenQuestsRequestAdminSync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] public class ShowConnectionError { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(FejdStartup __instance) { if (__instance.m_connectionFailedPanel.activeSelf) { __instance.m_connectionFailedError.fontSizeMax = 25f; __instance.m_connectionFailedError.fontSizeMin = 15f; TMP_Text connectionFailedError = __instance.m_connectionFailedError; connectionFailedError.text = connectionFailedError.text + "\n" + RavenQuestsPlugin.ConnectionError; } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] public static class RemoveDisconnectedPeerFromVerified { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { if (__instance.IsServer()) { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list")); RpcHandlers.ValidatedPeers.Remove(peer.m_rpc); } } } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] public static class RpcHandlers { public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>(); public static void RPC_RavenQuests_Version(ZRpc rpc, ZPackage pkg) { string text = pkg.ReadString(); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Version check, local: 0.0.1, remote: " + text)); if (text != "0.0.1") { RavenQuestsPlugin.ConnectionError = "RavenQuests Installed: 0.0.1\n Needed: " + text; if (ZNet.instance.IsServer()) { RavenQuestsPlugin.RavenQuestsLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting...")); rpc.Invoke("Error", new object[1] { 3 }); } } else if (!ZNet.instance.IsServer()) { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)"Received same version from server!"); } else { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list")); ValidatedPeers.Add(rpc); } } public static string ComputeHashForMod() { using SHA256 sHA = SHA256.Create(); byte[] array = sHA.ComputeHash(File.ReadAllBytes(Assembly.GetExecutingAssembly().Location)); StringBuilder stringBuilder = new StringBuilder(); byte[] array2 = array; foreach (byte b in array2) { stringBuilder.Append(b.ToString("X2")); } return stringBuilder.ToString(); } } } namespace RavenQuests.Solution { public static class DefaultQuests { [HarmonyPatch(typeof(Player), "AddKnownBiome")] private static class Player_AddKnownBiome_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(Player __instance, Biome biome) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 if ((int)biome == 64 && !__instance.m_knownBiome.Contains((Biome)64)) { QuestRaven.ToggleFly(enable: true); } } } public static void Setup() { QuestManager.Quest Runestones = new QuestManager.Quest("Lore", "Discover the 5 runestones of the deep north", 0, QuestManager.Quest.QuestData.QuestType.Text); Runestones.Data.Set(new List<string> { "$runestone_deepnorth_1", "$runestone_deepnorth_2", "$runestone_deepnorth_3", "$runestone_deepnorth_4", "$runestone_deepnorth_5" }, "Runestones"); Runestones.Reward.Set("Navi_RS", 1, 1, 0); Runestones.AddStartText("Hail, traveler of the North! You stand upon ancient grounds, where secrets lay frozen in time. If you seek knowledge beyond the mortal realm, I shall guide your path."); Runestones.AddStartText("Summon me whenever your courage falters, by calling upon the runes in your possession."); Runestones.AddStartText("Your journey begins by seeking the ten sacred runestones scattered across this desolate tundra."); Runestones.AddStartText("Do you possess the heart of a true warrior to accept this quest?"); Runestones.AddStartAction("May the spirits of the North watch over you!", delegate(bool alt) { if (!alt) { Runestones.AcceptQuest(); } else { QuestRaven.m_questData = null; } }); Runestones.AddCancelText("Your journey has only just begun. The ancient echoes call for you to unearth the lost tales of this land."); Runestones.AddCancelText("Do you wish to abandon this path and leave these mysteries hidden in the ice?"); Runestones.AddCancelAction("May the fates guide your choice.", delegate(bool alt) { if (alt) { Runestones.CancelQuest(); } else { QuestRaven.ToggleFly(); } }); Runestones.AddCompletedText("You have proven yourself cunning and resilient, mastering the secrets of this frozen tundra."); Runestones.AddCompletedText("As foretold, a reward awaits you for your valor. Will you claim it now, warrior?"); Runestones.AddCompletedAction("Summon me when you are ready to face the next challenge that lies beyond the mists.", delegate(bool alt) { if (!alt) { Runestones.CollectReward(Player.m_localPlayer); } else { QuestRaven.ToggleFly(); } }); QuestManager.Quest Snowmen = new QuestManager.Quest("Curiosities", "Seek out the three enchanted snowmen hidden in the frostbitten lands", 1, QuestManager.Quest.QuestData.QuestType.Runestone); Snowmen.Reward.Set("ChristmasPresent_RS", 3, 1, 0); Snowmen.Data.Set(new List<string> { "Snowman_01", "Snowman_02", "Snowman_03" }, "Snowmen"); Snowmen.AddStartText("A new trial awaits, traveler of winter's realm."); Snowmen.AddStartText("Hidden among these dark, icy lands are three ancient snowmen, crafted long ago. Find them, and a Yuletide treasure shall be yours."); Snowmen.AddStartText("Will you accept this quest of frost and mystery?"); Snowmen.AddStartAction("May the winds guide your search!", delegate(bool alt) { if (!alt) { Snowmen.AcceptQuest(); } else { QuestRaven.m_questData = null; } }); Snowmen.AddCancelText("The quest to find the three enchanted snowmen is yours to bear. Do you wish to abandon it?"); Snowmen.AddCancelAction("The choice is yours, wanderer of snow and shadow.", delegate(bool alt) { if (alt) { Snowmen.CancelQuest(); } else { QuestRaven.ToggleFly(); } }); Snowmen.AddCompletedText("Impressive! You have uncovered the three enchanted snowmen hidden in the frozen wilds."); Snowmen.AddCompletedText("A Yuletide gift awaits, a reward for your persistence and sharp eyes. Will you claim it now?"); Snowmen.AddCompletedAction("Take heart, and may the spirit of winter guide you onward!", delegate(bool alt) { if (!alt) { Snowmen.CollectReward(Player.m_localPlayer); } else { QuestRaven.ToggleFly(); } }); QuestManager.Quest Trophies = new QuestManager.Quest("Trophy Hunter", "Gather the sacred trophies of the North", 2, QuestManager.Quest.QuestData.QuestType.Trophies); Trophies.Reward.Set("CryptKey_RS", 1, 1, 0); Trophies.Data.Set(new List<string> { "TrophyCatFish_RS", "TrophyCreeper_RS", "TrophyLizardFish_RS", "TrophyWendigo_RS", "TrophyWereBoar_RS", "TrophyWereWolf_RS", "TrophyYeti_RS" }, "Trophies"); Trophies.AddStartText("Prove yourself, warrior. The North calls for a champion worthy to bear its secrets."); Trophies.AddStartText("Bring forth the trophies of its fiercest beasts, and I shall grant you a key to the dungeons below."); Trophies.AddStartText("Do you accept this trial of courage and blood?"); Trophies.AddStartAction("May the spirits of the wild be at your side.", delegate(bool alt) { if (!alt) { Trophies.AcceptQuest(); } else { QuestRaven.m_questData = null; } }); Trophies.AddCancelText("The task is yours: gather the sacred trophies of the North. Are you prepared to let it go?"); Trophies.AddCancelAction("Farewell, hunter. May the beasts spare you in your journey.", delegate(bool alt) { if (alt) { Trophies.CancelQuest(); } else { QuestRaven.ToggleFly(); } }); Trophies.AddCompletedText("Impressive, warrior! You’ve conquered the wilds and returned with the sacred trophies."); Trophies.AddCompletedText("As promised, here is the key to the dungeon's mysteries."); Trophies.AddCompletedText("Will you claim it now and continue your path?"); Trophies.AddCompletedAction("Until we meet again on the hunt.", delegate(bool alt) { if (!alt) { Trophies.CollectReward(Player.m_localPlayer); } else { QuestRaven.ToggleFly(); } }); QuestManager.Quest CoatOfArms = new QuestManager.Quest("Coat of Arms", "Seek out the 12 lost coats of arms", 3, QuestManager.Quest.QuestData.QuestType.CollectItems); CoatOfArms.Data.Set(new List<string> { "CoatOfArmsItem1_RS", "CoatOfArmsItem2_RS", "CoatOfArmsItem3_RS", "CoatOfArmsItem4_RS", "CoatOfArmsItem5_RS", "CoatOfArmsItem6_RS", "CoatOfArmsItem7_RS", "CoatOfArmsItem8_RS", "CoatOfArmsItem9_RS", "CoatOfArmsItem10_RS", "CoatOfArmsItem11_RS", "CoatOfArmsItem12_RS" }, "Coat of Arms"); CoatOfArms.Reward.Set("DungeonKey_RS", 1, 1, 0); CoatOfArms.AddStartText("The path you walk grows darker. To complete this trial, you must venture into forsaken crypts and claim the ancient coats of arms."); CoatOfArms.AddStartText("These symbols, long worn by the undead, hold the memories of warriors past. Are you prepared to face them?"); CoatOfArms.AddStartText("Will you brave the crypts and claim these relics?"); CoatOfArms.AddStartAction("May the ancient spirits watch over you.", delegate(bool alt) { if (!alt) { CoatOfArms.AcceptQuest(); } else { QuestRaven.m_questData = null; } }); CoatOfArms.AddCancelText("The task is set: gather the coats of arms lost to time, held by the undead within the crypts."); CoatOfArms.AddCancelText("Do you choose to abandon this quest?"); CoatOfArms.AddCancelAction("Return, should your courage be renewed.", delegate(bool alt) { if (alt) { CoatOfArms.CancelQuest(); } else { QuestRaven.ToggleFly(); } }); CoatOfArms.AddCompletedText("Well done, warrior. You have unearthed all 12 coats of arms, defying the shadows of the crypt."); CoatOfArms.AddCompletedText("As promised, a relic from the ancient, access to the temple."); CoatOfArms.AddCompletedText("Will you accept it now?"); CoatOfArms.AddCompletedAction("Until our paths cross again, brave soul.", delegate(bool alt) { if (!alt) { CoatOfArms.CollectReward(Player.m_localPlayer); } else { QuestRaven.ToggleFly(); } }); QuestManager.Quest StoneGuard = new QuestManager.Quest("Eryndral", "Ascend the tower and seek out the Stone Guard to uncover the wisdom of the ancients.", 4, QuestManager.Quest.QuestData.QuestType.Runestone); StoneGuard.Data.Set(new List<string> { "StoneGuard_RS" }, "Statue"); StoneGuard.Reward.Set("AxeAncient_RS", 1, 1, 0); StoneGuard.AddStartText("In the days of old, when the Gray Wizard still walked the lands, he built a solitary tower to guard his most profound secrets."); StoneGuard.AddStartText("At its peak stands Eryndral, the Stone Guard, a timeless sentinel. He will judge your worth."); StoneGuard.AddStartText("If you dare to take on this challenge, a relic of untold power awaits you as your reward."); StoneGuard.AddStartText("Will you face the Stone Guard and prove yourself?"); StoneGuard.AddStartAction("May your courage guide you, traveler!", delegate(bool alt) { if (!alt) { StoneGuard.AcceptQuest(); } else { QuestRaven.m_questData = null; } }); StoneGuard.AddCancelText("The ascent to the wizard's tower is perilous, and only the brave return with the knowledge of the past."); StoneGuard.AddCancelText("Do you wish to abandon this quest and leave its secrets behind?"); StoneGuard.AddCancelAction("Farewell, traveler. The tower awaits your return.", delegate(bool alt) { if (alt) { StoneGuard.CancelQuest(); } else { QuestRaven.ToggleFly(); } }); StoneGuard.AddCompletedText("You stand triumphant at the summit, where few have tread. The Stone Guard nods in approval."); StoneGuard.AddCompletedText("As promised, the relic is yours to claim. It hums with an energy that defies understanding."); StoneGuard.AddCompletedText("Do you accept your reward, or leave it for another time?"); StoneGuard.AddCompletedAction("May this gift serve you well, traveler. Go forth in light and shadow.", delegate(bool alt) { if (!alt) { StoneGuard.CollectReward(Player.m_localPlayer); } else { QuestRaven.ToggleFly(); } }); } } public static class Helpers { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] public static string GetNormalizedName(string name) { return Regex.Replace(name, "\\s*\\(.*?\\)", "").Trim(); } } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] public static class QuestManager { [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [HarmonyPatch(typeof(Player), "Load")] private static class Player_Load_Patch { private static void Postfix(Player __instance) { LoadProgress(__instance); LoadCurrentQuest(__instance); } private static void LoadProgress(Player player) { if (!player.m_customData.TryGetValue("RavenQuestData", out var value)) { return; } IDeserializer deserializer = new DeserializerBuilder().Build(); Dictionary<string, PlayerQuestData> savedQuestData = deserializer.Deserialize<Dictionary<string, PlayerQuestData>>(value); m_savedQuestData = savedQuestData; foreach (PlayerQuestData value3 in m_savedQuestData.Values) { if (!m_quests.TryGetValue(value3.QuestName, out var value2)) { continue; } value2.SetProgress(value3.Progress, save: false); value2.Data.FoundPrefabs = value3.FoundPrefabs; foreach (string foundPrefab in value3.FoundPrefabs) { value2.Data.PrefabNames.Remove(foundPrefab); } value2.m_completed = value3.Completed; } } private static void LoadCurrentQuest(Player player) { if (player.m_customData.TryGetValue("RavenCurrentQuest", out var value) && m_quests.TryGetValue(value, out var value2)) { m_currentQuest = value2; } } } [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] [HarmonyPatch(typeof(Game), "SavePlayerProfile")] private static class Game_SavePlayerProfile_Patch { private static void Prefix() { SaveProgress(); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] private static class ObjectDB_Awake_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(ObjectDB __instance) { if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)ZNetScene.instance)) { return; } foreach (Quest value in m_quests.Values) { value.UpdateSharedName(); if (value.Data.Type == Quest.QuestData.QuestType.Bounty) { value.GetBountyPrefab(); } } } } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] public class Quest { [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] public class Dialogue { public readonly string m_text; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] public readonly Action<bool> m_action; public Dialogue(string text) { m_text = text; } public Dialogue(string text, [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] Action<bool> action) { m_text = text; m_action = action; } } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] public class QuestData { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] public enum QuestType { Kill, Harvest, Collect, CollectItems, Bounty, Farm, Craft, Runestone, Location, Destructible, Text, Trophies } public List<string> PrefabNames = new List<string>(); public readonly List<string> SharedNames = new List<string>(); public readonly Dictionary<string, string> Names = new Dictionary<string, string>(); public int PrefabCount; public List<string> FoundPrefabs = new List<string>(); [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] public string SharedName; public int Amount; public int Level; public int Progress; public readonly Bounty.BountyModifiers BountyData = new Bounty.BountyModifiers(); public QuestType Type { get; private set; } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] [field: <03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] public string PrefabName { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(2)] get; [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(2)] private set; } = ""; public void Set(List<string> prefabNames, string key) { PrefabNames = prefabNames; Amount = prefabNames.Count; PrefabCount = prefabNames.Count; PrefabName = key; } public void Set(string prefabName, int amount = 1, int level = 1) { PrefabName = prefabName; Amount = amount; Level = level; if (Type == QuestType.Bounty) { Amount = 1; } } public void Set(string prefabName, string name) { PrefabName = prefabName; BountyData.m_name = name; Amount = 1; Type = QuestType.Bounty; } public void GetSharedName() { if (PrefabNames.Count > 0 && Type == QuestType.CollectItems) { ItemDrop val = default(ItemDrop); foreach (string prefabName in PrefabNames) { GameObject prefab = ZNetScene.instance.GetPrefab(prefabName); if (prefab != null && prefab.TryGetComponent<ItemDrop>(ref val)) { SharedNames.Add(val.m_itemData.m_shared.m_name); Names[prefabName] = val.m_itemData.m_shared.m_name; } } } if (Utility.IsNullOrWhiteSpace(PrefabName)) { return; } GameObject prefab2 = ZNetScene.instance.GetPrefab(PrefabName); if (prefab2 == null) { SharedName = PrefabName; return; } switch (Type) { case QuestType.Kill: { Character val4 = default(Character); SharedName = (prefab2.TryGetComponent<Character>(ref val4) ? val4.m_name : PrefabName); break; } case QuestType.Harvest: { Pickable val3 = default(Pickable); SharedName = (prefab2.TryGetComponent<Pickable>(ref val3) ? val3.GetHoverName() : PrefabName); break; } case QuestType.Collect: case QuestType.Craft: { ItemDrop val5 = default(ItemDrop); SharedName = (prefab2.TryGetComponent<ItemDrop>(ref val5) ? val5.m_itemData.m_shared.m_name : PrefabName); break; } case QuestType.Farm: { Piece val2 = default(Piece); SharedName = (prefab2.TryGetComponent<Piece>(ref val2) ? val2.m_name : PrefabName); break; } case QuestType.Bounty: SharedName = BountyData.m_name; break; case QuestType.CollectItems: break; } } public QuestData(QuestType questType) { Type = questType; } } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] public class RewardData { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] public enum RewardType { Item, Skill, AlmanacEXP, Spawn } public string SharedName = ""; public RewardType Type { get; private set; } public string PrefabName { get; private set; } = null; public int Amount { get; private set; } public float Delay { get; private set; } public int Quality { get; private set; } public int Variant { get; private set; } public SkillType SkillType { get; private set; } public float ExperienceAmount { get; private set; } public void Set(string itemName, int amount, int quality, int variant) { Type = RewardType.Item; PrefabName = itemName; Amount = amount; Quality = quality; Variant = variant; } public void GetSharedName() { if (Utility.IsNullOrWhiteSpace(PrefabName)) { return; } RewardType type = Type; RewardType rewardType = type; if (rewardType == RewardType.Spawn) { GameObject prefab = ZNetScene.instance.GetPrefab(PrefabName); Character val = default(Character); if (Object.op_Implicit((Object)(object)prefab) && prefab.TryGetComponent<Character>(ref val)) { SharedName = val.m_name; } } else { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(PrefabName); ItemDrop val2 = default(ItemDrop); if (Object.op_Implicit((Object)(object)itemPrefab) && itemPrefab.TryGetComponent<ItemDrop>(ref val2)) { SharedName = val2.m_itemData.m_shared.m_name; } } } public void Set(SkillType skillType, float amount) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Type = RewardType.Skill; SkillType = skillType; ExperienceAmount = amount; } public void Set(string creatureName, int amount, float delay) { PrefabName = creatureName; Delay = delay; Amount = amount; } } public readonly RewardData Reward = new RewardData(); public readonly QuestData Data; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] public Bounty m_currentBounty; public readonly Queue<Dialogue> m_startQueue = new Queue<Dialogue>(); public readonly Queue<Dialogue> m_cancelQueue = new Queue<Dialogue>(); public readonly Queue<Dialogue> m_completedQueue = new Queue<Dialogue>(); public bool m_completed; public string Name { get; } public string Description { get; } public Quest(string name, string description, int index, QuestData.QuestType type) { Name = name; Description = description; Data = new QuestData(type); m_quests[name] = this; m_questQueue[index] = this; } public bool IsCorrectType(QuestData.QuestType type) { return Data.Type == type; } public bool IsMatchingRunestone(string name) { return Data.PrefabNames.Contains(name); } public bool IsMatchingPrefab(string name, bool sharedName = false) { return sharedName ? (Data.SharedName == name) : (name == Data.PrefabName); } public void UpdateSharedName() { Data.GetSharedName(); Reward.GetSharedName(); } public void AcceptQuest() { m_currentQuest = this; QuestRaven.m_questData = null; QuestRaven.ToggleFly(); StartBountySpawn(); } public void GetBountyPrefab() { GameObject prefab = ZNetScene.instance.GetPrefab(Data.PrefabName); if (Object.op_Implicit((Object)(object)prefab)) { Data.BountyData.m_critter = prefab; } } private void StartBountySpawn() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (Data.Type == QuestData.QuestType.Bounty) { if (!Object.op_Implicit((Object)(object)Data.BountyData.m_critter)) { CancelQuest(); return; } if (!Bounty.FindSpawnPoint(out var point)) { CancelQuest(); return; } Bounty.PreSpawnEffectList.Create(point, Quaternion.identity, (Transform)null, 1f, -1); Data.BountyData.m_pos = point; ((MonoBehaviour)RavenQuestsPlugin.Plugin).Invoke("SpawnBounty", 10f); } } private void StartRewardSpawn() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (Reward.Type == RewardData.RewardType.Spawn) { if (!Utility.IsNullOrWhiteSpace(Data.PrefabName)) { CancelQuest(); return; } Bounty.PreSpawnEffectList.Create(((Component)Player.m_localPlayer).transform.position, Quaternion.identity, (Transform)null, 1f, -1); ((MonoBehaviour)RavenQuestsPlugin.Plugin).Invoke("Spawn", 10f); } } public void CancelQuest() { Data.Progress = 0; m_currentQuest = null; m_savedQuestData.Remove(Name); QuestRaven.m_questData = null; QuestRaven.ToggleFly(); } private void Save() { m_savedQuestData[Name] = new PlayerQuestData { QuestName = Name, Progress = Data.Progress, Completed = m_completed, FoundPrefabs = Data.FoundPrefabs }; } public bool IsCompleted() { return Data.Progress >= Data.Amount; } public void IncreaseProgress(int amount = 1) { Data.Progress += amount; Save(); } public void IncreaseFoundPrefabs(string name) { Data.FoundPrefabs.Add(name); Data.PrefabNames.Remove(name); IncreaseProgress(); } public void SetProgress(int amount, bool save = true) { Data.Progress = amount; if (save) { Save(); } } public string GetProgressText() { return Data.Type switch { QuestData.QuestType.Runestone => Localization.instance.Localize($"<color=orange>{Data.FoundPrefabs.Count}</color>/{Data.PrefabCount} {Data.PrefabName}"), QuestData.QuestType.Trophies => Localization.instance.Localize($"<color=orange>{Data.Progress}</color>/{Data.Amount} {Data.PrefabName}"), _ => Localization.instance.Localize($"$quest_type_{Data.Type.ToString().ToLower()} <color=orange>{Data.Progress}</color>/{Data.Amount} {Data.SharedName}"), }; } public void CollectReward(Player player) { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) if (m_completed) { ((Character)player).Message((MessageType)2, "Already collected reward", 0, (Sprite)null); } else { switch (Reward.Type) { case RewardData.RewardType.Item: { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(Reward.PrefabName); ItemDrop val = default(ItemDrop); if (!Object.op_Implicit((Object)(object)itemPrefab) || !itemPrefab.TryGetComponent<ItemDrop>(ref val)) { return; } ItemData val2 = val.m_itemData.Clone(); val2.m_stack = Reward.Amount; val2.m_dropPrefab = itemPrefab; val2.m_crafterName = ((Character)player).GetHoverName(); val2.m_crafterID = player.GetPlayerID(); val2.m_variant = Reward.Variant; val2.m_quality = Reward.Quality; ((Humanoid)player).GetInventory().AddItem(val2); ((Character)player).Message((MessageType)2, $"Received {Reward.Amount} x {Reward.SharedName}", 0, (Sprite)null); break; } case RewardData.RewardType.Skill: { ((Character)player).GetSkills().RaiseSkill(Reward.SkillType, Reward.ExperienceAmount); object arg = Reward.ExperienceAmount; SkillType skillType = Reward.SkillType; ((Character)player).Message((MessageType)2, $"Received {arg} $skill_{((object)(SkillType)(ref skillType)).ToString().ToLower()} experience", 0, (Sprite)null); break; } case RewardData.RewardType.AlmanacEXP: ClassesAPI.AddEXP((int)Reward.ExperienceAmount); ((Character)player).Message((MessageType)2, $"Received {Reward.ExperienceAmount} Almanac Class Experience", 0, (Sprite)null); break; case RewardData.RewardType.Spawn: StartRewardSpawn(); break; } m_completed = true; Save(); } m_currentQuest = null; QuestRaven.ToggleFly(); } public void AddCancelText(string text) { m_cancelQueue.Enqueue(new Dialogue(text)); } public void AddCancelAction(string text, [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] Action<bool> action) { Dialogue item = new Dialogue(text, action); m_cancelQueue.Enqueue(item); } public void AddStartText(string text) { m_startQueue.Enqueue(new Dialogue(text)); } public void AddStartAction(string text, [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] Action<bool> action) { Dialogue item = new Dialogue(text, action); m_startQueue.Enqueue(item); } public void AddCompletedText(string text) { m_completedQueue.Enqueue(new Dialogue(text)); } public void AddCompletedAction(string text, [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] Action<bool> action) { Dialogue item = new Dialogue(text, action); m_completedQueue.Enqueue(item); } } [Serializable] [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] public class PlayerQuestData { public string QuestName = null; public int Progress; public bool Completed; public List<string> FoundPrefabs = new List<string>(); } private const string PlayerCustomDataKey = "RavenQuestData"; private const string PlayerCustomCurrentQuestKey = "RavenCurrentQuest"; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] public static Quest m_currentQuest; public static readonly Dictionary<int, Quest> m_questQueue = new Dictionary<int, Quest>(); public static readonly Dictionary<string, Quest> m_quests = new Dictionary<string, Quest>(); public static Dictionary<string, PlayerQuestData> m_savedQuestData = new Dictionary<string, PlayerQuestData>(); public static bool AvailableQuests() { return m_questQueue.Values.Any([<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (Quest quest) => !quest.IsCompleted()); } [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(2)] public static Quest GetQuest() { return (from pair in m_questQueue.ToList() orderby pair.Key select pair).Where([<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (KeyValuePair<int, Quest> kvp) => { KeyValuePair<int, Quest> keyValuePair2 = kvp; return !keyValuePair2.Value.IsCompleted(); }).Select([<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (KeyValuePair<int, Quest> kvp) => { KeyValuePair<int, Quest> keyValuePair = kvp; return keyValuePair.Value; }).FirstOrDefault(); } private static void SaveProgress() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (m_currentQuest != null) { Player.m_localPlayer.m_customData["RavenCurrentQuest"] = m_currentQuest.Name; } else { Player.m_localPlayer.m_customData.Remove("RavenCurrentQuest"); } if (m_savedQuestData.Count != 0) { ISerializer serializer = new SerializerBuilder().Build(); string value = serializer.Serialize(m_savedQuestData); Player.m_localPlayer.m_customData["RavenQuestData"] = value; } } } } public static class QuestCommands { [HarmonyPatch(typeof(Terminal), "Awake")] private static class Terminal_Awake_Patch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEventFailable <>9__0_0; public static ConsoleOptionsFetcher <>9__0_1; internal object <Postfix>b__0_0(ConsoleEventArgs args) { //IL_0462: Unknown result type (might be due to invalid IL or missing references) switch (args[1]) { case "help": { List<string> list = new List<string> { "reset - clears player profile of quest progress", "info - prints to console quest progress", "list - prints to console registered quests" }; foreach (string item in list) { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)item); } break; } case "reset": if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return true; } Player.m_localPlayer.m_customData.Remove("RavenQuestData"); QuestManager.m_savedQuestData.Clear(); foreach (QuestManager.Quest value2 in QuestManager.m_quests.Values) { value2.SetProgress(0); value2.Data.PrefabNames.AddRange(value2.Data.FoundPrefabs); value2.Data.FoundPrefabs.Clear(); value2.m_completed = false; } QuestManager.m_currentQuest = null; if ((Object)(object)Bounty.m_instance != (Object)null) { Bounty.m_instance.m_character.SetHealth(0f); } RavenQuestsPlugin.RavenQuestsLogger.LogDebug((object)"Cleared raven quest data from player profile"); break; case "info": foreach (QuestManager.PlayerQuestData value3 in QuestManager.m_savedQuestData.Values) { if (QuestManager.m_quests.TryGetValue(value3.QuestName, out var value)) { QuestManager.Quest.QuestData.QuestType type = value.Data.Type; QuestManager.Quest.QuestData.QuestType questType = type; if (questType == QuestManager.Quest.QuestData.QuestType.Runestone) { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Name: " + value3.QuestName)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Progress: " + $"{value3.FoundPrefabs.Count}/{value.Data.PrefabCount}")); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Completed: " + value3.Completed)); } else { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Name: " + value3.QuestName)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Progress: " + value3.Progress)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Completed: " + value3.Completed)); } } } break; case "list": foreach (QuestManager.Quest value4 in QuestManager.m_quests.Values) { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Name: " + value4.Name)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Description: " + value4.Description)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Quest: " + $"{value4.Data.Type}, {value4.Data.PrefabName}, {value4.Data.Amount}, {value4.Data.Level}")); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Reward Item: " + $"{value4.Reward.PrefabName}, {value4.Reward.Amount}, {value4.Reward.Quality}, {value4.Reward.Variant}")); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Reward Skill: " + $"{value4.Reward.SkillType}, {value4.Reward.ExperienceAmount}")); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)""); } break; } return true; } internal List<string> <Postfix>b__0_1() { return new List<string> { "help", "reset", "info", "list" }; } } private static void Postfix() { //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_002a: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEventFailable val = delegate(ConsoleEventArgs args) { //IL_0462: Unknown result type (might be due to invalid IL or missing references) switch (args[1]) { case "help": { List<string> list = new List<string> { "reset - clears player profile of quest progress", "info - prints to console quest progress", "list - prints to console registered quests" }; foreach (string item in list) { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)item); } break; } case "reset": if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return true; } Player.m_localPlayer.m_customData.Remove("RavenQuestData"); QuestManager.m_savedQuestData.Clear(); foreach (QuestManager.Quest value2 in QuestManager.m_quests.Values) { value2.SetProgress(0); value2.Data.PrefabNames.AddRange(value2.Data.FoundPrefabs); value2.Data.FoundPrefabs.Clear(); value2.m_completed = false; } QuestManager.m_currentQuest = null; if ((Object)(object)Bounty.m_instance != (Object)null) { Bounty.m_instance.m_character.SetHealth(0f); } RavenQuestsPlugin.RavenQuestsLogger.LogDebug((object)"Cleared raven quest data from player profile"); break; case "info": foreach (QuestManager.PlayerQuestData value3 in QuestManager.m_savedQuestData.Values) { if (QuestManager.m_quests.TryGetValue(value3.QuestName, out var value)) { QuestManager.Quest.QuestData.QuestType type = value.Data.Type; QuestManager.Quest.QuestData.QuestType questType = type; if (questType == QuestManager.Quest.QuestData.QuestType.Runestone) { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Name: " + value3.QuestName)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Progress: " + $"{value3.FoundPrefabs.Count}/{value.Data.PrefabCount}")); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Completed: " + value3.Completed)); } else { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Name: " + value3.QuestName)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Progress: " + value3.Progress)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Completed: " + value3.Completed)); } } } break; case "list": foreach (QuestManager.Quest value4 in QuestManager.m_quests.Values) { RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Name: " + value4.Name)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Description: " + value4.Description)); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Quest: " + $"{value4.Data.Type}, {value4.Data.PrefabName}, {value4.Data.Amount}, {value4.Data.Level}")); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Reward Item: " + $"{value4.Reward.PrefabName}, {value4.Reward.Amount}, {value4.Reward.Quality}, {value4.Reward.Variant}")); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)("Reward Skill: " + $"{value4.Reward.SkillType}, {value4.Reward.ExperienceAmount}")); RavenQuestsPlugin.RavenQuestsLogger.LogInfo((object)""); } break; } return true; }; <>c.<>9__0_0 = val; obj = (object)val; } object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleOptionsFetcher val2 = () => new List<string> { "help", "reset", "info", "list" }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } ConsoleCommand val3 = new ConsoleCommand("ravenquest", "use help to discover available commands", (ConsoleEventFailable)obj, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false); } } } public static class RandomTalk { [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(1)] public static readonly List<string> m_randomTalk = new List<string> { "Kaw! Got any snacks?", "Odin told me to keep an eye on you... literally!", "Ever seen a bird this stylish? Kaw!", "Flying around is exhausting. Got a place to sit?", "Kaw! I saw you trip back there. Didn’t think I noticed, huh?", "Rumor has it you’re a hero. Don’t let it go to your head!", "Need some advice? Kaw! Too bad, I got none.", "Kaw! Kaw! Does this echo? …Anyone?", "I could fly all day... but I’d rather watch you.", "You’d be lost without me. Admit it!", "Ever think about taking a bird break? Kaw!", "Odin says he’s watching you. So am I... closer!", "Kaw! This is my good side. No, wait, this one!", "Ever wonder why the sky is blue? I don’t. Kaw!", "Kaw! Do you talk to animals often, or am I special?", "You call that a sword? Kaw!", "Kaw! Wanna trade? I got... feathers.", "Hope you don’t mind the mess. Odin’s messy too!", "Kaw! I saw what you did... Odin’s impressed!" }; } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] public static class UI { [HarmonyPatch(typeof(Hud), "Awake")] [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] private static class Hud_Awake_Patch { private static void Postfix(Hud __instance) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)__instance)) { font = GetFont("Norsebold"); m_root = CreateRoot(__instance); m_title = CreateTextElement(m_root.transform, 16, (TextAnchor)3); m_title.text = ""; m_description = CreateTextElement(m_root.transform, 14, (TextAnchor)0); m_description.text = ""; m_text = CreateTextElement(m_root.transform, 14, (TextAnchor)0); m_text.text = ""; m_root.SetActive(false); m_root.transform.localScale = Vector3.one * RavenQuestsPlugin._UIScale.Value; RavenQuestsPlugin._UIScale.SettingChanged += [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (object _, EventArgs _) => { //IL_000b: 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) m_root.transform.localScale = Vector3.one * RavenQuestsPlugin._UIScale.Value; }; } } private static GameObject CreateRoot(Hud __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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) GameObject val = new GameObject("QuestHud"); RectTransform rect = val.AddComponent<RectTransform>(); ((Transform)rect).SetParent(((Component)__instance).transform); ((Transform)rect).localPosition = Vector2.op_Implicit(RavenQuestsPlugin._hudPosition.Value); RavenQuestsPlugin._hudPosition.SettingChanged += [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (object _, EventArgs _) => { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((Transform)rect).localPosition = Vector2.op_Implicit(RavenQuestsPlugin._hudPosition.Value); }; rect.sizeDelta = new Vector2(200f, 100f); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.5f); VerticalLayoutGroup val3 = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true; ((LayoutGroup)val3).padding.left = 5; ((LayoutGroup)val3).padding.top = 5; ((LayoutGroup)val3).padding.bottom = 5; ((LayoutGroup)val3).padding.right = 5; return val; } private static Text CreateTextElement(Transform parent, int fontSize, TextAnchor alignment) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("element"); RectTransform val2 = val.AddComponent<RectTransform>(); ((Transform)val2).SetParent(parent); Text val3 = val.AddComponent<Text>(); val3.alignment = alignment; val3.font = font; val3.fontSize = fontSize; return val3; } } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] private static Font font; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] private static GameObject m_root; private static Text m_title; private static Text m_description; private static Text m_text; public static void Update() { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)Hud.instance) || m_root == null) { return; } if (QuestManager.m_currentQuest == null || ((Character)Player.m_localPlayer).IsTeleporting() || ((Character)Player.m_localPlayer).IsDead() || Player.m_localPlayer.IsSleeping() || Game.instance.IsShuttingDown() || ((Component)Hud.instance.m_loadingScreen).gameObject.activeInHierarchy || Minimap.IsOpen() || Hud.instance.m_userHidden || ((Character)Player.m_localPlayer).InCutscene()) { if (m_root.activeInHierarchy) { m_root.SetActive(false); } return; } if (!m_root.activeInHierarchy) { m_root.SetActive(true); } m_title.text = "<color=orange>" + QuestManager.m_currentQuest.Name + "</color>"; m_description.text = QuestManager.m_currentQuest.Description; m_text.text = QuestManager.m_currentQuest.GetProgressText(); } [return: <03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] private static Font GetFont(string name) { Font[] source = Resources.FindObjectsOfTypeAll<Font>(); return ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)([<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] (Font x) => ((Object)x).name == name)); } } } namespace RavenQuests.Solution.Tracking { public static class Collect { [HarmonyPatch(typeof(Player), "Awake")] private static class Player_Awake_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(Player __instance) { if (!Object.op_Implicit((Object)(object)__instance) != Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } Inventory inventory = ((Humanoid)__instance).GetInventory(); inventory.m_onChanged = (Action)Delegate.Combine(inventory.m_onChanged, (Action)delegate { QuestManager.Quest currentQuest = QuestManager.m_currentQuest; bool flag; if (currentQuest != null) { QuestManager.Quest.QuestData data = currentQuest.Data; if (data != null) { QuestManager.Quest.QuestData.QuestType type = data.Type; if ((uint)(type - 2) <= 1u) { flag = true; goto IL_002b; } } } flag = false; goto IL_002b; IL_002b: if (flag) { switch (currentQuest.Data.Type) { case QuestManager.Quest.QuestData.QuestType.Collect: { int amount = ((Humanoid)__instance).GetInventory().CountItems(QuestManager.m_currentQuest.Data.SharedName, -1, true); currentQuest.SetProgress(amount); break; } case QuestManager.Quest.QuestData.QuestType.CollectItems: { int num = 0; foreach (string sharedName in currentQuest.Data.SharedNames) { if (__instance.IsKnownMaterial(sharedName)) { num++; } } currentQuest.SetProgress(num); break; } } } }); } } } public static class Craft { [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] private static class InventoryGUI_DoCrafting_Patch { private static void Prefix() { m_isCrafting = true; } private static void Postfix() { m_isCrafting = false; } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(string), typeof(int), typeof(int), typeof(int), typeof(long), typeof(string), typeof(Vector2i), typeof(bool) })] private static class Inventory_AddItem_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(2)] private static void Postfix(ItemData __result) { if (m_isCrafting && __result != null && QuestManager.m_currentQuest != null && QuestManager.m_currentQuest.IsCorrectType(QuestManager.Quest.QuestData.QuestType.Craft) && QuestManager.m_currentQuest.IsMatchingPrefab(__result.m_shared.m_name, sharedName: true)) { QuestManager.m_currentQuest.IncreaseProgress(); } } } private static bool m_isCrafting; } public static class Destruct { [HarmonyPatch(typeof(Destructible), "Destroy")] private static class Destructible_Destroy_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Prefix(Destructible __instance, [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] HitData hit) { QuestManager.Quest currentQuest = QuestManager.m_currentQuest; if (currentQuest != null) { QuestManager.Quest.QuestData data = currentQuest.Data; if (data != null && data.Type == QuestManager.Quest.QuestData.QuestType.Destructible && hit != null && !currentQuest.IsMatchingPrefab(((Object)__instance).name.Replace("(Clone)", string.Empty))) { currentQuest.IncreaseProgress(); } } } } } public static class Farm { [HarmonyPatch(typeof(Plant), "Awake")] private static class Plant_Awake_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(Plant __instance) { if (Object.op_Implicit((Object)(object)__instance) && __instance.m_nview.IsValid()) { __instance.m_nview.Register<string, long>("RPC_CheckQuest", (Action<long, string, long>)RPC_CheckQuest); } } } [HarmonyPatch(typeof(Plant), "Grow")] private static class Plant_Grow_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Prefix(Plant __instance) { if (__instance.m_nview.IsOwner()) { string text = ((Object)__instance).name.Replace("(Clone)", string.Empty); long @long = __instance.m_nview.GetZDO().GetLong(ZDOVars.s_creator, 0L); __instance.m_nview.InvokeRPC("RPC_CheckQuest", new object[2] { text, @long }); } } } [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void RPC_CheckQuest(long sender, string prefabName, long uid) { if (QuestManager.m_currentQuest != null && QuestManager.m_currentQuest.IsCorrectType(QuestManager.Quest.QuestData.QuestType.Farm) && QuestManager.m_currentQuest.IsMatchingPrefab(prefabName) && uid == Player.m_localPlayer.GetPlayerID()) { QuestManager.m_currentQuest.IncreaseProgress(); } } } public static class Harvest { [HarmonyPatch(typeof(Pickable), "Interact")] private static class Pickable_Interact_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(Pickable __instance, ref bool __result) { if (__result && QuestManager.m_currentQuest != null && QuestManager.m_currentQuest.IsCorrectType(QuestManager.Quest.QuestData.QuestType.Harvest)) { string name = ((Object)__instance).name.Replace("(Clone)", string.Empty); if (QuestManager.m_currentQuest.IsMatchingPrefab(name)) { QuestManager.m_currentQuest.IncreaseProgress(); } } } } } public static class Kills { [HarmonyPatch(typeof(Character), "Awake")] private static class Character_Awake_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(Character __instance) { Character obj = __instance; obj.m_onDeath = (Action)Delegate.Combine(obj.m_onDeath, (Action)delegate { if (QuestManager.m_currentQuest != null && QuestManager.m_currentQuest.IsCorrectType(QuestManager.Quest.QuestData.QuestType.Kill) && QuestManager.m_currentQuest.IsMatchingPrefab(((Object)__instance).name.Replace("(Clone)", string.Empty)) && QuestManager.m_currentQuest.Data.Level <= __instance.m_level) { QuestManager.m_currentQuest.IncreaseProgress(); } }); } } } public static class LocationFind { private static float m_locationFindTimer; public static void UpdateLocationFind(float dt) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) QuestManager.Quest currentQuest = QuestManager.m_currentQuest; if (currentQuest == null) { return; } QuestManager.Quest.QuestData data = currentQuest.Data; if (data == null || data.Type != QuestManager.Quest.QuestData.QuestType.Location) { return; } m_locationFindTimer += dt; if (m_locationFindTimer < 120f) { return; } m_locationFindTimer = 0f; Location location = Location.GetLocation(((Component)Player.m_localPlayer).transform.position, false); if (location != null) { string text = ((Object)location).name.Replace("(Clone)", string.Empty); if (!(text != currentQuest.Data.PrefabName) && !currentQuest.IsCompleted()) { currentQuest.IncreaseProgress(); } } else if (currentQuest.IsCompleted()) { currentQuest.SetProgress(0); } } } public static class RuneFind { [HarmonyPatch(typeof(RuneStone), "Interact")] private static class RuneStone_Interact_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(RuneStone __instance) { if (QuestManager.m_currentQuest != null && QuestManager.m_currentQuest.IsCorrectType(QuestManager.Quest.QuestData.QuestType.Runestone)) { string normalizedName = Helpers.GetNormalizedName(((Object)__instance).name); if (QuestManager.m_currentQuest.IsMatchingRunestone(normalizedName)) { QuestManager.m_currentQuest.IncreaseFoundPrefabs(normalizedName); } } } } } public static class TextCollect { [HarmonyPatch(typeof(Player), "AddKnownText")] private static class Player_AddKnownText_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(Player __instance) { QuestManager.Quest quest = QuestManager.m_currentQuest; if (quest == null) { return; } QuestManager.Quest.QuestData data = quest.Data; if (data != null && data.Type == QuestManager.Quest.QuestData.QuestType.Text) { int amount = __instance.m_knownTexts.Count((KeyValuePair<string, string> kvp) => quest.Data.PrefabNames.Contains(kvp.Key)); quest.SetProgress(amount); } } } } public static class TrophyCollect { [HarmonyPatch(typeof(Player), "AddTrophy")] private static class Player_AddTrophy_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(Player __instance) { QuestManager.Quest quest = QuestManager.m_currentQuest; if (quest == null) { return; } QuestManager.Quest.QuestData data = quest.Data; if (data != null && data.Type == QuestManager.Quest.QuestData.QuestType.Trophies) { int amount = __instance.m_trophies.Count((string dropPrefabName) => quest.Data.PrefabNames.Contains(dropPrefabName)); quest.SetProgress(amount); } } } } } namespace RavenQuests.Solution.Behaviors { [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] public class Bounty : MonoBehaviour { [HarmonyPatch(typeof(ZNetScene), "Awake")] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] private static class ZNetScene_GetBountyAssets { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(ZNetScene __instance) { if (Object.op_Implicit((Object)(object)__instance)) { GetEffects(__instance); } } } [Serializable] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(0)] public class BountyModifiers { [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] public GameObject m_critter; public Vector3 m_pos; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(1)] public string m_name = ""; public float m_health = 1f; public float m_scale = 1f; public int m_level = 1; } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] public static Bounty m_instance; public static EffectList PreSpawnEffectList; public static EffectList DoneSpawnEffectList; public Character m_character = null; public ZNetView m_nview = null; public void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); m_character = ((Component)this).GetComponent<Character>(); Character character = m_character; character.m_onDeath = (Action)Delegate.Combine(character.m_onDeath, new Action(OnDeath)); m_nview.GetZDO().Persistent = false; m_nview.Register<bool>("RPC_SetBoss", (Action<long, bool>)RPC_SetBoss); m_nview.Register<float>("RPC_SetScale", (Action<long, float>)RPC_SetScale); m_nview.Register<string>("RPC_SetFaction", (Action<long, string>)RPC_SetFaction); m_nview.Register<string>("RPC_SetSharedName", (Action<long, string>)RPC_SetSharedName); m_nview.Register<bool>("RPC_SetTameable", (Action<long, bool>)RPC_SetTameable); m_instance = this; } public void OnDestroy() { if (m_character.m_health > 0f) { QuestManager.Quest currentQuest = QuestManager.m_currentQuest; if (currentQuest != null) { QuestManager.Quest.QuestData data = currentQuest.Data; if (data != null && data.Type == QuestManager.Quest.QuestData.QuestType.Bounty) { if ((Object)(object)QuestManager.m_currentQuest.m_currentBounty != (Object)(object)this) { return; } QuestManager.m_currentQuest.m_currentBounty = null; QuestManager.m_currentQuest.CancelQuest(); ((Character)Player.m_localPlayer).Message((MessageType)2, "Bounty Escaped", 0, (Sprite)null); } } } m_instance = null; } public void OnDeath() { m_instance = null; if (QuestManager.m_currentQuest != null && QuestManager.m_currentQuest.Data.Type == QuestManager.Quest.QuestData.QuestType.Bounty) { QuestManager.m_currentQuest.IncreaseProgress(); QuestManager.m_currentQuest.m_currentBounty = null; } } private void RPC_SetFaction(long sender, string faction) { //IL_0019: 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 (Enum.TryParse<Faction>(faction, ignoreCase: true, out Faction result)) { m_character.m_faction = result; } } private void RPC_SetBoss(long sender, bool enable) { m_character.m_boss = enable; } private void RPC_SetScale(long sender, float scale) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localScale = new Vector3(scale, scale, scale); } private void RPC_SetSharedName(long sender, string sharedName) { m_character.m_name = sharedName; } private void RPC_SetTameable(long sender, bool enable) { Tameable val = default(Tameable); if (!enable && ((Component)m_character).TryGetComponent<Tameable>(ref val)) { Object.Destroy((Object)(object)val); } } public void ApplyModifiers(BountyModifiers data) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) m_nview.InvokeRPC("RPC_SetBoss", new object[1] { true }); m_nview.InvokeRPC("RPC_SetFaction", new object[1] { "Boss" }); m_nview.InvokeRPC("RPC_SetSharedName", new object[1] { data.m_name }); m_nview.InvokeRPC("RPC_SetTameable", new object[1] { false }); m_nview.InvokeRPC("RPC_SetScale", new object[1] { data.m_scale }); m_character.m_faction = (Faction)8; m_character.m_boss = true; m_character.m_name = data.m_name; ((Component)this).transform.localScale = new Vector3(data.m_scale, data.m_scale, data.m_scale); m_character.SetLevel(data.m_level); m_character.SetMaxHealth(data.m_health); m_character.m_baseAI.SetAlerted(true); } public static bool FindSpawnPoint(out Vector3 point) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)Player.m_localPlayer).transform.position; Vector3 forward = ((Component)Utils.GetMainCamera()).transform.forward; forward.y = 0f; Vector3 val = forward; ((Vector3)(ref val)).Normalize(); point = new Vector3(0f, -999f, 0f); bool result = false; float num = default(float); Vector3 val4 = default(Vector3); GameObject val5 = default(GameObject); for (int i = 0; i < 20; i++) { Vector3 val2 = Quaternion.Euler(0f, (float)Random.Range(-30, 30), 0f) * val; Vector3 val3 = position + val2 * Random.Range(15f, 20f); if (ZoneSystem.instance.GetSolidHeight(val3, ref num, ref val4, ref val5) && (double)num > 30.0 && (double)num > (double)point.y && (double)num < 2000.0 && (double)val4.y > 0.5 && (double)Mathf.Abs(num - position.y) < 2.0) { val3.y = num; point = val3; result = true; } } return result; } private static void GetEffects(ZNetScene instance) { GetPreSpawnEffects(instance); GetSpawnEffects(instance); } private static void GetPreSpawnEffects(ZNetScene instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005d: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown GameObject prefab = instance.GetPrefab("vfx_prespawn"); GameObject prefab2 = instance.GetPrefab("sfx_prespawn"); if (Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)prefab2)) { EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = prefab, m_enabled = true, m_variant = -1 }, new EffectData { m_prefab = prefab2, m_enabled = true, m_variant = -1 } }; PreSpawnEffectList = val; } } private static void GetSpawnEffects(ZNetScene instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005d: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown GameObject prefab = instance.GetPrefab("vfx_spawn"); GameObject prefab2 = instance.GetPrefab("sfx_spawn"); if (Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)prefab2)) { EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = prefab, m_enabled = true, m_variant = -1 }, new EffectData { m_prefab = prefab2, m_enabled = true, m_variant = -1 } }; DoneSpawnEffectList = val; } } } public static class OnDeathDrops { [HarmonyPatch(typeof(Character), "Awake")] private static class Character_Awake_Patch { [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] private static void Postfix(Character __instance) { string text = ((Object)__instance).name.Replace("(Clone)", string.Empty); if (!text.StartsWith("RS_Skeleton")) { return; } QuestManager.Quest quest = QuestManager.m_currentQuest; if (quest == null) { return; } QuestManager.Quest.QuestData data = quest.Data; if (data == null || data.Type != QuestManager.Quest.QuestData.QuestType.CollectItems || Random.value > 0.3f) { return; } Character obj = __instance; obj.m_onDeath = (Action)Delegate.Combine(obj.m_onDeath, (Action)delegate { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) ItemDrop val = default(ItemDrop); foreach (KeyValuePair<string, string> name in quest.Data.Names) { if (!Player.m_localPlayer.m_knownMaterial.Contains(name.Value)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(name.Key); if (itemPrefab != null && itemPrefab.TryGetComponent<ItemDrop>(ref val)) { ItemDrop.DropItem(val.m_itemData, 1, ((Component)__instance).transform.position, Quaternion.identity); break; } } } }); } } } [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(0)] [<21190bcf-0860-4029-83e9-c85e99fc529c>NullableContext(1)] public class QuestRaven : MonoBehaviour, Hoverable, Interactable, IDestructible { [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] public static QuestManager.Quest m_questData; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] private static QuestRaven m_instance; public bool m_active; public string m_name = "Översyn"; public GameObject m_visual = null; public GameObject m_exclamation = null; public float m_idleEffectIntervalMin = 30f; public float m_idleEffectIntervalMax = 60f; public float m_spawnDistance = 20f; public float m_enemyCheckDistance = 4f; public float m_rotateSpeed = 70f; public float m_minRotationAngle = 30f; public float m_longDialogVisibleTime = 60f; public float m_textOffset = 1.4f; public float m_textCullDistance = 20f; public EffectList m_idleEffect = new EffectList(); public EffectList m_deSpawnEffect = new EffectList(); public Animator m_animator = null; [<03f138a6-931d-4acc-a711-e8e94d3b7f2b>Nullable(2)] private QuestManager.Quest.Dialogue m_currentDialogue; public void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = new Vector3(0f, 100000f, 0f); m_instance = this; m_animator = m_visual.GetComponentInChildren<Animator>(); ((MonoBehaviour)this).InvokeRepeating("IdleEffect", Random.Range(m_idleEffectIntervalMin, m_idleEffectIntervalMax), Random.Range(m_idleEffectIntervalMin, m_idleEffectIntervalMax)); ((MonoBehaviour)this).InvokeRepeating("CheckSpawn", 1f, 1f); } public void OnDestroy() { if (!((Object)(object)m_instance != (Object)(object)this)) { m_instance = null; } } public string GetHoverText() { if (!IsSpawned()) { return ""; } if (m_questData == null && QuestManager.m_currentQuest == null) { return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $raven_interact"); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(m_name); if (QuestManager.m_currentQuest != null) { if (QuestManager.m_currentQuest.IsCompleted()) { if (QuestManager.m_currentQuest.m_completedQueue.Count == 0) { return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $raven_interact"); } QuestManager.Quest.Dialogue dialogue = QuestManager.m_currentQuest.m_completedQueue.Peek(); if (dialogue.m_action != null) { stringBuilder.Append("\n[<color=yellow><b>$KEY_Use</b></color>] $raven_collect"); stringBuilder.Append("\n[<color=yellow><b>L.Shift + $KEY_Use</b></color>] $raven_refuse"); } else { stringBuilder.Append("\n[<color=yellow><b>$KEY_Use</b></color>] $raven_continue"); } } else { if (QuestManager.m_currentQuest.m_cancelQueue.Count == 0) { return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $raven_interact"); } QuestManager.Quest.Dialogue dialogue2 = QuestManager.m_currentQuest.m_cancelQueue.Peek(); if (dialogue2.m_action != null) { stringBuilder.Append("\n[<color=yellow><b>$KEY_Use</b></color>] $raven_keep"); stringBuilder.Append("\n[<color=yellow><b>L.Shift + $KEY_Use</b></color>] $raven_cancel"); } else { stringBuilder.Append("\n[<color=yellow><b>$KEY_Use</b></color>] $raven_continue"); } } } else { if (m_questData == null) { return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $raven_interact"); } if (m_questData.m_startQueue.Count == 0) { return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $raven_interact"); } if (m_questData.m_startQueue.Peek()?.m_action != null) { stringBuilder.Append("\n[<color=yellow><b>$KEY_Use</b></color>] $raven_accept"); stringBuilder.Append("\n[<color=yellow><b>L.Shift + $KEY_Use</b></color>] $raven_decline"); } else { stringBuilder.Append("\n[<color=yellow><b>$KEY_Use</b></color>] $raven_continue"); } } return Localization.instance.Localize(stringBuilder.ToString()); } public string GetHoverName() { return Localization.instance.Localize(m_name); } public bool Interact(Humanoid character, bool hold, bool alt) { if (hold) { return false; } if (Chat.instance.IsDialogVisible(((Component)this).gameObject)) { Chat.instance.ClearNpcText(((Component)this).gameObject); } Talk(alt); return false; } public void Talk(bool alt) { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } if (QuestManager.m_currentQuest == null) { if (m_questData == null) { m_questData = QuestManager.GetQuest(); } if (m_questData == null) { RandomTalk(); } else if (m_questData.m_startQueue.Count != 0) { QuestManager.Quest.Dialogue dialogue = m_questData.m_startQueue.Dequeue(); Say(dialogue); m_questData.m_startQueue.Enqueue(dialogue); dialogue.m_action?.Invoke(alt); } } else if (QuestManager.m_currentQuest.IsCompleted()) { if (QuestManager.m_currentQuest.m_completedQueue.Count != 0) { QuestManager.Quest.Dialogue dialogue2 = QuestManager.m_currentQuest.m_completedQueue.Dequeue(); Say(dialogue2); QuestManager.m_currentQuest.m_completedQueue.Enqueue(dialogue2); if (!alt) { dialogue2.m_action?.Invoke(alt); } } } else if (QuestManager.m_currentQuest.m_cancelQueue.Count != 0) { QuestManager.Quest.Dialogue dialogue3 = QuestManager.m_currentQuest.m_cancelQueue.Dequeue(); Say(dialogue3); QuestManager.m_currentQuest.m_cancelQueue.Enqueue(dialogue3); dialogue3.m_action?.Invoke(alt); } } public void RandomTalk() { string text = RavenQuests.Solution.RandomTalk.m_randomTalk[Random.Range(0, RavenQuests.Solution.RandomTalk.m_randomTalk.Count)]; Say(new QuestManager.Quest.Dialogue(text)); } public void Say(QuestManager.Quest.Dialogue dialogue) { //IL_000c: 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) Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up * m_textOffset, m_textCullDistance, m_longDialogVisibleTime, m_name, dialogue.m_text, true); m_animator.SetTrigger("talk"); m_currentDialogue = dialogue; } public bool UseItem(Humanoid user, ItemData item) { return false; } public void IdleEffect() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (IsSpawned()) { Transform transform = ((Component)this).transform; m_idleEffect.Create(transform.position, transform.rotation, (Transform)null, 1f, -1); ((MonoBehaviour)this).CancelInvoke("IdleEffect"); ((MonoBehaviour)this).InvokeRepeating("IdleEffect", Random.Range(m_idleEffectIntervalMin, m_idleEffectIntervalMax), Random.Range(m_idleEffectIntervalMin, m_idleEffectIntervalMax)); } } public void Update() { if (!IsAway() && !IsFlying() && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { UpdateLookTowardsPlayer(); } if (IsSpawned()) { GameObject exclamation = m_exclamation; QuestManager.Quest currentQuest = QuestManager.m_currentQuest; bool flag = ((currentQuest == null || currentQuest.m_completed) ? true : false); exclamation.SetActive(flag && QuestManager.AvailableQuests()); } else { m_exclamation.SetActive(false); } } private void UpdateLookTowardsPlayer() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown resu