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.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CreatureManager; using HarmonyLib; using ItemManager; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using SoftReferenceableAssets; using TMPro; using Transmog.Source; using TransmogAPI; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; 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("Transmog")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Transmog")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("0.0.1")] [assembly: AssemblyCompany("marlthon")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<332850e2-c1dc-4859-b644-01b205e454bc>Embedded] internal sealed class <332850e2-c1dc-4859-b644-01b205e454bc>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<332850e2-c1dc-4859-b644-01b205e454bc>Embedded] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<332850e2-c1dc-4859-b644-01b205e454bc>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace PieceManager { [NullableContext(1)] [Nullable(0)] [PublicAPI] public static class MaterialReplacer { [NullableContext(0)] public enum ShaderType { PieceShader, VegetationShader, RockShader, RugShader, GrassShader, CustomCreature, UseUnityShader } private static readonly Dictionary ObjectToSwap; private static readonly Dictionary OriginalMaterials; private static readonly Dictionary ObjectsForShaderReplace; private static readonly HashSet CachedShaders; private static bool hasRun; static MaterialReplacer() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown CachedShaders = new HashSet(); hasRun = false; OriginalMaterials = new Dictionary(); ObjectToSwap = new Dictionary(); ObjectsForShaderReplace = new Dictionary(); Harmony val = new Harmony("org.bepinex.helpers.PieceManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZoneSystem), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MaterialReplacer), "ReplaceAllMaterialsWithOriginal", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void RegisterGameObjectForShaderSwap(GameObject go, ShaderType type) { if (!ObjectsForShaderReplace.ContainsKey(go)) { ObjectsForShaderReplace.Add(go, type); } } public static void RegisterGameObjectForMatSwap(GameObject go, bool isJotunnMock = false) { if (!ObjectToSwap.ContainsKey(go)) { ObjectToSwap.Add(go, isJotunnMock); } } private static void GetAllMaterials() { Material[] array = Resources.FindObjectsOfTypeAll(); foreach (Material val in array) { OriginalMaterials[((Object)val).name] = val; } } [HarmonyPriority(700)] private static void ReplaceAllMaterialsWithOriginal() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType == 4 || hasRun) { return; } if (OriginalMaterials.Count == 0) { GetAllMaterials(); } foreach (KeyValuePair item in ObjectToSwap) { GameObject key = item.Key; bool value = item.Value; ProcessGameObjectMaterials(key, value); } AssetBundle[] array = Resources.FindObjectsOfTypeAll(); AssetBundle[] array2 = array; foreach (AssetBundle val in array2) { IEnumerable enumerable3; try { IEnumerable enumerable2; if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val)) { IEnumerable enumerable = val.LoadAllAssets(); enumerable2 = enumerable; } else { enumerable2 = from shader in ((IEnumerable)val.GetAllAssetNames()).Select((Func)val.LoadAsset) where (Object)(object)shader != (Object)null select shader; } enumerable3 = enumerable2; } catch (Exception) { continue; } if (enumerable3 == null) { continue; } foreach (Shader item2 in enumerable3) { CachedShaders.Add(item2); } } foreach (KeyValuePair item3 in ObjectsForShaderReplace) { GameObject key2 = item3.Key; ShaderType value2 = item3.Value; ProcessGameObjectShaders(key2, value2); } hasRun = true; } private static void ProcessGameObjectMaterials(GameObject go, bool isJotunnMock) { Renderer[] componentsInChildren = go.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials.Select([NullableContext(0)] (Material material) => ReplaceMaterial(material, isJotunnMock)).ToArray(); val.sharedMaterials = sharedMaterials; } } private static Material ReplaceMaterial(Material originalMaterial, bool isJotunnMock) { string text = (isJotunnMock ? "JVLmock_" : "_REPLACE_"); if (!((Object)originalMaterial).name.StartsWith(text, StringComparison.Ordinal)) { return originalMaterial; } string text2 = ((Object)originalMaterial).name.Replace(" (Instance)", "").Replace(text, ""); if (OriginalMaterials.TryGetValue(text2, out var value)) { return value; } Debug.LogWarning((object)("No suitable material found to replace: " + text2)); return originalMaterial; } private static void ProcessGameObjectShaders(GameObject go, ShaderType shaderType) { Renderer[] componentsInChildren = go.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null) { val2.shader = GetShaderForType(val2.shader, shaderType, ((Object)val2.shader).name); } } } } private static Shader GetShaderForType(Shader orig, ShaderType shaderType, string originalShaderName) { return (Shader)(shaderType switch { ShaderType.PieceShader => FindShaderWithName(orig, "Custom/Piece"), ShaderType.VegetationShader => FindShaderWithName(orig, "Custom/Vegetation"), ShaderType.RockShader => FindShaderWithName(orig, "Custom/StaticRock"), ShaderType.RugShader => FindShaderWithName(orig, "Custom/Rug"), ShaderType.GrassShader => FindShaderWithName(orig, "Custom/Grass"), ShaderType.CustomCreature => FindShaderWithName(orig, "Custom/Creature"), ShaderType.UseUnityShader => FindShaderWithName(orig, ((Object)(object)FindShaderWithName(orig, originalShaderName) != (Object)null) ? originalShaderName : "ToonDeferredShading2017"), _ => FindShaderWithName(orig, "Standard"), }); } public static Shader FindShaderWithName(Shader origShader, string name) { foreach (Shader cachedShader in CachedShaders) { if (((Object)cachedShader).name == name) { return cachedShader; } } return origShader; } } [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 } [Nullable(0)] [NullableContext(1)] public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [Nullable(0)] [NullableContext(1)] [PublicAPI] public class ExtensionList { public readonly List ExtensionStations = new List(); 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; [Nullable(2)] public string custom; } [PublicAPI] [Nullable(0)] [NullableContext(1)] public class CraftingStationList { public readonly List Stations = new List(); 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; [Nullable(2)] public string custom; } [PublicAPI] public enum BuildPieceCategory { Misc = 0, Crafting = 1, BuildingWorkbench = 2, BuildingStonecutter = 3, Furniture = 4, All = 100, Custom = 99 } [PublicAPI] [Nullable(0)] [NullableContext(1)] public class RequiredResourcesList { public readonly List Requirements = new List(); public void Add(string item, int amount, bool recover) { Requirements.Add(new Requirement { itemName = item, amount = amount, recover = recover }); } } public struct Requirement { [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; } [NullableContext(1)] [Nullable(0)] [PublicAPI] 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] [Nullable(0)] [NullableContext(1)] public class PieceTool { public readonly HashSet Tools = new HashSet(); public void Add(string tool) { Tools.Add(tool); } } [Nullable(0)] [PublicAPI] [NullableContext(1)] public class BuildPiece { [Nullable(0)] internal class PieceConfig { public ConfigEntry craft = null; public ConfigEntry category = null; public ConfigEntry customCategory = null; public ConfigEntry tools = null; public ConfigEntry extensionTable = null; public ConfigEntry customExtentionTable = null; public ConfigEntry maxStationDistance = null; public ConfigEntry table = null; public ConfigEntry customTable = null; } [NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] [Nullable(2)] public string Category; [Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action CustomDrawer; } [Nullable(0)] private class SerializedRequirements { public readonly List Reqs; public SerializedRequirements(List reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) { Reqs = reqs.Split(new char[1] { ',' }).Select([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([NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}:{r.recover}")); } [return: Nullable(2)] public static ItemDrop fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent() : 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 dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func)([NullableContext(0)] (Requirement r) => r.itemName), (Func)([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([NullableContext(0)] (Requirement v) => v != null).ToArray(); [NullableContext(2)] static ItemDrop ResItem(Requirement r) { return fetchByName(ObjectDB.instance, r.itemName); } } } internal static readonly List registeredPieces = new List(); private static readonly Dictionary pieceMap = new Dictionary(); internal static Dictionary pieceConfigs = new Dictionary(); internal List Conversions = new List(); internal List conversions = new List(); [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; [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; [Nullable(2)] [Description("Specifies a config entry which toggles whether a recipe is active.")] public ConfigEntryBase RecipeIsActive = null; [Nullable(2)] private LocalizeKey _name; [Nullable(2)] private LocalizeKey _description; internal string[] activeTools = null; [Nullable(2)] private static object configManager; [Nullable(2)] private static Localization _english; [Nullable(2)] internal static BaseUnityPlugin _plugin = null; private static bool hasConfigSync = true; [Nullable(2)] private static object _configSync; public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } Piece component = Prefab.GetComponent(); 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(); 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 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([NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); return _plugin; } } [Nullable(2)] private static object configSync { [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 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); } 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([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().m_category = (PieceCategory)registeredPiece.Category.Category; } else { registeredPiece.Prefab.GetComponent().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(); 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 += [NullableContext(0)] (object _, EventArgs _) => { Inventory[] source = (from c in Player.s_players.Select([NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsByType((FindObjectsSortMode)0) select c.GetInventory()) where c != null select c).ToArray(); Dictionary> dictionary = (from kv in (from i in (from p in ObjectDB.instance.m_items select p.GetComponent() into c where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent()) select c).Concat(ItemDrop.s_instances) select new KeyValuePair(Utils.GetPrefabName(((Component)i).gameObject), i.m_itemData)).Concat(from i in source.SelectMany([NullableContext(0)] (Inventory i) => i.GetAllItems()) select new KeyValuePair(((Object)i.m_dropPrefab).name, i)) where Object.op_Implicit((Object)(object)kv.Value.m_shared.m_buildPieces) group kv by kv.Key).ToDictionary([NullableContext(0)] (IGrouping> g) => g.Key, [NullableContext(0)] (IGrouping> g) => g.Select([NullableContext(0)] (KeyValuePair 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 hideWhenNoneAttributes2; if (piece.Extension.ExtensionStations.Count > 0) { pieceExtensionComp = piece.Prefab.GetOrAddComponent(); 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(); 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 hideWhenNoneAttributes; if (piece.Crafting.Stations.Count > 0) { hideWhenNoneAttributes = new List(); 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 += [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.FindObjectsByType((FindObjectsSortMode)0); 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 += [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 += [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() : null); } else { pieceExtensionComp.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.extensionTable.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } 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() : null); break; } default: piecePrefab2.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.table.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); 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 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(); ConfigChanged(null, null); ((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged)); } registeredPiece3.InitializeNewRegisteredPiece(registeredPiece3); [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()); } } } 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(); 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.FindObjectsByType((FindObjectsSortMode)0); 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().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 > 1) ? extensionStation.Table : value.extensionTable.Value) { case CraftingTable.None: registeredPiece.Prefab.GetComponent().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().m_craftingStation = prefab.GetComponent(); } 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().m_craftingStation = null; } else { registeredPiece.Prefab.GetComponent().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Extension.ExtensionStations.Count > 1) ? extensionStation.Table : value.extensionTable.Value).ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } break; } } foreach (CraftingStationConfig station in registeredPiece.Crafting.Stations) { switch ((value == null || registeredPiece.Crafting.Stations.Count > 1) ? station.Table : value.table.Value) { case CraftingTable.None: registeredPiece.Prefab.GetComponent().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().m_craftingStation = prefab2.GetComponent(); } 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().m_craftingStation = null; } else { registeredPiece.Prefab.GetComponent().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Crafting.Stations.Count > 1) ? station.Table : value.table.Value).ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } break; } } registeredPiece.conversions = new List(); 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().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().Any() || prefab.GetComponentsInChildren().Any())) { Camera component = new GameObject("CameraIcon", new Type[1] { typeof(Camera) }).GetComponent(); 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(); ((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(prefab); Transform[] componentsInChildren = val.GetComponentsInChildren(); 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(); Vector3 val3 = componentsInChildren2.Aggregate(Vector3.positiveInfinity, [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, [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(); 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 * ((float)Math.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().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([NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); List list = new List(); bool flag = false; int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true) .Invoke(configManager, Array.Empty()) ?? ((object)130)); GUILayout.BeginVertical(Array.Empty()); foreach (Requirement req in new SerializedRequirements((string)cfg.BoxedValue).Reqs) { GUILayout.BeginHorizontal(Array.Empty()); int num2 = req.amount; if (int.TryParse(GUILayout.TextField(num2.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 40f }, Array.Empty()), 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()); 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()) != req.recover) { flag2 = !flag2; flag = true; } if (GUILayout.Button("x", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty()) && !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()) && !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 config<[Nullable(2)] T>(string group, string name, T value, ConfigDescription description) { ConfigEntry val = plugin.Config.Bind(group, name, value, description); configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T)) .Invoke(configSync, new object[1] { val }); return val; } private static ConfigEntry config<[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())); } } public static class GoExtensions { [NullableContext(1)] public static T GetOrAddComponent<[Nullable(0)] T>(this GameObject gameObject) where T : Component { return gameObject.GetComponent() ?? gameObject.AddComponent(); } } [PublicAPI] [Nullable(0)] [NullableContext(1)] public class LocalizeKey { private static readonly List keys = new List(); public readonly string Key; public readonly Dictionary Localizations = new Dictionary(); 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; if (Localization.m_instance != null) { 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.m_instance != null) { 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)); } } } } [NullableContext(1)] [Nullable(0)] public static class LocalizationCache { private static readonly Dictionary localizations = new Dictionary(); internal static void LocalizationPostfix(Localization __instance, string language) { string key = localizations.FirstOrDefault([NullableContext(0)] (KeyValuePair l) => l.Value == __instance).Key; if (key != null) { localizations.Remove(key); } if (!localizations.ContainsKey(language)) { localizations.Add(language, __instance); } } public static Localization ForLanguage([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; } } [NullableContext(1)] [Nullable(0)] public class AdminSyncing { [CompilerGenerated] private sealed class <g__WatchAdminListChanges|2_0>d : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [Nullable(0)] private object <>2__current; [Nullable(new byte[] { 0, 1 })] private List 5__1; [Nullable(new byte[] { 0, 1 })] private List 5__2; [Nullable(new byte[] { 0, 1 })] private List 5__3; object IEnumerator.Current { [DebuggerHidden] [return: Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <g__WatchAdminListChanges|2_0>d(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; if (!ZNet.instance.m_adminList.GetList().SequenceEqual(5__1)) { 5__1 = new List(ZNet.instance.m_adminList.GetList()); 5__2 = (from p in ZNet.instance.GetPeers() where ZNet.instance.ListContainsId(ZNet.instance.m_adminList, p.m_rpc.GetSocket().GetHostName()) select p).ToList(); 5__3 = ZNet.instance.GetPeers().Except(5__2).ToList(); g__SendAdmin|2_2(5__3, isAdmin: false); g__SendAdmin|2_2(5__2, isAdmin: true); 5__2 = null; 5__3 = null; } } else { <>1__state = -1; 5__1 = new List(ZNet.instance.m_adminList.GetList()); } <>2__current = (object)new WaitForSeconds(30f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <>c__DisplayClass3_0 { [Nullable(0)] public ZPackage package; [NullableContext(0)] internal IEnumerator b__1(ZNetPeer p) { return TellPeerAdminStatus(p, package); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <>c__DisplayClass4_0 { [Nullable(0)] public ZNetPeer peer; [Nullable(0)] public ZRoutedRpc rpc; } [CompilerGenerated] private sealed class d__4 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private bool <>2__current; [Nullable(0)] public ZNetPeer peer; [Nullable(0)] public ZPackage package; private <>c__DisplayClass4_0 <>8__1; bool IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = default(<>c__DisplayClass4_0); <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; <>8__1.peer = peer; <>8__1.rpc = ZRoutedRpc.instance; if (<>8__1.rpc == null) { return false; } g__SendPackage|4_0(package, ref <>8__1); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [Nullable(0)] private object <>2__current; [Nullable(new byte[] { 0, 1 })] public List peers; [Nullable(0)] public ZPackage package; [Nullable(0)] private <>c__DisplayClass3_0 <>8__1; [Nullable(0)] private byte[] 5__2; [Nullable(new byte[] { 0, 1 })] private List> 5__3; [Nullable(0)] private ZPackage 5__4; [Nullable(0)] private MemoryStream 5__5; [Nullable(0)] private DeflateStream 5__6; object IEnumerator.Current { [DebuggerHidden] [return: Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass3_0(); <>8__1.package = package; if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return false; } 5__2 = <>8__1.package.GetArray(); if (5__2 != null && 5__2.LongLength > 10000) { 5__4 = new ZPackage(); 5__4.Write(4); 5__5 = new MemoryStream(); 5__6 = new DeflateStream(5__5, CompressionLevel.Optimal); try { 5__6.Write(5__2, 0, 5__2.Length); } finally { if (5__6 != null) { ((IDisposable)5__6).Dispose(); } } 5__6 = null; 5__4.Write(5__5.ToArray()); <>8__1.package = 5__4; 5__4 = null; 5__5 = null; } 5__3 = (from peer in peers where peer.IsReady() select peer into p select TellPeerAdminStatus(p, <>8__1.package)).ToList(); 5__3.RemoveAll((IEnumerator writer) => !writer.MoveNext()); break; case 1: <>1__state = -1; 5__3.RemoveAll((IEnumerator writer) => !writer.MoveNext()); break; } if (5__3.Count > 0) { <>2__current = null; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } 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(BuildPiece._plugin.Info.Metadata.Name + " PMAdminStatusSync", (Action)RPC_AdminPieceAddRemove); } else if (!registeredOnClient) { ZRoutedRpc.instance.Register(BuildPiece._plugin.Info.Metadata.Name + " PMAdminStatusSync", (Action)RPC_AdminPieceAddRemove); registeredOnClient = true; } } if (isServer) { ((MonoBehaviour)ZNet.instance).StartCoroutine(WatchAdminListChanges()); } [IteratorStateMachine(typeof(<g__WatchAdminListChanges|2_0>d))] static IEnumerator WatchAdminListChanges() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <g__WatchAdminListChanges|2_0>d(0); } } [IteratorStateMachine(typeof(d__3))] private static IEnumerator sendZPackage(List peers, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { peers = peers, package = package }; } [IteratorStateMachine(typeof(d__4))] private static IEnumerator TellPeerAdminStatus(ZNetPeer peer, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { peer = peer, package = package }; } 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(); 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.FindObjectsByType((FindObjectsSortMode)0); 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 pieces = ObjectDB.instance.GetItemPrefab("Hammer").GetComponent().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)); } } } [CompilerGenerated] internal static void g__SendAdmin|2_2(List 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)); } [CompilerGenerated] internal static void g__SendPackage|4_0(ZPackage pkg, ref <>c__DisplayClass4_0 P_1) { BaseUnityPlugin plugin = BuildPiece._plugin; string text = ((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync"; if (isServer) { P_1.peer.m_rpc.Invoke(text, new object[1] { pkg }); } else { P_1.rpc.InvokeRoutedRPC(P_1.peer.m_server ? 0 : P_1.peer.m_uid, text, new object[1] { pkg }); } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] [Nullable(0)] [NullableContext(1)] 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(((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync", (Action)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); } } [Nullable(0)] [NullableContext(1)] public static class PiecePrefabManager { [Nullable(0)] private struct BundleId { [UsedImplicitly] public string assetBundleFileName; [UsedImplicitly] public string folderName; } private static readonly Dictionary bundleCache; private static readonly List piecePrefabs; private static readonly Dictionary PieceCategories; private static readonly Dictionary OtherPieceCategories; private static readonly Dictionary 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(); piecePrefabs = new List(); PieceCategories = new Dictionary(); OtherPieceCategories = new Dictionary(); VanillaLabels = new Dictionary(); 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 dictionary = bundleCache; AssetBundle? obj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)([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 FixRefs(AssetBundle assetBundle) { return assetBundle.LoadAllAssets(); } 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(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(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(__result, PieceCategories.Keys.ToArray()); } } public static Dictionary 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 dictionary = new Dictionary(); 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(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 pieceCategoriesMap = GetPieceCategoriesMap(); foreach (KeyValuePair 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((IEnumerable)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(Hud.instance.m_pieceCategoryTabs[0], val.transform.parent); val2.SetActive(false); UIInputHandler orAddComponent = val2.GetOrAddComponent(); orAddComponent.m_onLeftDown = (Action)Delegate.Combine(orAddComponent.m_onLeftDown, new Action(Hud.instance.OnLeftClickCategory)); TMP_Text[] componentsInChildren = val2.GetComponentsInChildren(); 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 TranspileMaxCategory(IEnumerable 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 list = new List(); 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 UpdateAvailable_Transpiler(IEnumerable instructions) { return TranspileMaxCategory(instructions, 0); } private static HashSet CategoriesInPieceTable(PieceTable pieceTable) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); Piece val = default(Piece); foreach (GameObject item in pieceTable.m_pieces.Where([NullableContext(0)] (GameObject pieceFab) => (Object)(object)pieceFab != (Object)null)) { if (item.TryGetComponent(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 references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)Hud.instance.m_pieceCategoryTabs[0].transform; RectTransform val2 = (RectTransform)Hud.instance.m_pieceCategoryRoot.transform; RectTransform val3 = (RectTransform)Hud.instance.m_pieceSelectionWindow.transform; HorizontalLayoutGroup val4 = default(HorizontalLayoutGroup); if (((Component)((Transform)val).parent).TryGetComponent(ref val4)) { Object.DestroyImmediate((Object)(object)val4); } Rect rect = val.rect; Vector2 size = ((Rect)(ref rect)).size; GridLayoutGroup val5 = default(GridLayoutGroup); GridLayoutGroup val6 = (((Component)((Transform)val).parent).TryGetComponent(ref val5) ? val5 : ((Component)((Transform)val).parent).gameObject.AddComponent()); val6.cellSize = size; val6.spacing = new Vector2(0f, 1f); val6.constraint = (Constraint)1; val6.constraintCount = 5; ((LayoutGroup)val6).childAlignment = (TextAnchor)4; HashSet hashSet = CategoriesInPieceTable(pieceTable); UpdatePieceTableCategories(pieceTable, hashSet); rect = val2.rect; int num = Mathf.Max((int)(((Rect)(ref rect)).width / size.x), 1); int count = pieceTable.m_categories.Count; float num2 = (0f - size.x) * (float)num / 2f + size.x / 2f; float num3 = (size.y + 1f) * Mathf.Floor((float)(count - 1) / (float)num) + 5f; Vector2 val7 = default(Vector2); ((Vector2)(ref val7))..ctor(num2, num3); int num4 = Mathf.CeilToInt((float)count / (float)num); float num5 = (size.y + 1f) * (float)num4; RectTransform component = ((Component)((Transform)val).parent).GetComponent(); component.anchoredPosition = new Vector2(component.anchoredPosition.x, num5 / 2f); int num6 = 0; for (int i = 0; i < Hud.instance.m_pieceCategoryTabs.Length; i++) { GameObject val8 = Hud.instance.m_pieceCategoryTabs[i]; if ((Object)(object)val8 == (Object)null) { continue; } if (i >= pieceTable.m_categories.Count) { val8.SetActive(false); continue; } PieceCategory item = pieceTable.m_categories[i]; string text = pieceTable.m_categoryLabels[i]; if (hashSet.Contains(item)) { num6++; } val8.GetComponentInChildren().text = Localization.instance.Localize(text); } Transform obj = ((Transform)val3).Find("Bkg2"); RectTransform val9 = (RectTransform)((obj != null) ? ((Component)obj).transform : null); if (Object.op_Implicit((Object)(object)val9)) { float num7 = (size.y + 1f) * (float)Mathf.Max(0, Mathf.FloorToInt((float)(num6 - 1) / (float)num)); val9.offsetMax = new Vector2(val9.offsetMax.x, num7); } else { Debug.LogWarning((object)"RefreshCategories: Could not find background image"); } ((Component)Hud.instance).GetComponentInParent().RefreshLocalization(); } private static void UpdatePieceTableCategories(PieceTable pieceTable, HashSet visibleCategories) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < GetMaxCategoryOrDefault(); i++) { PieceCategory val = (PieceCategory)i; if (visibleCategories.Contains(val) && !pieceTable.m_categories.Contains(val)) { pieceTable.m_categories.Add(val); pieceTable.m_categoryLabels.Add(GetVanillaLabel(val)); } if (!visibleCategories.Contains(val) && pieceTable.m_categories.Contains(val)) { int index = pieceTable.m_categories.IndexOf(val); pieceTable.m_categories.RemoveAt(index); pieceTable.m_categoryLabels.RemoveAt(index); } } foreach (KeyValuePair pieceCategory in PieceCategories) { string key = pieceCategory.Key; PieceCategory value = pieceCategory.Value; if (visibleCategories.Contains(value) && !pieceTable.m_categories.Contains(value)) { pieceTable.m_categories.Add(value); pieceTable.m_categoryLabels.Add("$" + GetCategoryToken(key)); } if (visibleCategories.Contains(value) && !pieceTable.m_categoryLabels.Contains("$" + GetCategoryToken(key))) { pieceTable.m_categoryLabels.Add("$" + GetCategoryToken(key)); } if (!visibleCategories.Contains(value) && pieceTable.m_categories.Contains(value)) { int index2 = pieceTable.m_categories.IndexOf(value); pieceTable.m_categories.RemoveAt(index2); pieceTable.m_categoryLabels.RemoveAt(index2); } } } private static string GetVanillaLabel(PieceCategory category) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!VanillaLabels.ContainsKey(category)) { SearchVanillaLabels(); } string value; return VanillaLabels.TryGetValue(category, out value) ? value : string.Empty; } private static void SearchVanillaLabels() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) PieceTable[] array = Resources.FindObjectsOfTypeAll(); foreach (PieceTable val in array) { for (int j = 0; j < val.m_categories.Count; j++) { PieceCategory key = val.m_categories[j]; if (j < val.m_categoryLabels.Count && !VanillaLabels.ContainsKey(key) && !string.IsNullOrEmpty(val.m_categoryLabels[j])) { VanillaLabels[key] = val.m_categoryLabels[j]; } } } } private static string GetCategoryToken(string name) { char[] endChars = Localization.instance.m_endChars; string text = string.Concat(name.ToLower().Split(endChars)); return "piecemanager_cat_" + text; } private static void Patch_SetPlaceMode(Player __instance) { if (Object.op_Implicit((Object)(object)__instance.m_buildPieces)) { RepositionCategories(__instance.m_buildPieces); } } private static void UpdateAvailable_Prefix(PieceTable __instance) { if (__instance.m_availablePieces.Count > 0) { int num = ModifiedMaxCategory() - __instance.m_availablePieces.Count; for (int i = 0; i < num; i++) { __instance.m_availablePieces.Add(new List()); } } } private static void UpdateAvailable_Postfix(PieceTable __instance) { Array.Resize(ref __instance.m_selectedPiece, __instance.m_availablePieces.Count); Array.Resize(ref __instance.m_lastSelectedPiece, __instance.m_availablePieces.Count); } [HarmonyPriority(200)] private static void Hud_AwakeCreateTabs() { CreateCategoryTabs(); } [HarmonyPriority(700)] private static void Patch_ZNetSceneAwake(ZNetScene __instance) { foreach (GameObject piecePrefab in piecePrefabs) { if (!__instance.m_prefabs.Contains(piecePrefab)) { __instance.m_prefabs.Add(piecePrefab); } } } [HarmonyPriority(700)] private static void RefFixPatch_ZNetSceneAwake(ZNetScene __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject piecePrefab in piecePrefabs) { if (__instance.m_prefabs.Contains(piecePrefab) && Object.op_Implicit((Object)(object)piecePrefab.GetComponent())) { piecePrefab.GetComponent().m_isUpgrade = true; piecePrefab.GetComponent().m_connectionPrefab = __instance.GetPrefab("piece_workbench_ext3").GetComponent().m_connectionPrefab; piecePrefab.GetComponent().m_connectionOffset = __instance.GetPrefab("piece_workbench_ext3").GetComponent().m_connectionOffset; } } } [HarmonyPriority(300)] private static void Patch_ObjectDBInit(ObjectDB __instance) { foreach (BuildPiece registeredPiece in BuildPiece.registeredPieces) { string[] activeTools = registeredPiece.activeTools; foreach (string text in activeTools) { GameObject itemPrefab = __instance.GetItemPrefab(text); PieceTable val = ((itemPrefab != null) ? itemPrefab.GetComponent().m_itemData.m_shared.m_buildPieces : null); if (val != null && !val.m_pieces.Contains(registeredPiece.Prefab)) { val.m_pieces.Add(registeredPiece.Prefab); } } } } } public static class PieceManagerVersion { [Nullable(1)] public const string Version = "1.2.9"; } [PublicAPI] [Nullable(0)] [NullableContext(1)] public class Conversion { [Nullable(0)] internal class ConversionConfig { public ConfigEntry input = null; public ConfigEntry output = null; } public string Input = null; public string Output = null; [Nullable(2)] internal ConversionConfig config; public Conversion(BuildPiece conversionPiece) { conversionPiece.Conversions.Add(this); } } } namespace CreatureManager { public enum Toggle { On, Off } [PublicAPI] public enum GlobalKey { [InternalName("")] None, [InternalName("defeated_bonemass")] KilledBonemass, [InternalName("defeated_gdking")] KilledElder, [InternalName("defeated_goblinking")] KilledYagluth, [InternalName("defeated_dragon")] KilledModer, [InternalName("defeated_eikthyr")] KilledEikthyr, [InternalName("KilledTroll")] KilledTroll, [InternalName("killed_surtling")] KilledSurtling } [Flags] [PublicAPI] public enum Weather { [InternalName("")] None = 0, [InternalName("Clear")] ClearSkies = 1, [InternalName("Heath clear")] MeadowsClearSkies = 4, [InternalName("LightRain")] LightRain = 8, [InternalName("Rain")] Rain = 0x10, [InternalName("ThunderStorm")] ThunderStorm = 0x20, [InternalName("nofogts")] ClearThunderStorm = 0x40, [InternalName("SwampRain")] SwampRain = 0x80, [InternalName("Darklands_dark")] MistlandsDark = 0x100, [InternalName("Ashrain")] AshlandsAshrain = 0x200, [InternalName("Snow")] MountainSnow = 0x400, [InternalName("SnowStorm")] MountainBlizzard = 0x800, [InternalName("DeepForest Mist")] BlackForestFog = 0x1000, [InternalName("Misty")] Fog = 0x2000, [InternalName("Twilight_Snow")] DeepNorthSnow = 0x4000, [InternalName("Twilight_SnowStorm")] DeepNorthSnowStorm = 0x8000, [InternalName("Twilight_Clear")] DeepNorthClear = 0x10000, [InternalName("Eikthyr")] EikyrsThunderstorm = 0x20000, [InternalName("GDKing")] EldersHaze = 0x40000, [InternalName("Bonemass")] BonemassDownpour = 0x80000, [InternalName("Moder")] ModersVortex = 0x100000, [InternalName("GoblinKing")] YagluthsMagicBlizzard = 0x200000, [InternalName("Crypt")] Crypt = 0x400000, [InternalName("SunkenCrypt")] SunkenCrypt = 0x800000 } [NullableContext(1)] [Nullable(0)] public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } public enum DropOption { Disabled, Default, Custom } public enum SpawnOption { Disabled, Default, Custom } public enum SpawnTime { Day, Night, Always } public enum SpawnArea { Center, Edge, Everywhere } public enum Forest { Yes, No, Both } [PublicAPI] public struct Range { public float min; public float max; public Range(float min, float max) { this.min = 0f; this.max = 0f; this.min = min; this.max = max; } } [PublicAPI] [Nullable(0)] [NullableContext(1)] public class Creature { [Nullable(0)] [PublicAPI] public class DropList { [Nullable(0)] internal class SerializedDrops { [Nullable(new byte[] { 1, 0, 1, 1 })] public readonly List> Drops; public SerializedDrops(DropList drops, Creature creature) { Drops = (drops.drops ?? creature.Prefab.GetComponent()?.m_drops.ToDictionary([NullableContext(0)] (Drop drop) => ((Object)drop.m_prefab).name, [NullableContext(0)] (Drop drop) => new Drop { Amount = new Range(drop.m_amountMin, drop.m_amountMax), DropChance = drop.m_chance, DropOnePerPlayer = drop.m_onePerPlayer, MultiplyDropByLevel = drop.m_levelMultiplier }) ?? new Dictionary()).ToList(); } public SerializedDrops([Nullable(new byte[] { 1, 0, 1, 1 })] List> drops) { Drops = drops; } public SerializedDrops(string reqs) { Drops = (from r in reqs.Split(new char[1] { ',' }) select r.Split(new char[1] { ':' })).ToDictionary([NullableContext(0)] (string[] l) => l[0], [NullableContext(0)] (string[] parts) => { Range amount = new Range(1f, 1f); if (parts.Length > 1) { string[] array = parts[1].Split(new char[1] { '-' }); if (!int.TryParse(array[0], out var result)) { result = 1; } if (array.Length == 1 || !int.TryParse(array[0], out var result2)) { result2 = result; } amount = new Range(result, result2); } float result3; return new Drop { Amount = amount, DropChance = ((parts.Length > 2 && float.TryParse(parts[2], out result3)) ? result3 : 100f), DropOnePerPlayer = (parts.Length > 3 && parts[3] == "onePerPlayer"), MultiplyDropByLevel = (parts.Length > 4 && parts[4] == "multiplyByLevel") }; }).ToList(); } public override string ToString() { return string.Join(",", Drops.Select([NullableContext(0)] (KeyValuePair kv) => string.Format("{0}:{1}-{2}:{3}:{4}:{5}", kv.Key, kv.Value.Amount.min, kv.Value.Amount.max, kv.Value.DropChance, kv.Value.DropOnePerPlayer ? "onePerPlayer" : "unrestricted", kv.Value.MultiplyDropByLevel ? "multiplyByLevel" : "unaffectedByLevel"))); } } [Nullable(new byte[] { 2, 1, 1 })] private Dictionary drops = null; public Drop this[string prefabName] { get { Drop result; if (!(drops ?? (drops = new Dictionary())).TryGetValue(prefabName, out var value)) { Drop drop2 = (drops[prefabName] = new Drop()); result = drop2; } else { result = value; } return result; } } public void None() { drops = new Dictionary(); } [HarmonyPriority(700)] internal static void AddDropsToCreature() { foreach (Creature registeredCreature in registeredCreatures) { UpdateDrops(registeredCreature); } } internal static void UpdateDrops(Creature creature) { if (!creatureConfigs.ContainsKey(creature) || creatureConfigs[creature].Drops.get == null) { return; } DropOption dropOption = creatureConfigs[creature].Drops.get(); if (dropOption == DropOption.Default && creature.Drops.drops == null) { return; } CharacterDrop val = creature.Prefab.GetComponent() ?? creature.Prefab.AddComponent(); DropOption dropOption2 = creatureConfigs[creature].Drops.get(); if (1 == 0) { } List> source = dropOption2 switch { DropOption.Custom => new SerializedDrops(creatureConfigs[creature].CustomDrops.get()).Drops, DropOption.Disabled => new List>(), _ => creature.Drops.drops.ToList(), }; if (1 == 0) { } val.m_drops = (from d in ((IEnumerable>)source).Select((Func, Drop>)([NullableContext(0)] (KeyValuePair kv) => { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown if (kv.Key == "" || ZNetScene.instance == null) { return null; } GameObject prefab = ZNetScene.instance.GetPrefab(kv.Key); if (prefab == null) { Debug.LogWarning((object)("Found invalid prefab name " + kv.Key + " for creature " + ((Object)creature.Prefab).name)); return null; } return new Drop { m_prefab = prefab, m_amountMin = (int)kv.Value.Amount.min, m_amountMax = (int)kv.Value.Amount.max, m_chance = kv.Value.DropChance / 100f, m_onePerPlayer = kv.Value.DropOnePerPlayer, m_levelMultiplier = kv.Value.MultiplyDropByLevel }; })) where d != null select d).ToList(); } } [PublicAPI] [NullableContext(0)] public class Drop { public Range Amount = new Range(1f, 1f); public float DropChance = 100f; public bool DropOnePerPlayer = false; public bool MultiplyDropByLevel = true; } [NullableContext(0)] private class CustomConfig<[Nullable(2)] T> { [Nullable(1)] public Func get = null; [Nullable(new byte[] { 2, 1 })] public ConfigEntry config = null; } [Nullable(0)] private class CreatureConfig { public readonly CustomConfig Spawn = new CustomConfig(); public readonly CustomConfig CanBeTamed = new CustomConfig(); public readonly CustomConfig ConsumesItemName = new CustomConfig(); public readonly CustomConfig SpecificSpawnTime = new CustomConfig(); public readonly CustomConfig RequiredAltitude = new CustomConfig(); public readonly CustomConfig RequiredOceanDepth = new CustomConfig(); public readonly CustomConfig RequiredGlobalKey = new CustomConfig(); public readonly CustomConfig GroupSize = new CustomConfig(); public readonly CustomConfig Biome = new CustomConfig(); public readonly CustomConfig SpecificSpawnArea = new CustomConfig(); public readonly CustomConfig RequiredWeather = new CustomConfig(); public readonly CustomConfig SpawnAltitude = new CustomConfig(); public readonly CustomConfig CanHaveStars = new CustomConfig(); public readonly CustomConfig AttackImmediately = new CustomConfig(); public readonly CustomConfig CheckSpawnInterval = new CustomConfig(); public readonly CustomConfig SpawnChance = new CustomConfig(); public readonly CustomConfig ForestSpawn = new CustomConfig(); public readonly CustomConfig Maximum = new CustomConfig(); public readonly CustomConfig Drops = new CustomConfig(); public readonly CustomConfig CustomDrops = new CustomConfig(); public readonly CustomConfig Health = new CustomConfig(); public readonly CustomConfig RegenAllHpTime = new CustomConfig(); public readonly CustomConfig BluntModifier = new CustomConfig(); public readonly CustomConfig SlashModifier = new CustomConfig(); public readonly CustomConfig PierceModifier = new CustomConfig(); public readonly CustomConfig ChopModifier = new CustomConfig(); public readonly CustomConfig PickaxeModifier = new CustomConfig(); public readonly CustomConfig FireModifier = new CustomConfig(); public readonly CustomConfig FrostModifier = new CustomConfig(); public readonly CustomConfig LightningModifier = new CustomConfig(); public readonly CustomConfig PoisonModifier = new CustomConfig(); public readonly CustomConfig SpiritModifier = new CustomConfig(); } [NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] [Nullable(2)] public string Category; [Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action CustomDrawer; } [Nullable(0)] private class AcceptableEnumValues<[Nullable(0)] T> : AcceptableValueBase where T : struct, IConvertible { [Nullable(new byte[] { 1, 0 })] [PublicAPI] public virtual T[] AcceptableValues { [return: Nullable(new byte[] { 1, 0 })] get; } public AcceptableEnumValues([Nullable(new byte[] { 1, 0 })] params T[] acceptableValues) : base(typeof(T)) { AcceptableValues = acceptableValues; } public override object Clamp(object value) { return ((AcceptableValueBase)this).IsValid(value) ? value : ((object)AcceptableValues[0]); } public override bool IsValid(object value) { return AcceptableValues.Contains((T)value); } public override string ToDescriptionString() { return string.Join(", ", AcceptableValues); } } private readonly HashSet _configuredProperties = new HashSet(); private bool _canSpawn = false; private bool _canBeTamed = false; private string _foodItems = ""; private SpawnTime _specificSpawnTime = SpawnTime.Always; private Range _requiredAltitude = new Range(5f, 1000f); private Range _requiredOceanDepth = new Range(0f, 0f); private GlobalKey _requiredGlobalKey = GlobalKey.None; private Range _groupSize = new Range(1f, 1f); private Biome _biome = (Biome)1; private SpawnArea _specificSpawnArea = SpawnArea.Everywhere; private Weather _requiredWeather = Weather.None; private float _spawnAltitude = 0.5f; private bool _canHaveStars = true; private bool _attackImmediately = false; private int _checkSpawnInterval = 600; private float _spawnChance = 100f; private Forest _forestSpawn = Forest.Both; private int _maximum = 1; private float _health = -1f; private float _regenAllHpTime = -1f; private DamageModifier _bluntModifier = (DamageModifier)0; private DamageModifier _slashModifier = (DamageModifier)0; private DamageModifier _pierceModifier = (DamageModifier)0; private DamageModifier _chopModifier = (DamageModifier)0; private DamageModifier _pickaxeModifier = (DamageModifier)0; private DamageModifier _fireModifier = (DamageModifier)0; private DamageModifier _frostModifier = (DamageModifier)0; private DamageModifier _lightningModifier = (DamageModifier)0; private DamageModifier _poisonModifier = (DamageModifier)0; private DamageModifier _spiritModifier = (DamageModifier)0; public bool ConfigurationEnabled = true; public readonly GameObject Prefab; public DropList Drops = new DropList(); private static readonly List registeredCreatures = new List(); private static Dictionary creatureConfigs = new Dictionary(); [Nullable(2)] private static object configManager; private static List lastRegisteredSpawns = new List(); [Nullable(2)] private static Localization _english; [Nullable(2)] private static BaseUnityPlugin _plugin; private static bool hasConfigSync = true; [Nullable(2)] private static object _configSync; public bool CanSpawn => _canSpawn; public bool CanBeTamed => _canBeTamed; public string FoodItems => _foodItems; public SpawnTime SpecificSpawnTime => _specificSpawnTime; public Range RequiredAltitude => _requiredAltitude; public Range RequiredOceanDepth => _requiredOceanDepth; public GlobalKey RequiredGlobalKey => _requiredGlobalKey; public Range GroupSize => _groupSize; public Biome Biome => _biome; public SpawnArea SpecificSpawnArea => _specificSpawnArea; public Weather RequiredWeather => _requiredWeather; public float SpawnAltitude => _spawnAltitude; public bool CanHaveStars => _canHaveStars; public bool AttackImmediately => _attackImmediately; public int CheckSpawnInterval => _checkSpawnInterval; public float SpawnChance => _spawnChance; public Forest ForestSpawn => _forestSpawn; public int Maximum => _maximum; public float Health => _health; public float RegenAllHpTime => _regenAllHpTime; public DamageModifier BluntModifier => _bluntModifier; public DamageModifier SlashModifier => _slashModifier; public DamageModifier PierceModifier => _pierceModifier; public DamageModifier ChopModifier => _chopModifier; public DamageModifier PickaxeModifier => _pickaxeModifier; public DamageModifier FireModifier => _fireModifier; public DamageModifier FrostModifier => _frostModifier; public DamageModifier LightningModifier => _lightningModifier; public DamageModifier PoisonModifier => _poisonModifier; public DamageModifier SpiritModifier => _spiritModifier; private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); 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 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([NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [Nullable(2)] private static object configSync { [NullableContext(2)] get { if (_configSync == null && hasConfigSync) { Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " CreatureManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public bool IsConfigured(string propertyName) { return _configuredProperties.Contains(propertyName); } public Creature EnableSpawning(bool enabled = true, bool isConfigurable = true) { _canSpawn = enabled; if (isConfigurable) { _configuredProperties.Add("CanSpawn"); } return this; } public Creature EnableTaming(bool enabled = true, bool isConfigurable = true) { _canBeTamed = enabled; if (isConfigurable) { _configuredProperties.Add("CanBeTamed"); } return this; } public DropList ConfigureDrops() { _configuredProperties.Add("Drops"); return Drops; } public Creature ConfigureFoodItems(string foodItems, bool isConfigurable = true) { _foodItems = foodItems; if (isConfigurable) { _configuredProperties.Add("FoodItems"); } return this; } public Creature ConfigureSpawnTime(SpawnTime spawnTime, bool isConfigurable = true) { _specificSpawnTime = spawnTime; if (isConfigurable) { _configuredProperties.Add("SpecificSpawnTime"); } return this; } public Creature ConfigureRequiredAltitude(Range altitude, bool isConfigurable = true) { _requiredAltitude = altitude; if (isConfigurable) { _configuredProperties.Add("RequiredAltitude"); } return this; } public Creature ConfigureRequiredOceanDepth(Range depth, bool isConfigurable = true) { _requiredOceanDepth = depth; if (isConfigurable) { _configuredProperties.Add("RequiredOceanDepth"); } return this; } public Creature ConfigureRequiredGlobalKey(GlobalKey globalKey, bool isConfigurable = true) { _requiredGlobalKey = globalKey; if (isConfigurable) { _configuredProperties.Add("RequiredGlobalKey"); } return this; } public Creature ConfigureGroupSize(Range groupSize, bool isConfigurable = true) { _groupSize = groupSize; if (isConfigurable) { _configuredProperties.Add("GroupSize"); } return this; } public Creature ConfigureBiome(Biome biome, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _biome = biome; if (isConfigurable) { _configuredProperties.Add("Biome"); } return this; } public Creature ConfigureSpawnArea(SpawnArea spawnArea, bool isConfigurable = true) { _specificSpawnArea = spawnArea; if (isConfigurable) { _configuredProperties.Add("SpecificSpawnArea"); } return this; } public Creature ConfigureRequiredWeather(Weather weather, bool isConfigurable = true) { _requiredWeather = weather; if (isConfigurable) { _configuredProperties.Add("RequiredWeather"); } return this; } public Creature ConfigureSpawnAltitude(float altitude, bool isConfigurable = true) { _spawnAltitude = altitude; if (isConfigurable) { _configuredProperties.Add("SpawnAltitude"); } return this; } public Creature EnableStars(bool enabled = true, bool isConfigurable = true) { _canHaveStars = enabled; if (isConfigurable) { _configuredProperties.Add("CanHaveStars"); } return this; } public Creature ConfigureAttackImmediately(bool attackImmediately = true, bool isConfigurable = true) { _attackImmediately = attackImmediately; if (isConfigurable) { _configuredProperties.Add("AttackImmediately"); } return this; } public Creature ConfigureSpawnInterval(int interval, bool isConfigurable = true) { _checkSpawnInterval = interval; if (isConfigurable) { _configuredProperties.Add("CheckSpawnInterval"); } return this; } public Creature ConfigureSpawnChance(float chance, bool isConfigurable = true) { _spawnChance = chance; if (isConfigurable) { _configuredProperties.Add("SpawnChance"); } return this; } public Creature ConfigureForestSpawn(Forest forest, bool isConfigurable = true) { _forestSpawn = forest; if (isConfigurable) { _configuredProperties.Add("ForestSpawn"); } return this; } public Creature ConfigureMaximum(int max, bool isConfigurable = true) { _maximum = max; if (isConfigurable) { _configuredProperties.Add("Maximum"); } return this; } public Creature ConfigureHealth(float health, bool isConfigurable = true) { _health = health; if (isConfigurable) { _configuredProperties.Add("Health"); } return this; } public Creature ConfigureRegenAllHpTime(float time, bool isConfigurable = true) { _regenAllHpTime = time; if (isConfigurable) { _configuredProperties.Add("RegenAllHpTime"); } return this; } public Creature ConfigureBluntModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _bluntModifier = modifier; if (isConfigurable) { _configuredProperties.Add("BluntModifier"); } return this; } public Creature ConfigureSlashModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _slashModifier = modifier; if (isConfigurable) { _configuredProperties.Add("SlashModifier"); } return this; } public Creature ConfigurePierceModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _pierceModifier = modifier; if (isConfigurable) { _configuredProperties.Add("PierceModifier"); } return this; } public Creature ConfigureChopModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _chopModifier = modifier; if (isConfigurable) { _configuredProperties.Add("ChopModifier"); } return this; } public Creature ConfigurePickaxeModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _pickaxeModifier = modifier; if (isConfigurable) { _configuredProperties.Add("PickaxeModifier"); } return this; } public Creature ConfigureFireModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _fireModifier = modifier; if (isConfigurable) { _configuredProperties.Add("FireModifier"); } return this; } public Creature ConfigureFrostModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _frostModifier = modifier; if (isConfigurable) { _configuredProperties.Add("FrostModifier"); } return this; } public Creature ConfigureLightningModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _lightningModifier = modifier; if (isConfigurable) { _configuredProperties.Add("LightningModifier"); } return this; } public Creature ConfigurePoisonModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _poisonModifier = modifier; if (isConfigurable) { _configuredProperties.Add("PoisonModifier"); } return this; } public Creature ConfigureSpiritModifier(DamageModifier modifier, bool isConfigurable = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _spiritModifier = modifier; if (isConfigurable) { _configuredProperties.Add("SpiritModifier"); } return this; } internal static bool IsRegisteredCreature(string prefabName) { return registeredCreatures.Any([NullableContext(0)] (Creature c) => ((Object)c.Prefab).name == prefabName); } public Creature(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public Creature(AssetBundle bundle, string prefabName) : this(PrefabManager.RegisterPrefab(bundle, prefabName)) { } public Creature(GameObject creature) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) Prefab = creature; registeredCreatures.Add(this); } public LocalizeKey Localize() { return new LocalizeKey(Prefab.GetComponent().m_name); } internal static void Patch_FejdStartup() { //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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_074a: Unknown result type (might be due to invalid IL or missing references) //IL_0754: Expected O, but got Unknown //IL_0d39: Unknown result type (might be due to invalid IL or missing references) //IL_0d43: Expected O, but got Unknown Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); if (!TomlTypeConverter.CanConvert(typeof(Range))) { TomlTypeConverter.AddConverter(typeof(Range), new TypeConverter { ConvertToObject = [NullableContext(0)] (string s, Type _) => { Match match = Regex.Match(s, "^(-?\\d+(?:\\.\\d*)?)\\s*-\\s*(-?\\d+(?:\\.\\d*)?)$"); return match.Success ? new Range(float.Parse(match.Groups[1].Value), float.Parse(match.Groups[2].Value)) : default(Range); }, ConvertToString = [NullableContext(0)] (object obj, Type _) => { Range range = (Range)obj; return $"{range.min} - {range.max}"; } }); } bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (Creature registeredCreature in registeredCreatures) { Creature creature = registeredCreature; CreatureConfig creatureConfig2 = (creatureConfigs[creature] = new CreatureConfig()); CreatureConfig cfg = creatureConfig2; string name2 = creature.Prefab.GetComponent().m_name; string englishName = new Regex("['[\"\\]]").Replace(english.Localize(name2), "").Trim(); string localizedName = englishName; if (Localization.m_instance != null) { localizedName = Localization.instance.Localize(name2).Trim(); } int order = 0; cfg.Spawn.get = () => creature.CanSpawn ? SpawnOption.Default : SpawnOption.Disabled; cfg.CanBeTamed.get = () => (!creature.CanBeTamed) ? Toggle.Off : Toggle.On; cfg.ConsumesItemName.get = () => creature.FoodItems; cfg.SpecificSpawnTime.get = () => creature.SpecificSpawnTime; cfg.RequiredAltitude.get = () => creature.RequiredAltitude; cfg.RequiredOceanDepth.get = () => creature.RequiredOceanDepth; cfg.RequiredGlobalKey.get = () => creature.RequiredGlobalKey; cfg.GroupSize.get = () => creature.GroupSize; cfg.Biome.get = () => creature.Biome; cfg.SpecificSpawnArea.get = () => creature.SpecificSpawnArea; cfg.RequiredWeather.get = () => creature.RequiredWeather; cfg.SpawnAltitude.get = () => creature.SpawnAltitude; cfg.CanHaveStars.get = () => (!creature.CanHaveStars) ? Toggle.Off : Toggle.On; cfg.AttackImmediately.get = () => (!creature.AttackImmediately) ? Toggle.Off : Toggle.On; cfg.CheckSpawnInterval.get = () => creature.CheckSpawnInterval; cfg.SpawnChance.get = () => creature.SpawnChance; cfg.ForestSpawn.get = () => creature.ForestSpawn; cfg.Maximum.get = () => creature.Maximum; cfg.Drops.get = () => DropOption.Default; cfg.CustomDrops.get = () => new DropList.SerializedDrops(creature.Drops, creature).ToString(); cfg.Health.get = () => creature.Prefab.GetComponent()?.m_health ?? creature.Health; cfg.RegenAllHpTime.get = delegate { Character component = creature.Prefab.GetComponent(); if ((Object)(object)component == (Object)null) { return creature.RegenAllHpTime; } FieldInfo fieldInfo = typeof(Character).GetField("m_regenAllHPTime", BindingFlags.Instance | BindingFlags.Public) ?? typeof(Character).GetField("m_regenAllHpTime", BindingFlags.Instance | BindingFlags.Public); return (fieldInfo != null) ? ((float)fieldInfo.GetValue(component)) : creature.RegenAllHpTime; }; cfg.BluntModifier.get = () => creature.BluntModifier; cfg.SlashModifier.get = () => creature.SlashModifier; cfg.PierceModifier.get = () => creature.PierceModifier; cfg.ChopModifier.get = () => creature.ChopModifier; cfg.PickaxeModifier.get = () => creature.PickaxeModifier; cfg.FireModifier.get = () => creature.FireModifier; cfg.FrostModifier.get = () => creature.FrostModifier; cfg.LightningModifier.get = () => creature.LightningModifier; cfg.PoisonModifier.get = () => creature.PoisonModifier; cfg.SpiritModifier.get = () => creature.SpiritModifier; ConfigurationManagerAttributes tameConfigVisibility = new ConfigurationManagerAttributes(); if (creature.IsConfigured("CanBeTamed")) { config(cfg.CanBeTamed, cfg.CanBeTamed.get, delegate { tameConfigVisibility.Browsable = cfg.CanBeTamed.get() == Toggle.On; reloadConfigDisplay(); updateAI(); }, "Can be tamed", "Decides, if the creature can be tamed."); } tameConfigVisibility.Browsable = cfg.CanBeTamed.get() == Toggle.On; if (creature.IsConfigured("FoodItems")) { configWithDesc(cfg.ConsumesItemName, cfg.ConsumesItemName.get, updateAI, "Food items", new ConfigDescription("The items the creature consumes to get tame.", (AcceptableValueBase)null, new object[1] { tameConfigVisibility })); } ConfigurationManagerAttributes spawnConfigVisibility = new ConfigurationManagerAttributes(); ConfigurationManagerAttributes dropConfigVisibility = new ConfigurationManagerAttributes(); if (creature.IsConfigured("CanSpawn")) { config(cfg.Spawn, cfg.Spawn.get, delegate { spawnConfigVisibility.Browsable = cfg.Spawn.get() == SpawnOption.Custom; reloadConfigDisplay(); updateAllSpawnConfigs(); }, "Spawn", "Configures the spawn for the creature."); } spawnConfigVisibility.Browsable = cfg.Spawn.get() == SpawnOption.Custom; if (creature.IsConfigured("SpecificSpawnTime")) { spawnConfig(cfg.SpecificSpawnTime, cfg.SpecificSpawnTime.get, "Spawn time", "Configures the time of day for the creature to spawn."); } if (creature.IsConfigured("RequiredAltitude")) { spawnConfig(cfg.RequiredAltitude, cfg.RequiredAltitude.get, "Required altitude", "Configures the altitude required for the creature to spawn."); } if (creature.IsConfigured("RequiredOceanDepth")) { spawnConfig(cfg.RequiredOceanDepth, cfg.RequiredOceanDepth.get, "Required ocean depth", "Configures the ocean depth required for the creature to spawn."); } if (creature.IsConfigured("RequiredGlobalKey")) { spawnConfig(cfg.RequiredGlobalKey, cfg.RequiredGlobalKey.get, "Required global key", "Configures the global key required for the creature to spawn."); } if (creature.IsConfigured("GroupSize")) { spawnConfig(cfg.GroupSize, cfg.GroupSize.get, "Group size", "Configures the size of the groups in which the creature spawns."); } if (creature.IsConfigured("Biome")) { spawnConfig(cfg.Biome, cfg.Biome.get, "Biome", "Configures the biome required for the creature to spawn."); } if (creature.IsConfigured("SpecificSpawnArea")) { spawnConfig(cfg.SpecificSpawnArea, cfg.SpecificSpawnArea.get, "Spawn area", "Configures if the creature spawns more towards the center or the edge of the biome."); } if (creature.IsConfigured("RequiredWeather")) { spawnConfig(cfg.RequiredWeather, cfg.RequiredWeather.get, "Required weather", "Configures the weather required for the creature to spawn."); } if (creature.IsConfigured("SpawnAltitude")) { spawnConfig(cfg.SpawnAltitude, cfg.SpawnAltitude.get, "Spawn altitude", "Configures the height from the ground in which the creature will spawn."); } if (creature.IsConfigured("CanHaveStars")) { spawnConfig(cfg.CanHaveStars, cfg.CanHaveStars.get, "Can have stars", "If the creature can have stars."); } if (creature.IsConfigured("AttackImmediately")) { spawnConfig(cfg.AttackImmediately, cfg.AttackImmediately.get, "Hunt player", "Makes the creature immediately hunt down the player after it spawns."); } if (creature.IsConfigured("CheckSpawnInterval")) { spawnConfig(cfg.CheckSpawnInterval, cfg.CheckSpawnInterval.get, "Maximum spawn interval", "Configures the timespan that Valheim has to make the creature spawn."); } if (creature.IsConfigured("SpawnChance")) { spawnConfig(cfg.SpawnChance, cfg.SpawnChance.get, "Spawn chance", "Sets the chance for the creature to be spawned, every time Valheim checks the spawn."); } if (creature.IsConfigured("ForestSpawn")) { spawnConfig(cfg.ForestSpawn, cfg.ForestSpawn.get, "Forest condition", "If the creature can spawn in forests or cannot spawn in forests. Or both."); } if (creature.IsConfigured("Maximum")) { spawnConfig(cfg.Maximum, cfg.Maximum.get, "Maximum creature count", "The maximum number of this creature near the player, before Valheim stops spawning it in. Setting this lower than the upper limit of the group size does not make sense."); } if (creature.IsConfigured("Drops")) { config(cfg.Drops, cfg.Drops.get, delegate { dropConfigVisibility.Browsable = cfg.Drops.get() == DropOption.Custom; reloadConfigDisplay(); DropList.UpdateDrops(creature); }, "Drops", "Configures the drops for the creature."); dropConfigVisibility.Browsable = cfg.Drops.get() == DropOption.Custom; configWithDesc(cfg.CustomDrops, cfg.CustomDrops.get, delegate { DropList.UpdateDrops(creature); }, "Drop config", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { dropConfigVisibility })); } if (creature.IsConfigured("Health")) { config(cfg.Health, cfg.Health.get, updateCharacterStats, "Health", "Maximum health points of the creature."); } if (creature.IsConfigured("RegenAllHpTime")) { config(cfg.RegenAllHpTime, cfg.RegenAllHpTime.get, updateCharacterStats, "Regen All HP Time", "Time in seconds to fully regenerate HP (0 = disabled)."); } if (creature.IsConfigured("BluntModifier")) { config(cfg.BluntModifier, cfg.BluntModifier.get, updateCharacterStats, "Damage Modifier: Blunt", "Resistance to blunt damage."); } if (creature.IsConfigured("SlashModifier")) { config(cfg.SlashModifier, cfg.SlashModifier.get, updateCharacterStats, "Damage Modifier: Slash", "Resistance to slash damage."); } if (creature.IsConfigured("PierceModifier")) { config(cfg.PierceModifier, cfg.PierceModifier.get, updateCharacterStats, "Damage Modifier: Pierce", "Resistance to pierce damage."); } if (creature.IsConfigured("ChopModifier")) { config(cfg.ChopModifier, cfg.ChopModifier.get, updateCharacterStats, "Damage Modifier: Chop", "Resistance to chop damage."); } if (creature.IsConfigured("PickaxeModifier")) { config(cfg.PickaxeModifier, cfg.PickaxeModifier.get, updateCharacterStats, "Damage Modifier: Pickaxe", "Resistance to pickaxe damage."); } if (creature.IsConfigured("FireModifier")) { config(cfg.FireModifier, cfg.FireModifier.get, updateCharacterStats, "Damage Modifier: Fire", "Resistance to fire damage."); } if (creature.IsConfigured("FrostModifier")) { config(cfg.FrostModifier, cfg.FrostModifier.get, updateCharacterStats, "Damage Modifier: Frost", "Resistance to frost damage."); } if (creature.IsConfigured("LightningModifier")) { config(cfg.LightningModifier, cfg.LightningModifier.get, updateCharacterStats, "Damage Modifier: Lightning", "Resistance to lightning damage."); } if (creature.IsConfigured("PoisonModifier")) { config(cfg.PoisonModifier, cfg.PoisonModifier.get, updateCharacterStats, "Damage Modifier: Poison", "Resistance to poison damage."); } if (creature.IsConfigured("SpiritModifier")) { config(cfg.SpiritModifier, cfg.SpiritModifier.get, updateCharacterStats, "Damage Modifier: Spirit", "Resistance to spirit damage."); } void config([Nullable(new byte[] { 1, 0 })] CustomConfig customConfig, [Nullable(new byte[] { 1, 0 })] Func getter, Action configChanged, string name, string desc) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown configWithDesc(customConfig, getter, configChanged, name, new ConfigDescription(desc, (AcceptableValueBase)null, Array.Empty())); } void configWithDesc([Nullable(new byte[] { 1, 0 })] CustomConfig customConfig, [Nullable(new byte[] { 1, 0 })] Func getter, Action configChanged, string name, ConfigDescription desc) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown if (creature.ConfigurationEnabled) { customConfig.config = pluginConfig(englishName, name, getter(), new ConfigDescription(desc.Description, desc.AcceptableValues, desc.Tags.Concat(new ConfigurationManagerAttributes[1] { new ConfigurationManagerAttributes { Order = (order -= 1), CustomDrawer = ((customConfig == cfg.CustomDrops) ? new Action(drawConfigTable) : ((typeof(T) == typeof(Range)) ? new Action(drawRange) : null)), Category = localizedName } }).ToArray())); customConfig.config.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { configChanged(); }; customConfig.get = [NullableContext(0)] () => customConfig.config.Value; } } void spawnConfig([Nullable(new byte[] { 1, 0 })] CustomConfig customConfig, [Nullable(new byte[] { 1, 0 })] Func getter, string name, string desc, [Nullable(2)] AcceptableValueBase acceptableValues = null) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown configWithDesc(customConfig, getter, updateAllSpawnConfigs, name, new ConfigDescription(desc, acceptableValues, new object[1] { spawnConfigVisibility })); } void updateAI() { if (Object.op_Implicit((Object)(object)ObjectDB.instance)) { BaseAI[] array3 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (BaseAI ai in array3) { creature.updateAi(ai); } creature.updateAi(creature.Prefab.GetComponent()); } } void updateAllSpawnConfigs() { SpawnSystem[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (SpawnSystem val2 in array2) { foreach (SpawnSystemList spawnList in val2.m_spawnLists) { foreach (SpawnData spawner in spawnList.m_spawners) { if ((Object)(object)creature.Prefab == (Object)(object)spawner.m_prefab) { creature.updateSpawnData(spawner); } } } } } void updateCharacterStats() { creature.applyCharacterStats(creature.Prefab.GetComponent()); Character[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (Character val in array) { if (((Object)((Component)val).gameObject).name.StartsWith(((Object)creature.Prefab).name)) { creature.applyCharacterStats(val); } } } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } static void reloadConfigDisplay() { object obj2 = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager); if (obj2 is bool && (bool)obj2) { configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty()); } } } private static void drawRange(ConfigEntryBase cfg) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select([NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); ConfigEntry val = (ConfigEntry)(object)cfg; GUILayout.BeginHorizontal(Array.Empty()); float.TryParse(GUILayout.TextField(val.Value.min.ToString(CultureInfo.InvariantCulture), Array.Empty()), out var result); GUILayout.Label(" - ", new GUIStyle(GUI.skin.label) { fixedWidth = 14f }, Array.Empty()); float.TryParse(GUILayout.TextField(val.Value.max.ToString(CultureInfo.InvariantCulture), Array.Empty()), out var result2); GUILayout.EndHorizontal(); if (!valueOrDefault && (Math.Abs(val.Value.min - result) > 1E-05f || Math.Abs(val.Value.max - result2) > 1E-05f)) { val.Value = new Range(result, result2); } } private static void drawConfigTable(ConfigEntryBase cfg) { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Expected O, but got Unknown //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select([NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); List> list = new List>(); bool flag = false; int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true) .Invoke(configManager, Array.Empty()) ?? ((object)130)); GUILayout.BeginVertical(Array.Empty()); foreach (KeyValuePair drop in new DropList.SerializedDrops((string)cfg.BoxedValue).Drops) { GUILayout.BeginHorizontal(Array.Empty()); int num2 = Mathf.RoundToInt(drop.Value.Amount.min); if (int.TryParse(GUILayout.TextField(num2.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 35f }, Array.Empty()), out var result) && result != num2 && !valueOrDefault) { num2 = result; flag = true; } GUILayout.Label(" - ", new GUIStyle(GUI.skin.label) { fixedWidth = 14f }, Array.Empty()); int num3 = Mathf.RoundToInt(drop.Value.Amount.max); if (int.TryParse(GUILayout.TextField(num3.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 35f }, Array.Empty()), out var result2) && result2 != num3 && !valueOrDefault) { num3 = result2; flag = true; } GUILayout.Label(" ", new GUIStyle(GUI.skin.label) { fixedWidth = 10f }, Array.Empty()); string text = GUILayout.TextField(drop.Key, new GUIStyle(GUI.skin.textField) { fixedWidth = num - 35 - 14 - 35 - 10 - 21 - 18 }, Array.Empty()); string text2 = (valueOrDefault ? drop.Key : text); flag = flag || text2 != drop.Key; bool flag2 = GUILayout.Button("x", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); float num4 = drop.Value.DropChance; if (float.TryParse(GUILayout.TextField(num4.ToString(CultureInfo.InvariantCulture), new GUIStyle(GUI.skin.textField) { fixedWidth = 45f }, Array.Empty()), out var result3) && Math.Abs(result3 - num4) > 1E-05f && !valueOrDefault) { num4 = result3; flag = true; } GUILayout.Label("% ", Array.Empty()); string tooltip = GUI.tooltip; bool flag3 = drop.Value.MultiplyDropByLevel; bool flag4 = GUILayout.Toggle(flag3, new GUIContent(flag3 ? "per level" : "fixed", "Loot is multiplied by the creature's level."), Array.Empty()); if (flag4 != flag3 && !valueOrDefault) { flag3 = flag4; flag = true; } bool flag5 = drop.Value.DropOnePerPlayer; bool flag6 = GUILayout.Toggle(flag5, new GUIContent(flag5 ? "per player" : "independent", "Drops one per player."), Array.Empty()); if (flag6 != flag5 && !valueOrDefault) { flag5 = flag6; flag = true; } if (GUI.tooltip != tooltip) { Vector3 mousePosition = Input.mousePosition; GUI.Label(new Rect(mousePosition.x, mousePosition.y, 100f, 35f), GUI.tooltip); } if (flag2) { flag = true; } else { Drop value = new Drop { Amount = new Range(num2, num3), DropChance = num4, MultiplyDropByLevel = flag3, DropOnePerPlayer = flag5 }; list.Add(new KeyValuePair(text2, value)); } if (GUILayout.Button("+", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; list.Add(new KeyValuePair("", new Drop())); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = new DropList.SerializedDrops(list).ToString(); } } private void updateAi(BaseAI ai) { CreatureConfig creatureConfig = creatureConfigs[this]; if (Object.op_Implicit((Object)(object)((Component)ai).GetComponent()) != (creatureConfig.CanBeTamed.get() == Toggle.On)) { if (creatureConfig.CanBeTamed.get() == Toggle.On) { ai.m_tamable = ((Component)ai).gameObject.AddComponent(); } else { Object.Destroy((Object)(object)ai.m_tamable); ai.m_tamable = null; } } MonsterAI val = (MonsterAI)(object)((ai is MonsterAI) ? ai : null); if (val == null) { return; } val.m_consumeItems.Clear(); string[] array = creatureConfig.ConsumesItemName.get().Split(new char[1] { ',' }); string[] array2 = array; foreach (string text in array2) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text.Trim()); ItemDrop val2 = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); if (val2 != null) { val.m_consumeItems.Add(val2); } } } internal static void UpdateCreatures(ObjectDB __instance) { BaseAI ai = default(BaseAI); Character character = default(Character); foreach (Creature registeredCreature in registeredCreatures) { if (registeredCreature.Prefab.TryGetComponent(ref ai)) { registeredCreature.updateAi(ai); } if (registeredCreature.Prefab.TryGetComponent(ref character)) { registeredCreature.applyCharacterStats(character); } } } [NullableContext(2)] private void applyCharacterStats(Character character) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)character == (Object)null)) { CreatureConfig creatureConfig = creatureConfigs[this]; if (IsConfigured("Health")) { character.m_health = creatureConfig.Health.get(); } if (IsConfigured("RegenAllHpTime")) { (typeof(Character).GetField("m_regenAllHPTime", BindingFlags.Instance | BindingFlags.Public) ?? typeof(Character).GetField("m_regenAllHpTime", BindingFlags.Instance | BindingFlags.Public))?.SetValue(character, creatureConfig.RegenAllHpTime.get()); } if (IsConfigured("BluntModifier")) { character.m_damageModifiers.m_blunt = creatureConfig.BluntModifier.get(); } if (IsConfigured("SlashModifier")) { character.m_damageModifiers.m_slash = creatureConfig.SlashModifier.get(); } if (IsConfigured("PierceModifier")) { character.m_damageModifiers.m_pierce = creatureConfig.PierceModifier.get(); } if (IsConfigured("ChopModifier")) { character.m_damageModifiers.m_chop = creatureConfig.ChopModifier.get(); } if (IsConfigured("PickaxeModifier")) { character.m_damageModifiers.m_pickaxe = creatureConfig.PickaxeModifier.get(); } if (IsConfigured("FireModifier")) { character.m_damageModifiers.m_fire = creatureConfig.FireModifier.get(); } if (IsConfigured("FrostModifier")) { character.m_damageModifiers.m_frost = creatureConfig.FrostModifier.get(); } if (IsConfigured("LightningModifier")) { character.m_damageModifiers.m_lightning = creatureConfig.LightningModifier.get(); } if (IsConfigured("PoisonModifier")) { character.m_damageModifiers.m_poison = creatureConfig.PoisonModifier.get(); } if (IsConfigured("SpiritModifier")) { character.m_damageModifiers.m_spirit = creatureConfig.SpiritModifier.get(); } } } internal static void ApplyCreatureStats(ZNetScene __instance) { foreach (Creature registeredCreature in registeredCreatures) { registeredCreature.applyCharacterStats(registeredCreature.Prefab.GetComponent()); } } private void updateSpawnData(SpawnData spawnData) { //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_0079: 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_008a: 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_0081: Unknown result type (might be due to invalid IL or missing references) CreatureConfig cfg = creatureConfigs[this]; spawnData.m_enabled = cfg.Spawn.get() != SpawnOption.Disabled; spawnData.m_biome = cfg.Biome.get(); SpawnArea spawnArea = cfg.SpecificSpawnArea.get(); if (1 == 0) { } BiomeArea biomeArea = (BiomeArea)(spawnArea switch { SpawnArea.Center => 2, SpawnArea.Edge => 1, _ => 3, }); if (1 == 0) { } spawnData.m_biomeArea = biomeArea; spawnData.m_maxSpawned = cfg.Maximum.get(); spawnData.m_spawnInterval = cfg.CheckSpawnInterval.get(); spawnData.m_spawnChance = cfg.SpawnChance.get(); spawnData.m_requiredGlobalKey = ((InternalName)typeof(GlobalKey).GetMember(cfg.RequiredGlobalKey.get().ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName; spawnData.m_requiredEnvironments = (from Weather w in Enum.GetValues(typeof(Weather)) where (w & cfg.RequiredWeather.get()) != 0 select ((InternalName)typeof(Weather).GetMember(w.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).ToList(); spawnData.m_groupSizeMin = (int)cfg.GroupSize.get().min; spawnData.m_groupSizeMax = (int)cfg.GroupSize.get().max; SpawnTime spawnTime = cfg.SpecificSpawnTime.get(); bool spawnAtNight = (uint)(spawnTime - 1) <= 1u; spawnData.m_spawnAtNight = spawnAtNight; spawnTime = cfg.SpecificSpawnTime.get(); spawnAtNight = ((spawnTime == SpawnTime.Day || spawnTime == SpawnTime.Always) ? true : false); spawnData.m_spawnAtDay = spawnAtNight; spawnData.m_minAltitude = cfg.RequiredAltitude.get().min; spawnData.m_maxAltitude = cfg.RequiredAltitude.get().max; Forest forest = cfg.ForestSpawn.get(); spawnAtNight = ((forest == Forest.Yes || forest == Forest.Both) ? true : false); spawnData.m_inForest = spawnAtNight; forest = cfg.ForestSpawn.get(); spawnAtNight = (uint)(forest - 1) <= 1u; spawnData.m_outsideForest = spawnAtNight; spawnData.m_minOceanDepth = cfg.RequiredOceanDepth.get().min; spawnData.m_maxOceanDepth = cfg.RequiredOceanDepth.get().max; spawnData.m_huntPlayer = cfg.AttackImmediately.get() == Toggle.On; spawnData.m_groundOffset = cfg.SpawnAltitude.get(); spawnData.m_maxLevel = ((cfg.CanHaveStars.get() != 0) ? 1 : 3); } [HarmonyPriority(700)] internal static void AddToSpawnSystem(SpawnSystem __instance) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown SpawnSystemList val = __instance.m_spawnLists.First(); foreach (SpawnData lastRegisteredSpawn in lastRegisteredSpawns) { val.m_spawners.Remove(lastRegisteredSpawn); } lastRegisteredSpawns.Clear(); foreach (Creature registeredCreature in registeredCreatures) { SpawnData val2 = new SpawnData { m_name = ((Object)registeredCreature.Prefab).name, m_prefab = registeredCreature.Prefab }; registeredCreature.updateSpawnData(val2); lastRegisteredSpawns.Add(val2); val.m_spawners.Add(val2); } } private static ConfigEntry pluginConfig<[Nullable(2)] T>(string group, string name, T value, ConfigDescription description) { ConfigEntry val = plugin.Config.Bind(group, name, value, description); configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T)) .Invoke(configSync, new object[1] { val }); return val; } private static ConfigEntry pluginConfig<[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 pluginConfig(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } } [NullableContext(1)] [Nullable(0)] [PublicAPI] public class LocalizeKey { private static readonly List keys = new List(); public readonly string Key; public readonly Dictionary Localizations = new Dictionary(); 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; if (Localization.m_instance != null) { 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.m_instance != null) { 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, __instance.Localize(value2)); } } } } public enum HpDisplayFormat { CurrentOnly, CurrentAndMax } [NullableContext(1)] [Nullable(0)] internal static class CreatureHpDisplay { [Nullable(2)] internal static ConfigEntry CfgShowOnAllCreatures; [Nullable(2)] internal static ConfigEntry CfgShowOnPlayers; [Nullable(2)] internal static ConfigEntry CfgFormat; private static readonly Dictionary hpTexts = new Dictionary(); private static readonly Dictionary lastHpCache = new Dictionary(); private static string GetBaseName(Character c) { return ((Object)((Component)c).gameObject).name.Replace("(Clone)", "").Trim(); } private static bool ShouldShow(Character c) { if (c.IsBoss()) { return false; } if (c.IsPlayer()) { ConfigEntry cfgShowOnPlayers = CfgShowOnPlayers; return cfgShowOnPlayers != null && cfgShowOnPlayers.Value == Toggle.On; } ConfigEntry cfgShowOnAllCreatures = CfgShowOnAllCreatures; return (cfgShowOnAllCreatures != null && cfgShowOnAllCreatures.Value == Toggle.On) || Creature.IsRegisteredCreature(GetBaseName(c)); } internal static void RegisterConfigs(bool saveOnConfigSet) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown if (CfgShowOnAllCreatures == null) { CfgShowOnAllCreatures = pluginConfig("! HP Display", "Show HP on all creatures", Toggle.Off, new ConfigDescription("Show numeric HP above the health bar for ALL creatures (vanilla, mods, etc). When Off, shows only for creatures registered by this mod.", (AcceptableValueBase)null, Array.Empty())); CfgShowOnPlayers = pluginConfig("! HP Display", "Show HP on players", Toggle.Off, new ConfigDescription("Show numeric HP above the health bar for other players.", (AcceptableValueBase)null, Array.Empty())); CfgFormat = pluginConfig("! HP Display", "HP display format", HpDisplayFormat.CurrentAndMax, new ConfigDescription("Format of the value displayed on the creatures' HP bar. CurrentOnly (xxx) CurrentAndMax (xxx/xxx)", (AcceptableValueBase)null, Array.Empty())); CfgShowOnAllCreatures.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { hpTexts.Clear(); }; CfgShowOnPlayers.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { hpTexts.Clear(); }; CfgFormat.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { hpTexts.Clear(); }; } } private static ConfigEntry pluginConfig<[Nullable(2)] T>(string group, string name, T value, ConfigDescription desc) { MethodInfo methodInfo = typeof(Creature).GetMethods(BindingFlags.Static | BindingFlags.NonPublic).FirstOrDefault([NullableContext(0)] (MethodInfo m) => { int result; if (m.Name == "pluginConfig" && m.IsGenericMethodDefinition) { ParameterInfo[] parameters = m.GetParameters(); if (parameters != null && parameters.Length == 4) { result = ((parameters[3].ParameterType == typeof(ConfigDescription)) ? 1 : 0); goto IL_0044; } } result = 0; goto IL_0044; IL_0044: return (byte)result != 0; })?.MakeGenericMethod(typeof(T)); return (ConfigEntry)methodInfo.Invoke(null, new object[4] { group, name, value, desc }); } internal static void Postfix_ShowHud(EnemyHud __instance, Character c, bool isMount) { //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) if (isMount || !ShouldShow(c) || hpTexts.ContainsKey(c) || !(Traverse.Create((object)__instance).Field("m_huds").GetValue() is IDictionary dictionary) || !dictionary.Contains(c)) { return; } object obj = dictionary[c]; object value = Traverse.Create(obj).Field("m_gui").GetValue(); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { return; } Transform val2 = val.transform.Find("Health"); if ((Object)(object)val2 == (Object)null) { return; } Transform val3 = val2.Find("CreatureHPText"); if ((Object)(object)val3 != (Object)null) { hpTexts[c] = ((Component)val3).GetComponent(); return; } object value2 = Traverse.Create(obj).Field("m_name").GetValue(); TextMeshProUGUI val4 = (TextMeshProUGUI)((value2 is TextMeshProUGUI) ? value2 : null); if (!((Object)(object)val4 == (Object)null)) { GameObject val5 = Object.Instantiate(((Component)val4).gameObject, val2, false); ((Object)val5).name = "CreatureHPText"; TextMeshProUGUI component = val5.GetComponent(); ((TMP_Text)component).fontSize = 12f; ((TMP_Text)component).fontStyle = (FontStyles)1; ((TMP_Text)component).alignment = (TextAlignmentOptions)514; ((Graphic)component).color = Color.white; ((TMP_Text)component).outlineWidth = 0.2f; ((TMP_Text)component).outlineColor = Color32.op_Implicit(Color.black); ((TMP_Text)component).text = ""; RectTransform component2 = val5.GetComponent(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; val5.SetActive(true); hpTexts[c] = component; } } internal static void Postfix_UpdateHuds(EnemyHud __instance) { List list = new List(); foreach (KeyValuePair hpText in hpTexts) { if ((Object)(object)hpText.Key == (Object)null) { continue; } if ((Object)(object)hpText.Value == (Object)null) { list.Add(hpText.Key); continue; } bool flag = ShouldShow(hpText.Key); ((Component)hpText.Value).gameObject.SetActive(flag); if (!flag) { continue; } int num = Mathf.CeilToInt(hpText.Key.GetHealth()); if (!lastHpCache.TryGetValue(hpText.Key, out var value) || value != num) { lastHpCache[hpText.Key] = num; ConfigEntry cfgFormat = CfgFormat; if (cfgFormat != null && cfgFormat.Value == HpDisplayFormat.CurrentAndMax) { int num2 = Mathf.CeilToInt(hpText.Key.GetMaxHealth()); ((TMP_Text)hpText.Value).text = $"{num}/{num2}"; } else { ((TMP_Text)hpText.Value).text = num.ToString(); } } } foreach (Character item in list) { hpTexts.Remove(item); lastHpCache.Remove(item); } } } [Nullable(0)] [NullableContext(1)] public static class LocalizationCache { private static readonly Dictionary localizations = new Dictionary(); internal static void LocalizationPostfix(Localization __instance, string language) { string key = localizations.FirstOrDefault([NullableContext(0)] (KeyValuePair l) => l.Value == __instance).Key; if (key != null) { localizations.Remove(key); } if (!localizations.ContainsKey(language)) { localizations.Add(language, __instance); } } public static Localization ForLanguage([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; } } [Nullable(0)] [NullableContext(1)] public static class PrefabManager { [Nullable(0)] private struct BundleId { [UsedImplicitly] public string assetBundleFileName; [UsedImplicitly] public string folderName; } private static readonly Dictionary bundleCache; private static readonly List prefabs; static PrefabManager() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown bundleCache = new Dictionary(); prefabs = new List(); Harmony val = new Harmony("org.bepinex.helpers.CreatureManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PrefabManager), "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(Creature), "ApplyCreatureStats", (Type[])null, (Type[])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(Creature.DropList), "AddDropsToCreature", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(SpawnSystem), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Creature), "AddToSpawnSystem", (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(Creature), "UpdateCreatures", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Creature), "Patch_FejdStartup", (Type[])null, (Type[])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); if (!typeof(Biome).GetCustomAttributes(typeof(FlagsAttribute), inherit: false).Any()) { val.Patch((MethodBase)AccessTools.Method(typeof(Biome).GetType(), "GetCustomAttributes", new Type[2] { typeof(Type), typeof(bool) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PrefabManager), "BiomeIsFlags", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void BiomeIsFlags(Type __instance, Type attributeType, ref object[] __result) { if (__instance == typeof(Biome) && attributeType == typeof(FlagsAttribute)) { __result = new object[1] { new FlagsAttribute() }; } } 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 dictionary = bundleCache; AssetBundle? obj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)([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 GameObject RegisterPrefab(AssetBundle assets, string prefabName) { GameObject val = assets.LoadAsset(prefabName); prefabs.Add(val); return val; } [HarmonyPriority(700)] private static void Patch_ZNetSceneAwake(ZNetScene __instance) { foreach (GameObject prefab in prefabs) { __instance.m_prefabs.Add(prefab); } } } } namespace Transmog { public static class RegistroDeCriaturas { public static void RegistrarTudo() { Creature creature = new Creature("mar_transcreatures", "Transmog_Human_Man").EnableStars(enabled: true, isConfigurable: false).EnableTaming(enabled: false, isConfigurable: false).EnableSpawning(enabled: false, isConfigurable: false); creature.Localize().Portuguese_Brazilian("Humano").English("Human"); Creature creature2 = new Creature("mar_transcreatures", "Transmog_Human_Woman").EnableStars(enabled: true, isConfigurable: false).EnableTaming(enabled: false, isConfigurable: false).EnableSpawning(enabled: false, isConfigurable: false); creature2.Localize().Portuguese_Brazilian("Humana").English("Human Woman"); Creature creature3 = new Creature("mar_transcreatures", "Transmog_Elven_Man").EnableStars(enabled: true, isConfigurable: false).EnableTaming(enabled: false, isConfigurable: false).EnableSpawning(enabled: false, isConfigurable: false); creature3.Localize().Portuguese_Brazilian("Elfo").English("Elven"); Creature creature4 = new Creature("mar_transcreatures", "Transmog_Elven_Woman").EnableStars(enabled: true, isConfigurable: false).EnableTaming(enabled: false, isConfigurable: false).EnableSpawning(enabled: false, isConfigurable: false); creature4.Localize().Portuguese_Brazilian("Elfa").English("Elven Woman"); Creature creature5 = new Creature("mar_transcreatures", "Transmog_Elf_Woman").EnableStars(enabled: true, isConfigurable: false).EnableTaming(enabled: false, isConfigurable: false).EnableSpawning(enabled: false, isConfigurable: false); creature5.Localize().Portuguese_Brazilian("Elfica").English("Elf Woman"); Creature creature6 = new Creature("mar_transcreatures", "Transmog_Dwarf_Man").EnableStars(enabled: true, isConfigurable: false).EnableTaming(enabled: false, isConfigurable: false).EnableSpawning(enabled: false, isConfigurable: false); creature6.Localize().Portuguese_Brazilian("Anão").English("Dwarf"); Creature creature7 = new Creature("mar_transcreatures", "Transmog_Dwarf_Woman").EnableStars(enabled: true, isConfigurable: false).EnableTaming(enabled: false, isConfigurable: false).EnableSpawning(enabled: false, isConfigurable: false); creature7.Localize().Portuguese_Brazilian("Anã").English("Dwarf Woman"); GameObject val = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_crit_transmog"); GameObject val2 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_HotGround_transmog"); GameObject val3 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_slide_transmog"); GameObject val4 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "vfx_perfectblock_transmog"); GameObject val5 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "vfx_player_death_transmog"); GameObject val6 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "vfx_player_hit_transmog"); GameObject val7 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "vfx_tar_surface_transmog"); GameObject val8 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "vfx_water_surface_transmog"); GameObject val9 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_drop_transmog"); GameObject val10 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_eat_transmog"); GameObject val11 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_equip_transmog"); GameObject val12 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_gui_button_transmog"); GameObject val13 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_hit_transmog"); GameObject val14 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_jump_transmog"); GameObject val15 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_perfectblock_transmog"); GameObject val16 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_pickup_transmog"); GameObject val17 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_footstep_climb_transmog"); GameObject val18 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_footstep_jog_transmog"); GameObject val19 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_footstep_mud_jog_transmog"); GameObject val20 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_footstep_mud_run_transmog"); GameObject val21 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_footstep_run_transmog"); GameObject val22 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_footstep_snow_jog_transmog"); GameObject val23 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_footstep_snow_run_transmog"); GameObject val24 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "fx_footstep_water_transmog"); GameObject val25 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_footstep_sneak_transmog"); GameObject val26 = ItemManager.PrefabManager.RegisterPrefab("mar_transcreatures", "sfx_footstep_swim_transmog"); } } [NullableContext(1)] [Nullable(0)] [BepInPlugin("marlthon.Transmog", "Transmog", "0.0.1")] public class TransmogPlugin : BaseUnityPlugin { [NullableContext(0)] public enum Toggle { On = 1, Off = 0 } [NullableContext(0)] [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class DebugDuplicatePrefabs { [NullableContext(1)] private static void Prefix(ZNetScene __instance) { Dictionary dictionary = new Dictionary(); foreach (GameObject prefab in __instance.m_prefabs) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); if (dictionary.TryGetValue(stableHashCode, out var value)) { Debug.LogError((object)$"[DUPLICATE PREFAB] Hash: {stableHashCode} | New: {((Object)prefab).name} | Existing: {value}"); } else { dictionary[stableHashCode] = ((Object)prefab).name; } } } } internal const string ModName = "Transmog"; internal const string ModVersion = "0.0.1"; internal const string Author = "marlthon"; private const string ModGUID = "marlthon.Transmog"; private static string ConfigFileName = "marlthon.Transmog.cfg"; private static string ConfigFileFullPath; internal static string ConnectionError; private readonly Harmony _harmony = new Harmony("marlthon.Transmog"); public static readonly ManualLogSource CreatureQuestsLogger; public static readonly ConfigSync ConfigSync; public static TransmogPlugin plugin; public static GameObject m_root; private static ConfigEntry _serverConfigLocked; public static ConfigEntry _hidePlayerName; private FileSystemWatcher _configWatcher = null; public void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown plugin = this; m_root = new GameObject("root"); Object.DontDestroyOnLoad((Object)(object)m_root); m_root.SetActive(false); CreatureFormManager creatureFormManager = new CreatureFormManager(m_root); InitConfigs(); Transformation.SetupCustomizations(); VanillaSouls.Setup(); RegistroDeCriaturas.RegistrarTudo(); Runes.Register(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); SetupWatcher(); } private void InitConfigs() { _serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only."); ConfigSync.AddLockingConfigEntry(_serverConfigLocked); _hidePlayerName = config("2 - Settings", "Hide Player Name", Toggle.On, "If on, when player is a creature, hide name tag"); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { _configWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); _configWatcher.Changed += ReadConfigValues; _configWatcher.Created += ReadConfigValues; _configWatcher.Renamed += ReadConfigValues; _configWatcher.IncludeSubdirectories = true; _configWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; _configWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { ((BaseUnityPlugin)this).Config.Reload(); } catch { CreatureQuestsLogger.LogError((object)("There was an issue loading your " + ConfigFileName)); CreatureQuestsLogger.LogError((object)"Please check your config entries for spelling and format!"); } } public ConfigEntry config<[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 val2 = ((BaseUnityPlugin)this).Config.Bind(group, name, value, val); SyncedConfigEntry syncedConfigEntry = ConfigSync.AddConfigEntry(val2); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val2; } public ConfigEntry config<[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()), synchronizedSetting); } static TransmogPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; ConnectionError = ""; CreatureQuestsLogger = Logger.CreateLogSource("Transmog"); ConfigSync = new ConfigSync("marlthon.Transmog") { DisplayName = "Transmog", CurrentVersion = "0.0.1", MinimumRequiredVersion = "0.0.1" }; plugin = null; m_root = null; _serverConfigLocked = null; _hidePlayerName = null; } } [NullableContext(1)] [Nullable(0)] public static class Runes { [NullableContext(0)] [HarmonyPatch(typeof(Player), "GetAvailableRecipes")] private static class FilterDisabledGemRecipesPatch { [NullableContext(1)] private static void Postfix(ref List available) { available.RemoveAll([NullableContext(1)] (Recipe recipe) => !IsRecipeEnabled(recipe)); } } [Nullable(0)] [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] private static class BlockDisabledGemCraftingPatch { private static readonly FieldInfo CraftRecipeField = AccessTools.Field(typeof(InventoryGui), "m_craftRecipe"); private static bool Prefix(InventoryGui __instance) { object? value = CraftRecipeField.GetValue(__instance); Recipe val = (Recipe)((value is Recipe) ? value : null); return val == null || IsRecipeEnabled(val); } } private const string AssetBundleName = "mar_transcreatures"; private static readonly Dictionary> RecipeEnabledConfigs = new Dictionary>(StringComparer.Ordinal); public static void Register() { RegisterRune("TransmogGem_ElvenMan", "Gema Elfica", "Elven Gem", "Use para assumir a forma de um elfo por tempo limitado.", "Use to assume the form of an elven man for a limited time."); RegisterRune("TransmogGem_ElvenWoman", "Gema Elfica Feminina", "Elven Woman Gem", "Use para assumir a forma de uma elfa por tempo limitado.", "Use to assume the form of an elven woman for a limited time."); RegisterRune("TransmogGem_ElfWoman", "Gema de Elfa", "Elf Woman Gem", "Use para assumir a forma de uma elfa por tempo limitado.", "Use to assume the form of an elf woman for a limited time."); RegisterRune("TransmogGem_HumanMan", "Gema Humana", "Human Gem", "Use para assumir a forma de um humano por tempo limitado.", "Use to assume the form of a human man for a limited time."); RegisterRune("TransmogGem_HumanWoman", "Gema Humana Feminina", "Human Woman Gem", "Use para assumir a forma de uma humana por tempo limitado.", "Use to assume the form of a human woman for a limited time."); RegisterRune("TransmogGem_DwarfMan", "Gema Anã", "Dwarf Gem", "Use para assumir a forma de um anão por tempo limitado.", "Use to assume the form of a dwarf for a limited time."); RegisterRune("TransmogGem_DwarfWoman", "Gema Anã Feminina", "Dwarf Woman Gem", "Use para assumir a forma de uma anã por tempo limitado.", "Use to assume the form of a dwarf woman for a limited time."); } private static void RegisterRune(string prefabName, string ptName, string enName, string ptDescription, string enDescription) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) AssetBundle val = ItemManager.PrefabManager.RegisterAssetBundle("mar_transcreatures"); GameObject val2 = val.LoadAsset(prefabName); if ((Object)(object)val2 == (Object)null) { TransmogPlugin.CreatureQuestsLogger.LogWarning((object)("Could not find transmog gem prefab '" + prefabName + "' in assetbundle 'mar_transcreatures'.")); return; } Item item = new Item(val2) { Configurable = Configurability.Recipe }; item.Crafting.Add(CraftingTable.Workbench, 1); item.RequiredItems.Add("SurtlingCore", 1); item.RequiredItems.Add("Coins", 10); ConfigEntry value = (ConfigEntry)(object)(item.RecipeIsActive = (ConfigEntryBase)(object)TransmogPlugin.plugin.config(enName, "Recipe Enabled", ItemManager.Toggle.Off, "If on, this transformation gem can be crafted.")); RecipeEnabledConfigs[prefabName] = value; ItemDrop component = item.Prefab.GetComponent(); SharedData shared = component.m_itemData.m_shared; shared.m_name = "$item_" + prefabName; shared.m_description = "$item_" + prefabName + "_description"; shared.m_itemType = (ItemType)2; shared.m_maxStackSize = 1; shared.m_useDurability = true; shared.m_canBeReparied = false; shared.m_consumeStatusEffect = null; item.Name.English(enName).Portuguese_Brazilian(ptName); item.Description.English(enDescription).Portuguese_Brazilian(ptDescription); } public static bool IsRecipeEnabled(Recipe recipe) { if ((Object)(object)recipe == (Object)null || (Object)(object)recipe.m_item == (Object)null) { return true; } string name = ((Object)((Component)recipe.m_item).gameObject).name; ConfigEntry value; return !RecipeEnabledConfigs.TryGetValue(name, out value) || value.Value == ItemManager.Toggle.On; } } } namespace Transmog.Source { [NullableContext(1)] [Nullable(0)] public class CommandData { [NullableContext(0)] [HarmonyPatch(typeof(Terminal), "updateSearch")] private static class Terminal_UpdateSearch_Patch { [NullableContext(1)] private static bool Prefix(Terminal __instance, string word) { if ((Object)(object)__instance.m_search == (Object)null) { return true; } string[] array = ((TMP_InputField)__instance.m_input).text.Split(new char[1] { ' ' }); if (array.Length < 3) { return true; } if (array[0] != m_startCommand) { return true; } return HandleSearch(__instance, word, array); } } [HarmonyPatch(typeof(Terminal), "tabCycle")] [NullableContext(0)] private static class Terminal_TabCycle_Patch { [NullableContext(1)] private static bool Prefix(Terminal __instance, string word, [Nullable(new byte[] { 2, 1 })] List options, bool usePrefix) { if (options == null || options.Count == 0) { return true; } usePrefix = usePrefix && __instance.m_tabPrefix > '\0'; if (usePrefix) { if (word.Length < 1 || word[0] != __instance.m_tabPrefix) { return true; } word = word.Substring(1); } return HandleTabCycle(__instance, word, options, usePrefix); } } public static string m_startCommand = "transmog"; public static Dictionary m_commands = new Dictionary(); public readonly string m_description; private readonly bool m_isSecret; private readonly bool m_adminOnly; private readonly Func m_command; [Nullable(new byte[] { 2, 1, 1 })] private readonly Func> m_optionFetcher; public bool Run(ConsoleEventArgs args) { return !IsAdmin() || m_command(args); } private bool IsAdmin() { if (!Object.op_Implicit((Object)(object)ZNet.m_instance)) { return true; } if (!m_adminOnly || ZNet.m_instance.LocalPlayerIsAdminOrHost()) { return true; } Debug.LogWarning((object)"Admin only command"); return false; } public bool IsSecret() { return m_isSecret; } public List FetchOptions() { return (m_optionFetcher == null) ? new List() : m_optionFetcher(); } public bool HasOptions() { return m_optionFetcher != null; } public CommandData(string input, string description, Func command, [Nullable(new byte[] { 2, 1, 1 })] Func> optionsFetcher = null, bool isSecret = false, bool adminOnly = false) { m_description = description; m_command = command; m_isSecret = isSecret; m_commands[input] = this; m_optionFetcher = optionsFetcher; m_adminOnly = adminOnly; } private static bool HandleSearch(Terminal __instance, string word, string[] strArray) { if (!m_commands.TryGetValue(strArray[1], out var value)) { return true; } if (value.HasOptions() && strArray.Length == 3) { List list = value.FetchOptions(); string currentSearch = strArray[2]; List list2; if (!Utility.IsNullOrWhiteSpace(currentSearch)) { int num = list.IndexOf(currentSearch); list2 = ((num != -1) ? list.GetRange(num, list.Count - num) : list); list2 = list2.FindAll((string x) => x.ToLower().Contains(currentSearch.ToLower())); } else { list2 = list; } if (list2.Count <= 0) { __instance.m_search.text = value.m_description; } else { __instance.m_lastSearch.Clear(); __instance.m_lastSearch.AddRange(list2); __instance.m_lastSearch.Remove(word); __instance.m_search.text = ""; int num2 = 10; int num3 = Math.Min(__instance.m_lastSearch.Count, num2); for (int i = 0; i < num3; i++) { string text = __instance.m_lastSearch[i]; TMP_Text search = __instance.m_search; search.text = search.text + text + " "; } if (__instance.m_lastSearch.Count <= num2) { return false; } int num4 = __instance.m_lastSearch.Count - num2; TMP_Text search2 = __instance.m_search; search2.text += $"... {num4} more."; } } else { __instance.m_search.text = value.m_description; } return false; } private static bool HandleTabCycle(Terminal __instance, string word, List options, bool usePrefix) { string text = ((TMP_InputField)__instance.m_input).text; string[] array = text.Split(new char[1] { ' ' }); if (array.Length < 2 || !string.Equals(array[0], m_startCommand, StringComparison.CurrentCultureIgnoreCase) || !m_commands.ContainsKey(array[1].ToLower())) { return true; } if (__instance.m_tabCaretPosition == -1) { __instance.m_tabOptions.Clear(); __instance.m_tabCaretPosition = ((TMP_InputField)__instance.m_input).caretPosition; word = word.ToLower(); __instance.m_tabLength = word.Length; if (__instance.m_tabLength == 0) { __instance.m_tabOptions.AddRange(options); } else { foreach (string option in options) { if (option != null && option.Length > __instance.m_tabLength && option.Substring(0, __instance.m_tabLength).ToLower() == word) { __instance.m_tabOptions.Add(option); } } } __instance.m_tabOptions.Sort(); __instance.m_tabIndex = -1; } if (__instance.m_tabOptions.Count == 0) { __instance.m_tabOptions.AddRange(__instance.m_lastSearch); } if (__instance.m_tabOptions.Count == 0) { return false; } if (++__instance.m_tabIndex >= __instance.m_tabOptions.Count) { __instance.m_tabIndex = 0; } if (__instance.m_tabCaretPosition - __instance.m_tabLength >= 0) { int num = 0; int num2 = 0; for (int i = 0; i < text.Length; i++) { if (text[i] == ' ') { num++; if (num == 2) { num2 = i + 1; break; } } } if (array.Length >= 3 && num2 > 0) { string text2 = text.Substring(0, num2); ((TMP_InputField)__instance.m_input).text = text2 + __instance.m_tabOptions[__instance.m_tabIndex]; } else if (array.Length == 2) { ((TMP_InputField)__instance.m_input).text = text + " " + __instance.m_tabOptions[__instance.m_tabIndex]; } } int tabCaretPositionEnd = (((TMP_InputField)__instance.m_input).caretPosition = ((TMP_InputField)__instance.m_input).text.Length); __instance.m_tabCaretPositionEnd = tabCaretPositionEnd; return false; } } [HarmonyPatch(typeof(Terminal), "Awake")] public static class Commands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleOptionsFetcher <>9__0_1; internal List b__0_1() { List list = new List { "reset", "target" }; list.AddRange(CreatureFormManager.GetSourceToCreatureFormDict().Keys); return list; } } [NullableContext(1)] private static void Postfix(Terminal __instance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown ConsoleEvent val = delegate(ConsoleEventArgs args) { if (!__instance.IsCheatsEnabled()) { __instance.AddString("Comando 'transmog' requer cheats ativados."); } else if (args.Length < 2) { __instance.AddString("Uso: transmog [nome_da_criatura] | reset | target [jogador] [criatura]"); } else { string text = args[1].ToLower(); if (text == "reset") { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { TransmogMaganger transmogMaganger = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffects().OfType() .FirstOrDefault(); if ((Object)(object)transmogMaganger != (Object)null) { ((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect((StatusEffect)(object)transmogMaganger, false); } else { CreatureFormManager.CreatureForm.Revert(); } __instance.AddString("Forma resetada para o jogador."); } } else if (text == "target") { if (args.Length < 4) { __instance.AddString("Uso: transmog target [nome_do_jogador] [nome_da_criatura]"); } else { string playerName = args[2]; string text2 = args[3]; Player val3 = ((IEnumerable)Player.GetAllPlayers()).FirstOrDefault((Func)((Player p) => p.GetPlayerName().ToLower() == playerName.ToLower())); if ((Object)(object)val3 == (Object)null) { __instance.AddString("Jogador '" + playerName + "' não encontrado."); } else { CreatureFormManager.CreatureForm creature = CreatureFormManager.GetCreature(text2); if (creature == null) { __instance.AddString("Criatura '" + text2 + "' não é uma transformação válida."); } else { CreatureFormManager.TriggerTransformation(val3, text2, creature.Duration); __instance.AddString("Acionando transformação para " + val3.GetPlayerName() + " em " + text2 + "."); } } } } else { string text3 = string.Join(" ", args.Args.Skip(1)); CreatureFormManager.CreatureForm creature2 = CreatureFormManager.GetCreature(text3); if (creature2 == null) { __instance.AddString("Criatura '" + text3 + "' não encontrada."); } else if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect((StatusEffect)(object)creature2.StatusEffect, false, 0, 0f); __instance.AddString("Transformando em " + text3 + "."); } } } }; object obj = <>c.<>9__0_1; if (obj == null) { ConsoleOptionsFetcher val2 = delegate { List list = new List { "reset", "target" }; list.AddRange(CreatureFormManager.GetSourceToCreatureFormDict().Keys); return list; }; <>c.<>9__0_1 = val2; obj = (object)val2; } new ConsoleCommand("transmog", "Uso: transmog [criatura] | reset | target [jogador] [criatura]", val, true, false, false, false, false, (ConsoleOptionsFetcher)obj, false, false, false); } } public static class HideName { [HarmonyPatch(typeof(EnemyHud), "ShowHud")] private static class EnemyHud_ShowHud_Patch { [NullableContext(1)] private static bool Prefix(EnemyHud __instance, Character c, bool isMount) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown if (TransmogPlugin._hidePlayerName.Value == TransmogPlugin.Toggle.Off) { return true; } if (__instance.m_huds.TryGetValue(c, out var _)) { return true; } if (!CreatureFormManager.TryGetCreature(((Object)c).name, out var creatureForm)) { return true; } GameObject val = ((!isMount) ? __instance.m_baseHud : __instance.m_baseHudMount); HudData val2 = new HudData(); val2.m_character = c; val2.m_ai = ((Component)c).GetComponent(); val2.m_gui = Object.Instantiate(val, __instance.m_hudRoot.transform); val2.m_gui.SetActive(true); val2.m_healthFast = ((Component)val2.m_gui.transform.Find("Health/health_fast")).GetComponent(); val2.m_healthSlow = ((Component)val2.m_gui.transform.Find("Health/health_slow")).GetComponent(); Transform val3 = val2.m_gui.transform.Find("Health/health_fast_friendly"); if (Object.op_Implicit((Object)(object)val3)) { val2.m_healthFastFriendly = ((Component)val3).GetComponent(); } if (isMount) { val2.m_stamina = ((Component)val2.m_gui.transform.Find("Stamina/stamina_fast")).GetComponent(); val2.m_staminaText = ((Component)val2.m_gui.transform.Find("Stamina/StaminaText")).GetComponent(); val2.m_healthText = ((Component)val2.m_gui.transform.Find("Health/HealthText")).GetComponent(); } ref RectTransform level = ref val2.m_level2; Transform obj = val2.m_gui.transform.Find("level_2"); level = (RectTransform)(object)((obj is RectTransform) ? obj : null); ref RectTransform level2 = ref val2.m_level3; Transform obj2 = val2.m_gui.transform.Find("level_3"); level2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); ref RectTransform alerted = ref val2.m_alerted; Transform obj3 = val2.m_gui.transform.Find("Alerted"); alerted = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null); ref RectTransform aware = ref val2.m_aware; Transform obj4 = val2.m_gui.transform.Find("Aware"); aware = (RectTransform)(object)((obj4 is RectTransform) ? obj4 : null); val2.m_name = ((Component)val2.m_gui.transform.Find("Name")).GetComponent(); ((TMP_Text)val2.m_name).text = Localization.instance.Localize(creatureForm.CreatureSharedName); val2.m_isMount = isMount; __instance.m_huds.Add(c, val2); return false; } } [HarmonyPatch(typeof(EnemyHud), "UpdateHuds")] private static class EnemyHud_UpdateHuds_Patch { [NullableContext(1)] private static bool Prefix(EnemyHud __instance, Player player, Sadle sadle, float dt) { //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) if (TransmogPlugin._hidePlayerName.Value == TransmogPlugin.Toggle.Off) { return true; } Camera mainCamera = Utils.GetMainCamera(); if ((Object)(object)mainCamera == (Object)null) { return false; } Character val = (Object.op_Implicit((Object)(object)sadle) ? sadle.GetCharacter() : null); Character val2 = (Object.op_Implicit((Object)(object)player) ? player.GetHoverCreature() : null); Character val3 = null; foreach (KeyValuePair hud in __instance.m_huds) { HudData value = hud.Value; if ((Object)(object)value.m_character == (Object)null || !__instance.TestShow(value.m_character, true) || (Object)(object)value.m_character == (Object)(object)val) { if ((Object)(object)val3 == (Object)null) { val3 = value.m_character; Object.Destroy((Object)(object)value.m_gui); } continue; } if ((Object)(object)value.m_character == (Object)(object)val2) { value.m_hoverTimer = 0f; } value.m_hoverTimer += dt; float healthPercentage = value.m_character.GetHealthPercentage(); CreatureFormManager.CreatureForm creatureForm; bool flag = CreatureFormManager.TryGetCreature(((Object)value.m_character).name, out creatureForm); if ((value.m_character.IsPlayer() && !flag) || value.m_character.IsBoss() || value.m_isMount || (double)value.m_hoverTimer < (double)__instance.m_hoverShowDuration) { value.m_gui.SetActive(true); int num = (flag ? 3 : value.m_character.GetLevel()); if (Object.op_Implicit((Object)(object)value.m_level2)) { ((Component)value.m_level2).gameObject.SetActive(num == 2); } if (Object.op_Implicit((Object)(object)value.m_level3)) { ((Component)value.m_level3).gameObject.SetActive(num == 3); } ((TMP_Text)value.m_name).text = Localization.instance.Localize(flag ? creatureForm.CreatureSharedName : value.m_character.GetHoverName()); if (!value.m_character.IsBoss() && !value.m_character.IsPlayer()) { bool flag2 = value.m_character.GetBaseAI().HaveTarget(); bool flag3 = value.m_character.GetBaseAI().IsAlerted(); ((Component)value.m_alerted).gameObject.SetActive(flag3); ((Component)value.m_aware).gameObject.SetActive(!flag3 && flag2); } if (flag) { ((Component)value.m_alerted).gameObject.SetActive(false); ((Component)value.m_aware).gameObject.SetActive(false); } } else { value.m_gui.SetActive(false); } value.m_healthSlow.SetValue(healthPercentage); if (Object.op_Implicit((Object)(object)value.m_healthFastFriendly)) { bool flag4 = !Object.op_Implicit((Object)(object)player) || BaseAI.IsEnemy((Character)(object)player, value.m_character); ((Component)value.m_healthFast).gameObject.SetActive(flag4); ((Component)value.m_healthFastFriendly).gameObject.SetActive(!flag4); value.m_healthFast.SetValue(healthPercentage); value.m_healthFastFriendly.SetValue(healthPercentage); } else { value.m_healthFast.SetValue(healthPercentage); } if (value.m_isMount) { if ((Object)(object)sadle == (Object)null) { continue; } float stamina = sadle.GetStamina(); float maxStamina = sadle.GetMaxStamina(); value.m_stamina.SetValue(stamina / maxStamina); TextMeshProUGUI healthText = value.m_healthText; string text = Mathf.CeilToInt(value.m_character.GetHealth()).ToString(); ((TMP_Text)healthText).text = text; TextMeshProUGUI staminaText = value.m_staminaText; string text2 = Mathf.CeilToInt(stamina).ToString(); ((TMP_Text)staminaText).text = text2; } if (!value.m_character.IsBoss() && value.m_gui.activeSelf) { Vector3 val4 = (value.m_character.IsPlayer() ? (value.m_character.GetHeadPoint() + Vector3.up * 0.3f) : ((!value.m_isMount) ? value.m_character.GetTopPoint() : (((Object)(object)player != (Object)null) ? (((Component)player).transform.position - ((Component)player).transform.up * 0.5f) : value.m_character.GetTopPoint()))); Vector3 val5 = Utils.WorldToScreenPointScaled(mainCamera, val4); if ((double)val5.x < 0.0 || (double)val5.x > (double)Screen.width || (double)val5.y < 0.0 || (double)val5.y > (double)Screen.height || (double)val5.z > 0.0) { value.m_gui.transform.position = val5; value.m_gui.SetActive(true); } else { value.m_gui.SetActive(false); } } } if (!((Object)(object)val3 != (Object)null)) { return false; } __instance.m_huds.Remove(val3); return false; } } } [Nullable(0)] [NullableContext(1)] internal static class TransmogConfigs { public static void BindDuration(CreatureFormManager.CreatureForm creatureForm, string group, string name, float defaultValue) { ApplyDuration(creatureForm, BindDurationConfig(group, name, defaultValue)); } public static ConfigEntry BindDurationConfig(string group, string name, float defaultValue) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return TransmogPlugin.plugin.config(group, name + " Duration", defaultValue, new ConfigDescription("Transformation duration in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 86400f), Array.Empty())); } public static void ApplyDuration(CreatureFormManager.CreatureForm creatureForm, ConfigEntry config) { creatureForm.Duration = config.Value; config.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { creatureForm.Duration = config.Value; }; } public static ConfigEntry BindTrophyCost(CreatureFormManager.CreatureForm creatureForm, string group, string name, int defaultValue) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown ConfigEntry config = TransmogPlugin.plugin.config(group, name + " Trophy Cost", defaultValue, new ConfigDescription("Number of matching trophies required to create one Soul.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 1000), Array.Empty())); creatureForm.TrophySoulCost = config.Value; config.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { creatureForm.TrophySoulCost = config.Value; }; return config; } } [Nullable(0)] [NullableContext(1)] public static class Transformation { private const string CustomTransformationConfigGroup = "3 - Custom Transformations"; public static void SetupCustomizations() { ConfigEntry humanManDuration = TransmogConfigs.BindDurationConfig("3 - Custom Transformations", "Transmog Human Man", 3600f); CreatureFormManager.ConfigureCreature("Transmog_Human_Man", delegate(CreatureFormManager.CreatureForm creatureForm) { creatureForm.UsePlayerAnimator = true; creatureForm.HideWeapons = false; creatureForm.HideArmor = false; creatureForm.HideHelmet = false; creatureForm.HeadTransform = "Head"; creatureForm.CameraMaxDistance = 8f; TransmogConfigs.ApplyDuration(creatureForm, humanManDuration); creatureForm.GenerateItem = false; creatureForm.EnableUseItem = false; creatureForm.EnableRuneItem = true; creatureForm.RuneItem = "TransmogGem_HumanMan"; ConfigureArmorVariants(creatureForm, 15); }); ConfigEntry humanWomanDuration = TransmogConfigs.BindDurationConfig("3 - Custom Transformations", "Transmog Human Woman", 3600f); CreatureFormManager.ConfigureCreature("Transmog_Human_Woman", delegate(CreatureFormManager.CreatureForm creatureForm) { creatureForm.UsePlayerAnimator = true; creatureForm.HideWeapons = false; creatureForm.HideArmor = false; creatureForm.HideHelmet = false; creatureForm.HeadTransform = "Head"; creatureForm.CameraMaxDistance = 8f; TransmogConfigs.ApplyDuration(creatureForm, humanWomanDuration); creatureForm.GenerateItem = false; creatureForm.EnableUseItem = false; creatureForm.EnableRuneItem = true; creatureForm.RuneItem = "TransmogGem_HumanWoman"; ConfigureArmorVariants(creatureForm, 15); }); ConfigEntry elvenManDuration = TransmogConfigs.BindDurationConfig("3 - Custom Transformations", "Transmog Elven Man", 3600f); CreatureFormManager.ConfigureCreature("Transmog_Elven_Man", delegate(CreatureFormManager.CreatureForm creatureForm) { creatureForm.UsePlayerAnimator = true; creatureForm.HideWeapons = false; creatureForm.HideArmor = false; creatureForm.HideHelmet = false; creatureForm.HeadTransform = "Head"; creatureForm.CameraMaxDistance = 8f; TransmogConfigs.ApplyDuration(creatureForm, elvenManDuration); creatureForm.GenerateItem = false; creatureForm.EnableUseItem = false; creatureForm.EnableRuneItem = true; creatureForm.RuneItem = "TransmogGem_ElvenMan"; ConfigureArmorVariants(creatureForm, 15); }); ConfigEntry elvenWomanDuration = TransmogConfigs.BindDurationConfig("3 - Custom Transformations", "Transmog Elven Woman", 3600f); CreatureFormManager.ConfigureCreature("Transmog_Elven_Woman", delegate(CreatureFormManager.CreatureForm creatureForm) { creatureForm.UsePlayerAnimator = true; creatureForm.HideWeapons = false; creatureForm.HideArmor = false; creatureForm.HideHelmet = false; creatureForm.HeadTransform = "Head"; creatureForm.CameraMaxDistance = 8f; TransmogConfigs.ApplyDuration(creatureForm, elvenWomanDuration); creatureForm.GenerateItem = false; creatureForm.EnableUseItem = false; creatureForm.EnableRuneItem = true; creatureForm.RuneItem = "TransmogGem_ElvenWoman"; ConfigureArmorVariants(creatureForm, 15); }); ConfigEntry elfWomanDuration = TransmogConfigs.BindDurationConfig("3 - Custom Transformations", "Transmog Elf Woman", 3600f); CreatureFormManager.ConfigureCreature("Transmog_Elf_Woman", delegate(CreatureFormManager.CreatureForm creatureForm) { creatureForm.UsePlayerAnimator = true; creatureForm.HideWeapons = false; creatureForm.HideArmor = false; creatureForm.HideHelmet = false; creatureForm.HeadTransform = "head"; creatureForm.CameraMaxDistance = 8f; TransmogConfigs.ApplyDuration(creatureForm, elfWomanDuration); creatureForm.GenerateItem = false; creatureForm.EnableUseItem = false; creatureForm.EnableRuneItem = true; creatureForm.RuneItem = "TransmogGem_ElfWoman"; ConfigureArmorVariants(creatureForm, 3); }); ConfigEntry dwarfManDuration = TransmogConfigs.BindDurationConfig("3 - Custom Transformations", "Transmog Dwarf Man", 3600f); CreatureFormManager.ConfigureCreature("Transmog_Dwarf_Man", delegate(CreatureFormManager.CreatureForm creatureForm) { creatureForm.UsePlayerAnimator = true; creatureForm.HideWeapons = false; creatureForm.HideArmor = false; creatureForm.HideHelmet = false; creatureForm.HeadTransform = "Head"; creatureForm.CameraMaxDistance = 8f; TransmogConfigs.ApplyDuration(creatureForm, dwarfManDuration); creatureForm.GenerateItem = false; creatureForm.EnableUseItem = false; creatureForm.EnableRuneItem = true; creatureForm.RuneItem = "TransmogGem_DwarfMan"; ConfigureArmorVariants(creatureForm, 13); }); ConfigEntry dwarfWomanDuration = TransmogConfigs.BindDurationConfig("3 - Custom Transformations", "Transmog Dwarf Woman", 3600f); CreatureFormManager.ConfigureCreature("Transmog_Dwarf_Woman", delegate(CreatureFormManager.CreatureForm creatureForm) { creatureForm.UsePlayerAnimator = true; creatureForm.HideWeapons = false; creatureForm.HideArmor = false; creatureForm.HideHelmet = false; creatureForm.HeadTransform = "Head"; creatureForm.CameraMaxDistance = 8f; TransmogConfigs.ApplyDuration(creatureForm, dwarfWomanDuration); creatureForm.GenerateItem = false; creatureForm.EnableUseItem = false; creatureForm.EnableRuneItem = true; creatureForm.RuneItem = "TransmogGem_DwarfWoman"; ConfigureArmorVariants(creatureForm, 13); }); ConfigEntry waterLoxDuration = TransmogConfigs.BindDurationConfig("3 - Custom Transformations", "Water Lox", 3600f); CreatureFormManager.ConfigureCreature("OM_ElephantWar01", delegate(CreatureFormManager.CreatureForm creatureForm) { creatureForm.UsePlayerAnimator = false; creatureForm.HideWeapons = true; creatureForm.HideArmor = true; creatureForm.HideHelmet = true; creatureForm.CameraMaxDistance = 16f; TransmogConfigs.ApplyDuration(creatureForm, waterLoxDuration); creatureForm.HeadTransform = "CATRigHead"; string primaryAttack = "atk_elephant_bite_odinmounts"; string secondaryAttack = "atk_elephant_stomp_odinmounts"; creatureForm.OnStartAttack = (CreatureFormManager.CreatureForm data, Humanoid instance, bool isSecondary) => data.OverrideAttack(instance, isSecondary, primaryAttack, secondaryAttack); }); } private static void ConfigureArmorVariants(CreatureFormManager.CreatureForm creatureForm, int armorCount, string armorRoot = "Visual") { creatureForm.EnableArmorVariants = true; creatureForm.ArmorVariantRoot = armorRoot; creatureForm.BaseArmorBody = ""; creatureForm.ArmorVariantPrefix = "Armor_"; creatureForm.FirstArmorVariant = 1; creatureForm.DefaultArmorVariant = 1; creatureForm.ArmorVariantCount = armorCount; creatureForm.EnableArmorVariantEffect = true; creatureForm.ArmorVariantEffect = "ArmorEffect"; creatureForm.ArmorVariantEffectDuration = 1f; } } [NullableContext(1)] [Nullable(0)] public static class VanillaSouls { private const int DefaultTrophyCost = 20; private const float DefaultDuration = 240f; private const float DefaultBossDuration = 120f; private static readonly HashSet BossPrefabNames = new HashSet { "Eikthyr", "gd_king", "Bonemass", "Dragon", "GoblinKing", "SeekerQueen", "TheQueen", "Fader" }; private static readonly Dictionary> SoulEnabledConfigs = new Dictionary>(); private static readonly Dictionary> DurationConfigs = new Dictionary>(); private static readonly Dictionary> TrophyCostConfigs = new Dictionary>(); public static void Setup() { CreatureFormManager.ConfigureAllCreatures(ConfigureCreature); CreatureFormManager.SetTrophySoulEnabledPredicate(IsSoulEnabled); } private static void ConfigureCreature(CreatureFormManager.CreatureForm creatureForm) { if (!creatureForm.IsAutoDiscovered && !IsTransmogCreature(creatureForm.SourcePrefabName)) { creatureForm.EnableTrophySoul = true; ApplySoulConfigs(creatureForm); } } private static bool IsSoulEnabled(CreatureFormManager.CreatureForm creatureForm) { if (IsTransmogCreature(creatureForm.SourcePrefabName)) { return false; } ApplySoulConfigs(creatureForm); return GetSoulEnabledConfig(creatureForm).Value == TransmogPlugin.Toggle.On; } private static void ApplySoulConfigs(CreatureFormManager.CreatureForm creatureForm) { creatureForm.EnableTrophySoul = true; creatureForm.Duration = GetDurationConfig(creatureForm).Value; creatureForm.TrophySoulCost = GetTrophyCostConfig(creatureForm).Value; } private static ConfigEntry GetSoulEnabledConfig(CreatureFormManager.CreatureForm creatureForm) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if (!SoulEnabledConfigs.TryGetValue(creatureForm.SourcePrefabName, out var value)) { value = TransmogPlugin.plugin.config(creatureForm.SourcePrefabName, "Soul Enabled", TransmogPlugin.Toggle.On, new ConfigDescription("If on, matching trophies can be converted into a Soul item for this transformation.", (AcceptableValueBase)null, Array.Empty())); SoulEnabledConfigs[creatureForm.SourcePrefabName] = value; } return value; } private static ConfigEntry GetDurationConfig(CreatureFormManager.CreatureForm creatureForm) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown if (!DurationConfigs.TryGetValue(creatureForm.SourcePrefabName, out var config)) { config = TransmogPlugin.plugin.config(creatureForm.SourcePrefabName, "Soul Duration", GetDefaultDuration(creatureForm), new ConfigDescription("Soul transformation duration in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 86400f), Array.Empty())); config.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { creatureForm.Duration = config.Value; }; DurationConfigs[creatureForm.SourcePrefabName] = config; } return config; } private static ConfigEntry GetTrophyCostConfig(CreatureFormManager.CreatureForm creatureForm) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown if (!TrophyCostConfigs.TryGetValue(creatureForm.SourcePrefabName, out var config)) { config = TransmogPlugin.plugin.config(creatureForm.SourcePrefabName, "Trophy Cost", 20, new ConfigDescription("Number of matching trophies required to create one Soul.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 1000), Array.Empty())); config.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { creatureForm.TrophySoulCost = config.Value; }; TrophyCostConfigs[creatureForm.SourcePrefabName] = config; } return config; } private static float GetDefaultDuration(CreatureFormManager.CreatureForm creatureForm) { return BossPrefabNames.Contains(creatureForm.SourcePrefabName) ? 120f : 240f; } private static bool IsTransmogCreature(string prefabName) { return prefabName.StartsWith("Transmog_") || prefabName.StartsWith("transmog_") || prefabName.StartsWith("Shapeshift_") || prefabName.StartsWith("OM_"); } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<38f0d412-7c90-40af-ac12-73792d49d68e>Embedded] internal sealed class <38f0d412-7c90-40af-ac12-73792d49d68e>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<38f0d412-7c90-40af-ac12-73792d49d68e>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <6e8a0b3d-54b2-47d7-8210-ca83312b3358>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <6e8a0b3d-54b2-47d7-8210-ca83312b3358>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <6e8a0b3d-54b2-47d7-8210-ca83312b3358>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<38f0d412-7c90-40af-ac12-73792d49d68e>Embedded] [CompilerGenerated] internal sealed class <74866c26-b31b-4204-8a38-f8afc91577c4>NullableContextAttribute : Attribute { public readonly byte Flag; public <74866c26-b31b-4204-8a38-f8afc91577c4>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace TransmogAPI { [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(1)] internal class CreatureFormManager { [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] private struct BundleId { [UsedImplicitly] public string assetBundleFileName; [UsedImplicitly] public string folderName; } [HarmonyPatch(typeof(Player), "Awake")] [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] private static class Player_Awake_Scanner_Patch { private static bool hasScanned; [HarmonyPostfix] private static void Postfix() { if (hasScanned || !Object.op_Implicit((Object)(object)ZNetScene.instance) || !EnsurePlayerPrefab()) { return; } hasScanned = true; List list = new List(); List list2 = new List(ZNetScene.instance.m_prefabs); foreach (GameObject item in list2) { if ((Object)(object)item != (Object)null && Object.op_Implicit((Object)(object)item.GetComponent()) && !Object.op_Implicit((Object)(object)item.GetComponent()) && !m_registry.ContainsKey(((Object)item).name)) { CreatureForm creatureForm = new CreatureForm(((Object)item).name) { IsAutoDiscovered = true }; ApplyGlobalConfigurations(creatureForm); if (m_configurations.TryGetValue(((Object)item).name, out var value)) { value(creatureForm); } creatureForm.Setup(); list.Add(creatureForm); } } if (!list.Any()) { return; } foreach (CreatureForm item2 in list) { RegisterToScene(item2.Prefab); RegisterStatusEffect((StatusEffect)(object)item2.StatusEffect); ItemDrop consumeItem = item2.ConsumeItem; if (consumeItem != null) { RegisterToScene(((Component)consumeItem).gameObject); RegisterToDB(((Component)consumeItem).gameObject); } } } } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Server_Scanner_Patch { private static bool hasScanned; [HarmonyPostfix] private static void Postfix() { if (hasScanned || !Object.op_Implicit((Object)(object)ZNetScene.instance) || !EnsurePlayerPrefab()) { return; } hasScanned = true; List list = new List(); List list2 = new List(ZNetScene.instance.m_prefabs); foreach (GameObject item in list2) { if ((Object)(object)item != (Object)null && Object.op_Implicit((Object)(object)item.GetComponent()) && !Object.op_Implicit((Object)(object)item.GetComponent()) && !m_registry.ContainsKey(((Object)item).name)) { CreatureForm creatureForm = new CreatureForm(((Object)item).name) { IsAutoDiscovered = true }; ApplyGlobalConfigurations(creatureForm); if (m_configurations.TryGetValue(((Object)item).name, out var value)) { value(creatureForm); } creatureForm.Setup(); list.Add(creatureForm); } } if (!list.Any()) { return; } foreach (CreatureForm item2 in list) { RegisterToScene(item2.Prefab); RegisterStatusEffect((StatusEffect)(object)item2.StatusEffect); ItemDrop consumeItem = item2.ConsumeItem; if (consumeItem != null) { RegisterToScene(((Component)consumeItem).gameObject); RegisterToDB(((Component)consumeItem).gameObject); } } } } [PublicAPI] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] public class CreatureForm { [Description("Source prefab to clone from, if using custom creature")] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] private GameObject SourceGameObject; private bool IsCustom; [Description("Source prefab name to clone from")] public readonly string SourcePrefabName; [Description("Prefab ID override, if empty, generated during creation as Shapeshift_prefabName")] public string OverrideName; [Description("Toggle to generate consume item to shapeshift")] public bool GenerateItem = false; [Description("Toggle to add consume status effect to item already in-game")] public bool EnableUseItem = false; [Description("Item to search for to add shapeshift status effect")] public string UseItem = ""; [Description("Reusable rune item prefab that triggers this transformation")] public string RuneItem = ""; [Description("Toggle to use RuneItem as a timed transformation activator")] public bool EnableRuneItem = false; [Description("Toggle to create a Soul item from creature trophies")] public bool EnableTrophySoul = false; [Description("Trophy prefab name used to craft the Soul, empty means auto-detect from creature drops")] public string TrophySoulTrophyItem = ""; [Description("Number of trophies required to create one Soul")] public int TrophySoulCost = 10; [Description("Generated Soul item prefab name, empty means TransmogSoul_SourcePrefabName")] public string TrophySoulItem = ""; [Description("Enable child object armor variant switching while transformed")] public bool EnableArmorVariants = false; [Description("Root child that contains the base visual object and Armor_XX children")] public string ArmorVariantRoot = ""; [Description("Base body child object to hide while armor variants are active")] public string BaseArmorBody = ""; [Description("Armor child object prefix, example Armor_ for Armor_01")] public string ArmorVariantPrefix = "Armor_"; [Description("Number of armor variants available")] public int ArmorVariantCount = 0; [Description("First armor variant index")] public int FirstArmorVariant = 1; [Description("Default armor variant")] public int DefaultArmorVariant = 1; [Description("Toggle to play a child object effect when armor variant changes")] public bool EnableArmorVariantEffect = false; [Description("Child object name under ArmorVariantRoot to toggle when armor variant changes")] public string ArmorVariantEffect = "ArmorEffect"; [Description("How long the armor variant child effect stays active")] public float ArmorVariantEffectDuration = 1f; [Description("Item to use to create consume item")] public string NewItem = "HealthUpgrade_GDKing"; [Description("Scale to manipulate cloned item")] public float NewItemScale = 0.5f; [Description("Localized name, default uses original")] public string CreatureSharedName = ""; [Description("Required during character awake")] public string HeadTransform = "Head"; [Description("Created cloned creature to shapeshift into")] public GameObject Prefab = null; [Description("Player component added to new creature")] public Player PlayerComponent = null; [Description("Status effect generated to handle transformation, created during setup")] public TransmogMaganger StatusEffect = null; [Description("Prefab ID of new creature")] public string PrefabName = ""; [Description("Items found on the humanoid component of the source prefab")] public readonly Dictionary AllItems = new Dictionary(); [Description("Toggle to replace animator")] public bool UsePlayerAnimator = false; [Description("Toggle to hide armor during VisEquipment AttachArmor")] public bool HideArmor = true; [Description("Toggle to hide helmet during VisEquipment AttachItem")] public bool HideHelmet = true; [Description("Toggle to hide weapons during VisEquipment AttachItem")] public bool HideWeapons = true; [Description("Toggle to enable flying override")] public bool CanFly = false; [Description("Toggle to require melee weapon")] public bool RequireWeapon = false; [Description("Toggle to require ranged weapon")] public bool RequireRanged = false; [Description("Set duration of status effect")] public float Duration = 500f; [Description("Toggle to override drowning in water and stamina regeneration while swimming")] public bool WaterCreature = false; [Description("Set fly acceleration")] public float FlyAcceleration = 1f; [Description("Toggle to invert look yaw during flight")] public bool InvertLookYaw = false; [Description("Set camera max distance")] public float CameraMaxDistance = 8f; [Description("Multiplier applied to vertical jump force on transformed prefabs")] public float JumpForceMultiplier = 0.6f; [Description("Set faction override, main component stays as Players but BaseAI.IsEnemy is patched to allow for added faction")] public string Group = ""; [Description("Toggle to allow not to lose skill experience on death")] public bool NoSkillDrain = false; [Description("Set item type to trigger OnEquip and OnUnequip patches")] public ItemType LevelEffectTrigger = (ItemType)6; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1 })] [Description("Add behavior on spawn")] public Action OnSpawn; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1 })] [Description("Add behavior on setup finish, best to use to modify data to make sure everything is loaded")] public Action OnSetupFinish = null; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1 })] [Description("Add behavior to override Humanoid.StartAttack")] public Func OnStartAttack; [Description("Add behavior to override Player.SetControls")] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1 })] public Action OnSetControls; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1 })] [Description("Add behavior to override Player.OnDodge")] public Action OnDodge; [Description("Add behavior to override VisEquipment.AttachArmor")] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1, 1, 1 })] public Func> OnAttachArmor; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1, 2 })] [Description("Add behavior to override VisEquipment.AttachItem")] public Func OnAttachItem; [Description("Add behavior to trigger after Humanoid.UnequipItem (LevelEffectTrigger to manage what kind of item)")] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1, 1 })] public Action OnUnEquipItem; [Description("Add behavior to trigger after Humanoid.EquipItem (LevelEffectTrigger to manage what kind of item)")] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1, 1 })] public Action OnEquipItem; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1 })] [Description("Add behavior to override GameCamerea.GetCameraPosition")] public Func OnGetCameraPosition; [Description("Add behavior to override GameCamera.GetCameraRotation")] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1, 1 })] public Func OnGetCameraRotation; [Description("Add behavior after status effect created")] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1 })] public Action OnCreateStatusEffect; [Description("If generated item is true, saved here")] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] public ItemDrop ConsumeItem; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] [Description("If trophy soul is enabled, saved here")] public ItemDrop SoulItemDrop; [Description("True when the form was generated by scanning an unconfigured creature prefab")] public bool IsAutoDiscovered = false; [Description("Internal variable to save current attack index to use for OnStartAttack or OnSetControls behaviors")] public int AttackIndex; [Description("Register in-game creature to transform into")] public CreatureForm(string prefabName, string Name = "") { //IL_0180: Unknown result type (might be due to invalid IL or missing references) SourcePrefabName = prefabName; OverrideName = Name; m_registry[Utility.IsNullOrWhiteSpace(OverrideName) ? SourcePrefabName : OverrideName] = this; } [Description("Register custom creature to transform into")] public CreatureForm(GameObject source, string Name = "") { //IL_0180: Unknown result type (might be due to invalid IL or missing references) SourcePrefabName = ((Object)source).name; OverrideName = Name; SourceGameObject = source; m_registry[SourcePrefabName] = this; IsCustom = true; } [Description("Register custom creature to transform into")] public CreatureForm(string assetBundle, string prefabName, bool fromAssetBundle, string Name = "") : this(RegisterAssetBundle(assetBundle).LoadAsset(prefabName), Name) { } [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] private static GameObject FindPrefab(string name) { if ((Object)(object)ZNetScene.instance != (Object)null) { GameObject val = ZNetScene.instance.m_prefabs.Find([<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] (GameObject x) => ((Object)x).name == name); if ((Object)(object)val != (Object)null) { return val; } } return ((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(name) : null; } private void AddItems([<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1 })] GameObject[] items) { if (items == null) { return; } foreach (GameObject val in items) { if (!((Object)(object)val == (Object)null)) { AllItems[((Object)val).name] = val; } } } private void CopyPlayerValues() { //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_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) Player component = m_playerPrefab.GetComponent(); PlayerComponent.m_maxPlaceDistance = component.m_maxPlaceDistance; PlayerComponent.m_maxInteractDistance = component.m_maxInteractDistance; PlayerComponent.m_scrollSens = component.m_scrollSens; PlayerComponent.m_staminaRegen = component.m_staminaRegen; PlayerComponent.m_runStaminaDrain = component.m_runStaminaDrain; PlayerComponent.m_sneakStaminaDrain = component.m_sneakStaminaDrain; PlayerComponent.m_swimStaminaDrainMinSkill = component.m_swimStaminaDrainMinSkill; PlayerComponent.m_swimStaminaDrainMaxSkill = component.m_swimStaminaDrainMaxSkill; PlayerComponent.m_dodgeStaminaUsage = component.m_dodgeStaminaUsage; PlayerComponent.m_weightStaminaFactor = component.m_weightStaminaFactor; PlayerComponent.m_eiterRegen = component.m_eiterRegen; PlayerComponent.m_eitrRegenDelay = component.m_eitrRegenDelay; PlayerComponent.m_autoPickupRange = component.m_autoPickupRange; PlayerComponent.m_maxCarryWeight = component.m_maxCarryWeight; PlayerComponent.m_hardDeathCooldown = component.m_hardDeathCooldown; PlayerComponent.m_baseCameraShake = component.m_baseCameraShake; PlayerComponent.m_placeDelay = component.m_placeDelay; PlayerComponent.m_removeDelay = component.m_removeDelay; PlayerComponent.m_drownEffects = component.m_drownEffects; PlayerComponent.m_spawnEffects = component.m_spawnEffects; PlayerComponent.m_removeEffects = component.m_removeEffects; PlayerComponent.m_dodgeEffects = component.m_dodgeEffects; PlayerComponent.m_autopickupEffects = component.m_autopickupEffects; PlayerComponent.m_skillLevelupEffects = component.m_skillLevelupEffects; PlayerComponent.m_equipStartEffects = component.m_equipStartEffects; PlayerComponent.m_placeMarker = component.m_placeMarker; PlayerComponent.m_tombstone = component.m_tombstone; PlayerComponent.m_valkyrie = component.m_valkyrie; PlayerComponent.m_textIcon = component.m_textIcon; PlayerComponent.m_baseHP = component.m_baseHP; PlayerComponent.m_baseStamina = component.m_baseStamina; PlayerComponent.m_wakeupTime = component.m_wakeupTime; PlayerComponent.m_guardianPowerCooldown = component.m_guardianPowerCooldown; PlayerComponent.m_scrollAmountThreshold = component.m_scrollAmountThreshold; PlayerComponent.m_autoRun = component.m_autoRun; ((Humanoid)PlayerComponent).m_unarmedWeapon = ((Humanoid)component).m_unarmedWeapon; ((Character)PlayerComponent).m_damageModifiers = ((Character)component).m_damageModifiers; } private void GetSharedName(GameObject source) { Character val = default(Character); if (source.TryGetComponent(ref val)) { CreatureSharedName = val.m_name; if (Utility.IsNullOrWhiteSpace(Group)) { Group = val.m_group; } } } private void SetDamageModifiers(GameObject source) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) Character val = default(Character); if (!source.TryGetComponent(ref val)) { return; } List list = new List(); foreach (DamageType value in Enum.GetValues(typeof(DamageType))) { DamageModifier modifier = ((DamageModifiers)(ref val.m_damageModifiers)).GetModifier(value); list.Add(new DamageModPair { m_type = value, m_modifier = (DamageModifier)(((int)modifier == 3) ? 5 : ((int)modifier)) }); } ((SE_Stats)StatusEffect).m_mods = list; } public void Setup() { //IL_0247: Unknown result type (might be due to invalid IL or missing references) if (!EnsurePlayerPrefab()) { return; } GameObject val = (IsCustom ? SourceGameObject : FindPrefab(SourcePrefabName)); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("[TransmogAPI] Source prefab '" + SourcePrefabName + "' not found for Setup.")); return; } Prefab = Object.Instantiate(val, m_root.transform, false); Rigidbody val2 = default(Rigidbody); if (Prefab.TryGetComponent(ref val2)) { val2.interpolation = (RigidbodyInterpolation)1; } if (Utility.IsNullOrWhiteSpace(OverrideName)) { ((Object)Prefab).name = "Shapeshift_" + ((Object)val).name; } else { ((Object)Prefab).name = "Shapeshift_" + OverrideName; } PrefabName = ((Object)Prefab).name; Player val3 = Prefab.Convert(); if (val3 == null) { Player val4 = Prefab.Convert(); if (val4 == null) { return; } val3 = val4; } PlayerComponent = val3; Player playerComponent = PlayerComponent; ((Character)playerComponent).m_jumpForce = ((Character)playerComponent).m_jumpForce * JumpForceMultiplier; GetSharedName(val); CreateStatusEffect(); if ((Object)(object)SoulItemDrop != (Object)null) { ((StatusEffect)StatusEffect).m_icon = SoulItemDrop.m_itemData.GetIcon(); } SetDamageModifiers(val); CopyPlayerValues(); Prefab.Copy(m_playerPrefab); Prefab.Copy(m_playerPrefab); Prefab.Copy(m_playerPrefab); Prefab.Remove(); Prefab.Remove(); Prefab.Remove(); Prefab.Remove(); Prefab.Remove(); Prefab.Remove(); Prefab.Remove(); RemoveNestedZNetViews(Prefab); Prefab.GetComponent().m_persistent = false; ((Character)PlayerComponent).m_faction = (Faction)0; ((Character)PlayerComponent).m_boss = false; ((Character)PlayerComponent).m_bossEvent = ""; ((Character)PlayerComponent).m_defeatSetGlobalKey = ""; LevelEffects componentInChildren = Prefab.GetComponentInChildren(); if (componentInChildren != null) { ((Component)componentInChildren).gameObject.Remove(); } AddItems(((Humanoid)PlayerComponent).m_defaultItems); AddItems(((Humanoid)PlayerComponent).m_randomWeapon); AddItems(((Humanoid)PlayerComponent).m_randomArmor); AddItems(((Humanoid)PlayerComponent).m_randomShield); if (((Humanoid)PlayerComponent).m_randomSets != null) { ItemSet[] randomSets = ((Humanoid)PlayerComponent).m_randomSets; foreach (ItemSet val5 in randomSets) { AddItems(val5.m_items); } } if (((Humanoid)PlayerComponent).m_randomItems != null) { RandomItem[] randomItems = ((Humanoid)PlayerComponent).m_randomItems; foreach (RandomItem val6 in randomItems) { AllItems[((Object)val6.m_prefab).name] = val6.m_prefab; } } ReplaceAnimator(); VisEquipment val7 = default(VisEquipment); if (Prefab.TryGetComponent(ref val7) && (Object)(object)val7.m_bodyModel == (Object)null) { val7.m_bodyModel = Prefab.GetComponentInChildren(); } if (GenerateItem) { GameObject val8 = CreateItem(); ItemDrop val9 = default(ItemDrop); if (val8 != null && val8.TryGetComponent(ref val9)) { m_itemToCreatures[val9.m_itemData.m_shared.m_name] = this; ConsumeItem = val9; } } else if (EnableUseItem && !Utility.IsNullOrWhiteSpace(UseItem)) { GameObject val10 = FindPrefab(UseItem); ItemDrop val11 = default(ItemDrop); if (val10 != null && val10.TryGetComponent(ref val11)) { m_itemToCreatures[val11.m_itemData.m_shared.m_name] = this; ((StatusEffect)StatusEffect).m_icon = val11.m_itemData.GetIcon(); val11.m_itemData.m_shared.m_consumeStatusEffect = (StatusEffect)(object)StatusEffect; } else { Debug.LogWarning((object)("[TransmogAPI] Could not find prefab '" + UseItem + "' to attach status effect.")); } } EnsureTrophySoulItem(val); if (EnableRuneItem && !Utility.IsNullOrWhiteSpace(RuneItem)) { GameObject val12 = FindPrefab(RuneItem); ItemDrop runeItemDrop = default(ItemDrop); if (val12 != null && val12.TryGetComponent(ref runeItemDrop)) { SetupRuneItem(runeItemDrop); } else { Debug.LogWarning((object)("[TransmogAPI] Could not find rune prefab '" + RuneItem + "' to attach transformation.")); } } OnSetupFinish?.Invoke(this); m_creatures[PrefabName] = this; m_sourceToCreatures[Utility.IsNullOrWhiteSpace(OverrideName) ? SourcePrefabName : OverrideName] = this; } private void SetupRuneItem(ItemDrop runeItemDrop) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) SharedData shared = runeItemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)2; shared.m_maxStackSize = 1; shared.m_useDurability = true; shared.m_maxDurability = Duration; shared.m_canBeReparied = false; shared.m_consumeStatusEffect = null; runeItemDrop.m_itemData.m_durability = Duration; m_runeToCreatures[shared.m_name] = this; } private static void RemoveNestedZNetViews(GameObject prefab) { ZNetView component = prefab.GetComponent(); ZNetView[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (ZNetView val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)component)) { Object.DestroyImmediate((Object)(object)val); } } } internal void EnsureTrophySoulItem() { if (EnableTrophySoul && !((Object)(object)SoulItemDrop != (Object)null)) { GameObject val = (IsCustom ? SourceGameObject : FindPrefab(SourcePrefabName)); if (!((Object)(object)val == (Object)null)) { EnsureTrophySoulItem(val); } } } internal void EnsureTrophySoulItemFromTrophy(GameObject trophyPrefab) { if (!((Object)(object)SoulItemDrop != (Object)null)) { TryCreateTrophySoulItemFromTrophy(trophyPrefab); } } internal void EnsureTrophySoulItemFromObjectDBTrophy() { if (EnableTrophySoul && !((Object)(object)SoulItemDrop != (Object)null)) { GameObject val = FindTrophyPrefabByName(); if (!((Object)(object)val == (Object)null)) { TryCreateTrophySoulItemFromTrophy(val); } } } private void EnsureTrophySoulItem(GameObject source) { if (EnableTrophySoul && !((Object)(object)SoulItemDrop != (Object)null)) { TryCreateTrophySoulItem(source); } } private void TryCreateTrophySoulItem(GameObject source) { if (IsTrophySoulEnabled()) { GameObject val = FindTrophyPrefab(source); if (!((Object)(object)val == (Object)null)) { TryCreateTrophySoulItemFromTrophy(val); } } } private void TryCreateTrophySoulItemFromTrophy(GameObject trophyPrefab) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) ItemDrop val = default(ItemDrop); if (!IsTrophySoulEnabled() || (Object)(object)trophyPrefab == (Object)null || !trophyPrefab.TryGetComponent(ref val)) { return; } string name = (Utility.IsNullOrWhiteSpace(TrophySoulItem) ? ("TransmogSoul_" + SourcePrefabName) : TrophySoulItem); GameObject val2 = Object.Instantiate(trophyPrefab, m_root.transform, false); ((Object)val2).name = name; ItemDrop val3 = default(ItemDrop); if (!val2.TryGetComponent(ref val3)) { Object.Destroy((Object)(object)val2); return; } SharedData shared = val3.m_itemData.m_shared; shared.m_name = GetSoulDisplayName(); shared.m_description = "Use to assume this creature form for a limited time."; shared.m_itemType = (ItemType)2; shared.m_maxStackSize = 1; shared.m_useDurability = true; shared.m_maxDurability = Duration; shared.m_canBeReparied = false; shared.m_consumeStatusEffect = null; shared.m_questItem = false; val3.m_itemData.m_durability = Duration; if ((Object)(object)StatusEffect != (Object)null) { ((StatusEffect)StatusEffect).m_icon = val3.m_itemData.GetIcon(); } SoulItemDrop = val3; ConsumeItem = val3; SetupRuneItem(val3); m_trophyToSoulCreatures[val.m_itemData.m_shared.m_name] = this; RegisterToScene(val2); RegisterToDB(val2); } [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] private GameObject FindTrophyPrefab(GameObject source) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 if (!Utility.IsNullOrWhiteSpace(TrophySoulTrophyItem)) { return FindPrefab(TrophySoulTrophyItem); } CharacterDrop component = source.GetComponent(); if ((Object)(object)component != (Object)null) { ItemDrop val = default(ItemDrop); for (int i = 0; i < component.m_drops.Count; i++) { GameObject prefab = component.m_drops[i].m_prefab; if (!((Object)(object)prefab == (Object)null) && prefab.TryGetComponent(ref val) && (int)val.m_itemData.m_shared.m_itemType == 13) { TrophySoulTrophyItem = ((Object)prefab).name; return prefab; } } } return FindTrophyPrefabByName(); } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(2)] private GameObject FindTrophyPrefabByName() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 string[] array = new string[4] { "Trophy" + SourcePrefabName, "Trophy" + SourcePrefabName.Replace("_", ""), SourcePrefabName + "Trophy", SourcePrefabName + "_Trophy" }; ItemDrop val2 = default(ItemDrop); for (int i = 0; i < array.Length; i++) { GameObject val = FindPrefab(array[i]); if (!((Object)(object)val == (Object)null) && val.TryGetComponent(ref val2) && (int)val2.m_itemData.m_shared.m_itemType == 13) { TrophySoulTrophyItem = ((Object)val).name; return val; } } string looseName = SourcePrefabName.Replace("_", ""); if ((Object)(object)ZNetScene.instance != (Object)null) { for (int j = 0; j < ZNetScene.instance.m_prefabs.Count; j++) { GameObject val3 = ZNetScene.instance.m_prefabs[j]; if (IsMatchingTrophyPrefab(val3, looseName)) { TrophySoulTrophyItem = ((Object)val3).name; return val3; } } } if ((Object)(object)ObjectDB.instance != (Object)null) { for (int k = 0; k < ObjectDB.instance.m_items.Count; k++) { GameObject val4 = ObjectDB.instance.m_items[k]; if (IsMatchingTrophyPrefab(val4, looseName)) { TrophySoulTrophyItem = ((Object)val4).name; return val4; } } } return null; } private static bool IsMatchingTrophyPrefab(GameObject prefab, string looseName) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 if ((Object)(object)prefab == (Object)null || !((Object)prefab).name.StartsWith("Trophy", StringComparison.Ordinal)) { return false; } if (!((Object)prefab).name.Replace("_", "").Contains(looseName)) { return false; } ItemDrop val = default(ItemDrop); if (!prefab.TryGetComponent(ref val)) { return false; } return (int)val.m_itemData.m_shared.m_itemType == 13; } internal bool IsTrophySoulEnabled() { return EnableTrophySoul && (m_trophySoulEnabledPredicate?.Invoke(this) ?? true); } internal string GetSoulDisplayName() { string text = SourcePrefabName.Replace('_', ' '); if (!Utility.IsNullOrWhiteSpace(CreatureSharedName) && !CreatureSharedName.StartsWith("$", StringComparison.Ordinal)) { text = CreatureSharedName; } return text + " Soul"; } public int ClampArmorVariant(int variant) { if (!EnableArmorVariants || ArmorVariantCount <= 0) { return DefaultArmorVariant; } int num = Mathf.Max(1, FirstArmorVariant); int num2 = Mathf.Max(num, ArmorVariantCount); if (variant < num) { return num2; } if (variant > num2) { return num; } return variant; } public string GetArmorVariantObjectName(int variant) { return ArmorVariantPrefix + variant.ToString("D2"); } public bool TryGetArmorVariantIndex(string objectName, out int variant) { variant = 0; if (Utility.IsNullOrWhiteSpace(objectName)) { return false; } if (!objectName.StartsWith(ArmorVariantPrefix, StringComparison.Ordinal)) { return false; } string s = objectName.Substring(ArmorVariantPrefix.Length); return int.TryParse(s, out variant); } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(2)] private GameObject CreateItem() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_006b: 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_014f: Unknown result type (might be due to invalid IL or missing references) GameObject val = FindPrefab(NewItem); if (val == null) { return null; } GameObject val2 = Object.Instantiate(val, m_root.transform, false); ((Object)val2).name = PrefabName + "_item"; Light val4 = default(Light); foreach (Transform item in val2.transform) { Transform val3 = item; val3.localScale *= NewItemScale; if (((Component)val3).TryGetComponent(ref val4)) { Light obj = val4; obj.range *= NewItemScale; } } ItemDrop val5 = default(ItemDrop); if (!val2.TryGetComponent(ref val5)) { return null; } val5.m_itemData.m_shared.m_name = "$" + ((Object)val2).name.ToLower(); val5.m_itemData.m_shared.m_description = "$" + ((Object)val2).name.ToLower() + "_desc"; val5.m_itemData.m_shared.m_questItem = false; val5.m_itemData.m_shared.m_itemType = (ItemType)16; val5.m_itemData.m_shared.m_maxStackSize = 20; ((StatusEffect)StatusEffect).m_icon = val5.m_itemData.GetIcon(); val5.m_itemData.m_shared.m_consumeStatusEffect = (StatusEffect)(object)StatusEffect; return val2; } private void ReplaceAnimator() { if (UsePlayerAnimator) { Animator componentInChildren = Prefab.GetComponentInChildren(); Animator componentInChildren2 = m_playerPrefab.GetComponentInChildren(); componentInChildren.runtimeAnimatorController = componentInChildren2.runtimeAnimatorController; } } private bool CanAttack(Humanoid instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 ItemData currentWeapon = instance.GetCurrentWeapon(); if (RequireRanged && (currentWeapon == null || (int)currentWeapon.m_shared.m_skillType != 8)) { ((Character)instance).Message((MessageType)2, "$msg_require_ranged", 0, (Sprite)null); return false; } if (RequireRanged && instance.GetAmmoItem() == null) { ((Character)instance).Message((MessageType)2, "$msg_outof " + currentWeapon.m_shared.m_ammoType, 0, (Sprite)null); return false; } if (RequireWeapon && (currentWeapon == null || (int)currentWeapon.m_shared.m_skillType == 11)) { ((Character)instance).Message((MessageType)2, "$msg_require_melee", 0, (Sprite)null); return false; } return true; } [Description("To use during OnStartAttack")] public bool OverrideAttack(Humanoid instance, bool secondary, string primaryAttack, string secondaryAttack = "") { Player val = (Player)(object)((instance is Player) ? instance : null); if (val == null) { return false; } if (!CanAttack(instance)) { return false; } if (Utility.IsNullOrWhiteSpace(secondaryAttack)) { secondaryAttack = primaryAttack; } if ((((Character)instance).InAttack() && !instance.HaveQueuedChain()) || ((Character)instance).InDodge() || !((Character)instance).CanMove() || ((Character)instance).IsKnockedBack() || ((Character)instance).IsStaggering() || ((Character)instance).InMinorAction()) { return false; } if (!AllItems.TryGetValue(secondary ? secondaryAttack : primaryAttack, out var value)) { return false; } ItemDrop val2 = default(ItemDrop); if (!value.TryGetComponent(ref val2)) { return false; } return DoAttack(val, val2.m_itemData.Clone(), secondary); } public bool TryRunJump(Player instance) { //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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (CanFly || ((Character)instance).IsFlying()) { return false; } if (!((Character)instance).IsOnGround() || ((Character)instance).IsDead() || ((Character)instance).IsEncumbered() || ((Character)instance).InDodge() || ((Character)instance).IsKnockedBack() || ((Character)instance).IsStaggering()) { return false; } if (!((Character)instance).HaveStamina(((Character)instance).m_jumpStaminaUsage)) { Hud.instance.StaminaBarEmptyFlash(); return true; } Vector3 val = ((Character)instance).m_body.linearVelocity; Vector3 val2 = ((Character)instance).m_lastGroundNormal + Vector3.up; Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = (((Object)(object)((Character)instance).GetSkills() != (Object)null) ? ((Character)instance).GetSkills().GetSkillFactor((SkillType)100) : 0f); float num2 = 1f + num * 0.4f; float num3 = ((Character)instance).m_jumpForce * num2; float num4 = Vector3.Dot(normalized, val); if (num4 < num3) { val += normalized * (num3 - num4); } val += ((Character)instance).m_moveDir * ((Character)instance).m_jumpForceForward * num2; ((Character)instance).m_seman.ApplyStatusEffectJumpMods(ref val); if (((Vector3)(ref val)).sqrMagnitude <= 0f) { return true; } ((Character)instance).RaiseSkill((SkillType)100, 1f); ((Character)instance).ForceJump(val, true); return true; } [Description("To use during OnSetControls")] public void OverrideSetControls(Player instance, bool block, bool jump, string blockAttack, string landAttack = "", string takeOffAttack = "") { GameObject value3; ItemDrop val3 = default(ItemDrop); if (CanFly && jump) { GameObject value2; ItemDrop val2 = default(ItemDrop); if (((Character)instance).IsFlying()) { ItemDrop val = default(ItemDrop); if (AllItems.TryGetValue(landAttack, out var value) && value.TryGetComponent(ref val)) { DoAttack(instance, val.m_itemData.Clone()); } } else if (AllItems.TryGetValue(takeOffAttack, out value2) && value2.TryGetComponent(ref val2)) { DoAttack(instance, val2.m_itemData.Clone()); } } else if (block && CanAttack((Humanoid)(object)instance) && AllItems.TryGetValue(blockAttack, out value3) && value3.TryGetComponent(ref val3)) { DoAttack(instance, val3.m_itemData.Clone()); } } [Description("To use during OnDodge")] public void OverrideDodge(Player instance, string leftDodge, string rightDodge) { bool flag = true; if (ZInput.GetButton("Left")) { flag = false; } else if (!ZInput.GetButton("Right") && ZInput.GetButton("Backward")) { flag = false; } ItemDrop val = default(ItemDrop); if (AllItems.TryGetValue(flag ? rightDodge : leftDodge, out var value) && value.TryGetComponent(ref val)) { DoAttack(instance, val.m_itemData.Clone()); } } [Description("To use during OnAttachArmor")] public List OverrideAttachArmor(VisEquipment instance, params string[] itemNames) { List list = new List(); foreach (string itemName in itemNames) { GameObject val = AttachSkin(instance, itemName); if (!((Object)(object)val == (Object)null)) { list.Add(val); } } return list; } private bool DoAttack(Player instance, ItemData item, bool secondary = false) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) ItemData currentWeapon = ((Humanoid)instance).GetCurrentWeapon(); ItemData ammoItem = ((Humanoid)instance).GetAmmoItem(); if (((Humanoid)instance).m_currentAttack != null) { ((Humanoid)instance).m_currentAttack.Stop(); ((Humanoid)instance).m_previousAttack = ((Humanoid)instance).m_currentAttack; ((Humanoid)instance).m_currentAttack = null; } Attack val = item.m_shared.m_attack.Clone(); if (currentWeapon != null) { item.m_shared.m_skillType = currentWeapon.m_shared.m_skillType; } else { item.m_shared.m_skillType = (SkillType)11; } if (!val.Start((Humanoid)(object)instance, ((Character)instance).m_body, ((Character)instance).m_zanim, ((Character)instance).m_animEvent, ((Humanoid)instance).m_visEquipment, item, ((Humanoid)instance).m_previousAttack, ((Humanoid)instance).m_timeSinceLastAttack, ((Humanoid)instance).GetAttackDrawPercentage())) { return false; } if (RequireRanged) { ((Humanoid)instance).GetInventory().RemoveItem(ammoItem, 1); } ((Humanoid)instance).ClearActionQueue(); ((Humanoid)instance).StartAttackGroundCheck(); ((Humanoid)instance).m_currentAttack = val; ((Humanoid)instance).m_currentAttackIsSecondary = secondary; ((Humanoid)instance).m_lastCombatTimer = 0f; return true; } [Description("To use during OnAttachArmor or OnAttachItem")] [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] public GameObject AttachSkin(VisEquipment instance, string itemName) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!AllItems.TryGetValue(itemName, out var value)) { return null; } Transform val = value.transform.Find("attach_skin"); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = Object.Instantiate(((Component)val).gameObject, ((Component)instance.m_bodyModel).transform.parent); val2.SetActive(true); val2.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); SkinnedMeshRenderer[] componentsInChildren = val2.GetComponentsInChildren(); foreach (SkinnedMeshRenderer val3 in componentsInChildren) { val3.rootBone = instance.m_bodyModel.rootBone; val3.bones = instance.m_bodyModel.bones; } VisEquipment.CleanupInstance(val2); VisEquipment.EnableEquippedEffects(val2); return val2; } [Description("To use during OnAttachArmor or OnAttachItem")] [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] public GameObject Attach(VisEquipment instance, bool leftHand, string itemName, string attachTransform = "attach") { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!AllItems.TryGetValue(itemName, out var value)) { return null; } Transform val = value.transform.Find(attachTransform); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = Object.Instantiate(((Component)val).gameObject, leftHand ? instance.m_leftHand : instance.m_rightHand); val2.SetActive(true); val2.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); val2.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); VisEquipment.CleanupInstance(val2); VisEquipment.EnableEquippedEffects(val2); return val2; } private void CreateStatusEffect() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00bd: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown TransmogMaganger transmogMaganger = ScriptableObject.CreateInstance(); transmogMaganger.m_data = this; ((StatusEffect)transmogMaganger).m_ttl = Duration; ((Object)transmogMaganger).name = "SE_" + PrefabName.ToLower(); ((StatusEffect)transmogMaganger).m_name = "$label_shapeshift"; ((StatusEffect)transmogMaganger).m_tooltip = "$label_shapeshift_desc " + (Utility.IsNullOrWhiteSpace(CreatureSharedName) ? OverrideName : CreatureSharedName); transmogMaganger.m_doneEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = FindPrefab("vfx_spawn") }, new EffectData { m_prefab = FindPrefab("sfx_spawn") } }; EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[3] { new EffectData { m_prefab = FindPrefab("vfx_prespawn"), m_attach = true }, new EffectData { m_prefab = FindPrefab("sfx_prespawn"), m_attach = true }, new EffectData { m_prefab = FindPrefab("fx_GP_Activation") } }; transmogMaganger.m_spawnEffects = val; ((StatusEffect)transmogMaganger).m_stopEffects = transmogMaganger.m_doneEffects; ((StatusEffect)transmogMaganger).m_stopEffects = transmogMaganger.m_doneEffects; ((StatusEffect)transmogMaganger).m_activationAnimation = "gpower"; if (CanFly) { ((SE_Stats)transmogMaganger).m_fallDamageModifier = -1f; } StatusEffect = transmogMaganger; Sprite val2 = null; AssetBundle val3 = RegisterAssetBundle("mar_transmog"); if ((Object)(object)val3 != (Object)null) { val2 = val3.LoadAsset("transmog_icon"); } if ((Object)(object)val2 == (Object)null) { GameObject val4 = FindPrefab("HealthUpgrade_GDKing"); ItemDrop val5 = default(ItemDrop); if (val4 != null && val4.TryGetComponent(ref val5)) { val2 = val5.m_itemData.GetIcon(); } } ((StatusEffect)transmogMaganger).m_icon = val2; OnCreateStatusEffect?.Invoke(this); } [Description("Transform into creature, destroys local player and spawns again as creature, transfers player data")] [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(2)] public Player ShapeShift() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return null; } Game.instance.m_playerProfile.SavePlayerData(Player.m_localPlayer); Vector3 position = ((Component)Player.m_localPlayer).transform.position; ((Character)Player.m_localPlayer).OnDisable(); ZNetScene.instance.Destroy(((Component)Player.m_localPlayer).gameObject); ZNet.instance.SetCharacterID(ZDOID.None); GameObject val = Object.Instantiate(Prefab, position, Quaternion.identity); Player component = val.GetComponent(); component.SetLocalPlayer(); Game.instance.m_playerProfile.LoadPlayerData(component); ZNet.instance.SetCharacterID(((Character)component).GetZDOID()); RefreshEquipmentAfterCharacterId(component); component.OnSpawned(false); OnSpawn?.Invoke(this, val); GameCamera.instance.m_maxDistance = CameraMaxDistance; m_currentCreature = SourcePrefabName; m_currentModel = PrefabName; return component; } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(2)] [Description("Transforms back to player model, destroys local player and spawns again as human, transfers player data")] public static Player Revert() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return null; } Game.instance.m_playerProfile.SavePlayerData(Player.m_localPlayer); Vector3 position = ((Component)Player.m_localPlayer).transform.position; ((Character)Player.m_localPlayer).OnDisable(); ZNetScene.instance.Destroy(((Component)Player.m_localPlayer).gameObject); ZNet.instance.SetCharacterID(ZDOID.None); Player component = Object.Instantiate(m_playerPrefab, position, Quaternion.identity).GetComponent(); component.SetLocalPlayer(); Game.instance.m_playerProfile.LoadPlayerData(component); ZNet.instance.SetCharacterID(((Character)component).GetZDOID()); RefreshEquipmentAfterCharacterId(component); component.OnSpawned(false); m_currentModel = ""; GameCamera.instance.m_maxDistance = m_defaultCameraMaxDistance; m_currentCreature = ""; return component; } private static void RefreshEquipmentAfterCharacterId(Player player) { if (!((Object)(object)player == (Object)null) && !((Object)(object)((Character)player).m_nview == (Object)null) && ((Character)player).m_nview.GetZDO() != null) { m_setupEquipmentMethod?.Invoke(player, null); } } } [PublicAPI] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] public class LocalizeKey { private static readonly List keys = new List(); public readonly string Key; public readonly Dictionary Localizations = new Dictionary(); 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)); } } } } [CompilerGenerated] private sealed class d__97 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] private object <>2__current; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] public GameObject effect; public float duration; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 0, 1 })] private ParticleSystem[] <>s__1; private int <>s__2; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] private ParticleSystem 5__3; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 0, 1 })] private AudioSource[] <>s__4; private int <>s__5; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] private AudioSource 5__6; object IEnumerator.Current { [DebuggerHidden] [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__97(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; 5__3 = null; <>s__4 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)effect == (Object)null) { return false; } <>s__1 = effect.GetComponentsInChildren(true); for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++) { 5__3 = <>s__1[<>s__2]; 5__3.Stop(true, (ParticleSystemStopBehavior)0); 5__3.Clear(true); 5__3.Play(true); 5__3 = null; } <>s__1 = null; <>s__4 = effect.GetComponentsInChildren(true); for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++) { 5__6 = <>s__4[<>s__5]; 5__6.Stop(); 5__6.Play(); 5__6 = null; } <>s__4 = null; <>2__current = (object)new WaitForSeconds(Mathf.Max(0.05f, duration)); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)effect != (Object)null) { Object.Destroy((Object)(object)effect); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__77 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] private object <>2__current; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] public Player player; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] public CreatureForm data; public float timeLeft; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] private TransmogMaganger 5__1; object IEnumerator.Current { [DebuggerHidden] [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__77(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; if ((Object)(object)player == (Object)null || !((Behaviour)player).isActiveAndEnabled) { return false; } 5__1 = ((Character)player).GetSEMan().AddStatusEffect((StatusEffect)(object)data.StatusEffect, false, 0, 0f) as TransmogMaganger; if ((Object)(object)5__1 == (Object)null) { return false; } 5__1.m_timer = 5__1.m_countdown + 1f; ((StatusEffect)5__1).m_ttl = timeLeft; ((StatusEffect)5__1).m_time = 0f; 5__1.m_showCountdown = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static GameObject m_root = null; private const string TriggerTransformationRpc = "TransmogAPI_RPC_TriggerTransformation"; private const string RuneInstanceIdKey = "TransmogRuneId"; private const string ArmorVariantCustomDataPrefix = "TransmogArmorVariant_"; private const string ArmorVariantZdoKey = "TransmogArmorVariant"; private static readonly Dictionary m_appliedArmorVariants = new Dictionary(); [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] private static readonly MethodInfo m_setupEquipmentMethod = AccessTools.DeclaredMethod(typeof(Humanoid), "SetupEquipment", (Type[])null, (Type[])null); private static readonly Dictionary bundleCache = new Dictionary(); private static readonly Dictionary> m_configurations = new Dictionary>(); private static GameObject m_playerPrefab = null; private static readonly Dictionary m_registry = new Dictionary(); public static readonly Dictionary m_sourceToCreatures = new Dictionary(); private static readonly Dictionary m_creatures = new Dictionary(); public static readonly Dictionary m_itemToCreatures = new Dictionary(); private static readonly Dictionary m_runeToCreatures = new Dictionary(); private static readonly Dictionary m_trophyToSoulCreatures = new Dictionary(); private static readonly List m_prefabsToRegister = new List(); private static readonly List> m_globalConfigurations = new List>(); [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1 })] private static Func m_trophySoulEnabledPredicate; public static string m_currentModel = ""; private static float m_defaultCameraMaxDistance; public static string m_currentCreature = ""; private static bool m_runJumpInputPressed; private static bool m_loaded; private const string SaveKeyPrefix = "TransmogAPI:"; private static readonly FieldInfo s_respawnAfterDeathField = typeof(Game).GetField("m_respawnAfterDeath", BindingFlags.Instance | BindingFlags.NonPublic); private 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)) { string name = "TransmogAPI.assets.mar_transmog"; Dictionary dictionary = bundleCache; AssetBundle? obj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)([<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] (AssetBundle a) => ((Object)a).name == assetBundleFileName)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(name)); AssetBundle result = obj; dictionary[key] = obj; return result; } return value; } public CreatureFormManager(GameObject root) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Expected O, but got Unknown //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Expected O, but got Unknown //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Expected O, but got Unknown //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Expected O, but got Unknown //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Expected O, but got Unknown //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Expected O, but got Unknown //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Expected O, but got Unknown //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Expected O, but got Unknown //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Expected O, but got Unknown //IL_056b: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Expected O, but got Unknown //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Expected O, but got Unknown //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Expected O, but got Unknown //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Expected O, but got Unknown //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_0668: Expected O, but got Unknown //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Expected O, but got Unknown //IL_06d2: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Expected O, but got Unknown //IL_070f: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Expected O, but got Unknown //IL_0777: Unknown result type (might be due to invalid IL or missing references) //IL_0784: Expected O, but got Unknown //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07c0: Expected O, but got Unknown //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_07fc: Expected O, but got Unknown //IL_082a: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Expected O, but got Unknown //IL_0867: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Expected O, but got Unknown m_root = root; Harmony val = new Harmony("com.marlthon.transmogapi"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_FejdStartup", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Game), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Game_Awake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_Awake", (Type[])null, (Type[])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(Application), "CallLogCallback", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Application", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(BaseAI), "IsEnemy", new Type[2] { typeof(Character), typeof(Character) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_BaseAI_IsEnemy", (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(CreatureFormManager), "Patch_ObjectDB", (Type[])null, (Type[])null)) { priority = 0 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Character), "SyncVelocity", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Character_SyncVelocity", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Humanoid), "StartAttack", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Humanoid_StartAttack", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetControls", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_SetControls", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "UpdateDodge", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_UpdateDodge", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Character), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Character_Awake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Character), "UpdateFlying", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Character_UpdateFlying", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "OnSwimming", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_OnSwimming", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "UpdateStats", new Type[1] { typeof(float) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_UpdateStats", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_Update", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetSkinColor", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_SetSkinColor", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetHairColor", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_SetHairColor", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetPlayerModel", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_SetPlayerModel", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetupVisEquipment", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_SetupVisEquipment", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(VisEquipment), "AttachArmor", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_VisEquipment_AttachArmor", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(VisEquipment), "AttachItem", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_VisEquipment_AttachItem", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Humanoid), "UnequipItem", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Humanoid_UnEquipItem", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Humanoid), "EquipItem", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Humanoid_EquipItem", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(GameCamera), "GetCameraPosition", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_GameCamera_GetCameraPosition", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(GameCamera), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_GameCamera_Awake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Humanoid), "UseItem", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Humanoid_UseItem_Rune", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "ConsumeItem", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_ConsumeItem_Rune", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "ConsumeItem", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_ConsumeItem", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); PatchTemporaryRuneHighlights(val, typeof(HotkeyBar), "UpdateIcons"); PatchTemporaryRuneHighlights(val, typeof(InventoryGrid), "UpdateGui"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Character), "GetLookYaw", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Character_GetLookYaw", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Attack), "GetMeleeAttackDir", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Attack_GetMeleeAttackDir", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Game), "Logout", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Game_Logout", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Game), "SavePlayerProfile", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Game_Logout", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "OnSpawned", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_Player_OnSpawned", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void PatchTemporaryRuneHighlights(Harmony harmony, Type type, string methodName) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0058: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(type, methodName, (Type[])null, (Type[])null); if (!(methodInfo == null)) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_RuneHighlightPrefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CreatureFormManager), "Patch_RuneHighlightFinalizer", (Type[])null, (Type[])null)), (HarmonyMethod)null); } } [PublicAPI] public static void ConfigureCreature(string prefabName, Action configureAction) { m_configurations[prefabName] = configureAction; } [PublicAPI] public static void ConfigureAllCreatures(Action configureAction) { m_globalConfigurations.Add(configureAction); } [PublicAPI] public static void SetTrophySoulEnabledPredicate(Func predicate) { m_trophySoulEnabledPredicate = predicate; } [Description("Trigger transformation on a player, set duration of effect")] public static bool TriggerTransformation(Player player, string creature, float duration) { if ((Object)(object)player == (Object)null) { return false; } CreatureForm creature2 = GetCreature(creature); if (creature2 == null) { return false; } if ((Object)(object)player == (Object)(object)Player.m_localPlayer || ((Object)(object)((Character)player).m_nview != (Object)null && ((Character)player).m_nview.IsOwner())) { return ApplyTransformation(player, creature, duration); } if ((Object)(object)((Character)player).m_nview == (Object)null || !((Character)player).m_nview.IsValid()) { return false; } ((Character)player).m_nview.InvokeRPC("TransmogAPI_RPC_TriggerTransformation", new object[2] { creature, duration }); return true; } public static void Revert(Player player) { List list = new List(from x in ((Character)player).GetSEMan().GetStatusEffects() where x is TransmogMaganger select x); foreach (StatusEffect item in list) { ((Character)player).GetSEMan().RemoveStatusEffect(item, false); } } [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] public static CreatureForm GetRegisteredCreature(string sourcePrefab) { CreatureForm value; return m_registry.TryGetValue(sourcePrefab, out value) ? value : null; } [Description("Returns all registered creature forms")] public static List GetAllRegisteredCreatures() { return m_registry.Values.ToList(); } [Description("Returns all created creature forms")] public static Dictionary GetAllCreatureForms() { return m_creatures; } [Description("Returns true if instance is creature form, example: IsCreature(Player.m_localPlayer.name)")] public static bool IsCreatureForm(string prefabName) { return m_creatures.ContainsKey(prefabName.Replace("(Clone)", string.Empty)); } [Description("Returns data of the creature form, example: TryGetCreature(Player.m_localPlayer.name)")] public static bool TryGetCreature(string prefabName, out CreatureForm creatureForm) { return m_creatures.TryGetValue(prefabName.Replace("(Clone)", string.Empty), out creatureForm); } [Description("Returns true if creature can be shapeshifted into, example: IsValidPrefabName('Boar')")] public static bool IsValidPrefabName(string prefabName) { return m_sourceToCreatures.ContainsKey(prefabName); } [Description("Returns creature data, example: GetCreature('Boar')")] [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] public static CreatureForm GetCreature(string prefab) { CreatureForm value; return (!m_sourceToCreatures.TryGetValue(prefab, out value)) ? null : value; } [Description("Returns source prefab to creature dictionary")] public static Dictionary GetSourceToCreatureFormDict() { return m_sourceToCreatures; } private static void ApplyGlobalConfigurations(CreatureForm form) { for (int i = 0; i < m_globalConfigurations.Count; i++) { m_globalConfigurations[i](form); } } private static void ApplyGlobalConfigurationsToRegisteredCreatures() { foreach (CreatureForm value in m_registry.Values) { ApplyGlobalConfigurations(value); } } private static void Patch_Application(string logString, string stackTrace, LogType type, ref bool __runOriginal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)type == 2 && logString.Contains("Invalid Layer Index '1'")) { __runOriginal = false; } } private static void Patch_BaseAI_IsEnemy(Character a, Character b, ref bool __result) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (!__result) { return; } Faction faction; if (TryGetCreature(((Object)a).name, out var creatureForm)) { if (!Utility.IsNullOrWhiteSpace(creatureForm.Group)) { faction = b.GetFaction(); if (string.Equals(((object)(Faction)(ref faction)).ToString(), creatureForm.Group, StringComparison.OrdinalIgnoreCase)) { __result = false; } } } else if (TryGetCreature(((Object)b).name, out creatureForm) && !Utility.IsNullOrWhiteSpace(creatureForm.Group)) { faction = a.GetFaction(); if (string.Equals(((object)(Faction)(ref faction)).ToString(), creatureForm.Group, StringComparison.OrdinalIgnoreCase)) { __result = false; } } } private static void Patch_FejdStartup(FejdStartup __instance) { if (m_loaded) { return; } Dictionary dictionary = new Dictionary { { "label_shapeshift", "Transmog" }, { "label_shapeshift_desc", "Take the form of" }, { "msg_shapeshift", "Shapeshifting to" }, { "label_duration", "Duration" }, { "label_disabled", "DISABLED" }, { "msg_require_melee", "Missing melee weapon" }, { "msg_require_ranged", "Missing ranged weapon" }, { "label_saddle", "Saddle" }, { "label_friendly", "Allied with" }, { "label_wolves", "wolves" }, { "label_boars", "boars" }, { "label_loxen", "loxen" }, { "label_chickens", "chickens" }, { "label_asksvins", "asksvins" }, { "label_mist_vision", "Mist Vision" } }; foreach (KeyValuePair item in dictionary) { LocalizeKey localizeKey = new LocalizeKey(item.Key); localizeKey.English(item.Value); } LoadDefaultCreatures(); ApplyGlobalConfigurationsToRegisteredCreatures(); m_playerPrefab = __instance.m_playerPrefab; EnsureTrophySoulItemsForCurrentObjectDB(); m_loaded = true; } private static void Patch_Game_Awake(Game __instance) { if ((Object)(object)__instance.m_playerPrefab != (Object)null) { m_playerPrefab = __instance.m_playerPrefab; } } private static void Patch_Player_Awake(Player __instance) { RegisterTransformationRpc(__instance); } private static void Patch_ObjectDB() { if (!Object.op_Implicit((Object)(object)ZNetScene.instance) || !EnsurePlayerPrefab()) { return; } foreach (CreatureForm item in m_registry.Values.Where([<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] (CreatureForm c) => !m_creatures.ContainsKey("Shapeshift_" + (Utility.IsNullOrWhiteSpace(c.OverrideName) ? c.SourcePrefabName : c.OverrideName)))) { item.Setup(); } foreach (CreatureForm value in m_creatures.Values) { value.EnsureTrophySoulItem(); RegisterToScene(value.Prefab); ItemDrop consumeItem = value.ConsumeItem; if (consumeItem != null) { RegisterToScene(((Component)consumeItem).gameObject); RegisterToDB(((Component)consumeItem).gameObject); } RegisterStatusEffect((StatusEffect)(object)value.StatusEffect); } foreach (GameObject item2 in m_prefabsToRegister) { RegisterToScene(item2); } } private static void EnsureTrophySoulItemsForCurrentObjectDB() { if ((Object)(object)ObjectDB.instance == (Object)null) { return; } foreach (CreatureForm value in m_registry.Values) { value.EnsureTrophySoulItemFromObjectDBTrophy(); if ((Object)(object)value.SoulItemDrop != (Object)null) { RegisterToDB(((Component)value.SoulItemDrop).gameObject); } } } private static bool Patch_Character_SyncVelocity(Character __instance) { if ((Object)(object)__instance == (Object)null) { return false; } if ((Object)(object)__instance.m_nview == (Object)null) { return false; } if (__instance.m_nview.GetZDO() == null) { return false; } if (!__instance.m_nview.GetZDO().IsValid()) { return false; } if ((Object)(object)__instance.m_body == (Object)null) { return false; } return true; } private static bool Patch_Humanoid_StartAttack(Humanoid __instance, bool secondaryAttack, ref bool __result) { if (!TryGetCreature(((Object)__instance).name, out var creatureForm)) { return true; } if (creatureForm.UsePlayerAnimator) { return true; } __result = creatureForm.OnStartAttack?.Invoke(creatureForm, __instance, secondaryAttack) ?? false; return false; } private static void Patch_Player_SetControls(Player __instance, bool block, bool jump, bool run) { if (TryGetCreature(((Object)__instance).name, out var creatureForm)) { bool flag = run || ZInput.GetButton("Run") || ZInput.GetButton("JoyRun"); bool flag2 = jump || ZInput.GetButton("Jump") || ZInput.GetButton("JoyJump"); bool flag3 = flag && flag2; bool flag4 = flag3 && !m_runJumpInputPressed; m_runJumpInputPressed = flag3; if ((!flag4 || !creatureForm.TryRunJump(__instance)) && !creatureForm.UsePlayerAnimator && (!((Character)__instance).InAttack() || ((Humanoid)__instance).HaveQueuedChain()) && !((Character)__instance).InDodge() && ((Character)__instance).CanMove() && !((Character)__instance).IsKnockedBack() && !((Character)__instance).IsStaggering() && !((Character)__instance).InMinorAction()) { creatureForm.OnSetControls?.Invoke(creatureForm, __instance, block, jump); } } } private static bool Patch_Player_UpdateDodge(Player __instance, float dt) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (!TryGetCreature(((Object)__instance).name, out var creatureForm)) { return true; } if (creatureForm.UsePlayerAnimator) { return true; } __instance.m_queuedDodgeTimer -= dt; if ((double)__instance.m_queuedDodgeTimer > 0.0 && ((Character)__instance).IsOnGround() && !((Character)__instance).IsDead() && !((Character)__instance).InAttack() && !((Character)__instance).IsEncumbered() && !((Character)__instance).InDodge() && !((Character)__instance).IsStaggering()) { float num = __instance.m_dodgeStaminaUsage - __instance.m_dodgeStaminaUsage * ((Character)__instance).GetEquipmentMovementModifier() + __instance.m_dodgeStaminaUsage * ((Character)__instance).GetEquipmentDodgeStaminaModifier(); ((Character)__instance).m_seman.ModifyDodgeStaminaUsage(num, ref num, true); if (((Character)__instance).HaveStamina(num)) { ((Humanoid)__instance).ClearActionQueue(); __instance.m_queuedDodgeTimer = 0f; __instance.m_dodgeInvincible = true; creatureForm.OnDodge?.Invoke(creatureForm, __instance); ((Character)__instance).AddNoise(5f); ((Character)__instance).UseStamina(num); Transform transform = ((Component)__instance).transform; __instance.m_dodgeEffects.Create(transform.position, Quaternion.identity, transform, 1f, -1); __instance.m_inDodge = true; } else { Hud.instance.StaminaBarEmptyFlash(); __instance.m_inDodge = false; } } else { __instance.m_inDodge = false; } __instance.m_dodgeInvincibleCached = false; return false; } private static void Patch_Character_Awake(Character __instance) { if (TryGetCreature(((Object)__instance).name, out var creatureForm) && !Utility.IsNullOrWhiteSpace(creatureForm.HeadTransform) && !(creatureForm.HeadTransform == "Head")) { __instance.m_head = Utils.FindChild(((Component)__instance).transform, creatureForm.HeadTransform, (IterativeSearchType)0); } } private static void Patch_Character_GetLookYaw(Character __instance, ref Quaternion __result) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (__instance is Player && TryGetCreature(((Object)__instance).name, out var creatureForm) && creatureForm.InvertLookYaw) { Quaternion val = __instance.m_lookYaw * Quaternion.Euler(0f, 180f, 0f); __result = val; } } private static void Patch_Attack_GetMeleeAttackDir(Attack __instance, ref Vector3 attackDir) { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && TryGetCreature(((Object)val).name, out var creatureForm) && creatureForm.InvertLookYaw) { attackDir = Vector3.Reflect(attackDir, Vector3.up); } } private static bool Patch_Character_UpdateFlying(Character __instance, float dt) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null) { return true; } if (!TryGetCreature(((Object)__instance).name, out var creatureForm)) { return true; } if (!creatureForm.CanFly || !__instance.IsFlying()) { return true; } if (__instance.m_run) { float num = val.m_runStaminaDrain * Mathf.Lerp(1f, 0.5f, val.m_skills.GetSkillFactor((SkillType)102)); float num2 = num - num * ((Character)val).GetEquipmentMovementModifier(); float num3 = num2 + num2 * ((Character)val).GetEquipmentRunStaminaModifier(); __instance.UseStamina(dt * num3 * Game.m_moveStaminaRate); } Character.takeInputDelay = Mathf.Max(new float[3] { 0f, 0f, Character.takeInputDelay - dt }); float num4 = (__instance.m_run ? __instance.m_flyFastSpeed : __instance.m_flySlowSpeed) * __instance.GetAttackSpeedFactorMovement(); Vector3 val2 = __instance.m_moveDir * num4; bool flag = ((Vector3)(ref __instance.m_moveDir)).magnitude > 0f; if (((Character)val).HaveStamina(1f) && flag) { float y = num4 * Mathf.Sin((0f - val.m_lookPitch) * ((float)Math.PI / 180f)); val2.y = y; } else if (!((Character)val).HaveStamina(1f)) { val2.y -= 1f; } Transform transform = ((Component)val).transform; ((Character)val).m_currentVel = Vector3.Lerp(((Character)val).m_currentVel, val2, creatureForm.FlyAcceleration); ((Character)val).m_body.linearVelocity = ((Character)val).m_currentVel; ((Character)val).m_body.useGravity = false; ((Character)val).m_lastGroundTouch = 0f; ((Character)val).m_maxAirAltitude = transform.position.y; if (flag) { if (creatureForm.InvertLookYaw) { Quaternion val3 = ((Character)val).m_lookYaw * Quaternion.Euler(0f, 180f, 0f); ((Character)val).m_body.rotation = Quaternion.RotateTowards(transform.rotation, val3, 100f * dt); } else { ((Character)val).m_body.rotation = Quaternion.RotateTowards(transform.rotation, ((Character)val).m_lookYaw, 100f * dt); } } ((Character)val).m_body.angularVelocity = Vector3.zero; ((Character)val).UpdateEyeRotation(); float num5 = Vector3.Dot(__instance.m_currentVel, ((Component)__instance).transform.forward); float num6 = Vector3.Dot(__instance.m_currentVel, ((Component)__instance).transform.right); __instance.m_zanim.SetFloat(Character.s_forwardSpeed, num5); __instance.m_zanim.SetFloat(Character.s_sidewaySpeed, num6); __instance.m_zanim.SetFloat(Character.s_turnSpeed, __instance.m_currentTurnVel); __instance.m_zanim.SetBool(Character.s_inWater, false); __instance.m_zanim.SetBool(Character.s_onGround, false); __instance.m_zanim.SetBool(Character.s_encumbered, false); __instance.m_zanim.SetBool(Character.s_flying, true); return false; } private static bool Patch_Player_OnSwimming(Player __instance, Vector3 targetVel, float dt) { if (!TryGetCreature(((Object)__instance).name, out var creatureForm)) { return true; } if (!creatureForm.WaterCreature) { return true; } if ((double)((Vector3)(ref targetVel)).magnitude > 0.10000000149011612) { float num = Mathf.Lerp(__instance.m_swimStaminaDrainMinSkill, __instance.m_swimStaminaDrainMaxSkill, __instance.m_skills.GetSkillFactor((SkillType)103)); float num2 = num + num * ((Character)__instance).GetEquipmentSwimStaminaModifier(); ((Character)__instance).m_seman.ModifySwimStaminaUsage(num2, ref num2, true); ((Character)__instance).UseStamina(dt * num2 * Game.m_moveStaminaRate); __instance.m_swimSkillImproveTimer += dt; if ((double)__instance.m_swimSkillImproveTimer > 1.0) { __instance.m_swimSkillImproveTimer = 0f; ((Character)__instance).RaiseSkill((SkillType)103, 1f); } } if (((Character)__instance).HaveStamina(0f)) { return false; } __instance.m_drownDamageTimer += dt; if ((double)__instance.m_drownDamageTimer <= 1.0) { return false; } __instance.m_drownDamageTimer = 0f; return false; } private static bool Patch_Player_UpdateStats(Player __instance, float dt) { if (!TryGetCreature(((Object)__instance).name, out var creatureForm)) { return true; } if (!creatureForm.WaterCreature) { return true; } if (((Character)__instance).InIntro() || ((Character)__instance).IsTeleporting()) { return false; } __instance.m_timeSinceDeath += dt; __instance.UpdateModifiers(); __instance.UpdateFood(dt, false); bool flag = ((Character)__instance).IsEncumbered(); float maxStamina = ((Character)__instance).GetMaxStamina(); float num = 1f; if (((Character)__instance).IsBlocking()) { num *= 0.8f; } if (((Character)__instance).InAttack() || ((Character)__instance).InDodge() || (((Character)__instance).m_wallRunning ? true : false) || (flag ? true : false)) { num = 0f; } float num2 = (__instance.m_staminaRegen + (float)(1.0 - (double)__instance.m_stamina / (double)maxStamina) * __instance.m_staminaRegen * __instance.m_staminaRegenTimeMultiplier) * num; float num3 = 1f; ((Character)__instance).m_seman.ModifyStaminaRegen(ref num3); float num4 = num2 * num3; __instance.m_staminaRegenTimer -= dt; if ((double)__instance.m_stamina < (double)maxStamina && (double)__instance.m_staminaRegenTimer <= 0.0) { __instance.m_stamina = Mathf.Min(maxStamina, __instance.m_stamina + num4 * dt * Game.m_staminaRegenRate); } ((Character)__instance).m_nview.GetZDO().Set(ZDOVars.s_stamina, __instance.m_stamina); float maxEitr = ((Character)__instance).GetMaxEitr(); float num5 = 1f; if (((Character)__instance).IsBlocking()) { num5 *= 0.8f; } if (((Character)__instance).InAttack() || ((Character)__instance).InDodge()) { num5 = 0f; } float num6 = (__instance.m_eiterRegen + (float)(1.0 - (double)__instance.m_eitr / (double)maxEitr) * __instance.m_eiterRegen) * num5; float num7 = 1f; ((Character)__instance).m_seman.ModifyEitrRegen(ref num7); float num8 = num7 + __instance.GetEquipmentEitrRegenModifier(); float num9 = num6 * num8; __instance.m_eitrRegenTimer -= dt; if ((double)__instance.m_eitr < (double)maxEitr && (double)__instance.m_eitrRegenTimer <= 0.0) { __instance.m_eitr = Mathf.Min(maxEitr, __instance.m_eitr + num9 * dt); } ((Character)__instance).m_nview.GetZDO().Set(ZDOVars.s_eitr, __instance.m_eitr); if (flag) { if ((double)((Vector3)(ref ((Character)__instance).m_moveDir)).magnitude > 0.10000000149011612) { ((Character)__instance).UseStamina(__instance.m_encumberedStaminaDrain * dt); } ((Character)__instance).m_seman.AddStatusEffect(SEMan.s_statusEffectEncumbered, false, 0, 0f); __instance.ShowTutorial("encumbered", false); } else { ((Character)__instance).m_seman.RemoveStatusEffect(SEMan.s_statusEffectEncumbered, false); } if (!__instance.HardDeath()) { ((Character)__instance).m_seman.AddStatusEffect(SEMan.s_statusEffectSoftDeath, false, 0, 0f); } else { ((Character)__instance).m_seman.RemoveStatusEffect(SEMan.s_statusEffectSoftDeath, false); } __instance.UpdateEnvStatusEffects(dt); return false; } private static bool Patch_Player_SetSkinColor(Player __instance) { return (Object)(object)((Humanoid)__instance).m_visEquipment != (Object)null; } private static bool Patch_Player_SetHairColor(Player __instance) { return (Object)(object)((Humanoid)__instance).m_visEquipment != (Object)null; } private static bool Patch_Player_SetPlayerModel(Player __instance) { return (Object)(object)((Humanoid)__instance).m_visEquipment != (Object)null; } private static bool Patch_Player_SetupVisEquipment(Player __instance) { if ((Object)(object)((Humanoid)__instance).m_visEquipment == (Object)null) { return false; } if ((Object)(object)((Character)__instance).m_nview == (Object)null || ((Character)__instance).m_nview.GetZDO() == null) { return false; } return true; } private static void Patch_VisEquipment_AttachArmor(VisEquipment __instance, int itemHash, ref List __result) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (!TryGetCreature(((Object)__instance).name, out var creatureForm)) { return; } if (creatureForm.HideArmor) { foreach (GameObject item in __result) { item.SetActive(false); } } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash); ItemDrop component = itemPrefab.GetComponent(); List list = creatureForm.OnAttachArmor?.Invoke(creatureForm, __instance, component.m_itemData.m_shared.m_itemType) ?? new List(); if (list.Count <= 0) { return; } foreach (GameObject item2 in __result) { Object.Destroy((Object)(object)item2); } __result = list; } private static void Patch_VisEquipment_AttachItem(VisEquipment __instance, int itemHash, ref GameObject __result) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 if (!TryGetCreature(((Object)__instance).name, out var creatureForm)) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash); ItemDrop component = itemPrefab.GetComponent(); bool flag = (int)component.m_itemData.m_shared.m_itemType == 6; if (flag) { if (creatureForm.HideHelmet) { __result.SetActive(false); } } else if (creatureForm.HideWeapons) { __result.SetActive(false); } GameObject val = creatureForm.OnAttachItem?.Invoke(creatureForm, __instance, flag); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)__result); __result = val; } } private static void Patch_Humanoid_UnEquipItem(Humanoid __instance, [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] ItemData item) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (item != null && TryGetCreature(((Object)__instance).name, out var creatureForm) && item.m_shared.m_itemType == creatureForm.LevelEffectTrigger) { creatureForm.OnUnEquipItem?.Invoke(creatureForm, __instance, item); } } private static void Patch_Humanoid_EquipItem(Humanoid __instance, [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] ItemData item) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (item != null && TryGetCreature(((Object)__instance).name, out var creatureForm) && item.m_shared.m_itemType == creatureForm.LevelEffectTrigger) { creatureForm.OnEquipItem?.Invoke(creatureForm, __instance, item); } } private static void Patch_GameCamera_GetCameraPosition(GameCamera __instance, float dt, ref Vector3 pos, ref Quaternion rot) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || !TryGetCreature(((Object)localPlayer).name, out var creatureForm) || (Object)(object)localPlayer == (Object)null || (creatureForm.OnGetCameraPosition == null && creatureForm.OnGetCameraRotation == null)) { return; } Vector3? val = creatureForm.OnGetCameraPosition?.Invoke(__instance, localPlayer); if (val.HasValue) { Vector3 valueOrDefault = val.GetValueOrDefault(); if (true) { float num = __instance.m_distance; Vector3 val2 = -((Component)((Character)localPlayer).m_eye).transform.forward; if (__instance.m_smoothYTilt && !((Character)localPlayer).InIntro()) { num = Mathf.Lerp(num, 1.5f, Utils.SmoothStep(0f, -0.5f, val2.y)); } Vector3 val3 = valueOrDefault + val2 * num; pos = val3; } } Quaternion? val4 = creatureForm.OnGetCameraRotation?.Invoke(__instance, localPlayer); if (val4.HasValue) { Quaternion valueOrDefault2 = val4.GetValueOrDefault(); if (true) { rot = valueOrDefault2; } } } private static void Patch_GameCamera_Awake(GameCamera __instance) { m_defaultCameraMaxDistance = __instance.m_maxDistance; } private static void Patch_Player_ConsumeItem(Player __instance, ref bool __result) { if (__result && IsCreatureForm(((Object)__instance).name)) { ((Character)__instance).m_animator.SetTrigger("consume"); } } private static void Patch_Game_Logout() { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } PlayerProfile val = Game.instance?.m_playerProfile; if (val == null) { return; } foreach (string item in val.m_knownCommands.Keys.Where([<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] (string k) => k.StartsWith("TransmogAPI:")).ToList()) { val.m_knownCommands.Remove(item); } TransmogMaganger transmogMaganger = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffects().OfType() .FirstOrDefault(); if ((Object)(object)transmogMaganger != (Object)null && transmogMaganger.m_shifted && !Utility.IsNullOrWhiteSpace(m_currentCreature)) { float num = ((StatusEffect)transmogMaganger).m_ttl - ((StatusEffect)transmogMaganger).m_time; if (num > 0f) { val.m_knownCommands["TransmogAPI:" + m_currentCreature] = num; } } } private static void Patch_Player_OnSpawned(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || ((Object)(object)Game.instance != (Object)null && s_respawnAfterDeathField?.GetValue(Game.instance) is int num && num != 0)) { return; } PlayerProfile val = Game.instance?.m_playerProfile; if (val == null) { return; } KeyValuePair keyValuePair = val.m_knownCommands.FirstOrDefault([<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] (KeyValuePair kv) => kv.Key.StartsWith("TransmogAPI:") && kv.Value > 0f); if (keyValuePair.Key != null) { string prefab = keyValuePair.Key.Substring("TransmogAPI:".Length); float value = keyValuePair.Value; val.m_knownCommands.Remove(keyValuePair.Key); CreatureForm creature = GetCreature(prefab); if (creature != null) { ((MonoBehaviour)__instance).StartCoroutine(RestoreTransformationCoroutine(__instance, creature, value)); } } } [IteratorStateMachine(typeof(d__77))] private static IEnumerator RestoreTransformationCoroutine(Player player, CreatureForm data, float timeLeft) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__77(0) { player = player, data = data, timeLeft = timeLeft }; } private static void RegisterStatusEffect(StatusEffect status) { if (!ObjectDB.instance.m_StatusEffects.Contains(status)) { ObjectDB.instance.m_StatusEffects.Add(status); } } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(2)] private static void RegisterToScene(GameObject prefab) { if (!((Object)(object)prefab == (Object)null) && !((Object)(object)ZNetScene.instance == (Object)null)) { if (!ZNetScene.instance.m_prefabs.Contains(prefab)) { ZNetScene.instance.m_prefabs.Add(prefab); } ZNetScene.instance.m_namedPrefabs[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = prefab; } } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(2)] private static void RegisterToDB(GameObject prefab) { if ((Object)(object)prefab == (Object)null || (Object)(object)ObjectDB.instance == (Object)null) { return; } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); for (int i = 0; i < ObjectDB.instance.m_items.Count; i++) { GameObject val = ObjectDB.instance.m_items[i]; if (!((Object)(object)val == (Object)null) && StringExtensionMethods.GetStableHashCode(((Object)val).name) == stableHashCode) { ObjectDB.instance.m_items[i] = prefab; ObjectDB.instance.m_itemByHash[stableHashCode] = prefab; return; } } ObjectDB.instance.m_items.Add(prefab); ObjectDB.instance.m_itemByHash[stableHashCode] = prefab; } private static bool EnsurePlayerPrefab() { if ((Object)(object)m_playerPrefab != (Object)null) { return true; } if ((Object)(object)Game.instance != (Object)null && (Object)(object)Game.instance.m_playerPrefab != (Object)null) { m_playerPrefab = Game.instance.m_playerPrefab; return true; } if ((Object)(object)ZNetScene.instance != (Object)null) { foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab == (Object)null || ((Object)prefab).name != "Player" || !Object.op_Implicit((Object)(object)prefab.GetComponent())) { continue; } m_playerPrefab = prefab; return true; } } Debug.LogWarning((object)"[TransmogAPI] Player prefab is not available yet; delaying creature form setup."); return false; } private static void RegisterTransformationRpc(Player player) { if (!((Object)(object)player == (Object)null) && !((Object)(object)((Character)player).m_nview == (Object)null)) { int stableHashCode = StringExtensionMethods.GetStableHashCode("TransmogAPI_RPC_TriggerTransformation"); if (!((Character)player).m_nview.m_functions.ContainsKey(stableHashCode)) { ((Character)player).m_nview.Register("TransmogAPI_RPC_TriggerTransformation", (Action)RPC_TriggerTransformation); } } } private static void RPC_TriggerTransformation(long sender, string creature, float duration) { if (!((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)((Character)Player.m_localPlayer).m_nview == (Object)null) && ((Character)Player.m_localPlayer).m_nview.IsOwner()) { ApplyTransformation(Player.m_localPlayer, creature, duration); } } private static bool ApplyTransformation(Player player, string creature, float duration) { if ((Object)(object)player == (Object)null) { return false; } CreatureForm creature2 = GetCreature(creature); if (creature2 == null) { return false; } StatusEffect val = ((Character)player).GetSEMan().AddStatusEffect((StatusEffect)(object)creature2.StatusEffect, true, 0, 0f); if (val == null) { val = ((Character)player).GetSEMan().GetStatusEffect(((StatusEffect)creature2.StatusEffect).NameHash()); } if ((Object)(object)val == (Object)null) { return false; } val.m_ttl = duration; val.ResetTime(); return true; } private static void Patch_Player_Update(Player __instance) { if ((Object)(object)__instance == (Object)null || ((Character)__instance).IsDead()) { return; } CreatureForm creatureForm = GetCreatureForm(__instance); if (creatureForm != null && creatureForm.EnableArmorVariants) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && (Object)(object)((Character)__instance).m_nview != (Object)null && ((Character)__instance).m_nview.IsOwner()) { HandleArmorVariantInput(__instance, creatureForm); EnsureArmorVariantNetworkState(__instance, creatureForm); } ApplyArmorVariantFromNetwork(__instance, creatureForm); } } [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] private static CreatureForm GetCreatureForm(Player player) { string prefabName = Utils.GetPrefabName(((Object)((Component)player).gameObject).name); CreatureForm value; return m_creatures.TryGetValue(prefabName, out value) ? value : null; } private static void HandleArmorVariantInput(Player player, CreatureForm data) { if (CanReadArmorVariantInput() && (ZInput.GetButton("AltPlace") || ZInput.GetButton("JoyAltPlace") || ZInput.GetButton("JoyAltKeys"))) { if (ZInput.GetKeyDown((KeyCode)275, true)) { SetArmorVariant(player, data, GetSavedArmorVariant(player, data) + 1); } else if (ZInput.GetKeyDown((KeyCode)276, true)) { SetArmorVariant(player, data, GetSavedArmorVariant(player, data) - 1); } } } private static bool CanReadArmorVariantInput() { if (InventoryGui.IsVisible() || Menu.IsVisible() || Minimap.IsOpen() || Console.IsVisible()) { return false; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return false; } if (Hud.InRadial() || Hud.IsPieceSelectionVisible()) { return false; } if (PlayerCustomizaton.IsBarberGuiVisible()) { return false; } return true; } private static void EnsureArmorVariantNetworkState(Player player, CreatureForm data) { if (!((Object)(object)((Character)player).m_nview == (Object)null) && ((Character)player).m_nview.IsValid()) { int savedArmorVariant = GetSavedArmorVariant(player, data); if (((Character)player).m_nview.GetZDO().GetInt("TransmogArmorVariant", 0) != savedArmorVariant) { ((Character)player).m_nview.GetZDO().Set("TransmogArmorVariant", savedArmorVariant); } } } private static int GetSavedArmorVariant(Player player, CreatureForm data) { int variant = data.DefaultArmorVariant; if (player.m_customData.TryGetValue(GetArmorVariantCustomDataKey(data), out var value) && int.TryParse(value, out var result)) { variant = result; } return data.ClampArmorVariant(variant); } private static string GetArmorVariantCustomDataKey(CreatureForm data) { return "TransmogArmorVariant_" + (Utility.IsNullOrWhiteSpace(data.OverrideName) ? data.SourcePrefabName : data.OverrideName); } private static void SetArmorVariant(Player player, CreatureForm data, int variant) { int num = data.ClampArmorVariant(variant); player.m_customData[GetArmorVariantCustomDataKey(data)] = num.ToString(); if ((Object)(object)((Character)player).m_nview != (Object)null && ((Character)player).m_nview.IsValid()) { ((Character)player).m_nview.GetZDO().Set("TransmogArmorVariant", num); } ApplyArmorVariant(player, data, num, force: true); } private static void ApplyArmorVariantFromNetwork(Player player, CreatureForm data) { int variant = data.DefaultArmorVariant; if ((Object)(object)((Character)player).m_nview != (Object)null && ((Character)player).m_nview.IsValid()) { variant = ((Character)player).m_nview.GetZDO().GetInt("TransmogArmorVariant", GetSavedArmorVariant(player, data)); } ApplyArmorVariant(player, data, data.ClampArmorVariant(variant), force: false); } private static void ApplyArmorVariant(Player player, CreatureForm data, int variant, bool force) { int instanceID = ((Object)player).GetInstanceID(); int value; bool flag = m_appliedArmorVariants.TryGetValue(instanceID, out value); if (!force && flag && value == variant) { return; } bool flag2 = flag && value != variant; m_appliedArmorVariants[instanceID] = variant; Transform val = ((Component)player).transform; if (!Utility.IsNullOrWhiteSpace(data.ArmorVariantRoot)) { Transform val2 = FindArmorVariantTransform(((Component)player).transform, data.ArmorVariantRoot); if ((Object)(object)val2 == (Object)null) { return; } val = val2; } if (!Utility.IsNullOrWhiteSpace(data.BaseArmorBody)) { Transform val3 = FindArmorVariantTransform(((Component)player).transform, data.BaseArmorBody); if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(false); } } bool flag3 = false; string armorVariantObjectName = data.GetArmorVariantObjectName(variant); Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Transform val4 in componentsInChildren) { if (!((Object)(object)val4 == (Object)(object)val) && ((Object)val4).name.StartsWith(data.ArmorVariantPrefix, StringComparison.Ordinal) && data.TryGetArmorVariantIndex(((Object)val4).name, out var variant2) && variant2 >= data.FirstArmorVariant && variant2 <= data.ArmorVariantCount) { ((Component)val4).gameObject.SetActive(((Object)val4).name == armorVariantObjectName); flag3 = true; } } if (!flag3) { for (int j = data.FirstArmorVariant; j <= data.ArmorVariantCount; j++) { Transform val5 = FindArmorVariantTransform(val, data.GetArmorVariantObjectName(j)); if (!((Object)(object)val5 == (Object)null)) { ((Component)val5).gameObject.SetActive(j == variant); } } } if (flag2) { PlayArmorVariantEffect(player, data, val); } } [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] private static Transform FindArmorVariantTransform(Transform root, string nameOrPath) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown if ((Object)(object)root == (Object)null || Utility.IsNullOrWhiteSpace(nameOrPath)) { return null; } string text = nameOrPath.Replace('\\', '/'); if (text.IndexOf('/') >= 0) { Transform val = root; string[] array = text.Split(new char[1] { '/' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { Transform val2 = null; foreach (Transform item in val) { Transform val3 = item; if (((Object)val3).name != array[i]) { continue; } val2 = val3; break; } if ((Object)(object)val2 == (Object)null) { return null; } val = val2; } return val; } return Utils.FindChild(root, nameOrPath, (IterativeSearchType)0); } private static void PlayArmorVariantEffect(Player player, CreatureForm data, Transform root) { //IL_006c: 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_0090: Unknown result type (might be due to invalid IL or missing references) if (data.EnableArmorVariantEffect && !Utility.IsNullOrWhiteSpace(data.ArmorVariantEffect)) { Transform val = Utils.FindChild(root, data.ArmorVariantEffect, (IterativeSearchType)0); if (!((Object)(object)val == (Object)null)) { GameObject val2 = Object.Instantiate(((Component)val).gameObject, val.parent, false); ((Object)val2).name = ((Object)val).name + "_Runtime"; val2.transform.localPosition = val.localPosition; val2.transform.localRotation = val.localRotation; val2.transform.localScale = val.localScale; val2.SetActive(true); ((MonoBehaviour)player).StartCoroutine(PlayArmorVariantEffectCoroutine(val2, data.ArmorVariantEffectDuration)); } } } [IteratorStateMachine(typeof(d__97))] private static IEnumerator PlayArmorVariantEffectCoroutine(GameObject effect, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__97(0) { effect = effect, duration = duration }; } private static bool Patch_Player_ConsumeItem_Rune(Player __instance, Inventory inventory, ItemData item, ref bool __result) { if (!TryUseRune(__instance, inventory, item, out var result)) { return true; } __result = result; return false; } private static bool Patch_Humanoid_UseItem_Rune(Humanoid __instance, Inventory inventory, ItemData item) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null) { return true; } if (TryCreateSoulFromTrophies(val, inventory, item)) { return false; } bool result; return !TryUseRune(val, inventory, item, out result); } private static bool TryCreateSoulFromTrophies(Player player, Inventory inventory, ItemData item) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 if ((Object)(object)player == (Object)null || item == null) { return false; } if (inventory == null) { inventory = ((Humanoid)player).GetInventory(); } if (inventory == null || !inventory.ContainsItem(item)) { return false; } if ((int)item.m_shared.m_itemType != 13) { return false; } if (!m_trophyToSoulCreatures.TryGetValue(item.m_shared.m_name, out var value) && !TryCreateSoulMappingFromClickedTrophy(item, out value)) { GameObject dropPrefab = item.m_dropPrefab; Debug.Log((object)("[TransmogAPI] No Soul mapping found for trophy '" + (((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? item.m_shared.m_name) + "'.")); return false; } if (!value.IsTrophySoulEnabled() || (Object)(object)value.SoulItemDrop == (Object)null) { return false; } int num = Mathf.Max(1, value.TrophySoulCost); int num2 = CountItems(inventory, item.m_shared.m_name); if (num2 < num) { ((Character)player).Message((MessageType)2, $"Need {num} trophies to create a soul.", 0, (Sprite)null); return true; } GameObject gameObject = ((Component)value.SoulItemDrop).gameObject; if (!inventory.CanAddItem(gameObject, 1)) { ((Character)player).Message((MessageType)2, "$msg_noroom", 0, (Sprite)null); return true; } inventory.RemoveItem(item.m_shared.m_name, num, -1, false); ItemData val = inventory.AddItem(((Object)gameObject).name, 1, 1, 0, player.GetPlayerID(), player.GetPlayerName(), true); if (val != null) { val.m_durability = value.Duration; } inventory.Changed(); ((Character)player).Message((MessageType)2, "Created " + value.GetSoulDisplayName() + ".", 0, (Sprite)null); return true; } private static bool TryCreateSoulMappingFromClickedTrophy(ItemData item, out CreatureForm data) { data = null; GameObject val = (((Object)(object)item.m_dropPrefab != (Object)null) ? item.m_dropPrefab : (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(item.m_shared) : null)); if ((Object)(object)val == (Object)null) { return false; } string name = ((Object)val).name; if (!name.StartsWith("Trophy", StringComparison.Ordinal)) { return false; } string text = name.Substring("Trophy".Length); if (Utility.IsNullOrWhiteSpace(text)) { return false; } if (!m_sourceToCreatures.TryGetValue(text, out data) && !m_sourceToCreatures.TryGetValue(text.Replace("_", ""), out data)) { return false; } data.EnableTrophySoul = true; data.TrophySoulTrophyItem = name; data.EnsureTrophySoulItemFromTrophy(val); return (Object)(object)data.SoulItemDrop != (Object)null; } private static int CountItems(Inventory inventory, string sharedName) { int num = 0; List allItems = inventory.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { ItemData val = allItems[i]; if (val.m_shared.m_name == sharedName) { num += val.m_stack; } } return num; } private static bool TryUseRune(Player player, Inventory inventory, ItemData item, out bool result) { result = false; if (item == null) { return false; } if (inventory == null) { inventory = ((Humanoid)player).GetInventory(); } if (!inventory.ContainsItem(item)) { return false; } if (!m_runeToCreatures.TryGetValue(item.m_shared.m_name, out var data)) { return false; } TransmogMaganger transmogMaganger = ((Character)player).GetSEMan().GetStatusEffects().OfType() .FirstOrDefault([<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] (TransmogMaganger effect) => effect.m_data == data); if ((Object)(object)transmogMaganger != (Object)null) { ((Character)player).GetSEMan().RemoveStatusEffect((StatusEffect)(object)transmogMaganger, false); result = true; return true; } float num = Mathf.Max(1f, (item.m_durability > 0f) ? item.m_durability : data.Duration); StatusEffect val = ((Character)player).GetSEMan().AddStatusEffect((StatusEffect)(object)data.StatusEffect, true, 0, 0f); TransmogMaganger transmogMaganger2 = (val as TransmogMaganger) ?? (((Character)player).GetSEMan().GetStatusEffect(((StatusEffect)data.StatusEffect).NameHash()) as TransmogMaganger); if ((Object)(object)transmogMaganger2 == (Object)null) { result = false; return true; } item.m_durability = num; if (!item.m_customData.TryGetValue("TransmogRuneId", out var value) || Utility.IsNullOrWhiteSpace(value)) { value = Guid.NewGuid().ToString("N"); item.m_customData["TransmogRuneId"] = value; } ((StatusEffect)transmogMaganger2).m_ttl = num; transmogMaganger2.m_boundRuneSharedName = item.m_shared.m_name; transmogMaganger2.m_boundRunePrefabName = (Object.op_Implicit((Object)(object)item.m_dropPrefab) ? ((Object)item.m_dropPrefab).name : data.RuneItem); transmogMaganger2.m_boundRuneInstanceId = value; transmogMaganger2.m_removeRuneWhenExpired = true; inventory.Changed(); result = true; return true; } private static void Patch_RuneHighlightPrefix(Player player, [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1 })] ref List __state) { if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead()) { return; } List list = new List(); List allItems = ((Humanoid)player).GetInventory().GetAllItems(); for (int i = 0; i < allItems.Count; i++) { ItemData val = allItems[i]; if (!val.m_equipped && IsActiveRune(player, val)) { val.m_equipped = true; list.Add(val); } } __state = ((list.Count > 0) ? list : null); } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(2)] private static Exception Patch_RuneHighlightFinalizer([<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1 })] List __state, Exception __exception) { if (__state != null) { for (int i = 0; i < __state.Count; i++) { __state[i].m_equipped = false; } } return __exception; } private static bool IsActiveRune(Player player, ItemData item) { List statusEffects = ((Character)player).GetSEMan().GetStatusEffects(); for (int i = 0; i < statusEffects.Count; i++) { if (statusEffects[i] is TransmogMaganger transmogMaganger && transmogMaganger.IsBoundRune(item)) { return true; } } return false; } [Description("To load default creatures in the game, with all data setup, modify data after")] private static void LoadDefaultCreatures() { //IL_0533: Unknown result type (might be due to invalid IL or missing references) CreatureForm Boar = new CreatureForm("Boar") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "boar_base_attack") }; CreatureForm creatureForm = new CreatureForm("Boar_piggy") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "boar_base_attack"), OnSetupFinish = delegate(CreatureForm data) { Animator componentInChildren7 = Boar.Prefab.GetComponentInChildren(); if (componentInChildren7 != null) { Animator componentInChildren8 = data.Prefab.GetComponentInChildren(); if (componentInChildren8 != null) { componentInChildren8.runtimeAnimatorController = componentInChildren7.runtimeAnimatorController; foreach (KeyValuePair allItem in Boar.AllItems) { data.AllItems[allItem.Key] = allItem.Value; } } } } }; CreatureForm creatureForm2 = new CreatureForm("Neck") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Neck_BiteAttack") }; CreatureForm creatureForm3 = new CreatureForm("Greyling") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Greyling_attack"), HeadTransform = "head" }; CreatureForm creatureForm4 = new CreatureForm("Eikthyr") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Eikthyr_antler", "Eikthyr_charge"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Eikthyr_stomp"); } }; CreatureForm creatureForm5 = new CreatureForm("Deer") { OnEquipItem = delegate(CreatureForm data, Humanoid instance, ItemData item) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_010b: Unknown result type (might be due to invalid IL or missing references) if ((int)item.m_shared.m_itemType == 6) { List list20 = new List { "Antler 01", "Antlers 04", "Antlers 05" }; List list21 = new List(); foreach (string item in list20) { Transform val42 = Utils.FindChild(((Component)instance).transform, item, (IterativeSearchType)0); if (val42 != null) { list21.Add(((Component)val42).gameObject); ((Component)val42).gameObject.SetActive(false); } } list21[Random.Range(0, list21.Count)].SetActive(true); LevelEffects componentInChildren6 = ((Component)instance).GetComponentInChildren(); if (componentInChildren6 != null) { LevelSetup val43 = componentInChildren6.m_levelSetups[0]; ((Component)componentInChildren6).transform.localScale = new Vector3(val43.m_scale, val43.m_scale, val43.m_scale); } } }, OnUnEquipItem = delegate(CreatureForm data, Humanoid instance, ItemData item) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_00dd: Unknown result type (might be due to invalid IL or missing references) if ((int)item.m_shared.m_itemType == 6) { List list19 = new List { "Antler 01", "Antlers 04", "Antlers 05" }; foreach (string item2 in list19) { Transform val40 = Utils.FindChild(((Component)instance).transform, item2, (IterativeSearchType)0); if (val40 != null) { ((Component)val40).gameObject.SetActive(false); } } LevelEffects componentInChildren5 = ((Component)instance).GetComponentInChildren(); if (componentInChildren5 != null) { LevelSetup val41 = componentInChildren5.m_levelSetups[1]; ((Component)componentInChildren5).transform.localScale = new Vector3(val41.m_scale, val41.m_scale, val41.m_scale); } } }, OnCreateStatusEffect = delegate(CreatureForm data) { ((SE_Stats)data.StatusEffect).m_runStaminaDrainModifier = -0.5f; } }; CreatureForm creatureForm6 = new CreatureForm("Ghost") { UsePlayerAnimator = true, HideWeapons = false, HideArmor = false, HideHelmet = false }; CreatureForm creatureForm7 = new CreatureForm("Greydwarf") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Greydwarf_attack", "Greydwarf_throw"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Greydwarf_attack"); } }; CreatureForm creatureForm8 = new CreatureForm("Greydwarf_Shaman") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Greydwarf_shaman_attack", "Greydwarf_shaman_attack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Greydwarf_shaman_heal"); } }; CreatureForm creatureForm9 = new CreatureForm("Greydwarf_Elite") { RequireWeapon = true, HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Greydwarf_elite_attack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Greydwarf_elite_attack"); } }; CreatureForm creatureForm10 = new CreatureForm("Troll") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "troll_punch", "troll_groundslam"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "troll_throw"); } }; CreatureForm creatureForm11 = new CreatureForm("Skeleton") { UsePlayerAnimator = true, HideWeapons = false, HideArmor = false }; CreatureForm creatureForm12 = new CreatureForm("Skeleton_Hildir") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "skeleton_sword_hildir", "skeleton_hildir_firenova"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "skeleton_sword_hildir"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? null : data.Attach(visEq, leftHand: false, "skeleton_sword_hildir") }; CreatureForm creatureForm13 = new CreatureForm("Skeleton_Poison") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "skeleton_mace"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "skeleton_mace"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? null : data.Attach(visEq, leftHand: false, "skeleton_mace") }; CreatureForm obj = new CreatureForm("gd_king") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "gd_king_stomp", "gd_king_rootspawn"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "gd_king_shoot"); } }; Faction val = (Faction)2; obj.Group = ((object)(Faction)(ref val)).ToString(); CreatureForm creatureForm14 = obj; CreatureForm creatureForm15 = new CreatureForm("Abomination") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Abomination_attack1", "Abomination_attack2"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Abomination_attack3"); }, HeadTransform = "head" }; CreatureForm creatureForm16 = new CreatureForm("Leech") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Leech_BiteAttack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Leech_BiteAttack"); }, WaterCreature = true }; CreatureForm creatureForm17 = new CreatureForm("Wraith") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "wraith_melee"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "wraith_melee"); }, CanFly = true }; CreatureForm creatureForm18 = new CreatureForm("Draugr") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "draugr_axe"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "draugr_axe"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? null : data.Attach(visEq, leftHand: false, "draugr_axe") }; CreatureForm creatureForm19 = new CreatureForm("Draugr_Ranged") { RequireWeapon = true, RequireRanged = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "draugr_bow"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "draugr_bow"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? null : data.Attach(visEq, leftHand: false, "draugr_bow") }; CreatureForm creatureForm20 = new CreatureForm("Draugr_Elite") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "draugr_sword"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "draugr_sword"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? null : data.Attach(visEq, leftHand: false, "draugr_sword") }; CreatureForm creatureForm21 = new CreatureForm("BogWitchKvastur") { HeadTransform = "Shaft", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "BogWitchKvastur_attack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "BogWitchKvastur_attack"); } }; CreatureForm creatureForm22 = new CreatureForm("Blob") { HeadTransform = "Bone.002", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "blob_attack_aoe"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "blob_attack_aoe"); }, OnCreateStatusEffect = delegate(CreatureForm data) { ((SE_Stats)data.StatusEffect).m_fallDamageModifier = -1f; } }; CreatureForm creatureForm23 = new CreatureForm("BlobElite") { HeadTransform = "Bone.002", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "blobelite_attack_aoe"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "blobelite_attack_aoe"); }, OnCreateStatusEffect = delegate(CreatureForm data) { ((SE_Stats)data.StatusEffect).m_fallDamageModifier = -1f; } }; CreatureForm creatureForm24 = new CreatureForm("Surtling") { HeadTransform = "mixamorig:Head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "imp_fireball_attack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "imp_fireball_attack"); } }; CreatureForm creatureForm25 = new CreatureForm("Bonemass") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "bonemass_attack_punch", "bonemass_attack_aoe"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "bonemass_attack_throw"); }, OnSetupFinish = delegate(CreatureForm data) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) if (data.AllItems.TryGetValue("bonemass_attack_throw", out var value5)) { GameObject val31 = Object.Instantiate(value5, m_root.transform, false); ((Object)val31).name = "bonemass_attack_throw_friendly"; ItemDrop val32 = default(ItemDrop); if (val31.TryGetComponent(ref val32)) { GameObject attackProjectile5 = val32.m_itemData.m_shared.m_attack.m_attackProjectile; if (attackProjectile5 != null) { GameObject val33 = Object.Instantiate(attackProjectile5, m_root.transform, false); ((Object)val33).name = "bonemass_throw_projectile_friendly"; val32.m_itemData.m_shared.m_attack.m_attackProjectile = val33; m_prefabsToRegister.Add(val33); Projectile val34 = default(Projectile); if (val33.TryGetComponent(ref val34)) { GameObject spawnOnHit3 = val34.m_spawnOnHit; if (spawnOnHit3 != null) { GameObject val35 = Object.Instantiate(spawnOnHit3, m_root.transform, false); ((Object)val35).name = "bonemass_spawn_friendly"; val34.m_spawnOnHit = val35; SpawnAbility val36 = default(SpawnAbility); if (val35.TryGetComponent(ref val36)) { List list18 = new List(); GameObject[] spawnPrefab4 = val36.m_spawnPrefab; Character val39 = default(Character); foreach (GameObject val37 in spawnPrefab4) { if (!((Object)(object)val37 == (Object)null)) { string name4 = ((Object)val37).name + "_bonemass_friendly"; GameObject val38 = Object.Instantiate(val37, m_root.transform, false); ((Object)val38).name = name4; if (val38.TryGetComponent(ref val39)) { val39.m_faction = (Faction)0; m_prefabsToRegister.Add(val38); list18.Add(val38); } } } val36.m_spawnPrefab = list18.ToArray(); data.AllItems["bonemass_attack_throw"] = val31; } } } } } } } }; CreatureForm Fenring = new CreatureForm("Fenring") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Fenring_attack_claw", "Fenring_attack_jump"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Fenring_taunt"); } }; CreatureForm creatureForm26 = new CreatureForm("Bjorn") { TrophySoulTrophyItem = "TrophyBjorn", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "bjorn_bite", "bjorn_claws"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "bjorn_slam"); } }; CreatureForm creatureForm27 = new CreatureForm("Fenring_Cultist") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Fenring_attack_fireclaw", "Fenring_attack_fireclaw_double"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Fenring_attack_flames"); }, OnSetupFinish = delegate(CreatureForm data) { foreach (KeyValuePair allItem2 in Fenring.AllItems) { data.AllItems[allItem2.Key] = allItem2.Value; } } }; CreatureForm creatureForm28 = new CreatureForm("Fenring_Cultist_Hildir") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Fenring_attack_iceclaw", "Fenring_attack_iceclaw_double"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list17 = new List { "Fenring_attack_frost", "Fenring_attack_IceNova" }; data.OverrideSetControls(instance, block, jump, list17[Random.Range(0, list17.Count)]); } }; CreatureForm Wolf = new CreatureForm("Wolf") { OnStartAttack = delegate(CreatureForm data, Humanoid instance, bool secondary) { string primaryAttack2; if (data.AttackIndex == 1) { primaryAttack2 = "Wolf_Attack2"; data.AttackIndex = 2; } else if (data.AttackIndex == 2) { primaryAttack2 = "Wolf_Attack3"; data.AttackIndex = 0; } else { primaryAttack2 = "Wolf_Attack1"; data.AttackIndex = 1; } return data.OverrideAttack(instance, secondary, primaryAttack2); }, OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { string blockAttack; if (data.AttackIndex == 1) { blockAttack = "Wolf_Attack2"; data.AttackIndex = 2; } else if (data.AttackIndex == 2) { blockAttack = "Wolf_Attack3"; data.AttackIndex = 0; } else { blockAttack = "Wolf_Attack1"; data.AttackIndex = 1; } data.OverrideSetControls(instance, block, jump, blockAttack); } }; CreatureForm creatureForm29 = new CreatureForm("Wolf_cub") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Wolf_Attack1", "Wolf_Attack2"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Wolf_Attack3"); }, OnSetupFinish = delegate(CreatureForm data) { Animator componentInChildren3 = Wolf.Prefab.GetComponentInChildren(); if (componentInChildren3 != null) { Animator componentInChildren4 = data.Prefab.GetComponentInChildren(); if (componentInChildren4 != null) { componentInChildren4.runtimeAnimatorController = componentInChildren3.runtimeAnimatorController; foreach (KeyValuePair allItem3 in Wolf.AllItems) { data.AllItems[allItem3.Key] = allItem3.Value; } } } } }; CreatureForm creatureForm30 = new CreatureForm("StoneGolem") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "stonegolem_attack1_spike", "stonegolem_attack3_spikesweep"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "stonegolem_attack1_spike"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => data.AttachSkin(visEq, helmet ? "StoneGolem_hat" : "StoneGolem_spikes") }; CreatureForm creatureForm31 = new CreatureForm("Bat") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "bat_melee"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "bat_melee"); }, CanFly = true }; CreatureForm creatureForm32 = new CreatureForm("Hatchling") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "hatchling_spit_cold"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "hatchling_spit_cold"); }, CanFly = true }; CreatureForm creatureForm33 = new CreatureForm("Ulv") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Ulv_attack1_bite", "Ulv_attack2_slash"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Ulv_attack1_bite"); } }; CreatureForm creatureForm34 = new CreatureForm("Dragon") { FlyAcceleration = 10f, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => ((Character)instance).IsFlying() ? data.OverrideAttack(instance, secondary, "dragon_spit_shotgun") : data.OverrideAttack(instance, secondary, "dragon_bite", ZInput.GetButton("Left") ? "dragon_claw_left" : "dragon_claw_right"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { if (jump) { if (((Character)instance).IsFlying()) { ((Character)instance).Land(); } else { ((Character)instance).TakeOff(); } } if (block) { data.OverrideSetControls(instance, block, jump, ((Character)instance).IsFlying() ? "dragon_spit_shotgun" : "dragon_coldbreath"); } }, CanFly = true, OnGetCameraPosition = delegate(GameCamera camera, Player player) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)((Character)player).m_eye).transform; return transform.position + -transform.forward * 5f; }, CameraMaxDistance = 30f }; CreatureForm creatureForm35 = new CreatureForm("Deathsquito") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Deathsquito_sting"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Deathsquito_sting"); }, CanFly = true, InvertLookYaw = true }; CreatureForm creatureForm36 = new CreatureForm("Goblin") { UsePlayerAnimator = true, HideWeapons = false, HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "GoblinSpear"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "ShieldWood"); }, OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (1 == 0) { } List result12 = (((int)itemType == 7) ? data.OverrideAttachArmor(visEq, "GoblinArmband", "GoblinShoulders") : (((int)itemType != 11) ? new List() : data.OverrideAttachArmor(visEq, "GoblinLegband", "GoblinLoin"))); if (1 == 0) { } return result12; } }; CreatureForm creatureForm37 = new CreatureForm("GoblinBrute") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "GoblinBrute_Attack", "GoblinBrute_RageAttack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "GoblinBrute_Taunt"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "GoblinBrute_ExecutionerCap") : data.Attach(visEq, leftHand: false, "GoblinBrute_Attack"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (1 == 0) { } List result11 = (((int)itemType == 7) ? data.OverrideAttachArmor(visEq, "GoblinBrute_ArmGuard", "GoblinBrute_Backbones", "GoblinBrute_ShoulderGuard") : (((int)itemType != 11) ? new List() : data.OverrideAttachArmor(visEq, "GoblinBrute_HipCloth", "GoblinBrute_LegBones"))); if (1 == 0) { } return result11; } }; CreatureForm creatureForm38 = new CreatureForm("GoblinShaman") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "GoblinShaman_attack_fireball", "GoblinShaman_attack_poke"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "GoblinShaman_attack_protect"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "GoblinShaman_Headdress_antlers") : data.Attach(visEq, leftHand: true, "GoblinShaman_Staff_Feathers", "attach_L_Hand") }; CreatureForm creatureForm39 = new CreatureForm("GoblinBruteBros") { RequireWeapon = true, OnStartAttack = delegate(CreatureForm data, Humanoid instance, bool secondary) { List list16 = new List { "GoblinBruteBros_Attack", "GoblinShaman_attack_fireball_hildir" }; return data.OverrideAttack(instance, secondary, list16[Random.Range(0, list16.Count)], "GoblinBruteBros_RageAttack"); }, OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list15 = new List { "GoblinBrute_Taunt", "GolbinShaman_attack_protect_hildir" }; data.OverrideSetControls(instance, block, jump, list15[Random.Range(0, list15.Count)]); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? null : data.Attach(visEq, leftHand: false, "GoblinBruteBros_Attack"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (1 == 0) { } List result10 = (((int)itemType == 7) ? data.OverrideAttachArmor(visEq, "GoblinBrute_ArmGuard", "GoblinBrute_Backbones", "GoblinBrute_ShoulderGuard") : (((int)itemType != 11) ? new List() : data.OverrideAttachArmor(visEq, "GoblinBrute_HipCloth", "GoblinBrute_LegBones"))); if (1 == 0) { } return result10; } }; CreatureForm creatureForm40 = new CreatureForm("BlobTar") { HeadTransform = "Bone.002", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "blobtar_attack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "blobtar_attack"); }, OnCreateStatusEffect = delegate(CreatureForm data) { ((SE_Stats)data.StatusEffect).m_fallDamageModifier = -1f; } }; CreatureForm Lox = new CreatureForm("Lox") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "lox_bite", "lox_stomp"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "lox_bite"); } }; CreatureForm creatureForm41 = new CreatureForm("Lox_Calf") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "lox_bite", "lox_stomp"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "lox_bite"); }, OnSetupFinish = delegate(CreatureForm data) { Animator componentInChildren = Lox.Prefab.GetComponentInChildren(); if (componentInChildren != null) { Animator componentInChildren2 = data.Prefab.GetComponentInChildren(); if (componentInChildren2 != null) { componentInChildren2.runtimeAnimatorController = componentInChildren.runtimeAnimatorController; foreach (KeyValuePair allItem4 in Lox.AllItems) { data.AllItems[allItem4.Key] = allItem4.Value; } } } } }; CreatureForm creatureForm42 = new CreatureForm("GoblinKing") { HeadTransform = "Jaw", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "GoblinKing_Beam", "GoblinKing_Meteors"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "GoblinKing_Taunt"); }, CameraMaxDistance = 12f }; CreatureForm creatureForm43 = new CreatureForm("Hare") { OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm44 = new CreatureForm("Dverger") { RequireRanged = true, HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "DvergerArbalest_shoot", "Dverger_melee"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Dverger_melee"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "DvergerHairMale") : data.Attach(visEq, leftHand: false, "DvergerArbalest", "attach_r.hand"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if (1 == 0) { } List result9 = (((int)itemType != 7) ? new List() : data.OverrideAttachArmor(visEq, "DvergerSuitArbalest")); if (1 == 0) { } return result9; }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm45 = new CreatureForm("DvergerMage", "DvergerMageFire") { RequireWeapon = true, HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "DvergerStaffFire_fireball", "DvergerStaffFire_clusterbomb"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Dverger_melee"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "DvergerHairMale") : data.Attach(visEq, leftHand: false, "DvergerStaffFire", "attach_r.hand"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if (1 == 0) { } List result8 = (((int)itemType != 7) ? new List() : data.OverrideAttachArmor(visEq, "DvergerSuitFire")); if (1 == 0) { } return result8; }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm46 = new CreatureForm("DvergerMage", "DvergerMageIce") { RequireWeapon = true, HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "DvergerStaffIce_icebolt", "DvergerStaffNova"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Dverger_melee"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "DvergerHairMale") : data.Attach(visEq, leftHand: false, "DvergerStaffIce", "attach_r.hand"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if (1 == 0) { } List result7 = (((int)itemType != 7) ? new List() : data.OverrideAttachArmor(visEq, "DvergerSuitIce")); if (1 == 0) { } return result7; }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm47 = new CreatureForm("DvergerMage", "DvergerMageSupport") { RequireWeapon = true, HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "DvergerMistile", "DvergerStaffSupport_buff"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "DvergerStaffHeal_heal"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "DvergerHairMale") : data.Attach(visEq, leftHand: false, "DvergerStaffHeal", "attach_r.hand"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if (1 == 0) { } List result6 = (((int)itemType != 7) ? new List() : data.OverrideAttachArmor(visEq, "DvergerSuitSupport")); if (1 == 0) { } return result6; }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm48 = new CreatureForm("Chicken") { HeadTransform = "head" }; CreatureForm creatureForm49 = new CreatureForm("Hen") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "boar_base_attack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "boar_base_attack"); } }; CreatureForm creatureForm50 = new CreatureForm("Seeker") { HeadTransform = "head", OnStartAttack = delegate(CreatureForm data, Humanoid instance, bool secondary) { if (!((Character)instance).IsFlying()) { List list14 = new List { "seeker_claw_left", "seeker_claw_right" }; return data.OverrideAttack(instance, secondary, list14[Random.Range(0, list14.Count)], "seeker_groundslam"); } return data.OverrideAttack(instance, secondary, "seeker_groundslam_flying"); }, OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "seeker_pincers", "seeker_land", "seeker_takeoff"); }, CanFly = true, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm51 = new CreatureForm("SeekerBrute") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "SeekerBrute_bite", "SeekerBrute_groundslam"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list13 = new List { "SeekerBrute_Taunt", "SeekerBrute_ram" }; data.OverrideSetControls(instance, block, jump, list13[Random.Range(0, list13.Count)]); }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm52 = new CreatureForm("Gjall") { HeadTransform = "Forehead", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "gjall_attack_spit", "gjall_attack_egg"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list12 = new List { "gjall_attack_taunt", "gjall_attack_shake" }; data.OverrideSetControls(instance, block, jump, list12[Random.Range(0, list12.Count)]); }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; }, OnSetupFinish = delegate(CreatureForm data) { //IL_01a1: Unknown result type (might be due to invalid IL or missing references) if (data.AllItems.TryGetValue("gjall_attack_egg", out var value4)) { GameObject val22 = Object.Instantiate(value4, m_root.transform, false); ((Object)val22).name = "gjall_attack_egg_friendly"; ItemDrop val23 = default(ItemDrop); if (val22.TryGetComponent(ref val23)) { GameObject attackProjectile4 = val23.m_itemData.m_shared.m_attack.m_attackProjectile; if (attackProjectile4 != null) { GameObject val24 = Object.Instantiate(attackProjectile4, m_root.transform, false); ((Object)val24).name = "gjall_egg_projectile_friendly"; val23.m_itemData.m_shared.m_attack.m_attackProjectile = val24; Projectile val25 = default(Projectile); if (val24.TryGetComponent(ref val25)) { GameObject spawnOnHit2 = val25.m_spawnOnHit; if (spawnOnHit2 != null) { GameObject val26 = Object.Instantiate(spawnOnHit2, m_root.transform, false); ((Object)val26).name = "gjall_egg_spawn_friendly"; val25.m_spawnOnHit = val26; SpawnAbility val27 = default(SpawnAbility); if (val26.TryGetComponent(ref val27)) { List list11 = new List(); GameObject[] spawnPrefab3 = val27.m_spawnPrefab; Character val30 = default(Character); foreach (GameObject val28 in spawnPrefab3) { if (!((Object)(object)val28 == (Object)null)) { string name3 = ((Object)val28).name + "_gjall_friendly"; GameObject val29 = Object.Instantiate(val28, m_root.transform, false); ((Object)val29).name = name3; if (val29.TryGetComponent(ref val30)) { val30.m_faction = (Faction)0; m_prefabsToRegister.Add(val29); list11.Add(val29); } } } val27.m_spawnPrefab = list11.ToArray(); data.AllItems["gjall_attack_egg"] = val22; } } } } } } }, CameraMaxDistance = 30f, CanFly = true }; CreatureForm creatureForm53 = new CreatureForm("Tick") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "tick_attack_attach"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "tick_attack_attach"); }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm54 = new CreatureForm("SeekerBrood") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "babyseeker_attack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "babyseeker_attack"); }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; } }; CreatureForm creatureForm55 = new CreatureForm("SeekerQueen") { HeadTransform = "jaw", OnStartAttack = delegate(CreatureForm data, Humanoid instance, bool secondary) { List list10 = new List { "SeekerQueen_Bite", "SeekerQueen_Slap" }; return data.OverrideAttack(instance, secondary, list10[Random.Range(0, list10.Count)], "SeekerQueen_Rush"); }, OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list9 = new List { "SeekerQueen_Spit", "SeekerQueen_PierceAOE" }; data.OverrideSetControls(instance, block, jump, list9[Random.Range(0, list9.Count)]); }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_removeMistlandMist = true; }, CameraMaxDistance = 12f, OnSetupFinish = delegate(CreatureForm data) { //IL_01a1: Unknown result type (might be due to invalid IL or missing references) if (data.AllItems.TryGetValue("SeekerQueen_Spit", out var value3)) { GameObject val13 = Object.Instantiate(value3, m_root.transform, false); ((Object)val13).name = "SeekerQueen_Spit_friendly"; ItemDrop val14 = default(ItemDrop); if (val13.TryGetComponent(ref val14)) { GameObject attackProjectile3 = val14.m_itemData.m_shared.m_attack.m_attackProjectile; if (attackProjectile3 != null) { GameObject val15 = Object.Instantiate(attackProjectile3, m_root.transform, false); ((Object)val15).name = "SeekerQueen_projectile_spit_friendly"; val14.m_itemData.m_shared.m_attack.m_attackProjectile = val15; Projectile val16 = default(Projectile); if (val15.TryGetComponent(ref val16)) { GameObject spawnOnHit = val16.m_spawnOnHit; if (spawnOnHit != null) { GameObject val17 = Object.Instantiate(spawnOnHit, m_root.transform, false); ((Object)val17).name = "SeekerQueen_Spit_SpawnAbility_friendly"; val16.m_spawnOnHit = val17; SpawnAbility val18 = default(SpawnAbility); if (val17.TryGetComponent(ref val18)) { List list8 = new List(); GameObject[] spawnPrefab2 = val18.m_spawnPrefab; Character val21 = default(Character); foreach (GameObject val19 in spawnPrefab2) { if (!((Object)(object)val19 == (Object)null)) { string name2 = ((Object)val19).name + "_queen_friendly"; GameObject val20 = Object.Instantiate(val19, m_root.transform, false); ((Object)val20).name = name2; if (val20.TryGetComponent(ref val21)) { val21.m_faction = (Faction)0; m_prefabsToRegister.Add(val20); list8.Add(val20); } } } val18.m_spawnPrefab = list8.ToArray(); data.AllItems["SeekerQueen_Spit"] = val13; } } } } } } } }; CreatureForm creatureForm56 = new CreatureForm("Morgen") { HeadTransform = "Jaw", OnStartAttack = delegate(CreatureForm data, Humanoid instance, bool secondary) { string primaryAttack; if (data.AttackIndex == 1) { primaryAttack = "Morgen_swipe_1"; data.AttackIndex = 2; } else if (data.AttackIndex == 2) { primaryAttack = "Morgen_swipe_2"; data.AttackIndex = 3; } else if (data.AttackIndex == 3) { primaryAttack = "Morgen_swipe_3"; data.AttackIndex = 4; } else if (data.AttackIndex == 4) { primaryAttack = "Morgen_swipe_4"; data.AttackIndex = 0; } else { primaryAttack = "Morgen_bite"; data.AttackIndex = 1; } return data.OverrideAttack(instance, secondary, primaryAttack, "Morgen_bodyslam"); }, OnDodge = delegate(CreatureForm data, Player instance) { data.OverrideDodge(instance, "Morgen_roll_left", "Morgen_roll_right"); }, CameraMaxDistance = 12f }; CreatureForm creatureForm57 = new CreatureForm("FallenValkyrie") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "fallenvalkyrie_claws", "fallenvalkyrie_spin"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list7 = new List { "fallenvalkyrie_taunt", "fallenvalkyrie_spit" }; data.OverrideSetControls(instance, block, jump, list7[Random.Range(0, list7.Count)]); }, CameraMaxDistance = 16f, CanFly = true }; CreatureForm creatureForm58 = new CreatureForm("Troll_Summoned") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "troll_summoned_punch", "troll_summoned_groundslam"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "troll_summoned_throw"); } }; CreatureForm Asksvin = new CreatureForm("Asksvin") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Asksvin_Bite", "Asksvin_Headbutt"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Asksvin_Pounce"); } }; CreatureForm creatureForm59 = new CreatureForm("Asksvin_hatchling") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Asksvin_Bite", "Asksvin_Headbutt"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Asksvin_Pounce"); }, OnSetupFinish = delegate(CreatureForm data) { foreach (KeyValuePair allItem5 in Asksvin.AllItems) { data.AllItems[allItem5.Key] = allItem5.Value; } data.Prefab.GetComponentInChildren().runtimeAnimatorController = Asksvin.Prefab.GetComponentInChildren().runtimeAnimatorController; } }; CreatureForm creatureForm60 = new CreatureForm("Volture") { HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "volture_talons"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "volture_talons"); }, CanFly = true }; CreatureForm creatureForm61 = new CreatureForm("BlobLava") { HeadTransform = "Bone.002", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "blobLava_attack_aoe"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "blobLava_attack_aoe"); }, OnCreateStatusEffect = delegate(CreatureForm data) { data.StatusEffect.m_noSkillDrain = true; } }; CreatureForm creatureForm62 = new CreatureForm("Fader") { HeadTransform = "head", OnStartAttack = delegate(CreatureForm data, Humanoid instance, bool secondary) { List list5 = new List { "Fader_Bite", "Fader_Claw_Left", "Fader_Claw_Right" }; List list6 = new List { "Fader_Fissure", "Fader_Spin", "Fader_Meteors", "Fader_WallOfFire", "Fader_Meteors_Intense", "Fader_Fissure_Intense", "Fader_Flamebreath" }; return data.OverrideAttack(instance, secondary, list5[Random.Range(0, list5.Count)], list6[Random.Range(0, list6.Count)]); }, OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list4 = new List { "Fader_Roar", "Fader_Roar_Intense" }; data.OverrideSetControls(instance, block, jump, list4[Random.Range(0, list4.Count)]); } }; CreatureForm creatureForm63 = new CreatureForm("Charred_Melee_Dyrnwyn") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "charred_dyrnwyn_greatsword_swing", "charred_dyrnwyn_greatsword_thrust"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list3 = new List { "charred_dyrnwyn_greatsword_feint", "charred_dyrnwyn_greatsword_thrustfeint" }; data.OverrideSetControls(instance, block, jump, list3[Random.Range(0, list3.Count)]); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "Charred_Helmet") : data.Attach(visEq, leftHand: false, "charred_dyrnwyn_greatsword_swing"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (1 == 0) { } List result5 = (((int)itemType == 7) ? data.OverrideAttachArmor(visEq, "Charred_Breastplate") : (((int)itemType != 11) ? new List() : data.OverrideAttachArmor(visEq, "Charred_HipCloth"))); if (1 == 0) { } return result5; } }; CreatureForm creatureForm64 = new CreatureForm("Charred_Archer") { RequireRanged = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "charred_bow", "charred_bow_volley"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "charred_bow"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "Charred_Helmet") : data.Attach(visEq, leftHand: false, "charred_bow"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (1 == 0) { } List result4 = (((int)itemType == 7) ? data.OverrideAttachArmor(visEq, "Charred_Breastplate") : (((int)itemType != 11) ? new List() : data.OverrideAttachArmor(visEq, "Charred_HipCloth"))); if (1 == 0) { } return result4; }, OnSetupFinish = delegate(CreatureForm data) { if (data.AllItems.TryGetValue("charred_bow", out var value2)) { GameObject val9 = Object.Instantiate(value2, m_root.transform, false); ((Object)val9).name = "charred_bow_draw"; ItemDrop val10 = default(ItemDrop); if (val9.TryGetComponent(ref val10)) { m_prefabsToRegister.Add(val9); val10.m_itemData.m_shared.m_attack.m_bowDraw = true; GameObject attackProjectile2 = val10.m_itemData.m_shared.m_attack.m_attackProjectile; if (attackProjectile2 != null) { GameObject val11 = Object.Instantiate(attackProjectile2, m_root.transform, false); ((Object)val11).name = "charred_bow_projectile_player"; m_prefabsToRegister.Add(val11); Projectile val12 = default(Projectile); if (val11.TryGetComponent(ref val12)) { val10.m_itemData.m_shared.m_attack.m_attackProjectile = val11; val12.m_ttl = 20f; val12.m_gravity = 5f; data.AllItems["charred_bow"] = val9; } } } } } }; CreatureForm creatureForm65 = new CreatureForm("Charred_Melee") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "charred_greatsword_swing", "charred_greatsword_thrust"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { List list2 = new List { "charred_greatsword_feint", "charred_greatsword_thrustfeint" }; data.OverrideSetControls(instance, block, jump, list2[Random.Range(0, list2.Count)]); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "Charred_Helmet") : data.Attach(visEq, leftHand: false, "charred_greatsword_swing"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (1 == 0) { } List result3 = (((int)itemType == 7) ? data.OverrideAttachArmor(visEq, "Charred_Breastplate") : (((int)itemType != 11) ? new List() : data.OverrideAttachArmor(visEq, "Charred_HipCloth"))); if (1 == 0) { } return result3; } }; CreatureForm creatureForm66 = new CreatureForm("Charred_Mage") { RequireWeapon = true, OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "charred_magestaff_fire", "charred_magestaff_summon"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "charred_magestaff_fire"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "Charred_Helmet") : data.Attach(visEq, leftHand: false, "charred_magestaff_fire"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (1 == 0) { } List result2 = (((int)itemType == 7) ? data.OverrideAttachArmor(visEq, "Charred_MageCloths") : (((int)itemType != 11) ? new List() : data.OverrideAttachArmor(visEq, "Charred_HipCloth"))); if (1 == 0) { } return result2; }, OnSetupFinish = delegate(CreatureForm data) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (data.AllItems.TryGetValue("charred_magestaff_summon", out var value)) { GameObject val2 = Object.Instantiate(value, m_root.transform, false); ((Object)val2).name = "charred_magestaff_summon_friendly"; m_prefabsToRegister.Add(val2); ItemDrop val3 = default(ItemDrop); if (val2.TryGetComponent(ref val3)) { GameObject attackProjectile = val3.m_itemData.m_shared.m_attack.m_attackProjectile; if (attackProjectile != null) { GameObject val4 = Object.Instantiate(attackProjectile, m_root.transform, false); ((Object)val4).name = "charred_magestaff_summoncharred_friendly"; val3.m_itemData.m_shared.m_attack.m_attackProjectile = val4; SpawnAbility val5 = default(SpawnAbility); if (val4.TryGetComponent(ref val5)) { List list = new List(); GameObject[] spawnPrefab = val5.m_spawnPrefab; Character val8 = default(Character); foreach (GameObject val6 in spawnPrefab) { if (!((Object)(object)val6 == (Object)null)) { string name = ((Object)val6).name + "_summoned_friendly"; GameObject val7 = Object.Instantiate(val6, m_root.transform, false); ((Object)val7).name = name; if (val7.TryGetComponent(ref val8)) { val8.m_faction = (Faction)0; m_prefabsToRegister.Add(val7); list.Add(val7); } } } val5.m_spawnPrefab = list.ToArray(); data.AllItems["charred_magestaff_summon"] = val2; } } } } } }; CreatureForm creatureForm67 = new CreatureForm("Charred_Twitcher") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "charred_twitcher_throw", "charred_twitcher_scratch_l"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "charred_twitcher_scratch_r"); } }; CreatureForm creatureForm68 = new CreatureForm("DvergerAshlands") { RequireRanged = true, HeadTransform = "head", OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "DvergerArbalest_shootAshlands", "Dverger_meleeAshlands"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Dverger_melee"); }, OnAttachItem = [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] (CreatureForm data, VisEquipment visEq, bool helmet) => helmet ? data.AttachSkin(visEq, "DvergerHairMale_Redbeard") : data.Attach(visEq, leftHand: false, "DvergerArbalest", "attach_r.hand"), OnAttachArmor = delegate(CreatureForm data, VisEquipment visEq, ItemType itemType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if (1 == 0) { } List result = (((int)itemType != 7) ? new List() : data.OverrideAttachArmor(visEq, "DvergerSuitArbalest_Ashlands")); if (1 == 0) { } return result; } }; CreatureForm creatureForm69 = new CreatureForm("BonemawSerpent") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "BonemawSerpent_bite", "Bonemaw_serpent_spit"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "BonemawSerpent_taunt"); }, WaterCreature = true }; CreatureForm creatureForm70 = new CreatureForm("Serpent") { OnStartAttack = (CreatureForm data, Humanoid instance, bool secondary) => data.OverrideAttack(instance, secondary, "Serpent_attack"), OnSetControls = delegate(CreatureForm data, Player instance, bool block, bool jump) { data.OverrideSetControls(instance, block, jump, "Serpent_taunt"); }, WaterCreature = true, OnCreateStatusEffect = delegate(CreatureForm data) { ((SE_Stats)data.StatusEffect).m_swimStaminaUseModifier = -0.5f; } }; } } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(1)] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] internal static class Helpers { private static readonly List IgnoredProperties = new List { typeof(Transform), typeof(Transform[]) }; [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] public static T Convert<[<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] TSource, [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] T>(this GameObject obj) where TSource : MonoBehaviour where T : MonoBehaviour { TSource component = obj.GetComponent(); if ((Object)(object)component == (Object)null) { return default(T); } T val = obj.AddComponent(); if ((Object)(object)val == (Object)null) { return default(T); } FieldInfo[] fields = typeof(TSource).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] fields2 = typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo oldField in array) { if (oldField.IsPublic || ((MemberInfo)oldField).GetCustomAttribute() != null) { FieldInfo fieldInfo = fields2.FirstOrDefault([<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(0)] (FieldInfo f) => f.Name == oldField.Name && f.FieldType == oldField.FieldType); if (fieldInfo != null) { fieldInfo.SetValue(val, oldField.GetValue(component)); } } } Object.Destroy((Object)(object)component); return val; } [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] public static T Copy<[<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] T>(this GameObject target, GameObject source) where T : MonoBehaviour { T component = source.GetComponent(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)("No component of type " + typeof(T).Name + " found on the source GameObject.")); return default(T); } T val = target.GetComponent(); if ((Object)(object)val == (Object)null) { val = target.AddComponent(); } FieldInfo[] fields = typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (fieldInfo.IsPublic || ((MemberInfo)fieldInfo).GetCustomAttribute() != null) { FieldInfo field = typeof(T).GetField(fieldInfo.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == fieldInfo.FieldType && !IgnoredProperties.Contains(field.FieldType)) { fieldInfo.SetValue(val, fieldInfo.GetValue(component)); } } } return val; } public static void Remove<[<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] T>(this GameObject prefab) where T : Component { T val = default(T); if (prefab.TryGetComponent(ref val)) { Object.Destroy((Object)(object)val); } } public static string PluralizeGroup(string group) { return group.ToLower() switch { "wolf" => "$label_wolves", "boar" => "$label_boars", "lox" => "$label_loxen", "chicken" => "$label_chickens", "asksvin" => "$label_asksvins", _ => FormatPascal(group), }; } public static string FormatPascal(string input) { if (Utility.IsNullOrWhiteSpace(input)) { return input; } string text = Regex.Replace(input, "(?NullableContext(1)] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] internal class PlayerSaddle : MonoBehaviour, Interactable, Hoverable { public string m_hoverText = ""; public float m_maxUseRange = 10f; public Transform m_attachPoint = null; public Vector3 m_detachOffset = new Vector3(0f, 0.5f, 0f); public string m_attachAnimation = "attach_chair"; public Player m_character = null; public ZNetView m_nview = null; public bool m_haveValidRider; public float m_raiseSkillTimer; public void Awake() { if ((Object)(object)m_attachPoint == (Object)null) { m_attachPoint = ((Component)this).transform; } m_character = ((Component)this).gameObject.GetComponentInParent(); m_nview = ((Component)m_character).GetComponent(); m_nview.Register("RPC_RequestAttach", (Action)RPC_RequestAttach); m_nview.Register("RPC_RequestResponse", (Action)RPC_RequestResponse); } public bool IsValid() { return Object.op_Implicit((Object)(object)this); } public virtual void FixedUpdate() { if (m_nview.IsValid()) { CalculateHaveValidRider(); } } public bool IsLocalUser() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return false; } long rider = GetRider(); int result; if (rider != 0L) { ZDOID zDOID = ((Character)Player.m_localPlayer).GetZDOID(); result = ((rider == ((ZDOID)(ref zDOID)).UserID) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } public void RPC_RequestAttach(long sender, long playerID) { if (m_nview.IsValid()) { CalculateHaveValidRider(); if (GetRider() == playerID || !HaveValidRider()) { m_nview.GetZDO().Set(ZDOVars.s_user, playerID); m_nview.InvokeRPC(sender, "RPC_RequestResponse", new object[1] { true }); } else { m_nview.InvokeRPC(sender, "RPC_RequestResponse", new object[1] { false }); } } } public void RPC_RequestResponse(long sender, bool granted) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } if (granted) { if (!((Object)(object)m_attachPoint == (Object)null)) { ((Character)Player.m_localPlayer).AttachStart(m_attachPoint, ((Component)m_character).gameObject, false, false, false, m_attachAnimation, m_detachOffset, (Transform)null); } } else { ((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_inuse", 0, (Sprite)null); } } private bool HaveValidRider() { return m_haveValidRider; } public virtual void CalculateHaveValidRider() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) m_haveValidRider = false; if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return; } long rider = GetRider(); if (rider == 0) { return; } foreach (ZDO allCharacterZDO in ZNet.instance.GetAllCharacterZDOS()) { if (((ZDOID)(ref allCharacterZDO.m_uid)).UserID != rider) { continue; } m_haveValidRider = Vector3.Distance(allCharacterZDO.GetPosition(), ((Component)this).transform.position) < m_maxUseRange; break; } if (!m_haveValidRider) { m_nview.GetZDO().Set(ZDOVars.s_user, 0L); } } private long GetRider() { return ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) ? 0 : m_nview.GetZDO().GetLong(ZDOVars.s_user, 0L); } public virtual bool Interact(Humanoid user, bool hold, bool alt) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (hold || !m_nview.IsValid() || !InUseDistance(user)) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if (val == null) { return false; } ZNetView nview = m_nview; object[] array = new object[1]; ZDOID zDOID = ((Character)val).GetZDOID(); array[0] = ((ZDOID)(ref zDOID)).UserID; nview.InvokeRPC("RPC_RequestAttach", array); return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } public virtual string GetHoverText() { if (!InUseDistance((Humanoid)(object)Player.m_localPlayer)) { return Localization.instance.Localize("$piece_toofar"); } return Localization.instance.Localize(m_hoverText) + Localization.instance.Localize("\n[$KEY_Use] $piece_use"); } private bool InUseDistance(Humanoid human) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(((Component)human).transform.position, ((Component)m_attachPoint).transform.position) < m_maxUseRange; } public string GetHoverName() { return Localization.instance.Localize(m_hoverText); } } [<74866c26-b31b-4204-8a38-f8afc91577c4>NullableContext(1)] [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(0)] internal class TransmogMaganger : SE_Stats { public CreatureFormManager.CreatureForm m_data = null; public EffectList m_spawnEffects = new EffectList(); public EffectList m_doneEffects = new EffectList(); public bool m_shifted; public float m_timer; public bool m_removeMistlandMist; public float m_removeMistTimer; public float m_countdown = 5f; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(new byte[] { 2, 1 })] public Func OnGetTooltip; [<6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] public Action OnStop; public bool m_showCountdown = true; public bool m_noSkillDrain; private const string RuneInstanceIdKey = "TransmogRuneId"; public string m_boundRuneSharedName = ""; public string m_boundRunePrefabName = ""; public string m_boundRuneInstanceId = ""; public bool m_removeRuneWhenExpired; private bool m_runeRemoved; public override void Setup(Character character) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown if (!m_shifted) { ((StatusEffect)this).m_startEffects = m_spawnEffects; } ((SE_Stats)this).Setup(character); ((StatusEffect)this).m_startEffects = new EffectList(); ((StatusEffect)this).m_character.m_zanim.SetTrigger(((StatusEffect)this).m_activationAnimation); } public override void UpdateStatusEffect(float dt) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) ((SE_Stats)this).UpdateStatusEffect(dt); UpdateMistlandMist(dt); UpdateBoundRuneDurability(); if (m_noSkillDrain) { Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { val.m_timeSinceDeath = 0f; } } if (!m_shifted) { m_timer += dt; if (!(m_timer < m_countdown)) { Transform transform = ((Component)((StatusEffect)this).m_character).transform; m_doneEffects.Create(transform.position, transform.rotation, transform, 1f, -1); ((StatusEffect)this).m_time = 0f; ShapeShift(); } } } public void UpdateMistlandMist(float dt) { m_removeMistTimer += dt; if (!(m_removeMistTimer < 10f)) { m_removeMistTimer = 0f; SetMist(!m_removeMistlandMist); } } public void SetMist(bool enable) { if (Object.op_Implicit((Object)(object)ParticleMist.m_instance)) { ((Behaviour)ParticleMist.m_instance).enabled = enable; } } private void UpdateBoundRuneDurability() { if (Utility.IsNullOrWhiteSpace(m_boundRuneSharedName)) { return; } Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { ItemData val2 = FindBoundRune(val); if (val2 != null) { val2.m_durability = Mathf.Max(0f, ((StatusEffect)this).m_ttl - ((StatusEffect)this).m_time); ((Humanoid)val).GetInventory().Changed(); } } } [return: <6e8a0b3d-54b2-47d7-8210-ca83312b3358>Nullable(2)] private ItemData FindBoundRune(Player player) { List allItems = ((Humanoid)player).GetInventory().GetAllItems(); ItemData val = null; foreach (ItemData item in allItems) { if (IsBoundRunePrefab(item)) { if (IsBoundRuneInstance(item)) { return item; } if (val == null) { val = item; } } } return val; } public bool IsBoundRune(ItemData item) { if (!IsBoundRunePrefab(item)) { return false; } return Utility.IsNullOrWhiteSpace(m_boundRuneInstanceId) || IsBoundRuneInstance(item); } private bool IsBoundRunePrefab(ItemData item) { if (item.m_shared.m_name != m_boundRuneSharedName) { return false; } return Utility.IsNullOrWhiteSpace(m_boundRunePrefabName) || !Object.op_Implicit((Object)(object)item.m_dropPrefab) || ((Object)item.m_dropPrefab).name == m_boundRunePrefabName; } private bool IsBoundRuneInstance(ItemData item) { string value; return !Utility.IsNullOrWhiteSpace(m_boundRuneInstanceId) && item.m_customData.TryGetValue("TransmogRuneId", out value) && value == m_boundRuneInstanceId; } private void RemoveBoundRuneIfExpired() { if (m_runeRemoved || !m_removeRuneWhenExpired || ((StatusEffect)this).m_ttl <= 0f || ((StatusEffect)this).m_time < ((StatusEffect)this).m_ttl) { return; } Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { ItemData val2 = FindBoundRune(val); if (val2 != null) { m_runeRemoved = ((Humanoid)val).GetInventory().RemoveItem(val2); } } } public override void ModifyAttack(SkillType skill, ref HitData hitData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) ((SE_Stats)this).ModifyAttack(skill, ref hitData); Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { ItemData currentWeapon = ((Humanoid)val).GetCurrentWeapon(); if (currentWeapon != null) { ((DamageTypes)(ref hitData.m_damage)).Add(currentWeapon.m_shared.m_damages, 1); } } } public void ShapeShift() { if (m_shifted || (Object)(object)((StatusEffect)this).m_character != (Object)(object)Player.m_localPlayer) { return; } bool godMode = Player.m_localPlayer.m_godMode; bool debugFly = Player.m_localPlayer.m_debugFly; bool ghostMode = Player.m_localPlayer.m_ghostMode; List statusEffects = ((StatusEffect)this).m_character.GetSEMan().GetStatusEffects(); Player val = m_data.ShapeShift(); if ((Object)(object)val == (Object)null) { return; } m_shifted = true; foreach (StatusEffect item in statusEffects) { if (!(item is TransmogMaganger)) { ((Character)val).GetSEMan().AddStatusEffect(item, false, 0, 0f); } } ((Character)val).GetSEMan().AddStatusEffect((StatusEffect)(object)this, false, 0, 0f); val.m_godMode = godMode; val.m_debugFly = debugFly; val.m_ghostMode = ghostMode; } public override void Stop() { RemoveBoundRuneIfExpired(); ((StatusEffect)this).Stop(); SetMist(enable: true); if ((Object)(object)((StatusEffect)this).m_character != (Object)(object)Player.m_localPlayer) { return; } OnStop?.Invoke(); if (((Character)Player.m_localPlayer).IsDead()) { CreatureFormManager.m_currentCreature = ""; CreatureFormManager.m_currentModel = ""; return; } bool godMode = Player.m_localPlayer.m_godMode; bool debugFly = Player.m_localPlayer.m_debugFly; bool ghostMode = Player.m_localPlayer.m_ghostMode; List statusEffects = ((StatusEffect)this).m_character.GetSEMan().GetStatusEffects(); Player val = CreatureFormManager.CreatureForm.Revert(); if ((Object)(object)val == (Object)null) { return; } foreach (StatusEffect item in statusEffects) { if (!(item is TransmogMaganger)) { ((Character)val).GetSEMan().AddStatusEffect(item, false, 0, 0f); } } val.m_godMode = godMode; val.m_debugFly = debugFly; val.m_ghostMode = ghostMode; } public override string GetTooltipString() { string text = ((SE_Stats)this).GetTooltipString(); if (!Utility.IsNullOrWhiteSpace(m_data.Group)) { text = text + "$label_friendly " + Helpers.PluralizeGroup(m_data.Group) + "\n"; } if (m_removeMistlandMist) { text += "$label_mist_vision\n"; } text = text + "$label_duration: " + StatusEffect.GetTimeString(((StatusEffect)this).m_ttl, false, false) + "\n"; if (OnGetTooltip != null) { string text2 = OnGetTooltip(); text += text2; } return text; } public override string GetIconText() { if (!m_showCountdown) { return ((StatusEffect)this).GetIconText(); } return (!m_shifted) ? StatusEffect.GetTimeString(m_countdown - m_timer, false, false) : ((StatusEffect)this).GetIconText(); } } } namespace Microsoft.CodeAnalysis { [Embedded] [CompilerGenerated] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [Embedded] internal sealed class <18dd9431-1b89-4862-9d9a-8abd55cf6a54>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <18dd9431-1b89-4862-9d9a-8abd55cf6a54>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <18dd9431-1b89-4862-9d9a-8abd55cf6a54>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [Embedded] [CompilerGenerated] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [Embedded] [CompilerGenerated] internal sealed class <09d46cfc-7ca7-4c0a-ad86-25ed8de42eec>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <09d46cfc-7ca7-4c0a-ad86-25ed8de42eec>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ItemManager { [PublicAPI] internal enum CraftingTable { Disabled, Inventory, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("piece_MeadCauldron")] MeadCauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("piece_magetable")] MageTable, [InternalName("piece_preptable")] PrepTable, [InternalName("blackforge")] BlackForge, Custom } [PublicAPI] internal enum ConversionPiece { Disabled, [InternalName("smelter")] Smelter, [InternalName("charcoal_kiln")] CharcoalKiln, [InternalName("blastfurnace")] BlastFurnace, [InternalName("windmill")] Windmill, [InternalName("piece_spinningwheel")] SpinningWheel, [InternalName("eitrrefinery")] EitrRefinery, Custom } [NullableContext(1)] [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] internal class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [PublicAPI] [NullableContext(1)] [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] internal class RequiredResourceList { public readonly List Requirements = new List(); public bool Free; public void Add(string itemName, int amount, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amount = amount, quality = quality }); } public void Add(string itemName, ConfigEntry amountConfig, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amountConfig = amountConfig, quality = quality }); } } [NullableContext(1)] [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] [PublicAPI] internal class CraftingStationList { public readonly List Stations = new List(); public void Add(CraftingTable table, int level) { Stations.Add(new CraftingStationConfig { Table = table, level = level }); } public void Add(string customTable, int level) { Stations.Add(new CraftingStationConfig { Table = CraftingTable.Custom, level = level, custom = customTable }); } } [PublicAPI] [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] [NullableContext(1)] internal class ItemRecipe { public readonly RequiredResourceList RequiredItems = new RequiredResourceList(); public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList(); public readonly CraftingStationList Crafting = new CraftingStationList(); public int CraftAmount = 1; public bool RequireOnlyOneIngredient; public float QualityResultAmountMultiplier = 1f; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] public ConfigEntryBase RecipeIsActive; } [PublicAPI] internal class Trade { public Trader Trader; public uint Price; public uint Stack = 1u; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] public string RequiredGlobalKey; } [Flags] [PublicAPI] internal enum Trader { None = 0, Haldor = 1, Hildir = 2 } internal struct Requirement { [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(1)] public string itemName; public int amount; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] public ConfigEntry amountConfig; [Description("Set to a non-zero value to apply the requirement only for a specific quality")] public int quality; } internal struct CraftingStationConfig { public CraftingTable Table; public int level; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] public string custom; } [Flags] internal enum Configurability { Disabled = 0, Recipe = 1, Stats = 2, Drop = 4, Trader = 8, Full = 0xF } [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] [PublicAPI] [NullableContext(1)] internal class DropTargets { public readonly List Drops = new List(); public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true) { Drops.Add(new DropTarget { creature = creatureName, chance = chance, min = min, max = max.GetValueOrDefault(min), levelMultiplier = levelMultiplier }); } } internal struct DropTarget { [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(1)] public string creature; public int min; public int max; public float chance; public bool levelMultiplier; } internal enum Toggle { On = 1, Off = 0 } [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] [NullableContext(1)] [PublicAPI] internal class Item { [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] private class ItemConfig { [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 2, 1 })] public ConfigEntry craft; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 2, 1 })] public ConfigEntry upgrade; public ConfigEntry table; public ConfigEntry tableLevel; public ConfigEntry customTable; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] public ConfigEntry maximumTableLevel; public ConfigEntry requireOneIngredient; public ConfigEntry qualityResultAmountMultiplier; } [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] private class TraderConfig { public ConfigEntry trader; public ConfigEntry price; public ConfigEntry stack; public ConfigEntry requiredGlobalKey; } [NullableContext(0)] private class RequirementQuality { public int quality; } [NullableContext(2)] [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string Category; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action CustomDrawer; public Func browsability; } [PublicAPI] [NullableContext(0)] public enum DamageModifier { Normal, Resistant, Weak, Immune, Ignore, VeryResistant, VeryWeak, None } [NullableContext(0)] private delegate void setDmgFunc(ref DamageTypes dmg, float value); [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] private class SerializedRequirements { public readonly List Reqs; public SerializedRequirements(List reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) : this(reqs.Split(new char[1] { ',' }).Select([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); result.quality = ((array.Length > 2 && int.TryParse(array[2], out var result3)) ? result3 : 0); return result; }).ToList()) { } public override string ToString() { return string.Join(",", Reqs.Select([NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : ""))); } [return: <18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] public static ItemDrop fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop obj = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); if ((Object)(object)obj == (Object)null) { Debug.LogWarning((object)("The required item '" + name + "' does not exist.")); } return obj; } public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_0194: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown Dictionary dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func)([NullableContext(0)] (Requirement r) => r.itemName), (Func)([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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown ItemDrop val6 = ResItem(r); return (val6 != null) ? new Requirement { m_amount = (r.amountConfig?.Value ?? r.amount), m_resItem = val6, m_amountPerLevel = 0 } : ((Requirement)null); })); List list = dictionary.Values.Where([NullableContext(0)] (Requirement v) => v != null).ToList(); foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != "")) { if (item.quality > 0) { ItemDrop val = ResItem(item); if (val != null) { Requirement val2 = new Requirement { m_resItem = val, m_amountPerLevel = (item.amountConfig?.Value ?? item.amount), m_amount = 0 }; list.Add(val2); requirementQuality.Add(val2, new RequirementQuality { quality = item.quality }); } continue; } if (!dictionary.TryGetValue(item.itemName, out var value) || value == null) { ItemDrop val3 = ResItem(item); if (val3 != null) { string itemName = item.itemName; Requirement val4 = new Requirement { m_resItem = val3, m_amount = 0 }; Requirement val5 = val4; dictionary[itemName] = val4; value = val5; list.Add(value); } } if (value != null) { value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount; } } return list.ToArray(); [NullableContext(2)] ItemDrop ResItem(Requirement r) { return fetchByName(objectDB, r.itemName); } } } [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] private class SerializedDrop { public readonly List Drops; public SerializedDrop(List drops) { Drops = drops; } public SerializedDrop(string drops) { Drops = ((drops == "") ? ((IEnumerable)Array.Empty()) : ((IEnumerable)drops.Split(new char[1] { ',' }))).Select([NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); if (array.Length <= 2 || !int.TryParse(array[2], out var result)) { result = 1; } if (array.Length <= 3 || !int.TryParse(array[3], out var result2)) { result2 = result; } bool levelMultiplier = array.Length <= 4 || array[4] != "0"; DropTarget result3 = default(DropTarget); result3.creature = array[0]; result3.chance = ((array.Length > 1 && float.TryParse(array[1], out var result4)) ? result4 : 1f); result3.min = result; result3.max = result2; result3.levelMultiplier = levelMultiplier; return result3; }).ToList(); } public override string ToString() { return string.Join(",", Drops.Select([NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0"))); } [return: <18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private static Character fetchByName(ZNetScene netScene, string name) { GameObject prefab = netScene.GetPrefab(name); Character obj = ((prefab != null) ? prefab.GetComponent() : null); if ((Object)(object)obj == (Object)null) { Debug.LogWarning((object)("The drop target character '" + name + "' does not exist.")); } return obj; } public Dictionary toCharacterDrops(ZNetScene netScene, GameObject item) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown Dictionary dictionary = new Dictionary(); foreach (DropTarget drop in Drops) { Character val = fetchByName(netScene, drop.creature); if (val != null) { dictionary[val] = new Drop { m_prefab = item, m_amountMin = drop.min, m_amountMax = drop.max, m_chance = drop.chance, m_levelMultiplier = drop.levelMultiplier }; } } return dictionary; } } [CompilerGenerated] private sealed class <>c__DisplayClass83_0 { public Quaternion? cameraRotation; public float lightIntensity; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] public ItemDrop item; public Quaternion? itemRotation; } [CompilerGenerated] private sealed class d__85 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 0, 1 })] private IEnumerable instructions; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 0, 1 })] public IEnumerable <>3__instructions; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 0, 1 })] private List 5__2; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] private FieldInfo 5__3; private int 5__4; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__85(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown int num; switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = instructions.ToList(); 5__3 = AccessTools.DeclaredField(typeof(Recipe), "m_amount"); 5__4 = 0; break; case 1: <>1__state = -1; if (5__4 > 1 && 5__2[5__4 - 2].opcode == OpCodes.Ldfld && CodeInstructionExtensions.OperandIs(5__2[5__4 - 2], (MemberInfo)5__3) && 5__2[5__4 - 1].opcode == OpCodes.Ldc_I4_1 && 5__2[5__4].operand is Label) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 2; return true; } goto IL_01b2; case 2: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Item), "CheckItemIsUpgrade", (Type[])null, (Type[])null)); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Brtrue, 5__2[5__4].operand); <>1__state = 4; return true; case 4: { <>1__state = -1; goto IL_01b2; } IL_01b2: num = 5__4 + 1; 5__4 = num; break; } if (5__4 < 5__2.Count) { <>2__current = 5__2[5__4]; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] [return: <18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] IEnumerator IEnumerable.GetEnumerator() { d__85 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__85(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] [return: <18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly List registeredItems = new List(); private static readonly Dictionary itemDropMap = new Dictionary(); private static Dictionary>> activeRecipes = new Dictionary>>(); [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 1, 1, 2 })] private static Dictionary hiddenCraftRecipes = new Dictionary(); [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 1, 1, 2 })] private static Dictionary hiddenUpgradeRecipes = new Dictionary(); private static Dictionary> itemCraftConfigs = new Dictionary>(); private static Dictionary> itemDropConfigs = new Dictionary>(); private Dictionary characterDrops = new Dictionary(); private readonly Dictionary statsConfigs = new Dictionary(); private static readonly ConditionalWeakTable requirementQuality = new ConditionalWeakTable(); public static Configurability DefaultConfigurability = Configurability.Full; public Configurability? Configurable; private Configurability configurationVisible = Configurability.Full; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private TraderConfig traderConfig; public readonly GameObject Prefab; [Description("Specifies the maximum required crafting station level to upgrade and repair the item.\nDefault is calculated from crafting station level and maximum quality.")] public int MaximumRequiredStationLevel = int.MaxValue; [Description("Assigns the item as a drop item to a creature.\nUses a creature name, a drop chance and a minimum and maximum amount.")] public readonly DropTargets DropsFrom = new DropTargets(); [Description("Configures whether the item can be bought at the trader.\nDon't forget to set cost to something above 0 or the item will be sold for free.")] public readonly Trade Trade = new Trade(); internal List Conversions = new List(); internal List conversions = new List(); public Dictionary Recipes = new Dictionary(); [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private LocalizeKey _name; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private LocalizeKey _description; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private static object configManager; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private static Localization _english; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private static BaseUnityPlugin _plugin; private static bool hasConfigSync = true; [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private static object _configSync; private Configurability configurability => Configurable ?? DefaultConfigurability; [Description("Specifies the resources needed to craft the item.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the item should need.")] public RequiredResourceList RequiredItems => this[""].RequiredItems; [Description("Specifies the resources needed to upgrade the item.\nUse .Add to add resources with their internal ID and an amount. This amount will be multipled by the item quality level.\nUse one .Add for each resource type the upgrade should need.")] public RequiredResourceList RequiredUpgradeItems => this[""].RequiredUpgradeItems; [Description("Specifies the crafting station needed to craft the item.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.\nUse one .Add for each crafting station.")] public CraftingStationList Crafting => this[""].Crafting; [Description("Specifies a config entry which toggles whether a recipe is active.")] [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] public ConfigEntryBase RecipeIsActive { [NullableContext(2)] get { return this[""].RecipeIsActive; } [NullableContext(2)] set { this[""].RecipeIsActive = value; } } [Description("Specifies the number of items that should be given to the player with a single craft of the item.\nDefaults to 1.")] public int CraftAmount { get { return this[""].CraftAmount; } set { this[""].CraftAmount = value; } } public bool RequireOnlyOneIngredient { get { return this[""].RequireOnlyOneIngredient; } set { this[""].RequireOnlyOneIngredient = value; } } public float QualityResultAmountMultiplier { get { return this[""].QualityResultAmountMultiplier; } set { this[""].QualityResultAmountMultiplier = value; } } public ItemRecipe this[string name] { get { if (Recipes.TryGetValue(name, out var value)) { return value; } return Recipes[name] = new ItemRecipe(); } } public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } SharedData shared = Prefab.GetComponent().m_itemData.m_shared; if (shared.m_name.StartsWith("$")) { _name = new LocalizeKey(shared.m_name); } else { string text = "$item_" + ((Object)Prefab).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(shared.m_name); shared.m_name = text; } return _name; } } public LocalizeKey Description { get { LocalizeKey description = _description; if (description != null) { return description; } SharedData shared = Prefab.GetComponent().m_itemData.m_shared; if (shared.m_description.StartsWith("$")) { _description = new LocalizeKey(shared.m_description); } else { string text = "$itemdesc_" + ((Object)Prefab).name.Replace(" ", "_"); _description = new LocalizeKey(text).English(shared.m_description); shared.m_description = text; } return _description; } } private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable 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([NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(2)] private static object configSync { [NullableContext(2)] get { if (_configSync == null && hasConfigSync) { Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public Item(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public Item(AssetBundle bundle, string prefabName) : this(PrefabManager.RegisterPrefab(bundle, prefabName, addToObjectDb: true), skipRegistering: true) { } public Item(GameObject prefab, bool skipRegistering = false) { if (!skipRegistering) { PrefabManager.RegisterPrefab(prefab, addToObjectDb: true); } Prefab = prefab; registeredItems.Add(this); itemDropMap[Prefab.GetComponent()] = this; Prefab.GetComponent().m_itemData.m_dropPrefab = Prefab; } public void ToggleConfigurationVisibility(Configurability visible) { configurationVisible = visible; if (itemDropConfigs.TryGetValue(this, out var value)) { Toggle((ConfigEntryBase)(object)value, Configurability.Drop); } if (itemCraftConfigs.TryGetValue(this, out var value2)) { foreach (ItemConfig value4 in value2.Values) { ToggleObj(value4, Configurability.Recipe); } } foreach (Conversion conversion in Conversions) { if (conversion.config != null) { ToggleObj(conversion.config, Configurability.Recipe); } } foreach (KeyValuePair statsConfig in statsConfigs) { Toggle(statsConfig.Key, Configurability.Stats); if ((visible & Configurability.Stats) != 0) { statsConfig.Value(); } } reloadConfigDisplay(); void Toggle(ConfigEntryBase cfg, Configurability check) { object[] tags = cfg.Description.Tags; for (int j = 0; j < tags.Length; j++) { if (tags[j] is ConfigurationManagerAttributes configurationManagerAttributes) { configurationManagerAttributes.Browsable = (visible & check) != 0 && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability()); } } } void ToggleObj(object obj, Configurability check) { FieldInfo[] fields = obj.GetType().GetFields(); for (int i = 0; i < fields.Length; i++) { object? value3 = fields[i].GetValue(obj); ConfigEntryBase val = (ConfigEntryBase)((value3 is ConfigEntryBase) ? value3 : null); if (val != null) { Toggle(val, check); } } } } internal static void reloadConfigDisplay() { object obj = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager); if (obj is bool && (bool)obj) { configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty()); } } private void UpdateItemTableConfig(string recipeKey, CraftingTable table, string customTableValue) { if (activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(recipeKey, out var value)) { value.First().m_enabled = table != CraftingTable.Disabled; if ((uint)table <= 1u) { value.First().m_craftingStation = null; } else if (table == CraftingTable.Custom) { Recipe obj = value.First(); GameObject prefab = ZNetScene.instance.GetPrefab(customTableValue); obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent() : null); } else { value.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(table)).GetComponent(); } } } private void UpdateCraftConfig(string recipeKey, SerializedRequirements craftRequirements, SerializedRequirements upgradeRequirements) { if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || !activeRecipes.ContainsKey(this) || !activeRecipes[this].TryGetValue(recipeKey, out var value)) { return; } foreach (Recipe item in value) { item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements); } } internal static void Patch_FejdStartup() { //IL_0e99: Unknown result type (might be due to invalid IL or missing references) //IL_0e9e: Unknown result type (might be due to invalid IL or missing references) //IL_2164: Unknown result type (might be due to invalid IL or missing references) //IL_216e: Expected O, but got Unknown //IL_0f62: Unknown result type (might be due to invalid IL or missing references) //IL_0f65: Unknown result type (might be due to invalid IL or missing references) //IL_0fbb: Expected I4, but got Unknown //IL_0b88: Unknown result type (might be due to invalid IL or missing references) //IL_0b92: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_10ef: Unknown result type (might be due to invalid IL or missing references) //IL_10f2: Unknown result type (might be due to invalid IL or missing references) //IL_10f4: Invalid comparison between Unknown and I4 //IL_10f6: Unknown result type (might be due to invalid IL or missing references) //IL_10fa: Invalid comparison between Unknown and I4 //IL_0cab: Unknown result type (might be due to invalid IL or missing references) //IL_0cb5: Expected O, but got Unknown //IL_0d56: Unknown result type (might be due to invalid IL or missing references) //IL_0d60: Expected O, but got Unknown //IL_10fc: Unknown result type (might be due to invalid IL or missing references) //IL_1100: Invalid comparison between Unknown and I4 //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Expected O, but got Unknown //IL_0e0a: Unknown result type (might be due to invalid IL or missing references) //IL_0e14: Expected O, but got Unknown //IL_12fb: Unknown result type (might be due to invalid IL or missing references) //IL_12fe: Unknown result type (might be due to invalid IL or missing references) //IL_1300: Invalid comparison between Unknown and I4 //IL_1302: Unknown result type (might be due to invalid IL or missing references) //IL_1306: Unknown result type (might be due to invalid IL or missing references) //IL_1308: Invalid comparison between Unknown and I4 //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Expected O, but got Unknown //IL_130a: Unknown result type (might be due to invalid IL or missing references) //IL_130e: Invalid comparison between Unknown and I4 //IL_13e3: Unknown result type (might be due to invalid IL or missing references) //IL_13e8: Unknown result type (might be due to invalid IL or missing references) //IL_13ea: Unknown result type (might be due to invalid IL or missing references) //IL_13ed: Invalid comparison between Unknown and I4 //IL_13ef: Unknown result type (might be due to invalid IL or missing references) //IL_13f3: Invalid comparison between Unknown and I4 //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: Expected O, but got Unknown //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Expected O, but got Unknown //IL_1462: Unknown result type (might be due to invalid IL or missing references) //IL_1465: Unknown result type (might be due to invalid IL or missing references) //IL_1467: Invalid comparison between Unknown and I4 //IL_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_0804: Expected O, but got Unknown //IL_1469: Unknown result type (might be due to invalid IL or missing references) //IL_146d: Unknown result type (might be due to invalid IL or missing references) //IL_146f: Invalid comparison between Unknown and I4 //IL_1471: Unknown result type (might be due to invalid IL or missing references) //IL_1475: Invalid comparison between Unknown and I4 //IL_15b2: Unknown result type (might be due to invalid IL or missing references) //IL_15b5: Invalid comparison between Unknown and I4 //IL_17b2: Unknown result type (might be due to invalid IL or missing references) //IL_17b9: Invalid comparison between Unknown and I4 //IL_1882: Unknown result type (might be due to invalid IL or missing references) //IL_1887: Unknown result type (might be due to invalid IL or missing references) //IL_1889: Unknown result type (might be due to invalid IL or missing references) //IL_188d: Unknown result type (might be due to invalid IL or missing references) //IL_188f: Invalid comparison between Unknown and I4 //IL_18fe: Unknown result type (might be due to invalid IL or missing references) //IL_1901: Unknown result type (might be due to invalid IL or missing references) //IL_1903: Invalid comparison between Unknown and I4 //IL_1528: Unknown result type (might be due to invalid IL or missing references) //IL_152d: Unknown result type (might be due to invalid IL or missing references) //IL_1905: Unknown result type (might be due to invalid IL or missing references) //IL_1909: Invalid comparison between Unknown and I4 //IL_190b: Unknown result type (might be due to invalid IL or missing references) //IL_190f: Invalid comparison between Unknown and I4 //IL_1d7c: Unknown result type (might be due to invalid IL or missing references) //IL_1d7f: Invalid comparison between Unknown and I4 Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); if (DefaultConfigurability != 0) { bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (Item item4 in registeredItems.Where([NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled)) { Item item3 = item4; string name2 = item3.Prefab.GetComponent().m_itemData.m_shared.m_name; string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(name2), "").Trim(); string localizedName = Localization.instance.Localize(name2).Trim(); int order = 0; if ((item3.configurability & Configurability.Recipe) != 0) { itemCraftConfigs[item3] = new Dictionary(); foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty("")) { string configKey = item5; string text = ((configKey == "") ? "" : (" (" + configKey + ")")); if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0) { continue; } ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig()); ItemConfig cfg = itemConfig2; List hideWhenNoneAttributes = new List(); cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName } })); ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = CustomTableBrowsability, Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.table.SettingChanged += TableConfigChanged; cfg.customTable.SettingChanged += TableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TableLevelBrowsability, Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes); cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); cfg.tableLevel.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value6)) { value6.First().m_minStationLevel = cfg.tableLevel.Value; } }; if (item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality > 1) { cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (item3.Recipes[configKey].Crafting.Stations.First().level + item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); } cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Category = localizedName } })); ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = QualityResultBrowsability, Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.requireOneIngredient.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value5)) { foreach (Recipe item6 in value5) { item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On; } } qualityResultAttributes.Browsable = QualityResultBrowsability(); reloadConfigDisplay(); }; cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item3.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes })); cfg.qualityResultAmountMultiplier.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value4)) { foreach (Recipe item7 in value4) { item7.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value; } } }; if ((!item3.Recipes[configKey].RequiredItems.Free || item3.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false); } if (item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality > 1 && (!item3.Recipes[configKey].RequiredUpgradeItems.Free || item3.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true); } if (cfg.craft != null) { cfg.craft.SettingChanged += ConfigChanged; } if (cfg.upgrade != null) { cfg.upgrade.SettingChanged += ConfigChanged; } void ConfigChanged(object o, EventArgs e) { item3.UpdateCraftConfig(configKey, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? "")); } bool CustomTableBrowsability() { return cfg.table.Value == CraftingTable.Custom; } bool ItemBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } bool QualityResultBrowsability() { return cfg.requireOneIngredient.Value == Toggle.On; } void TableConfigChanged(object o, EventArgs e) { item3.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value); customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item8 in hideWhenNoneAttributes) { item8.Browsable = cfg.table.Value != CraftingTable.Disabled; } reloadConfigDisplay(); } bool TableLevelBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } ConfigEntry itemConfig(string name, string value, string desc, bool isUpgrade) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes { CustomDrawer = drawRequirementsConfigTable(item3, isUpgrade), Order = (order -= 1), browsability = ItemBrowsability, Browsable = (ItemBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes3); return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 })); } } if ((item3.configurability & Configurability.Drop) != 0) { ConfigEntry val3 = (itemDropConfigs[item3] = config(englishName, "Drops from", new SerializedDrop(item3.DropsFrom.Drops).ToString(), new ConfigDescription(englishName + " drops from this creature.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = drawDropsConfigTable, Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Drop) != 0) } }))); val3.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { item3.UpdateCharacterDrop(); }; } for (int j = 0; j < item3.Conversions.Count; j++) { string text2 = ((item3.Conversions.Count > 1) ? $"{j + 1}. " : ""); Conversion conversion = item3.Conversions[j]; conversion.config = new Conversion.ConversionConfig(); int index = j; conversion.config.input = config(englishName, text2 + "Conversion Input Item", conversion.Input, new ConfigDescription("Input item to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.input.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (index < item3.conversions.Count) { ObjectDB instance = ObjectDB.instance; if (instance != null) { ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value); item3.conversions[index].m_from = from; UpdatePiece(); } } }; conversion.config.piece = config(englishName, text2 + "Conversion Piece", conversion.Piece, new ConfigDescription("Conversion piece used to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.piece.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { UpdatePiece(); }; conversion.config.customPiece = config(englishName, text2 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Custom conversion piece to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.customPiece.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { UpdatePiece(); }; void UpdatePiece() { if (index < item3.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance)) { string text3 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value))); string activePiece = conversion.config.activePiece; if (conversion.config.activePiece != null) { int num = ZNetScene.instance.GetPrefab(conversion.config.activePiece).GetComponent().m_conversion.IndexOf(item3.conversions[index]); if (num >= 0) { Smelter[] array3 = Resources.FindObjectsOfTypeAll(); foreach (Smelter val4 in array3) { if (Utils.GetPrefabName(((Component)val4).gameObject) == activePiece) { val4.m_conversion.RemoveAt(num); } } } conversion.config.activePiece = null; } if (item3.conversions[index].m_from != null && conversion.config.piece.Value != 0) { GameObject prefab = ZNetScene.instance.GetPrefab(text3); if (((prefab != null) ? prefab.GetComponent() : null) != null) { conversion.config.activePiece = text3; Smelter[] array3 = Resources.FindObjectsOfTypeAll(); foreach (Smelter val5 in array3) { if (Utils.GetPrefabName(((Component)val5).gameObject) == text3) { val5.m_conversion.Add(item3.conversions[index]); } } } } } } } } if ((item3.configurability & Configurability.Stats) != 0) { item3.statsConfigs.Clear(); SharedData shared2 = item3.Prefab.GetComponent().m_itemData.m_shared; ItemType itemType = shared2.m_itemType; statcfg("Weight", "Weight of " + englishName + ".", (SharedData shared) => shared.m_weight, delegate(SharedData shared, float value) { shared.m_weight = value; }); statcfg("Trader Value", "Trader value of " + englishName + ".", (SharedData shared) => shared.m_value, delegate(SharedData shared, int value) { shared.m_value = value; }); bool flag; switch (itemType - 3) { case 0: case 1: case 2: case 3: case 4: case 8: case 9: case 11: case 14: case 16: case 19: flag = true; break; default: flag = false; break; } if (flag) { statcfg("Durability", "Durability of " + englishName + ".", (SharedData shared) => shared.m_maxDurability, delegate(SharedData shared, float value) { shared.m_maxDurability = value; }); statcfg("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData shared) => shared.m_durabilityPerLevel, delegate(SharedData shared, float value) { shared.m_durabilityPerLevel = value; }); statcfg("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData shared) => shared.m_movementModifier, delegate(SharedData shared, float value) { shared.m_movementModifier = value; }); } if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg("Block Armor", "Block armor of " + englishName + ".", (SharedData shared) => shared.m_blockPower, delegate(SharedData shared, float value) { shared.m_blockPower = value; }); statcfg("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData shared) => shared.m_blockPowerPerLevel, delegate(SharedData shared, float value) { shared.m_blockPowerPerLevel = value; }); statcfg("Block Force", "Block force of " + englishName + ".", (SharedData shared) => shared.m_deflectionForce, delegate(SharedData shared, float value) { shared.m_deflectionForce = value; }); statcfg("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData shared) => shared.m_deflectionForcePerLevel, delegate(SharedData shared, float value) { shared.m_deflectionForcePerLevel = value; }); statcfg("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData shared) => shared.m_timedBlockBonus, delegate(SharedData shared, float value) { shared.m_timedBlockBonus = value; }); } else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false) { statcfg("Armor", "Armor of " + englishName + ".", (SharedData shared) => shared.m_armor, delegate(SharedData shared, float value) { shared.m_armor = value; }); statcfg("Armor per Level", "Armor per level for " + englishName + ".", (SharedData shared) => shared.m_armorPerLevel, delegate(SharedData shared, float value) { shared.m_armorPerLevel = value; }); } SkillType skillType = shared2.m_skillType; if (((int)skillType == 7 || (int)skillType == 12) ? true : false) { statcfg("Tool tier", "Tool tier of " + englishName + ".", (SharedData shared) => shared.m_toolTier, delegate(SharedData shared, int value) { shared.m_toolTier = value; }); } if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false) { Dictionary modifiers = shared2.m_damageModifiers.ToDictionary((DamageModPair d) => d.m_type, (DamageModPair d) => (DamageModifier)d.m_modifier); DamageType[] first = (DamageType[])Enum.GetValues(typeof(DamageType)); DamageType[] array = new DamageType[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); foreach (DamageType item9 in first.Except((IEnumerable)(object)array)) { DamageType damageType = item9; statcfg(((object)(DamageType)(ref damageType)).ToString() + " Resistance", ((object)(DamageType)(ref damageType)).ToString() + " resistance of " + englishName + ".", (SharedData _) => (!modifiers.TryGetValue(damageType, out var value3)) ? DamageModifier.None : value3, delegate(SharedData shared, DamageModifier value) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) DamageModPair val6 = default(DamageModPair); val6.m_type = damageType; val6.m_modifier = (DamageModifier)value; DamageModPair val7 = val6; for (int n = 0; n < shared.m_damageModifiers.Count; n++) { if (shared.m_damageModifiers[n].m_type == damageType) { if (value == DamageModifier.None) { shared.m_damageModifiers.RemoveAt(n); } else { shared.m_damageModifiers[n] = val7; } return; } } if (value != DamageModifier.None) { shared.m_damageModifiers.Add(val7); } }); } } if ((int)itemType == 2 && shared2.m_food > 0f) { statcfg("Health", "Health value of " + englishName + ".", (SharedData shared) => shared.m_food, delegate(SharedData shared, float value) { shared.m_food = value; }); statcfg("Stamina", "Stamina value of " + englishName + ".", (SharedData shared) => shared.m_foodStamina, delegate(SharedData shared, float value) { shared.m_foodStamina = value; }); statcfg("Eitr", "Eitr value of " + englishName + ".", (SharedData shared) => shared.m_foodEitr, delegate(SharedData shared, float value) { shared.m_foodEitr = value; }); statcfg("Duration", "Duration of " + englishName + ".", (SharedData shared) => shared.m_foodBurnTime, delegate(SharedData shared, float value) { shared.m_foodBurnTime = value; }); statcfg("Health Regen", "Health regen value of " + englishName + ".", (SharedData shared) => shared.m_foodRegen, delegate(SharedData shared, float value) { shared.m_foodRegen = value; }); } if ((int)shared2.m_skillType == 10) { statcfg("Health Cost", "Health cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealth, delegate(SharedData shared, float value) { shared.m_attack.m_attackHealth = value; }); statcfg("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealthPercentage, delegate(SharedData shared, float value) { shared.m_attack.m_attackHealthPercentage = value; }); } skillType = shared2.m_skillType; if (skillType - 9 <= 1) { statcfg("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackEitr, delegate(SharedData shared, float value) { shared.m_attack.m_attackEitr = value; }); } if ((itemType - 3 <= 1 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg("Knockback", "Knockback of " + englishName + ".", (SharedData shared) => shared.m_attackForce, delegate(SharedData shared, float value) { shared.m_attackForce = value; }); statcfg("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData shared) => shared.m_backstabBonus, delegate(SharedData shared, float value) { shared.m_backstabBonus = value; }); statcfg("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackStamina, delegate(SharedData shared, float value) { shared.m_attack.m_attackStamina = value; }); SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float val) { dmg.m_damage = val; }); SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float val) { dmg.m_slash = val; }); SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float val) { dmg.m_pierce = val; }); SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float val) { dmg.m_blunt = val; }); SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float val) { dmg.m_chop = val; }); SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float val) { dmg.m_pickaxe = val; }); SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float val) { dmg.m_fire = val; }); SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float val) { dmg.m_poison = val; }); SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float val) { dmg.m_frost = val; }); SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float val) { dmg.m_lightning = val; }); SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float val) { dmg.m_spirit = val; }); if ((int)itemType == 4) { statcfg("Projectiles", "Number of projectiles that " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_projectileBursts, delegate(SharedData shared, int value) { shared.m_attack.m_projectileBursts = value; }); statcfg("Burst Interval", "Time between the projectiles " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_burstInterval, delegate(SharedData shared, float value) { shared.m_attack.m_burstInterval = value; }); statcfg("Minimum Accuracy", "Minimum accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracyMin, delegate(SharedData shared, float value) { shared.m_attack.m_projectileAccuracyMin = value; }); statcfg("Accuracy", "Accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracy, delegate(SharedData shared, float value) { shared.m_attack.m_projectileAccuracy = value; }); statcfg("Minimum Velocity", "Minimum velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVelMin, delegate(SharedData shared, float value) { shared.m_attack.m_projectileVelMin = value; }); statcfg("Velocity", "Velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVel, delegate(SharedData shared, float value) { shared.m_attack.m_projectileVel = value; }); statcfg("Maximum Draw Time", "Time until " + englishName + " is fully drawn at skill level 0.", (SharedData shared) => shared.m_attack.m_drawDurationMin, delegate(SharedData shared, float value) { shared.m_attack.m_drawDurationMin = value; }); statcfg("Stamina Drain", "Stamina drain per second while drawing " + englishName + ".", (SharedData shared) => shared.m_attack.m_drawStaminaDrain, delegate(SharedData shared, float value) { shared.m_attack.m_drawStaminaDrain = value; }); } } } List traderAttributes; if ((item3.configurability & Configurability.Trader) != 0) { traderAttributes = new List(); item3.traderConfig = new TraderConfig { trader = config(englishName, "Trader Selling", item3.Trade.Trader, new ConfigDescription("Which traders sell " + englishName + ".", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Trader) != 0), Category = localizedName } })) }; item3.traderConfig.trader.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { item3.ReloadTraderConfiguration(); foreach (ConfigurationManagerAttributes item10 in traderAttributes) { item10.Browsable = TraderBrowsability(); } reloadConfigDisplay(); }; item3.traderConfig.price = traderConfig("Trader Price", item3.Trade.Price, "Price of " + englishName + " at the trader."); item3.traderConfig.stack = traderConfig("Trader Stack", item3.Trade.Stack, "Stack size of " + englishName + " in the trader. Also known as the number of items sold by a trader in one transaction."); item3.traderConfig.requiredGlobalKey = traderConfig("Trader Required Global Key", item3.Trade.RequiredGlobalKey ?? "", "Required global key to unlock " + englishName + " at the trader."); if (item3.traderConfig.trader.Value != 0) { PrefabManager.AddItemToTrader(item3.Prefab, item3.traderConfig.trader.Value, item3.traderConfig.price.Value, item3.traderConfig.stack.Value, item3.traderConfig.requiredGlobalKey.Value); } } else if (item3.Trade.Trader != 0) { PrefabManager.AddItemToTrader(item3.Prefab, item3.Trade.Trader, item3.Trade.Price, item3.Trade.Stack, item3.Trade.RequiredGlobalKey); } void SetDmg(string dmgType, Func readDmg, setDmgFunc setDmg) { statcfg(dmgType + " Damage", dmgType + " damage dealt by " + englishName + ".", (SharedData shared) => readDmg(shared.m_damages), delegate(SharedData shared, float val) { setDmg(ref shared.m_damages, val); }); statcfg(dmgType + " Damage Per Level", dmgType + " damage dealt increase per level for " + englishName + ".", (SharedData shared) => readDmg(shared.m_damagesPerLevel), delegate(SharedData shared, float val) { setDmg(ref shared.m_damagesPerLevel, val); }); } bool TraderBrowsability() { return item3.traderConfig.trader.Value != Trader.None; } void statcfg(string configName, string description, [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 1, 1, 0 })] Func readDefault, [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 1, 1, 0 })] Action setValue) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown SharedData shared3 = item3.Prefab.GetComponent().m_itemData.m_shared; ConfigEntry cfg2 = config(englishName, configName, readDefault(shared3), new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Stats) != 0) } })); if ((item3.configurationVisible & Configurability.Stats) != 0) { setValue(shared3, cfg2.Value); } item3.statsConfigs.Add((ConfigEntryBase)(object)cfg2, ApplyConfig); cfg2.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if ((item3.configurationVisible & Configurability.Stats) != 0) { ApplyConfig(); } }; void ApplyConfig() { item3.ApplyToAllInstances(delegate(ItemData item) { setValue(item.m_shared, cfg2.Value); }); } } [return: <18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 1, 0 })] ConfigEntry traderConfig(string name, [<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(0)] T value, string desc) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TraderBrowsability, Browsable = (TraderBrowsability() && (item3.configurationVisible & Configurability.Trader) != 0), Category = localizedName }; traderAttributes.Add(configurationManagerAttributes2); ConfigEntry obj = config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 })); obj.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { item3.ReloadTraderConfiguration(); }; return obj; } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } } configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); foreach (Item registeredItem in registeredItems) { Item item2 = registeredItem; foreach (KeyValuePair recipe in item2.Recipes) { KeyValuePair kv = recipe; RequiredResourceList[] array2 = new RequiredResourceList[2] { kv.Value.RequiredItems, kv.Value.RequiredUpgradeItems }; foreach (RequiredResourceList requiredResourceList in array2) { for (int l = 0; l < requiredResourceList.Requirements.Count; l++) { ConfigEntry amountCfg; int resourceIndex; if ((item2.configurability & Configurability.Recipe) != 0) { amountCfg = requiredResourceList.Requirements[l].amountConfig; if (amountCfg != null) { resourceIndex = l; amountCfg.SettingChanged += ConfigChanged; } } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(kv.Key, out var value2)) { foreach (Recipe item11 in value2) { item11.m_resources[resourceIndex].m_amount = amountCfg.Value; } } } } } } item2.InitializeNewRegisteredItem(); } } private void InitializeNewRegisteredItem() { foreach (KeyValuePair recipe in Recipes) { KeyValuePair kv = recipe; ConfigEntryBase enabledCfg = kv.Value.RecipeIsActive; if (enabledCfg != null) { ((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged)); } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(kv.Key, out var value)) { foreach (Recipe item in value) { item.m_enabled = (int)enabledCfg.BoxedValue != 0; } } } } } public void ReloadCraftingConfiguration() { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name)) == null) { registerRecipesInObjectDB(ObjectDB.instance); ObjectDB.instance.m_items.Add(Prefab); ObjectDB.instance.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab); ZNetScene.instance.m_prefabs.Add(Prefab); ZNetScene.instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab); } foreach (string item in Recipes.Keys.DefaultIfEmpty("")) { if (Recipes.TryGetValue(item, out var value) && value.Crafting.Stations.Count > 0) { UpdateItemTableConfig(item, value.Crafting.Stations.First().Table, value.Crafting.Stations.First().custom ?? ""); UpdateCraftConfig(item, new SerializedRequirements(value.RequiredItems.Requirements), new SerializedRequirements(value.RequiredUpgradeItems.Requirements)); } } } private void ReloadTraderConfiguration() { if (traderConfig.trader.Value == Trader.None) { PrefabManager.RemoveItemFromTrader(Prefab); } else { PrefabManager.AddItemToTrader(Prefab, traderConfig.trader.Value, traderConfig.price.Value, traderConfig.stack.Value, traderConfig.requiredGlobalKey.Value); } } public static void ApplyToAllInstances(GameObject prefab, Action callback) { callback(prefab.GetComponent().m_itemData); string name = prefab.GetComponent().m_itemData.m_shared.m_name; Inventory[] source = (from c in Player.s_players.Select([NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType() select c.GetInventory()) where c != null select c).ToArray(); foreach (ItemData item in (from i in (from p in ObjectDB.instance.m_items select p.GetComponent() into c where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent()) select c).Concat(ItemDrop.s_instances) select i.m_itemData).Concat(source.SelectMany([NullableContext(0)] (Inventory i) => i.GetAllItems()))) { if (item.m_shared.m_name == name) { callback(item); } } } public void ApplyToAllInstances(Action callback) { ApplyToAllInstances(Prefab, callback); } [NullableContext(0)] [return: <18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(1)] private static string getInternalName(T value) where T : struct { return ((InternalName)typeof(T).GetMember(value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName; } private void registerRecipesInObjectDB(ObjectDB objectDB) { //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Expected O, but got Unknown activeRecipes[this] = new Dictionary>(); itemCraftConfigs.TryGetValue(this, out var value); foreach (KeyValuePair recipe in Recipes) { List list = new List(); foreach (CraftingStationConfig station in recipe.Value.Crafting.Stations) { ItemConfig itemConfig = value?[recipe.Key]; Recipe val = ScriptableObject.CreateInstance(); string name = ((Object)Prefab).name; CraftingTable table = station.Table; ((Object)val).name = name + "_Recipe_" + table; val.m_amount = recipe.Value.CraftAmount; bool enabled; if (itemConfig != null) { enabled = itemConfig.table.Value != CraftingTable.Disabled; } else { ConfigEntryBase recipeIsActive = recipe.Value.RecipeIsActive; enabled = (int)(((recipeIsActive != null) ? recipeIsActive.BoxedValue : null) ?? ((object)1)) != 0; } val.m_enabled = enabled; val.m_item = Prefab.GetComponent(); val.m_resources = SerializedRequirements.toPieceReqs(objectDB, (itemConfig?.craft == null) ? new SerializedRequirements(recipe.Value.RequiredItems.Requirements) : new SerializedRequirements(itemConfig.craft.Value), (itemConfig?.upgrade == null) ? new SerializedRequirements(recipe.Value.RequiredUpgradeItems.Requirements) : new SerializedRequirements(itemConfig.upgrade.Value)); table = ((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value); if ((uint)table <= 1u) { val.m_craftingStation = null; } else if (((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value) == CraftingTable.Custom) { GameObject prefab = ZNetScene.instance.GetPrefab((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value); if (prefab != null) { val.m_craftingStation = prefab.GetComponent(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value) + "' does not exist")); } } else { val.m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value)).GetComponent(); } val.m_minStationLevel = ((itemConfig == null || list.Count > 0) ? station.level : itemConfig.tableLevel.Value); val.m_requireOnlyOneIngredient = ((itemConfig == null) ? recipe.Value.RequireOnlyOneIngredient : (itemConfig.requireOneIngredient.Value == Toggle.On)); val.m_qualityResultAmountMultiplier = itemConfig?.qualityResultAmountMultiplier.Value ?? recipe.Value.QualityResultAmountMultiplier; list.Add(val); RequiredResourceList requiredItems = recipe.Value.RequiredItems; if (requiredItems != null && !requiredItems.Free) { List requirements = requiredItems.Requirements; if (requirements != null && requirements.Count == 0) { hiddenCraftRecipes.Add(val, recipe.Value.RecipeIsActive); } } requiredItems = recipe.Value.RequiredUpgradeItems; if (requiredItems != null && !requiredItems.Free) { List requirements = requiredItems.Requirements; if (requirements != null && requirements.Count == 0) { hiddenUpgradeRecipes.Add(val, recipe.Value.RecipeIsActive); } } } activeRecipes[this].Add(recipe.Key, list); objectDB.m_recipes.AddRange(list); } conversions = new List(); for (int i = 0; i < Conversions.Count; i++) { Conversion conversion = Conversions[i]; conversions.Add(new ItemConversion { m_from = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.input.Value ?? conversion.Input), m_to = Prefab.GetComponent() }); ConversionPiece conversionPiece = conversion.config?.piece.Value ?? conversion.Piece; string text = null; if (conversionPiece != 0 && conversions[i].m_from != null) { text = ((conversionPiece != ConversionPiece.Custom) ? getInternalName(conversionPiece) : (conversion.config?.customPiece.Value ?? conversion.customPiece)); GameObject prefab2 = ZNetScene.instance.GetPrefab(text); Smelter val2 = ((prefab2 != null) ? prefab2.GetComponent() : null); if (val2 != null) { val2.m_conversion.Add(conversions[i]); } else { text = null; } } if (conversion.config != null) { conversion.config.activePiece = text; } } } [HarmonyPriority(0)] internal static void Patch_ObjectDBInit(ObjectDB __instance) { if ((Object)(object)__instance.GetItemPrefab("YagluthDrop") == (Object)null) { return; } hiddenCraftRecipes.Clear(); hiddenUpgradeRecipes.Clear(); foreach (Item registeredItem in registeredItems) { registeredItem.registerRecipesInObjectDB(__instance); } } internal static void Patch_TraderGetAvailableItems(Trader __instance, ref List __result) { string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); Trader trader2 = ((prefabName == "Haldor") ? Trader.Haldor : ((prefabName == "Hildir") ? Trader.Hildir : Trader.None)); Trader trader = trader2; __result.AddRange(from tuple in PrefabManager.CustomTradeItems.Values where (tuple.Item1 & trader) != 0 select tuple.Item2 into tradeItem where string.IsNullOrEmpty(tradeItem.m_requiredGlobalKey) || ZoneSystem.instance.GetGlobalKey(tradeItem.m_requiredGlobalKey) select tradeItem); } internal static void Patch_OnAddSmelterInput(ItemData item, bool __result) { if (__result) { ((Humanoid)Player.m_localPlayer).UnequipItem(item, true); } } internal static void Patch_MaximumRequiredStationLevel(Recipe __instance, ref int __result, int quality) { if (!itemDropMap.TryGetValue(__instance.m_item, out var value)) { return; } IEnumerable source; if (!itemCraftConfigs.TryGetValue(value, out var value2)) { source = Enumerable.Empty(); } else { CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); if (currentCraftingStation != null) { string stationName = Utils.GetPrefabName(((Component)currentCraftingStation).gameObject); source = from c in value2.Where([NullableContext(0)] (KeyValuePair c) => { switch (c.Value.table.Value) { case CraftingTable.Disabled: case CraftingTable.Inventory: return false; case CraftingTable.Custom: return c.Value.customTable.Value == stationName; default: return getInternalName(c.Value.table.Value) == stationName; } }) select c.Value; } else { source = value2.Values; } } __result = Mathf.Min(Mathf.Max(1, __instance.m_minStationLevel) + (quality - 1), (from cfg in source where cfg.maximumTableLevel != null select cfg.maximumTableLevel.Value).DefaultIfEmpty(value.MaximumRequiredStationLevel).Max()); } internal static void Patch_GetAvailableRecipesPrefix([<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 2, 1, 1, 1, 2 })] ref Dictionary> __state) { if (__state == null) { __state = new Dictionary>(); } Dictionary dictionary; if (InventoryGui.instance.InCraftTab()) { dictionary = hiddenCraftRecipes; } else { if (!InventoryGui.instance.InUpradeTab()) { return; } dictionary = hiddenUpgradeRecipes; } foreach (Recipe key in dictionary.Keys) { key.m_enabled = false; } __state[Assembly.GetExecutingAssembly()] = dictionary; } internal static void Patch_GetAvailableRecipesFinalizer([<18dd9431-1b89-4862-9d9a-8abd55cf6a54>Nullable(new byte[] { 1, 1, 1, 1, 2 })] Dictionary> __state) { if (!__state.TryGetValue(Assembly.GetExecutingAssembly(), out var value)) { return; } foreach (KeyValuePair item in value) { Recipe key = item.Key; ConfigEntryBase value2 = item.Value; key.m_enabled = (int)(((value2 != null) ? value2.BoxedValue : null) ?? ((object)1)) != 0; } } internal static IEnumerable Transpile_SetupRequirementList(IEnumerable instructionsEnumerable, ILGenerator ilg) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown List list = instructionsEnumerable.ToList(); MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(InventoryGui), "SetupRequirement", (Type[])null, (Type[])null); CodeInstruction val = null; CodeInstruction val2 = null; LocalBuilder localBuilder = ilg.DeclareLocal(typeof(int)); Dictionary dictionary = new Dictionary(); bool flag = false; int num = 0; int value = 0; Label? label = default(Label?); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { val = list[i + 2]; val2 = list[i + 5]; flag = true; } if (flag) { if (CodeInstructionExtensions.Branches(list[i], ref label) && dictionary.TryGetValue(label.Value, out value)) { num = i; break; } continue; } foreach (Label label4 in list[i].labels) { dictionary[label4] = i; } } if (list[value - 3].opcode == OpCodes.Dup) { return list; } Label label2 = ilg.DefineLabel(); Label label3 = ilg.DefineLabel(); list[num + 1].labels.Add(label2); list.InsertRange(num + 1, (IEnumerable)(object)new CodeInstruction[11] { new CodeInstruction(OpCodes.Ldloc, (object)localBuilder), new CodeInstruction(OpCodes.Brfalse, (object)label2), val.Clone(), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.DeclaredField(typeof(InventoryGui), "m_recipeRequirementList")), new CodeInstruction(OpCodes.Ldlen, (object)null), new CodeInstruction(OpCodes.Bgt, (object)label2), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), val2.Clone(), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Br, (object)label3) }); list.InsertRange(value - 2, (IEnumerable)(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Dup, (object)null) { labels = new List