Decompiled source of SurtlingCompanion v0.1.1

plugins/SurtlingCompanion.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SurtlingCompanion")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+6715fdb8b9a771449d4c1918d7e6c258f3c4d478")]
[assembly: AssemblyProduct("SurtlingCompanion")]
[assembly: AssemblyTitle("SurtlingCompanion")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SurtlingCompanion
{
	[BepInPlugin("lamento87.SurtlingCompanion", "Surtling Companion", "0.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class SurtlingCompanionPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Requirement), "GetAmount")]
		internal static class RequirementAmountPatch
		{
			private static readonly Dictionary<Requirement, int[]> Amounts = new Dictionary<Requirement, int[]>();

			public static void RegisterStaffRecipe()
			{
				Amounts.Clear();
				GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab("StaffSurtlingCompanion") : null);
				Recipe val2 = (Object.op_Implicit((Object)(object)val) ? ObjectDB.instance.GetRecipe(val.GetComponent<ItemDrop>().m_itemData) : null);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					return;
				}
				Requirement[] resources = val2.m_resources;
				foreach (Requirement val3 in resources)
				{
					if (Object.op_Implicit((Object)(object)val3.m_resItem) && StaffCosts.TryGetValue(((Object)val3.m_resItem).name, out var value))
					{
						Amounts[val3] = value;
					}
				}
			}

			private static void Postfix(Requirement __instance, int qualityLevel, ref int __result)
			{
				if (Amounts.TryGetValue(__instance, out var value))
				{
					__result = value[Mathf.Clamp(qualityLevel, 1, value.Length) - 1];
				}
			}
		}

		public const string PluginGUID = "lamento87.SurtlingCompanion";

		public const string PluginName = "Surtling Companion";

		public const string PluginVersion = "0.1.1";

		public const string CompanionPrefabName = "SurtlingCompanion";

		private const string CompanionName = "Surtling Companion";

		private const string StaffPrefabName = "StaffSurtlingCompanion";

		private const string SpawnProjectilePrefabName = "SurtlingCompanion_spawn";

		private static readonly Dictionary<string, int[]> StaffCosts = new Dictionary<string, int[]>
		{
			{
				"SurtlingCore",
				new int[3] { 5, 7, 10 }
			},
			{
				"Wisp",
				new int[3] { 1, 2, 3 }
			}
		};

		private static ConfigEntry<Vector3> handTrophyOffset;

		private static ConfigEntry<Vector3> handTrophyRotation;

		private static ConfigEntry<float> handTrophyScale;

		private readonly Harmony harmony = new Harmony("lamento87.SurtlingCompanion");

		private void Awake()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			handTrophyOffset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Hand trophy (restart to apply)", "Offset", new Vector3(0f, 0.12f, 0f), "Position of the trophy relative to the hand.");
			handTrophyRotation = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Hand trophy (restart to apply)", "Rotation", new Vector3(270f, 90f, 180f), "Rotation of the trophy in degrees (x, y, z).");
			handTrophyScale = ((BaseUnityPlugin)this).Config.Bind<float>("Hand trophy (restart to apply)", "Scale", 1f, "Size of the trophy in the hand.");
			harmony.PatchAll();
			PrefabManager.OnVanillaPrefabsAvailable += AddContent;
			ItemManager.OnItemsRegistered += RequirementAmountPatch.RegisterStaffRecipe;
			Logger.LogInfo((object)"Surtling Companion 0.1.1 loaded");
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}

		private void AddContent()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= AddContent;
			if (!Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("Surtling")) || !Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("StaffSkeleton")))
			{
				Logger.LogError((object)"Vanilla Surtling or Dead Raiser prefab not found, companion disabled");
				return;
			}
			AddCompanion();
			AddStaff();
		}

		private static void AddCompanion()
		{
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("SurtlingCompanion", "Surtling");
			val.GetComponent<Character>().m_name = "Surtling Companion";
			(val.GetComponent<CharacterDrop>() ?? val.AddComponent<CharacterDrop>()).m_drops = new List<Drop>
			{
				FixedDrop("SurtlingCore"),
				FixedDrop("Coal")
			};
			Tameable val2 = val.GetComponent<Tameable>() ?? val.AddComponent<Tameable>();
			val2.m_startsTamed = true;
			val2.m_commandable = true;
			val2.m_randomStartingName = new List<string> { "Surtur" };
			GameObject prefab = PrefabManager.Instance.GetPrefab("Wolf");
			Tameable val3 = ((prefab != null) ? prefab.GetComponent<Tameable>() : null);
			if (Object.op_Implicit((Object)(object)val3))
			{
				val2.m_petEffect = val3.m_petEffect;
				val2.m_tamedEffect = val3.m_tamedEffect;
			}
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("Skeleton_Friendly");
			Tameable val4 = ((prefab2 != null) ? prefab2.GetComponent<Tameable>() : null);
			if (Object.op_Implicit((Object)(object)val4))
			{
				val2.m_unsummonDistance = val4.m_unsummonDistance;
				val2.m_unsummonOnOwnerLogoutSeconds = val4.m_unsummonOnOwnerLogoutSeconds;
				val2.m_unSummonEffect = val4.m_unSummonEffect;
			}
			PrefabManager.Instance.AddPrefab(val);
		}

		private static Drop FixedDrop(string itemName)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			return new Drop
			{
				m_prefab = PrefabManager.Instance.GetPrefab(itemName),
				m_amountMin = 1,
				m_amountMax = 1,
				m_chance = 1f,
				m_levelMultiplier = false,
				m_dontScale = true
			};
		}

		private static void AddStaff()
		{
			//IL_00bc: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("StaffSurtlingCompanion", "StaffSkeleton");
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared.m_maxQuality = 3;
			shared.m_attack.m_attackEitr = 0f;
			shared.m_attack.m_attackStamina = 50f;
			ReplaceHandModelWithTrophy(val);
			GameObject val2 = PrefabManager.Instance.CreateClonedPrefab("SurtlingCompanion_spawn", shared.m_attack.m_attackProjectile);
			SpawnAbility component = val2.GetComponent<SpawnAbility>();
			SurtlingSpawnProjectile surtlingSpawnProjectile = val2.AddComponent<SurtlingSpawnProjectile>();
			if (Object.op_Implicit((Object)(object)component))
			{
				surtlingSpawnProjectile.m_preSpawnEffects = component.m_preSpawnEffects;
				surtlingSpawnProjectile.m_spawnEffects = component.m_spawnEffects;
				Object.DestroyImmediate((Object)(object)component);
			}
			PrefabManager.Instance.AddPrefab(val2);
			shared.m_attack.m_attackProjectile = val2;
			ItemConfig val3 = new ItemConfig
			{
				Name = "Surtling Raiser",
				Description = "Summons a tamed Surtling that follows you and fights by your side. Costs 50 stamina and a sacrifice of health, like the Dead Raiser. Upgrade it at the forge to summon starred Surtlings.",
				CraftingStation = CraftingStations.Forge,
				MinStationLevel = 1
			};
			foreach (KeyValuePair<string, int[]> staffCost in StaffCosts)
			{
				val3.AddRequirement(new RequirementConfig(staffCost.Key, staffCost.Value[0], staffCost.Value[1], true));
			}
			GameObject prefab = PrefabManager.Instance.GetPrefab("TrophySurtling");
			Sprite val4 = ((prefab != null) ? prefab.GetComponent<ItemDrop>().m_itemData.GetIcon() : null);
			if (Object.op_Implicit((Object)(object)val4))
			{
				val3.Icon = val4;
			}
			ItemManager.Instance.AddItem(new CustomItem(val, false, val3));
		}

		private static void ReplaceHandModelWithTrophy(GameObject staff)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			GameObject prefab = PrefabManager.Instance.GetPrefab("TrophySurtling");
			Transform val = staff.transform.Find("attach");
			if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)val))
			{
				Logger.LogWarning((object)"Could not swap the Surtling Raiser hand model, keeping the Dead Raiser model");
				return;
			}
			GameObject val2 = new GameObject("attach");
			val2.transform.SetParent(staff.transform, false);
			val2.transform.localPosition = val.localPosition;
			val2.transform.localRotation = val.localRotation;
			Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
			GameObject val3 = new GameObject("trophy");
			val3.transform.SetParent(val2.transform, false);
			val3.transform.localPosition = handTrophyOffset.Value;
			val3.transform.localEulerAngles = handTrophyRotation.Value;
			val3.transform.localScale = Vector3.one * handTrophyScale.Value;
			Transform transform = new GameObject("fit").transform;
			transform.SetParent(val3.transform, false);
			foreach (Transform item in prefab.transform)
			{
				Transform val4 = item;
				if (Object.op_Implicit((Object)(object)((Component)val4).GetComponentInChildren<Renderer>(true)))
				{
					((Object)Object.Instantiate<GameObject>(((Component)val4).gameObject, transform, false)).name = ((Object)val4).name;
				}
			}
			Component[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Component>(true);
			foreach (Component val5 in componentsInChildren)
			{
				if (val5 is Collider || val5 is Rigidbody || val5 is MonoBehaviour)
				{
					Object.DestroyImmediate((Object)(object)val5);
				}
			}
			FitToHand(transform);
		}

		private static void FitToHand(Transform fit)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0130: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: 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)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			Matrix4x4 worldToLocalMatrix = fit.worldToLocalMatrix;
			Bounds? val = null;
			MeshFilter[] componentsInChildren = ((Component)fit).GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val2 in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val2.sharedMesh))
				{
					continue;
				}
				Bounds bounds = val2.sharedMesh.bounds;
				Matrix4x4 val3 = worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix;
				for (int j = 0; j < 8; j++)
				{
					Vector3 val4 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(j & 1), (float)((j >> 1) & 1), (float)((j >> 2) & 1)) * 2f - Vector3.one);
					Vector3 val5 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(val4);
					if (val.HasValue)
					{
						Bounds value = val.Value;
						((Bounds)(ref value)).Encapsulate(val5);
						val = value;
					}
					else
					{
						val = new Bounds(val5, Vector3.zero);
					}
				}
			}
			if (!val.HasValue)
			{
				Logger.LogWarning((object)"Surtling trophy has no meshes to fit, hand model left unscaled");
				return;
			}
			Bounds value2 = val.Value;
			Vector3 size = ((Bounds)(ref value2)).size;
			float num = Mathf.Max(size.x, Mathf.Max(size.y, size.z));
			float num2 = ((num > 0f) ? (0.35f / num) : 1f);
			fit.localScale = Vector3.one * num2;
			value2 = val.Value;
			fit.localPosition = -((Bounds)(ref value2)).center * num2;
			object arg = size;
			value2 = val.Value;
			Logger.LogInfo((object)$"Hand trophy fitted: size {arg}, center {((Bounds)(ref value2)).center}, scale {num2}");
		}
	}
	public class SurtlingSpawnProjectile : MonoBehaviour, IProjectile
	{
		private static readonly float[] SpawnDistances = new float[3] { 2.5f, 2f, 1.5f };

		private static readonly int SummonerKey = StringExtensionMethods.GetStableHashCode("SurtlingCompanion_summoner");

		public EffectList m_preSpawnEffects = new EffectList();

		public EffectList m_spawnEffects = new EffectList();

		public void Setup(Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemData item, ItemData ammo)
		{
			//IL_003a: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab("SurtlingCompanion");
			if (Object.op_Implicit((Object)(object)prefab))
			{
				Player val = (Player)(object)((owner is Player) ? owner : null);
				if (val != null)
				{
					UnsummonExisting(val.GetPlayerID());
					Vector3 val2 = FindSpawnPoint(owner, prefab.GetComponent<CapsuleCollider>());
					m_preSpawnEffects.Create(val2, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
					GameObject val3 = Object.Instantiate<GameObject>(prefab, val2, ((Component)owner).transform.rotation);
					int num = ((item == null) ? 1 : Mathf.Max(1, item.m_quality));
					if (num > 1)
					{
						val3.GetComponent<Character>().SetLevel(num);
					}
					val3.GetComponent<ZNetView>().GetZDO().Set(SummonerKey, val.GetPlayerID());
					Tameable component = val3.GetComponent<Tameable>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.Command((Humanoid)(object)val, false);
					}
					m_spawnEffects.Create(val2, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
				}
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private static Vector3 FindSpawnPoint(Character owner, CapsuleCollider capsule)
		{
			//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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_018d: Unknown result type (might be due to invalid IL or missing references)
			int mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" });
			int num = mask | LayerMask.GetMask(new string[3] { "character", "character_net", "character_noenv" });
			float num2 = (Object.op_Implicit((Object)(object)capsule) ? (capsule.radius * 1.25f) : 0.6f);
			float num3 = (Object.op_Implicit((Object)(object)capsule) ? Mathf.Max(capsule.height * 1.25f, num2 * 2f) : 1.5f);
			Vector3 val = ((Component)owner).transform.forward;
			val.y = 0f;
			val = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val)).normalized : Vector3.forward);
			Vector3 val2 = ((Component)owner).transform.position + Vector3.up * 1f;
			float[] spawnDistances = SpawnDistances;
			RaycastHit val4 = default(RaycastHit);
			foreach (float num4 in spawnDistances)
			{
				Vector3 val3 = val2 + val * num4;
				if (!Physics.Linecast(val2, val3, mask) && Physics.Raycast(val3, Vector3.down, ref val4, 3f, mask))
				{
					Vector3 val5 = ((RaycastHit)(ref val4)).point + Vector3.up * (num2 + 0.05f);
					Vector3 val6 = ((RaycastHit)(ref val4)).point + Vector3.up * (num3 - num2);
					if (!Physics.CheckCapsule(val5, val6, num2, num))
					{
						return ((RaycastHit)(ref val4)).point;
					}
				}
			}
			return ((Component)owner).transform.position;
		}

		private static void UnsummonExisting(long playerID)
		{
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>();
				if (Object.op_Implicit((Object)(object)component) && component.IsValid() && !(Utils.GetPrefabName(((Component)allCharacter).gameObject) != "SurtlingCompanion") && component.GetZDO().GetLong(SummonerKey, 0L) == playerID)
				{
					Tameable component2 = ((Component)allCharacter).GetComponent<Tameable>();
					if (component2 != null)
					{
						component2.UnSummon();
					}
				}
			}
		}

		public string GetTooltipString(int itemQuality)
		{
			return "";
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}