Decompiled source of ManuLib v1.0.0

ManuLib.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ManuLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ManuLib")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8127ca6d-dea7-4f68-b515-c15a3c1b11da")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ManuLib;

public class MLCheckOnShip : MonoBehaviour
{
	public GrabbableObject targetItem;

	public bool checkOnStart = false;

	public UnityEvent onTrue;

	public UnityEvent onFalse;

	public void CheckOnShip()
	{
		if (targetItem.isInShipRoom)
		{
			if (onTrue != null)
			{
				onTrue.Invoke();
			}
		}
		else if (onFalse != null)
		{
			onFalse.Invoke();
		}
	}

	public void Start()
	{
		if (checkOnStart)
		{
			CheckOnShip();
		}
	}
}
public class MLItemValueModifier : MonoBehaviour
{
	public GrabbableObject targetItem;

	public int amountToChange = 0;

	public bool isPercentage = false;

	private double amountToChangeInternal = 0.0;

	private double amountToCheck = 0.0;

	private int originalValue = 0;

	public void AddCalculatedValue()
	{
		ResetInternalVariables();
		CalculatePercentage();
		amountToCheck += amountToChangeInternal;
		SetToValue();
	}

	public void MultiplyCalculatedValue()
	{
		ResetInternalVariables();
		CalculatePercentage();
		amountToCheck *= amountToChangeInternal;
		SetToValue();
	}

	public void SetToInputValue()
	{
		targetItem.SetScrapValue(amountToChange);
	}

	public void ResetToOriginalValue()
	{
		targetItem.SetScrapValue(originalValue);
	}

	private void CalculatePercentage()
	{
		if (isPercentage)
		{
			if (amountToChange > 0)
			{
				amountToChangeInternal *= 0.01;
			}
			else
			{
				Plugin.ManuLogger.LogWarning((object)"Rejected devision of a value equal to or lower than 0.");
			}
		}
	}

	private void SetToValue()
	{
		if (amountToCheck >= 0.0)
		{
			targetItem.SetScrapValue((int)amountToCheck);
			return;
		}
		targetItem.SetScrapValue(0);
		Plugin.ManuLogger.LogInfo((object)"Rejected a price change that would result in a negative value. Setting to 0");
	}

	private void ResetInternalVariables()
	{
		amountToCheck = targetItem.scrapValue;
		amountToChangeInternal = amountToChange;
	}

	private void Awake()
	{
		originalValue = targetItem.scrapValue;
	}
}
internal class MLObjectEviscerator : MonoBehaviour
{
	public GameObject ObjectToDestroy;

	public void DestroyObject()
	{
		if ((Object)(object)ObjectToDestroy != (Object)null)
		{
			Object.Destroy((Object)(object)ObjectToDestroy);
			Plugin.ManuLogger.LogWarning((object)"hello generic i took the shot");
		}
		else
		{
			Plugin.ManuLogger.LogWarning((object)"Rejected destruction of a null gameobject.");
		}
	}
}
public class MLPrintStewie : MonoBehaviour
{
	public void PrintStewie()
	{
		Plugin.ManuLogger.LogInfo((object)" ");
		Plugin.ManuLogger.LogInfo((object)"                       gggÞÇÇ6ÞÇÇÞggg   ");
		Plugin.ManuLogger.LogInfo((object)"                 ggGÞü3llll****l****‡63Þg    ");
		Plugin.ManuLogger.LogInfo((object)"               GÞ6‡‡l*******************lüGg    ");
		Plugin.ManuLogger.LogInfo((object)"             gÞ3ül************************llÞg    ");
		Plugin.ManuLogger.LogInfo((object)"           gG3‡l***3l************************3g   ");
		Plugin.ManuLogger.LogInfo((object)"          g6‡‡l*******‡‡ü3*******************l*üg ");
		Plugin.ManuLogger.LogInfo((object)"        G6ü3‡l***‡üül*363**************3üü3‡ll**lG   ");
		Plugin.ManuLogger.LogInfo((object)"        Þü6‡‡l**ü‡l*****l6*************‡6l*l6‡***üÞ  ");
		Plugin.ManuLogger.LogInfo((object)"        ggÞ3‡l*lü***6GÞÞÇ63***********ü‡*****l6***6g ");
		Plugin.ManuLogger.LogInfo((object)"          G3‡l**6**\u00af\u00af\u00af\u00af\u00af\u00afül******ül**lü‡l‡Þ33üÇl***3Ç");
		Plugin.ManuLogger.LogInfo((object)"           Þ3‡l**ü‡\u00af\u00af\u00af\u00af*3l*******lü***3*\u00af\u00af\u00af\u00af\u00af\u00af6l**‡3Ç");
		Plugin.ManuLogger.LogInfo((object)"            g63l***l33‡******‡***3l***l6l\u00af\u00af\u00aflü***3G  ");
		Plugin.ManuLogger.LogInfo((object)"              gLJl************l3Þ63******lll***lÞg   ");
		Plugin.ManuLogger.LogInfo((object)"                gÞül*************************lÇG   ");
		Plugin.ManuLogger.LogInfo((object)"                   gÞ63l******************‡üÞg       ");
		Plugin.ManuLogger.LogInfo((object)"                     g63üÞÇü3‡‡‡ll‡‡‡3ü6Gg           ");
		Plugin.ManuLogger.LogInfo((object)"                     Þ‡‡‡3ÞÇÞ‡36üÞÇÇ**‡G      ");
		Plugin.ManuLogger.LogInfo((object)"                    gü‡l***3‡***6Ç63l**Ç        ");
		Plugin.ManuLogger.LogInfo((object)"                    g3‡‡*******‡Ç‡*****Þ    ");
		Plugin.ManuLogger.LogInfo((object)"                    g63663‡l‡üÇÇÞ‡ll‡üÞ     ");
		Plugin.ManuLogger.LogInfo((object)"                    GÞÞÞÇÇÞÞÇÇÇÇÇÇÇÇÇÇg    ");
		Plugin.ManuLogger.LogInfo((object)"                    GÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇ6g   ");
		Plugin.ManuLogger.LogInfo((object)"                    GÞÇÇÇÇÇÇÇÇÇÇÇÇÇÇ66g ");
		Plugin.ManuLogger.LogInfo((object)"                    gGÇÞÇÇÇÇÇÇÇÇÇÇÇÇüG    ");
		Plugin.ManuLogger.LogInfo((object)"                     gÞÇÇÇÇÇÇÇÇÞÇÇÇÇÇg   ");
		Plugin.ManuLogger.LogInfo((object)"                     gÞÞÇÇÇÇÇ6ÞÇÇÇÇÇÇg   ");
		Plugin.ManuLogger.LogInfo((object)"                     gÞÞÞÞÇ6üü6ÞÇ63‡llüG       ");
		Plugin.ManuLogger.LogInfo((object)"                     Þ333‡llllll6‡lllllüg    ");
		Plugin.ManuLogger.LogInfo((object)"                     gÞü3l‡ll‡‡3Þgggggg  ");
		Plugin.ManuLogger.LogInfo((object)" ");
	}
}
public class MLRunOnHost : MonoBehaviour
{
	public UnityEvent OnHost = new UnityEvent();

	public UnityEvent OnClient = new UnityEvent();

	public void CheckClient()
	{
		if (((NetworkBehaviour)RoundManager.Instance).IsHost || ((NetworkBehaviour)RoundManager.Instance).IsServer)
		{
			OnHost.Invoke();
		}
		else
		{
			OnClient.Invoke();
		}
	}
}
[BepInPlugin("GenericGMD.ManuLib", "ManuLib", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource ManuLogger;

	private void Awake()
	{
		ManuLogger = ((BaseUnityPlugin)this).Logger;
		ManuLogger.LogInfo((object)"ManuLib loaded. Printing Stewie.");
		ManuLogger.LogInfo((object)" ");
		ManuLogger.LogInfo((object)"                       gggÞÇÇ6ÞÇÇÞggg   ");
		ManuLogger.LogInfo((object)"                 ggGÞü3llll****l****‡63Þg    ");
		ManuLogger.LogInfo((object)"               GÞ6‡‡l*******************lüGg    ");
		ManuLogger.LogInfo((object)"             gÞ3ül************************llÞg    ");
		ManuLogger.LogInfo((object)"           gG3‡l***3l************************3g   ");
		ManuLogger.LogInfo((object)"          g6‡‡l*******‡‡ü3*******************l*üg ");
		ManuLogger.LogInfo((object)"        G6ü3‡l***‡üül*363**************3üü3‡ll**lG   ");
		ManuLogger.LogInfo((object)"        Þü6‡‡l**ü‡l*****l6*************‡6l*l6‡***üÞ  ");
		ManuLogger.LogInfo((object)"        ggÞ3‡l*lü***6GÞÞÇ63***********ü‡*****l6***6g ");
		ManuLogger.LogInfo((object)"          G3‡l**6**\u00af\u00af\u00af\u00af\u00af\u00afül******ül**lü‡l‡Þ33üÇl***3Ç");
		ManuLogger.LogInfo((object)"           Þ3‡l**ü‡\u00af\u00af\u00af\u00af*3l*******lü***3*\u00af\u00af\u00af\u00af\u00af\u00af6l**‡3Ç");
		ManuLogger.LogInfo((object)"            g63l***l33‡******‡***3l***l6l\u00af\u00af\u00aflü***3G  ");
		ManuLogger.LogInfo((object)"              gLJl************l3Þ63******lll***lÞg   ");
		ManuLogger.LogInfo((object)"                gÞül*************************lÇG   ");
		ManuLogger.LogInfo((object)"                   gÞ63l******************‡üÞg       ");
		ManuLogger.LogInfo((object)"                     g63üÞÇü3‡‡‡ll‡‡‡3ü6Gg           ");
		ManuLogger.LogInfo((object)"                     Þ‡‡‡3ÞÇÞ‡36üÞÇÇ**‡G      ");
		ManuLogger.LogInfo((object)"                    gü‡l***3‡***6Ç63l**Ç        ");
		ManuLogger.LogInfo((object)"                    g3‡‡*******‡Ç‡*****Þ    ");
		ManuLogger.LogInfo((object)"                    g63663‡l‡üÇÇÞ‡ll‡üÞ     ");
		ManuLogger.LogInfo((object)"                    GÞÞÞÇÇÞÞÇÇÇÇÇÇÇÇÇÇg    ");
		ManuLogger.LogInfo((object)"                    GÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇ6g   ");
		ManuLogger.LogInfo((object)"                    GÞÇÇÇÇÇÇÇÇÇÇÇÇÇÇ66g ");
		ManuLogger.LogInfo((object)"                    gGÇÞÇÇÇÇÇÇÇÇÇÇÇÇüG    ");
		ManuLogger.LogInfo((object)"                     gÞÇÇÇÇÇÇÇÇÞÇÇÇÇÇg   ");
		ManuLogger.LogInfo((object)"                     gÞÞÇÇÇÇÇ6ÞÇÇÇÇÇÇg   ");
		ManuLogger.LogInfo((object)"                     gÞÞÞÞÇ6üü6ÞÇ63‡llüG       ");
		ManuLogger.LogInfo((object)"                     Þ333‡llllll6‡lllllüg    ");
		ManuLogger.LogInfo((object)"                     gÞü3l‡ll‡‡3Þgggggg  ");
		ManuLogger.LogInfo((object)" ");
		ManuLogger.LogInfo((object)"Print sucessful. Enjoy your Stewie.");
	}
}
public class MLKeyItem : GrabbableObject
{
	[Header("Extra stuff")]
	public bool hasLimitedUses = true;

	public int totalUses = 1;

	public bool destroyAfterUses = true;

	private int currentUses = 0;

	public UnityEvent OnUse = new UnityEvent();

	public UnityEvent OnFinalUse = new UnityEvent();

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		//IL_0027: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		if ((Object)(object)base.playerHeldBy == (Object)null || !((NetworkBehaviour)this).IsOwner || !Physics.Raycast(new Ray(((Component)base.playerHeldBy.gameplayCamera).transform.position, ((Component)base.playerHeldBy.gameplayCamera).transform.forward), ref val, 3f, 2816))
		{
			return;
		}
		DoorLock val2 = ((Component)((RaycastHit)(ref val)).transform).GetComponent<DoorLock>();
		if ((Object)(object)val2 == (Object)null)
		{
			TriggerPointToDoor component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<TriggerPointToDoor>();
			if ((Object)(object)component != (Object)null)
			{
				val2 = component.pointToDoor;
			}
		}
		if (!((Object)(object)val2 != (Object)null) || !val2.isLocked || val2.isPickingLock)
		{
			return;
		}
		if (currentUses < totalUses)
		{
			if (hasLimitedUses)
			{
				currentUses++;
			}
			if (OnUse != null)
			{
				OnUse.Invoke();
			}
			val2.UnlockDoorSyncWithServer();
			if (currentUses == totalUses)
			{
				if (OnFinalUse != null)
				{
					OnFinalUse.Invoke();
				}
				if (destroyAfterUses)
				{
					base.playerHeldBy.DespawnHeldObject();
				}
			}
		}
		else
		{
			Plugin.ManuLogger.LogInfo((object)"Tried to unlock a door with no uses remaining.");
		}
	}
}
public class MLModularBirdAi : EnemyAI
{
	public Animator bodyAnimator;

	private int behaviourStateLastFrame = -1;

	public AudioSource flappingAudio;

	public AudioClip[] birdScreechSFX;

	public AudioClip birdHitGroundSFX;

	public AISearchRoutine roamGlide;

	private bool alertingBird;

	private float glideTime = 10f;

	private float currentGlideTime;

	private RaycastHit hit;

	private bool flyingToOtherBirdLanding;

	private float avoidingPlayer;

	public Transform Body;

	private Vector3 previousPosition;

	private float flyLayerWeight;

	[Space(5f)]
	public float maxSpeed;

	[Space(5f)]
	public float speedElevationMultiplier;

	private float randomYRot;

	private int velocityAverageCount;

	private float averageVelocity;

	private float lerpedElevation;

	private float timeSinceEnteringFlight;

	private float randomHeightOffset;

	private bool birdStunned;

	private bool oddInterval;

	private int birdNoisiness = 5;

	private float timeSinceSquawking;

	private float velocityInterval;

	public Rigidbody birdRigidbody;

	[Header("Extra stuff")]
	public bool doesEnemyLeave;

	public override void Start()
	{
		((EnemyAI)this).Start();
		base.creatureAnimator.SetInteger("idleType", Random.Range(0, 2));
		base.creatureAnimator.SetFloat("speedMultiplier", Random.Range(0.73f, 1.3f));
		bodyAnimator.SetFloat("speedMultiplier", Random.Range(0.8f, 1.2f));
		randomHeightOffset = (float)new Random(StartOfRound.Instance.randomMapSeed / (int)(((NetworkBehaviour)this).NetworkObjectId + 1)).NextDouble();
	}

	public override void DaytimeEnemyLeave()
	{
		if (doesEnemyLeave)
		{
			((EnemyAI)this).DaytimeEnemyLeave();
			if (base.stunNormalizedTimer < 0f && !base.isEnemyDead)
			{
				bodyAnimator.SetBool("flying", true);
				base.creatureAnimator.SetBool("gliding", true);
				bodyAnimator.SetTrigger("Leave");
				bodyAnimator.SetBool("Leaving", true);
			}
			((MonoBehaviour)this).StartCoroutine(flyAwayThenDespawn());
		}
	}

	private IEnumerator flyAwayThenDespawn()
	{
		yield return (object)new WaitForSeconds(7f);
		if (((NetworkBehaviour)this).IsOwner)
		{
			((EnemyAI)this).KillEnemyOnOwnerClient(true);
		}
	}

	public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
		if (noiseID != 911 && !base.isEnemyDead && !(base.stunNormalizedTimer > 0f))
		{
			float num = Vector3.Distance(noisePosition, ((Component)this).transform.position + Vector3.up * 0.5f);
			if (Physics.Linecast(((Component)this).transform.position, noisePosition, 256))
			{
				noiseLoudness /= 2f;
			}
			float num2 = 0.01f;
			if (!(noiseLoudness / num <= num2) && base.currentBehaviourStateIndex == 0 && !alertingBird)
			{
				alertingBird = true;
				AlertBirdServerRpc();
			}
		}
	}

	public void StunBird()
	{
		//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)
		if (birdStunned)
		{
			return;
		}
		birdStunned = true;
		base.agent.speed = 0f;
		DoublewingAI[] array = Object.FindObjectsByType<DoublewingAI>((FindObjectsInactive)0, (FindObjectsSortMode)0);
		for (int i = 0; i < array.Length; i++)
		{
			if (!((Object)(object)array[i] == (Object)(object)this) && Vector3.Distance(((Component)array[i]).transform.position, ((Component)this).transform.position) < 8f)
			{
				array[i].AlertBirdByOther();
			}
		}
		flappingAudio.Stop();
		base.creatureAnimator.SetBool("stunned", true);
		bodyAnimator.SetBool("stunned", true);
	}

	public void UnstunBird()
	{
		if (birdStunned)
		{
			birdStunned = false;
			base.creatureAnimator.SetBool("stunned", false);
			bodyAnimator.SetBool("stunned", false);
			if (base.currentBehaviourStateIndex == 0)
			{
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
			}
		}
	}

	public override void DoAIInterval()
	{
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DoAIInterval();
		if (base.daytimeEnemyLeaving || base.isEnemyDead || StartOfRound.Instance.allPlayersDead || base.stunNormalizedTimer > 0f)
		{
			return;
		}
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
			oddInterval = !oddInterval;
			if (oddInterval && !alertingBird && Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(80f, 8, 4)))
			{
				alertingBird = true;
				AlertBirdServerRpc();
			}
			break;
		case 1:
		{
			behaviourStateLastFrame = 1;
			base.creatureAnimator.SetBool("gliding", true);
			bodyAnimator.SetBool("flying", true);
			base.agent.speed = Mathf.Clamp(base.agent.speed + base.AIIntervalTime * 4f, 5f, 19f);
			if (!flyingToOtherBirdLanding && avoidingPlayer <= 0f && !roamGlide.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, roamGlide);
			}
			if (avoidingPlayer > 0f)
			{
				avoidingPlayer -= base.AIIntervalTime;
				if (Vector3.Distance(((Component)this).transform.position, base.destination) < 3f)
				{
					avoidingPlayer = 0f;
				}
				break;
			}
			PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForPlayer(80f, 10, 8);
			if (oddInterval && Object.op_Implicit((Object)(object)val))
			{
				Transform val2 = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)val).transform.position, false, Random.Range(0, base.allAINodes.Length / 2), false, 50, -1);
				if (((EnemyAI)this).SetDestinationToPosition(val2.position, false))
				{
					avoidingPlayer = Random.Range(10, 20);
					((EnemyAI)this).StopSearch(roamGlide, true);
				}
			}
			currentGlideTime += base.AIIntervalTime;
			if (!(currentGlideTime > glideTime))
			{
				break;
			}
			currentGlideTime = 0f;
			if (flyingToOtherBirdLanding)
			{
				if (!((EnemyAI)this).SetDestinationToPosition(base.destination, true))
				{
					flyingToOtherBirdLanding = false;
					glideTime = 5f;
					break;
				}
				if (Vector3.Distance(((Component)this).transform.position, base.destination) < 3f)
				{
					if (!TryLanding())
					{
						flyingToOtherBirdLanding = false;
						glideTime = 5f;
					}
					else
					{
						((EnemyAI)this).SwitchToBehaviourState(0);
					}
					break;
				}
			}
			for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++)
			{
				if ((Object)(object)RoundManager.Instance.SpawnedEnemies[i].enemyType == (Object)(object)base.enemyType && RoundManager.Instance.SpawnedEnemies[i].currentBehaviourStateIndex == 0 && Vector3.Distance(((Component)this).transform.position, ((Component)RoundManager.Instance.SpawnedEnemies[i]).transform.position) < 100f)
				{
					Vector3 randomNavMeshPositionInRadius = RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)RoundManager.Instance.SpawnedEnemies[i]).transform.position, 10f, default(NavMeshHit));
					if (((EnemyAI)this).SetDestinationToPosition(randomNavMeshPositionInRadius, true))
					{
						((EnemyAI)this).StopSearch(roamGlide, true);
						flyingToOtherBirdLanding = true;
						glideTime = 2f;
					}
					break;
				}
			}
			if (!flyingToOtherBirdLanding)
			{
				if (TryLanding())
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
				else
				{
					glideTime = 10f;
				}
			}
			break;
		}
		}
	}

	public bool TryLanding()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		if (Physics.Raycast(new Vector3(((Component)this).transform.position.x, base.eye.position.y, ((Component)this).transform.position.z), Vector3.down, ref hit, 60f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
		{
			if (Physics.CheckSphere(((RaycastHit)(ref hit)).point, 16f, StartOfRound.Instance.playersMask, (QueryTriggerInteraction)1))
			{
				return false;
			}
			if (Vector3.Distance(((RaycastHit)(ref hit)).point, ((Component)this).transform.position) > 1f)
			{
				if (((EnemyAI)this).SetDestinationToPosition(((RaycastHit)(ref hit)).point, true))
				{
					base.agent.Warp(base.destination);
					return true;
				}
				return false;
			}
			return true;
		}
		return false;
	}

	[ServerRpc(RequireOwnership = false)]
	public void AlertBirdServerRpc()
	{
		AlertBirdClientRpc();
	}

	[ClientRpc]
	public void AlertBirdClientRpc()
	{
		AlertBird();
	}

	public void AlertBird()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		DoublewingAI[] array = Object.FindObjectsByType<DoublewingAI>((FindObjectsInactive)0, (FindObjectsSortMode)0);
		for (int i = 0; i < array.Length; i++)
		{
			if (!((Object)(object)array[i] == (Object)(object)this) && Vector3.Distance(((Component)array[i]).transform.position, ((Component)this).transform.position) < 8f)
			{
				array[i].AlertBirdByOther();
			}
		}
		((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
		alertingBird = false;
	}

	public void AlertBirdByOther()
	{
		if (!base.daytimeEnemyLeaving)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				((EnemyAI)this).SwitchToBehaviourState(1);
			}
			else
			{
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1);
			}
		}
	}

	public override void Update()
	{
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).Update();
		if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
		{
			return;
		}
		SetFlyDirection();
		if (base.daytimeEnemyLeaving)
		{
			return;
		}
		timeSinceSquawking += Time.deltaTime;
		if (base.stunNormalizedTimer > 0f)
		{
			StunBird();
		}
		else
		{
			UnstunBird();
		}
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
			if (behaviourStateLastFrame != 0)
			{
				behaviourStateLastFrame = 0;
				randomYRot = Random.Range(0f, 360f);
				base.agent.speed = 0f;
				base.creatureAnimator.SetBool("gliding", false);
				bodyAnimator.SetBool("flying", false);
				flyingToOtherBirdLanding = false;
				timeSinceEnteringFlight = 0f;
			}
			flyLayerWeight = Mathf.Max(0f, flyLayerWeight - Time.deltaTime * 0.28f);
			timeSinceEnteringFlight += Time.deltaTime;
			break;
		case 1:
			if (behaviourStateLastFrame != 1)
			{
				behaviourStateLastFrame = 1;
				timeSinceEnteringFlight = 0f;
				base.creatureAnimator.SetBool("gliding", true);
				bodyAnimator.SetBool("flying", true);
				int num = RoundManager.PlayRandomClip(base.creatureSFX, base.enemyType.audioClips, true, 1f, 0, 1000);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, base.enemyType.audioClips[num], 0.7f);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 12f, 0.6f, 0, false, 911);
				glideTime = Random.Range(8f, 20f);
			}
			timeSinceEnteringFlight += Time.deltaTime;
			flyLayerWeight = Mathf.Min(1f, flyLayerWeight + Time.deltaTime * 0.33f);
			break;
		}
	}

	private void BirdScreech()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		RoundManager.PlayRandomClip(base.creatureVoice, birdScreechSFX, true, 1f, 0, 1000);
		WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, birdScreechSFX[Random.Range(0, birdScreechSFX.Length)], 1f);
		RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 12f, 0.6f, 0, false, 911);
	}

	public void SetFlyDirection()
	{
		//IL_006a: 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_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_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: 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)
		//IL_00b0: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: 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_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: 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_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: 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_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0463: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		if (birdStunned || base.isEnemyDead)
		{
			Vector3 localEulerAngles = Body.localEulerAngles;
			localEulerAngles.x = 0f;
			localEulerAngles.z = 0f;
			Body.localEulerAngles = localEulerAngles;
			return;
		}
		bool flag = false;
		flag = averageVelocity * speedElevationMultiplier < 12f;
		Vector3 val = Body.position - previousPosition;
		float num = ((Vector3)(ref val)).magnitude / Time.deltaTime;
		if (base.daytimeEnemyLeaving)
		{
			val = Body.position - previousPosition;
			if (((Vector3)(ref val)).sqrMagnitude >= 0f)
			{
				if (Body.position - previousPosition == Vector3.zero)
				{
					Body.rotation = Quaternion.Lerp(Body.rotation, Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f), 5f * Time.deltaTime);
				}
				else
				{
					Body.rotation = Quaternion.Lerp(Body.rotation, Quaternion.LookRotation(Body.position - previousPosition, Vector3.up), 5f * Time.deltaTime);
				}
			}
		}
		else if (base.currentBehaviourStateIndex == 0 || timeSinceEnteringFlight < 1f)
		{
			flag = false;
			Body.rotation = Quaternion.Lerp(Body.rotation, Quaternion.Euler(new Vector3(0f, randomYRot, 0f)), 10f * Time.deltaTime);
		}
		else if (averageVelocity * speedElevationMultiplier > 0f && Body.position - previousPosition != Vector3.zero)
		{
			Body.rotation = Quaternion.Lerp(Body.rotation, Quaternion.LookRotation(Body.position - previousPosition, Vector3.up), 5f * Time.deltaTime);
		}
		if (velocityInterval <= 0f)
		{
			velocityInterval = 0.1f;
			velocityAverageCount++;
			if (velocityAverageCount > 5)
			{
				averageVelocity += (num - averageVelocity) / 6f;
			}
			else
			{
				averageVelocity += num;
				if (velocityAverageCount == 5)
				{
					averageVelocity /= velocityAverageCount;
				}
			}
		}
		else
		{
			velocityInterval -= Time.deltaTime;
		}
		base.creatureAnimator.SetBool("flapping", flag);
		if (flag)
		{
			if (flappingAudio.volume <= 0.99f)
			{
				flappingAudio.volume = Mathf.Min(flappingAudio.volume + Time.deltaTime, 1f);
			}
			if (!flappingAudio.isPlaying)
			{
				flappingAudio.Play();
			}
		}
		else if (flappingAudio.volume >= 0.05f)
		{
			flappingAudio.volume = Mathf.Max(flappingAudio.volume - Time.deltaTime, 0f);
		}
		else
		{
			flappingAudio.Stop();
		}
		lerpedElevation = Mathf.Lerp(lerpedElevation, averageVelocity * speedElevationMultiplier / maxSpeed, Time.deltaTime * 0.5f);
		bodyAnimator.SetFloat("elevation", Mathf.Clamp(lerpedElevation * randomHeightOffset, 0.02f, 0.98f));
		previousPosition = Body.position;
	}

	public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
		((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
		if (((NetworkBehaviour)this).IsOwner)
		{
			((EnemyAI)this).KillEnemyOnOwnerClient(false);
		}
	}

	public override void KillEnemy(bool destroy = false)
	{
		((EnemyAI)this).KillEnemy(destroy);
		bodyAnimator.SetBool("stunned", true);
		base.creatureAnimator.SetBool("dead", true);
	}

	public override void AnimationEventA()
	{
		((EnemyAI)this).AnimationEventA();
		if (((NetworkBehaviour)this).IsServer && timeSinceSquawking > 0.7f && Random.Range(0, 100) < birdNoisiness)
		{
			timeSinceSquawking = 0f;
			BirdScreechClientRpc();
		}
	}

	[ClientRpc(/*Could not decode attribute arguments.*/)]
	public void BirdScreechClientRpc()
	{
		BirdScreech();
	}

	public override void AnimationEventB()
	{
		((EnemyAI)this).AnimationEventB();
		base.creatureSFX.PlayOneShot(birdHitGroundSFX);
	}
}