Decompiled source of PortablePals v0.1.2
PortablePals.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.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 AllTameable; using AllTameable.DNA; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CompatPatches; using CreatureLevelControl; using HarmonyLib; using JetBrains.Annotations; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using LocalizationManager; using Microsoft.CodeAnalysis; using MonsterModifiers.Custom_Components; using PortablePals; using StarLevelSystem; using StarLevelSystem.modules; using UnityEngine; using UnityEngine.SceneManagement; 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: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyTitle("PortablePals")] [assembly: AssemblyProduct("PortablePals")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("db3f13a2-a323-4902-ad30-87a28b8836b6")] [assembly: AssemblyCompany("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace CompatPatches { internal class SLS { public static void SetSLSSize(float size, Character character) { DBG.blogDebug("Manual SLS Size:" + size); API.SetCreatureBaseAttribute(character, 4, size); ZDO zDO = ((Component)character).GetComponent<ZNetView>().GetZDO(); zDO.Set("SLE_Size", size); } public static void SetSLSColorFromZDO(Character character) { ZDO zDO = ((Component)character).GetComponent<ZNetView>().GetZDO(); string @string = zDO.GetString("PP_SLS_HSVE", ""); SetSLSColor(character, @string); } public static void SetSLSData(Dictionary<string, string> custData, Character character) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) CatchPal.ReleaseData releaseData = default(CatchPal.ReleaseData); if (!((Component)character).TryGetComponent<CatchPal.ReleaseData>(ref releaseData)) { DBG.blogDebug("No Release Data"); return; } if (!custData.TryGetValue("PP_SLS_General", out var value)) { DBG.blogDebug("Did not get SLS Data"); return; } string[] array = value.Split(new char[1] { ',' }); if (array.Length < 3) { DBG.blogDebug("Failed to get full SLS Data"); return; } if (float.TryParse(array[0], out var result)) { TimedScaleAndFreeze timedScaleAndFreeze = default(TimedScaleAndFreeze); if (((Component)character).TryGetComponent<TimedScaleAndFreeze>(ref timedScaleAndFreeze)) { timedScaleAndFreeze.sls_Size = result; Vector3 localScale = ((Component)character).transform.localScale; DBG.blogDebug("character.transform.localScale=" + ((object)(Vector3)(ref localScale)).ToString()); } releaseData.SaveFloats.Add("SLE_Size", result * 0.123f); releaseData.sls_Size = result; } if (float.TryParse(array[1], out var result2)) { releaseData.SaveFloats.Add("SLE_DMod", result2); DBG.blogDebug("SLE_DMod=" + result2); } releaseData.SaveStr.Add("SLE_Name", array[2]); if (custData.TryGetValue("PP_SLS_MODS", out var value2)) { byte[] array2 = Convert.FromBase64String(value2); if (array2.Length > 10) { releaseData.SaveBytes.Add("SLS_MODS", array2); DBG.blogDebug("Set SLS_MODS"); } else { DBG.blogDebug("SLS_MODS length=" + array2.Length); } } if (custData.TryGetValue("PP_SLS_BossMods", out var value3)) { byte[] array3 = Convert.FromBase64String(value3); if (array3.Length != 0) { releaseData.SaveBytes.Add("SLS_Boss_MODS", array3); DBG.blogDebug("Set SLS_Boss_MODS"); } else { DBG.blogDebug("SLS_Boss_MODS length=" + array3.Length); } } if (custData.TryGetValue("PP_SLS_MajorMods", out var value4)) { byte[] array4 = Convert.FromBase64String(value4); if (array4.Length != 0) { releaseData.SaveBytes.Add("SLS_Major_MODS", array4); DBG.blogDebug("Set SLS_Major_MODS"); } else { DBG.blogDebug("SLS_Major_MODS length=" + array4.Length); } } if (custData.TryGetValue("PP_SLS_MinorMods", out var value5)) { byte[] array5 = Convert.FromBase64String(value5); if (array5.Length != 0) { releaseData.SaveBytes.Add("SLS_Minor_MODS", array5); DBG.blogDebug("Set SLS_Minor_MODS"); } else { DBG.blogDebug("SLS_Minor_MODS length=" + array5.Length); } } if (custData.TryGetValue("PP_SLS_HSVE", out var value6)) { DBG.blogDebug("Set PP_SLS_HSVE:" + value6); releaseData.SaveStr.Add("PP_SLS_HSVE", value6); } } public static void SaveSLSValues(Dictionary<string, string> custData, Character character) { ZDO zDO = character.m_nview.GetZDO(); string text = ""; text = text + zDO.GetFloat("SLE_Size", 0f) + ","; text = text + zDO.GetFloat("SLE_DMod", 0f) + ","; text += zDO.GetString("SLE_Name", ""); Utils2.addOrUpdateCustomData(custData, "PP_SLS_General", text); byte[] byteArray = zDO.GetByteArray("SLS_MODS", (byte[])null); if (byteArray != null) { DBG.blogDebug("SLS_MODS not null"); string newValue = Convert.ToBase64String(zDO.GetByteArray("SLS_MODS", (byte[])null)); Utils2.addOrUpdateCustomData(custData, "PP_SLS_MODS", newValue); } else { DBG.blogDebug("SLS_MODS null"); custData.Remove("PP_SLS_MODS"); } Utils2.addOrUpdateCustomData(custData, "PP_SLS_HSVE", GetSLSColor(character)); } public static string GetSLSColor(Character character) { //IL_00b0: 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_00cc: Unknown result type (might be due to invalid IL or missing references) SkinnedMeshRenderer componentInChildren = ((Component)character).GetComponentInChildren<SkinnedMeshRenderer>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return ""; } Material[] sharedMaterials = ((Renderer)componentInChildren).sharedMaterials; if (sharedMaterials.Length == 0) { return ""; } string text = sharedMaterials[0].GetFloat("_Hue") + ","; text = text + sharedMaterials[0].GetFloat("_Saturation") + ","; text = text + sharedMaterials[0].GetFloat("_Value") + ","; Color color = sharedMaterials[0].GetColor("_EmissionColor"); text += ((((Color)(ref color)).maxColorComponent > 0f) ? color.a : 0f); DBG.blogDebug("hsve:" + text); return text; } public static void SetSLSColor(Character character, string color_data) { string[] array = color_data.Split(new char[1] { ',' }); if (array.Length < 4) { DBG.blogDebug("Failed to get color SLS Data"); return; } float.TryParse(array[0], out var result); float.TryParse(array[1], out var result2); float.TryParse(array[2], out var result3); float.TryParse(array[3], out var result4); APIReciever.UpdateCreatureColorization(character, result3, result, result2, result4 > 0f); } } internal class MonsterMod { public static void SetModifiers(Character character, string MonMod) { MonsterModifier val = default(MonsterModifier); if (((Component)character).TryGetComponent<MonsterModifier>(ref val)) { if (Object.op_Implicit((Object)(object)val.character)) { DBG.blogDebug("MonMod has started"); } character.m_nview.GetZDO().Set("modifiers", MonMod); DBG.blogDebug("MonMod has been set"); DBG.blogDebug("MonMod is:" + character.m_nview.GetZDO().GetString("modifiers", string.Empty)); } } public static string getModifiers(Character character) { MonsterModifier val = default(MonsterModifier); string text; if (((Component)character).TryGetComponent<MonsterModifier>(ref val)) { text = string.Join(",", val.Modifiers); DBG.blogDebug("got modifiers from component: " + text); } else { text = character.m_nview.GetZDO().GetString("modifiers", string.Empty) ?? ""; DBG.blogDebug("got modifiers from zdo: " + text); } return text; } } internal class VikingNPC { [HarmonyPatch(typeof(Humanoid), "GiveDefaultItems")] [HarmonyPostfix] private static void GiveDefaultItems(Humanoid __instance) { TimedScaleAndFreeze timedScaleAndFreeze = default(TimedScaleAndFreeze); if (((Component)__instance).TryGetComponent<TimedScaleAndFreeze>(ref timedScaleAndFreeze) && timedScaleAndFreeze.clearInv) { Inventory inventory = __instance.GetInventory(); if (inventory.m_inventory.Count() > 0) { timedScaleAndFreeze.clearInv = false; inventory.RemoveAll(); inventory.Changed(); } } } } [HarmonyPatch(typeof(CreatureLevelControl), "PatchSize")] internal class CLLC_Patches { private static bool Prefix(CreatureLevelControl __instance, EnemyLevelData originalData, out Vector3 __state) { //IL_000f: 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_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) GameObject gameObject = ((Component)originalData).gameObject; __state = gameObject.transform.localScale; TimedScaleAndFreeze timedScaleAndFreeze = default(TimedScaleAndFreeze); if ((((Object)(object)gameObject != (Object)null) & gameObject.TryGetComponent<TimedScaleAndFreeze>(ref timedScaleAndFreeze)) && timedScaleAndFreeze.CLLC_Scale != 1f) { DBG.blogDebug("Already Scaled by CLLC"); __state = Vector3.zero; return false; } return true; } private static void Postfix(CreatureLevelControl __instance, EnemyLevelData originalData, Vector3 __state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!(__state == Vector3.zero)) { GameObject gameObject = ((Component)originalData).gameObject; TimedScaleAndFreeze tsf = default(TimedScaleAndFreeze); if ((Object)(object)gameObject != (Object)null && gameObject.TryGetComponent<TimedScaleAndFreeze>(ref tsf)) { float scale = gameObject.transform.localScale.x / __state.x; DBG.blogDebug("In CLLC Patch with scale=" + scale); CatchPal.checkScales(gameObject, isCLLC: true, tsf, scale); } } } } internal class AllTame_API { [HarmonyPatch(typeof(DNA), "setTraits")] public class AT_DNA_Patches { private static void Prefix(DNA __instance, out Vector3 __state) { //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) __state = ((Component)__instance).gameObject.transform.localScale; } private static void Postfix(DNA __instance, Vector3 __state) { //IL_0027: 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) GameObject gameObject = ((Component)__instance).gameObject; TimedScaleAndFreeze tsf = default(TimedScaleAndFreeze); if ((Object)(object)gameObject != (Object)null && gameObject.TryGetComponent<TimedScaleAndFreeze>(ref tsf)) { float scale = gameObject.transform.localScale.x / __state.x; DBG.blogDebug((object)("In setTraits Patch with scale=" + scale)); CatchPal.checkScales(gameObject, isCLLC: false, tsf, scale); } } } public static string GetDNA(Character character) { DNA component = ((Component)character).GetComponent<DNA>(); if ((Object)(object)component == (Object)null) { return ""; } return component.DNA_hash.ToString(); } public static void setDNAHash(GameObject go, ZNetView znv) { DNA component = go.GetComponent<DNA>(); if (Object.op_Implicit((Object)(object)component)) { component.DNA_hash = znv.GetZDO().GetLong("AT_DNA", 0L); component.ParseMSG(); } } public static void setDNA(GameObject go, long dna_hash1, long dna_hash2) { DNA val = default(DNA); if (go.TryGetComponent<DNA>(ref val)) { val.DNA_hash = dna_hash1; val.ParseMSG(); val.restoreColor(); val.setAttributes(); val.SetZDO(); DBG.blogDebug((object)("PP hash=" + dna_hash1 + ":" + dna_hash2)); } else { DBG.blogDebug((object)"No DNA"); } } } internal class CLLC { public static void SetInfusionCreature(Character character, string infusion) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!Enum.TryParse<CreatureInfusion>(infusion, out CreatureInfusion result)) { DBG.blogDebug("Failed to parse infusion from string " + infusion); } else { API.SetInfusionCreature(character, result); } } public static void SetExtraEffectCreature(Character character, string effect) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!Enum.TryParse<CreatureExtraEffect>(effect, out CreatureExtraEffect result)) { DBG.blogDebug("Failed to parse extra effect from string " + effect); } else { API.SetExtraEffectCreature(character, result); } } public static string CLLC_getInfusion(Character character) { //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) CreatureInfusion infusionCreature = API.GetInfusionCreature(character); return ((object)(CreatureInfusion)(ref infusionCreature)).ToString(); } public static string CLLC_getEffect(Character character) { //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) CreatureExtraEffect extraEffectCreature = API.GetExtraEffectCreature(character); return ((object)(CreatureExtraEffect)(ref extraEffectCreature)).ToString(); } } } namespace PortablePals { internal class CatchPal { public class ReleaseData : MonoBehaviour { public float sls_Size = 1f; public int lvl = 1; public float color = 0f; public float duration = 3f; private bool SavedData = false; public ZNetView znv; public Dictionary<string, string> SaveStr = new Dictionary<string, string>(); public Dictionary<string, byte[]> SaveBytes = new Dictionary<string, byte[]>(); public Dictionary<string, float> SaveFloats = new Dictionary<string, float>(); private void Awake() { } private void Start() { ((MonoBehaviour)this).Invoke("DestroySelf", duration); SaveToZDO(); } public void SaveToZDO() { if (SavedData) { return; } SavedData = true; ZNetView component = ((Component)this).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null) { return; } ZDO zDO = component.GetZDO(); zDO.Set(ZDOVars.s_level, lvl, false); DBG.blogDebug("Release Set lvl:" + lvl); foreach (KeyValuePair<string, string> item in SaveStr) { zDO.Set(item.Key, item.Value); DBG.blogDebug("Release Set Str: " + item.Key + ":" + item.Value); } foreach (KeyValuePair<string, byte[]> saveByte in SaveBytes) { zDO.Set(saveByte.Key, saveByte.Value); DBG.blogDebug("Release Set Str: " + saveByte.Key + ":" + saveByte.Value); } foreach (KeyValuePair<string, float> saveFloat in SaveFloats) { zDO.Set(saveFloat.Key, saveFloat.Value); DBG.blogDebug("Release Set Str: " + saveFloat.Key + ":" + saveFloat.Value); } zDO.Set("SLS_DSpwnMlt", true); } private void DestroySelf() { Object.Destroy((Object)(object)this); } } public static string releaseZDOKey = "PP_Release"; public static float tsf_startScale = 0.1f; public static float tsf_startTime = 0.6f; public static float tsf_duration = 1.1f; public static GameObject Staging; public const int maxCatchDist = 15; public static Vector3 throwforce = new Vector3(-50f, 450f, 200f); public static ForceMode forceMode = (ForceMode)0; public static Vector3 throwLoc = new Vector3(0.4f, 0.9f, -0.04f); public static int catcherHash = StringExtensionMethods.GetStableHashCode("PP_Catcher"); [HarmonyPatch(typeof(Character), "Awake")] [HarmonyPostfix] private static void RegisterRPCs(Character __instance) { ZNetView nview = __instance.m_nview; nview.Register<ZDOID>("RPC_RequestCatch", (Action<long, ZDOID>)RPC_RequestCatch); nview.Register<ZDOID, ZDOID>("RPC_CatchEffect", (Action<long, ZDOID, ZDOID>)RPC_CatchEffect); if (nview.GetZDO() != null && nview.GetZDO().GetBool(releaseZDOKey, false)) { DBG.blogDebug("Has Release ZDO"); ReleaseCreatureEffect(__instance); nview.GetZDO().Set(releaseZDOKey, false); } } [HarmonyPatch(typeof(Character), "Awake")] [HarmonyPriority(600)] [HarmonyPrefix] private static void CheckData(Character __instance) { ReleaseData releaseData = default(ReleaseData); if (((Component)__instance).TryGetComponent<ReleaseData>(ref releaseData)) { releaseData.SaveToZDO(); } } public static int attemptCatch(Player plr, ItemData item) { //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) if (((Character)plr).InAttack()) { DBG.blogDebug("In Attack"); return 0; } if (item.m_customData.TryGetValue("PP_Prefab", out var value) && (value ?? "") != "") { ReleaseCreature(plr, item); if (item.m_shared.m_useDurability) { float maxDurability = item.GetMaxDurability(); if (item.m_durability > maxDurability) { item.m_durability = maxDurability; } item.m_durability -= 1f; } return 1; } item.m_shared.m_movementModifier = -0.05f; if (float.TryParse(GeneralExtensions.GetValueSafe<string, string>(item.m_customData, "PP_LastCatch"), out var result)) { float num = Math.Abs(result - Time.time); if (num < 0.3f) { DBG.blogDebug("Catch already in Progress"); return 0; } if (num < Plugin.cooldown.Value) { DBG.blogDebug("In Cooldown:" + result); ((Character)plr).Message((MessageType)2, "Item in cooldown, try again in " + (int)(Plugin.cooldown.Value - num + 1f) + "s", 0, (Sprite)null); return 0; } } Character val = null; GameObject val2 = null; plr.FindHoverObject(ref val2, ref val); if ((Object)(object)val != (Object)null) { if (Vector3.Distance(((Character)plr).m_eye.position, ((Component)val).transform.position) < 15f) { DBG.blogDebug("hovering=" + val.m_name); if (CatchCreature(plr, item, val)) { return 2; } DBG.blogDebug("Failed to attempt catch=" + ((Object)val).name); return 0; } DBG.blogDebug("to far away from=" + ((Object)val).name); return 0; } DBG.blogDebug("no creature to catch"); return 0; } private static bool CatchCreature(Player plr, ItemData item, Character hovCreature) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) if (!hovCreature.m_nview.IsValid() || !hovCreature.IsTamed()) { return false; } item.m_shared.m_movementModifier = -0.9f; ZDO zDO = hovCreature.m_nview.GetZDO(); long @long = zDO.GetLong(catcherHash, 0L); DBG.blogDebug("Catcher uid=" + @long); ZDOID zDOID = zDO.GetZDOID("PP_Catcher"); if (((ZDOID)(ref zDOID)).UserID != 0) { DBG.blogDebug("Already has Catcher ZDOID"); if (Time.time - zDO.GetFloat("PP_CatcherTime", 0f) < 5f) { return false; } DBG.blogDebug("Time has passed, attempting Catch"); } if (@long != 0) { DBG.blogDebug("Already has Catcher"); } Utils2.addOrUpdateCustomData(item.m_customData, "PP_LastCatch", Time.time.ToString()); DBG.blogDebug("Set lastCatch to: " + Time.time); zDO.Set("PP_Catcher", ((Character)plr).m_nview.GetZDO().m_uid); zDO.Set("PP_CatcherTime", Time.time); DBG.blogDebug("Set ZDOID"); ZDOID zDOID2 = zDO.GetZDOID("PP_Catcher"); ZDOID uid = zDO.m_uid; DBG.blogDebug("found ZDOID"); GameObject val = ZNetScene.instance.FindInstance(zDOID2); DBG.blogDebug("go name=" + ((Object)val).name); hovCreature.m_nview.InvokeRPC(ZNetView.Everybody, "RPC_RequestCatch", new object[1] { uid }); ((MonoBehaviour)hovCreature).StartCoroutine(CatchUpdate(hovCreature)); return true; } private static ItemData GetPalStone(Player plr, Character hovCreature) { if (!hovCreature.m_nview.IsValid() || !hovCreature.IsTamed()) { return null; } ItemData rightItem = ((Humanoid)plr).m_rightItem; if (rightItem == null || !((Object)rightItem.m_dropPrefab).name.Contains("PalStone")) { return null; } return rightItem; } public static bool SaveCreatureToItem(Character hovCreature, ItemData item) { //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, string> customData = item.m_customData; Utils2.addOrUpdateCustomData(customData, "PP_Prefab", hovCreature.m_nview.GetPrefabName()); Utils2.addOrUpdateCustomData(customData, "PP_Name", hovCreature.m_nview.GetZDO().GetString(StringExtensionMethods.GetStableHashCode("TamedName"), "")); Utils2.addOrUpdateCustomData(customData, "PP_Lvl", hovCreature.m_level.ToString()); Utils2.addOrUpdateCustomData(customData, "PP_Health", hovCreature.GetHealth().ToString()); float num = (float)hovCreature.m_nview.GetZDO().GetLong(ZDOVars.s_tameLastFeeding, 0L) / 10000000f; Utils2.addOrUpdateCustomData(customData, "PP_LastFed", ((int)(ZNet.instance.m_netTime - (double)num)).ToString()); Growup component = ((Component)hovCreature).gameObject.GetComponent<Growup>(); if (Object.op_Implicit((Object)(object)component)) { float num2 = (float)hovCreature.m_nview.GetZDO().GetLong(ZDOVars.s_spawnTime, 0L) / 10000000f; int num3 = (int)(ZNet.instance.m_netTime - (double)num2); DBG.blogDebug("growTime " + num3); Utils2.addOrUpdateCustomData(customData, "PP_growTime", num3.ToString()); } Utils2.addOrUpdateCustomData(customData, "PP_HealStart", ((int)ZNet.instance.m_netTime).ToString()); Humanoid val = (Humanoid)(object)((hovCreature is Humanoid) ? hovCreature : null); if (Object.op_Implicit((Object)(object)val)) { Utils2.addOrUpdateCustomData(customData, "PP_Seed", val.m_seed.ToString()); if (((object)hovCreature).GetType().Name.Contains("Companion")) { dropInventory(val.GetInventory(), ((Component)hovCreature).transform.position); } } DBG.blogDebug("Health=" + hovCreature.GetHealth()); if (Plugin.hasCLLC) { Utils2.addOrUpdateCustomData(customData, "PP_CLLC", CLLC.CLLC_getInfusion(hovCreature) + "," + CLLC.CLLC_getEffect(hovCreature)); } if (Plugin.hasAT) { Utils2.addOrUpdateCustomData(customData, "PP_DNA", AllTame_API.GetDNA(hovCreature)); } if (Plugin.hasMonMod) { Utils2.addOrUpdateCustomData(customData, "PP_MonMod", MonsterMod.getModifiers(hovCreature)); } if (Plugin.hasSLS) { SLS.SaveSLSValues(customData, hovCreature); } Tameable tamable = hovCreature.m_baseAI.m_tamable; if ((Object)(object)tamable != (Object)null && tamable.HaveSaddle()) { DBG.blogDebug("Has Saddle"); Utils2.addOrUpdateCustomData(customData, "PP_Saddle", "true"); Sadle saddle = tamable.m_saddle; if ((Object)(object)saddle != (Object)null) { Container componentInChildren = ((Component)saddle).GetComponentInChildren<Container>(); if ((Object)(object)componentInChildren != (Object)null) { dropInventory(componentInChildren.m_inventory, ((Component)hovCreature).transform.position); } } } else { Utils2.addOrUpdateCustomData(customData, "PP_Saddle", "false"); } return true; } public static void dropInventory(Inventory inv, Vector3 pos) { //IL_002d: 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) List<ItemData> allItems = inv.GetAllItems(); DBG.blogDebug("Dropping Inventory"); foreach (ItemData item in allItems) { ItemDrop.DropItem(item, item.m_stack, pos, Quaternion.Euler(0f, 0f, (float)Random.Range(0, 360))); } } private static void ReleaseCreatureEffect(Character character) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) DBG.blogDebug("Releasing Creature Effect"); GameObject gameObject = ((Component)character).gameObject; TimedScaleAndFreeze timedScaleAndFreeze = gameObject.AddComponent<TimedScaleAndFreeze>(); timedScaleAndFreeze.ZNetDestroy = false; timedScaleAndFreeze.startScale = tsf_startScale; timedScaleAndFreeze.startimeScale = tsf_startTime; timedScaleAndFreeze.duration = tsf_duration; timedScaleAndFreeze.roughness = 0.02f; timedScaleAndFreeze.breakChild = -1; ZNetView nview = character.m_nview; if (Object.op_Implicit((Object)(object)nview) && nview.IsValid()) { timedScaleAndFreeze.ogScale = nview.GetZDO().GetVec3("PP_Scale", Vector3.one); } else { DBG.blogWarning("Failed to grab zdo scale for " + ((Object)character).name); timedScaleAndFreeze.ogScale = gameObject.transform.localScale; } ((Component)character).transform.localScale = timedScaleAndFreeze.ogScale * tsf_startScale; if (!Object.op_Implicit((Object)(object)gameObject)) { DBG.blogWarning("Failed to release " + ((Object)character).name); return; } VisEquipment component = gameObject.GetComponent<VisEquipment>(); if (Plugin.hasAT) { AllTame_API.setDNAHash(gameObject, nview); } if ((Object)(object)component != (Object)null) { DBG.blogDebug("has visequ"); ((Component)component.m_rightHand).gameObject.SetActive(false); ((Component)component.m_leftHand).gameObject.SetActive(false); ((Behaviour)component).enabled = false; Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null); if ((Object)(object)val != (Object)null) { val.GiveDefaultItems(); } } else { DBG.blogDebug("no visequ"); } gameObject.SetActive(true); ((Behaviour)character).enabled = false; } public static void checkScales(GameObject go, bool isCLLC, TimedScaleAndFreeze tsf, float scale) { //IL_005f: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0113: Unknown result type (might be due to invalid IL or missing references) if (scale == 1f || scale > 5f || Math.Abs(tsf.DNA_Scale - scale) < 0.001f || Math.Abs(tsf.CLLC_Scale - scale) < 0.001f) { DBG.blogDebug("Seems like duplicate Scale=" + scale); Transform transform = go.transform; transform.localScale /= scale; } else if (isCLLC) { if (tsf.CLLC_Scale != 1f) { DBG.blogDebug("Postfix Already Scaled by CLLC "); return; } tsf.CLLC_Scale = scale; DBG.blogDebug("CLLC Scale Modified by " + scale + ": lvl=" + go.GetComponent<Character>().GetLevel() + ": tamed=" + go.GetComponent<Character>().m_tamed); tsf.exteriorScale *= scale; } else if (tsf.DNA_Scale != 1f) { DBG.blogDebug("Postfix Already Scaled by DNA "); } else { DBG.blogDebug("DNA Scale Modified by " + scale); tsf.DNA_Scale = scale; tsf.exteriorScale *= scale; } } public static void ReleaseCreature_PreAwake(Character creature, ItemData palstone) { if (Plugin.hasSLS) { SLS.SetSLSData(palstone.m_customData, creature); } } public static void ReleaseCreature_PostAwake(Character creature, ItemData palstone) { if (Plugin.hasSLS) { SLS.SetSLSColorFromZDO(creature); } } public static void ReleaseCreature_PostRelease(Character creature, TimedScaleAndFreeze tsf) { if (Plugin.hasSLS) { SLS.SetSLSSize(tsf.sls_Size, creature); } } private static Character ReleaseCreature(Player plr, ItemData item) { //IL_0050: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0661: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_0a36: Unknown result type (might be due to invalid IL or missing references) //IL_0a3b: Unknown result type (might be due to invalid IL or missing references) //IL_0a55: Unknown result type (might be due to invalid IL or missing references) //IL_0a57: Unknown result type (might be due to invalid IL or missing references) //IL_0ab2: Unknown result type (might be due to invalid IL or missing references) //IL_0af3: Unknown result type (might be due to invalid IL or missing references) //IL_0af8: Unknown result type (might be due to invalid IL or missing references) //IL_0b05: Unknown result type (might be due to invalid IL or missing references) //IL_0b0a: Unknown result type (might be due to invalid IL or missing references) DBG.blogDebug("Releasing Creature local"); Dictionary<string, string> customData = item.m_customData; customData.TryGetValue("PP_Prefab", out var value); GameObject prefab = ZNetScene.instance.GetPrefab(StringExtensionMethods.GetStableHashCode(value)); if (!Object.op_Implicit((Object)(object)prefab)) { return null; } Vector3 val = ((Component)plr).transform.position + ((Component)plr).transform.rotation * throwLoc; Vector3 localScale = prefab.transform.localScale; Vector3 val2 = localScale; DBG.blogDebug("StartScale=" + ((object)(Vector3)(ref val2)).ToString()); GameObject val3 = new GameObject("tempObject"); val3.SetActive(false); GameObject val4 = Object.Instantiate<GameObject>(prefab, val, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f), val3.transform); ReleaseData releaseData = val4.AddComponent<ReleaseData>(); Character component = val4.GetComponent<Character>(); component.m_tamed = true; bool flag = false; if (int.TryParse(GeneralExtensions.GetValueSafe<string, string>(customData, "PP_Lvl"), out var result)) { releaseData.lvl = result; } else { flag = true; } ReleaseCreature_PreAwake(component, item); val4.transform.SetParent((Transform)null); Object.Destroy((Object)(object)val3); ZNetView component2 = val4.GetComponent<ZNetView>(); ZDO zDO = component2.GetZDO(); DBG.blogDebug("lvl=" + zDO.GetInt(ZDOVars.s_level, 0)); string valueSafe = GeneralExtensions.GetValueSafe<string, string>(item.m_customData, "PP_LastCatch"); Utils2.addOrUpdateCustomData(((Humanoid)plr).RightItem.m_customData, "PP_Prefab", ""); Utils2.addOrUpdateCustomData(item.m_customData, "PP_LastCatch", Time.time.ToString()); val2 = val4.transform.localScale; DBG.blogDebug("Scale=" + ((object)(Vector3)(ref val2)).ToString()); val4.transform.localScale = localScale; DBG.blogDebug("Created Creature"); component.m_nview.GetZDO().Set(releaseZDOKey, true); if (customData.TryGetValue("PP_Saddle", out var value2) && value2 == "true") { DBG.blogDebug("Attempting Saddle"); component.m_nview.GetZDO().Set(ZDOVars.s_haveSaddleHash, true); if ((Object)(object)component.m_baseAI != (Object)null && (Object)(object)component.m_baseAI.m_tamable != (Object)null) { DBG.blogDebug("Attempting Set Saddle"); component.m_baseAI.m_tamable.SetSaddle(true); } } Humanoid val5 = (Humanoid)(object)((component is Humanoid) ? component : null); if (Object.op_Implicit((Object)(object)val5) && int.TryParse(GeneralExtensions.GetValueSafe<string, string>(customData, "PP_Seed"), out var result2)) { val5.m_seed = result2; component.m_nview.GetZDO().Set(ZDOVars.s_seed, result2, true); DBG.blogDebug("Set Seed"); } component.m_nview.GetZDO().Set(ZDOVars.s_tamed, true); component.m_nview.InvokeRPC("RPC_SetTamed", new object[1] { true }); if (customData.TryGetValue("PP_Name", out var value3) && value3 != "") { Tameable val6 = default(Tameable); if (val4.TryGetComponent<Tameable>(ref val6)) { val6.SetText(value3); } else { List<Component> list = val4.GetComponents(typeof(Component)).ToList(); foreach (Component item2 in list) { if (!((object)item2).GetType().Name.Contains("Tameable")) { continue; } DBG.blogDebug("found alt Tameable with: " + ((object)item2).GetType()); MethodInfo method = ((object)item2).GetType().GetMethod("SetText"); if (method != null) { try { object[] parameters = new object[1] { value3 }; method.Invoke(item2, parameters); } catch { DBG.blogDebug("Failed SetText in " + ((object)item2).GetType()); continue; } break; } DBG.blogDebug("no method SetText found in " + ((object)item2).GetType()); } } } else { DBG.blogDebug("No Specific Name"); } if (Plugin.hasCLLC && customData.TryGetValue("PP_CLLC", out var value4)) { string[] array = value4.Split(new char[1] { ',' }); CLLC.SetInfusionCreature(component, array[0]); if (array.Length > 1) { CLLC.SetExtraEffectCreature(component, array[1]); } } if (Plugin.hasMonMod && customData.TryGetValue("PP_MonMod", out var value5)) { MonsterMod.SetModifiers(component, value5); } string name = ((Object)item.m_dropPrefab).name; bool flag2 = false; if (name.Contains("Speed")) { DBG.blogDebug("Speed PalStone"); component.GetSEMan().AddStatusEffect((StatusEffect)(object)Plugin.prefabManager.SE_SpeedBuff, false, 0, 0f); } else if (name.Contains("Armour")) { DBG.blogDebug("Armour PalStone"); component.GetSEMan().AddStatusEffect((StatusEffect)(object)Plugin.prefabManager.SE_ArmorBuff, false, 0, 0f); } else if (name.Contains("Heal")) { DBG.blogDebug("Heal PalStone"); flag2 = true; component.GetSEMan().AddStatusEffect((StatusEffect)(object)Plugin.prefabManager.SE_HealBuff, false, 0, 0f); } if (flag || !component.IsTamed()) { DBG.blogDebug("Error Occured, Destryoing Creature"); Object.Destroy((Object)(object)val4); } val4.SetActive(true); val2 = val4.transform.localScale; DBG.blogDebug("localScale pre DNA Set=" + ((object)(Vector3)(ref val2)).ToString()); component.m_nview.GetZDO().Set("PP_Scale", val4.transform.localScale); if (Plugin.hasAT && customData.TryGetValue("PP_DNA", out var value6)) { string[] array2 = value6.Split(new char[1] { ':' }); if (long.TryParse(array2[0], out var result3)) { if (array2.Length > 1 && long.TryParse(array2[1], out var result4)) { AllTame_API.setDNA(val4, result3, result4); } else { AllTame_API.setDNA(val4, result3, 0L); } } } if (customData.TryGetValue("PP_Health", out var value7)) { DBG.blogDebug("Attempting Health"); float.TryParse(value7, out var result5); if (result5 > 0f) { component.SetHealth(result5); DBG.blogDebug("Health Read=" + component.GetHealth()); } } if (customData.TryGetValue("PP_HealStart", out var value8)) { float.TryParse(value8, out var result6); if (flag2 && result6 > 0f) { DBG.blogDebug("healStartTimeStr=" + result6); DBG.blogDebug("ZNet.instance.m_netTime=" + (int)ZNet.instance.m_netTime); float num = (float)(ZNet.instance.m_netTime - (double)result6); DBG.blogDebug("seconds=" + num); if (num > 0f) { float val7 = Plugin.percentHealPerMin.Value * num / 60f; DBG.blogDebug("healPercent=" + val7); float val8 = 1f - component.GetHealthPercentage(); DBG.blogDebug("maxHealPercent=" + val8); component.SetHealth(component.GetHealth() + component.GetMaxHealth() * Math.Min(val7, val8)); DBG.blogDebug("Health healed=" + component.GetHealth()); } } } if (customData.TryGetValue("PP_LastFed", out var value9)) { DBG.blogDebug("Attempting LastFed"); float.TryParse(value9, out var result7); if (result7 != 0f) { long num2 = Math.Max(ZNet.instance.GetTime().Ticks - Convert.ToInt64(result7 * 10000000f), 0L); DBG.blogDebug("lastFed =" + result7 + ", ticks=" + num2); component.m_nview.GetZDO().Set(ZDOVars.s_tameLastFeeding, num2); } } Growup val9 = default(Growup); if (((Component)component).gameObject.TryGetComponent<Growup>(ref val9) && customData.TryGetValue("PP_growTime", out var value10)) { DBG.blogDebug("Attempting GrowTime"); float.TryParse(value10, out var result8); if (result8 != 0f) { long num3 = Math.Max(ZNet.instance.GetTime().Ticks - Convert.ToInt64(result8 * 10000000f), 0L); DBG.blogDebug("grow =" + result8 + ", ticks=" + num3); component.m_nview.GetZDO().Set(ZDOVars.s_spawnTime, num3); } } localScale = val4.transform.localScale; ReleaseCreatureEffect(component); ReleaseCreature_PostAwake(component, item); val4.GetComponent<TimedScaleAndFreeze>().ogScale = localScale; if (((object)component).GetType().Name.Contains("Companion")) { val4.GetComponent<TimedScaleAndFreeze>().clearInv = true; } float num4 = Math.Min(val4.GetComponent<Rigidbody>().mass, 110f) - 10f; val4.GetComponent<Rigidbody>().AddForce(((Component)plr).transform.rotation * new Vector3(throwforce.x, throwforce.y - 100f * num4 / 110f, throwforce.z + 220f * num4 / 110f) * (num4 + 10f), forceMode); Utils2.addOrUpdateCustomData(item.m_customData, "PP_LastCatch", valueSafe); return component; } private static void RPC_RequestCatch(long uid, ZDOID creature) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) GameObject val = ZNetScene.instance.FindInstance(creature); ZLog.Log((object)("Player " + uid + " wants to catch " + ((Object)val).name + " im: " + ZDOMan.GetSessionID())); ZNetView nview = val.GetComponent<Character>().m_nview; if (nview.IsOwner()) { nview.GetZDO().SetOwner(uid); ZLog.Log((object)(" Setting Owner to " + uid)); } else if (nview.GetZDO().GetOwner() == uid) { ZLog.Log((object)" but they are already the owner PP"); } else { ZLog.Log((object)" but neither I nor the requesting player are the owners PP"); } } private static IEnumerator CatchUpdate(Character creature) { yield return (object)new WaitForSeconds(0.1f); CatchUpdate_Repeat(creature); } private static IEnumerator regainControl(Player plr, float time) { yield return (object)new WaitForSeconds(time); regainControl_Repeat(plr, repeat: true); } private static void regainControl_Repeat(Player plr, bool repeat = false) { ItemData rightItem = ((Humanoid)plr).RightItem; if (rightItem == null || !((Object)rightItem.m_dropPrefab).name.Contains("PalStone")) { DBG.blogDebug("Invalid Item to regain control from"); return; } DBG.blogDebug("Forcing Movement"); ((Character)plr).m_animator.CrossFade("Base Layer.Movement", 0.25f, 0); if (rightItem.m_shared.m_movementModifier + 0.2f >= -0.05f) { DBG.blogDebug("Regained control"); rightItem.m_shared.m_movementModifier = -0.05f; return; } DBG.blogDebug("decreasing movement penalty"); SharedData shared = rightItem.m_shared; shared.m_movementModifier += 0.2f; if (repeat) { ((MonoBehaviour)plr).StartCoroutine(regainControl(plr, 0.1f)); } } private static void CatchUpdate_Repeat(Character creature) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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) ZNetView nview = creature.m_nview; if (!nview.IsValid()) { return; } ZDOID zDOID = nview.GetZDO().GetZDOID("PP_Catcher"); long userID = ((ZDOID)(ref zDOID)).UserID; long owner = nview.GetZDO().GetOwner(); DBG.blogDebug("found UID=" + userID); DBG.blogDebug("owner=" + owner); if (userID == owner) { ZLog.Log((object)"I can finally Catch"); ItemData palStone = GetPalStone(Player.m_localPlayer, creature); if (palStone != null && SaveCreatureToItem(creature, palStone)) { creature.m_nview.InvokeRPC(ZNetView.Everybody, "RPC_CatchEffect", new object[2] { nview.GetZDO().m_uid, zDOID }); } else { DBG.blogWarning("Failed to save creature data to Item"); } ((MonoBehaviour)Player.m_localPlayer).StartCoroutine(regainControl(Player.m_localPlayer, 1.1f)); } else { regainControl_Repeat(Player.m_localPlayer); ZLog.Log((object)"Im still not the owner"); ((MonoBehaviour)creature).StartCoroutine(CatchUpdate(creature)); } } private static void RPC_CatchEffect(long uid, ZDOID creature, ZDOID catcher) { //IL_0006: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) GameObject val = ZNetScene.instance.FindInstance(creature); Character component = val.GetComponent<Character>(); GameObject val2 = ZNetScene.instance.FindInstance(catcher); if (component.m_nview.IsValid()) { GameObject val3 = new GameObject("holder"); val3.SetActive(false); val3.transform.position = ((Component)component).transform.position; ((Component)component).transform.parent = val3.transform; val3.AddComponent<TimedColor>(); TimedDestruction val4 = val3.AddComponent<TimedDestruction>(); val4.Trigger(2f); TimedScaleAndFreeze timedScaleAndFreeze = ((Component)component).gameObject.AddComponent<TimedScaleAndFreeze>().SetRB(((Component)component).GetComponent<Rigidbody>()); Vector3 endPos = val2.transform.position + val2.transform.rotation * new Vector3(0.288f, 1.8141f, 0.91f); timedScaleAndFreeze.SetEndPos(endPos); timedScaleAndFreeze.startScale = 1f; timedScaleAndFreeze.endScale = 0.01f; timedScaleAndFreeze.startimeMove = 0.3f; timedScaleAndFreeze.startimeScale = 0f; timedScaleAndFreeze.roughness = 0f; timedScaleAndFreeze.breakChild = -1; timedScaleAndFreeze.setFinalScale = false; val3.SetActive(true); } } } internal class Patches { [HarmonyPatch(typeof(InventoryGui), "CanRepair")] public static class FixMaxRepairLevel { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { bool skipped = false; foreach (CodeInstruction instruction in instructions) { if (!skipped && instruction.opcode == OpCodes.Ldc_I4_4) { skipped = true; yield return new CodeInstruction(OpCodes.Ldc_I4_8, (object)null); } else { yield return instruction; } } } } public static string catch_anim = "emote_point"; public static string release_anim = "knife_stab"; [HarmonyPatch(typeof(ObjectDB), "Awake")] [HarmonyPostfix] private static void AddItems(ObjectDB __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "main" && ZNet.instance.IsServer()) { DBG.blogDebug("Updating Pal Stones as Server"); PrefabManager.UpdateItems(); } } [HarmonyPrefix] [HarmonyPatch(typeof(Attack), "Start")] private static bool Attack_Start(Attack __instance, Humanoid character, ZSyncAnimation zanim, ItemData weapon, ref float timeSinceLastAttack) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown if (weapon == null) { return true; } if ((Object)(object)weapon.m_dropPrefab == (Object)null || !((Object)weapon.m_dropPrefab).name.Contains("PalStone")) { return true; } if (Math.Abs(Time.time - weapon.m_lastAttackTime) < 1.1f) { return false; } weapon.m_shared.m_movementModifier = -0.05f; DBG.blogDebug("inPalStoneAttackAwake"); int num = CatchPal.attemptCatch((Player)character, weapon); if (((Character)character).IsPlayer() && num <= 0) { weapon.m_lastAttackTime = Time.time; ((Character)character).m_attack = true; return false; } if (num == 2) { __instance.m_attackAnimation = catch_anim; __instance.m_attackChainLevels = 1; zanim.SetSpeed(4f); zanim.m_animator.speed = 3f; } else { __instance.m_attackAnimation = release_anim; __instance.m_attackChainLevels = 3; zanim.SetSpeed(0.5f); zanim.m_animator.speed = 0.5f; } weapon.m_lastAttackTime = Time.time; DBG.blogDebug("animation=" + __instance.m_attackAnimation); return true; } private static string ByPassFilter(string text) { string result = default(string); bool flag = default(bool); if (CensorShittyWords.Filter(text, ref result, ref flag) && flag) { return result; } return text; } [HarmonyPostfix] [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] private static void Postfix(ItemData item, bool crafting, int qualityLevel, ref string __result) { if (Object.op_Implicit((Object)(object)item.m_dropPrefab) && ((Object)item.m_dropPrefab).name.Contains("PalStone")) { __result = Build_PalStone_Description(item, crafting, qualityLevel); } } private static string Build_PalStone_Description(ItemData item, bool crafting, int quality) { Player localPlayer = Player.m_localPlayer; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(item.m_shared.m_description); stringBuilder.Append("\n"); if (item.m_crafterID != 0) { stringBuilder.AppendFormat("\n$item_crafter: <color=orange>{0}\n</color>", ByPassFilter(item.m_crafterName)); } string name = ((Object)item.m_dropPrefab).name; if (name.Contains("Speed")) { stringBuilder.AppendFormat("<color=yellow>{0}$pp_speedEffect_desc\n$pp_duration</color>{1}s\n", Plugin.speedIncrease.Value * 100f, Plugin.Speed_buffLength.Value); } else if (name.Contains("Armour")) { stringBuilder.AppendFormat("<color=#04a6da>$pp_armourEffect_desc\n$pp_duration</color>{0}s\n", Plugin.Armor_buffLength.Value); } else if (name.Contains("Heal")) { stringBuilder.AppendFormat("<color=green>$pp_healEffect_desc {0}%</color>\n", Plugin.percentHealPerMin.Value * 100f); } if (item.m_shared.m_useDurability) { if (crafting) { float maxDurability = item.GetMaxDurability(quality); stringBuilder.AppendFormat("\n$item_durability: <color=orange>{0}</color>", maxDurability); } else { float maxDurability2 = item.GetMaxDurability(quality); float durability = item.m_durability; stringBuilder.AppendFormat("\n$item_durability: <color=orange>{0}%</color> <color=yellow>({1}/{2})</color>", (item.GetDurabilityPercentage() * 100f).ToString("0"), durability.ToString("0"), maxDurability2.ToString("0")); } if (item.m_shared.m_canBeReparied && !crafting) { Recipe recipe = ObjectDB.instance.GetRecipe(item); if ((Object)(object)recipe != (Object)null) { int minStationLevel = recipe.m_minStationLevel; stringBuilder.AppendFormat("\n$item_repairlevel: <color=orange>{0}</color>", minStationLevel.ToString()); } } } stringBuilder.Append("\n"); Dictionary<string, string> customData = item.m_customData; if (!customData.TryGetValue("PP_Prefab", out var value) || (value ?? "") == "") { stringBuilder.Append("<color=red>$pp_empty</color>\n"); localPlayer.AppendEquipmentModifierTooltips(item, stringBuilder); return stringBuilder.ToString(); } GameObject prefab = ZNetScene.instance.GetPrefab(value); Character val = default(Character); if (Object.op_Implicit((Object)(object)prefab) && prefab.TryGetComponent<Character>(ref val)) { value = val.m_name; } stringBuilder.Append("$pp_stored_creature<color=green>" + value + "</color>\n"); if (customData.TryGetValue("PP_Name", out var value2) && (value2 ?? "") != "") { stringBuilder.Append("$pp_name<color=orange>" + value2 + "</color>\n"); } stringBuilder.Append("$pp_lvl<color=orange>" + GeneralExtensions.GetValueSafe<string, string>(customData, "PP_Lvl") + "</color>\n"); if (Plugin.hasCLLC) { string[] array = GeneralExtensions.GetValueSafe<string, string>(customData, "PP_CLLC").Split(new char[1] { ',' }); if ((array[0] ?? "") != "" && array[0] != "None") { stringBuilder.Append("$pp_infusion<color=orange>" + array[0] + "</color>\n"); } if (array.Length > 1 && array[1] + "None" != "" && array[1] != "None") { stringBuilder.Append("$pp_effect<color=orange>" + array[1] + "</color>\n"); } } if (customData.TryGetValue("PP_Saddle", out var value3) && value3 == "true") { stringBuilder.Append("- <color=orange>$pp_has_saddle</color>\n"); } localPlayer.AppendEquipmentModifierTooltips(item, stringBuilder); return stringBuilder.ToString(); } } public static class DBG { public static void cprt(string s) { Console.instance.Print(s); } public static void InfoTL(string s) { ((Character)Player.m_localPlayer).Message((MessageType)1, s, 0, (Sprite)null); } public static void InfoCT(string s) { ((Character)Player.m_localPlayer).Message((MessageType)2, s, 0, (Sprite)null); } public static void blogInfo(object o) { Plugin.logger.LogInfo(o); } public static void blogWarning(object o) { Plugin.logger.LogWarning(o); } public static void blogDebug(object o) { if (Plugin.debugout.Value) { Plugin.logger.LogWarning(o); } } public static void tryblogDebug(object o, object o_backup) { try { if (Plugin.debugout.Value) { Plugin.logger.LogWarning(o); } } catch { Plugin.logger.LogWarning(o_backup); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("meldurson.valheim.PortablePals", "PortablePals", "0.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static ConfigEntry<int> nexusID; public static ConfigEntry<string> cfg; public static ConfigEntry<int> durability; public static ConfigEntry<bool> repairable; public static ConfigEntry<bool> destroyOnBreak; public static ConfigEntry<string> recipe; public static ConfigEntry<string> craftingStation; public static ConfigEntry<float> cooldown; public static ConfigEntry<bool> debugout; public static ConfigEntry<string> recipe_Heal; public static ConfigEntry<float> percentHealPerMin; public static ConfigEntry<string> recipe_Speed; public static ConfigEntry<float> speedIncrease; public static ConfigEntry<int> Speed_buffLength; public static ConfigEntry<string> recipe_Armor; public static ConfigEntry<int> Armor_buffLength; public static string assetPath = "Assets/PortablePals/"; public static ManualLogSource logger; public static GameObject Root; public static PrefabManager prefabManager; public const string CLLCGUID = "org.bepinex.plugins.creaturelevelcontrol"; public const string AllTameableGUID = "meldurson.valheim.AllTameable"; public const string MonModGUID = "warpalicious.MonsterModifiers"; public const string SLSGUID = "MidnightsFX.StarLevelSystem"; public static bool hasCLLC = false; public static bool hasAT = false; public static bool hasMonMod = false; public static bool hasSLS = false; [HarmonyPatch(typeof(ZNetScene), "Shutdown")] [HarmonyPostfix] private static void Postfix() { DBG.blogInfo("Reseting PortablePals"); } private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_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_007d: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Expected O, but got Unknown //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Expected O, but got Unknown //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Expected O, but got Unknown //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Expected O, but got Unknown //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Expected O, but got Unknown //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Expected O, but got Unknown //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Expected O, but got Unknown logger = ((BaseUnityPlugin)this).Logger; recipe = ((BaseUnityPlugin)this).Config.Bind<string>("2: Crafting", "Crafting Recipe", "DragonTear:3,Crystal:5,WolfClaw:5,Obsidian:3", new ConfigDescription("What is the recipe for craft, separate amount with : and different items with ,", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); craftingStation = ((BaseUnityPlugin)this).Config.Bind<string>("2: Crafting", "Crafting Station", "piece_workbench:3", new ConfigDescription("What is the required Crafting Station and Level, separated by a : such as piece_workbench:3 would be lvl 3 Workbench (vanilla stations are: piece_workbench, forge, piece_cauldron, piece_stonecutter, piece_artisanstation, blackforge, piece_magetable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); durability = ((BaseUnityPlugin)this).Config.Bind<int>("2: Crafting", "Durability", 15, new ConfigDescription("Durability of PalStone, 0 is indestuctable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); repairable = ((BaseUnityPlugin)this).Config.Bind<bool>("2: Crafting", "Repairable", true, new ConfigDescription("If durability is used, can stone be repaired?", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); destroyOnBreak = ((BaseUnityPlugin)this).Config.Bind<bool>("2: Crafting", "destroyOnBreak", false, new ConfigDescription("If durability is used, will the stone be destroyed when out of durability (sets repairable to false)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); cooldown = ((BaseUnityPlugin)this).Config.Bind<float>("2: Crafting", "Cooldown", 20f, new ConfigDescription("Cooldown between uses in seconds", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); debugout = ((BaseUnityPlugin)this).Config.Bind<bool>("1: General", "Debug Output", false, "Determines if debug is output to bepinex log"); recipe_Heal = ((BaseUnityPlugin)this).Config.Bind<string>("3: Healing Stone", "Crafting Recipe", "PalStone:1,LinenThread:10,Obsidian:5,MeadHealthMinor:5", new ConfigDescription("What is the recipe for crafting the Healing Pal Stone, separate amount with : and different items with ,", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); percentHealPerMin = ((BaseUnityPlugin)this).Config.Bind<float>("3: Healing Stone", "Healing Per Minute", 0.05f, new ConfigDescription("What percent does a creature trapped in a healing pal stone gain per minute as a decimal (0.05 is 5% per minute)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); recipe_Speed = ((BaseUnityPlugin)this).Config.Bind<string>("4: Speed Stone", "Crafting Recipe", "PalStone:1,LinenThread:10,Obsidian:5,MeadStaminaMinor:5", new ConfigDescription("What is the recipe for crafting the Speed Pal Stone, separate amount with : and different items with ,", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); speedIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("4: Speed Stone", "Percent Speed Increase", 0.2f, new ConfigDescription("What percent does a creature released from a speed stone gain as a decimal (0.2 is 20% speed increase)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Speed_buffLength = ((BaseUnityPlugin)this).Config.Bind<int>("4: Speed Stone", "Buff Length", 180, new ConfigDescription("How long does the speed buff last in seconds", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); recipe_Armor = ((BaseUnityPlugin)this).Config.Bind<string>("5: Armour Stone", "Crafting Recipe", "PalStone:1,LinenThread:10,Obsidian:5,LoxPelt:15", new ConfigDescription("What is the recipe for crafting the Speed Pal Stone, separate amount with : and different items with ,", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Armor_buffLength = ((BaseUnityPlugin)this).Config.Bind<int>("5: Armour Stone", "Buff Length", 180, new ConfigDescription("How long does the armour buff last in seconds", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Localizer.Load(); Root = new GameObject("PortablePals Root"); Object.DontDestroyOnLoad((Object)(object)Root); CatchPal.Staging = new GameObject("Staging Area"); CatchPal.Staging.transform.SetParent(Root.transform); CatchPal.Staging.SetActive(false); if (Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.creaturelevelcontrol")) { DBG.blogDebug("Has CLLC"); hasCLLC = true; } if (Chainloader.PluginInfos.ContainsKey("meldurson.valheim.AllTameable")) { DBG.blogDebug("Has AllTameable"); hasAT = true; } if (Chainloader.PluginInfos.ContainsKey("warpalicious.MonsterModifiers")) { DBG.blogDebug("Has MonsterModifiers"); hasMonMod = true; } if (Chainloader.PluginInfos.ContainsKey("MidnightsFX.StarLevelSystem")) { DBG.blogDebug("Has StarLevelSystem"); hasSLS = true; } PerformPatches(); prefabManager = Root.AddComponent<PrefabManager>(); DBG.blogInfo("PortablePals Loaded"); PrefabManager.OnVanillaPrefabsAvailable += PrefabManager.ItemReg; SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr) { if (attr.InitialSynchronization) { Logger.LogMessage((object)"Initial Config sync event received"); } else { Logger.LogMessage((object)"Config sync event received"); } PrefabManager.ItemRegFromServer(); }; } public void PerformPatches() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("meldurson.valheim.PortablePals"); DBG.blogInfo("Patching Select"); val.PatchAll(typeof(Patches)); val.PatchAll(typeof(CatchPal)); if (hasCLLC) { val.PatchAll(typeof(CLLC_Patches)); DBG.blogDebug("Patched CLLCPatches"); } if (hasAT) { val.PatchAll(typeof(AllTame_API.AT_DNA_Patches)); DBG.blogDebug("Patched ATPatches"); } if (Chainloader.PluginInfos.ContainsKey("RustyMods.VikingNPC")) { DBG.blogInfo("Patching RustyMods.VikingNPC"); val.PatchAll(typeof(VikingNPC)); } IEnumerable<MethodBase> patchedMethods = val.GetPatchedMethods(); val.PatchAll(typeof(Patches.FixMaxRepairLevel)); foreach (MethodBase item in patchedMethods) { DBG.blogDebug(item.ReflectedType?.ToString() + ":" + item.Name + " is patched"); } } } public class TimedScaleAndFreeze : MonoBehaviour { public float roughness = 0.05f; public float startimeScale = 1f; public float startimeMove = 0.4f; private float lastTimeScale = 0f; private float lastTimeMove = 0f; public float duration = 1f; public int breakChild = 0; public float startScale = 0.01f; public float endScale = 1f; public float maxMovePercent = 0.1f; public Vector3 endLoc = Vector3.zero; private float timeMulti; public Vector3 ogScale; private float endTime; public bool ZNetDestroy = true; private bool firstUpdate = true; public float CLLC_Scale = 1f; public float DNA_Scale = 1f; public bool setFinalScale = true; public bool clearInv = false; public bool pastStart = false; public float sls_Size = 1f; private bool sls_SetSecond = true; private Vector3 previousScale; public Vector3 exteriorScale = Vector3.one; public Rigidbody rb; private RigidbodyConstraints constraints = (RigidbodyConstraints)0; public ZNetView m_nview; private void Start() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_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_0175: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_nview == (Object)null) { m_nview = ((Component)this).GetComponent<ZNetView>(); } if ((Object)(object)m_nview == (Object)null) { m_nview = ((Component)this).GetComponentInParent<ZNetView>(); } lastTimeScale = Time.time + startimeScale; startimeScale = lastTimeScale; lastTimeMove = Time.time + startimeMove; startimeMove = lastTimeMove; DBG.blogDebug("Start Time Scale =" + startimeScale); timeMulti = (endScale - startScale) / duration; _ = ogScale; if (ogScale == Vector3.zero) { ogScale = ((Component)this).transform.localScale; } Vector3 val = ogScale; DBG.blogDebug("ogScale =" + ((object)(Vector3)(ref val)).ToString()); CatchPal.ReleaseData releaseData = default(CatchPal.ReleaseData); if (sls_Size == 1f && ((Component)this).gameObject.TryGetComponent<CatchPal.ReleaseData>(ref releaseData)) { sls_Size = releaseData.sls_Size; } ogScale *= sls_Size; val = ogScale; DBG.blogDebug("post SLS =" + ((object)(Vector3)(ref val)).ToString()); ((Component)this).transform.localScale = ogScale * startScale; previousScale = ((Component)this).transform.localScale; endTime = startimeScale + duration; } private void Update() { //IL_0100: 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_0138: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_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_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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) //IL_01a4: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; Vector3 val; if (time > endTime) { if (setFinalScale) { ((Component)this).transform.localScale = Vector3.Scale(exteriorScale, ogScale); val = ((Component)this).transform.localScale; DBG.blogDebug("finalScale=" + ((object)(Vector3)(ref val)).ToString()); if (sls_Size != 1f) { ((Component)this).transform.localScale = ogScale; val = ((Component)this).transform.localScale; DBG.blogDebug("finalScale post sls=" + ((object)(Vector3)(ref val)).ToString()); } CatchPal.ReleaseCreature_PostRelease(((Component)this).gameObject.GetComponent<Character>(), this); } removeSelf(); return; } if (time - lastTimeScale > roughness) { Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(((Component)this).transform.localScale.x / previousScale.x, ((Component)this).transform.localScale.y / previousScale.y, ((Component)this).transform.localScale.z / previousScale.z); if (((Vector3)(ref val2)).magnitude < 5f) { exteriorScale = Vector3.Scale(exteriorScale, val2); } else { val = val2; string? text = ((object)(Vector3)(ref val)).ToString(); val = ((Component)this).transform.localScale; DBG.blogDebug("scaler Scale too high =" + text + ", scale=" + ((object)(Vector3)(ref val)).ToString()); } if (((Component)this).transform.localScale.x / previousScale.x != 1f) { val = exteriorScale; string? text2 = ((object)(Vector3)(ref val)).ToString(); val = ((Component)this).transform.localScale; DBG.blogDebug("exterior Scale =" + text2 + ", scale=" + ((object)(Vector3)(ref val)).ToString()); } if (sls_Size != 1f && sls_SetSecond && exteriorScale != Vector3.one) { val = ((Component)this).transform.localScale; if ((double)((Vector3)(ref val)).magnitude > 0.4 * (double)sls_Size) { sls_SetSecond = false; if (Plugin.hasSLS) { string[] obj = new string[6] { "sls exterior Scale =", null, null, null, null, null }; val = exteriorScale; obj[1] = ((object)(Vector3)(ref val)).ToString(); obj[2] = ", scale="; val = ((Component)this).transform.localScale; obj[3] = ((object)(Vector3)(ref val)).ToString(); obj[4] = "newSLS="; obj[5] = (sls_Size * 0.42f).ToString(); DBG.blogDebug(string.Concat(obj)); ZDO zDO = ((Component)this).gameObject.GetComponent<ZNetView>().GetZDO(); zDO.Set("SLE_Size", sls_Size * 0.42f); } } } ((Component)this).transform.localScale = Vector3.Scale(exteriorScale, ogScale) * (startScale + timeMulti * (time - startimeScale)); previousScale = ((Component)this).transform.localScale; lastTimeScale = time; if (firstUpdate) { Character component = ((Component)this).gameObject.GetComponent<Character>(); if ((Object)(object)component != (Object)null && !((Behaviour)component).enabled) { ((Behaviour)component).enabled = true; } firstUpdate = false; } Humanoid val3 = default(Humanoid); if (clearInv && pastStart && ((Component)this).gameObject.TryGetComponent<Humanoid>(ref val3)) { Inventory inventory = val3.GetInventory(); if (inventory.m_inventory.Count() > 0) { clearInv = false; } inventory.RemoveAll(); inventory.Changed(); } } if (time - lastTimeMove > roughness && endLoc != Vector3.zero) { if (endLoc != Vector3.zero) { ((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, endLoc, maxMovePercent * Vector3.Distance(((Component)this).transform.position, endLoc)); } lastTimeMove = time; } } public void SetEndPos(Vector3 location) { //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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) endLoc = location; Vector3 val = endLoc; DBG.blogDebug("End loc =" + ((object)(Vector3)(ref val)).ToString()); } public TimedScaleAndFreeze SetRB(Rigidbody freeze_rb) { //IL_000f: 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) rb = freeze_rb; constraints = rb.constraints; rb.constraints = (RigidbodyConstraints)126; return this; } public void removeSelf() { //IL_01ba: Unknown result type (might be due to invalid IL or missing references) Humanoid component = ((Component)this).gameObject.GetComponent<Humanoid>(); if (clearInv && (Object)(object)component != (Object)null) { Inventory inventory = component.GetInventory(); DBG.blogDebug("inv pre size=" + inventory.m_inventory.Count()); DBG.blogDebug("Clearing Inventory"); inventory.RemoveAll(); DBG.blogDebug("inv post size=" + inventory.m_inventory.Count()); inventory.Changed(); } try { VisEquipment componentInChildren = ((Component)this).gameObject.GetComponentInChildren<VisEquipment>(); if ((Object)(object)componentInChildren != (Object)null && !((Behaviour)componentInChildren).enabled) { ((Behaviour)componentInChildren).enabled = true; ((Component)componentInChildren.m_rightHand).gameObject.SetActive(true); ((Component)componentInChildren.m_leftHand).gameObject.SetActive(true); if ((Object)(object)component != (Object)null) { component.EquipItem(component.RightItem, true); DBG.blogDebug("Equipped right Item:" + ((object)component.RightItem).ToString()); } } } catch { DBG.blogWarning("Failed VisEquip"); } try { if (breakChild >= 0 && breakChild < ((Component)this).transform.childCount) { DBG.blogDebug("Breaking Child " + ((Object)((Component)this).gameObject).name); Transform child = ((Component)this).transform.GetChild(breakChild); if (Object.op_Implicit((Object)(object)child)) { child.parent = null; if ((Object)(object)rb != (Object)null) { rb.constraints = constraints; } } } } catch { DBG.blogWarning("Failed Break Child"); } try { ZNetView component2 = ((Component)this).gameObject.GetComponent<ZNetView>(); if ((Object)(object)component2 != (Object)null && component2.IsValid() && component2.GetZDO().GetBool(CatchPal.releaseZDOKey, false)) { DBG.blogDebug("Removing Release ZDO"); component2.GetZDO().Set(CatchPal.releaseZDOKey, false); } } catch { DBG.blogWarning("Failed reset releaseZDO"); } DestroyNow(); } public void DestroyNow() { if (!ZNetDestroy) { DBG.blogDebug("Destroying tsf component in " + ((Object)((Component)this).gameObject).name); Object.Destroy((Object)(object)this); } else if (Object.op_Implicit((Object)(object)m_nview)) { if (m_nview.IsValid()) { if (!m_nview.HasOwner()) { m_nview.ClaimOwnership(); } if (m_nview.IsOwner()) { DBG.blogDebug("Destroying Znet in " + ((Object)((Component)this).gameObject).name); ZNetScene.instance.Destroy(((Component)this).gameObject); } } } else { DBG.blogDebug("Not Owner, waiting for owner to destroy " + ((Object)((Component)this).gameObject).name); } } } public class TimedColor : MonoBehaviour { public float roughness = 0.01f; public float startime = 0f; private float lastTime = 0f; public float duration = 0.7f; public int breakChild = 0; public Color endColorMulti = new Color(25f, 25f, 25f); private Color colMulti; private float endTime; private List<Material> materials = new List<Material>(); private int actualCyles = 0; private bool hasEnded = false; public Rigidbody rb; private void Start() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) lastTime = Time.time + startime; startime = lastTime; DBG.blogDebug("Start Color time =" + startime); int num = (int)(duration / Math.Max(roughness, 1f / 59f)); DBG.blogDebug("Expected num cycles=" + num); colMulti = new Color(Mathf.Pow(endColorMulti.r, 1f / (float)num), Mathf.Pow(endColorMulti.g, 1f / (float)num), Mathf.Pow(endColorMulti.b, 1f / (float)num)); endTime = startime + duration; Renderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<Renderer>(); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { DBG.blogDebug("material added: " + ((Object)val.material).name); materials.Add(val.material); } } private void Update() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00bd: 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) if (hasEnded) { return; } float time = Time.time; if (time > endTime) { DBG.blogDebug("ActualCycles =" + actualCyles); hasEnded = true; } else { if (!(time - lastTime > roughness)) { return; } actualCyles++; foreach (Material material in materials) { Color color = material.color; material.color = new Color(color.r * colMulti.r, color.g * colMulti.g, color.b * colMulti.b); } lastTime = time; } } } public class PP_SE : StatusEffect { private ZNetView m_nview; public string ZDO_key = ""; public float m_lvl = 1f; public float m_length = 600f; public float m_damageMod = 0.6f; public SkillType[] modifySkills = (SkillType[])(object)new SkillType[0]; public override void Setup(Character character) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) base.m_character = character; if (!string.IsNullOrEmpty(base.m_startMessage)) { base.m_character.Message(base.m_startMessageType, base.m_startMessage, 0, (Sprite)null); } m_nview = base.m_character.m_nview; if (m_nview.IsValid()) { if (base.m_repeatInterval > 0f) { m_length = base.m_repeatInterval; } DBG.blogDebug("Setting " + ZDO_key + " to time " + (Time.time + m_length)); m_nview.GetZDO().Set(ZDO_key, Time.time + m_length); } ((StatusEffect)this).TriggerStartEffects(); } public override void UpdateStatusEffect(float dt) { base.m_time += dt; if (base.m_repeatInterval > 0f) { base.m_msgTimer += dt; if (base.m_msgTimer > base.m_repeatInterval) { DBG.blogDebug("resetting timer for " + ZDO_key + " to time " + (Time.time + base.m_repeatInterval)); base.m_msgTimer = 0f; m_nview.GetZDO().Set(ZDO_key, Time.time + base.m_repeatInterval); } } } public override void ModifyAttack(SkillType skill, ref HitData hitData) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (modifySkills.Length != 0 && (modifySkills.Contains(skill) || (int)modifySkills[0] == 999)) { ((DamageTypes)(ref hitData.m_damage)).Modify(m_damageMod); } } public override void Stop() { ((StatusEffect)this).Stop(); m_nview.GetZDO().Set(ZDO_key, 0f); } } public class PrefabManager : MonoBehaviour { public SE_Stats SE_SpeedBuff = ScriptableObject.CreateInstance<SE_Stats>(); public SE_Stats SE_ArmorBuff = ScriptableObject.CreateInstance<SE_Stats>(); public SE_Stats SE_HealBuff = ScriptableObject.CreateInstance<SE_Stats>(); public GameObject Root; private static AssetBundle PP_Assets; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Root = new GameObject("PrefabList"); Root.transform.SetParent(Plugin.Root.transform); Root.SetActive(false); PP_Assets = AssetUtils.LoadAssetBundleFromResources("portablepals", Assembly.GetExecutingAssembly()); } public static AssetBundle getAssetBundle() { return PP_Assets; } public static void ItemReg() { DBG.blogDebug("ItemReg"); AddItems(); PrefabManager.OnVanillaPrefabsAvailable -= ItemReg; } public static void ItemRegFromServer() { UpdateItems(); } public static void AddItems() { addPortablePalStone(); addSpeedPalStone(); addArmourPalStone(); addHealPalStone(); Plugin.prefabManager.addEffects(); } public static void UpdateItems() { DBG.blogDebug("Updating recipes for palstones"); if ((Object)(object)ZNetScene.instance == (Object)null) { DBG.blogDebug("zns is null"); return; } ResetPalStoneRecipe(Plugin.recipe.Value, "PalStone"); ResetPalStoneRecipe(Plugin.recipe_Armor.Value, "PalStoneArmour"); ResetPalStoneRecipe(Plugin.recipe_Heal.Value, "PalStoneHeal"); ResetPalStoneRecipe(Plugin.recipe_Speed.Value, "PalStoneSpeed"); } private static Recipe ResetPalStoneRecipe(string recipeConfig, string item) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item); ItemDrop val = default(ItemDrop); if ((Object)(object)itemPrefab == (Object)null || !itemPrefab.TryGetComponent<ItemDrop>(ref val)) { DBG.blogWarning(item + " is null or does not have itemDrop"); return null; } Recipe val2 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val2).name = "Recipe_" + item; val2.m_item = val; string[] array = Plugin.craftingStation.Value.Split(new char[1] { ':' }); GameObject prefab = ZNetScene.instance.GetPrefab(array[0]); CraftingStation val3 = default(CraftingStation); if ((Object)(object)prefab == (Object)null || !prefab.TryGetComponent<CraftingStation>(ref val3)) { DBG.blogWarning("invalid crafting station: " + array[0]); return null; } val2.m_craftingStation = val3; val2.m_repairStation = val3; if (array.Length > 1 && int.TryParse(array[1], out var result)) { val2.m_minStationLevel = result; } else { val2.m_minStationLevel = 5; } string[] array2 = recipeConfig.Split(new char[1] { ',' }); int amt = 1; List<Requirement> list = new List<Requirement>(); for (int i = 0; i < array2.Length; i++) { string[] array3 = array2[i].Split(new char[1] { ':' }); if (array3.Length == 2 && int.TryParse(array3[1], out var result2)) { amt = result2; } Requirement val4 = makeRequirment(array3[0], amt); if (val4 == null) { return null; } list.Add(val4); } val2.m_resources = list.ToArray(); if (ItemManager.Instance.GetRecipe(((Object)val2).name) != null) { ItemManager.Instance.RemoveRecipe(((Object)val2).name); } ObjectDB.instance.m_recipes.Add(val2); SetDurability(ref val.m_itemData); return val2; } private static Requirement makeRequirment(string itemStr, int amt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Requirement val = new Requirement(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemStr); ItemDrop resItem = default(ItemDrop); if (!Object.op_Implicit((Object)(object)itemPrefab) || !itemPrefab.TryGetComponent<ItemDrop>(ref resItem)) { DBG.blogDebug("Ingredient: " + itemStr + " is not found"); return null; } val.m_amount = amt; val.m_amountPerLevel = Mathf.RoundToInt((float)amt * 0.75f); val.m_resItem = resItem; return val; } private static ItemConfig makePalStoneRecipe(string recipeConfig) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown ItemConfig val = new ItemConfig(); string[] array = recipeConfig.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); if (array2.Length == 2 && int.TryParse(array2[1], out var result)) { val.AddRequirement(new RequirementConfig(array2[0], result, 0, false)); } else { val.AddRequirement(new RequirementConfig(array2[0], 1, 0, false)); } } string[] array3 = Plugin.craftingStation.Value.Split(new char[1] { ':' }); if (array3.Length == 2 && int.TryParse(array3[1], out var result2)) { val.CraftingStation = array3[0]; val.MinStationLevel = result2; val.RepairStation = array3[0]; } else { val.CraftingStation = array3[0]; val.RepairStation = array3[0]; val.MinStationLevel = 5; } return val; } public static void addPortablePalStone() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown CustomItem val = ItemManager.Instance.GetItem("PalStone"); if (val == null) { DBG.blogDebug("Adding recipe for Pal Stone"); GameObject val2 = PP_Assets.LoadAsset<GameObject>(Plugin.assetPath + "Palstone.prefab"); DBG.blogDebug("Loaded from assets"); PrefabExtension.FixReferences(val2, true); val = new CustomItem(val2, true, makePalStoneRecipe(Plugin.recipe.Value)); ItemManager.Instance.AddItem(val); } SetDurability(ref val.ItemDrop.m_itemData); } public static void addSpeedPalStone() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown CustomItem val = ItemManager.Instance.GetItem("PalStoneSpeed"); if (val == null) { DBG.blogDebug("Adding recipe for Pal Stone Speed"); GameObject val2 = PP_Assets.LoadAsset<GameObject>(Plugin.assetPath + "PalStoneSpeed.prefab"); PrefabExtension.FixReferences(val2, true); DBG.blogDebug("Loaded from assets"); DBG.blogDebug("Set Name"); val = new CustomItem(val2, true, makePalStoneRecipe(Plugin.recipe_Speed.Value)); ItemManager.Instance.AddItem(val); DBG.blogDebug("Added Item"); } SetDurability(ref val.ItemDrop.m_itemData); } public static void addArmourPalStone() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown CustomItem val = ItemManager.Instance.GetItem("PalStoneArmour"); if (val == null) { DBG.blogDebug("Adding recipe for Pal Stone Armour"); GameObject val2 = PP_Assets.LoadAsset<GameObject>(Plugin.assetPath + "PalStoneArmour.prefab"); PrefabExtension.FixReferences(val2, true); val = new CustomItem(val2, true, makePalStoneRecipe(Plugin.recipe_Armor.Value)); ItemManager.Instance.AddItem(val); } SetDurability(ref val.ItemDrop.m_itemData); } public static void addHealPalStone() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown CustomItem val = ItemManager.Instance.GetItem("PalStoneHeal"); if (val == null) { DBG.blogDebug("Adding recipe for Pal Stone Heal"); GameObject val2 = PP_Assets.LoadAsset<GameObject>(Plugin.assetPath + "PalStoneHeal.prefab"); PrefabExtension.FixReferences(val2, true); val = new CustomItem(val2, true, makePalStoneRecipe(Plugin.recipe_Heal.Value)); ItemManager.Instance.AddItem(val); } SetDurability(ref val.ItemDrop.m_itemData); } public static void SetDurability(ref ItemData id2) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (Plugin.durability.Value > 0) { id2.m_shared.m_maxDurability = Plugin.durability.Value; id2.m_shared.m_useDurability = true; } else { id2.m_shared.m_useDurability = false; } if (Plugin.destroyOnBreak.Value) { id2.m_shared.m_canBeReparied = false; id2.m_shared.m_destroyBroken = true; } else if (Plugin.repairable.Value) { id2.m_shared.m_canBeReparied = true; } else { id2.m_shared.m_canBeReparied = false; } id2.m_shared.m_attachOverride = (ItemType)19; } private void addEffects() { //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) Transform transform = PP_Assets.LoadAsset<GameObject>(Plugin.assetPath + "vfx_ReleaseEffects.prefab").transform; GameObject val = Object.Instantiate<GameObject>(((Component)transform.Find("vfx_SpeedRelease")).gameObject, Root.transform); ((StatusEffect)SE_SpeedBuff).m_startEffects.m_effectPrefabs = NewStickyEffect(); ((StatusEffect)SE_SpeedBuff).m_startEffects.m_effectPrefabs[0].m_prefab = val; ((Object)SE_SpeedBuff).name = "SE_PPSpeed"; ((StatusEffect)SE_SpeedBuff).m_ttl = Plugin.Speed_buffLength.Value; SE_SpeedBuff.m_speedModifier = 1f + Plugin.speedIncrease.Value; GameObject val2 = Object.Instantiate<GameObject>(((Component)transform.Find("vfx_HealRelease")).gameObject, Root.transform); ((StatusEffect)SE_HealBuff).m_startEffects.m_effectPrefabs = NewStickyEffect(); ((StatusEffect)SE_HealBuff).m_startEffects.m_effectPrefabs[0].m_prefab = val2; ((Object)SE_HealBuff).name = "SE_PPHeal"; ((StatusEffect)SE_HealBuff).m_ttl = 10f; GameObject val3 = Object.Instantiate<GameObject>(((Component)transform.Find("vfx_ArmourRelease")).gameObject, Root.transform); ((StatusEffect)SE_ArmorBuff).m_startEffects.m_effectPrefabs = NewStickyEffect(); ((StatusEffect)SE_ArmorBuff).m_startEffects.m_effectPrefabs[0].m_prefab = val3; ((Object)SE_ArmorBuff).name = "SE_PPArmour"; ((StatusEffect)SE_ArmorBuff).m_ttl = Plugin.Armor_buffLength.Value; SE_ArmorBuff.m_mods = new List<DamageModPair>(); DamageModPair item = default(DamageModPair); item.m_type = (DamageType)1024; item.m_modifier = (DamageModifier)5; SE_ArmorBuff.m_mods.Add(item); PrefabManager.Instance.AddPrefab(val); PrefabManager.Instance.AddPrefab(val2); PrefabManager.Instance.AddPrefab(val3); } private EffectData[] NewStickyEffect() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown EffectData[] array = (EffectData[])(object)new EffectData[1] { new EffectData() }; EffectData val = array[0]; val.m_attach = true; val.m_inheritParentRotation = true; val.m_inheritParentScale = true; val.m_scale = true; return array; } } public static class Utils2 { private const BindingFlags bindingFlags = BindingFlags.Public; public static T GetCopyOf<T>(this Component comp, T other) where T : Component { Type type = ((object)comp).GetType(); if (type != ((object)other).GetType()) { return default(T); } List<Type> list = new List<Type>(); Type baseType = type.BaseType; while (baseType != null && !(baseType == typeof(MonoBehaviour))) { list.Add(baseType);