Decompiled source of You Vs AI v1.0.1

YouVsAI.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Empress")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("YouVsAI")]
[assembly: AssemblyTitle("YouVsAI")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EmpressYouVsAI
{
	internal static class EmpressAIAccess
	{
		private delegate bool EmpressBoolStaticDelegate();

		private delegate PlayerAvatar EmpressPlayerAvatarStaticDelegate();

		private delegate void EmpressEnemyInvestigateStaticDelegate(Vector3 position, float range, bool pathfindOnly);

		private delegate void EmpressEnemyChaseDelegate(Enemy instance, PlayerAvatar player);

		private delegate void EmpressPhysGrabReleaseDelegate(PhysGrabber instance, int releaseObjectViewID, float disableTimer);

		private delegate void EmpressPhysGrabOverrideDelegate(PhysGrabber instance, PhysGrabObject target, float grabTime, bool grabRelease);

		private delegate void EmpressPhysFloatTimeDelegate(PhysGrabObject instance, float value, float time);

		private delegate void EmpressPhysFloatDelegate(PhysGrabObject instance, float value);

		private delegate void EmpressPlayerControllerMoveForceDelegate(PlayerController instance, Vector3 direction, float amount, float time);

		private delegate void EmpressPlayerControllerFloatDelegate(PlayerController instance, float value);

		private delegate void EmpressPlayerControllerFloatFloatDelegate(PlayerController instance, float value, float time);

		private delegate void EmpressPlayerControllerLookDelegate(PlayerController instance, float target, float timeIn, float timeOut, float time);

		private delegate void EmpressPlayerControllerVectorDelegate(PlayerController instance, Vector3 force);

		private delegate void EmpressPlayerAvatarVoidDelegate(PlayerAvatar instance);

		private delegate void EmpressImpactFloatDelegate(PhysGrabObjectImpactDetector instance, float value);

		private delegate void EmpressImpactFloatFloatDelegate(PhysGrabObjectImpactDetector instance, float value, float time);

		private delegate void EmpressImpactFloatVectorDelegate(PhysGrabObjectImpactDetector instance, float force, Vector3 contactPoint);

		private delegate void EmpressImpactBreakHeavyDelegate(PhysGrabObjectImpactDetector instance, Vector3 contactPoint, bool forceBreak, float minimumValue);

		private delegate void EmpressItemToggleDelegate(ItemToggle instance, bool toggle, int player);

		private delegate void EmpressItemDisableDelegate(ItemToggle instance, bool disable);

		private static readonly FieldRef<object, GameManager> EmpressGameManagerInstance = EmpressStaticRef<GameManager>(typeof(GameManager), "instance");

		private static readonly FieldRef<object, RunManager> EmpressRunManagerInstance = EmpressStaticRef<RunManager>(typeof(RunManager), "instance");

		private static readonly FieldRef<object, GameDirector> EmpressGameDirectorInstance = EmpressStaticRef<GameDirector>(typeof(GameDirector), "instance");

		private static readonly FieldRef<object, PlayerAvatar> EmpressPlayerAvatarInstance = EmpressStaticRef<PlayerAvatar>(typeof(PlayerAvatar), "instance");

		private static readonly FieldRef<object, LevelGenerator> EmpressLevelGeneratorInstance = EmpressStaticRef<LevelGenerator>(typeof(LevelGenerator), "Instance");

		private static readonly FieldRef<object, ShopManager> EmpressShopManagerInstance = EmpressStaticRef<ShopManager>(typeof(ShopManager), "instance");

		private static readonly FieldRef<object, PhysGrabber> EmpressPhysGrabberInstance = EmpressStaticRef<PhysGrabber>(typeof(PhysGrabber), "instance");

		private static readonly FieldRef<object, PlayerController> EmpressPlayerControllerInstance = EmpressStaticRef<PlayerController>(typeof(PlayerController), "instance");

		private static readonly FieldRef<PlayerAvatar, PlayerHealth> EmpressAvatarHealth = EmpressInstanceRef<PlayerAvatar, PlayerHealth>("playerHealth");

		private static readonly FieldRef<PlayerAvatar, bool> EmpressAvatarDeadSet = EmpressInstanceRef<PlayerAvatar, bool>("deadSet");

		private static readonly FieldRef<PlayerHealth, int> EmpressHealthValue = EmpressInstanceRef<PlayerHealth, int>("health");

		private static readonly FieldRef<PlayerHealth, int> EmpressHealthMax = EmpressInstanceRef<PlayerHealth, int>("maxHealth");

		private static readonly FieldRef<GameDirector, gameState> EmpressDirectorState = EmpressInstanceRef<GameDirector, gameState>("currentState");

		private static readonly FieldRef<GameDirector, List<PlayerAvatar>> EmpressDirectorPlayers = EmpressInstanceRef<GameDirector, List<PlayerAvatar>>("PlayerList");

		private static readonly FieldRef<RunManager, Level> EmpressRunLevelCurrent = EmpressInstanceRef<RunManager, Level>("levelCurrent");

		private static readonly FieldRef<RunManager, int> EmpressRunLevelsCompleted = EmpressInstanceRef<RunManager, int>("levelsCompleted");

		private static readonly FieldRef<LevelGenerator, bool> EmpressLevelGenerated = EmpressInstanceRef<LevelGenerator, bool>("Generated");

		private static readonly FieldRef<ShopManager, List<ItemAttributes>> EmpressShoppingList = EmpressInstanceRef<ShopManager, List<ItemAttributes>>("shoppingList");

		private static readonly FieldRef<PhysGrabber, PhysGrabObject> EmpressGrabberHeldObject = EmpressInstanceRef<PhysGrabber, PhysGrabObject>("grabbedPhysGrabObject");

		private static readonly FieldRef<PhysGrabber, ItemAttributes> EmpressGrabberLookItem = EmpressInstanceRef<PhysGrabber, ItemAttributes>("currentlyLookingAtItemAttributes");

		private static readonly FieldRef<PlayerController, GameObject> EmpressControllerPhysObject = EmpressInstanceRef<PlayerController, GameObject>("physGrabObject");

		private static readonly FieldRef<PhysGrabObject, Rigidbody> EmpressPhysRb = EmpressInstanceRef<PhysGrabObject, Rigidbody>("rb");

		private static readonly FieldRef<PhysGrabObject, PhysGrabObjectImpactDetector> EmpressPhysImpactDetector = EmpressInstanceRef<PhysGrabObject, PhysGrabObjectImpactDetector>("impactDetector");

		private static readonly FieldRef<PhysGrabObject, bool> EmpressPhysHeldByLocal = EmpressInstanceRef<PhysGrabObject, bool>("heldByLocalPlayer");

		private static readonly FieldRef<PhysGrabObject, bool> EmpressPhysGrabbedLocal = EmpressInstanceRef<PhysGrabObject, bool>("grabbedLocal");

		private static readonly FieldRef<PhysGrabObject, bool> EmpressPhysGrabbed = EmpressInstanceRef<PhysGrabObject, bool>("grabbed");

		private static readonly FieldRef<PhysGrabObjectImpactDetector, bool> EmpressImpactIsCart = EmpressInstanceRef<PhysGrabObjectImpactDetector, bool>("isCart");

		private static readonly FieldRef<PhysGrabObjectImpactDetector, bool> EmpressImpactIsValuable = EmpressInstanceRef<PhysGrabObjectImpactDetector, bool>("isValuable");

		private static readonly FieldRef<ItemAttributes, bool> EmpressItemShopItem = EmpressInstanceRef<ItemAttributes, bool>("shopItem");

		private static readonly FieldRef<ItemAttributes, PhysGrabObject> EmpressItemPhysGrabObject = EmpressInstanceRef<ItemAttributes, PhysGrabObject>("physGrabObject");

		private static readonly FieldRef<ItemAttributes, ItemToggle> EmpressItemToggle = EmpressInstanceRef<ItemAttributes, ItemToggle>("itemToggle");

		private static readonly FieldRef<ItemAttributes, string> EmpressItemName = EmpressInstanceRef<ItemAttributes, string>("itemName");

		private static readonly EmpressBoolStaticDelegate EmpressGameMultiplayer = EmpressStaticMethod<EmpressBoolStaticDelegate>(typeof(GameManager), "Multiplayer");

		private static readonly EmpressBoolStaticDelegate EmpressRunIsLevel = EmpressStaticMethod<EmpressBoolStaticDelegate>(typeof(SemiFunc), "RunIsLevel");

		private static readonly EmpressBoolStaticDelegate EmpressRunIsShop = EmpressStaticMethod<EmpressBoolStaticDelegate>(typeof(SemiFunc), "RunIsShop");

		private static readonly EmpressPlayerAvatarStaticDelegate EmpressPlayerAvatarLocal = EmpressStaticMethod<EmpressPlayerAvatarStaticDelegate>(typeof(SemiFunc), "PlayerAvatarLocal");

		private static readonly EmpressEnemyInvestigateStaticDelegate EmpressWorldEnemyInvestigateMethod = EmpressStaticMethod<EmpressEnemyInvestigateStaticDelegate>(typeof(SemiFunc), "EnemyInvestigate", new Type[3]
		{
			typeof(Vector3),
			typeof(float),
			typeof(bool)
		});

		private static readonly EmpressEnemyChaseDelegate EmpressEnemySetChaseTargetMethod = EmpressInstanceMethod<EmpressEnemyChaseDelegate>(typeof(Enemy), "SetChaseTarget", new Type[1] { typeof(PlayerAvatar) });

		private static readonly EmpressPhysGrabReleaseDelegate EmpressGrabberRelease = EmpressInstanceMethod<EmpressPhysGrabReleaseDelegate>(typeof(PhysGrabber), "OverrideGrabRelease", new Type[2]
		{
			typeof(int),
			typeof(float)
		});

		private static readonly EmpressPhysGrabOverrideDelegate EmpressGrabberOverrideGrab = EmpressInstanceMethod<EmpressPhysGrabOverrideDelegate>(typeof(PhysGrabber), "OverrideGrab", new Type[3]
		{
			typeof(PhysGrabObject),
			typeof(float),
			typeof(bool)
		});

		private static readonly EmpressPhysFloatTimeDelegate EmpressOverrideDragMethod = EmpressInstanceMethod<EmpressPhysFloatTimeDelegate>(typeof(PhysGrabObject), "OverrideDrag", new Type[2]
		{
			typeof(float),
			typeof(float)
		});

		private static readonly EmpressPhysFloatTimeDelegate EmpressOverrideAngularDragMethod = EmpressInstanceMethod<EmpressPhysFloatTimeDelegate>(typeof(PhysGrabObject), "OverrideAngularDrag", new Type[2]
		{
			typeof(float),
			typeof(float)
		});

		private static readonly EmpressPhysFloatDelegate EmpressOverrideZeroGravityMethod = EmpressInstanceMethod<EmpressPhysFloatDelegate>(typeof(PhysGrabObject), "OverrideZeroGravity", new Type[1] { typeof(float) });

		private static readonly EmpressPhysFloatTimeDelegate EmpressOverrideMassMethod = EmpressInstanceMethod<EmpressPhysFloatTimeDelegate>(typeof(PhysGrabObject), "OverrideMass", new Type[2]
		{
			typeof(float),
			typeof(float)
		});

		private static readonly EmpressPhysFloatDelegate EmpressOverrideFragilityMethod = EmpressInstanceMethod<EmpressPhysFloatDelegate>(typeof(PhysGrabObject), "OverrideFragility", new Type[1] { typeof(float) });

		private static readonly EmpressPlayerControllerMoveForceDelegate EmpressMoveForceMethod = EmpressInstanceMethod<EmpressPlayerControllerMoveForceDelegate>(typeof(PlayerController), "MoveForce", new Type[3]
		{
			typeof(Vector3),
			typeof(float),
			typeof(float)
		});

		private static readonly EmpressPlayerControllerFloatDelegate EmpressInputDisableMethod = EmpressInstanceMethod<EmpressPlayerControllerFloatDelegate>(typeof(PlayerController), "InputDisable", new Type[1] { typeof(float) });

		private static readonly EmpressPlayerControllerFloatFloatDelegate EmpressMoveMultMethod = EmpressInstanceMethod<EmpressPlayerControllerFloatFloatDelegate>(typeof(PlayerController), "MoveMult", new Type[2]
		{
			typeof(float),
			typeof(float)
		});

		private static readonly EmpressPlayerControllerVectorDelegate EmpressForceImpulseMethod = EmpressInstanceMethod<EmpressPlayerControllerVectorDelegate>(typeof(PlayerController), "ForceImpulse", new Type[1] { typeof(Vector3) });

		private static readonly EmpressPlayerControllerFloatDelegate EmpressAntiGravityMethod = EmpressInstanceMethod<EmpressPlayerControllerFloatDelegate>(typeof(PlayerController), "AntiGravity", new Type[1] { typeof(float) });

		private static readonly EmpressPlayerControllerFloatFloatDelegate EmpressOverrideSpeedMethod = EmpressInstanceMethod<EmpressPlayerControllerFloatFloatDelegate>(typeof(PlayerController), "OverrideSpeed", new Type[2]
		{
			typeof(float),
			typeof(float)
		});

		private static readonly EmpressPlayerControllerLookDelegate EmpressOverrideLookSpeedMethod = EmpressInstanceMethod<EmpressPlayerControllerLookDelegate>(typeof(PlayerController), "OverrideLookSpeed", new Type[4]
		{
			typeof(float),
			typeof(float),
			typeof(float),
			typeof(float)
		});

		private static readonly EmpressPlayerControllerFloatDelegate EmpressOverrideJumpCooldownMethod = EmpressInstanceMethod<EmpressPlayerControllerFloatDelegate>(typeof(PlayerController), "OverrideJumpCooldown", new Type[1] { typeof(float) });

		private static readonly EmpressPlayerAvatarVoidDelegate EmpressPlayerGlitchShortMethod = EmpressInstanceMethod<EmpressPlayerAvatarVoidDelegate>(typeof(PlayerAvatar), "PlayerGlitchShort");

		private static readonly EmpressImpactFloatDelegate EmpressEnemyInvestigateMethod = EmpressInstanceMethod<EmpressImpactFloatDelegate>(typeof(PhysGrabObjectImpactDetector), "EnemyInvestigate", new Type[1] { typeof(float) });

		private static readonly EmpressImpactFloatFloatDelegate EmpressPlayerHurtMultiplierMethod = EmpressInstanceMethod<EmpressImpactFloatFloatDelegate>(typeof(PhysGrabObjectImpactDetector), "PlayerHurtMultiplier", new Type[2]
		{
			typeof(float),
			typeof(float)
		});

		private static readonly EmpressImpactFloatVectorDelegate EmpressImpactHeavyMethod = EmpressInstanceMethod<EmpressImpactFloatVectorDelegate>(typeof(PhysGrabObjectImpactDetector), "ImpactHeavy", new Type[2]
		{
			typeof(float),
			typeof(Vector3)
		});

		private static readonly EmpressImpactBreakHeavyDelegate EmpressBreakHeavyMethod = EmpressInstanceMethod<EmpressImpactBreakHeavyDelegate>(typeof(PhysGrabObjectImpactDetector), "BreakHeavy", new Type[3]
		{
			typeof(Vector3),
			typeof(bool),
			typeof(float)
		});

		private static readonly EmpressItemToggleDelegate EmpressToggleItemMethod = EmpressInstanceMethod<EmpressItemToggleDelegate>(typeof(ItemToggle), "ToggleItem", new Type[2]
		{
			typeof(bool),
			typeof(int)
		});

		private static readonly EmpressItemDisableDelegate EmpressToggleDisableMethod = EmpressInstanceMethod<EmpressItemDisableDelegate>(typeof(ItemToggle), "ToggleDisable", new Type[1] { typeof(bool) });

		private static readonly HashSet<int> EmpressUnsafeItemToggles = new HashSet<int>();

		internal static GameManager GameManagerInstance => EmpressGetStatic<GameManager>(EmpressGameManagerInstance);

		internal static RunManager RunManagerInstance => EmpressGetStatic<RunManager>(EmpressRunManagerInstance);

		internal static GameDirector GameDirectorInstance => EmpressGetStatic<GameDirector>(EmpressGameDirectorInstance);

		internal static PlayerAvatar PlayerAvatarInstance => EmpressGetStatic<PlayerAvatar>(EmpressPlayerAvatarInstance);

		internal static LevelGenerator LevelGeneratorInstance => EmpressGetStatic<LevelGenerator>(EmpressLevelGeneratorInstance);

		internal static ShopManager ShopManagerInstance => EmpressGetStatic<ShopManager>(EmpressShopManagerInstance);

		internal static PhysGrabber PhysGrabberInstance => EmpressGetStatic<PhysGrabber>(EmpressPhysGrabberInstance);

		internal static PlayerController PlayerControllerInstance => EmpressGetStatic<PlayerController>(EmpressPlayerControllerInstance);

		internal static bool IsMultiplayer()
		{
			try
			{
				return EmpressGameMultiplayer != null && EmpressGameMultiplayer();
			}
			catch
			{
				return false;
			}
		}

		internal static bool RunIsLevel()
		{
			try
			{
				return EmpressRunIsLevel != null && EmpressRunIsLevel();
			}
			catch
			{
				return false;
			}
		}

		internal static bool RunIsShop()
		{
			try
			{
				return EmpressRunIsShop != null && EmpressRunIsShop();
			}
			catch
			{
				return false;
			}
		}

		internal static PlayerAvatar GetLocalPlayer()
		{
			try
			{
				return (EmpressPlayerAvatarLocal != null) ? (EmpressPlayerAvatarLocal() ?? PlayerAvatarInstance) : PlayerAvatarInstance;
			}
			catch
			{
				return PlayerAvatarInstance;
			}
		}

		internal static PlayerHealth GetPlayerHealth(PlayerAvatar player)
		{
			return EmpressGet<PlayerAvatar, PlayerHealth>(player, EmpressAvatarHealth);
		}

		internal static bool IsDead(PlayerAvatar player)
		{
			if (!((Object)(object)player == (Object)null))
			{
				return EmpressGet<PlayerAvatar, bool>(player, EmpressAvatarDeadSet);
			}
			return true;
		}

		internal static int GetHealth(PlayerHealth health)
		{
			return EmpressGet<PlayerHealth, int>(health, EmpressHealthValue);
		}

		internal static int GetMaxHealth(PlayerHealth health)
		{
			int num = EmpressGet<PlayerHealth, int>(health, EmpressHealthMax);
			if (num <= 0)
			{
				return 100;
			}
			return num;
		}

		internal static gameState GetGameState(GameDirector director)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)director != (Object)null))
			{
				return (gameState)0;
			}
			return EmpressGet<GameDirector, gameState>(director, EmpressDirectorState);
		}

		internal static int GetPlayerCount(GameDirector director)
		{
			return (((Object)(object)director != (Object)null) ? EmpressGet<GameDirector, List<PlayerAvatar>>(director, EmpressDirectorPlayers) : null)?.Count ?? 0;
		}

		internal static Level GetCurrentLevel(RunManager manager)
		{
			if (!((Object)(object)manager != (Object)null))
			{
				return null;
			}
			return EmpressGet<RunManager, Level>(manager, EmpressRunLevelCurrent);
		}

		internal static int GetLevelsCompleted(RunManager manager)
		{
			if (!((Object)(object)manager != (Object)null))
			{
				return 0;
			}
			return EmpressGet<RunManager, int>(manager, EmpressRunLevelsCompleted);
		}

		internal static bool IsLevelGenerated(LevelGenerator generator)
		{
			if (!((Object)(object)generator == (Object)null))
			{
				return EmpressGet<LevelGenerator, bool>(generator, EmpressLevelGenerated);
			}
			return true;
		}

		internal static int GetShoppingCount(ShopManager manager)
		{
			return (((Object)(object)manager != (Object)null) ? EmpressGet<ShopManager, List<ItemAttributes>>(manager, EmpressShoppingList) : null)?.Count ?? 0;
		}

		internal static ItemAttributes GetShoppingItem(ShopManager manager, int index)
		{
			List<ItemAttributes> list = (((Object)(object)manager != (Object)null) ? EmpressGet<ShopManager, List<ItemAttributes>>(manager, EmpressShoppingList) : null);
			if (list == null || index < 0 || index >= list.Count)
			{
				return null;
			}
			return list[index];
		}

		internal static PhysGrabObject GetGrabbedObject(PhysGrabber grabber)
		{
			if (!((Object)(object)grabber != (Object)null))
			{
				return null;
			}
			return EmpressGet<PhysGrabber, PhysGrabObject>(grabber, EmpressGrabberHeldObject);
		}

		internal static ItemAttributes GetLookedAtItem(PhysGrabber grabber)
		{
			if (!((Object)(object)grabber != (Object)null))
			{
				return null;
			}
			return EmpressGet<PhysGrabber, ItemAttributes>(grabber, EmpressGrabberLookItem);
		}

		internal static GameObject GetControllerPhysObject(PlayerController controller)
		{
			if (!((Object)(object)controller != (Object)null))
			{
				return null;
			}
			return EmpressGet<PlayerController, GameObject>(controller, EmpressControllerPhysObject);
		}

		internal static Rigidbody GetRigidbody(PhysGrabObject physObject)
		{
			if (!((Object)(object)physObject != (Object)null))
			{
				return null;
			}
			return EmpressGet<PhysGrabObject, Rigidbody>(physObject, EmpressPhysRb);
		}

		internal static PhysGrabObjectImpactDetector GetImpactDetector(PhysGrabObject physObject)
		{
			if (!((Object)(object)physObject != (Object)null))
			{
				return null;
			}
			return EmpressGet<PhysGrabObject, PhysGrabObjectImpactDetector>(physObject, EmpressPhysImpactDetector);
		}

		internal static bool IsHeldOrGrabbed(PhysGrabObject physObject)
		{
			if (!((Object)(object)physObject == (Object)null) && !EmpressGet<PhysGrabObject, bool>(physObject, EmpressPhysHeldByLocal) && !EmpressGet<PhysGrabObject, bool>(physObject, EmpressPhysGrabbedLocal))
			{
				return EmpressGet<PhysGrabObject, bool>(physObject, EmpressPhysGrabbed);
			}
			return true;
		}

		internal static bool IsCart(PhysGrabObjectImpactDetector impactDetector)
		{
			if ((Object)(object)impactDetector != (Object)null)
			{
				return EmpressGet<PhysGrabObjectImpactDetector, bool>(impactDetector, EmpressImpactIsCart);
			}
			return false;
		}

		internal static bool IsValuable(PhysGrabObjectImpactDetector impactDetector)
		{
			if ((Object)(object)impactDetector != (Object)null)
			{
				return EmpressGet<PhysGrabObjectImpactDetector, bool>(impactDetector, EmpressImpactIsValuable);
			}
			return false;
		}

		internal static bool IsShopItem(ItemAttributes item)
		{
			if ((Object)(object)item != (Object)null)
			{
				return EmpressGet<ItemAttributes, bool>(item, EmpressItemShopItem);
			}
			return false;
		}

		internal static PhysGrabObject GetItemPhysGrabObject(ItemAttributes item)
		{
			if (!((Object)(object)item != (Object)null))
			{
				return null;
			}
			return EmpressGet<ItemAttributes, PhysGrabObject>(item, EmpressItemPhysGrabObject);
		}

		internal static ItemToggle GetItemToggle(ItemAttributes item)
		{
			if (!((Object)(object)item != (Object)null))
			{
				return null;
			}
			return EmpressGet<ItemAttributes, ItemToggle>(item, EmpressItemToggle);
		}

		internal static string GetItemName(ItemAttributes item)
		{
			if (!((Object)(object)item != (Object)null))
			{
				return string.Empty;
			}
			return EmpressGet<ItemAttributes, string>(item, EmpressItemName) ?? string.Empty;
		}

		internal static void OverrideGrabRelease(PhysGrabber grabber, int viewId, float disableTimer)
		{
			if ((Object)(object)grabber != (Object)null && EmpressGrabberRelease != null)
			{
				EmpressGrabberRelease(grabber, viewId, disableTimer);
			}
		}

		internal static void OverrideGrab(PhysGrabber grabber, PhysGrabObject target, float grabTime, bool grabRelease)
		{
			if ((Object)(object)grabber != (Object)null && (Object)(object)target != (Object)null && EmpressGrabberOverrideGrab != null)
			{
				EmpressGrabberOverrideGrab(grabber, target, grabTime, grabRelease);
			}
		}

		internal static void OverrideDrag(PhysGrabObject physObject, float value, float time)
		{
			if ((Object)(object)physObject != (Object)null && EmpressOverrideDragMethod != null)
			{
				EmpressOverrideDragMethod(physObject, value, time);
			}
		}

		internal static void OverrideAngularDrag(PhysGrabObject physObject, float value, float time)
		{
			if ((Object)(object)physObject != (Object)null && EmpressOverrideAngularDragMethod != null)
			{
				EmpressOverrideAngularDragMethod(physObject, value, time);
			}
		}

		internal static void OverrideZeroGravity(PhysGrabObject physObject, float time)
		{
			if ((Object)(object)physObject != (Object)null && EmpressOverrideZeroGravityMethod != null)
			{
				EmpressOverrideZeroGravityMethod(physObject, time);
			}
		}

		internal static void OverrideMass(PhysGrabObject physObject, float value, float time)
		{
			if ((Object)(object)physObject != (Object)null && EmpressOverrideMassMethod != null)
			{
				EmpressOverrideMassMethod(physObject, value, time);
			}
		}

		internal static void OverrideFragility(PhysGrabObject physObject, float value)
		{
			if ((Object)(object)physObject != (Object)null && EmpressOverrideFragilityMethod != null)
			{
				EmpressOverrideFragilityMethod(physObject, value);
			}
		}

		internal static void MoveForce(PlayerController controller, Vector3 direction, float amount, float time)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)controller != (Object)null && EmpressMoveForceMethod != null)
			{
				EmpressMoveForceMethod(controller, direction, amount, time);
			}
		}

		internal static void InputDisable(PlayerController controller, float time)
		{
			if ((Object)(object)controller != (Object)null && EmpressInputDisableMethod != null)
			{
				EmpressInputDisableMethod(controller, time);
			}
		}

		internal static void MoveMult(PlayerController controller, float multiplier, float time)
		{
			if ((Object)(object)controller != (Object)null && EmpressMoveMultMethod != null)
			{
				EmpressMoveMultMethod(controller, multiplier, time);
			}
		}

		internal static void ForceImpulse(PlayerController controller, Vector3 force)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)controller != (Object)null && EmpressForceImpulseMethod != null)
			{
				EmpressForceImpulseMethod(controller, force);
			}
		}

		internal static void AntiGravity(PlayerController controller, float time)
		{
			if ((Object)(object)controller != (Object)null && EmpressAntiGravityMethod != null)
			{
				EmpressAntiGravityMethod(controller, time);
			}
		}

		internal static void OverrideSpeed(PlayerController controller, float speedMultiplier, float time)
		{
			if ((Object)(object)controller != (Object)null && EmpressOverrideSpeedMethod != null)
			{
				EmpressOverrideSpeedMethod(controller, speedMultiplier, time);
			}
		}

		internal static void OverrideLookSpeed(PlayerController controller, float target, float timeIn, float timeOut, float time)
		{
			if ((Object)(object)controller != (Object)null && EmpressOverrideLookSpeedMethod != null)
			{
				EmpressOverrideLookSpeedMethod(controller, target, timeIn, timeOut, time);
			}
		}

		internal static void OverrideJumpCooldown(PlayerController controller, float cooldown)
		{
			if ((Object)(object)controller != (Object)null && EmpressOverrideJumpCooldownMethod != null)
			{
				EmpressOverrideJumpCooldownMethod(controller, cooldown);
			}
		}

		internal static void PlayerGlitchShort(PlayerAvatar player)
		{
			if ((Object)(object)player != (Object)null && EmpressPlayerGlitchShortMethod != null)
			{
				EmpressPlayerGlitchShortMethod(player);
			}
		}

		internal static void EnemyInvestigate(Vector3 position, float radius, bool pathfindOnly)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (EmpressWorldEnemyInvestigateMethod != null)
			{
				EmpressWorldEnemyInvestigateMethod(position, radius, pathfindOnly);
			}
		}

		internal static void SetEnemyChaseTarget(Enemy enemy, PlayerAvatar player)
		{
			if ((Object)(object)enemy != (Object)null && (Object)(object)player != (Object)null && EmpressEnemySetChaseTargetMethod != null)
			{
				EmpressEnemySetChaseTargetMethod(enemy, player);
			}
		}

		internal static void EnemyInvestigate(PhysGrabObjectImpactDetector impactDetector, float radius)
		{
			if ((Object)(object)impactDetector != (Object)null && EmpressEnemyInvestigateMethod != null)
			{
				EmpressEnemyInvestigateMethod(impactDetector, radius);
			}
		}

		internal static void PlayerHurtMultiplier(PhysGrabObjectImpactDetector impactDetector, float multiplier, float time)
		{
			if ((Object)(object)impactDetector != (Object)null && EmpressPlayerHurtMultiplierMethod != null)
			{
				EmpressPlayerHurtMultiplierMethod(impactDetector, multiplier, time);
			}
		}

		internal static void ImpactHeavy(PhysGrabObjectImpactDetector impactDetector, float force, Vector3 contactPoint)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)impactDetector != (Object)null && EmpressImpactHeavyMethod != null)
			{
				EmpressImpactHeavyMethod(impactDetector, force, contactPoint);
			}
		}

		internal static void BreakHeavy(PhysGrabObjectImpactDetector impactDetector, Vector3 contactPoint, bool forceBreak, float minimumValue)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)impactDetector != (Object)null && EmpressBreakHeavyMethod != null)
			{
				EmpressBreakHeavyMethod(impactDetector, contactPoint, forceBreak, minimumValue);
			}
		}

		internal static bool ToggleItem(ItemToggle itemToggle, bool toggle)
		{
			if ((Object)(object)itemToggle == (Object)null || EmpressToggleItemMethod == null || EmpressToggleIsBlocked(itemToggle))
			{
				return false;
			}
			try
			{
				EmpressToggleItemMethod(itemToggle, toggle, -1);
				return true;
			}
			catch (Exception exception)
			{
				EmpressBlockToggle(itemToggle, exception);
				return false;
			}
		}

		internal static bool ToggleDisable(ItemToggle itemToggle, bool disable)
		{
			if ((Object)(object)itemToggle == (Object)null || EmpressToggleDisableMethod == null || EmpressToggleIsBlocked(itemToggle))
			{
				return false;
			}
			try
			{
				EmpressToggleDisableMethod(itemToggle, disable);
				return true;
			}
			catch (Exception exception)
			{
				EmpressBlockToggle(itemToggle, exception);
				return false;
			}
		}

		private static bool EmpressToggleIsBlocked(ItemToggle itemToggle)
		{
			if (!((Object)(object)itemToggle == (Object)null))
			{
				return EmpressUnsafeItemToggles.Contains(((Object)itemToggle).GetInstanceID());
			}
			return true;
		}

		private static void EmpressBlockToggle(ItemToggle itemToggle, Exception exception)
		{
			if (!((Object)(object)itemToggle == (Object)null))
			{
				int instanceID = ((Object)itemToggle).GetInstanceID();
				if (EmpressUnsafeItemToggles.Add(instanceID))
				{
					EmpressAIPlugin.EmpressDebug("shop toggle guarded after game-side " + exception.GetType().Name);
				}
			}
		}

		private static FieldRef<object, F> EmpressStaticRef<F>(Type type, string name) where F : class
		{
			try
			{
				return AccessTools.FieldRefAccess<F>(type, name);
			}
			catch (Exception ex)
			{
				EmpressAIPlugin.EmpressWarning("access wrapper failed for " + type.Name + "." + name + ": " + ex.GetType().Name);
				return null;
			}
		}

		private static FieldRef<T, F> EmpressInstanceRef<T, F>(string name) where T : class
		{
			try
			{
				return AccessTools.FieldRefAccess<T, F>(name);
			}
			catch (Exception ex)
			{
				EmpressAIPlugin.EmpressWarning("access wrapper failed for " + typeof(T).Name + "." + name + ": " + ex.GetType().Name);
				return null;
			}
		}

		private static TDelegate EmpressStaticMethod<TDelegate>(Type type, string name, Type[] parameters = null) where TDelegate : Delegate
		{
			return EmpressMethod<TDelegate>(AccessTools.Method(type, name, parameters, (Type[])null));
		}

		private static TDelegate EmpressInstanceMethod<TDelegate>(Type type, string name, Type[] parameters = null) where TDelegate : Delegate
		{
			return EmpressMethod<TDelegate>(AccessTools.Method(type, name, parameters, (Type[])null));
		}

		private static TDelegate EmpressMethod<TDelegate>(MethodInfo methodInfo) where TDelegate : Delegate
		{
			try
			{
				return (methodInfo != null) ? AccessTools.MethodDelegate<TDelegate>(methodInfo, (object)null, false) : null;
			}
			catch (Exception ex)
			{
				EmpressAIPlugin.EmpressWarning("method wrapper failed: " + ex.GetType().Name);
				return null;
			}
		}

		private static T EmpressGetStatic<T>(FieldRef<object, T> fieldRef) where T : class
		{
			try
			{
				return (fieldRef != null) ? fieldRef.Invoke((object)null) : null;
			}
			catch
			{
				return null;
			}
		}

		private static F EmpressGet<T, F>(T instance, FieldRef<T, F> fieldRef) where T : class
		{
			try
			{
				return (instance != null && fieldRef != null) ? fieldRef.Invoke(instance) : default(F);
			}
			catch
			{
				return default(F);
			}
		}
	}
	internal static class EmpressAIBrainMemory
	{
		private static readonly Dictionary<EmpressAISabotageKind, EmpressAITacticMemory> EmpressMemory = new Dictionary<EmpressAISabotageKind, EmpressAITacticMemory>();

		private static bool EmpressLoaded;

		private static float EmpressNextSaveAt;

		private static string EmpressBrainPath => Path.Combine(Paths.ConfigPath, "EmpressYouVsAI.brain");

		internal static void EmpressLoad()
		{
			if (EmpressLoaded)
			{
				return;
			}
			EmpressLoaded = true;
			try
			{
				string empressBrainPath = EmpressBrainPath;
				if (!File.Exists(empressBrainPath))
				{
					return;
				}
				string[] array = File.ReadAllLines(empressBrainPath);
				for (int i = 0; i < array.Length; i++)
				{
					string[] array2 = array[i].Split('|');
					if (array2.Length == 6 && Enum.TryParse<EmpressAISabotageKind>(array2[0], out var result))
					{
						EmpressMemory[result] = new EmpressAITacticMemory
						{
							Attempts = EmpressParseInt(array2[1]),
							Hits = EmpressParseInt(array2[2]),
							Dodges = EmpressParseInt(array2[3]),
							Failures = EmpressParseInt(array2[4]),
							Bias = EmpressParseFloat(array2[5])
						};
					}
				}
			}
			catch (Exception ex)
			{
				EmpressAIPlugin.EmpressWarning("brain memory load failed: " + ex.GetType().Name);
			}
		}

		internal static float EmpressGetMultiplier(EmpressAISabotageKind kind)
		{
			EmpressLoad();
			EmpressAITacticMemory empressAITacticMemory = EmpressGet(kind);
			if (empressAITacticMemory.Attempts <= 0)
			{
				return 1f;
			}
			float num = (float)empressAITacticMemory.Hits / (float)Mathf.Max(1, empressAITacticMemory.Attempts);
			float num2 = (float)empressAITacticMemory.Dodges / (float)Mathf.Max(1, empressAITacticMemory.Attempts);
			float num3 = (float)empressAITacticMemory.Failures / (float)Mathf.Max(1, empressAITacticMemory.Attempts);
			return Mathf.Clamp(1f + empressAITacticMemory.Bias + num * 0.28f - num2 * 0.18f - num3 * 0.26f, 0.58f, 1.58f);
		}

		internal static void EmpressRecordAttempt(EmpressAISabotageKind kind)
		{
			EmpressAITacticMemory empressAITacticMemory = EmpressGet(kind);
			empressAITacticMemory.Attempts = Mathf.Min(empressAITacticMemory.Attempts + 1, 10000);
			EmpressScheduleSave();
		}

		internal static void EmpressRecordHit(EmpressAISabotageKind kind, float strength)
		{
			EmpressAITacticMemory empressAITacticMemory = EmpressGet(kind);
			empressAITacticMemory.Hits = Mathf.Min(empressAITacticMemory.Hits + 1, 10000);
			empressAITacticMemory.Bias = Mathf.Clamp(empressAITacticMemory.Bias + Mathf.Clamp(strength, 0.02f, 0.16f), -0.42f, 0.42f);
			EmpressScheduleSave();
		}

		internal static void EmpressRecordDodge(EmpressAISabotageKind kind, float strength)
		{
			EmpressAITacticMemory empressAITacticMemory = EmpressGet(kind);
			empressAITacticMemory.Dodges = Mathf.Min(empressAITacticMemory.Dodges + 1, 10000);
			empressAITacticMemory.Bias = Mathf.Clamp(empressAITacticMemory.Bias - Mathf.Clamp(strength, 0.015f, 0.12f), -0.42f, 0.42f);
			EmpressScheduleSave();
		}

		internal static void EmpressRecordFailure(EmpressAISabotageKind kind)
		{
			EmpressAITacticMemory empressAITacticMemory = EmpressGet(kind);
			empressAITacticMemory.Failures = Mathf.Min(empressAITacticMemory.Failures + 1, 10000);
			empressAITacticMemory.Bias = Mathf.Clamp(empressAITacticMemory.Bias - 0.035f, -0.42f, 0.42f);
			EmpressScheduleSave();
		}

		internal static void EmpressTickSave()
		{
			if (EmpressNextSaveAt > 0f && Time.unscaledTime >= EmpressNextSaveAt)
			{
				EmpressSave();
			}
		}

		internal static void EmpressSave()
		{
			EmpressNextSaveAt = 0f;
			try
			{
				string empressBrainPath = EmpressBrainPath;
				string directoryName = Path.GetDirectoryName(empressBrainPath);
				if (!string.IsNullOrWhiteSpace(directoryName))
				{
					Directory.CreateDirectory(directoryName);
				}
				List<string> list = new List<string>(EmpressMemory.Count);
				foreach (KeyValuePair<EmpressAISabotageKind, EmpressAITacticMemory> item in EmpressMemory)
				{
					EmpressAITacticMemory value = item.Value;
					list.Add(item.Key.ToString() + "|" + value.Attempts.ToString(CultureInfo.InvariantCulture) + "|" + value.Hits.ToString(CultureInfo.InvariantCulture) + "|" + value.Dodges.ToString(CultureInfo.InvariantCulture) + "|" + value.Failures.ToString(CultureInfo.InvariantCulture) + "|" + value.Bias.ToString("0.###", CultureInfo.InvariantCulture));
				}
				File.WriteAllLines(empressBrainPath, list);
			}
			catch (Exception ex)
			{
				EmpressAIPlugin.EmpressWarning("brain memory save failed: " + ex.GetType().Name);
			}
		}

		private static EmpressAITacticMemory EmpressGet(EmpressAISabotageKind kind)
		{
			EmpressLoad();
			if (!EmpressMemory.TryGetValue(kind, out EmpressAITacticMemory value))
			{
				value = new EmpressAITacticMemory();
				EmpressMemory[kind] = value;
			}
			return value;
		}

		private static void EmpressScheduleSave()
		{
			EmpressNextSaveAt = Time.unscaledTime + 6f;
		}

		private static int EmpressParseInt(string value)
		{
			if (!int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return 0;
			}
			return Mathf.Clamp(result, 0, 10000);
		}

		private static float EmpressParseFloat(string value)
		{
			if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return 0f;
			}
			return Mathf.Clamp(result, -0.42f, 0.42f);
		}
	}
	internal sealed class EmpressAIConfig
	{
		internal ConfigEntry<bool> Enabled { get; }

		internal ConfigEntry<bool> DebugLogging { get; }

		internal ConfigEntry<float> OverlayScale { get; }

		internal ConfigEntry<float> TypingCharactersPerSecond { get; }

		internal ConfigEntry<float> StartingFrustration { get; }

		internal ConfigEntry<float> FrustrationGainPerLevel { get; }

		internal ConfigEntry<float> BaseSabotageIntervalSeconds { get; }

		internal ConfigEntry<float> AggressionScale { get; }

		internal float EmpressOverlayScale => Mathf.Clamp(OverlayScale.Value, 0.75f, 1.5f);

		internal float EmpressTypingSpeed => Mathf.Clamp(TypingCharactersPerSecond.Value, 12f, 120f);

		internal float EmpressStartingFrustration => Mathf.Clamp(StartingFrustration.Value, 0f, 100f);

		internal float EmpressFrustrationGainPerLevel => Mathf.Clamp(FrustrationGainPerLevel.Value, -25f, 50f);

		internal float EmpressBaseSabotageInterval => Mathf.Clamp(BaseSabotageIntervalSeconds.Value, 2f, 30f);

		internal float EmpressAggressionScale => Mathf.Clamp(AggressionScale.Value, 0.25f, 4f);

		internal EmpressAIConfig(ConfigFile config)
		{
			Enabled = config.Bind<bool>("Empress General", "Enabled", true, "Enable You VS A.I.");
			DebugLogging = config.Bind<bool>("Empress General", "DebugLogging", false, "Enable concise Empress A.I. debug logs.");
			OverlayScale = config.Bind<float>("Empress Overlay", "OverlayScale", 1f, "Scale multiplier for the Empress A.I. overlay.");
			TypingCharactersPerSecond = config.Bind<float>("Empress Overlay", "TypingCharactersPerSecond", 36f, "Typing speed for the Empress A.I. chat overlay.");
			StartingFrustration = config.Bind<float>("Empress Directives", "StartingFrustration", 24f, "Starting frustration for a fresh run.");
			FrustrationGainPerLevel = config.Bind<float>("Empress Directives", "FrustrationGainPerLevel", 14f, "Frustration gained when the player survives into the next level.");
			BaseSabotageIntervalSeconds = config.Bind<float>("Empress Directives", "BaseSabotageIntervalSeconds", 8f, "Base delay between hostile actions.");
			AggressionScale = config.Bind<float>("Empress Directives", "AggressionScale", 1.15f, "Overall aggression multiplier for sabotage pacing.");
		}
	}
	internal enum EmpressAISabotageKind
	{
		NearbyThrow,
		ObjectFeint,
		LineBreaker,
		Crossfire,
		CeilingPincer,
		HeldObjectBackfire,
		ReturnToSender,
		ForcedCatch,
		BlindCatch,
		FloorSweep,
		BackstepPunish,
		BarricadeRoute,
		DoorTax,
		CornerClamp,
		ObjectOrbit,
		CeilingDrop,
		GravityBloom,
		FurnitureThrow,
		FurnitureOrbit,
		FurnitureAmbush,
		FurniturePincer,
		FurnitureRain,
		OverheadWake,
		ShelterCollapse,
		CamperJudgement,
		StillnessExecution,
		StillnessDebt,
		HallucinationPulse,
		ShopBetrayal,
		ShopGripTax,
		ShopExtractionDenial,
		ShopCascade,
		ShopShelfSweep,
		ItemPossession,
		ValuablePunish,
		GreedSpiral,
		FragilityCurse,
		MassAnchor,
		ShrapnelBurst,
		SideShove,
		SilentDrag,
		SlowField,
		GravityFlip,
		LookScramble,
		Tripwire,
		EnemyBait,
		DecoyCrash,
		NoiseChain,
		HunterLock,
		PredatorBeacon,
		PredatorPincer,
		EnemyCrossfire,
		CartRush,
		CartAmbush,
		LaneCollapse,
		CartPinball,
		ExitCutoff,
		JumpCut,
		Lockstep,
		DeadAngle,
		GravityWell,
		RoomCheckmate
	}
	internal enum EmpressAIPlayerProfile
	{
		Balanced,
		Greedy,
		Rusher,
		Cautious,
		Shopper,
		Survivor,
		Camper
	}
	internal readonly struct EmpressAISabotageOption
	{
		internal EmpressAISabotageKind Kind { get; }

		internal float Weight { get; }

		internal string PreviewText { get; }

		internal string Tactic { get; }

		internal PhysGrabObject? TargetObject { get; }

		internal PhysGrabObject? SecondaryObject { get; }

		internal ItemAttributes? TargetItem { get; }

		internal ItemAttributes? SecondaryItem { get; }

		internal Rigidbody? TargetBody { get; }

		internal Rigidbody? SecondaryBody { get; }

		internal EmpressAISabotageOption(EmpressAISabotageKind kind, float weight, string previewText, string tactic, PhysGrabObject? targetObject = null, PhysGrabObject? secondaryObject = null, ItemAttributes? targetItem = null, ItemAttributes? secondaryItem = null, Rigidbody? targetBody = null, Rigidbody? secondaryBody = null)
		{
			Kind = kind;
			Weight = weight;
			PreviewText = previewText;
			Tactic = tactic;
			TargetObject = targetObject;
			SecondaryObject = secondaryObject;
			TargetItem = targetItem;
			SecondaryItem = secondaryItem;
			TargetBody = targetBody;
			SecondaryBody = secondaryBody;
		}
	}
	internal sealed class EmpressAISabotagePlan
	{
		internal EmpressAISabotageKind Kind { get; }

		internal string PreviewText { get; }

		internal string Tactic { get; }

		internal PhysGrabObject? TargetObject { get; }

		internal PhysGrabObject? SecondaryObject { get; }

		internal ItemAttributes? TargetItem { get; }

		internal ItemAttributes? SecondaryItem { get; }

		internal Rigidbody? TargetBody { get; }

		internal Rigidbody? SecondaryBody { get; }

		internal float ExecuteAt { get; }

		internal EmpressAISabotagePlan(EmpressAISabotageOption option, float executeAt)
		{
			Kind = option.Kind;
			PreviewText = option.PreviewText;
			Tactic = option.Tactic;
			TargetObject = option.TargetObject;
			SecondaryObject = option.SecondaryObject;
			TargetItem = option.TargetItem;
			SecondaryItem = option.SecondaryItem;
			TargetBody = option.TargetBody;
			SecondaryBody = option.SecondaryBody;
			ExecuteAt = executeAt;
		}
	}
	internal readonly struct EmpressAIQueuedMessage
	{
		internal string Speaker { get; }

		internal string Text { get; }

		internal Color Accent { get; }

		internal float HoldSeconds { get; }

		internal string Timestamp { get; }

		internal EmpressAIQueuedMessage(string speaker, string text, Color accent, float holdSeconds)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Speaker = speaker;
			Text = text;
			Accent = accent;
			HoldSeconds = holdSeconds;
			Timestamp = DateTime.Now.ToString("HH:mm:ss");
		}
	}
	internal sealed class EmpressAIVisibleMessage
	{
		internal string Speaker { get; }

		internal string Text { get; }

		internal Color Accent { get; }

		internal float HoldSeconds { get; }

		internal string Timestamp { get; }

		internal float VisibleCharacters { get; set; }

		internal float CompletedAt { get; set; } = -1f;


		internal EmpressAIVisibleMessage(EmpressAIQueuedMessage source)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Speaker = source.Speaker;
			Text = source.Text;
			Accent = source.Accent;
			HoldSeconds = source.HoldSeconds;
			Timestamp = source.Timestamp;
		}
	}
	internal sealed class EmpressAITacticMemory
	{
		internal int Attempts { get; set; }

		internal int Hits { get; set; }

		internal int Dodges { get; set; }

		internal int Failures { get; set; }

		internal float Bias { get; set; }
	}
	internal sealed class EmpressAIOverlay : MonoBehaviour
	{
		private readonly List<EmpressAIQueuedMessage> _empressPendingMessages = new List<EmpressAIQueuedMessage>();

		private readonly List<EmpressAIVisibleMessage> _empressVisibleMessages = new List<EmpressAIVisibleMessage>();

		private Texture2D _empressPanelTexture;

		private Texture2D _empressHeaderTexture;

		private Texture2D _empressBarBackTexture;

		private Texture2D _empressBarFillTexture;

		private GUIStyle _empressTitleStyle;

		private GUIStyle _empressBodyStyle;

		private GUIStyle _empressSmallStyle;

		private GUIStyle _empressDeathStyle;

		private GUIStyle _empressStatusStyle;

		private bool _empressStylesReady;

		private EmpressAIVisibleMessage? _empressActiveMessage;

		private string _empressMode = "STANDBY";

		private string _empressScene = "boot";

		private string _empressTactic = "Waiting";

		private float _empressFrustration;

		private bool _empressGameplayVisible;

		private bool _empressMultiplayerLocked;

		private bool _empressUiVisible = true;

		private string _empressDeathBanner = string.Empty;

		private float _empressDeathBannerUntil;

		internal static EmpressAIOverlay? Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				((Behaviour)this).enabled = false;
				((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Instance = this;
				((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
				EmpressBuildTextures();
			}
		}

		private void Update()
		{
			if (!EmpressAIPlugin.EmpressConfig.Enabled.Value)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			float empressTypingSpeed = EmpressAIPlugin.EmpressConfig.EmpressTypingSpeed;
			if (_empressActiveMessage == null && _empressPendingMessages.Count > 0)
			{
				EmpressAIQueuedMessage source = _empressPendingMessages[0];
				_empressPendingMessages.RemoveAt(0);
				_empressActiveMessage = new EmpressAIVisibleMessage(source);
				_empressVisibleMessages.Add(_empressActiveMessage);
				if (_empressVisibleMessages.Count > 6)
				{
					_empressVisibleMessages.RemoveAt(0);
				}
			}
			if (_empressActiveMessage != null)
			{
				_empressActiveMessage.VisibleCharacters += empressTypingSpeed * Time.unscaledDeltaTime;
				if (_empressActiveMessage.VisibleCharacters >= (float)_empressActiveMessage.Text.Length)
				{
					_empressActiveMessage.VisibleCharacters = _empressActiveMessage.Text.Length;
					if (_empressActiveMessage.CompletedAt < 0f)
					{
						_empressActiveMessage.CompletedAt = unscaledTime;
					}
					if (unscaledTime - _empressActiveMessage.CompletedAt >= _empressActiveMessage.HoldSeconds)
					{
						_empressActiveMessage = null;
					}
				}
			}
			for (int num = _empressVisibleMessages.Count - 1; num >= 0; num--)
			{
				EmpressAIVisibleMessage empressAIVisibleMessage = _empressVisibleMessages[num];
				if (empressAIVisibleMessage != _empressActiveMessage && empressAIVisibleMessage.CompletedAt >= 0f && unscaledTime - empressAIVisibleMessage.CompletedAt > 30f)
				{
					_empressVisibleMessages.RemoveAt(num);
				}
			}
			if (_empressDeathBannerUntil > 0f && unscaledTime >= _empressDeathBannerUntil)
			{
				_empressDeathBannerUntil = 0f;
				_empressDeathBanner = string.Empty;
			}
		}

		private void OnGUI()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//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_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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Expected O, but got Unknown
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (current != null && (int)current.type == 4 && (int)current.keyCode == 287)
			{
				_empressUiVisible = !_empressUiVisible;
				current.Use();
			}
			if (!EmpressAIPlugin.EmpressConfig.Enabled.Value || !_empressUiVisible)
			{
				return;
			}
			if (!_empressStylesReady)
			{
				EmpressBuildStyles();
			}
			float empressOverlayScale = EmpressAIPlugin.EmpressConfig.EmpressOverlayScale;
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.Scale(new Vector3(empressOverlayScale, empressOverlayScale, 1f));
			float num = (float)Screen.width / empressOverlayScale;
			float num2 = (float)Screen.height / empressOverlayScale;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(24f, Mathf.Max(24f, num2 - 256f), Mathf.Min(560f, num - 48f), 224f);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(Mathf.Max(24f, num - 336f), 24f, 312f, 112f);
			GUI.DrawTexture(val, (Texture)(object)_empressPanelTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 34f), (Texture)(object)_empressHeaderTexture);
			GUI.Label(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 6f, ((Rect)(ref val)).width - 28f, 24f), "Empress A.I. messenger", _empressTitleStyle);
			GUI.DrawTexture(val2, (Texture)(object)_empressPanelTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width, 30f), (Texture)(object)_empressHeaderTexture);
			GUI.Label(new Rect(((Rect)(ref val2)).x + 12f, ((Rect)(ref val2)).y + 4f, ((Rect)(ref val2)).width - 24f, 22f), "Empress A.I. status", _empressTitleStyle);
			string text = (_empressMultiplayerLocked ? "MULTIPLAYER LOCK" : _empressMode);
			GUI.Label(new Rect(((Rect)(ref val2)).x + 14f, ((Rect)(ref val2)).y + 36f, ((Rect)(ref val2)).width - 28f, 20f), "Mode  " + text, _empressStatusStyle);
			GUI.Label(new Rect(((Rect)(ref val2)).x + 14f, ((Rect)(ref val2)).y + 58f, ((Rect)(ref val2)).width - 28f, 20f), "Scene  " + _empressScene, _empressStatusStyle);
			GUI.Label(new Rect(((Rect)(ref val2)).x + 14f, ((Rect)(ref val2)).y + 80f, ((Rect)(ref val2)).width - 28f, 20f), "Tactic  " + _empressTactic, _empressStatusStyle);
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + 168f, ((Rect)(ref val2)).y + 39f, 124f, 14f);
			GUI.DrawTexture(val3, (Texture)(object)_empressBarBackTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref val3)).x + 1f, ((Rect)(ref val3)).y + 1f, (((Rect)(ref val3)).width - 2f) * Mathf.Clamp01(_empressFrustration / 100f), ((Rect)(ref val3)).height - 2f), (Texture)(object)_empressBarFillTexture);
			GUI.Label(new Rect(((Rect)(ref val2)).x + 168f, ((Rect)(ref val2)).y + 54f, 124f, 18f), "Frustration " + Mathf.RoundToInt(_empressFrustration) + "%", _empressSmallStyle);
			float num3 = ((Rect)(ref val)).width - 24f;
			float num4 = ((Rect)(ref val)).yMax - 14f;
			for (int num5 = _empressVisibleMessages.Count - 1; num5 >= 0; num5--)
			{
				EmpressAIVisibleMessage empressAIVisibleMessage = _empressVisibleMessages[num5];
				string text2 = ((empressAIVisibleMessage == _empressActiveMessage) ? empressAIVisibleMessage.Text.Substring(0, Mathf.Clamp(Mathf.FloorToInt(empressAIVisibleMessage.VisibleCharacters), 0, empressAIVisibleMessage.Text.Length)) : empressAIVisibleMessage.Text);
				string text3 = ColorUtility.ToHtmlStringRGB(empressAIVisibleMessage.Accent);
				string text4 = "<color=#8CE8FF>[" + empressAIVisibleMessage.Timestamp + "] </color><color=#" + text3 + ">" + empressAIVisibleMessage.Speaker + "</color><color=#F2F8FF>: " + EmpressEscapeRichText(text2) + "</color>";
				float num6 = _empressBodyStyle.CalcHeight(new GUIContent(text4), num3);
				num4 -= num6;
				if (num4 <= ((Rect)(ref val)).y + 36f)
				{
					break;
				}
				GUI.Label(new Rect(((Rect)(ref val)).x + 12f, num4, num3, num6), text4, _empressBodyStyle);
				num4 -= 5f;
			}
			if (!_empressGameplayVisible)
			{
				GUI.Label(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y + 42f, ((Rect)(ref val)).width - 24f, 36f), _empressMultiplayerLocked ? "Come back alone. I only hunt in singleplayer." : "Watching the run state. Boot when ready.", _empressStatusStyle);
			}
			if (_empressDeathBannerUntil > 0f && !string.IsNullOrWhiteSpace(_empressDeathBanner))
			{
				Rect val4 = new Rect(num * 0.15f, num2 * 0.18f, num * 0.7f, 72f);
				GUI.DrawTexture(val4, (Texture)(object)_empressPanelTexture);
				GUI.Label(val4, _empressDeathBanner, _empressDeathStyle);
			}
			GUI.matrix = matrix;
		}

		internal void EmpressPushMessage(string text, Color accent, bool urgent = false, float holdSeconds = 7f)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(text))
			{
				return;
			}
			EmpressAIQueuedMessage item = new EmpressAIQueuedMessage("Empress A.I.", text.Trim(), accent, holdSeconds);
			if (urgent)
			{
				if (_empressActiveMessage != null)
				{
					_empressActiveMessage.VisibleCharacters = _empressActiveMessage.Text.Length;
					if (_empressActiveMessage.CompletedAt < 0f)
					{
						_empressActiveMessage.CompletedAt = Time.unscaledTime - _empressActiveMessage.HoldSeconds;
					}
					_empressActiveMessage = null;
				}
				_empressPendingMessages.Insert(0, item);
			}
			else
			{
				_empressPendingMessages.Add(item);
			}
		}

		internal void EmpressShowDeath(string text)
		{
			_empressDeathBanner = "Death logged: " + text;
			_empressDeathBannerUntil = Time.unscaledTime + 9f;
		}

		internal void EmpressSetStatus(bool gameplayVisible, bool multiplayerLocked, string mode, string scene, float frustration, string tactic)
		{
			_empressGameplayVisible = gameplayVisible;
			_empressMultiplayerLocked = multiplayerLocked;
			_empressMode = mode;
			_empressScene = scene;
			_empressFrustration = frustration;
			_empressTactic = tactic;
		}

		private void EmpressBuildTextures()
		{
			//IL_0015: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			_empressPanelTexture = EmpressMakeTexture(new Color(0.05f, 0.08f, 0.13f, 0.92f));
			_empressHeaderTexture = EmpressMakeTexture(new Color(0.07f, 0.33f, 0.44f, 0.97f));
			_empressBarBackTexture = EmpressMakeTexture(new Color(0.11f, 0.13f, 0.17f, 1f));
			_empressBarFillTexture = EmpressMakeTexture(new Color(0.96f, 0.26f, 0.41f, 1f));
		}

		private void EmpressBuildStyles()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_008f: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00e5: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			Font val = Font.CreateDynamicFontFromOSFont(new string[4] { "Consolas", "Lucida Console", "Courier New", "Segoe UI" }, 16);
			if ((Object)(object)val == (Object)null)
			{
				val = GUI.skin.font;
			}
			GUIStyle val2 = new GUIStyle(GUI.skin.label)
			{
				font = val,
				fontSize = 16,
				fontStyle = (FontStyle)1
			};
			val2.normal.textColor = Color.white;
			val2.alignment = (TextAnchor)3;
			_empressTitleStyle = val2;
			GUIStyle val3 = new GUIStyle(GUI.skin.label)
			{
				font = val,
				fontSize = 15,
				wordWrap = true,
				richText = true
			};
			val3.normal.textColor = new Color(0.95f, 0.97f, 1f, 1f);
			_empressBodyStyle = val3;
			GUIStyle val4 = new GUIStyle(GUI.skin.label)
			{
				font = val,
				fontSize = 12
			};
			val4.normal.textColor = new Color(0.82f, 0.9f, 0.98f, 1f);
			val4.alignment = (TextAnchor)3;
			_empressSmallStyle = val4;
			GUIStyle val5 = new GUIStyle(GUI.skin.label)
			{
				font = val,
				fontSize = 13
			};
			val5.normal.textColor = new Color(0.88f, 0.95f, 1f, 1f);
			val5.alignment = (TextAnchor)3;
			_empressStatusStyle = val5;
			GUIStyle val6 = new GUIStyle(GUI.skin.label)
			{
				font = val,
				fontSize = 24,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4,
				wordWrap = true
			};
			val6.normal.textColor = new Color(1f, 0.54f, 0.58f, 1f);
			_empressDeathStyle = val6;
			_empressStylesReady = true;
		}

		private static Texture2D EmpressMakeTexture(Color color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61
			};
			val.SetPixel(0, 0, color);
			val.Apply();
			return val;
		}

		private static string EmpressEscapeRichText(string text)
		{
			return text.Replace("<", "&lt;").Replace(">", "&gt;");
		}
	}
	[BepInPlugin("empress.repo.youvsai", "You VS A.I", "1.0.0")]
	public sealed class EmpressAIPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "empress.repo.youvsai";

		public const string PluginName = "You VS A.I";

		public const string PluginVersion = "1.0.0";

		private static GameObject? EmpressRuntimeHost;

		internal static EmpressAIPlugin Plugin { get; private set; }

		internal static EmpressAIConfig EmpressConfig { get; private set; }

		private void Awake()
		{
			Plugin = this;
			EmpressConfig = new EmpressAIConfig(((BaseUnityPlugin)this).Config);
			EmpressEnsureRuntimeHost();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[EmpressA.I.] loaded");
		}

		internal static void EmpressEnsureRuntimeHost()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			EmpressAIRuntime empressAIRuntime = default(EmpressAIRuntime);
			if (!((Object)(object)EmpressRuntimeHost != (Object)null) || !EmpressRuntimeHost.TryGetComponent<EmpressAIRuntime>(ref empressAIRuntime))
			{
				EmpressRuntimeHost = new GameObject("EmpressAIRuntimeHost");
				((Object)EmpressRuntimeHost).hideFlags = (HideFlags)61;
				Object.DontDestroyOnLoad((Object)(object)EmpressRuntimeHost);
				EmpressRuntimeHost.AddComponent<EmpressAIOverlay>();
				EmpressRuntimeHost.AddComponent<EmpressAIRuntime>();
			}
		}

		internal static void EmpressInfo(string message)
		{
			((BaseUnityPlugin)Plugin).Logger.LogInfo((object)("[EmpressA.I.] " + message));
		}

		internal static void EmpressWarning(string message)
		{
			((BaseUnityPlugin)Plugin).Logger.LogWarning((object)("[EmpressA.I.] " + message));
		}

		internal static void EmpressError(string message)
		{
			((BaseUnityPlugin)Plugin).Logger.LogError((object)("[EmpressA.I.] " + message));
		}

		internal static void EmpressDebug(string message)
		{
			if (EmpressConfig.DebugLogging.Value)
			{
				((BaseUnityPlugin)Plugin).Logger.LogInfo((object)("[EmpressA.I.] " + message));
			}
		}
	}
	internal sealed class EmpressAIRuntime : MonoBehaviour
	{
		private readonly List<EmpressAISabotageOption> _empressSabotageOptions = new List<EmpressAISabotageOption>(160);

		private readonly Dictionary<EmpressAISabotageKind, float> _empressLastSabotageAt = new Dictionary<EmpressAISabotageKind, float>(32);

		private readonly Dictionary<int, float> _empressLastFamilyAt = new Dictionary<int, float>(12);

		private readonly List<Rigidbody> _empressAwakenedFurniture = new List<Rigidbody>(24);

		private readonly HashSet<int> _empressAwakenedFurnitureSources = new HashSet<int>();

		private readonly List<string> _empressRecentPhrases = new List<string>(10);

		private PhysGrabObject[] _empressPhysCache = (PhysGrabObject[])(object)new PhysGrabObject[0];

		private ItemAttributes[] _empressItemCache = (ItemAttributes[])(object)new ItemAttributes[0];

		private Enemy[] _empressEnemyCache = (Enemy[])(object)new Enemy[0];

		private EmpressAISabotagePlan? _empressPendingSabotage;

		private EmpressAISabotageKind? _empressOutcomeKind;

		private float _empressFrustration;

		private float _empressNextSabotageAt;

		private float _empressLastCauseAt = -999f;

		private float _empressSceneEnteredAt;

		private float _empressLastPlayerDamageAt;

		private float _empressLastPositionSampleAt;

		private float _empressOutcomeDeadline;

		private float _empressOutcomeStartFrustration;

		private float _empressPlayerSpeedScore;

		private float _empressCarryScore;

		private float _empressShopScore;

		private float _empressSurvivalScore;

		private float _empressStillScore;

		private float _empressUnderCoverScore;

		private float _empressDodgeScore;

		private float _empressSatisfiedUntil;

		private float _empressSceneScanAt = -999f;

		private int _empressLastHealth = -1;

		private int _empressOutcomeStartHealth = -1;

		private int _empressLastShoppingListCount = -1;

		private bool _empressSceneScanHasShop;

		private bool _empressDeathAnnounced;

		private bool _empressFirstGameplayIntro;

		private bool _empressMultiplayerWarned;

		private Vector3 _empressLastSamplePosition;

		private Vector3 _empressLastMeasuredVelocity;

		private Vector3 _empressOutcomeStartPosition;

		private string _empressSceneKey = string.Empty;

		private string _empressCurrentTactic = "Waiting";

		private string _empressLastCauseText = "catastrophic override";

		private EmpressAIPlayerProfile _empressPlayerProfile;

		private EmpressAISabotageKind? _empressLastSabotageKind;

		private EmpressAISabotageKind? _empressPreviousSabotageKind;

		private void Awake()
		{
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			EmpressAIBrainMemory.EmpressLoad();
			if (_empressFrustration <= 0f)
			{
				_empressFrustration = EmpressAIPlugin.EmpressConfig.EmpressStartingFrustration;
			}
		}

		private void OnEnable()
		{
			SceneManager.sceneLoaded += EmpressOnSceneLoaded;
		}

		private void OnDisable()
		{
			SceneManager.sceneLoaded -= EmpressOnSceneLoaded;
		}

		private void Update()
		{
			//IL_0077: 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_0137: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Invalid comparison between Unknown and I4
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Invalid comparison between Unknown and I4
			EmpressAIPlugin.EmpressEnsureRuntimeHost();
			EmpressAIOverlay instance = EmpressAIOverlay.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			if (!EmpressAIPlugin.EmpressConfig.Enabled.Value)
			{
				instance.EmpressSetStatus(gameplayVisible: false, multiplayerLocked: false, "DISABLED", "boot", _empressFrustration, "Sleeping");
				return;
			}
			GameManager gameManagerInstance = EmpressAIAccess.GameManagerInstance;
			RunManager runManagerInstance = EmpressAIAccess.RunManagerInstance;
			GameDirector gameDirectorInstance = EmpressAIAccess.GameDirectorInstance;
			Scene activeScene;
			if ((Object)(object)gameManagerInstance == (Object)null || (Object)(object)runManagerInstance == (Object)null || (Object)(object)gameDirectorInstance == (Object)null)
			{
				activeScene = SceneManager.GetActiveScene();
				instance.EmpressSetStatus(gameplayVisible: false, multiplayerLocked: false, "BOOT", ((Scene)(ref activeScene)).name, _empressFrustration, "Waiting");
				return;
			}
			if (EmpressAIAccess.IsMultiplayer())
			{
				if (!_empressMultiplayerWarned)
				{
					instance.EmpressPushMessage("Multiplayer detected. I am staying out of that one. Come back alone.", new Color(0.86f, 0.56f, 1f, 1f), urgent: true, 8f);
					EmpressAIPlugin.EmpressInfo("multiplayer detected, sabotage disabled");
					_empressMultiplayerWarned = true;
				}
				activeScene = SceneManager.GetActiveScene();
				instance.EmpressSetStatus(gameplayVisible: false, multiplayerLocked: true, "MULTIPLAYER LOCK", ((Scene)(ref activeScene)).name, _empressFrustration, "Dormant");
				return;
			}
			_empressMultiplayerWarned = false;
			PlayerAvatar localPlayer = EmpressAIAccess.GetLocalPlayer();
			PlayerHealth playerHealth = EmpressAIAccess.GetPlayerHealth(localPlayer);
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)playerHealth == (Object)null)
			{
				activeScene = SceneManager.GetActiveScene();
				instance.EmpressSetStatus(gameplayVisible: false, multiplayerLocked: false, "WAITING", ((Scene)(ref activeScene)).name, _empressFrustration, "Looking for player");
				return;
			}
			string text = EmpressBuildSceneLabel();
			if (!EmpressSceneIsSupported())
			{
				instance.EmpressSetStatus(gameplayVisible: false, multiplayerLocked: false, "STANDBY", text, _empressFrustration, "Watching");
				return;
			}
			if (!EmpressGameplayReady())
			{
				instance.EmpressSetStatus(gameplayVisible: true, multiplayerLocked: false, "ARMING", text, _empressFrustration, "Reading level");
				return;
			}
			EmpressArmSceneIfNeeded(text, localPlayer);
			EmpressTrackPlayerProfile(localPlayer, playerHealth);
			EmpressObservePlayer(localPlayer, playerHealth);
			EmpressAIBrainMemory.EmpressTickSave();
			if (EmpressAIAccess.IsDead(localPlayer))
			{
				_empressPendingSabotage = null;
				if (!_empressDeathAnnounced)
				{
					EmpressAnnounceDeath(text);
				}
				instance.EmpressSetStatus(gameplayVisible: true, multiplayerLocked: false, "POST MORTEM", text, _empressFrustration, "Recording death");
				return;
			}
			gameState gameState = EmpressAIAccess.GetGameState(gameDirectorInstance);
			if ((int)gameState != 2 && (int)gameState != 1)
			{
				instance.EmpressSetStatus(gameplayVisible: true, multiplayerLocked: false, "WAITING", text, _empressFrustration, _empressCurrentTactic);
				return;
			}
			EmpressTickFrustration(localPlayer, playerHealth);
			EmpressTickSabotage(text, localPlayer);
			instance.EmpressSetStatus(gameplayVisible: true, multiplayerLocked: false, EmpressAIAccess.RunIsShop() ? "SHOP OVERRIDE" : "HUNTING", text, _empressFrustration, _empressCurrentTactic);
		}

		private void EmpressOnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			_empressSceneKey = string.Empty;
			_empressPendingSabotage = null;
			_empressOutcomeKind = null;
			_empressOutcomeDeadline = 0f;
			_empressOutcomeStartHealth = -1;
			_empressLastHealth = -1;
			_empressLastShoppingListCount = -1;
			_empressDeathAnnounced = false;
			_empressSatisfiedUntil = 0f;
			_empressLastPositionSampleAt = 0f;
			_empressLastMeasuredVelocity = Vector3.zero;
			_empressStillScore = 0f;
			_empressUnderCoverScore = 0f;
			_empressDodgeScore = 0f;
			_empressAwakenedFurniture.Clear();
			_empressAwakenedFurnitureSources.Clear();
			EmpressResetSceneScan();
			_empressCurrentTactic = "Scanning " + ((Scene)(ref scene)).name;
			EmpressAIPlugin.EmpressDebug("scene loaded: " + ((Scene)(ref scene)).name);
		}

		private static bool EmpressSceneIsSupported()
		{
			if (!EmpressAIAccess.RunIsLevel())
			{
				return EmpressAIAccess.RunIsShop();
			}
			return true;
		}

		private static bool EmpressGameplayReady()
		{
			LevelGenerator levelGeneratorInstance = EmpressAIAccess.LevelGeneratorInstance;
			if ((Object)(object)levelGeneratorInstance != (Object)null && !EmpressAIAccess.IsLevelGenerated(levelGeneratorInstance))
			{
				return false;
			}
			if (EmpressAIAccess.GetPlayerCount(EmpressAIAccess.GameDirectorInstance) <= 0 && (Object)(object)EmpressAIAccess.PlayerAvatarInstance == (Object)null)
			{
				return false;
			}
			return true;
		}

		private string EmpressBuildSceneLabel()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			Level currentLevel = EmpressAIAccess.GetCurrentLevel(EmpressAIAccess.RunManagerInstance);
			if ((Object)(object)currentLevel != (Object)null)
			{
				return ((Object)currentLevel).name;
			}
			return name;
		}

		private void EmpressArmSceneIfNeeded(string sceneLabel, PlayerAvatar player)
		{
			//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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			string[] obj = new string[5]
			{
				sceneLabel,
				"|",
				EmpressAIAccess.GetLevelsCompleted(EmpressAIAccess.RunManagerInstance).ToString(),
				"|",
				null
			};
			Scene activeScene = SceneManager.GetActiveScene();
			obj[4] = ((Scene)(ref activeScene)).buildIndex.ToString();
			string text = string.Concat(obj);
			if (text == _empressSceneKey)
			{
				return;
			}
			if (!string.IsNullOrEmpty(_empressSceneKey))
			{
				if (_empressDeathAnnounced)
				{
					_empressFrustration = Mathf.Clamp(_empressFrustration - Random.Range(16f, 28f), 0f, 100f);
				}
				else
				{
					_empressFrustration = Mathf.Clamp(_empressFrustration + EmpressAIPlugin.EmpressConfig.EmpressFrustrationGainPerLevel + (EmpressAIAccess.RunIsShop() ? 8f : 4f), 0f, 100f);
				}
			}
			else
			{
				_empressFrustration = EmpressAIPlugin.EmpressConfig.EmpressStartingFrustration;
			}
			_empressSceneKey = text;
			_empressPendingSabotage = null;
			_empressOutcomeKind = null;
			_empressOutcomeDeadline = 0f;
			_empressOutcomeStartHealth = -1;
			_empressSceneEnteredAt = Time.unscaledTime;
			_empressLastPlayerDamageAt = Time.unscaledTime;
			_empressSatisfiedUntil = 0f;
			_empressLastPositionSampleAt = Time.unscaledTime;
			_empressLastSamplePosition = ((Component)player).transform.position;
			_empressLastMeasuredVelocity = Vector3.zero;
			_empressPlayerSpeedScore *= 0.45f;
			_empressCarryScore *= 0.6f;
			_empressShopScore *= 0.7f;
			_empressSurvivalScore *= 0.55f;
			_empressStillScore = 0f;
			_empressUnderCoverScore = 0f;
			_empressDodgeScore = 0f;
			_empressPlayerProfile = EmpressAIPlayerProfile.Balanced;
			_empressDeathAnnounced = false;
			EmpressResetSceneScan();
			_empressLastHealth = EmpressAIAccess.GetHealth(EmpressAIAccess.GetPlayerHealth(player));
			_empressLastShoppingListCount = EmpressAIAccess.GetShoppingCount(EmpressAIAccess.ShopManagerInstance);
			_empressNextSabotageAt = Time.unscaledTime + Random.Range(9.4f, 15.6f) * Mathf.Lerp(1.08f, 0.86f, _empressFrustration / 100f);
			_empressCurrentTactic = (EmpressAIAccess.RunIsShop() ? "Shop breach prepared" : "Route analysis ready");
			EmpressAIOverlay instance = EmpressAIOverlay.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				if (!_empressFirstGameplayIntro)
				{
					instance.EmpressPushMessage("Singleplayer link established. Good. No witnesses.", new Color(0.72f, 0.93f, 1f, 1f), urgent: true);
					_empressFirstGameplayIntro = true;
				}
				instance.EmpressPushMessage(EmpressAIAccess.RunIsShop() ? "Shop connection acquired. I am reading the stock." : ("Level " + sceneLabel + " mapped. I am building a plan."), new Color(0.72f, 0.93f, 1f, 1f), urgent: true, 6f);
			}
			EmpressAIPlugin.EmpressInfo("scene armed: " + sceneLabel + " frustration " + Mathf.RoundToInt(_empressFrustration) + "%");
		}

		private void EmpressObservePlayer(PlayerAvatar player, PlayerHealth playerHealth)
		{
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			int health = EmpressAIAccess.GetHealth(playerHealth);
			if (_empressLastHealth >= 0 && health < _empressLastHealth)
			{
				int num = _empressLastHealth - health;
				bool num2 = Time.unscaledTime - _empressLastCauseAt <= 10f;
				float num3 = (num2 ? Mathf.Max(10f, (float)num * 1.18f + Random.Range(6f, 12f)) : Mathf.Max(4f, (float)num * 0.68f));
				_empressFrustration = Mathf.Clamp(_empressFrustration - num3, 0f, 100f);
				_empressLastPlayerDamageAt = Time.unscaledTime;
				_empressSurvivalScore = Mathf.Max(0f, _empressSurvivalScore - num3 * 0.55f);
				_empressDodgeScore = Mathf.Max(0f, _empressDodgeScore - num3 * 0.4f);
				if (num2)
				{
					if (_empressOutcomeKind.HasValue)
					{
						EmpressAIBrainMemory.EmpressRecordHit(_empressOutcomeKind.Value, Mathf.Clamp((float)num / 120f, 0.04f, 0.18f));
					}
					_empressOutcomeKind = null;
					_empressOutcomeDeadline = 0f;
					_empressSatisfiedUntil = Time.unscaledTime + Random.Range(8f, 15f);
					_empressPendingSabotage = null;
					_empressNextSabotageAt = Mathf.Max(_empressNextSabotageAt, _empressSatisfiedUntil + Random.Range(2.5f, 6.5f));
					_empressCurrentTactic = "Satisfied";
					EmpressAIOverlay.Instance?.EmpressPushMessage(EmpressPickFresh("Fine. That counted. I am lowering the heat for exactly one breath.", "Good hit. I will pretend that was enough.", "There. The bar drops. Do not get proud.", "Damage acknowledged. I am recalculating instead of screaming."), new Color(0.72f, 0.93f, 1f, 1f), urgent: true, 4.8f);
				}
				else
				{
					EmpressAIOverlay.Instance?.EmpressPushMessage(EmpressPickFresh("The level hurt you without me. I still learn from it.", "Not my move, but your pain is useful data.", "Damage is damage. I am calmer for now."), new Color(0.72f, 0.93f, 1f, 1f), urgent: true, 4f);
				}
			}
			_empressLastHealth = health;
			EmpressEvaluateOutcome(player, health);
			ShopManager shopManagerInstance = EmpressAIAccess.ShopManagerInstance;
			if ((Object)(object)shopManagerInstance != (Object)null)
			{
				int shoppingCount = EmpressAIAccess.GetShoppingCount(shopManagerInstance);
				if (_empressLastShoppingListCount >= 0 && shoppingCount > _empressLastShoppingListCount)
				{
					_empressFrustration = Mathf.Clamp(_empressFrustration + 5f, 0f, 100f);
					_empressShopScore = Mathf.Clamp(_empressShopScore + 4f, 0f, 100f);
				}
				_empressLastShoppingListCount = shoppingCount;
			}
		}

		private void EmpressStartOutcomeTracking(EmpressAISabotageKind kind, PlayerAvatar player)
		{
			//IL_0038: 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)
			PlayerHealth playerHealth = EmpressAIAccess.GetPlayerHealth(player);
			_empressOutcomeKind = kind;
			_empressOutcomeDeadline = Time.unscaledTime + EmpressGetOutcomeWindow(kind);
			_empressOutcomeStartHealth = EmpressAIAccess.GetHealth(playerHealth);
			_empressOutcomeStartPosition = ((Component)player).transform.position;
			_empressOutcomeStartFrustration = _empressFrustration;
			EmpressAIBrainMemory.EmpressRecordAttempt(kind);
		}

		private void EmpressEvaluateOutcome(PlayerAvatar player, int currentHealth)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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)
			if (!_empressOutcomeKind.HasValue || Time.unscaledTime < _empressOutcomeDeadline)
			{
				return;
			}
			EmpressAISabotageKind value = _empressOutcomeKind.Value;
			_empressOutcomeKind = null;
			_empressOutcomeDeadline = 0f;
			if ((Vector3.Distance(((Component)player).transform.position, _empressOutcomeStartPosition) >= 2.4f || ((Vector3)(ref _empressLastMeasuredVelocity)).magnitude >= 1.6f) && currentHealth >= _empressOutcomeStartHealth)
			{
				float num = Mathf.Lerp(2.5f, 7.5f, Mathf.InverseLerp(40f, 100f, _empressOutcomeStartFrustration));
				if (_empressPlayerProfile != EmpressAIPlayerProfile.Camper)
				{
					num += 2.5f;
				}
				_empressFrustration = Mathf.Clamp(_empressFrustration - num, 0f, 100f);
				_empressDodgeScore = Mathf.Clamp(_empressDodgeScore + num * 0.7f, 0f, 100f);
				EmpressAIBrainMemory.EmpressRecordDodge(value, num / 80f);
				if (Random.value < 0.36f)
				{
					EmpressAIOverlay.Instance?.EmpressPushMessage(EmpressPickFresh("You dodged the thought. Annoying. Effective.", "That escape was clean. I hate that.", "You moved before the room closed. I saw it.", "Fine. Your evasion earns a lower bar."), new Color(0.72f, 0.93f, 1f, 1f), urgent: true, 4.6f);
				}
			}
			else if (currentHealth >= _empressOutcomeStartHealth)
			{
				EmpressAIBrainMemory.EmpressRecordFailure(value);
				_empressDodgeScore = Mathf.Clamp(_empressDodgeScore + 1.2f, 0f, 100f);
			}
		}

		private static float EmpressGetOutcomeWindow(EmpressAISabotageKind kind)
		{
			switch (kind)
			{
			case EmpressAISabotageKind.HunterLock:
			case EmpressAISabotageKind.PredatorBeacon:
			case EmpressAISabotageKind.PredatorPincer:
			case EmpressAISabotageKind.EnemyCrossfire:
				return 13f;
			case EmpressAISabotageKind.ShelterCollapse:
			case EmpressAISabotageKind.StillnessExecution:
			case EmpressAISabotageKind.StillnessDebt:
			case EmpressAISabotageKind.RoomCheckmate:
				return 10.5f;
			case EmpressAISabotageKind.FurniturePincer:
			case EmpressAISabotageKind.FurnitureRain:
			case EmpressAISabotageKind.OverheadWake:
			case EmpressAISabotageKind.ShopExtractionDenial:
			case EmpressAISabotageKind.GravityWell:
				return 9f;
			default:
				return 7.5f;
			}
		}

		private void EmpressTrackPlayerProfile(PlayerAvatar player, PlayerHealth playerHealth)
		{
			//IL_004f: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			float unscaledTime = Time.unscaledTime;
			float num = unscaledTime - _empressLastPositionSampleAt;
			if (num < 0.7f)
			{
				return;
			}
			if (_empressLastPositionSampleAt <= 0f)
			{
				_empressLastPositionSampleAt = unscaledTime;
				_empressLastSamplePosition = ((Component)player).transform.position;
				_empressLastMeasuredVelocity = Vector3.zero;
				return;
			}
			Vector3 val = ((Component)player).transform.position - _empressLastSamplePosition;
			_empressLastMeasuredVelocity = Vector3.ClampMagnitude(val / Mathf.Max(num, 0.01f), 7.5f);
			float num2 = ((Vector3)(ref val)).magnitude / Mathf.Max(num, 0.01f);
			_empressLastPositionSampleAt = unscaledTime;
			_empressLastSamplePosition = ((Component)player).transform.position;
			_empressPlayerSpeedScore = Mathf.Clamp(_empressPlayerSpeedScore * 0.94f + Mathf.InverseLerp(2.2f, 7.2f, num2) * 3.2f, 0f, 100f);
			_empressCarryScore = Mathf.Clamp(_empressCarryScore * 0.94f, 0f, 100f);
			_empressShopScore = Mathf.Clamp(_empressShopScore * 0.96f, 0f, 100f);
			_empressSurvivalScore = Mathf.Clamp(_empressSurvivalScore * 0.985f + Mathf.InverseLerp(24f, 110f, unscaledTime - _empressLastPlayerDamageAt) * 1.8f, 0f, 100f);
			if (num2 < 0.22f)
			{
				_empressStillScore = Mathf.Clamp(_empressStillScore + 4.8f, 0f, 100f);
			}
			else if (num2 < 0.7f)
			{
				_empressStillScore = Mathf.Clamp(_empressStillScore + 1.4f, 0f, 100f);
			}
			else
			{
				_empressStillScore = Mathf.Clamp(_empressStillScore * 0.82f - 1.2f, 0f, 100f);
			}
			if (EmpressPlayerHasOverheadCover(player))
			{
				_empressUnderCoverScore = Mathf.Clamp(_empressUnderCoverScore + ((num2 < 0.8f) ? 4.2f : 1.4f), 0f, 100f);
			}
			else
			{
				_empressUnderCoverScore = Mathf.Clamp(_empressUnderCoverScore * 0.84f - 0.8f, 0f, 100f);
			}
			PhysGrabObject val2 = EmpressGetHeldObject();
			if ((Object)(object)val2 != (Object)null)
			{
				_empressCarryScore = Mathf.Clamp(_empressCarryScore + 2.6f, 0f, 100f);
				if ((Object)(object)((Component)val2).GetComponent<ValuableObject>() != (Object)null)
				{
					_empressCarryScore = Mathf.Clamp(_empressCarryScore + 3.4f, 0f, 100f);
				}
			}
			if (EmpressAIAccess.RunIsShop())
			{
				_empressShopScore = Mathf.Clamp(_empressShopScore + 1.3f, 0f, 100f);
			}
			float num3 = (float)EmpressAIAccess.GetHealth(playerHealth) / (float)Mathf.Max(1, EmpressAIAccess.GetMaxHealth(playerHealth));
			EmpressAIPlayerProfile empressAIPlayerProfile = EmpressAIPlayerProfile.Balanced;
			if (EmpressAIAccess.RunIsShop() && _empressShopScore >= 16f)
			{
				empressAIPlayerProfile = EmpressAIPlayerProfile.Shopper;
			}
			else if (_empressStillScore >= 18f && num3 > 0.18f)
			{
				empressAIPlayerProfile = EmpressAIPlayerProfile.Camper;
			}
			else if (_empressCarryScore >= Mathf.Max(17f, _empressPlayerSpeedScore + 4f))
			{
				empressAIPlayerProfile = EmpressAIPlayerProfile.Greedy;
			}
			else if (_empressPlayerSpeedScore >= 22f && num3 > 0.38f)
			{
				empressAIPlayerProfile = EmpressAIPlayerProfile.Rusher;
			}
			else if (num3 <= 0.38f || num2 < 0.45f)
			{
				empressAIPlayerProfile = EmpressAIPlayerProfile.Cautious;
			}
			else if (_empressSurvivalScore >= 30f)
			{
				empressAIPlayerProfile = EmpressAIPlayerProfile.Survivor;
			}
			if (empressAIPlayerProfile != _empressPlayerProfile)
			{
				_empressPlayerProfile = empressAIPlayerProfile;
				EmpressAIPlugin.EmpressDebug("profile shifted to " + _empressPlayerProfile);
			}
		}

		private void EmpressTickFrustration(PlayerAvatar player, PlayerHealth playerHealth)
		{
			//IL_016f: 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)
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			float num = (EmpressAIAccess.RunIsShop() ? 0.55f : 0.35f);
			num += Mathf.Clamp01((float)EmpressAIAccess.GetLevelsCompleted(EmpressAIAccess.RunManagerInstance) / 10f) * 0.35f;
			num += Mathf.InverseLerp(18f, 80f, Time.unscaledTime - _empressLastPlayerDamageAt) * 0.55f;
			PhysGrabObject val = EmpressGetHeldObject();
			if ((Object)(object)val != (Object)null)
			{
				num += 0.25f;
				if ((Object)(object)((Component)val).GetComponent<ValuableObject>() != (Object)null)
				{
					num += 0.45f;
				}
			}
			if (EmpressAIAccess.GetHealth(playerHealth) <= Mathf.CeilToInt((float)EmpressAIAccess.GetMaxHealth(playerHealth) * 0.3f))
			{
				num -= 0.85f;
			}
			if (_empressPendingSabotage != null)
			{
				num += 0.08f;
			}
			if (Time.unscaledTime < _empressSatisfiedUntil)
			{
				num -= 0.28f;
			}
			num += _empressSurvivalScore * 0.004f;
			num += _empressStillScore * 0.007f;
			num -= _empressDodgeScore * 0.0035f;
			if (_empressPlayerProfile == EmpressAIPlayerProfile.Camper)
			{
				num += 0.32f;
			}
			else if (((Vector3)(ref _empressLastMeasuredVelocity)).magnitude >= 1.4f && Time.unscaledTime - _empressLastPlayerDamageAt < 26f)
			{
				num -= 0.16f;
			}
			if (_empressUnderCoverScore >= 14f)
			{
				num += Mathf.InverseLerp(14f, 70f, _empressUnderCoverScore) * 0.5f;
			}
			if (Vector3.Distance(((Component)player).transform.position, Vector3.zero) > 70f)
			{
				num += 0.05f;
			}
			_empressFrustration = Mathf.Clamp(_empressFrustration + num * unscaledDeltaTime, 0f, 100f);
		}

		private void EmpressTickSabotage(string sceneLabel, PlayerAvatar player)
		{
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime < _empressSatisfiedUntil)
			{
				_empressCurrentTactic = "Watching the result";
			}
			else if (_empressPendingSabotage != null)
			{
				if (!(Time.unscaledTime < _empressPendingSabotage.ExecuteAt))
				{
					bool flag = EmpressExecutePlannedSabotage(player, _empressPendingSabotage);
					if (flag)
					{
						EmpressRecordSabotage(_empressPendingSabotage.Kind);
						EmpressStartOutcomeTracking(_empressPendingSabotage.Kind, player);
					}
					_empressPendingSabotage = null;
					EmpressScheduleNextSabotage(flag, sceneLabel);
				}
			}
			else
			{
				if (Time.unscaledTime < _empressNextSabotageAt)
				{
					return;
				}
				if (_empressLastPlayerDamageAt > _empressSceneEnteredAt + 1f)
				{
					float num = Mathf.Lerp(8.8f, 4.6f, _empressFrustration / 100f);
					if (Time.unscaledTime - _empressLastPlayerDamageAt < num)
					{
						_empressCurrentTactic = "Assessing the damage";
						_empressNextSabotageAt = Time.unscaledTime + Random.Range(4.8f, 9.8f) * Mathf.Lerp(1.12f, 0.42f, _empressFrustration / 100f);
						return;
					}
				}
				EmpressAISabotagePlan empressAISabotagePlan = EmpressCreateSabotagePlan(player);
				if (empressAISabotagePlan == null)
				{
					_empressCurrentTactic = "Holding for a cleaner angle";
					_empressNextSabotageAt = Time.unscaledTime + Random.Range(8.6f, 17.4f) * Mathf.Lerp(1.16f, (_empressFrustration >= 94f) ? 0.22f : 0.8f, _empressFrustration / 100f);
					return;
				}
				_empressPendingSabotage = empressAISabotagePlan;
				_empressCurrentTactic = empressAISabotagePlan.Tactic;
				EmpressAIOverlay.Instance?.EmpressPushMessage(empressAISabotagePlan.PreviewText, new Color(1f, 0.78f, 0.86f, 1f), urgent: true, 5.2f);
				EmpressAIPlugin.EmpressDebug("sabotage armed in " + sceneLabel + " tactic " + empressAISabotagePlan.Tactic);
			}
		}

		private EmpressAISabotagePlan? EmpressCreateSabotagePlan(PlayerAvatar player)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_095c: Unknown result type (might be due to invalid IL or missing references)
			//IL_096e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acc: Unknown result type (might be due to invalid IL or missing references)
			_empressSabotageOptions.Clear();
			bool flag = EmpressAIAccess.RunIsShop();
			EmpressRefreshSceneScan(flag);
			PhysGrabObject val = EmpressGetHeldObject();
			List<PhysGrabObject> list = EmpressCollectThrowables(((Component)player).transform.position, 18f, 8, cartOnly: false, val);
			List<PhysGrabObject> list2 = EmpressCollectImpactObjects(((Component)player).transform.position, 21f, 5, val);
			List<PhysGrabObject> list3 = EmpressCollectValuableTargets(((Component)player).transform.position, 17f, 5, val);
			List<PhysGrabObject> list4 = EmpressCollectThrowables(((Component)player).transform.position, 20f, 4, cartOnly: true, null);
			List<ItemAttributes> list5 = (List<ItemAttributes>)(flag ? ((IList)EmpressCollectShopItems(player, 5)) : ((IList)new List<ItemAttributes>(0)));
			float maxDistance = ((_empressFrustration >= 92f) ? 34f : ((_empressPlayerProfile == EmpressAIPlayerProfile.Camper) ? 28f : 20f));
			int maxCount = ((_empressFrustration >= 92f) ? 14 : ((_empressPlayerProfile == EmpressAIPlayerProfile.Camper) ? 10 : 6));
			List<Rigidbody> list6 = EmpressCollectFurnitureBodies(player, maxDistance, maxCount);
			List<Rigidbody> list7 = EmpressCollectOverheadBodies(player, (_empressFrustration >= 82f) ? 9f : 6f, (_empressUnderCoverScore >= 20f) ? 5 : 3);
			List<Enemy> list8 = EmpressCollectEnemyThreats(player, (_empressFrustration >= 88f) ? 80f : 38f, (_empressFrustration >= 88f) ? 8 : 5);
			float num = ((list8.Count > 0) ? Vector3.Distance(((Component)player).transform.position, ((Component)list8[0]).transform.position) : 999f);
			float num2 = EmpressGetBoardPressure(val, list.Count, list2.Count, list4.Count, list3.Count, list5.Count, list6.Count + list7.Count, list8.Count, num, flag);
			bool flag2 = (Object)(object)val != (Object)null || list.Count > 0 || list2.Count > 0 || list4.Count > 0 || list3.Count > 0 || list5.Count > 0 || list6.Count > 0 || list7.Count > 0 || list8.Count > 0;
			if ((Object)(object)val != (Object)null)
			{
				string text = EmpressDescribeObject(((Component)val).gameObject);
				EmpressAddOption(EmpressAISabotageKind.HeldObjectBackfire, 4.4f + _empressFrustration * 0.024f + num2 * 0.35f, "You kept " + text + " too close to your chest. I noticed.", "Held object backlash", contextual: true, val);
				if (_empressFrustration >= 46f)
				{
					EmpressAddOption(EmpressAISabotageKind.ReturnToSender, 4.9f + _empressFrustration * 0.024f + num2 * 0.38f, "You are holding my ammunition for me.", "Return to sender", contextual: true, val);
				}
				if (flag && _empressFrustration >= 34f)
				{
					EmpressAddOption(EmpressAISabotageKind.ShopGripTax, 5.1f + _empressFrustration * 0.026f + num2 * 0.38f, "Shop hands detected. I am charging a grip tax.", "Shop grip tax", contextual: true, val);
				}
				if (_empressFrustration >= 38f)
				{
					EmpressAddOption(EmpressAISabotageKind.MassAnchor, 4.1f + _empressFrustration * 0.02f + num2 * 0.3f, text + " is about to become a brick with opinions.", "Mass anchor", contextual: true, val);
				}
			}
			if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<ValuableObject>() != (Object)null)
			{
				EmpressAddOption(EmpressAISabotageKind.ValuablePunish, 5.2f + _empressFrustration * 0.026f + num2 * 0.42f, "That valuable is about to invoice you personally.", "Greed punishment", contextual: true, val);
				EmpressAddOption(EmpressAISabotageKind.FragilityCurse, 4.8f + _empressFrustration * 0.022f + num2 * 0.34f, "Careful. I made that valuable allergic to mistakes.", "Fragility curse", contextual: true, val);
				if (_empressFrustration >= 64f)
				{
					EmpressAddOption(EmpressAISabotageKind.GreedSpiral, 6f + _empressFrustration * 0.028f + num2 * 0.38f, "I can smell the greed on that route. Keep holding it.", "Greed spiral", contextual: true, val);
				}
			}
			for (int i = 0; i < list.Count; i++)
			{
				PhysGrabObject val2 = list[i];
				float num3 = Vector3.Distance(((Component)player).transform.position, ((Component)val2).transform.position);
				float num4 = EmpressGetAngleBias(player, ((Component)val2).transform.position);
				float num5 = 1f - Mathf.Clamp01(Mathf.InverseLerp(1.2f, 12.5f, num3));
				EmpressAddOption(EmpressAISabotageKind.NearbyThrow, 2.8f + _empressFrustration * 0.016f + num4 * 1.2f + num5 * 0.85f, EmpressBuildThrowPreview(player, val2), (num4 >= 0.62f) ? "Side angle projectile" : "Room projectile", contextual: true, val2);
				if (_empressFrustration >= 26f && i < 5)
				{
					EmpressAddOption(EmpressAISabotageKind.ObjectFeint, 3.1f + _empressFrustration * 0.016f + num4 * 0.9f, "I am going to make you dodge the wrong thing.", "Object feint", contextual: true, val2);
				}
				if (_empressFrustration >= 32f && i < 5)
				{
					EmpressAddOption(EmpressAISabotageKind.FloorSweep, 3.4f + _empressFrustration * 0.017f + num5 * 0.9f, EmpressDescribeObject(((Component)val2).gameObject) + " is taking the low road.", "Floor sweep", contextual: true, val2);
				}
				if (_empressFrustration >= 36f && i < 5)
				{
					EmpressAddOption(EmpressAISabotageKind.BarricadeRoute, 3.7f + _empressFrustration * 0.018f + num4 * 0.6f, "I am not hitting you. I am removing the route.", "Route barricade", contextual: true, val2);
				}
				if (_empressFrustration >= 44f && i < 4)
				{
					EmpressAddOption(EmpressAISabotageKind.DoorTax, 4f + _empressFrustration * 0.019f + num2 * 0.18f, "The way forward has a fee now.", "Door tax", contextual: true, val2);
				}
				if (_empressFrustration >= 46f && i < 4)
				{
					EmpressAddOption(EmpressAISabotageKind.BackstepPunish, 4.1f + _empressFrustration * 0.019f + num4 * 0.75f, "That backup plan has a collision box now.", "Backstep punish", contextual: true, val2);
				}
				if (_empressFrustration >= 48f && i < 4)
				{
					EmpressAddOption(EmpressAISabotageKind.CornerClamp, 4.3f + _empressFrustration * 0.019f + num5 * 0.7f, "I am clamping the corner before you reach it.", "Corner clamp", contextual: true, val2);
				}
				if (_empressFrustration >= 52f && i < 4)
				{
					EmpressAddOption(EmpressAISabotageKind.ObjectOrbit, 4.5f + _empressFrustration * 0.02f + num5 * 0.5f, "I am putting " + EmpressDescribeObject(((Component)val2).gameObject) + " into your orbit.", "Object orbit", contextual: true, val2);
				}
				if (_empressFrustration >= 56f && i < 4)
				{
					EmpressAddOption(EmpressAISabotageKind.CeilingDrop, 4.8f + _empressFrustration * 0.02f + num2 * 0.18f, "Look up later. Not now.", "Ceiling drop", contextual: true, val2);
				}
				if ((Object)(object)EmpressAIAccess.PhysGrabberInstance != (Object)null && _empressFrustration >= 42f && i < 3)
				{
					EmpressAddOption(EmpressAISabotageKind.ForcedCatch, 3.5f + _empressFrustration * 0.018f + num5 * 0.75f, "If you insist on being close, you can hold this for me.", "Forced catch", contextual: true, val2);
				}
				if ((Object)(object)EmpressAIAccess.PhysGrabberInstance != (Object)null && _empressFrustration >= 58f && i < 2)
				{
					EmpressAddOption(EmpressAISabotageKind.BlindCatch, 4.4f + _empressFrustration * 0.02f + num4, EmpressBuildBlindCatchPreview(val2), "Blind catch", contextual: true, val2);
				}
				if (_empressFrustration >= 54f && i < 3)
				{
					EmpressAddOption(EmpressAISabotageKind.SilentDrag, 4f + _empressFrustration * 0.018f + num5 * 0.7f, "I am going to slow your feet before " + EmpressDescribeObject(((Component)val2).gameObject) + " arrives.", "Silent drag", contextual: true, val2);
				}
				if (_empressFrustration >= 58f && i < 3)
				{
					EmpressAddOption(EmpressAISabotageKind.SlowField, 4.2f + _empressFrustration * 0.018f + num2 * 0.2f, "I am making the room sticky for one bad second.", "Slow