Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of PortablePals v0.3.1
PortablePals.dll
Decompiled 3 days 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 CreatureGenetics; 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.common; using StarLevelSystem.modules; using StarLevelSystem.modules.Sizes; 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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [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: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyCompany("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace CompatPatches { internal class CreatureGenetics_API { public static string GetDNA(Character character) { Genetics component = ((Component)character).GetComponent<Genetics>(); if ((Object)(object)component == (Object)null) { return ""; } DBG.blogDebug("Setting CG DNA"); string text = Convert.ToBase64String(component.DNA_Strand); DBG.blogDebug("CG DNA=" + text); return text; } public static void addDNA(GameObject newGo) { Genetics val = default(Genetics); if (!newGo.TryGetComponent<Genetics>(ref val)) { val = newGo.AddComponent<Genetics>(); } val.delay_Size = true; } public static void setFinalSize(Character creature) { Genetics val = default(Genetics); if (((Component)creature).TryGetComponent<Genetics>(ref val)) { val.finalSizeDelay(); } } public static void setDNA(Character chr, string DNA_String) { CatchPal.ReleaseData releaseData = default(CatchPal.ReleaseData); if (!((Component)chr).TryGetComponent<CatchPal.ReleaseData>(ref releaseData)) { DBG.blogDebug("CG No Release Data"); return; } releaseData.SaveBytes.Add("CG_DNA", Convert.FromBase64String(DNA_String)); DBG.blogDebug("PP dna strand=" + string.Join(",", Convert.FromBase64String(DNA_String))); } } internal class SaveZDO_API { public enum zdoType { String, Int, Float, Bool, Long } public static bool hasInitModCompatsZDO = false; public static List<string> ModCompatZDOs = new List<string>(); public static Dictionary<string, zdoType> CategorizedZDOs = new Dictionary<string, zdoType>(); public static bool CategorizeZDO(ZDO zdo, string zdoValue, Dictionary<string, string> custData) { string newValue = default(string); if (zdo.GetString(zdoValue, ref newValue)) { CategorizedZDOs.Add(zdoValue, zdoType.String); Utils2.addOrUpdateCustomData(custData, zdoValue + ":str", newValue); return true; } float num = default(float); if (zdo.GetFloat(zdoValue, ref num)) { CategorizedZDOs.Add(zdoValue, zdoType.Float); Utils2.addOrUpdateCustomData(custData, zdoValue + ":flt", num.ToString()); return true; } int num2 = default(int); if (zdo.GetInt(zdoValue, ref num2)) { CategorizedZDOs.Add(zdoValue, zdoType.Int); Utils2.addOrUpdateCustomData(custData, zdoValue + ":int", num2.ToString()); return true; } bool flag = default(bool); if (zdo.GetBool(zdoValue, ref flag)) { CategorizedZDOs.Add(zdoValue, zdoType.Bool); Utils2.addOrUpdateCustomData(custData, zdoValue + ":bool", flag ? "t" : "f"); return true; } long num3 = zdo.GetLong(zdoValue, 0L); if (num3 != 0) { CategorizedZDOs.Add(zdoValue, zdoType.Long); Utils2.addOrUpdateCustomData(custData, zdoValue + ":long", num3.ToString()); } return false; } public static void AddZDOsToCustomData(Character character, Dictionary<string, string> custData) { ZDO zDO = character.m_nview.GetZDO(); if (!hasInitModCompatsZDO && (Plugin.ModCompatZDOs.Value ?? "") != "") { ModCompatZDOs.AddRange(Plugin.ModCompatZDOs.Value.Split(new char[1] { ',' }).ToList()); } hasInitModCompatsZDO = true; if (ModCompatZDOs.Count == 0 && CategorizedZDOs.Count == 0) { DBG.blogDebug("No custom zdos, skipping"); return; } List<string> list = new List<string>(); for (int num = ModCompatZDOs.Count - 1; num >= 0; num--) { string text = ModCompatZDOs[num]; if (CategorizedZDOs.TryGetValue(text, out var _)) { ModCompatZDOs.RemoveAt(num); } else if (CategorizeZDO(zDO, text, custData)) { ModCompatZDOs.RemoveAt(num); list.Add(text); } } string newValue = default(string); int num4 = default(int); float num3 = default(float); bool flag = default(bool); foreach (KeyValuePair<string, zdoType> categorizedZDO in CategorizedZDOs) { if (list.Contains(categorizedZDO.Key)) { continue; } switch (categorizedZDO.Value) { case zdoType.String: if (zDO.GetString(categorizedZDO.Key, ref newValue)) { Utils2.addOrUpdateCustomData(custData, categorizedZDO.Key + ":str", newValue); } break; case zdoType.Int: if (zDO.GetInt(categorizedZDO.Key, ref num4)) { Utils2.addOrUpdateCustomData(custData, categorizedZDO.Key + ":int", num4.ToString()); } break; case zdoType.Float: if (zDO.GetFloat(categorizedZDO.Key, ref num3)) { Utils2.addOrUpdateCustomData(custData, categorizedZDO.Key + ":flt", num3.ToString()); } break; case zdoType.Long: { long num2 = zDO.GetLong(categorizedZDO.Key, 0L); if (num2 != 0) { Utils2.addOrUpdateCustomData(custData, categorizedZDO.Key + ":long", num2.ToString()); } break; } case zdoType.Bool: if (zDO.GetBool(categorizedZDO.Key, ref flag)) { Utils2.addOrUpdateCustomData(custData, categorizedZDO.Key + ":bool", flag ? "t" : "f"); } break; } } } public static void AddCustomDataToReleaseData(CatchPal.ReleaseData releaseData, Dictionary<string, string> custData) { List<string> list = new List<string>(); foreach (KeyValuePair<string, string> custDatum in custData) { DBG.blogDebug("CustomData " + custDatum.Key + " with value " + custDatum.Value + " "); if (!custDatum.Key.Contains(":")) { continue; } DBG.blogDebug("Has :"); string[] array = custDatum.Key.Split(new char[1] { ':' }); DBG.blogDebug("splitStr[0]:" + array[0]); DBG.blogDebug("splitStr[1]:" + array[1]); switch (array[1]) { case "str": DBG.blogDebug("Case:" + array[1]); Utils2.addOrUpdateCustomData(releaseData.SaveStr, array[0], custDatum.Value); DBG.blogDebug("Set string " + array[0] + " to value" + custDatum.Value + " "); break; case "int": { DBG.blogDebug("Case:" + array[1]); if (int.TryParse(custDatum.Value, out var result2)) { Utils2.addOrUpdateCustomData(releaseData.SaveInts, array[0], result2); DBG.blogDebug("Set int " + array[0] + " to value" + custDatum.Value + " "); } else { DBG.blogWarning("failed to parse int: " + custDatum.Value); } break; } case "flt": { DBG.blogDebug("Case:" + array[1]); if (float.TryParse(custDatum.Value, out var result3)) { Utils2.addOrUpdateCustomData(releaseData.SaveFloats, array[0], result3); DBG.blogDebug("Set float " + array[0] + " to value" + custDatum.Value + " "); } else { DBG.blogWarning("failed to parse float: " + custDatum.Value); } break; } case "long": { DBG.blogDebug("Case:" + array[1]); if (long.TryParse(custDatum.Value, out var result)) { Utils2.addOrUpdateCustomData(releaseData.SaveLongs, array[0], result); DBG.blogDebug("Set long " + array[0] + " to value" + custDatum.Value + " "); } else { DBG.blogWarning("failed to parse long: " + custDatum.Value); } break; } case "bool": DBG.blogDebug("Case:" + array[1]); Utils2.addOrUpdateCustomData(releaseData.SaveBools, array[0], custDatum.Value == "t"); DBG.blogDebug(string.Format("Set bool {0} to value{1} ", array[0], custDatum.Value == "t")); break; default: DBG.blogDebug("Default Case:" + array[1]); Utils2.addOrUpdateCustomData(releaseData.SaveStr, array[0], custDatum.Value); DBG.blogDebug("Set string " + array[0] + " to value" + custDatum.Value + " "); break; } list.Add(custDatum.Key); } foreach (string item in list) { custData.Remove(item); } } } internal class SLS { public static void SetSLSSize(TimedScaleAndFreeze tsf, Character character) { } public static void SetSLSColorFromZDO(Character character) { ZDO zDO = ((Component)character).GetComponent<ZNetView>().GetZDO(); string color_data = zDO.GetString("PP_SLS_HSVE", ""); SetSLSColor(character, color_data); } 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 < 1) { 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; DBG.blogDebug("character.transform.localScale=" + ((object)((Component)character).transform.localScale/*cast due to .constrained prefix*/).ToString()); } releaseData.SaveFloats.Add("SLS_SIZE", result * 0.1f); releaseData.sls_Size = result; } if (custData.TryGetValue("PP_SLS_MODS", out var value2)) { releaseData.SaveStr.Add("SLS_MODV2", value2); DBG.blogDebug("Set SLS_MODS=" + value2); } if (custData.TryGetValue("PP_SLS_HSVE", out var value3)) { DBG.blogDebug("Set PP_SLS_HSVE:" + value3); releaseData.SaveStr.Add("PP_SLS_HSVE", value3); } } public static void SaveSLSValues(Dictionary<string, string> custData, Character character) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = character.m_nview.GetZDO(); string text = ""; text += zDO.GetVec3(DataObjects.SLS_SIZE, Vector3.zero).x; Utils2.addOrUpdateCustomData(custData, "PP_SLS_General", text); string text2 = zDO.GetString("SLS_MODV2", ""); if (text2 != null) { DBG.blogDebug("SLS_MODS not null"); Utils2.addOrUpdateCustomData(custData, "PP_SLS_MODS", text2); } 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); } [HarmonyPrefix] [HarmonyPatch(typeof(SizeModifications), "SetSizeModification")] private static bool Prefix_ApplySizeNew(GameObject obj, ZNetView zview, CharacterCacheEntry characterCache, bool update = false, float bonus = 0f) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Vector3 vec = zview.m_zdo.GetVec3(DataObjects.SLS_SIZE, Vector3.zero); DBG.blogDebug("SLS PreSize=" + obj.transform.localScale.x + ", zdo=" + vec.x); return true; } [HarmonyPatch(typeof(SizeModifications), "SetSizeModification")] [HarmonyPostfix] private static void Postfix_ApplySizeNew(GameObject obj, ZNetView zview, CharacterCacheEntry characterCache, bool update = false, float bonus = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) float x = obj.transform.localScale.x; Vector3 vec = zview.m_zdo.GetVec3(DataObjects.SLS_SIZE, Vector3.zero); DBG.blogDebug("SLS PostSize=" + obj.transform.localScale.x + ", zdo=" + vec.x); TimedScaleAndFreeze timedScaleAndFreeze = default(TimedScaleAndFreeze); if (obj.TryGetComponent<TimedScaleAndFreeze>(ref timedScaleAndFreeze)) { obj.transform.localScale = timedScaleAndFreeze.getPreviousScale(); DBG.blogDebug("SLS post set size back to=" + ((object)obj.transform.localScale/*cast due to .constrained prefix*/).ToString()); timedScaleAndFreeze.sls_Size = x; } } } 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 BetterRiding { public static bool CanCapture(Character character, Player player) { if (Plugin.hasYBR) { DBG.blogDebug("has YBR"); ZNetView nview = character.m_nview; if ((Object)(object)nview == (Object)null || !nview.IsValid()) { return false; } ZDO zDO = nview.GetZDO(); long num = zDO.GetLong("playerID", 0L); DBG.blogDebug("bonded player=" + num); DBG.blogDebug("playerID=" + player.GetPlayerID()); if (num != 0L && num != player.GetPlayerID()) { MessageHud.instance.ShowMessage((MessageType)2, "Cannot capture another players bonded creature.", 0, (Sprite)null, false, true); return false; } } return true; } } 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(false, false); } } } } [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) return ((object)API.GetInfusionCreature(character)/*cast due to .constrained prefix*/).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) return ((object)API.GetExtraEffectCreature(character)/*cast due to .constrained prefix*/).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 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>(); public Dictionary<string, int> SaveInts = new Dictionary<string, int>(); public Dictionary<string, bool> SaveBools = new Dictionary<string, bool>(); public Dictionary<string, long> SaveLongs = new Dictionary<string, long>(); 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 Byte: " + saveByte.Key + ":" + saveByte.Value); } foreach (KeyValuePair<string, float> saveFloat in SaveFloats) { zDO.Set(saveFloat.Key, saveFloat.Value); DBG.blogDebug("Release Set Float: " + saveFloat.Key + ":" + saveFloat.Value); } foreach (KeyValuePair<string, int> saveInt in SaveInts) { zDO.Set(saveInt.Key, saveInt.Value); DBG.blogDebug("Release Set Int: " + saveInt.Key + ":" + saveInt.Value); } foreach (KeyValuePair<string, long> saveLong in SaveLongs) { zDO.Set(saveLong.Key, saveLong.Value); DBG.blogDebug("Release Set Long: " + saveLong.Key + ":" + saveLong.Value); } foreach (KeyValuePair<string, bool> saveBool in SaveBools) { zDO.Set(saveBool.Key, saveBool.Value); DBG.blogDebug("Release Set Bool: " + saveBool.Key + ":" + saveBool.Value); } zDO.Set("SLS_MULT", 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")] [HarmonyPrefix] [HarmonyPriority(600)] private static void CheckData(Character __instance) { ReleaseData releaseData = default(ReleaseData); if (((Component)__instance).TryGetComponent<ReleaseData>(ref releaseData)) { DBG.blogDebug("Pre Character awake"); releaseData.SaveToZDO(); } } [HarmonyPatch(typeof(ZNetView), "Awake")] [HarmonyPostfix] private static void CheckDataPost(Character __instance) { ReleaseData releaseData = default(ReleaseData); if (((Component)__instance).TryGetComponent<ReleaseData>(ref releaseData)) { DBG.blogDebug("Post ZNV awake"); releaseData.SaveToZDO(); } } public static int attemptCatch(Player plr, ItemData item) { //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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); MessageHud.instance.ShowMessage((MessageType)2, "Item in cooldown, try again in " + (int)(Plugin.cooldown.Value - num + 1f) + "s", 0, (Sprite)null, false, true); 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) if (!hovCreature.m_nview.IsValid() || !hovCreature.IsTamed()) { return false; } if (!API.CanCapture(hovCreature, plr)) { return false; } item.m_shared.m_movementModifier = -0.9f; ZDO zDO = hovCreature.m_nview.GetZDO(); long num = zDO.GetLong(catcherHash, 0L); DBG.blogDebug("Catcher uid=" + num); 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 (num != 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_0301: 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)); } else if (Plugin.hasCG) { Utils2.addOrUpdateCustomData(customData, "PP_CG", CreatureGenetics_API.GetDNA(hovCreature)); } if (Plugin.hasMonMod) { Utils2.addOrUpdateCustomData(customData, "PP_MonMod", MonsterMod.getModifiers(hovCreature)); } if (Plugin.hasSLS) { SLS.SaveSLSValues(customData, hovCreature); } API.SaveDataToPalStone(hovCreature, customData); 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 (Plugin.hasCG) { CreatureGenetics_API.addDNA(gameObject); } 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) { API.ReleaseCreature_PreAwake(creature, palstone.m_customData); if (Plugin.hasSLS) { SLS.SetSLSData(palstone.m_customData, creature); } if (Plugin.hasCG && palstone.m_customData.TryGetValue("PP_CG", out var value)) { CreatureGenetics_API.setDNA(creature, value); } } public static void ReleaseCreature_PostAwake(Character creature, ItemData palstone) { API.ReleaseCreature_PostAwake(creature, palstone.m_customData); } public static void ReleaseCreature_PostRelease(Character creature, TimedScaleAndFreeze tsf) { if (Plugin.hasCG) { CreatureGenetics_API.setFinalSize(creature); } } private unsafe 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_038f: 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_046f: Unknown result type (might be due to invalid IL or missing references) //IL_077a: Unknown result type (might be due to invalid IL or missing references) //IL_077f: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_08ad: Unknown result type (might be due to invalid IL or missing references) //IL_08b2: Unknown result type (might be due to invalid IL or missing references) //IL_08e4: Unknown result type (might be due to invalid IL or missing references) //IL_098b: Unknown result type (might be due to invalid IL or missing references) //IL_0990: Unknown result type (might be due to invalid IL or missing references) //IL_0c19: Unknown result type (might be due to invalid IL or missing references) //IL_0c1e: Unknown result type (might be due to invalid IL or missing references) //IL_0cf8: Unknown result type (might be due to invalid IL or missing references) //IL_0cfd: Unknown result type (might be due to invalid IL or missing references) //IL_0d1c: Unknown result type (might be due to invalid IL or missing references) //IL_0d21: Unknown result type (might be due to invalid IL or missing references) //IL_0d5f: Unknown result type (might be due to invalid IL or missing references) //IL_0d64: Unknown result type (might be due to invalid IL or missing references) //IL_0da3: Unknown result type (might be due to invalid IL or missing references) //IL_0da8: Unknown result type (might be due to invalid IL or missing references) //IL_0dc8: Unknown result type (might be due to invalid IL or missing references) //IL_0dca: Unknown result type (might be due to invalid IL or missing references) //IL_0e17: Unknown result type (might be due to invalid IL or missing references) //IL_0e1c: Unknown result type (might be due to invalid IL or missing references) //IL_0e60: Unknown result type (might be due to invalid IL or missing references) //IL_0ea1: Unknown result type (might be due to invalid IL or missing references) //IL_0ea6: Unknown result type (might be due to invalid IL or missing references) //IL_0eb3: Unknown result type (might be due to invalid IL or missing references) //IL_0eb8: Unknown result type (might be due to invalid IL or missing references) //IL_0ef3: Unknown result type (might be due to invalid IL or missing references) //IL_0ef8: 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*)(&val2))/*cast due to .constrained prefix*/).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); int num = 0; DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); 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; } SaveZDO_API.AddCustomDataToReleaseData(releaseData, customData); DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); ReleaseCreature_PreAwake(component, item); DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); val4.transform.SetParent((Transform)null); Object.Destroy((Object)(object)val3); DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); ZNetView component2 = val4.GetComponent<ZNetView>(); ZNetView component3 = ((Component)component).GetComponent<ZNetView>(); if ((Object)(object)component2 == (Object)null || !component2.IsValid()) { return null; } if (!component2.IsOwner()) { component2.ClaimOwnership(); } if (!component2.IsOwner()) { return null; } 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()); DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); DBG.blogDebug("Scale=" + ((object)val4.transform.localScale/*cast due to .constrained prefix*/).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); } } DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); 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"); } DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); 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); } DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); 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, (short)(-1)); } else if (name.Contains("Armour")) { DBG.blogDebug("Armour PalStone"); component.GetSEMan().AddStatusEffect((StatusEffect)(object)Plugin.prefabManager.SE_ArmorBuff, false, 0, 0f, (short)(-1)); } else if (name.Contains("Heal")) { DBG.blogDebug("Heal PalStone"); flag2 = true; component.GetSEMan().AddStatusEffect((StatusEffect)(object)Plugin.prefabManager.SE_HealBuff, false, 0, 0f, (short)(-1)); } if (flag || !component.IsTamed()) { DBG.blogDebug("Error Occured, Destryoing Creature"); Object.Destroy((Object)(object)val4); } val4.SetActive(true); DBG.blogDebug("localScale pre DNA Set=" + ((object)val4.transform.localScale/*cast due to .constrained prefix*/).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); } } } DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); 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 num2 = (float)(ZNet.instance.m_netTime - (double)result6); DBG.blogDebug("seconds=" + num2); if (num2 > 0f) { float val7 = Plugin.percentHealPerMin.Value * num2 / 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 num3 = Math.Max(ZNet.instance.GetTime().Ticks - Convert.ToInt64(result7 * 10000000f), 0L); DBG.blogDebug("lastFed =" + result7 + ", ticks=" + num3); component.m_nview.GetZDO().Set(ZDOVars.s_tameLastFeeding, num3); } } DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); 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 num4 = Math.Max(ZNet.instance.GetTime().Ticks - Convert.ToInt64(result8 * 10000000f), 0L); DBG.blogDebug("grow =" + result8 + ", ticks=" + num4); component.m_nview.GetZDO().Set(ZDOVars.s_spawnTime, num4); } } localScale = val4.transform.localScale; DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); ReleaseCreatureEffect(component); DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); ReleaseCreature_PostAwake(component, item); DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); val4.GetComponent<TimedScaleAndFreeze>().ogScale = localScale; if (((object)component).GetType().Name.Contains("Companion")) { val4.GetComponent<TimedScaleAndFreeze>().clearInv = true; } DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); float num5 = Math.Min(val4.GetComponent<Rigidbody>().mass, 110f) - 10f; val4.GetComponent<Rigidbody>().AddForce(((Component)plr).transform.rotation * new Vector3(throwforce.x, throwforce.y - 100f * num5 / 110f, throwforce.z + 220f * num5 / 110f) * (num5 + 10f), forceMode); Utils2.addOrUpdateCustomData(item.m_customData, "PP_LastCatch", valueSafe); DBG.blogDebug($"Scale({num++})=" + val4.transform.localScale.x); 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"; [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] private static void AddItems(ObjectDB __instance) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.localizeLoaded) { Localizer.Load(); Plugin.localizeLoaded = true; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "main" && ZNet.instance.IsServer()) { DBG.blogDebug("Updating Pal Stones as Server"); PrefabManager.UpdateItems(); } } [HarmonyPatch(typeof(Attack), "Start")] [HarmonyPrefix] 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), typeof(bool) })] 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 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); } } } [BepInPlugin("meldurson.valheim.PortablePals", "PortablePals", "0.3.1")] [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.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*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 ConfigEntry<string> ModCompatZDOs; 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 CreatureGeneticsGUID = "meldurson.CreatureGenetics"; public const string MonModGUID = "warpalicious.MonsterModifiers"; public const string SLSGUID = "MidnightsFX.StarLevelSystem"; public const string BetterRidingGUID = "Yggdrah.BetterRiding"; public static bool hasCLLC = false; public static bool hasAT = false; public static bool hasCG = false; public static bool hasMonMod = false; public static bool hasSLS = false; public static bool hasYBR = false; public static bool localizeLoaded = 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_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Expected O, but got Unknown //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Expected O, but got Unknown //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: 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 } })); ModCompatZDOs = ((BaseUnityPlugin)this).Config.Bind<string>("6: Mod Compatibility", "Mod ZDOs", "", new ConfigDescription("Can add zdos that are used by mods and save them to the palstone, separate zdos with , (comma). Some mods may require more complex compatibility.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); 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; } else if (Chainloader.PluginInfos.ContainsKey("meldurson.CreatureGenetics")) { DBG.blogDebug("Has Creature Genetics"); hasCG = 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; } if (Chainloader.PluginInfos.ContainsKey("Raelaziel.OdinHorse")) { Utils2.addOrUpdateCustomData(SaveZDO_API.CategorizedZDOs, "HorseMaterial", SaveZDO_API.zdoType.Int); } if (Chainloader.PluginInfos.ContainsKey("Yggdrah.BetterRiding")) { hasYBR = true; Utils2.addOrUpdateCustomData(SaveZDO_API.CategorizedZDOs, "playerID", SaveZDO_API.zdoType.Long); Utils2.addOrUpdateCustomData(SaveZDO_API.CategorizedZDOs, "ownerName", SaveZDO_API.zdoType.String); } 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 (hasSLS) { val.PatchAll(typeof(SLS)); DBG.blogDebug("Patched SLSPatches"); } 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 Vector3 previousScale; public Vector3 exteriorScale = Vector3.one; public Rigidbody rb; private RigidbodyConstraints constraints = (RigidbodyConstraints)0; public ZNetView m_nview; private unsafe 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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*)(&val))/*cast due to .constrained prefix*/).ToString()); CatchPal.ReleaseData releaseData = default(CatchPal.ReleaseData); if (Plugin.hasSLS && sls_Size == 1f && ((Component)this).gameObject.TryGetComponent<CatchPal.ReleaseData>(ref releaseData)) { sls_Size = releaseData.sls_Size / ogScale.x; } ogScale *= sls_Size; val = ogScale; DBG.blogDebug("post SLS =" + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString()); ((Component)this).transform.localScale = ogScale * startScale; previousScale = ((Component)this).transform.localScale; endTime = startimeScale + duration; } private unsafe void Update() { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_01cf: 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_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033c: 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_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (time > endTime) { if (setFinalScale) { ((Component)this).transform.localScale = Vector3.Scale(exteriorScale, ogScale); DBG.blogDebug("finalScale=" + ((object)((Component)this).transform.localScale/*cast due to .constrained prefix*/).ToString()); endScale = ((Component)this).transform.localScale.x; CatchPal.ReleaseCreature_PostRelease(((Component)this).gameObject.GetComponent<Character>(), this); } removeSelf(); return; } if (time - lastTimeScale > roughness) { Vector3 val = default(Vector3); ((Vector3)(ref val))..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 val)).magnitude < 5f) { exteriorScale = Vector3.Scale(exteriorScale, val); } else { Vector3 val2 = val; DBG.blogDebug("scaler Scale too high =" + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString() + ", scale=" + ((object)((Component)this).transform.localScale/*cast due to .constrained prefix*/).ToString()); } if (((Component)this).transform.localScale.x / previousScale.x != 1f) { Vector3 val2 = exteriorScale; DBG.blogDebug("exterior Scale =" + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString() + ", scale=" + ((object)((Component)this).transform.localScale/*cast due to .constrained prefix*/).ToString()); } ((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.op_Implicit((Object)(object)component) && !((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(false, false); } } 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 Vector3 getPreviousScale() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return previousScale; } public unsafe 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*)(&val))/*cast due to .constrained prefix*/).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_01bc: 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(false, false); } 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