Decompiled source of LCChickenJockeyMod v1.1.0

LCChickenJockeyMod.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[CreateAssetMenu(menuName = "LCChickenJockeyMod/AllAssets")]
public class AllAssets : ScriptableObject
{
	public EnemyType[] allEnemies;

	[Space(3f)]
	public TerminalNode[] allBestiaryPages;

	[Space(3f)]
	public TerminalKeyword[] allKeywords;

	[Space(3f)]
	public GameObject[] allNetworkPrefabs;
}
public class ChickenJockeyScript : EnemyAI
{
	private static ManualLogSource Logger;

	private Vector3 lastPos;

	private float movedSinceLastPos;

	private float animTimerMoving;

	private float animTimerLooking;

	private bool inHurtAnim;

	private float hurtTimer;

	private float timeLastAttacking;

	private float timeLastSeeingPlayer;

	private float timeIdleResting;

	private int nodesSearched;

	private int nextNodesToSearch;

	private float nextRestTime;

	private Material[] matsSetOnHurt;

	private static int groundedLayerMask = -1;

	[Space(5f)]
	[Header("CHICKEN JOCKEY")]
	[Header("Parameters")]
	public float[] movementSpeeds;

	public float[] syncSpeeds;

	[Space(3f)]
	[Header("Audiovisual")]
	public Transform feetOrigin;

	public DualAnimator dualAnimator;

	public AudioSource chickenAudio;

	[Space]
	public AudioClip minecraftHurtSFX;

	public AudioClip minecraftDeathSFX;

	public AudioClip[] chickenHurtSFX;

	public AudioClip memeSFX;

	[Space(3f)]
	[Header("Looking")]
	public Transform chickenHeadMount;

	private int chickenIdleLookingOffset;

	private float chickenIdleLookingTimer;

	[Space]
	public Transform zombieHeadMount;

	private int zombieIdleLookingOffset;

	private float zombieIdleLookingTimer;

	[Space]
	public Transform tempLooker;

	public Transform tempRotator;

	public Transform tempTarget;

	public override void Start()
	{
		//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)
		((EnemyAI)this).Start();
		lastPos = ((Component)this).transform.position;
		matsSetOnHurt = (Material[])(object)new Material[base.skinnedMeshRenderers.Length];
		for (int i = 0; i < matsSetOnHurt.Length; i++)
		{
			matsSetOnHurt[i] = ((Renderer)base.skinnedMeshRenderers[i]).material;
		}
		if (groundedLayerMask == -1)
		{
			GetGroundedLayerMask();
		}
		if (Plugin.GetConfigValueBool("Say The Line, Jack"))
		{
			PlayAudio(memeSFX, chickenAudio, 25f, 1f);
		}
		if (((NetworkBehaviour)this).IsServer)
		{
			SyncHpServerRpc(Mathf.Max(1, Plugin.GetConfigValueInt("Enemy HP")));
		}
	}

	public override void Update()
	{
		((EnemyAI)this).Update();
		if (base.isEnemyDead || !base.ventAnimationFinished)
		{
			return;
		}
		DoSyncSpeedCheck();
		DoAnimationCheck();
		if (inHurtAnim)
		{
			if (hurtTimer > 0f)
			{
				hurtTimer -= Time.deltaTime;
			}
			else
			{
				ToggleHurt(setTo: false);
			}
		}
		if (base.currentBehaviourStateIndex != 0 || !((NetworkBehaviour)this).IsOwner)
		{
			return;
		}
		if (!base.currentSearch.inProgress)
		{
			timeIdleResting += Time.deltaTime;
			if (timeIdleResting > nextRestTime)
			{
				StartIdleSearch();
			}
		}
		else
		{
			timeIdleResting = 0f;
		}
	}

	public override void DoAIInterval()
	{
		((EnemyAI)this).DoAIInterval();
		if (base.isEnemyDead || !base.ventAnimationFinished)
		{
			return;
		}
		DoMovementCheck();
		float num = ((base.currentBehaviourStateIndex == 1) ? 4 : (-1));
		PlayerControllerB[] allPlayersInLineOfSight = ((EnemyAI)this).GetAllPlayersInLineOfSight(50f, 35, base.eye, num, -1);
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
		{
			PlayerControllerB val = null;
			if (allPlayersInLineOfSight != null && allPlayersInLineOfSight.Length != 0)
			{
				val = GetClosestOfSeenPlayers(allPlayersInLineOfSight);
			}
			if ((Object)(object)val != (Object)null)
			{
				StartChasingPlayer(val);
			}
			break;
		}
		case 1:
			StopIdleSearch();
			if (HasLostPlayer())
			{
				SetTarget(null);
				((EnemyAI)this).SwitchToBehaviourState(0);
			}
			else
			{
				if (!((Object)(object)base.targetPlayer != (Object)null))
				{
					break;
				}
				((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
				if (allPlayersInLineOfSight == null || allPlayersInLineOfSight.Length == 0)
				{
					break;
				}
				for (int i = 0; i < allPlayersInLineOfSight.Length; i++)
				{
					if ((Object)(object)allPlayersInLineOfSight[i] == (Object)(object)base.targetPlayer)
					{
						timeLastSeeingPlayer = Time.realtimeSinceStartup;
					}
				}
			}
			break;
		}
	}

	private void StartIdleSearch()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		if (!base.currentSearch.inProgress)
		{
			nextRestTime = 0f;
			nodesSearched = 0;
			nextNodesToSearch = Random.Range(3, 11);
			((EnemyAI)this).StartSearch(((Component)this).transform.position, base.currentSearch);
			Logger.LogDebug((object)$"{((Object)this).name} #{((NetworkBehaviour)this).NetworkObjectId}: StartIdleSearch(nextNodesToSearch = {nextNodesToSearch})");
		}
	}

	public override void ReachedNodeInSearch()
	{
		((EnemyAI)this).ReachedNodeInSearch();
		if (base.currentSearch.inProgress)
		{
			nodesSearched++;
			if (nodesSearched >= nextNodesToSearch)
			{
				StartIdleRest();
			}
		}
	}

	private void StartIdleRest()
	{
		nextRestTime = Random.Range(2f, 15f);
		Logger.LogDebug((object)$"{((Object)this).name} #{((NetworkBehaviour)this).NetworkObjectId}: StartIdleRest(nextRestTime = {nextRestTime})");
		StopIdleSearch();
	}

	private void StopIdleSearch()
	{
		if (base.currentSearch.inProgress)
		{
			nodesSearched = 0;
			((EnemyAI)this).StopSearch(base.currentSearch, true);
			Logger.LogDebug((object)$"{((Object)this).name} #{((NetworkBehaviour)this).NetworkObjectId}: StopIdleSearch()");
		}
	}

	private void StartChasingPlayer(PlayerControllerB playerToChase)
	{
		if (base.currentBehaviourStateIndex != 1)
		{
			Logger.LogInfo((object)$"chasing {playerToChase}!");
			SetTarget(playerToChase);
			((EnemyAI)this).SwitchToBehaviourState(1);
			((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
		}
	}

	private PlayerControllerB GetClosestOfSeenPlayers(PlayerControllerB[] seenPlayers)
	{
		//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)
		PlayerControllerB result = null;
		if (seenPlayers == null || seenPlayers.Length == 0)
		{
			return result;
		}
		base.tempDist = 35f;
		foreach (PlayerControllerB val in seenPlayers)
		{
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
			if (num < base.tempDist)
			{
				base.tempDist = num;
				result = val;
			}
		}
		return result;
	}

	public override void OnCollideWithPlayer(Collider other)
	{
		//IL_0036: 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_0046: 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_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_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)
		((EnemyAI)this).OnCollideWithPlayer(other);
		PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
		if ((Object)(object)val != (Object)null && Time.realtimeSinceStartup - timeLastAttacking > 1f)
		{
			Vector3 val2 = Vector3.Normalize(((Component)val).transform.position - ((Component)this).transform.position) * 7.5f + Vector3.up * 15f;
			val.DamagePlayer(5, false, true, (CauseOfDeath)6, 0, false, val2);
			val.externalForceAutoFade += val2;
			DoPlayerCollisionLocal(val);
			DoPlayerCollisionServerRpc((int)val.playerClientId);
		}
	}

	[ServerRpc(RequireOwnership = false)]
	private void DoPlayerCollisionServerRpc(int sentBy)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: 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)
		//IL_006d: 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_0089: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3707347206u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, sentBy);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3707347206u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				DoPlayerCollisionClientRpc(sentBy);
			}
		}
	}

	[ClientRpc]
	private void DoPlayerCollisionClientRpc(int sentBy)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: 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)
		//IL_006d: 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_0089: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3218605476u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, sentBy);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3218605476u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (sentBy != (int)StartOfRound.Instance.localPlayerController.playerClientId)
			{
				DoPlayerCollisionLocal(StartOfRound.Instance.allPlayerScripts[sentBy]);
			}
		}
	}

	private void DoPlayerCollisionLocal(PlayerControllerB collidedPlayer)
	{
		timeLastAttacking = Time.realtimeSinceStartup;
		if (!((Object)(object)collidedPlayer == (Object)null))
		{
			dualAnimator.TwoSetTrigger("Attack");
			PlayAudio(minecraftHurtSFX, collidedPlayer.movementAudio, 5f);
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.targetPlayer == (Object)null)
			{
				StartChasingPlayer(collidedPlayer);
			}
			if (Plugin.GetConfigValueBool("OOF.mp3") && collidedPlayer.isPlayerDead)
			{
				PlayAudio(minecraftDeathSFX, chickenAudio);
			}
		}
	}

	private void SetTarget(PlayerControllerB newTargetPlayer)
	{
		if ((Object)(object)newTargetPlayer == (Object)null)
		{
			SetTargetLocal(null);
			SetTargetServerRpc(-1);
		}
		else
		{
			SetTargetLocal(newTargetPlayer);
			SetTargetServerRpc((int)newTargetPlayer.playerClientId);
		}
	}

	[ServerRpc(RequireOwnership = false)]
	private void SetTargetServerRpc(int targetID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: 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)
		//IL_006d: 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_0089: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2303263789u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, targetID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2303263789u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				SetTargetClientRpc(targetID);
			}
		}
	}

	[ClientRpc]
	private void SetTargetClientRpc(int targetID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: 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)
		//IL_006d: 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_0089: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2049702024u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, targetID);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2049702024u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (targetID < 0 || targetID >= StartOfRound.Instance.allPlayerScripts.Length)
			{
				SetTargetLocal(null);
			}
			else
			{
				SetTargetLocal(StartOfRound.Instance.allPlayerScripts[targetID]);
			}
		}
	}

	private void SetTargetLocal(PlayerControllerB newTargetPlayer)
	{
		base.targetPlayer = newTargetPlayer;
		Logger.LogDebug((object)$"SetTargetLocal(): {base.targetPlayer}");
		if ((Object)(object)base.targetPlayer != (Object)null)
		{
			timeLastSeeingPlayer = Time.realtimeSinceStartup;
		}
	}

	public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
		((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
		if (hurtTimer > 0f || force == 0 || !base.ventAnimationFinished || base.isEnemyDead)
		{
			return;
		}
		base.enemyHP -= force;
		ToggleHurt(setTo: true);
		if (base.enemyHP <= 0)
		{
			((EnemyAI)this).KillEnemyOnOwnerClient(false);
			return;
		}
		PlayAudio(chickenHurtSFX[Random.Range(0, chickenHurtSFX.Length)], chickenAudio, 15f, 0.8f);
		if ((Object)(object)playerWhoHit != (Object)null)
		{
			StartChasingPlayer(playerWhoHit);
		}
	}

	public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
	{
		((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer);
		if ((Object)(object)setStunnedByPlayer != (Object)null)
		{
			StartChasingPlayer(setStunnedByPlayer);
		}
	}

	public override void KillEnemy(bool destroy = false)
	{
		((EnemyAI)this).KillEnemy(destroy);
		PlayAudio(chickenHurtSFX[Random.Range(0, chickenHurtSFX.Length)], chickenAudio, 25f, 1f);
	}

	private void PlayAudio(AudioClip playClip, AudioSource fromSource, float noiseRange = -1f, float noiseLoudness = 0.33f)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)playClip == (Object)null) && !((Object)(object)fromSource == (Object)null))
		{
			fromSource.PlayOneShot(playClip);
			WalkieTalkie.TransmitOneShotAudio(fromSource, playClip, 1f);
			if (noiseRange > 0f)
			{
				RoundManager.Instance.PlayAudibleNoise(((Component)fromSource).transform.position, noiseRange, noiseLoudness, 0, false, 0);
			}
		}
	}

	private void ToggleHurt(bool setTo)
	{
		//IL_003c: 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)
		inHurtAnim = setTo;
		hurtTimer = (inHurtAnim ? 0.5f : 0f);
		for (int i = 0; i < matsSetOnHurt.Length; i++)
		{
			matsSetOnHurt[i].color = (inHurtAnim ? Color.red : Color.white);
		}
		if (inHurtAnim)
		{
			dualAnimator.DualSetTrigger("Hurt");
			base.agent.speed = 0f;
		}
	}

	private void DoMovementCheck()
	{
		if (IsResting() || inHurtAnim || base.stunNormalizedTimer > 0f)
		{
			base.agent.speed = 0f;
		}
		else
		{
			base.agent.speed = movementSpeeds[base.currentBehaviourStateIndex];
		}
	}

	private void DoSyncSpeedCheck()
	{
		base.syncMovementSpeed = syncSpeeds[base.currentBehaviourStateIndex];
	}

	private void DoAnimationCheck()
	{
		if (animTimerLooking > 0f)
		{
			animTimerLooking -= Time.deltaTime;
		}
		else
		{
			animTimerLooking = 0.01f;
			AnimateLooking();
		}
		if (animTimerMoving > 0f)
		{
			animTimerMoving -= Time.deltaTime;
		}
		else
		{
			animTimerMoving = 0.33f;
			DoDistanceMovedCheck();
			IsInAir();
		}
		AnimateMovement();
	}

	private void AnimateMovement()
	{
		if (base.hitsPhysicsObjects)
		{
			base.creatureAnimator.SetTrigger("ChickenFlapping");
		}
		else if (movedSinceLastPos < 0.1f)
		{
			if (IsResting())
			{
				base.creatureAnimator.SetTrigger("ChickenIdle");
			}
		}
		else
		{
			base.creatureAnimator.SetTrigger("ChickenWalking");
			dualAnimator.OneSetFloat("WalkingSpeed", movedSinceLastPos);
		}
	}

	private void AnimateLooking()
	{
		//IL_001f: 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)
		if ((Object)(object)base.targetPlayer != (Object)null)
		{
			base.targetNode.position = base.targetPlayer.playerEye.position;
			base.favoriteSpot.position = base.targetPlayer.playerEye.position;
			RotateHeadMount(chickenHeadMount, base.targetNode, snapToAngle: true);
			RotateHeadMount(zombieHeadMount, base.favoriteSpot, snapToAngle: true);
		}
		else
		{
			ChickenIdleLooking();
			ZombieIdleLooking();
		}
	}

	private void ChickenIdleLooking()
	{
		//IL_0043: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_00f2: 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_008f: Unknown result type (might be due to invalid IL or missing references)
		if (!IsResting() || (chickenIdleLookingTimer > 0f && chickenIdleLookingOffset == 0))
		{
			chickenIdleLookingTimer -= 0.025f;
			ResetHeadMount(chickenHeadMount);
			return;
		}
		Vector3 cleanVector = GetCleanVector3(chickenHeadMount.localEulerAngles);
		chickenIdleLookingTimer = 2.5f;
		if (chickenIdleLookingOffset == 0)
		{
			SetNewLookingOffset(forChicken: true);
		}
		else if ((chickenIdleLookingOffset < 0 && cleanVector.y <= (float)chickenIdleLookingOffset) || (chickenIdleLookingOffset > 0 && cleanVector.y >= (float)chickenIdleLookingOffset))
		{
			if (chickenIdleLookingOffset < 0)
			{
				chickenIdleLookingOffset++;
			}
			else
			{
				chickenIdleLookingOffset--;
			}
		}
		else
		{
			tempRotator.position = chickenHeadMount.position;
			tempRotator.localEulerAngles = new Vector3(0f, (float)chickenIdleLookingOffset, 0f);
			base.targetNode.position = tempTarget.position;
			RotateHeadMount(chickenHeadMount, base.targetNode, snapToAngle: false);
		}
	}

	private void ZombieIdleLooking()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		if (zombieIdleLookingTimer > 0f && zombieIdleLookingOffset == 0)
		{
			zombieIdleLookingTimer -= 0.025f;
			ResetHeadMount(zombieHeadMount);
			return;
		}
		Vector3 cleanVector = GetCleanVector3(zombieHeadMount.localEulerAngles);
		zombieIdleLookingTimer = 7.5f;
		if (zombieIdleLookingOffset == 0)
		{
			SetNewLookingOffset(forChicken: false);
		}
		else if ((zombieIdleLookingOffset < 0 && cleanVector.y <= (float)zombieIdleLookingOffset) || (zombieIdleLookingOffset > 0 && cleanVector.y >= (float)zombieIdleLookingOffset))
		{
			if (zombieIdleLookingOffset < 0)
			{
				zombieIdleLookingOffset++;
			}
			else
			{
				zombieIdleLookingOffset--;
			}
		}
		else
		{
			tempRotator.position = zombieHeadMount.position;
			tempRotator.localEulerAngles = new Vector3(0f, (float)zombieIdleLookingOffset, 0f);
			base.favoriteSpot.position = tempTarget.position;
			RotateHeadMount(zombieHeadMount, base.favoriteSpot, snapToAngle: false);
		}
	}

	private void RotateHeadMount(Transform headMount, Transform lookTarget, bool snapToAngle)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_005b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: 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_00eb: 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)
		if ((Object)(object)headMount == (Object)null || (Object)(object)lookTarget == (Object)null)
		{
			return;
		}
		float num = 60f;
		tempLooker.position = headMount.position;
		tempLooker.LookAt(lookTarget);
		Vector3 cleanVector = GetCleanVector3(tempLooker.localEulerAngles);
		float num2 = Mathf.Clamp(cleanVector.x, num * -1f, num);
		float num3 = Mathf.Clamp(cleanVector.y, num * -1f, num);
		float num4 = Mathf.Clamp(cleanVector.z, num * -1f, num);
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(num2, num3, num4);
		if (snapToAngle)
		{
			SnapToAngle(headMount, val);
		}
		else
		{
			MoveToAngle(headMount, val);
		}
		if (((NetworkBehaviour)this).IsOwner && !((Object)(object)headMount != (Object)(object)chickenHeadMount) && IsResting())
		{
			float y = GetCleanVector3(chickenHeadMount.localEulerAngles).y;
			if (y > num * 0.9f)
			{
				((Component)this).transform.Rotate(Vector3.up, (Space)1);
				chickenIdleLookingOffset--;
			}
			else if (y < num * -0.9f)
			{
				((Component)this).transform.Rotate(Vector3.down, (Space)1);
				chickenIdleLookingOffset++;
			}
		}
	}

	private void ResetHeadMount(Transform ofTransform = null)
	{
		if ((Object)(object)ofTransform == (Object)null || (Object)(object)ofTransform == (Object)(object)chickenHeadMount)
		{
			MoveToZero(ofTransform);
		}
		if ((Object)(object)ofTransform == (Object)null || (Object)(object)ofTransform == (Object)(object)zombieHeadMount)
		{
			MoveToZero(ofTransform);
		}
	}

	private void SnapToAngle(Transform ofTransform, Vector3 snapToAngle)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)ofTransform == (Object)null))
		{
			ofTransform.localEulerAngles = snapToAngle;
		}
	}

	private void MoveToAngle(Transform ofTransform, Vector3 toLocalAngle)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: 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_0036: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_0093: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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_0114: 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_00dd: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//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_015e: 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_0127: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: 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_0171: 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_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)ofTransform == (Object)null) && !(toLocalAngle == Vector3.zero))
		{
			Vector3 cleanVector = GetCleanVector3(ofTransform.localEulerAngles);
			float num = 3.3f * (Time.deltaTime * 60f);
			if (toLocalAngle.z < 0f && cleanVector.z > toLocalAngle.z)
			{
				ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x, ofTransform.localEulerAngles.y, ofTransform.localEulerAngles.z - num);
			}
			else if (toLocalAngle.z > 0f && cleanVector.z < toLocalAngle.z)
			{
				ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x, ofTransform.localEulerAngles.y, ofTransform.localEulerAngles.z + num);
			}
			else if (toLocalAngle.y < 0f && cleanVector.y > toLocalAngle.y)
			{
				ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x, ofTransform.localEulerAngles.y - num, ofTransform.localEulerAngles.z);
			}
			else if (toLocalAngle.y > 0f && cleanVector.y < toLocalAngle.y)
			{
				ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x, ofTransform.localEulerAngles.y + num, ofTransform.localEulerAngles.z);
			}
			else if (toLocalAngle.x < 0f && cleanVector.x > toLocalAngle.x)
			{
				ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x - num, ofTransform.localEulerAngles.y, ofTransform.localEulerAngles.z);
			}
			else if (toLocalAngle.x > 0f && cleanVector.x < toLocalAngle.x)
			{
				ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x + num, ofTransform.localEulerAngles.y, ofTransform.localEulerAngles.z);
			}
		}
	}

	private void MoveToZero(Transform ofTransform)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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)
		//IL_0036: 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_0065: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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_0094: 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)
		//IL_00c5: 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)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: 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_0116: 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_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: 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_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: 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)
		if ((Object)(object)ofTransform == (Object)null)
		{
			return;
		}
		Vector3 cleanVector = GetCleanVector3(ofTransform.localEulerAngles);
		float num = 1f * (Time.deltaTime * 60f);
		if (cleanVector.z > 1f || cleanVector.z < -1f)
		{
			if (cleanVector.z > 0f)
			{
				num *= -1f;
			}
			ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x, ofTransform.localEulerAngles.y, ofTransform.localEulerAngles.z + num);
		}
		else if (cleanVector.x > 1f || cleanVector.x < -1f)
		{
			if (cleanVector.x > 0f)
			{
				num *= -1f;
			}
			ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x + num, ofTransform.localEulerAngles.y, ofTransform.localEulerAngles.z);
		}
		else if (cleanVector.y > 1f || cleanVector.y < -1f)
		{
			if (cleanVector.y > 0f)
			{
				num *= -1f;
			}
			ofTransform.localEulerAngles = new Vector3(ofTransform.localEulerAngles.x, ofTransform.localEulerAngles.y + num, ofTransform.localEulerAngles.z);
		}
		else if ((Object)(object)ofTransform == (Object)(object)chickenHeadMount)
		{
			base.targetNode.position = chickenHeadMount.position + ((Component)this).transform.forward * 3f;
		}
		else if ((Object)(object)ofTransform == (Object)(object)zombieHeadMount)
		{
			base.favoriteSpot.position = zombieHeadMount.position + ((Component)this).transform.forward * 3f;
		}
	}

	private void DoDistanceMovedCheck()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		movedSinceLastPos = Vector3.Distance(((Component)this).transform.position, lastPos);
		lastPos = ((Component)this).transform.position;
	}

	private void IsInAir()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_002b: 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)
		base.hitsPhysicsObjects = !Physics.Linecast(((Component)feetOrigin).transform.position, ((Component)feetOrigin).transform.position - Vector3.up * 1.33f, groundedLayerMask, (QueryTriggerInteraction)1);
	}

	private bool IsResting()
	{
		if (((NetworkBehaviour)this).IsOwner)
		{
			if (base.currentBehaviourStateIndex == 0 && nextRestTime > 0f)
			{
				return timeIdleResting < nextRestTime;
			}
			return false;
		}
		return movedSinceLastPos < 0.1f;
	}

	private bool HasLostPlayer()
	{
		if ((Object)(object)base.targetPlayer == (Object)null)
		{
			return true;
		}
		if (Time.realtimeSinceStartup - timeLastSeeingPlayer > 3f)
		{
			return true;
		}
		if (base.targetPlayer.isPlayerDead || base.targetPlayer.isInsideFactory == base.isOutside)
		{
			return true;
		}
		return false;
	}

	private Vector3 GetCleanVector3(Vector3 dirtyVector)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: 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)
		//IL_0058: 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_0067: Unknown result type (might be due to invalid IL or missing references)
		float num = ((dirtyVector.x > 180f) ? (dirtyVector.x - 360f) : dirtyVector.x);
		float num2 = ((dirtyVector.y > 180f) ? (dirtyVector.y - 360f) : dirtyVector.y);
		float num3 = ((dirtyVector.z > 180f) ? (dirtyVector.z - 360f) : dirtyVector.z);
		return new Vector3(num, num2, num3);
	}

	public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
	{
		//IL_0001: 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_0064: 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_0077: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
		if (((NetworkBehaviour)this).IsOwner && noiseID != 546 && noiseID != 75 && chickenIdleLookingOffset == 0 && base.currentBehaviourStateIndex != 1 && !(base.stunNormalizedTimer > 0f) && !base.isEnemyDead && base.ventAnimationFinished && !base.inSpecialAnimation)
		{
			int num = Mathf.RoundToInt(Vector3.Angle(((Component)this).transform.forward, noisePosition));
			if (((Component)this).transform.InverseTransformPoint(noisePosition).x < 0f)
			{
				num *= -1;
			}
			Logger.LogDebug((object)$"angleFromNoise: {num}");
			SetNewLookingOffset(forChicken: true, num);
		}
	}

	private void SetNewLookingOffset(bool forChicken, int overrideOffset = -999)
	{
		if (((NetworkBehaviour)this).IsOwner)
		{
			int num = ((overrideOffset == -999) ? Random.Range(-180, 181) : overrideOffset);
			if (num == 0)
			{
				num = 45;
			}
			num = Mathf.Clamp(num, forChicken ? (-170) : (-55), forChicken ? 171 : 56);
			SetNewLookingOffsetLocal(num, forChicken);
			SetNewLookingOffsetServerRpc((int)StartOfRound.Instance.localPlayerController.playerClientId, num, forChicken);
		}
	}

	[ServerRpc(RequireOwnership = false)]
	private void SetNewLookingOffsetServerRpc(int sentBy, int lookingOffset, bool forChicken)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Invalid comparison between Unknown and I4
		//IL_005f: 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)
		//IL_006d: 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_007e: 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_009d: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(201035104u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, sentBy);
				BytePacker.WriteValueBitPacked(val2, lookingOffset);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref forChicken, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 201035104u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				SetNewLookingOffsetClientRpc(sentBy, lookingOffset, forChicken);
			}
		}
	}

	[ClientRpc]
	private void SetNewLookingOffsetClientRpc(int sentBy, int lookingOffset, bool forChicken)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Invalid comparison between Unknown and I4
		//IL_005f: 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)
		//IL_006d: 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_007e: 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_009d: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4142849465u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, sentBy);
			BytePacker.WriteValueBitPacked(val2, lookingOffset);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref forChicken, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4142849465u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (sentBy != (int)StartOfRound.Instance.localPlayerController.playerClientId)
			{
				SetNewLookingOffsetLocal(lookingOffset, forChicken);
			}
		}
	}

	private void SetNewLookingOffsetLocal(int lookingOffset, bool forChicken)
	{
		if (forChicken)
		{
			chickenIdleLookingOffset = lookingOffset;
		}
		else
		{
			zombieIdleLookingOffset = lookingOffset;
		}
		Logger.LogDebug((object)$"SetNewLookingOffsetLocal(): forChicken? {forChicken} | chicken: {chickenIdleLookingOffset} & zombie: {zombieIdleLookingOffset}");
	}

	private void GetGroundedLayerMask()
	{
		groundedLayerMask = StartOfRound.Instance.collidersAndRoomMaskAndDefault;
		groundedLayerMask |= 1 << LayerMask.NameToLayer("Railing");
	}

	[ServerRpc(RequireOwnership = false)]
	private void SyncHpServerRpc(int hp)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: 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)
		//IL_006d: 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_0089: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2247810382u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hp);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2247810382u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				SyncHpClientRpc(hp);
			}
		}
	}

	[ClientRpc]
	private void SyncHpClientRpc(int hp)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: 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)
		//IL_006d: 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_0089: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(175893601u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hp);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 175893601u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.enemyHP = hp;
				Logger.LogDebug((object)$"enemyHP = {base.enemyHP}");
			}
		}
	}

	protected override void __initializeVariables()
	{
		((EnemyAI)this).__initializeVariables();
	}

	protected override void __initializeRpcs()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		((NetworkBehaviour)this).__registerRpc(3707347206u, new RpcReceiveHandler(__rpc_handler_3707347206), "DoPlayerCollisionServerRpc");
		((NetworkBehaviour)this).__registerRpc(3218605476u, new RpcReceiveHandler(__rpc_handler_3218605476), "DoPlayerCollisionClientRpc");
		((NetworkBehaviour)this).__registerRpc(2303263789u, new RpcReceiveHandler(__rpc_handler_2303263789), "SetTargetServerRpc");
		((NetworkBehaviour)this).__registerRpc(2049702024u, new RpcReceiveHandler(__rpc_handler_2049702024), "SetTargetClientRpc");
		((NetworkBehaviour)this).__registerRpc(201035104u, new RpcReceiveHandler(__rpc_handler_201035104), "SetNewLookingOffsetServerRpc");
		((NetworkBehaviour)this).__registerRpc(4142849465u, new RpcReceiveHandler(__rpc_handler_4142849465), "SetNewLookingOffsetClientRpc");
		((NetworkBehaviour)this).__registerRpc(2247810382u, new RpcReceiveHandler(__rpc_handler_2247810382), "SyncHpServerRpc");
		((NetworkBehaviour)this).__registerRpc(175893601u, new RpcReceiveHandler(__rpc_handler_175893601), "SyncHpClientRpc");
		((EnemyAI)this).__initializeRpcs();
	}

	private static void __rpc_handler_3707347206(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int sentBy = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref sentBy);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChickenJockeyScript)(object)target).DoPlayerCollisionServerRpc(sentBy);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3218605476(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int sentBy = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref sentBy);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChickenJockeyScript)(object)target).DoPlayerCollisionClientRpc(sentBy);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2303263789(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int targetServerRpc = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref targetServerRpc);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChickenJockeyScript)(object)target).SetTargetServerRpc(targetServerRpc);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2049702024(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int targetClientRpc = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref targetClientRpc);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChickenJockeyScript)(object)target).SetTargetClientRpc(targetClientRpc);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_201035104(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0049: 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_005e: 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)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int sentBy = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref sentBy);
			int lookingOffset = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref lookingOffset);
			bool forChicken = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref forChicken, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChickenJockeyScript)(object)target).SetNewLookingOffsetServerRpc(sentBy, lookingOffset, forChicken);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_4142849465(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0049: 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_005e: 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)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int sentBy = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref sentBy);
			int lookingOffset = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref lookingOffset);
			bool forChicken = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref forChicken, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChickenJockeyScript)(object)target).SetNewLookingOffsetClientRpc(sentBy, lookingOffset, forChicken);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2247810382(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int hp = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref hp);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChickenJockeyScript)(object)target).SyncHpServerRpc(hp);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_175893601(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int hp = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref hp);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((ChickenJockeyScript)(object)target).SyncHpClientRpc(hp);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "ChickenJockeyScript";
	}
}
public class DualAnimator : MonoBehaviour
{
	public Animator animator1;

	public Animator animator2;

	public void OneSetTrigger(string setToTrigger)
	{
		if ((Object)(object)animator1 != (Object)null)
		{
			animator1.SetTrigger(setToTrigger);
		}
	}

	public void OneSetBool(string boolName, bool setToBool)
	{
		if ((Object)(object)animator1 != (Object)null)
		{
			animator1.SetBool(boolName, setToBool);
		}
	}

	public void OneSetFloat(string floatName, float setToFloat)
	{
		if ((Object)(object)animator1 != (Object)null)
		{
			animator1.SetFloat(floatName, setToFloat);
		}
	}

	public void TwoSetTrigger(string setToTrigger)
	{
		if ((Object)(object)animator2 != (Object)null)
		{
			animator2.SetTrigger(setToTrigger);
		}
	}

	public void TwoSetBool(string boolName, bool setToBool)
	{
		if ((Object)(object)animator2 != (Object)null)
		{
			animator2.SetBool(boolName, setToBool);
		}
	}

	public void TwoSetFloat(string floatName, float setToFloat)
	{
		if ((Object)(object)animator2 != (Object)null)
		{
			animator2.SetFloat(floatName, setToFloat);
		}
	}

	public void DualSetTrigger(string setToTrigger)
	{
		if ((Object)(object)animator1 != (Object)null)
		{
			animator1.SetTrigger(setToTrigger);
		}
		if ((Object)(object)animator2 != (Object)null)
		{
			animator2.SetTrigger(setToTrigger);
		}
	}

	public void DualSetBool(string boolName, bool setToBool)
	{
		if ((Object)(object)animator1 != (Object)null)
		{
			animator1.SetBool(boolName, setToBool);
		}
		if ((Object)(object)animator2 != (Object)null)
		{
			animator2.SetBool(boolName, setToBool);
		}
	}

	public void DualSetFloat(string floatName, float setToFloat)
	{
		if ((Object)(object)animator1 != (Object)null)
		{
			animator1.SetFloat(floatName, setToFloat);
		}
		if ((Object)(object)animator2 != (Object)null)
		{
			animator2.SetFloat(floatName, setToFloat);
		}
	}
}
[BepInPlugin("local.SimonTendo.LCChickenJockeyMod", "LCChickenJockeyMod", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(QuickMenuManager))]
	public class ChickenJockeyQuickMenuManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Debug_SetEnemyDropdownOptions")]
		public static void Debug_SetEnemyDropdownOptionsPrefix(QuickMenuManager __instance)
		{
			EnemyType[] allEnemies = allAssets.allEnemies;
			for (int i = 0; i < allEnemies.Length; i++)
			{
				AddEnemyToDebugMenu(allEnemies[i], __instance);
			}
		}
	}

	[HarmonyPatch(typeof(NetworkManager))]
	public class ChickenJockeyNetworkManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetSingleton")]
		public static void SetSingletonPostfix()
		{
			if (allAssets.allNetworkPrefabs == null || allAssets.allNetworkPrefabs.Length == 0)
			{
				Logger.LogError((object)"allNetworkPrefabs is not valid, please fix");
				return;
			}
			for (int i = 0; i < allAssets.allNetworkPrefabs.Length; i++)
			{
				NetworkManager.Singleton.AddNetworkPrefab(allAssets.allNetworkPrefabs[i]);
			}
		}
	}

	[HarmonyPatch(typeof(Terminal))]
	public class ChickenJockeyTerminalPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void AwakePostfix(Terminal __instance)
		{
			List<TerminalKeyword> list = __instance.terminalNodes.allKeywords.ToList();
			list.AddRange(allAssets.allKeywords);
			__instance.terminalNodes.allKeywords = list.ToArray();
			Logger.LogDebug((object)$"updated allKeywords to Length {__instance.terminalNodes.allKeywords.Length}");
			AddEnemyFilesToTerminal(__instance);
		}
	}

	[HarmonyPatch(typeof(PlayerControllerB))]
	public class ChickenJockeyPlayerControllerBPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("ConnectClientToPlayerObject")]
		public static void ConnectClientToPlayerObjectPostfix()
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null && !setUp)
			{
				SetUpConfigs(StartOfRound.Instance);
				SetUpEnemy(StartOfRound.Instance);
				AddAllEnemyTypesToLevels(StartOfRound.Instance);
				setUp = true;
			}
		}
	}

	internal static ManualLogSource Logger;

	public static AssetBundle assetBundle;

	public static ConfigFile myConfig;

	public static Dictionary<string, ConfigEntry<bool>> boolConfigs = new Dictionary<string, ConfigEntry<bool>>();

	public static Dictionary<string, ConfigEntry<int>> intConfigs = new Dictionary<string, ConfigEntry<int>>();

	public static Dictionary<string, ConfigEntry<string>> stringConfigs = new Dictionary<string, ConfigEntry<string>>();

	public static AllAssets allAssets;

	public static bool setUp = false;

	private void Awake()
	{
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		Logger = ((BaseUnityPlugin)this).Logger;
		Logger.LogInfo((object)"Plugin LCChickenJockeyMod is loaded!");
		assetBundle = AssetBundle.LoadFromFile(Path.Combine(GetAssemblyLocation(), "chickenjockeybundle"));
		if ((Object)(object)assetBundle == (Object)null)
		{
			Logger.LogError((object)"Failed to load AssetBundle");
			return;
		}
		allAssets = assetBundle.LoadAsset<AllAssets>("Assets/LCChickenJockeyMod/ScriptableObjects/AllAssets.asset");
		if ((Object)(object)allAssets == (Object)null)
		{
			Logger.LogError((object)"Failed to load AllAssets");
			return;
		}
		Logger.LogDebug((object)"Successfully loaded AssetBundle");
		SendLoggers();
		new Harmony("LCChickenJockeyMod").PatchAll();
		myConfig = ((BaseUnityPlugin)this).Config;
		UnityNetcodePatcher();
	}

	private static void SendLoggers()
	{
		Type[] types = Assembly.GetExecutingAssembly().GetTypes();
		foreach (Type type in types)
		{
			FieldInfo[] fields = type.GetFields(BindingFlags.Static | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.FieldType == typeof(ManualLogSource))
				{
					fieldInfo.SetValue(type, Logger);
				}
			}
		}
	}

	private static void UnityNetcodePatcher()
	{
		Type[] types = Assembly.GetExecutingAssembly().GetTypes();
		for (int i = 0; i < types.Length; i++)
		{
			MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
				{
					methodInfo.Invoke(null, null);
				}
			}
		}
	}

	public static string GetAssemblyLocation()
	{
		return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
	}

	private static void SetUpConfigs(StartOfRound __instance)
	{
		if ((Object)(object)__instance == (Object)null || __instance.levels == null || __instance.levels.Length == 0)
		{
			return;
		}
		BindConfig("Memes", "Say The Line, Jack", defaultValue: false, "Have Jack Black say his iconic popcorn-tossing catchphrase.");
		BindConfig("Memes", "OOF.mp3", defaultValue: false, "Play the classic death sound from before Steve's vocal chords were taken from him.");
		BindConfig("General", "Enable Spawning", defaultValue: true, "Set if the Chicken Jockey can be added to levels as a spawnable enemy.\nHost's values are used.");
		BindConfig("General", "Enemy HP", 5, "Set how much health Chicken Jockeys have.\nHost's values are used.");
		BindConfig("General", "Max Count", 10, "Set how many Chicken Jockeys can spawn at most during a day.\nHost's values are used.");
		BindConfig("General", "Power Level", 1, "Set how much space Chicken Jockeys take up in a day's total enemy pool.\nThe higher, the fewer other enemies can spawn.\nHost's values are used.");
		BindConfig("General", "Invalid Levels", "71 Gordion;44 Liquidation", "The PlanetNames of all levels where the enemy should not be added as a spawnable enemy.\nSeparate planet names with a ; symbol.\nHost's values are used.");
		if (GetConfigValueBool("Enable Spawning"))
		{
			for (int i = 0; i < __instance.levels.Length; i++)
			{
				SelectableLevel val = __instance.levels[i];
				if (!((Object)(object)val == (Object)null) && LevelValidToSpawn(val))
				{
					int defaultValue = 50;
					switch (val.PlanetName)
					{
					case "41 Experimentation":
						defaultValue = 75;
						break;
					case "220 Assurance":
						defaultValue = 1;
						break;
					case "56 Vow":
						defaultValue = 44;
						break;
					case "61 March":
						defaultValue = 50;
						break;
					case "20 Adamance":
						defaultValue = 69;
						break;
					case "85 Rend":
						defaultValue = 64;
						break;
					case "7 Dine":
						defaultValue = 15;
						break;
					case "21 Offense":
						defaultValue = 25;
						break;
					case "8 Titan":
						defaultValue = 33;
						break;
					case "68 Artifice":
						defaultValue = 100;
						break;
					case "5 Embrion":
						defaultValue = 3;
						break;
					}
					BindConfig("Spawning", val.PlanetName, defaultValue, "Chance for the Chicken Jockey to spawn on " + val.PlanetName + ".\nHost's values are used.");
				}
			}
		}
		myConfig.Save();
	}

	public static void BindConfig(string categoryName, string configName, bool defaultValue, string configDescription)
	{
		if (!string.IsNullOrEmpty(categoryName) && !string.IsNullOrEmpty(configName))
		{
			ConfigEntry<bool> val = myConfig.Bind<bool>(categoryName, configName, defaultValue, configDescription);
			if (boolConfigs.TryAdd(configName, val))
			{
				Logger.LogDebug((object)$"Successfully bound Config \"{((ConfigEntryBase)val).Definition}\" with Value {val.Value}.");
				return;
			}
			Logger.LogWarning((object)$"Failed to add Config with categoryName \"{categoryName}\", configName \"{configName}\", defaultValue {defaultValue}, and configDescription \"{configDescription}\".");
		}
	}

	public static void BindConfig(string categoryName, string configName, int defaultValue, string configDescription)
	{
		if (!string.IsNullOrEmpty(categoryName) && !string.IsNullOrEmpty(configName))
		{
			ConfigEntry<int> val = myConfig.Bind<int>(categoryName, configName, defaultValue, configDescription);
			if (intConfigs.TryAdd(configName, val))
			{
				Logger.LogDebug((object)$"Successfully bound Config \"{((ConfigEntryBase)val).Definition}\" with Value {val.Value}.");
				return;
			}
			Logger.LogWarning((object)$"Failed to add Config with categoryName \"{categoryName}\", configName \"{configName}\", defaultValue {defaultValue}, and configDescription \"{configDescription}\".");
		}
	}

	public static void BindConfig(string categoryName, string configName, string defaultValue, string configDescription)
	{
		if (!string.IsNullOrEmpty(categoryName) && !string.IsNullOrEmpty(configName))
		{
			ConfigEntry<string> val = myConfig.Bind<string>(categoryName, configName, defaultValue, configDescription);
			if (stringConfigs.TryAdd(configName, val))
			{
				Logger.LogDebug((object)$"Successfully bound Config \"{((ConfigEntryBase)val).Definition}\" with Value {val.Value}.");
				return;
			}
			Logger.LogWarning((object)("Failed to add Config with categoryName \"" + categoryName + "\", configName \"" + configName + "\", defaultValue " + defaultValue + ", and configDescription \"" + configDescription + "\"."));
		}
	}

	public static bool GetConfigValueBool(string configName)
	{
		if (string.IsNullOrEmpty(configName))
		{
			return false;
		}
		ConfigEntry<bool> value = null;
		if (boolConfigs.TryGetValue(configName, out value))
		{
			return value.Value;
		}
		return false;
	}

	public static int GetConfigValueInt(string configName)
	{
		if (string.IsNullOrEmpty(configName))
		{
			return -1;
		}
		ConfigEntry<int> value = null;
		if (intConfigs.TryGetValue(configName, out value))
		{
			return value.Value;
		}
		return -1;
	}

	public static string GetConfigValueString(string configName)
	{
		if (string.IsNullOrEmpty(configName))
		{
			return string.Empty;
		}
		ConfigEntry<string> value = null;
		if (stringConfigs.TryGetValue(configName, out value))
		{
			return value.Value;
		}
		return string.Empty;
	}

	public static void SetUpEnemy(StartOfRound __instance)
	{
		Material mapDotMat = GetMapDotMat(__instance.levels[0].Enemies.ToArray());
		EnemyType[] allEnemies = allAssets.allEnemies;
		foreach (EnemyType val in allEnemies)
		{
			if (!((Object)(object)val == (Object)null))
			{
				val.MaxCount = Mathf.Max(1, GetConfigValueInt("Max Count"));
				val.PowerLevel = Mathf.Max(1, GetConfigValueInt("Power Level"));
				if ((Object)(object)mapDotMat != (Object)null)
				{
					AddMapDotMat(val, mapDotMat);
				}
			}
		}
	}

	public static void AddAllEnemyTypesToLevels(StartOfRound __instance)
	{
		if (!GetConfigValueBool("Enable Spawning"))
		{
			Logger.LogDebug((object)"not adding enemy: A");
			return;
		}
		for (int i = 0; i < allAssets.allEnemies.Length; i++)
		{
			EnemyType val = allAssets.allEnemies[i];
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			for (int j = 0; j < __instance.levels.Length; j++)
			{
				SelectableLevel val2 = __instance.levels[j];
				if (!((Object)(object)val2 == (Object)null))
				{
					AddEnemyToLevel(val, val2);
				}
			}
		}
	}

	private static void AddEnemyToLevel(EnemyType enemy, SelectableLevel level)
	{
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Expected O, but got Unknown
		if ((Object)(object)enemy == (Object)null || (Object)(object)level == (Object)null || string.IsNullOrEmpty(level.PlanetName))
		{
			return;
		}
		if (!LevelValidToSpawn(level))
		{
			Logger.LogDebug((object)("not adding enemy " + enemy.enemyName + " to level " + level.PlanetName + ": B"));
			return;
		}
		int configValueInt = GetConfigValueInt(level.PlanetName);
		if (configValueInt <= 0)
		{
			Logger.LogDebug((object)("not adding enemy " + enemy.enemyName + " to level " + level.PlanetName + ": C"));
			return;
		}
		SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity();
		val.enemyType = enemy;
		val.rarity = configValueInt;
		Logger.LogDebug((object)$"adding {val.enemyType.enemyName} to {level.PlanetName} with spawnChance {val.rarity}");
		if (enemy.isOutsideEnemy)
		{
			level.OutsideEnemies.Add(val);
		}
		else
		{
			level.Enemies.Add(val);
		}
	}

	private static bool LevelValidToSpawn(SelectableLevel level)
	{
		string configValueString = GetConfigValueString("Invalid Levels");
		if ((Object)(object)level == (Object)null || string.IsNullOrEmpty(level.PlanetName) || string.IsNullOrEmpty(configValueString))
		{
			return false;
		}
		configValueString = configValueString.ToLower();
		string[] array = configValueString.Split(';', StringSplitOptions.RemoveEmptyEntries);
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i] == level.PlanetName.ToLower())
			{
				return false;
			}
		}
		return true;
	}

	private static void AddEnemyToDebugMenu(EnemyType enemyToAdd, QuickMenuManager debugMenu)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		if ((Object)(object)enemyToAdd == (Object)null || (Object)(object)debugMenu == (Object)null)
		{
			return;
		}
		SelectableLevel testAllEnemiesLevel = debugMenu.testAllEnemiesLevel;
		if ((Object)(object)testAllEnemiesLevel == (Object)null)
		{
			return;
		}
		SpawnableEnemyWithRarity val = new SpawnableEnemyWithRarity();
		val.enemyType = enemyToAdd;
		val.rarity = 0;
		string arg = "Inside";
		if (enemyToAdd.isOutsideEnemy && testAllEnemiesLevel.OutsideEnemies != null && testAllEnemiesLevel.OutsideEnemies.Count > 0)
		{
			for (int i = 0; i < testAllEnemiesLevel.OutsideEnemies.Count; i++)
			{
				if ((Object)(object)testAllEnemiesLevel.OutsideEnemies[i].enemyType == (Object)(object)enemyToAdd)
				{
					Logger.LogDebug((object)$"not adding duplicate of {enemyToAdd}");
					return;
				}
			}
			debugMenu.testAllEnemiesLevel.OutsideEnemies.Add(val);
			arg = "Outside";
		}
		else if (!enemyToAdd.isOutsideEnemy && testAllEnemiesLevel.Enemies != null && testAllEnemiesLevel.Enemies.Count > 0)
		{
			for (int j = 0; j < testAllEnemiesLevel.Enemies.Count; j++)
			{
				if ((Object)(object)testAllEnemiesLevel.Enemies[j].enemyType == (Object)(object)enemyToAdd)
				{
					Logger.LogDebug((object)$"not adding duplicate of {enemyToAdd}");
					return;
				}
			}
			debugMenu.testAllEnemiesLevel.Enemies.Add(val);
		}
		Logger.LogDebug((object)$"added {enemyToAdd} to debug menu as {arg} enemy");
	}

	private static Material GetMapDotMat(SpawnableEnemyWithRarity[] enemies)
	{
		if (enemies == null || enemies.Length == 0)
		{
			Logger.LogWarning((object)"GetEnemyAssets() called with null enemies");
			return null;
		}
		foreach (SpawnableEnemyWithRarity val in enemies)
		{
			if (val == null || (Object)(object)val.enemyType == (Object)null)
			{
				return null;
			}
			EnemyType enemyType = val.enemyType;
			if (!((Object)(object)enemyType == (Object)null) && enemyType.enemyName != null && !((Object)(object)enemyType.enemyPrefab == (Object)null) && enemyType.enemyName == "Flowerman")
			{
				GameObject gameObject = ((Component)enemyType.enemyPrefab.transform.Find("MapDot (2)")).gameObject;
				if ((Object)(object)gameObject == (Object)null)
				{
					Logger.LogDebug((object)"no MapDot found");
					return null;
				}
				MeshRenderer component = gameObject.GetComponent<MeshRenderer>();
				if ((Object)(object)component == (Object)null || (Object)(object)((Renderer)component).material == (Object)null || ((Object)((Renderer)component).material).name == null)
				{
					Logger.LogDebug((object)"no meshRenderer or material found");
					return null;
				}
				string text = "MapDotRed (Instance)";
				if (((Object)((Renderer)component).material).name != text)
				{
					Logger.LogDebug((object)("meshRenderer material is not " + text));
					return null;
				}
				return ((Renderer)component).material;
			}
		}
		return null;
	}

	private static void AddMapDotMat(EnemyType enemyType, Material matToUse)
	{
		if ((Object)(object)enemyType == (Object)null || (Object)(object)enemyType.enemyPrefab == (Object)null)
		{
			Logger.LogWarning((object)"AddMapDotMat() called with null enemyType");
			return;
		}
		Transform val = enemyType.enemyPrefab.transform.Find("MapDot");
		if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject.GetComponent<MeshRenderer>() == (Object)null)
		{
			Logger.LogError((object)$"Add a child called 'MapDot' with MeshRenderer to {enemyType.enemyPrefab}");
			return;
		}
		((Component)val).gameObject.SetActive(true);
		((Renderer)((Component)val).gameObject.GetComponent<MeshRenderer>()).material = matToUse;
	}

	public static void AddEnemyFilesToTerminal(Terminal terminalScript)
	{
		TerminalKeyword infoKeyword = GetInfoKeyword(terminalScript.terminalNodes.allKeywords);
		List<CompatibleNoun> list = null;
		if ((Object)(object)infoKeyword != (Object)null)
		{
			list = infoKeyword.compatibleNouns.ToList();
		}
		for (int i = 0; i < allAssets.allBestiaryPages.Length; i++)
		{
			TerminalNode val = allAssets.allBestiaryPages[i];
			int count = terminalScript.enemyFiles.Count;
			terminalScript.enemyFiles.Add(val);
			val.creatureFileID = count;
			GameObject val2 = null;
			for (int j = 0; j < allAssets.allEnemies.Length; j++)
			{
				EnemyType val3 = allAssets.allEnemies[j];
				if (val3.enemyName.Contains(val.creatureName))
				{
					val2 = val3.enemyPrefab;
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				ScanNodeProperties componentInChildren = val2.GetComponentInChildren<ScanNodeProperties>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.creatureScanID = count;
					Logger.LogDebug((object)$"set creatureScanID for {((Object)val2).name} to {componentInChildren.creatureScanID}");
				}
			}
			else
			{
				Logger.LogWarning((object)$"failed to find prefab ({val2}) or scan node for {val.creatureName}");
			}
			list?.Add(SetEnemyInfoCnoun(val, infoKeyword));
		}
		if (list != null)
		{
			infoKeyword.compatibleNouns = list.ToArray();
		}
	}

	private static TerminalKeyword GetInfoKeyword(TerminalKeyword[] allKeywords)
	{
		foreach (TerminalKeyword val in allKeywords)
		{
			if (val.word == "info")
			{
				return val;
			}
		}
		Logger.LogWarning((object)"failed to find TerminalKeyword 'info', bestiary files cannot be accessed using this keyword");
		return null;
	}

	private static CompatibleNoun SetEnemyInfoCnoun(TerminalNode enemyFile, TerminalKeyword infoVerb)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		CompatibleNoun val = new CompatibleNoun();
		val.result = enemyFile;
		TerminalKeyword[] allKeywords = allAssets.allKeywords;
		foreach (TerminalKeyword val2 in allKeywords)
		{
			if ((Object)(object)val2.specialKeywordResult == (Object)(object)enemyFile)
			{
				val2.defaultVerb = infoVerb;
				val.noun = val2;
			}
		}
		if ((Object)(object)val.noun == (Object)null)
		{
			Logger.LogWarning((object)$"SetEnemyInfoCnoun({enemyFile}, {infoVerb}) did not find keyword for noun");
		}
		return val;
	}
}
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
	private struct MonoScriptData
	{
		public byte[] FilePathsData;

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[230]
		{
			0, 0, 0, 1, 0, 0, 0, 47, 92, 65,
			115, 115, 101, 116, 115, 92, 76, 67, 67, 104,
			105, 99, 107, 101, 110, 74, 111, 99, 107, 101,
			121, 77, 111, 100, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 65, 108, 108, 65, 115, 115, 101,
			116, 115, 46, 99, 115, 0, 0, 0, 1, 0,
			0, 0, 57, 92, 65, 115, 115, 101, 116, 115,
			92, 76, 67, 67, 104, 105, 99, 107, 101, 110,
			74, 111, 99, 107, 101, 121, 77, 111, 100, 92,
			83, 99, 114, 105, 112, 116, 115, 92, 67, 104,
			105, 99, 107, 101, 110, 74, 111, 99, 107, 101,
			121, 83, 99, 114, 105, 112, 116, 46, 99, 115,
			0, 0, 0, 1, 0, 0, 0, 50, 92, 65,
			115, 115, 101, 116, 115, 92, 76, 67, 67, 104,
			105, 99, 107, 101, 110, 74, 111, 99, 107, 101,
			121, 77, 111, 100, 92, 83, 99, 114, 105, 112,
			116, 115, 92, 68, 117, 97, 108, 65, 110, 105,
			109, 97, 116, 111, 114, 46, 99, 115, 0, 0,
			0, 5, 0, 0, 0, 44, 92, 65, 115, 115,
			101, 116, 115, 92, 76, 67, 67, 104, 105, 99,
			107, 101, 110, 74, 111, 99, 107, 101, 121, 77,
			111, 100, 92, 83, 99, 114, 105, 112, 116, 115,
			92, 80, 108, 117, 103, 105, 110, 46, 99, 115
		};
		result.TypesData = new byte[245]
		{
			0, 0, 0, 0, 10, 124, 65, 108, 108, 65,
			115, 115, 101, 116, 115, 0, 0, 0, 0, 20,
			124, 67, 104, 105, 99, 107, 101, 110, 74, 111,
			99, 107, 101, 121, 83, 99, 114, 105, 112, 116,
			0, 0, 0, 0, 13, 124, 68, 117, 97, 108,
			65, 110, 105, 109, 97, 116, 111, 114, 0, 0,
			0, 0, 7, 124, 80, 108, 117, 103, 105, 110,
			0, 0, 0, 0, 41, 80, 108, 117, 103, 105,
			110, 124, 67, 104, 105, 99, 107, 101, 110, 74,
			111, 99, 107, 101, 121, 81, 117, 105, 99, 107,
			77, 101, 110, 117, 77, 97, 110, 97, 103, 101,
			114, 80, 97, 116, 99, 104, 0, 0, 0, 0,
			39, 80, 108, 117, 103, 105, 110, 124, 67, 104,
			105, 99, 107, 101, 110, 74, 111, 99, 107, 101,
			121, 78, 101, 116, 119, 111, 114, 107, 77, 97,
			110, 97, 103, 101, 114, 80, 97, 116, 99, 104,
			0, 0, 0, 0, 33, 80, 108, 117, 103, 105,
			110, 124, 67, 104, 105, 99, 107, 101, 110, 74,
			111, 99, 107, 101, 121, 84, 101, 114, 109, 105,
			110, 97, 108, 80, 97, 116, 99, 104, 0, 0,
			0, 0, 42, 80, 108, 117, 103, 105, 110, 124,
			67, 104, 105, 99, 107, 101, 110, 74, 111, 99,
			107, 101, 121, 80, 108, 97, 121, 101, 114, 67,
			111, 110, 116, 114, 111, 108, 108, 101, 114, 66,
			80, 97, 116, 99, 104
		};
		result.TotalFiles = 4;
		result.TotalTypes = 8;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace __GEN;

internal class NetworkVariableSerializationHelper
{
	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeSerialization()
	{
	}
}