Decompiled source of Houndcaller v1.0.0

Houndcaller.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Houndcaller;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("axelc.houndcaller", "Houndcaller", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public const string Guid = "axelc.houndcaller";

	public const string PluginName = "Houndcaller";

	public const string Version = "1.0.0";

	internal static ManualLogSource Log;

	internal static TerminalNode BestiaryNode;

	internal static ConfigEntry<int> SpawnWeight;

	internal static ConfigEntry<int> MaxPerRound;

	internal static ConfigEntry<float> RoamSpeed;

	internal static ConfigEntry<float> TouchRadius;

	internal static ConfigEntry<int> DogsPerSummon;

	internal static ConfigEntry<int> MaxDogsPerWizard;

	internal static ConfigEntry<float> CooldownSeconds;

	internal static ConfigEntry<bool> LoudRitual;

	private void Awake()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		BindConfig();
		EnemyType val = CreateEnemyType();
		BestiaryNode = CreateBestiaryNode();
		TerminalKeyword val2 = ScriptableObject.CreateInstance<TerminalKeyword>();
		((Object)val2).name = "HoundcallerKeyword";
		val2.word = "houndcaller";
		Enemies.RegisterEnemy(val, SpawnWeight.Value, (LevelTypes)(-1), BestiaryNode, val2);
		new Harmony("axelc.houndcaller").PatchAll();
		Log.LogInfo((object)"Houndcaller 1.0.0 loaded.");
	}

	private void BindConfig()
	{
		SpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "SpawnWeight", 50, "Indoor spawn weight on every moon. For reference, most vanilla indoor enemies sit between 10 and 100.");
		MaxPerRound = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MaxPerRound", 1, "Most Houndcallers that can exist in the facility at once.");
		RoamSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Houndcaller", "RoamSpeed", 3f, "How fast the Houndcaller drifts through the hallways.");
		TouchRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Houndcaller", "TouchRadius", 1.4f, "How close (in meters) a player has to get to count as running into him.");
		DogsPerSummon = ((BaseUnityPlugin)this).Config.Bind<int>("Summoning", "DogsPerSummon", 2, "Eyeless dogs summoned each time someone runs into him.");
		MaxDogsPerWizard = ((BaseUnityPlugin)this).Config.Bind<int>("Summoning", "MaxDogsPerWizard", 4, "Total dogs one Houndcaller can summon in a round. 0 means no limit.");
		CooldownSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Summoning", "CooldownSeconds", 25f, "Seconds after a summon before he can summon again.");
		LoudRitual = ((BaseUnityPlugin)this).Config.Bind<bool>("Summoning", "LoudRitual", true, "The ritual ends with a loud noise, so the freshly summoned dogs come looking for whoever bumped him.");
	}

	private static EnemyType CreateEnemyType()
	{
		GameObject val = NetworkPrefabs.CreateNetworkPrefab("Houndcaller");
		NavMeshAgent val2 = val.AddComponent<NavMeshAgent>();
		val2.speed = RoamSpeed.Value;
		val2.acceleration = 10f;
		val2.angularSpeed = 240f;
		val2.radius = 0.45f;
		val2.height = 2.2f;
		val2.stoppingDistance = 0f;
		val2.autoBraking = true;
		WizardAI wizardAI = val.AddComponent<WizardAI>();
		EnemyType val3 = ScriptableObject.CreateInstance<EnemyType>();
		((Object)val3).name = "Houndcaller";
		val3.enemyName = "Houndcaller";
		val3.enemyPrefab = val;
		val3.PowerLevel = 1f;
		val3.MaxCount = MaxPerRound.Value;
		val3.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f);
		val3.isOutsideEnemy = false;
		val3.isDaytimeEnemy = false;
		val3.canDie = false;
		val3.canBeStunned = false;
		val3.stunTimeMultiplier = 1f;
		val3.doorSpeedMultiplier = 1f;
		((EnemyAI)wizardAI).enemyType = val3;
		return val3;
	}

	private static TerminalNode CreateBestiaryNode()
	{
		TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
		((Object)val).name = "HoundcallerFile";
		val.creatureName = "Houndcaller";
		val.clearPreviousText = true;
		val.maxCharactersToType = 35;
		val.displayText = "HOUNDCALLER\n\nSigurd's danger level: 70%\n\nScientific name: Magus canis-vocans\n\nA tall robed figure seen drifting slowly through facility corridors, staff in hand. It has never been observed attacking anyone. It does not need to.\n\nPhysical contact provokes a short ritual. The figure raises its staff, a ring of light opens on the floor, and eyeless dogs are pulled in from somewhere far outside. The ritual ends loudly.\n\nIf you bump into it: stop running, stop talking, and let the dogs walk past you.\n\n";
		return val;
	}
}
[HarmonyPatch(typeof(MouthDogAI), "Start")]
internal static class MouthDogInsidePatch
{
	private const float FacilityHeight = -80f;

	private static void Postfix(MouthDogAI __instance)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		if (((EnemyAI)__instance).isOutside && ((Component)__instance).transform.position.y < -80f)
		{
			((EnemyAI)__instance).SetEnemyOutside(false);
		}
	}
}
public class WizardAI : EnemyAI
{
	private const int StateRoaming = 0;

	private const int StateSummoning = 1;

	private const float RitualDuration = 2.6f;

	private const float SummonDelay = 1.2f;

	private const float DogSpawnRadius = 8f;

	private const float DogMinDistanceFromPlayers = 4f;

	private static EnemyType cachedDogType;

	private WizardModel model;

	private int lastSeenState;

	private float localRitualStart;

	private bool localSummonPlayed = true;

	private bool serverInRitual;

	private bool serverSummoned;

	private float serverRitualStart;

	private float nextRitualTime;

	private int dogsSummoned;

	public override void Start()
	{
		model = WizardModel.Build(((Component)this).transform);
		base.eye = model.Eye;
		base.creatureSFX = CreateAudioSource("WizardSFX");
		base.creatureVoice = CreateAudioSource("WizardVoice");
		base.enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[2]
		{
			MakeState("Roaming"),
			MakeState("Summoning")
		};
		CreateScanNode();
		((EnemyAI)this).Start();
		base.AIIntervalTime = 0.2f;
		nextRitualTime = Time.time + 4f;
	}

	public override void DoAIInterval()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DoAIInterval();
		if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead && (base.currentSearch == null || !base.currentSearch.inProgress))
		{
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}
	}

	public override void Update()
	{
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: 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)
		((EnemyAI)this).Update();
		bool flag = base.currentBehaviourStateIndex == 1;
		if (flag && lastSeenState != 1)
		{
			localRitualStart = Time.time;
			localSummonPlayed = false;
		}
		lastSeenState = base.currentBehaviourStateIndex;
		if (flag && !localSummonPlayed && Time.time - localRitualStart >= 1.2f)
		{
			localSummonPlayed = true;
			PlaySummonEffects();
		}
		if ((Object)(object)base.agent != (Object)null)
		{
			base.agent.speed = (flag ? 0f : Plugin.RoamSpeed.Value);
		}
		if ((Object)(object)model != (Object)null)
		{
			Vector3 position = Vector3.zero;
			bool hasTarget = flag && TryGetNearestPlayer(((Component)this).transform.position, 8f, out position);
			model.Animate(flag, hasTarget, position);
		}
		if (((NetworkBehaviour)this).IsServer && !base.isEnemyDead)
		{
			ServerTick();
		}
	}

	private void ServerTick()
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		if (serverInRitual)
		{
			float num = Time.time - serverRitualStart;
			if (!serverSummoned && num >= 1.2f)
			{
				serverSummoned = true;
				SummonDogs();
			}
			if (num >= 2.6f)
			{
				serverInRitual = false;
				nextRitualTime = Time.time + Plugin.CooldownSeconds.Value;
				if (Plugin.LoudRitual.Value)
				{
					RoundManager.Instance.PlayAudibleNoise(base.eye.position, 18f, 0.7f, 0, false, 0);
				}
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			}
		}
		else if (!(Time.time < nextRitualTime) && !StartOfRound.Instance.allPlayersDead)
		{
			int value = Plugin.MaxDogsPerWizard.Value;
			if ((value <= 0 || dogsSummoned < value) && IsAnyPlayerTouching())
			{
				serverInRitual = true;
				serverSummoned = false;
				serverRitualStart = Time.time;
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			}
		}
	}

	private bool IsAnyPlayerTouching()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		float value = Plugin.TouchRadius.Value;
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		foreach (PlayerControllerB val in allPlayerScripts)
		{
			if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead || !val.isInsideFactory)
			{
				continue;
			}
			Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
			if (!(Mathf.Abs(val2.y) > 2f))
			{
				val2.y = 0f;
				if (((Vector3)(ref val2)).sqrMagnitude <= value * value)
				{
					return true;
				}
			}
		}
		return false;
	}

	private void SummonDogs()
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		EnemyType val = FindDogType();
		if ((Object)(object)val == (Object)null)
		{
			Plugin.Log.LogWarning((object)"Couldn't find the eyeless dog enemy type, so nothing was summoned.");
			return;
		}
		int num = Plugin.DogsPerSummon.Value;
		int value = Plugin.MaxDogsPerWizard.Value;
		if (value > 0)
		{
			num = Mathf.Min(num, value - dogsSummoned);
		}
		for (int i = 0; i < num; i++)
		{
			RoundManager.Instance.SpawnEnemyGameObject(PickDogSpawnPosition(), Random.Range(0f, 360f), -1, val);
			dogsSummoned++;
		}
	}

	private Vector3 PickDogSpawnPosition()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		Vector3 result = ((Component)this).transform.position;
		float num = -1f;
		for (int i = 0; i < 10; i++)
		{
			Vector3 randomNavMeshPositionInRadius = RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)this).transform.position, 8f, default(NavMeshHit));
			Vector3 position;
			float num2 = (TryGetNearestPlayer(randomNavMeshPositionInRadius, 100f, out position) ? Vector3.Distance(randomNavMeshPositionInRadius, position) : 100f);
			if (num2 >= 4f)
			{
				return randomNavMeshPositionInRadius;
			}
			if (num2 > num)
			{
				num = num2;
				result = randomNavMeshPositionInRadius;
			}
		}
		return result;
	}

	private void PlaySummonEffects()
	{
		if ((Object)(object)model != (Object)null)
		{
			model.Burst();
		}
		EnemyType val = FindDogType();
		if (!((Object)(object)val == (Object)null) && !((Object)(object)base.creatureSFX == (Object)null))
		{
			MouthDogAI componentInChildren = val.enemyPrefab.GetComponentInChildren<MouthDogAI>();
			if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.screamSFX != (Object)null)
			{
				base.creatureSFX.PlayOneShot(componentInChildren.screamSFX, 1f);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, componentInChildren.screamSFX, 1f);
			}
		}
	}

	private static bool TryGetNearestPlayer(Vector3 from, float maxDistance, out Vector3 position)
	{
		//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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		position = Vector3.zero;
		float num = maxDistance;
		bool result = false;
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		foreach (PlayerControllerB val in allPlayerScripts)
		{
			if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead)
			{
				float num2 = Vector3.Distance(from, ((Component)val).transform.position);
				if (num2 < num)
				{
					num = num2;
					position = ((Component)val).transform.position;
					result = true;
				}
			}
		}
		return result;
	}

	internal static EnemyType FindDogType()
	{
		if ((Object)(object)cachedDogType != (Object)null)
		{
			return cachedDogType;
		}
		if ((Object)(object)StartOfRound.Instance != (Object)null)
		{
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (!((Object)(object)val == (Object)null))
				{
					cachedDogType = FindDogIn(val.OutsideEnemies) ?? FindDogIn(val.Enemies) ?? FindDogIn(val.DaytimeEnemies);
					if ((Object)(object)cachedDogType != (Object)null)
					{
						return cachedDogType;
					}
				}
			}
		}
		EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>();
		foreach (EnemyType val2 in array)
		{
			if (IsDog(val2))
			{
				cachedDogType = val2;
				return val2;
			}
		}
		return null;
	}

	private static EnemyType FindDogIn(List<SpawnableEnemyWithRarity> enemies)
	{
		if (enemies == null)
		{
			return null;
		}
		foreach (SpawnableEnemyWithRarity enemy in enemies)
		{
			if (enemy != null && IsDog(enemy.enemyType))
			{
				return enemy.enemyType;
			}
		}
		return null;
	}

	private static bool IsDog(EnemyType type)
	{
		if ((Object)(object)type != (Object)null && (Object)(object)type.enemyPrefab != (Object)null)
		{
			return (Object)(object)type.enemyPrefab.GetComponentInChildren<MouthDogAI>() != (Object)null;
		}
		return false;
	}

	private static EnemyBehaviourState MakeState(string name)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		EnemyBehaviourState val = new EnemyBehaviourState();
		val.name = name;
		return val;
	}

	private AudioSource CreateAudioSource(string name)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(((Component)this).transform, false);
		val.transform.localPosition = new Vector3(0f, 1.5f, 0f);
		AudioSource val2 = val.AddComponent<AudioSource>();
		val2.playOnAwake = false;
		val2.spatialBlend = 1f;
		val2.rolloffMode = (AudioRolloffMode)1;
		val2.minDistance = 2f;
		val2.maxDistance = 35f;
		val2.pitch = 0.8f;
		EnemyType val3 = FindDogType();
		if ((Object)(object)val3 != (Object)null)
		{
			EnemyAI componentInChildren = val3.enemyPrefab.GetComponentInChildren<EnemyAI>();
			if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.creatureSFX != (Object)null)
			{
				val2.outputAudioMixerGroup = componentInChildren.creatureSFX.outputAudioMixerGroup;
			}
		}
		return val2;
	}

	private void CreateScanNode()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("ScanNode");
		val.layer = 22;
		val.transform.SetParent(((Component)this).transform, false);
		val.transform.localPosition = new Vector3(0f, 1.4f, 0f);
		BoxCollider val2 = val.AddComponent<BoxCollider>();
		((Collider)val2).isTrigger = true;
		val2.size = new Vector3(0.6f, 0.6f, 0.6f);
		ScanNodeProperties val3 = val.AddComponent<ScanNodeProperties>();
		val3.headerText = "Houndcaller";
		val3.subText = "Do not touch.";
		val3.nodeType = 1;
		val3.minRange = 1;
		val3.maxRange = 25;
		val3.requiresLineOfSight = true;
		val3.creatureScanID = (((Object)(object)Plugin.BestiaryNode != (Object)null) ? Plugin.BestiaryNode.creatureFileID : (-1));
	}
}
public class WizardModel : MonoBehaviour
{
	private const int EnemyLayer = 19;

	private const float BodyScale = 0.9f;

	private const float IdleLightLumens = 250f;

	private const float RitualLightLumens = 2500f;

	private const float BurstLightLumens = 12000f;

	private static readonly Color RobeColor = new Color(0.12f, 0.08f, 0.28f);

	private static readonly Color MantleColor = new Color(0.07f, 0.04f, 0.16f);

	private static readonly Color TrimColor = new Color(0.65f, 0.48f, 0.14f);

	private static readonly Color SkinColor = new Color(0.6f, 0.6f, 0.54f);

	private static readonly Color BeardColor = new Color(0.88f, 0.88f, 0.85f);

	private static readonly Color WoodColor = new Color(0.3f, 0.18f, 0.08f);

	private static readonly Color ArcaneColor = new Color(0.65f, 0.25f, 1f);

	private static readonly Color EyeColor = new Color(1f, 0.82f, 0.2f);

	private static readonly Quaternion RightArmIdle = Quaternion.Euler(-35f, 0f, 12f);

	private static readonly Quaternion RightArmRitual = Quaternion.Euler(-100f, 0f, 8f);

	private static readonly Quaternion LeftArmIdle = Quaternion.Euler(-20f, 0f, -10f);

	private static readonly Quaternion LeftArmRitual = Quaternion.Euler(-110f, 0f, -30f);

	private static Shader litShader;

	private static readonly Dictionary<string, Material> materials = new Dictionary<string, Material>();

	public Transform Eye;

	private Transform enemyRoot;

	private Transform rightArm;

	private Transform leftArm;

	private Transform staff;

	private Transform orb;

	private Transform runes;

	private Transform runesInner;

	private Light orbLight;

	private Component hdLightData;

	private PropertyInfo hdIntensity;

	private Vector3 lastRootPosition;

	private float yaw;

	private float desiredYaw;

	private float ritualBlend;

	private float burst;

	private float phase;

	public static WizardModel Build(Transform enemyRoot)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("WizardVisual");
		val.transform.SetParent(enemyRoot, false);
		val.transform.localScale = Vector3.one * 0.9f;
		WizardModel wizardModel = val.AddComponent<WizardModel>();
		wizardModel.enemyRoot = enemyRoot;
		wizardModel.lastRootPosition = enemyRoot.position;
		wizardModel.yaw = enemyRoot.eulerAngles.y;
		wizardModel.desiredYaw = wizardModel.yaw;
		wizardModel.phase = Random.Range(0f, 100f);
		wizardModel.BuildBody();
		wizardModel.BuildRuneCircle();
		return wizardModel;
	}

	public void Burst()
	{
		burst = 1f;
	}

	public void Animate(bool inRitual, bool hasTarget, Vector3 target)
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: 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_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		float deltaTime = Time.deltaTime;
		float num = Time.time + phase;
		ritualBlend = Mathf.MoveTowards(ritualBlend, inRitual ? 1f : 0f, deltaTime * 3f);
		float num2 = Mathf.SmoothStep(0f, 1f, ritualBlend);
		burst = Mathf.MoveTowards(burst, 0f, deltaTime * 1.5f);
		Vector3 position = enemyRoot.position;
		Vector3 val = position - lastRootPosition;
		val.y = 0f;
		lastRootPosition = position;
		if (hasTarget)
		{
			Vector3 val2 = target - position;
			if (val2.x * val2.x + val2.z * val2.z > 0.01f)
			{
				desiredYaw = Mathf.Atan2(val2.x, val2.z) * 57.29578f;
			}
		}
		else if (deltaTime > 0f && ((Vector3)(ref val)).magnitude / deltaTime > 0.3f)
		{
			desiredYaw = Mathf.Atan2(val.x, val.z) * 57.29578f;
		}
		yaw = Mathf.MoveTowardsAngle(yaw, desiredYaw, 220f * deltaTime);
		float num3 = 0.06f + Mathf.Sin(num * 1.6f) * 0.04f + num2 * 0.15f;
		((Component)this).transform.position = position + Vector3.up * num3;
		((Component)this).transform.rotation = Quaternion.Euler(Mathf.Sin(num * 1.1f) * 2f, yaw, Mathf.Sin(num * 0.9f) * 2.5f);
		rightArm.localRotation = Quaternion.Slerp(RightArmIdle, RightArmRitual, num2) * Quaternion.Euler(Mathf.Sin(num * 1.3f) * 3f, 0f, 0f);
		leftArm.localRotation = Quaternion.Slerp(LeftArmIdle, LeftArmRitual, num2) * Quaternion.Euler(Mathf.Sin(num * 1.3f + 1f) * 4f, 0f, 0f);
		staff.localRotation = Quaternion.Inverse(rightArm.localRotation);
		float num4 = 1f + Mathf.Sin(num * 5f) * 0.12f;
		orb.localScale = Vector3.one * 0.16f * (num4 + num2 * 0.35f + burst * 0.6f);
		SetLightIntensity(Mathf.Lerp(250f, 2500f, num2) * num4 + burst * 12000f);
		orbLight.range = Mathf.Lerp(6f, 12f, Mathf.Max(num2, burst));
		bool flag = ritualBlend > 0.01f;
		if (((Component)runes).gameObject.activeSelf != flag)
		{
			((Component)runes).gameObject.SetActive(flag);
		}
		if (flag)
		{
			runes.localScale = Vector3.one * (num2 + burst * 0.15f);
			runes.localRotation = Quaternion.Euler(0f, num * 40f, 0f);
			runesInner.localRotation = Quaternion.Euler(0f, (0f - num) * 110f, 0f);
		}
	}

	private void BuildBody()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: 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_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: 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_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: 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_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_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: 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_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = ((Component)this).transform;
		Material val = Mat(RobeColor);
		Material val2 = Mat(TrimColor);
		Material val3 = Mat(SkinColor);
		Part(transform, "Robe", Frustum(0.5f, 0.17f, 1.32f, 24, 0f), val, new Vector3(0f, 0.02f, 0f), Quaternion.identity);
		Part(transform, "Hem", Frustum(0.515f, 0.495f, 0.07f, 24, 0f), val2, new Vector3(0f, 0.02f, 0f), Quaternion.identity);
		Part(transform, "Belt", Frustum(0.3f, 0.283f, 0.07f, 24, 0f), val2, new Vector3(0f, 0.84f, 0f), Quaternion.identity);
		Part(transform, "Mantle", Frustum(0.24f, 0.12f, 0.18f, 24, 0f), Mat(MantleColor), new Vector3(0f, 1.3f, 0f), Quaternion.identity);
		Primitive(transform, "Head", (PrimitiveType)0, val3, new Vector3(0f, 1.6f, 0f), Vector3.one * 0.3f, Quaternion.identity);
		Primitive(transform, "Nose", (PrimitiveType)0, val3, new Vector3(0f, 1.6f, 0.15f), new Vector3(0.06f, 0.07f, 0.12f), Quaternion.identity);
		Material mat = Glow(EyeColor, 3f);
		Primitive(transform, "EyeL", (PrimitiveType)0, mat, new Vector3(-0.06f, 1.64f, 0.125f), Vector3.one * 0.045f, Quaternion.identity);
		Primitive(transform, "EyeR", (PrimitiveType)0, mat, new Vector3(0.06f, 1.64f, 0.125f), Vector3.one * 0.045f, Quaternion.identity);
		Eye = Pivot(transform, "Eye", new Vector3(0f, 1.64f, 0.15f));
		Part(transform, "Beard", Frustum(0.12f, 0.015f, 0.55f, 16, -0.26f), Mat(BeardColor), new Vector3(0f, 1.56f, 0.09f), Quaternion.Euler(180f, 0f, 0f));
		BuildHat(transform, val2);
		BuildArms(transform, val, val2, val3);
	}

	private void BuildHat(Transform body, Material trim)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_00ce: 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_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		Material mat = Mat(RobeColor);
		Material mat2 = Glow(EyeColor, 2f);
		Part(body, "HatBrim", Frustum(0.36f, 0.33f, 0.025f, 28, 0f), mat, new Vector3(0f, 1.7f, 0f), Quaternion.identity);
		Part(body, "HatBand", Frustum(0.21f, 0.2f, 0.06f, 24, 0f), trim, new Vector3(0f, 1.725f, 0f), Quaternion.identity);
		Transform parent = Part(body, "HatLower", Frustum(0.205f, 0.14f, 0.3f, 20, -0.03f), mat, new Vector3(0f, 1.725f, 0f), Quaternion.identity);
		Transform parent2 = Part(parent, "HatMiddle", Frustum(0.14f, 0.075f, 0.27f, 16, -0.02f), mat, new Vector3(0f, 0.3f, -0.03f), Quaternion.Euler(-20f, 0f, 0f));
		Part(parent2, "HatTip", Frustum(0.075f, 0.004f, 0.25f, 12, -0.02f), mat, new Vector3(0f, 0.27f, -0.02f), Quaternion.Euler(-30f, 0f, 0f));
		Primitive(parent, "Star", (PrimitiveType)3, mat2, new Vector3(0f, 0.15f, 0.158f), Vector3.one * 0.045f, Quaternion.Euler(0f, 0f, 45f));
		Primitive(parent2, "Star", (PrimitiveType)3, mat2, new Vector3(0.08f, 0.12f, 0.07f), Vector3.one * 0.03f, Quaternion.Euler(0f, 50f, 45f));
	}

	private void BuildArms(Transform body, Material robe, Material trim, Material skin)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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_00e1: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01b0: Unknown result type (might be due to invalid IL or missing references)
		Material mat = Mat(WoodColor);
		rightArm = Pivot(body, "RightArm", new Vector3(0.22f, 1.36f, 0.02f));
		BuildSleeve(rightArm, robe, trim, skin);
		staff = Pivot(rightArm, "Staff", new Vector3(0f, -0.52f, 0f));
		Primitive(staff, "Shaft", (PrimitiveType)2, mat, new Vector3(0f, 0.1f, 0f), new Vector3(0.045f, 0.9f, 0.045f), Quaternion.identity);
		Vector3 val = default(Vector3);
		for (int i = 0; i < 3; i++)
		{
			float num = (float)i * 120f * ((float)Math.PI / 180f);
			((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num));
			Quaternion localRotation = Quaternion.AngleAxis(25f, Vector3.Cross(Vector3.up, val));
			Primitive(staff, "Prong", (PrimitiveType)2, mat, new Vector3(0f, 1.03f, 0f) + val * 0.06f, new Vector3(0.018f, 0.07f, 0.018f), localRotation);
		}
		orb = Primitive(staff, "Orb", (PrimitiveType)0, Glow(ArcaneColor, 4f), new Vector3(0f, 1.1f, 0f), Vector3.one * 0.16f, Quaternion.identity);
		CreateOrbLight();
		leftArm = Pivot(body, "LeftArm", new Vector3(-0.22f, 1.36f, 0.02f));
		BuildSleeve(leftArm, robe, trim, skin);
	}

	private static void BuildSleeve(Transform arm, Material robe, Material trim, Material skin)
	{
		//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_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		Quaternion localRotation = Quaternion.Euler(180f, 0f, 0f);
		Part(arm, "Sleeve", Frustum(0.065f, 0.12f, 0.5f, 16, 0f), robe, Vector3.zero, localRotation);
		Part(arm, "Cuff", Frustum(0.122f, 0.124f, 0.04f, 16, 0f), trim, new Vector3(0f, -0.46f, 0f), localRotation);
		Primitive(arm, "Hand", (PrimitiveType)0, skin, new Vector3(0f, -0.52f, 0f), Vector3.one * 0.09f, Quaternion.identity);
	}

	private void BuildRuneCircle()
	{
		//IL_001b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: 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_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)
		runes = Pivot(enemyRoot, "RuneCircle", new Vector3(0f, 0.03f, 0f));
		Material mat = Glow(ArcaneColor, 3f);
		Part(runes, "OuterRing", Ring(1.5f, 1.6f, 64), mat, Vector3.zero, Quaternion.identity);
		runesInner = Pivot(runes, "Inner", Vector3.zero);
		Part(runesInner, "InnerRing", Ring(1.12f, 1.18f, 64), mat, Vector3.zero, Quaternion.identity);
		Vector3[] array = (Vector3[])(object)new Vector3[5];
		for (int i = 0; i < 5; i++)
		{
			float num = (90f + 72f * (float)i) * ((float)Math.PI / 180f);
			ref Vector3 reference = ref array[i];
			reference = new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * 1.1f;
		}
		for (int j = 0; j < 5; j++)
		{
			Vector3 val = array[j];
			Vector3 val2 = array[(j + 2) % 5];
			Primitive(runesInner, "StarLine", (PrimitiveType)3, mat, (val + val2) * 0.5f, new Vector3(0.05f, 0.01f, Vector3.Distance(val, val2)), Quaternion.LookRotation(val2 - val));
		}
		((Component)runes).gameObject.SetActive(false);
	}

	private void CreateOrbLight()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("OrbLight");
		val.transform.SetParent(orb, false);
		orbLight = val.AddComponent<Light>();
		orbLight.type = (LightType)2;
		orbLight.color = ArcaneColor;
		orbLight.range = 6f;
		orbLight.shadows = (LightShadows)0;
		Type type = Type.GetType("UnityEngine.Rendering.HighDefinition.HDAdditionalLightData, Unity.RenderPipelines.HighDefinition.Runtime");
		if (type != null)
		{
			hdLightData = val.AddComponent(type);
			hdIntensity = type.GetProperty("intensity", BindingFlags.Instance | BindingFlags.Public);
		}
		SetLightIntensity(250f);
	}

	private void SetLightIntensity(float lumens)
	{
		if (hdIntensity != null && (Object)(object)hdLightData != (Object)null)
		{
			try
			{
				hdIntensity.SetValue(hdLightData, lumens, null);
				return;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Falling back to plain light intensity: " + ex.Message));
				hdIntensity = null;
			}
		}
		orbLight.intensity = lumens;
	}

	private static Material Mat(Color color)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return GetMaterial(color, Color.black);
	}

	private static Material Glow(Color color, float strength)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: 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)
		return GetMaterial(color, color * strength);
	}

	private unsafe static Material GetMaterial(Color color, Color emission)
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		string key = ((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).ToString() + ((object)(*(Color*)(&emission))/*cast due to .constrained prefix*/).ToString();
		if (materials.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
		{
			return value;
		}
		if ((Object)(object)litShader == (Object)null)
		{
			litShader = Shader.Find("HDRP/Lit");
		}
		if ((Object)(object)litShader != (Object)null)
		{
			value = new Material(litShader);
		}
		else
		{
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			value = new Material(val.GetComponent<Renderer>().sharedMaterial);
			Object.Destroy((Object)(object)val);
		}
		((Object)value).name = "Houndcaller_" + materials.Count;
		value.SetColor("_BaseColor", color);
		value.SetColor("_Color", color);
		value.SetFloat("_Smoothness", 0.15f);
		if (((Color)(ref emission)).maxColorComponent > 0f)
		{
			value.SetColor("_EmissiveColor", emission);
			value.SetFloat("_EmissiveExposureWeight", 0f);
			value.EnableKeyword("_EMISSION");
		}
		materials[key] = value;
		return value;
	}

	private static Transform Pivot(Transform parent, string name, Vector3 localPosition)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.layer = 19;
		val.transform.SetParent(parent, false);
		val.transform.localPosition = localPosition;
		return val.transform;
	}

	private static Transform Part(Transform parent, string name, Mesh mesh, Material mat, Vector3 localPosition, Quaternion localRotation)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		Transform val = Pivot(parent, name, localPosition);
		val.localRotation = localRotation;
		((Component)val).gameObject.AddComponent<MeshFilter>().sharedMesh = mesh;
		((Renderer)((Component)val).gameObject.AddComponent<MeshRenderer>()).sharedMaterial = mat;
		return val;
	}

	private static Transform Primitive(Transform parent, string name, PrimitiveType type, Material mat, Vector3 localPosition, Vector3 localScale, Quaternion localRotation)
	{
		//IL_0000: 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_0041: 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)
		GameObject val = GameObject.CreatePrimitive(type);
		Object.DestroyImmediate((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = name;
		val.layer = 19;
		val.transform.SetParent(parent, false);
		val.transform.localPosition = localPosition;
		val.transform.localRotation = localRotation;
		val.transform.localScale = localScale;
		((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = mat;
		return val.transform;
	}

	private static Mesh Frustum(float bottomRadius, float topRadius, float height, int segments, float topOffsetZ)
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: 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)
		List<Vector3> list = new List<Vector3>();
		List<Vector3> list2 = new List<Vector3>();
		List<int> list3 = new List<int>();
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(0f, height, topOffsetZ);
		Vector3 val2 = default(Vector3);
		for (int i = 0; i <= segments; i++)
		{
			float num = (float)i * (float)Math.PI * 2f / (float)segments;
			((Vector3)(ref val2))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num));
			Vector3 val3 = val2 * height + Vector3.up * (bottomRadius - topRadius);
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			list.Add(val2 * bottomRadius);
			list2.Add(normalized);
			list.Add(val + val2 * topRadius);
			list2.Add(normalized);
		}
		for (int j = 0; j < segments; j++)
		{
			int num2 = j * 2;
			list3.Add(num2);
			list3.Add(num2 + 1);
			list3.Add(num2 + 2);
			list3.Add(num2 + 2);
			list3.Add(num2 + 1);
			list3.Add(num2 + 3);
		}
		AddCap(list, list2, list3, Vector3.zero, bottomRadius, segments, facesUp: false);
		AddCap(list, list2, list3, val, topRadius, segments, facesUp: true);
		return FinishMesh(list, list2, list3);
	}

	private static void AddCap(List<Vector3> verts, List<Vector3> normals, List<int> tris, Vector3 center, float radius, int segments, bool facesUp)
	{
		//IL_0015: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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)
		if (!(radius < 0.01f))
		{
			Vector3 item = (facesUp ? Vector3.up : Vector3.down);
			int count = verts.Count;
			verts.Add(center);
			normals.Add(item);
			for (int i = 0; i <= segments; i++)
			{
				float num = (float)i * (float)Math.PI * 2f / (float)segments;
				verts.Add(center + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * radius);
				normals.Add(item);
			}
			for (int j = 0; j < segments; j++)
			{
				tris.Add(count);
				tris.Add(facesUp ? (count + 2 + j) : (count + 1 + j));
				tris.Add(facesUp ? (count + 1 + j) : (count + 2 + j));
			}
		}
	}

	private static Mesh Ring(float innerRadius, float outerRadius, int segments)
	{
		//IL_0044: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: 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)
		List<Vector3> list = new List<Vector3>();
		List<Vector3> list2 = new List<Vector3>();
		List<int> list3 = new List<int>();
		Vector3 val = default(Vector3);
		for (int i = 0; i <= segments; i++)
		{
			float num = (float)i * (float)Math.PI * 2f / (float)segments;
			((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num));
			list.Add(val * innerRadius);
			list2.Add(Vector3.up);
			list.Add(val * outerRadius);
			list2.Add(Vector3.up);
		}
		for (int j = 0; j < segments; j++)
		{
			int num2 = j * 2;
			list3.Add(num2);
			list3.Add(num2 + 3);
			list3.Add(num2 + 1);
			list3.Add(num2);
			list3.Add(num2 + 2);
			list3.Add(num2 + 3);
		}
		return FinishMesh(list, list2, list3);
	}

	private static Mesh FinishMesh(List<Vector3> verts, List<Vector3> normals, List<int> tris)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		Mesh val = new Mesh();
		((Object)val).name = "HoundcallerMesh";
		val.SetVertices(verts);
		val.SetNormals(normals);
		val.SetTriangles(tris, 0);
		val.RecalculateBounds();
		return val;
	}
}