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.modules;
using UnityEngine;
using UnityEngine.SceneManagement;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.ObjectPool;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Callbacks;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;
[assembly: 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 SLS
{
public static void SetSLSSize(TimedScaleAndFreeze tsf, Character character)
{
float x = tsf.exteriorScale.x;
DBG.blogDebug("Manual SLS Size:" + x);
if (x <= 0f)
{
DBG.blogDebug("Size too small:");
return;
}
ZDO zDO = ((Component)character).GetComponent<ZNetView>().GetZDO();
DBG.blogDebug("Current SLS Size:" + zDO.GetFloat("SLS_SIZE", 0f));
zDO.Set("SLS_SIZE", x);
DBG.blogDebug("NEW SLS Size:" + x);
}
public static void SetSLSColorFromZDO(Character character)
{
ZDO zDO = ((Component)character).GetComponent<ZNetView>().GetZDO();
string @string = zDO.GetString("PP_SLS_HSVE", "");
SetSLSColor(character, @string);
}
public static void SetSLSData(Dictionary<string, string> custData, Character character)
{
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
CatchPal.ReleaseData releaseData = default(CatchPal.ReleaseData);
if (!((Component)character).TryGetComponent<CatchPal.ReleaseData>(ref releaseData))
{
DBG.blogDebug("No Release Data");
return;
}
if (!custData.TryGetValue("PP_SLS_General", out var value))
{
DBG.blogDebug("Did not get SLS Data");
return;
}
string[] array = value.Split(new char[1] { ',' });
if (array.Length < 2)
{
DBG.blogDebug("Failed to get full SLS Data");
return;
}
if (float.TryParse(array[0], out var result))
{
TimedScaleAndFreeze timedScaleAndFreeze = default(TimedScaleAndFreeze);
if (((Component)character).TryGetComponent<TimedScaleAndFreeze>(ref timedScaleAndFreeze))
{
timedScaleAndFreeze.sls_Size = result;
Vector3 localScale = ((Component)character).transform.localScale;
DBG.blogDebug("character.transform.localScale=" + ((object)(Vector3)(ref localScale)).ToString());
}
releaseData.SaveFloats.Add("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)
{
ZDO zDO = character.m_nview.GetZDO();
string text = "";
text = text + zDO.GetFloat("SLS_SIZE", 0f) + ",";
text += zDO.GetString("SLS_CHARNAME", "");
Utils2.addOrUpdateCustomData(custData, "PP_SLS_General", text);
string @string = zDO.GetString("SLS_MODV2", "");
if (@string != null)
{
DBG.blogDebug("SLS_MODS not null");
Utils2.addOrUpdateCustomData(custData, "PP_SLS_MODS", @string);
}
else
{
DBG.blogDebug("SLS_MODS null");
custData.Remove("PP_SLS_MODS");
}
Utils2.addOrUpdateCustomData(custData, "PP_SLS_HSVE", GetSLSColor(character));
}
public static string GetSLSColor(Character character)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
SkinnedMeshRenderer componentInChildren = ((Component)character).GetComponentInChildren<SkinnedMeshRenderer>();
if (!Object.op_Implicit((Object)(object)componentInChildren))
{
return "";
}
Material[] sharedMaterials = ((Renderer)componentInChildren).sharedMaterials;
if (sharedMaterials.Length == 0)
{
return "";
}
string text = sharedMaterials[0].GetFloat("_Hue") + ",";
text = text + sharedMaterials[0].GetFloat("_Saturation") + ",";
text = text + sharedMaterials[0].GetFloat("_Value") + ",";
Color color = sharedMaterials[0].GetColor("_EmissionColor");
text += ((((Color)(ref color)).maxColorComponent > 0f) ? color.a : 0f);
DBG.blogDebug("hsve:" + text);
return text;
}
public static void SetSLSColor(Character character, string color_data)
{
string[] array = color_data.Split(new char[1] { ',' });
if (array.Length < 4)
{
DBG.blogDebug("Failed to get color SLS Data");
return;
}
float.TryParse(array[0], out var result);
float.TryParse(array[1], out var result2);
float.TryParse(array[2], out var result3);
float.TryParse(array[3], out var result4);
APIReciever.UpdateCreatureColorization(character, result3, result, result2, result4 > 0f);
}
}
internal class MonsterMod
{
public static void SetModifiers(Character character, string MonMod)
{
MonsterModifier val = default(MonsterModifier);
if (((Component)character).TryGetComponent<MonsterModifier>(ref val))
{
if (Object.op_Implicit((Object)(object)val.character))
{
DBG.blogDebug("MonMod has started");
}
character.m_nview.GetZDO().Set("modifiers", MonMod);
DBG.blogDebug("MonMod has been set");
DBG.blogDebug("MonMod is:" + character.m_nview.GetZDO().GetString("modifiers", string.Empty));
}
}
public static string getModifiers(Character character)
{
MonsterModifier val = default(MonsterModifier);
string text;
if (((Component)character).TryGetComponent<MonsterModifier>(ref val))
{
text = string.Join(",", val.Modifiers);
DBG.blogDebug("got modifiers from component: " + text);
}
else
{
text = character.m_nview.GetZDO().GetString("modifiers", string.Empty) ?? "";
DBG.blogDebug("got modifiers from zdo: " + text);
}
return text;
}
}
internal class VikingNPC
{
[HarmonyPatch(typeof(Humanoid), "GiveDefaultItems")]
[HarmonyPostfix]
private static void GiveDefaultItems(Humanoid __instance)
{
TimedScaleAndFreeze timedScaleAndFreeze = default(TimedScaleAndFreeze);
if (((Component)__instance).TryGetComponent<TimedScaleAndFreeze>(ref timedScaleAndFreeze) && timedScaleAndFreeze.clearInv)
{
Inventory inventory = __instance.GetInventory();
if (inventory.m_inventory.Count() > 0)
{
timedScaleAndFreeze.clearInv = false;
inventory.RemoveAll();
inventory.Changed();
}
}
}
}
[HarmonyPatch(typeof(CreatureLevelControl), "PatchSize")]
internal class CLLC_Patches
{
private static bool Prefix(CreatureLevelControl __instance, EnemyLevelData originalData, out Vector3 __state)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)originalData).gameObject;
__state = gameObject.transform.localScale;
TimedScaleAndFreeze timedScaleAndFreeze = default(TimedScaleAndFreeze);
if ((((Object)(object)gameObject != (Object)null) & gameObject.TryGetComponent<TimedScaleAndFreeze>(ref timedScaleAndFreeze)) && timedScaleAndFreeze.CLLC_Scale != 1f)
{
DBG.blogDebug("Already Scaled by CLLC");
__state = Vector3.zero;
return false;
}
return true;
}
private static void Postfix(CreatureLevelControl __instance, EnemyLevelData originalData, Vector3 __state)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
if (!(__state == Vector3.zero))
{
GameObject gameObject = ((Component)originalData).gameObject;
TimedScaleAndFreeze tsf = default(TimedScaleAndFreeze);
if ((Object)(object)gameObject != (Object)null && gameObject.TryGetComponent<TimedScaleAndFreeze>(ref tsf))
{
float scale = gameObject.transform.localScale.x / __state.x;
DBG.blogDebug("In CLLC Patch with scale=" + scale);
CatchPal.checkScales(gameObject, isCLLC: true, tsf, scale);
}
}
}
}
internal class AllTame_API
{
[HarmonyPatch(typeof(DNA), "setTraits")]
public class AT_DNA_Patches
{
private static void Prefix(DNA __instance, out Vector3 __state)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
__state = ((Component)__instance).gameObject.transform.localScale;
}
private static void Postfix(DNA __instance, Vector3 __state)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)__instance).gameObject;
TimedScaleAndFreeze tsf = default(TimedScaleAndFreeze);
if ((Object)(object)gameObject != (Object)null && gameObject.TryGetComponent<TimedScaleAndFreeze>(ref tsf))
{
float scale = gameObject.transform.localScale.x / __state.x;
DBG.blogDebug((object)("In setTraits Patch with scale=" + scale));
CatchPal.checkScales(gameObject, isCLLC: false, tsf, scale);
}
}
}
public static string GetDNA(Character character)
{
DNA component = ((Component)character).GetComponent<DNA>();
if ((Object)(object)component == (Object)null)
{
return "";
}
return component.DNA_hash.ToString();
}
public static void setDNAHash(GameObject go, ZNetView znv)
{
DNA component = go.GetComponent<DNA>();
if (Object.op_Implicit((Object)(object)component))
{
component.DNA_hash = znv.GetZDO().GetLong("AT_DNA", 0L);
component.ParseMSG();
}
}
public static void setDNA(GameObject go, long dna_hash1, long dna_hash2)
{
DNA val = default(DNA);
if (go.TryGetComponent<DNA>(ref val))
{
val.DNA_hash = dna_hash1;
val.ParseMSG();
val.restoreColor();
val.setAttributes();
val.SetZDO();
DBG.blogDebug((object)("PP hash=" + dna_hash1 + ":" + dna_hash2));
}
else
{
DBG.blogDebug((object)"No DNA");
}
}
}
internal class CLLC
{
public static void SetInfusionCreature(Character character, string infusion)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (!Enum.TryParse<CreatureInfusion>(infusion, out CreatureInfusion result))
{
DBG.blogDebug("Failed to parse infusion from string " + infusion);
}
else
{
API.SetInfusionCreature(character, result);
}
}
public static void SetExtraEffectCreature(Character character, string effect)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (!Enum.TryParse<CreatureExtraEffect>(effect, out CreatureExtraEffect result))
{
DBG.blogDebug("Failed to parse extra effect from string " + effect);
}
else
{
API.SetExtraEffectCreature(character, result);
}
}
public static string CLLC_getInfusion(Character character)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
CreatureInfusion infusionCreature = API.GetInfusionCreature(character);
return ((object)(CreatureInfusion)(ref infusionCreature)).ToString();
}
public static string CLLC_getEffect(Character character)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
CreatureExtraEffect extraEffectCreature = API.GetExtraEffectCreature(character);
return ((object)(CreatureExtraEffect)(ref extraEffectCreature)).ToString();
}
}
}
namespace PortablePals
{
internal class CatchPal
{
public class ReleaseData : MonoBehaviour
{
public float sls_Size = 1f;
public int lvl = 1;
public float color = 0f;
public float duration = 3f;
private bool SavedData = false;
public Dictionary<string, string> SaveStr = new Dictionary<string, string>();
public Dictionary<string, byte[]> SaveBytes = new Dictionary<string, byte[]>();
public Dictionary<string, float> SaveFloats = new Dictionary<string, float>();
private void Awake()
{
}
private void Start()
{
((MonoBehaviour)this).Invoke("DestroySelf", duration);
SaveToZDO();
}
public void SaveToZDO()
{
if (SavedData)
{
return;
}
SavedData = true;
ZNetView component = ((Component)this).GetComponent<ZNetView>();
if ((Object)(object)component == (Object)null)
{
return;
}
ZDO zDO = component.GetZDO();
zDO.Set(ZDOVars.s_level, lvl, false);
DBG.blogDebug("Release Set lvl:" + lvl);
foreach (KeyValuePair<string, string> item in SaveStr)
{
zDO.Set(item.Key, item.Value);
DBG.blogDebug("Release Set Str: " + item.Key + ":" + item.Value);
}
foreach (KeyValuePair<string, byte[]> saveByte in SaveBytes)
{
zDO.Set(saveByte.Key, saveByte.Value);
DBG.blogDebug("Release Set 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);
}
zDO.Set("SLS_MULT", true);
}
private void DestroySelf()
{
Object.Destroy((Object)(object)this);
}
}
[CompilerGenerated]
private sealed class <CatchUpdate>d__25 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Character creature;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CatchUpdate>d__25(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
CatchUpdate_Repeat(creature);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <regainControl>d__26 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Player plr;
public float time;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <regainControl>d__26(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(time);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
regainControl_Repeat(plr, repeat: true);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
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);
}
}
[HarmonyPriority(600)]
[HarmonyPrefix]
[HarmonyPatch(typeof(Character), "Awake")]
private static void CheckData(Character __instance)
{
ReleaseData releaseData = default(ReleaseData);
if (((Component)__instance).TryGetComponent<ReleaseData>(ref releaseData))
{
releaseData.SaveToZDO();
}
}
public static int attemptCatch(Player plr, ItemData item)
{
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
if (((Character)plr).InAttack())
{
DBG.blogDebug("In Attack");
return 0;
}
if (item.m_customData.TryGetValue("PP_Prefab", out var value) && (value ?? "") != "")
{
ReleaseCreature(plr, item);
if (item.m_shared.m_useDurability)
{
float maxDurability = item.GetMaxDurability();
if (item.m_durability > maxDurability)
{
item.m_durability = maxDurability;
}
item.m_durability -= 1f;
}
return 1;
}
item.m_shared.m_movementModifier = -0.05f;
if (float.TryParse(GeneralExtensions.GetValueSafe<string, string>(item.m_customData, "PP_LastCatch"), out var result))
{
float num = Math.Abs(result - Time.time);
if (num < 0.3f)
{
DBG.blogDebug("Catch already in Progress");
return 0;
}
if (num < Plugin.cooldown.Value)
{
DBG.blogDebug("In Cooldown:" + result);
((Character)plr).Message((MessageType)2, "Item in cooldown, try again in " + (int)(Plugin.cooldown.Value - num + 1f) + "s", 0, (Sprite)null);
return 0;
}
}
Character val = null;
GameObject val2 = null;
plr.FindHoverObject(ref val2, ref val);
if ((Object)(object)val != (Object)null)
{
if (Vector3.Distance(((Character)plr).m_eye.position, ((Component)val).transform.position) < 15f)
{
DBG.blogDebug("hovering=" + val.m_name);
if (CatchCreature(plr, item, val))
{
return 2;
}
DBG.blogDebug("Failed to attempt catch=" + ((Object)val).name);
return 0;
}
DBG.blogDebug("to far away from=" + ((Object)val).name);
return 0;
}
DBG.blogDebug("no creature to catch");
return 0;
}
private static bool CatchCreature(Player plr, ItemData item, Character hovCreature)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
if (!hovCreature.m_nview.IsValid() || !hovCreature.IsTamed())
{
return false;
}
item.m_shared.m_movementModifier = -0.9f;
ZDO zDO = hovCreature.m_nview.GetZDO();
long @long = zDO.GetLong(catcherHash, 0L);
DBG.blogDebug("Catcher uid=" + @long);
ZDOID zDOID = zDO.GetZDOID("PP_Catcher");
if (((ZDOID)(ref zDOID)).UserID != 0)
{
DBG.blogDebug("Already has Catcher ZDOID");
if (Time.time - zDO.GetFloat("PP_CatcherTime", 0f) < 5f)
{
return false;
}
DBG.blogDebug("Time has passed, attempting Catch");
}
if (@long != 0)
{
DBG.blogDebug("Already has Catcher");
}
Utils2.addOrUpdateCustomData(item.m_customData, "PP_LastCatch", Time.time.ToString());
DBG.blogDebug("Set lastCatch to: " + Time.time);
zDO.Set("PP_Catcher", ((Character)plr).m_nview.GetZDO().m_uid);
zDO.Set("PP_CatcherTime", Time.time);
DBG.blogDebug("Set ZDOID");
ZDOID zDOID2 = zDO.GetZDOID("PP_Catcher");
ZDOID uid = zDO.m_uid;
DBG.blogDebug("found ZDOID");
GameObject val = ZNetScene.instance.FindInstance(zDOID2);
DBG.blogDebug("go name=" + ((Object)val).name);
hovCreature.m_nview.InvokeRPC(ZNetView.Everybody, "RPC_RequestCatch", new object[1] { uid });
((MonoBehaviour)hovCreature).StartCoroutine(CatchUpdate(hovCreature));
return true;
}
private static ItemData GetPalStone(Player plr, Character hovCreature)
{
if (!hovCreature.m_nview.IsValid() || !hovCreature.IsTamed())
{
return null;
}
ItemData rightItem = ((Humanoid)plr).m_rightItem;
if (rightItem == null || !((Object)rightItem.m_dropPrefab).name.Contains("PalStone"))
{
return null;
}
return rightItem;
}
public static bool SaveCreatureToItem(Character hovCreature, ItemData item)
{
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: 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);
}
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)
{
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)
{
}
public static void ReleaseCreature_PostRelease(Character creature, TimedScaleAndFreeze tsf)
{
if (Plugin.hasSLS)
{
SLS.SetSLSSize(tsf, creature);
}
if (Plugin.hasCG)
{
CreatureGenetics_API.setFinalSize(creature);
}
}
private static Character ReleaseCreature(Player plr, ItemData item)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0404: Unknown result type (might be due to invalid IL or missing references)
//IL_0497: Unknown result type (might be due to invalid IL or missing references)
//IL_049c: Unknown result type (might be due to invalid IL or missing references)
//IL_070f: Unknown result type (might be due to invalid IL or missing references)
//IL_0714: Unknown result type (might be due to invalid IL or missing references)
//IL_083c: Unknown result type (might be due to invalid IL or missing references)
//IL_0841: Unknown result type (might be due to invalid IL or missing references)
//IL_0873: Unknown result type (might be due to invalid IL or missing references)
//IL_091a: Unknown result type (might be due to invalid IL or missing references)
//IL_091f: Unknown result type (might be due to invalid IL or missing references)
//IL_0ba8: Unknown result type (might be due to invalid IL or missing references)
//IL_0bad: Unknown result type (might be due to invalid IL or missing references)
//IL_0c87: Unknown result type (might be due to invalid IL or missing references)
//IL_0c8c: Unknown result type (might be due to invalid IL or missing references)
//IL_0cab: Unknown result type (might be due to invalid IL or missing references)
//IL_0cb0: Unknown result type (might be due to invalid IL or missing references)
//IL_0cee: Unknown result type (might be due to invalid IL or missing references)
//IL_0cf3: Unknown result type (might be due to invalid IL or missing references)
//IL_0d32: Unknown result type (might be due to invalid IL or missing references)
//IL_0d37: Unknown result type (might be due to invalid IL or missing references)
//IL_0d57: Unknown result type (might be due to invalid IL or missing references)
//IL_0d59: Unknown result type (might be due to invalid IL or missing references)
//IL_0da6: Unknown result type (might be due to invalid IL or missing references)
//IL_0dab: Unknown result type (might be due to invalid IL or missing references)
//IL_0def: Unknown result type (might be due to invalid IL or missing references)
//IL_0e30: Unknown result type (might be due to invalid IL or missing references)
//IL_0e35: Unknown result type (might be due to invalid IL or missing references)
//IL_0e42: Unknown result type (might be due to invalid IL or missing references)
//IL_0e47: Unknown result type (might be due to invalid IL or missing references)
//IL_0e82: Unknown result type (might be due to invalid IL or missing references)
//IL_0e87: Unknown result type (might be due to invalid IL or missing references)
DBG.blogDebug("Releasing Creature local");
Dictionary<string, string> customData = item.m_customData;
customData.TryGetValue("PP_Prefab", out var value);
GameObject prefab = ZNetScene.instance.GetPrefab(StringExtensionMethods.GetStableHashCode(value));
if (!Object.op_Implicit((Object)(object)prefab))
{
return null;
}
Vector3 val = ((Component)plr).transform.position + ((Component)plr).transform.rotation * throwLoc;
Vector3 localScale = prefab.transform.localScale;
Vector3 val2 = localScale;
DBG.blogDebug("StartScale=" + ((object)(Vector3)(ref val2)).ToString());
GameObject val3 = new GameObject("tempObject");
val3.SetActive(false);
GameObject val4 = Object.Instantiate<GameObject>(prefab, val, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f), val3.transform);
int num = 0;
string text = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text + val2.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;
}
string text2 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text2 + val2.x);
ReleaseCreature_PreAwake(component, item);
string text3 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text3 + val2.x);
val4.transform.SetParent((Transform)null);
Object.Destroy((Object)(object)val3);
string text4 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text4 + val2.x);
ZNetView component2 = val4.GetComponent<ZNetView>();
ZDO zDO = component2.GetZDO();
DBG.blogDebug("lvl=" + zDO.GetInt(ZDOVars.s_level, 0));
string valueSafe = GeneralExtensions.GetValueSafe<string, string>(item.m_customData, "PP_LastCatch");
Utils2.addOrUpdateCustomData(((Humanoid)plr).RightItem.m_customData, "PP_Prefab", "");
Utils2.addOrUpdateCustomData(item.m_customData, "PP_LastCatch", Time.time.ToString());
string text5 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text5 + val2.x);
val2 = val4.transform.localScale;
DBG.blogDebug("Scale=" + ((object)(Vector3)(ref val2)).ToString());
val4.transform.localScale = localScale;
DBG.blogDebug("Created Creature");
component.m_nview.GetZDO().Set(releaseZDOKey, true);
if (customData.TryGetValue("PP_Saddle", out var value2) && value2 == "true")
{
DBG.blogDebug("Attempting Saddle");
component.m_nview.GetZDO().Set(ZDOVars.s_haveSaddleHash, true);
if ((Object)(object)component.m_baseAI != (Object)null && (Object)(object)component.m_baseAI.m_tamable != (Object)null)
{
DBG.blogDebug("Attempting Set Saddle");
component.m_baseAI.m_tamable.SetSaddle(true);
}
}
string text6 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text6 + val2.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");
}
string text7 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text7 + val2.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);
}
string text8 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text8 + val2.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);
}
else if (name.Contains("Armour"))
{
DBG.blogDebug("Armour PalStone");
component.GetSEMan().AddStatusEffect((StatusEffect)(object)Plugin.prefabManager.SE_ArmorBuff, false, 0, 0f);
}
else if (name.Contains("Heal"))
{
DBG.blogDebug("Heal PalStone");
flag2 = true;
component.GetSEMan().AddStatusEffect((StatusEffect)(object)Plugin.prefabManager.SE_HealBuff, false, 0, 0f);
}
if (flag || !component.IsTamed())
{
DBG.blogDebug("Error Occured, Destryoing Creature");
Object.Destroy((Object)(object)val4);
}
val4.SetActive(true);
val2 = val4.transform.localScale;
DBG.blogDebug("localScale pre DNA Set=" + ((object)(Vector3)(ref val2)).ToString());
component.m_nview.GetZDO().Set("PP_Scale", val4.transform.localScale);
if (Plugin.hasAT && customData.TryGetValue("PP_DNA", out var value6))
{
string[] array2 = value6.Split(new char[1] { ':' });
if (long.TryParse(array2[0], out var result3))
{
if (array2.Length > 1 && long.TryParse(array2[1], out var result4))
{
AllTame_API.setDNA(val4, result3, result4);
}
else
{
AllTame_API.setDNA(val4, result3, 0L);
}
}
}
string text9 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text9 + val2.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);
}
}
string text10 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text10 + val2.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;
string text11 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text11 + val2.x);
ReleaseCreatureEffect(component);
string text12 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text12 + val2.x);
ReleaseCreature_PostAwake(component, item);
string text13 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text13 + val2.x);
val4.GetComponent<TimedScaleAndFreeze>().ogScale = localScale;
if (((object)component).GetType().Name.Contains("Companion"))
{
val4.GetComponent<TimedScaleAndFreeze>().clearInv = true;
}
string text14 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text14 + val2.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);
string text15 = $"Scale({num++})=";
val2 = val4.transform.localScale;
DBG.blogDebug(text15 + val2.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");
}
}
[IteratorStateMachine(typeof(<CatchUpdate>d__25))]
private static IEnumerator CatchUpdate(Character creature)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CatchUpdate>d__25(0)
{
creature = creature
};
}
[IteratorStateMachine(typeof(<regainControl>d__26))]
private static IEnumerator regainControl(Player plr, float time)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <regainControl>d__26(0)
{
plr = plr,
time = time
};
}
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
{
[CompilerGenerated]
private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private bool <skipped>5__1;
private IEnumerator<CodeInstruction> <>s__2;
private CodeInstruction <instruction>5__3;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__2 = null;
<instruction>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<skipped>5__1 = false;
<>s__2 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
goto IL_00e2;
case 2:
{
<>1__state = -3;
goto IL_00e2;
}
IL_00e2:
<instruction>5__3 = null;
break;
}
if (<>s__2.MoveNext())
{
<instruction>5__3 = <>s__2.Current;
if (!<skipped>5__1 && <instruction>5__3.opcode == OpCodes.Ldc_I4_4)
{
<skipped>5__1 = true;
<>2__current = new CodeInstruction(OpCodes.Ldc_I4_8, (object)null);
<>1__state = 1;
return true;
}
<>2__current = <instruction>5__3;
<>1__state = 2;
return true;
}
<>m__Finally1();
<>s__2 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__2 != null)
{
<>s__2.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__0(-2)
{
<>3__instructions = instructions
};
}
}
public static string catch_anim = "emote_point";
public static string release_anim = "knife_stab";
[HarmonyPatch(typeof(ObjectDB), "Awake")]
[HarmonyPostfix]
private static void AddItems(ObjectDB __instance)
{
//IL_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();
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Attack), "Start")]
private static bool Attack_Start(Attack __instance, Humanoid character, ZSyncAnimation zanim, ItemData weapon, ref float timeSinceLastAttack)
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
if (weapon == null)
{
return true;
}
if ((Object)(object)weapon.m_dropPrefab == (Object)null || !((Object)weapon.m_dropPrefab).name.Contains("PalStone"))
{
return true;
}
if (Math.Abs(Time.time - weapon.m_lastAttackTime) < 1.1f)
{
return false;
}
weapon.m_shared.m_movementModifier = -0.05f;
DBG.blogDebug("inPalStoneAttackAwake");
int num = CatchPal.attemptCatch((Player)character, weapon);
if (((Character)character).IsPlayer() && num <= 0)
{
weapon.m_lastAttackTime = Time.time;
((Character)character).m_attack = true;
return false;
}
if (num == 2)
{
__instance.m_attackAnimation = catch_anim;
__instance.m_attackChainLevels = 1;
zanim.SetSpeed(4f);
zanim.m_animator.speed = 3f;
}
else
{
__instance.m_attackAnimation = release_anim;
__instance.m_attackChainLevels = 3;
zanim.SetSpeed(0.5f);
zanim.m_animator.speed = 0.5f;
}
weapon.m_lastAttackTime = Time.time;
DBG.blogDebug("animation=" + __instance.m_attackAnimation);
return true;
}
private static string ByPassFilter(string text)
{
string result = default(string);
bool flag = default(bool);
if (CensorShittyWords.Filter(text, ref result, ref flag) && flag)
{
return result;
}
return text;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
{
typeof(ItemData),
typeof(int),
typeof(bool),
typeof(float),
typeof(int)
})]
private static void Postfix(ItemData item, bool crafting, int qualityLevel, ref string __result)
{
if (Object.op_Implicit((Object)(object)item.m_dropPrefab) && ((Object)item.m_dropPrefab).name.Contains("PalStone"))
{
__result = Build_PalStone_Description(item, crafting, qualityLevel);
}
}
private static string Build_PalStone_Description(ItemData item, bool crafting, int quality)
{
Player localPlayer = Player.m_localPlayer;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(item.m_shared.m_description);
stringBuilder.Append("\n");
if (item.m_crafterID != 0)
{
stringBuilder.AppendFormat("\n$item_crafter: <color=orange>{0}\n</color>", ByPassFilter(item.m_crafterName));
}
string name = ((Object)item.m_dropPrefab).name;
if (name.Contains("Speed"))
{
stringBuilder.AppendFormat("<color=yellow>{0}$pp_speedEffect_desc\n$pp_duration</color>{1}s\n", Plugin.speedIncrease.Value * 100f, Plugin.Speed_buffLength.Value);
}
else if (name.Contains("Armour"))
{
stringBuilder.AppendFormat("<color=#04a6da>$pp_armourEffect_desc\n$pp_duration</color>{0}s\n", Plugin.Armor_buffLength.Value);
}
else if (name.Contains("Heal"))
{
stringBuilder.AppendFormat("<color=green>$pp_healEffect_desc {0}%</color>\n", Plugin.percentHealPerMin.Value * 100f);
}
if (item.m_shared.m_useDurability)
{
if (crafting)
{
float maxDurability = item.GetMaxDurability(quality);
stringBuilder.AppendFormat("\n$item_durability: <color=orange>{0}</color>", maxDurability);
}
else
{
float maxDurability2 = item.GetMaxDurability(quality);
float durability = item.m_durability;
stringBuilder.AppendFormat("\n$item_durability: <color=orange>{0}%</color> <color=yellow>({1}/{2})</color>", (item.GetDurabilityPercentage() * 100f).ToString("0"), durability.ToString("0"), maxDurability2.ToString("0"));
}
if (item.m_shared.m_canBeReparied && !crafting)
{
Recipe recipe = ObjectDB.instance.GetRecipe(item);
if ((Object)(object)recipe != (Object)null)
{
int minStationLevel = recipe.m_minStationLevel;
stringBuilder.AppendFormat("\n$item_repairlevel: <color=orange>{0}</color>", minStationLevel.ToString());
}
}
}
stringBuilder.Append("\n");
Dictionary<string, string> customData = item.m_customData;
if (!customData.TryGetValue("PP_Prefab", out var value) || (value ?? "") == "")
{
stringBuilder.Append("<color=red>$pp_empty</color>\n");
localPlayer.AppendEquipmentModifierTooltips(item, stringBuilder);
return stringBuilder.ToString();
}
GameObject prefab = ZNetScene.instance.GetPrefab(value);
Character val = default(Character);
if (Object.op_Implicit((Object)(object)prefab) && prefab.TryGetComponent<Character>(ref val))
{
value = val.m_name;
}
stringBuilder.Append("$pp_stored_creature<color=green>" + value + "</color>\n");
if (customData.TryGetValue("PP_Name", out var value2) && (value2 ?? "") != "")
{
stringBuilder.Append("$pp_name<color=orange>" + value2 + "</color>\n");
}
stringBuilder.Append("$pp_lvl<color=orange>" + GeneralExtensions.GetValueSafe<string, string>(customData, "PP_Lvl") + "</color>\n");
if (Plugin.hasCLLC)
{
string[] array = GeneralExtensions.GetValueSafe<string, string>(customData, "PP_CLLC").Split(new char[1] { ',' });
if ((array[0] ?? "") != "" && array[0] != "None")
{
stringBuilder.Append("$pp_infusion<color=orange>" + array[0] + "</color>\n");
}
if (array.Length > 1 && array[1] + "None" != "" && array[1] != "None")
{
stringBuilder.Append("$pp_effect<color=orange>" + array[1] + "</color>\n");
}
}
if (customData.TryGetValue("PP_Saddle", out var value3) && value3 == "true")
{
stringBuilder.Append("- <color=orange>$pp_has_saddle</color>\n");
}
localPlayer.AppendEquipmentModifierTooltips(item, stringBuilder);
return stringBuilder.ToString();
}
}
public static class DBG
{
public static void cprt(string s)
{
Console.instance.Print(s);
}
public static void InfoTL(string s)
{
((Character)Player.m_localPlayer).Message((MessageType)1, s, 0, (Sprite)null);
}
public static void InfoCT(string s)
{
((Character)Player.m_localPlayer).Message((MessageType)2, s, 0, (Sprite)null);
}
public static void blogInfo(object o)
{
Plugin.logger.LogInfo(o);
}
public static void blogWarning(object o)
{
Plugin.logger.LogWarning(o);
}
public static void blogDebug(object o)
{
if (Plugin.debugout.Value)
{
Plugin.logger.LogWarning(o);
}
}
public static void tryblogDebug(object o, object o_backup)
{
try
{
if (Plugin.debugout.Value)
{
Plugin.logger.LogWarning(o);
}
}
catch
{
Plugin.logger.LogWarning(o_backup);
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("meldurson.valheim.PortablePals", "PortablePals", "0.2.0")]
[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 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 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 localizeLoaded = false;
[HarmonyPostfix]
[HarmonyPatch(typeof(ZNetScene), "Shutdown")]
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_0366: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Expected O, but got Unknown
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: 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
} }));
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;
}
PerformPatches();
prefabManager = Root.AddComponent<PrefabManager>();
DBG.blogInfo("PortablePals Loaded");
PrefabManager.OnVanillaPrefabsAvailable += PrefabManager.ItemReg;
SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
{
if (attr.InitialSynchronization)
{
Logger.LogMessage((object)"Initial Config sync event received");
}
else
{
Logger.LogMessage((object)"Config sync event received");
}
PrefabManager.ItemRegFromServer();
};
}
public void PerformPatches()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("meldurson.valheim.PortablePals");
DBG.blogInfo("Patching Select");
val.PatchAll(typeof(Patches));
val.PatchAll(typeof(CatchPal));
if (hasCLLC)
{
val.PatchAll(typeof(CLLC_Patches));
DBG.blogDebug("Patched CLLCPatches");
}
if (hasAT)
{
val.PatchAll(typeof(AllTame_API.AT_DNA_Patches));
DBG.blogDebug("Patched ATPatches");
}
if (Chainloader.PluginInfos.ContainsKey("RustyMods.VikingNPC"))
{
DBG.blogInfo("Patching RustyMods.VikingNPC");
val.PatchAll(typeof(VikingNPC));
}
IEnumerable<MethodBase> patchedMethods = val.GetPatchedMethods();
val.PatchAll(typeof(Patches.FixMaxRepairLevel));
foreach (MethodBase item in patchedMethods)
{
DBG.blogDebug(item.ReflectedType?.ToString() + ":" + item.Name + " is patched");
}
}
}
public class TimedScaleAndFreeze : MonoBehaviour
{
public float roughness = 0.05f;
public float startimeScale = 1f;
public float startimeMove = 0.4f;
private float lastTimeScale = 0f;
private float lastTimeMove = 0f;
public float duration = 1f;
public int breakChild = 0;
public float startScale = 0.01f;
public float endScale = 1f;
public float maxMovePercent = 0.1f;
public Vector3 endLoc = Vector3.zero;
private float timeMulti;
public Vector3 ogScale;
private float endTime;
public bool ZNetDestroy = true;
private bool firstUpdate = true;
public float CLLC_Scale = 1f;
public float DNA_Scale = 1f;
public bool setFinalScale = true;
public bool clearInv = false;
public bool pastStart = false;
public float sls_Size = 1f;
private Vector3 previousScale;
public Vector3 exteriorScale = Vector3.one;
public Rigidbody rb;
private RigidbodyConstraints constraints = (RigidbodyConstraints)0;
public ZNetView m_nview;
private void Start()
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: 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_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: 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)
if ((Object)(object)m_nview == (Object)null)
{
m_nview = ((Component)this).GetComponent<ZNetView>();
}
if ((Object)(object)m_nview == (Object)null)
{
m_nview = ((Component)this).GetComponentInParent<ZNetView>();
}
lastTimeScale = Time.time + startimeScale;
startimeScale = lastTimeScale;
lastTimeMove = Time.time + startimeMove;
startimeMove = lastTimeMove;
DBG.blogDebug("Start Time Scale =" + startimeScale);
timeMulti = (endScale - startScale) / duration;
_ = ogScale;
if (ogScale == Vector3.zero)
{
ogScale = ((Component)this).transform.localScale;
}
Vector3 val = ogScale;
DBG.blogDebug("ogScale =" + ((object)(Vector3)(ref val)).ToString());
val = ogScale;
DBG.blogDebug("post SLS =" + ((object)(Vector3)(ref val)).ToString());
((Component)this).transform.localScale = ogScale * startScale;
previousScale = ((Component)this).transform.localScale;
endTime = startimeScale + duration;
}
private void Update()
{
//IL_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_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: 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_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: 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_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
float time = Time.time;
Vector3 val;
if (time > endTime)
{
if (setFinalScale)
{
((Component)this).transform.localScale = Vector3.Scale(exteriorScale, ogScale);
val = ((Component)this).transform.localScale;
DBG.blogDebug("finalScale=" + ((object)(Vector3)(ref val)).ToString());
endScale = ((Component)this).transform.localScale.x;
CatchPal.ReleaseCreature_PostRelease(((Component)this).gameObject.GetComponent<Character>(), this);
}
removeSelf();
return;
}
if (time - lastTimeScale > roughness)
{
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(((Component)this).transform.localScale.x / previousScale.x, ((Component)this).transform.localScale.y / previousScale.y, ((Component)this).transform.localScale.z / previousScale.z);
if (((Vector3)(ref val2)).magnitude < 5f)
{
exteriorScale = Vector3.Scale(exteriorScale, val2);
}
else
{
val = val2;
string? text = ((object)(Vector3)(ref val)).ToString();
val = ((Component)this).transform.localScale;
DBG.blogDebug("scaler Scale too high =" + text + ", scale=" + ((object)(Vector3)(ref val)).ToString());
}
if (((Component)this).transform.localScale.x / previousScale.x != 1f)
{
val = exteriorScale;
string? text2 = ((object)(Vector3)(ref val)).ToString();
val = ((Component)this).transform.localScale;
DBG.blogDebug("exterior Scale =" + text2 + ", scale=" + ((object)(Vector3)(ref val)).ToString());
}
((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();
}
}
if (time - lastTimeMove > roughness && endLoc != Vector3.zero)
{
if (endLoc != Vector3.zero)
{
((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, endLoc, maxMovePercent * Vector3.Distance(((Component)this).transform.position, endLoc));
}
lastTimeMove = time;
}
}
public void SetEndPos(Vector3 location)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
endLoc = location;
Vector3 val = endLoc;
DBG.blogDebug("End loc =" + ((object)(Vector3)(ref val)).ToString());
}
public TimedScaleAndFreeze SetRB(Rigidbody freeze_rb)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
rb = freeze_rb;
constraints = rb.constraints;
rb.constraints = (RigidbodyConstraints)126;
return this;
}
public void removeSelf()
{
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
Humanoid component = ((Component)this).gameObject.GetComponent<Humanoid>();
if (clearInv && (Object)(object)component != (Object)null)
{
Inventory inventory = component.GetInventory();
DBG.blogDebug("inv pre size=" + inventory.m_inventory.Count());
DBG.blogDebug("Clearing Inventory");
inventory.RemoveAll();
DBG.blogDebug("inv post size=" + inventory.m_inventory.Count());
inventory.Changed();
}
try
{
VisEquipment componentInChildren = ((Component)this).gameObject.GetComponentInChildren<VisEquipment>();
if ((Object)(object)componentInChildren != (Object)null && !((Behaviour)componentInChildren).enabled)
{
((Behaviour)componentInChildren).enabled = true;
((Component)componentInChildren.m_rightHand).gameObject.SetActive(true);
((Component)componentInChildren.m_leftHand).gameObject.SetActive(true);
if ((Object)(object)component != (Object)null)
{
component.EquipItem(component.RightItem, true);
DBG.blogDebug("Equipped right Item:" + ((object)component.RightItem).ToString());
}
}
}
catch
{
DBG.blogWarning("Failed VisEquip");
}
try
{
if (breakChild >= 0 && breakChild < ((Component)this).transform.childCount)
{
DBG.blogDebug("Breaking Child " + ((Object)((Component)this).gameObject).name);
Transform child = ((Component)this).transform.GetChild(breakChild);
if (Object.op_Implicit((Object)(object)child))
{
child.parent = null;
if ((Object)(object)rb != (Object)null)
{
rb.constraints = constraints;
}
}
}
}
catch
{
DBG.blogWarning("Failed Break Child");
}
try
{
ZNetView component2 = ((Component)this).gameObject.GetComponent<ZNetView>();
if ((Object)(object)component2 != (Object)null && component2.IsValid() && component2.GetZDO().GetBool(CatchPal.releaseZDOKey, false))
{
DBG.blogDebug("Removing Release ZDO");
component2.GetZDO().Set(CatchPal.releaseZDOKey, false);
}
}
catch
{
DBG.blogWarning("Failed reset releaseZDO");
}
DestroyNow();
}
public void DestroyNow()
{
if (!ZNetDestroy)
{
DBG.blogDebug("Destroying tsf component in " + ((Object)((Component)this).gameObject).name);
Object.Destroy((Object)(object)this);
}
else if (Object.op_Implicit((Object)(object)m_nview))
{
if (m_nview.IsValid())
{
if (!m_nview.HasOwner())
{
m_nview.ClaimOwnership();
}
if (m_nview.IsOwner())
{
DBG.blogDebug("Destroying Znet in " + ((Object)((Component)this).gameObject).name);
ZNetScene.instance.Destroy(((Component)this).gameObject);
}
}
}
else
{
DBG.blogDebug("Not Owner, waiting for owner to destroy " + ((Object)((Component)this).gameObject).name);
}
}
}
public class TimedColor : MonoBehaviour
{
public float roughness = 0.01f;
public float startime = 0f;
private float lastTime = 0f;
public float duration = 0.7f;
public int breakChild = 0;
public Color endColorMulti = new Color(25f, 25f, 25f);
private Color colMulti;
private float endTime;
private List<Material> materials = new List<Material>();
private int actualCyles = 0;
private bool hasEnded = false;
public Rigidbody rb;
private void Start()
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
lastTime = Time.time + startime;
startime = lastTime;
DBG.blogDebug("Start Color time =" + startime);
int num = (int)(duration / Math.Max(roughness, 1f / 59f));
DBG.blogDebug("Expected num cycles=" + num);
colMulti = new Color(Mathf.Pow(endColorMulti.r, 1f / (float)num), Mathf.Pow(endColorMulti.g, 1f / (float)num), Mathf.Pow(endColorMulti.b, 1f / (float)num));
endTime = startime + duration;
Renderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
DBG.blogDebug("material added: " + ((Object)val.material).name);
materials.Add(val.material);
}
}
private void Update()
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
if (hasEnded)
{
return;
}
float time = Time.time;
if (time > endTime)
{
DBG.blogDebug("ActualCycles =" + actualCyles);
hasEnded = true;
}
else
{
if (!(time - lastTime > roughness))
{
return;
}
actualCyles++;
foreach (Material material in materials)
{
Color color = material.color;
material.color = new Color(color.r * colMulti.r, color.g * colMulti.g, color.b * colMulti.b);
}
lastTime = time;
}
}
}
public class PP_SE : StatusEffect
{
private ZNetView m_nview;
public string ZDO_key = "";
public float m_lvl = 1f;
public float m_length = 600f;
public float m_damageMod = 0.6f;
public SkillType[] modifySkills = (SkillType[])(object)new SkillType[0];
public override void Setup(Character character)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
base.m_character = character;
if (!string.IsNullOrEmpty(base.m_startMessage))
{
base.m_character.Message(base.m_startMessageType, base.m_startMessage, 0, (Sprite)null);
}
m_nview = base.m_character.m_nview;
if (m_nview.IsValid())
{
if (base.m_repeatInterval > 0f)
{
m_length = base.m_repeatInterval;
}
DBG.blogDebug("Setting " + ZDO_key + " to time " + (Time.time + m_length));
m_nview.GetZDO().Set(ZDO_key, Time.time + m_length);
}
((StatusEffect)this).TriggerStartEffects();
}
public override void UpdateStatusEffect(float dt)
{
base.m_time += dt;
if (base.m_repeatInterval > 0f)
{
base.m_msgTimer += dt;
if (base.m_msgTimer > base.m_repeatInterval)
{
DBG.blogDebug("resetting timer for " + ZDO_key + " to time " + (Time.time + base.m_repeatInterval));
base.m_msgTimer = 0f;
m_nview.GetZDO().Set(ZDO_key, Time.time + base.m_repeatInterval);
}
}
}
public override void ModifyAttack(SkillType skill, ref HitData hitData)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (modifySkills.Length != 0 && (modifySkills.Contains(skill) || (int)modifySkills[0] == 999))
{
((DamageTypes)(ref hitData.m_damage)).Modify(m_damageMod);
}
}
public override void Stop()
{
((StatusEffect)this).Stop();
m_nview.GetZDO().Set(ZDO_key, 0f);
}
}
public class PrefabManager : MonoBehaviour
{
public SE_Stats SE_SpeedBuff = ScriptableObject.CreateInstance<SE_Stats>();
public SE_Stats SE_ArmorBuff = ScriptableObject.CreateInstance<SE_Stats>();
public SE_Stats SE_HealBuff = ScriptableObject.CreateInstance<SE_Stats>();
public GameObject Root;
private static AssetBundle PP_Assets;
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
Root = new GameObject("PrefabList");
Root.transform.SetParent(Plugin.Root.transform);
Root.SetActive(false);
PP_Assets = AssetUtils.LoadAssetBundleFromResources("portablepals", Assembly.GetExecutingAssembly());
}
public static AssetBundle getAssetBundle()
{
return PP_Assets;
}
public static void ItemReg()
{
DBG.blogDebug("ItemReg");
AddItems();
PrefabManager.OnVanillaPrefabsAvailable -= ItemReg;
}
public static void ItemRegFromServer()
{
UpdateItems();
}
public static void AddItems()
{
addPortablePalStone();
addSpeedPalStone();
addArmourPalStone();
addHealPalStone();
Plugin.prefabManager.addEffects();
}
public static void UpdateItems()
{
DBG.blogDebug("Updating recipes for palstones");
if ((Object)(object)ZNetScene.instance == (Object)null)
{
DBG.blogDebug("zns is null");
return;
}
ResetPalStoneRecipe(Plugin.recipe.Value, "PalStone");
ResetPalStoneRecipe(Plugin.recipe_Armor.Value, "PalStoneArmour");
ResetPalStoneRecipe(Plugin.recipe_Heal.Value, "PalStoneHeal");
ResetPalStoneRecipe(Plugin.recipe_Speed.Value, "PalStoneSpeed");
}
private static Recipe ResetPalStoneRecipe(string recipeConfig, string item)
{
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item);
ItemDrop val = default(ItemDrop);
if ((Object)(object)itemPrefab == (Object)null || !itemPrefab.TryGetComponent<ItemDrop>(ref val))
{
DBG.blogWarning(item + " is null or does not have itemDrop");
return null;
}
Recipe val2 = ScriptableObject.CreateInstance<Recipe>();
((Object)val2).name = "Recipe_" + item;
val2.m_item = val;
string[] array = Plugin.craftingStation.Value.Split(new char[1] { ':' });
GameObject prefab = ZNetScene.instance.GetPrefab(array[0]);
CraftingStation val3 = default(CraftingStation);
if ((Object)(object)prefab == (Object)null || !prefab.TryGetComponent<CraftingStation>(ref val3))
{
DBG.blogWarning("invalid crafting station: " + array[0]);
return null;
}
val2.m_craftingStation = val3;
val2.m_repairStation = val3;
if (array.Length > 1 && int.TryParse(array[1], out var result))
{
val2.m_minStationLevel = result;
}
else
{
val2.m_minStationLevel = 5;
}
string[] array2 = recipeConfig.Split(new char[1] { ',' });
int amt = 1;
List<Requirement> list = new List<Requirement>();
for (int i = 0; i < array2.Length; i++)
{
string[] array3 = array2[i].Split(new char[1] { ':' });
if (array3.Length == 2 && int.TryParse(array3[1], out var result2))
{
amt = result2;
}
Requirement val4 = makeReq