using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using REPOLib.Objects.Sdk; using UnityEngine; using UnityEngine.AI; using UnityEngine.Animations; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Playables; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("Jester")] [assembly: AssemblyTitle("Jester")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 Empress.REPO.Jester { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Empress.REPO.Jester", "Empress REPO Jester", "1.0.0")] public sealed class EmpressRepoJesterPlugin : BaseUnityPlugin { private const string JesterBundleFileName = "empressjester"; private const string JesterBundlePrefabName = "Box Jester"; private static readonly FieldInfo EnemySetupField = AccessTools.Field(typeof(EnemyContent), "_setup"); private static readonly FieldInfo SpawnObjectsField = AccessTools.Field(typeof(EnemyContent), "_spawnObjects"); internal const string PluginGuid = "Empress.REPO.Jester"; internal const string PluginName = "Empress REPO Jester"; internal const string PluginVersion = "1.0.0"; internal const string TemplatePrefabName = "EmpressJesterPrefab"; private static Harmony? _harmony; private static bool _registered; private static MethodInfo? _spawnManagerRefreshMethod; private static AssetBundle? _jesterBundle; private static GameObject? _jesterVisualPrefab; private static readonly Dictionary JesterAnimationClips = new Dictionary(StringComparer.Ordinal); internal static ManualLogSource Log { get; private set; } = null; internal static string PluginDirectory { get; private set; } = string.Empty; private void Awake() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin location: " + ((BaseUnityPlugin)this).Info.Location)); PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty; ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); if (_harmony == null) { _harmony = new Harmony("Empress.REPO.Jester"); } PatchTemplateGuards(_harmony); ((MonoBehaviour)this).StartCoroutine(EmpressRepoJesterAudioBank.LoadAudioAsync(((BaseUnityPlugin)this).Logger)); RegisterEnemy(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Empress REPO Jester v1.0.0"); } internal static void RefreshSpawnManagerEnemyNames() { Type type = AccessTools.TypeByName("SpawnManager.Managers.EnemyManager"); if (!(type == null)) { if ((object)_spawnManagerRefreshMethod == null) { _spawnManagerRefreshMethod = AccessTools.Method(type, "RefreshAllEnemyNames", (Type[])null, (Type[])null); } _spawnManagerRefreshMethod?.Invoke(null, null); } } internal static void ConfigureRuntimeInstance(EnemyParent enemyParent, Enemy enemy, EnemyStateSpawn stateSpawn, EnemyStateStunned stateStunned, PhotonView rootPhotonView, PhotonView enemyPhotonView, Transform centerTransform) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) Transform centerTransform2; Transform headTransform; Transform lidTransform; Transform leftArmTransform; Transform rightArmTransform; Transform windKeyTransform; Transform springTransform; Animator visualAnimator; Transform jesterMeshTransform; EmpressRepoJesterAuthoring authoring; Transform visualRoot = BuildJesterVisualRig(enemy, out centerTransform2, out headTransform, out lidTransform, out leftArmTransform, out rightArmTransform, out windKeyTransform, out springTransform, out visualAnimator, out jesterMeshTransform, out authoring); enemy.Type = (EnemyType)3; enemy.CenterTransform = centerTransform2; enemy.KillLookAtTransform = headTransform; enemy.CustomValuableSpawnTransform = centerTransform2; enemy.CurrentState = (EnemyState)1; AudioSource musicSource = CreateAudioSource(((Component)enemy).gameObject, "JesterMusic", 1f, 8f, 0.8f); AudioSource sfxSource = CreateAudioSource(((Component)enemy).gameObject, "JesterSfx", 1f, 10f, 1f); AudioSource voiceSource = CreateAudioSource(((Component)enemy).gameObject, "JesterVoice", 1f, 12f, 0.9f); EmpressRepoJesterController empressRepoJesterController = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); empressRepoJesterController.TemplateBehaviourTypeName = string.Empty; empressRepoJesterController.VisualRoot = visualRoot; empressRepoJesterController.CenterTransform = centerTransform2; empressRepoJesterController.HeadTransform = headTransform; empressRepoJesterController.LidTransform = lidTransform; empressRepoJesterController.LeftArmTransform = leftArmTransform; empressRepoJesterController.RightArmTransform = rightArmTransform; empressRepoJesterController.WindKeyTransform = windKeyTransform; empressRepoJesterController.SpringTransform = springTransform; empressRepoJesterController.VisualAnimator = visualAnimator; empressRepoJesterController.JesterMeshTransform = jesterMeshTransform; empressRepoJesterController.DoorPushProbeTransform = (((Object)(object)authoring != (Object)null) ? authoring.DoorPushProbe : null); empressRepoJesterController.DoorPushRadius = (((Object)(object)authoring != (Object)null) ? authoring.ResolveDoorPushRadius() : 0.55f); empressRepoJesterController.DoorPushForce = (((Object)(object)authoring != (Object)null) ? authoring.DoorPushForce : 2.8f); empressRepoJesterController.DoorPushTorque = (((Object)(object)authoring != (Object)null) ? authoring.DoorPushTorque : 1.1f); empressRepoJesterController.MusicSource = musicSource; empressRepoJesterController.SfxSource = sfxSource; empressRepoJesterController.VoiceSource = voiceSource; empressRepoJesterController.WindupClip = EmpressRepoJesterAudioBank.WindupClip; empressRepoJesterController.PopClip = EmpressRepoJesterAudio.BuildPopClip(); empressRepoJesterController.ScreamClip = EmpressRepoJesterAudio.BuildScreamClip(); empressRepoJesterController.KillClip = EmpressRepoJesterAudio.BuildKillClip(); empressRepoJesterController.StompClips = EmpressRepoJesterAudioBank.GetStompClips(); empressRepoJesterController.InitializeRuntime(); RepoEnemyAccess.SetEnemyParentEnemy(enemyParent, enemy); RepoEnemyAccess.SetEnemyParent(enemy, enemyParent); RepoEnemyAccess.SetPhotonView(enemy, enemyPhotonView); RepoEnemyAccess.SetStateSpawn(enemy, stateSpawn); RepoEnemyAccess.SetHasStateSpawn(enemy, value: true); RepoEnemyAccess.SetStateStunned(enemy, stateStunned); RepoEnemyAccess.SetHasStateStunned(enemy, value: true); RepoEnemyAccess.SetTargetPlayerViewId(enemy, -1); RepoEnemyAccess.SetVisionMask(enemy, LayerMask.op_Implicit(LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "HideTriggers" }))); RepoEnemyAccess.SetStateSpawnEnemy(stateSpawn, enemy); RepoEnemyAccess.SetStateStunnedEnemy(stateStunned, enemy); rootPhotonView.ObservedComponents = new List { (Component)(object)enemyParent }; enemyPhotonView.ObservedComponents = new List { (Component)(object)enemy }; } private void RegisterEnemy() { if (!_registered) { GameObject item = JesterTemplateBootstrap.CreateTemplate(((BaseUnityPlugin)this).Logger); RarityPreset val = ScriptableObject.CreateInstance(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Rarity - Jester"; val.chance = 60f; EnemySetup val2 = ScriptableObject.CreateInstance(); ((Object)val2).hideFlags = (HideFlags)61; ((Object)val2).name = "Enemy - Jester"; val2.spawnObjects = new List(); val2.levelsCompletedCondition = false; val2.levelsCompletedMin = 0; val2.levelsCompletedMax = 10; val2.rarityPreset = val; val2.runsPlayed = 0; EnemyContent val3 = ScriptableObject.CreateInstance(); ((Object)val3).hideFlags = (HideFlags)61; ((Object)val3).name = "EnemyContentEmpressJester"; EnemySetupField.SetValue(val3, val2); SpawnObjectsField.SetValue(val3, new List { item }); Enemies.RegisterEnemy(val3); _registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered the Jester enemy with REPOLib."); } } private static void PatchTemplateGuards(Harmony harmony) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyParent), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyParentAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyParent), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyParentUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(Enemy), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(Enemy), "Start", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyStart", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(Enemy), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyNavMeshAgent), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyNavMeshAgentAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyNavMeshAgent), "OnEnable", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyNavMeshAgentOnEnable", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyNavMeshAgent), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyNavMeshAgentUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyStateSpawn), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyStateSpawnUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyStateStunned), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoJesterPlugin), "SkipTemplateEnemyStateStunnedUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool SkipTemplateEnemyParentAwake(EnemyParent __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyParentUpdate(EnemyParent __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyAwake(Enemy __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyStart(Enemy __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyUpdate(Enemy __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyNavMeshAgentAwake(EnemyNavMeshAgent __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyNavMeshAgentOnEnable(EnemyNavMeshAgent __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyNavMeshAgentUpdate(EnemyNavMeshAgent __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyStateSpawnUpdate(EnemyStateSpawn __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyStateStunnedUpdate(EnemyStateStunned __instance) { return !JesterTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static Transform BuildJesterVisualRig(Enemy enemy, out Transform centerTransform, out Transform headTransform, out Transform lidTransform, out Transform leftArmTransform, out Transform rightArmTransform, out Transform windKeyTransform, out Transform springTransform, out Animator? visualAnimator, out Transform? jesterMeshTransform, out EmpressRepoJesterAuthoring? authoring) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_028b: 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_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0638: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06ea: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_072c: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_07af: Unknown result type (might be due to invalid IL or missing references) //IL_07d8: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_0816: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0852: Unknown result type (might be due to invalid IL or missing references) //IL_0870: Unknown result type (might be due to invalid IL or missing references) //IL_0899: Unknown result type (might be due to invalid IL or missing references) //IL_08ad: Unknown result type (might be due to invalid IL or missing references) //IL_08c1: Unknown result type (might be due to invalid IL or missing references) //IL_08d7: Unknown result type (might be due to invalid IL or missing references) //IL_08ff: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_0930: Unknown result type (might be due to invalid IL or missing references) //IL_0956: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)enemy).transform; if (TryBuildBundleVisualRig(transform, out Transform visualRoot, out centerTransform, out headTransform, out lidTransform, out leftArmTransform, out rightArmTransform, out windKeyTransform, out springTransform, out visualAnimator, out jesterMeshTransform, out authoring)) { return visualRoot; } visualAnimator = null; jesterMeshTransform = null; authoring = null; Transform transform2 = new GameObject("JesterVisualRoot").transform; transform2.SetParent(transform, false); transform2.localPosition = new Vector3(0f, 0.1f, 0f); transform2.localRotation = Quaternion.identity; Material seedMaterial = FindSeedMaterial(((Component)enemy).gameObject); Material material = CreateTintedMaterial(seedMaterial, new Color(0.72f, 0.12f, 0.14f)); Material material2 = CreateTintedMaterial(seedMaterial, new Color(0.16f, 0.32f, 0.74f)); Material material3 = CreateTintedMaterial(seedMaterial, new Color(0.93f, 0.87f, 0.71f)); Material material4 = CreateTintedMaterial(seedMaterial, new Color(0.08f, 0.08f, 0.1f)); Material material5 = CreateTintedMaterial(seedMaterial, new Color(0.82f, 0.68f, 0.18f)); Material material6 = CreateTintedMaterial(seedMaterial, new Color(0.68f, 0.72f, 0.78f)); Transform transform3 = new GameObject("JesterBox").transform; transform3.SetParent(transform2, false); transform3.localPosition = Vector3.zero; CreatePiece("BodyBase", (PrimitiveType)3, transform3, new Vector3(0f, 0.45f, 0f), new Vector3(0.95f, 0.9f, 0.95f), material); CreatePiece("BodyStripeFront", (PrimitiveType)3, transform3, new Vector3(0f, 0.45f, 0.475f), new Vector3(0.78f, 0.6f, 0.04f), material3); CreatePiece("BodyStripeSideL", (PrimitiveType)3, transform3, new Vector3(-0.475f, 0.45f, 0f), new Vector3(0.04f, 0.58f, 0.72f), material2); CreatePiece("BodyStripeSideR", (PrimitiveType)3, transform3, new Vector3(0.475f, 0.45f, 0f), new Vector3(0.04f, 0.58f, 0.72f), material2); CreatePiece("TrimTop", (PrimitiveType)3, transform3, new Vector3(0f, 0.93f, 0f), new Vector3(1.02f, 0.06f, 1.02f), material5); CreatePiece("TrimBottom", (PrimitiveType)3, transform3, new Vector3(0f, 0.02f, 0f), new Vector3(1.02f, 0.06f, 1.02f), material5); lidTransform = new GameObject("LidPivot").transform; lidTransform.SetParent(transform3, false); lidTransform.localPosition = new Vector3(0f, 0.9f, -0.38f); CreatePiece("Lid", (PrimitiveType)3, lidTransform, new Vector3(0f, 0f, 0.38f), new Vector3(1f, 0.08f, 0.88f), material2); CreatePiece("LidTrim", (PrimitiveType)3, lidTransform, new Vector3(0f, 0.01f, 0.38f), new Vector3(1.04f, 0.02f, 0.92f), material5); windKeyTransform = new GameObject("WindKey").transform; windKeyTransform.SetParent(transform3, false); windKeyTransform.localPosition = new Vector3(0.62f, 0.56f, -0.02f); CreatePiece("KeyStem", (PrimitiveType)2, windKeyTransform, Vector3.zero, new Vector3(0.08f, 0.16f, 0.08f), material6, (Vector3?)new Vector3(90f, 0f, 0f)); CreatePiece("KeyWingTop", (PrimitiveType)3, windKeyTransform, new Vector3(0.16f, 0f, 0f), new Vector3(0.22f, 0.04f, 0.1f), material6); CreatePiece("KeyWingBottom", (PrimitiveType)3, windKeyTransform, new Vector3(-0.16f, 0f, 0f), new Vector3(0.22f, 0.04f, 0.1f), material6); springTransform = new GameObject("Spring").transform; springTransform.SetParent(transform2, false); springTransform.localPosition = new Vector3(0f, 0.94f, 0f); for (int i = 0; i < 6; i++) { float num = (float)i / 5f; CreatePiece($"SpringRing{i}", (PrimitiveType)2, springTransform, new Vector3(0f, 0.12f + num * 0.38f, 0f), new Vector3(0.23f, 0.015f, 0.23f), material6, (Vector3?)new Vector3(90f, 0f, 0f)); } Transform transform4 = new GameObject("HeadRoot").transform; transform4.SetParent(transform2, false); transform4.localPosition = new Vector3(0f, 1.2f, 0f); headTransform = new GameObject("Head").transform; headTransform.SetParent(transform4, false); headTransform.localPosition = new Vector3(0f, 0.42f, 0f); CreatePiece("HeadBall", (PrimitiveType)0, headTransform, Vector3.zero, new Vector3(0.5f, 0.56f, 0.5f), material3); CreatePiece("HatBrim", (PrimitiveType)2, headTransform, new Vector3(0f, 0.32f, 0f), new Vector3(0.3f, 0.02f, 0.3f), material4); CreatePiece("HatTop", (PrimitiveType)2, headTransform, new Vector3(0f, 0.48f, 0f), new Vector3(0.18f, 0.18f, 0.18f), material4); CreatePiece("EyeLeft", (PrimitiveType)0, headTransform, new Vector3(-0.1f, 0.03f, 0.21f), new Vector3(0.08f, 0.08f, 0.08f), material4); CreatePiece("EyeRight", (PrimitiveType)0, headTransform, new Vector3(0.1f, 0.03f, 0.21f), new Vector3(0.08f, 0.08f, 0.08f), material4); CreatePiece("Nose", (PrimitiveType)0, headTransform, new Vector3(0f, -0.03f, 0.25f), new Vector3(0.11f, 0.11f, 0.11f), material); CreatePiece("Jaw", (PrimitiveType)3, headTransform, new Vector3(0f, -0.16f, 0.08f), new Vector3(0.22f, 0.08f, 0.2f), material3, (Vector3?)new Vector3(12f, 0f, 0f)); leftArmTransform = new GameObject("LeftArm").transform; leftArmTransform.SetParent(transform4, false); leftArmTransform.localPosition = new Vector3(-0.34f, 0.16f, 0.02f); CreatePiece("LeftArmUpper", (PrimitiveType)2, leftArmTransform, Vector3.zero, new Vector3(0.06f, 0.22f, 0.06f), material2, (Vector3?)new Vector3(0f, 0f, 90f)); CreatePiece("LeftHand", (PrimitiveType)0, leftArmTransform, new Vector3(-0.24f, 0f, 0f), new Vector3(0.08f, 0.08f, 0.08f), material5); rightArmTransform = new GameObject("RightArm").transform; rightArmTransform.SetParent(transform4, false); rightArmTransform.localPosition = new Vector3(0.34f, 0.16f, 0.02f); CreatePiece("RightArmUpper", (PrimitiveType)2, rightArmTransform, Vector3.zero, new Vector3(0.06f, 0.22f, 0.06f), material2, (Vector3?)new Vector3(0f, 0f, 90f)); CreatePiece("RightHand", (PrimitiveType)0, rightArmTransform, new Vector3(0.24f, 0f, 0f), new Vector3(0.08f, 0.08f, 0.08f), material5); centerTransform = new GameObject("JesterCenter").transform; centerTransform.SetParent(transform2, false); centerTransform.localPosition = new Vector3(0f, 0.92f, 0f); return transform2; } private static bool TryBuildBundleVisualRig(Transform attachRoot, out Transform visualRoot, out Transform centerTransform, out Transform headTransform, out Transform lidTransform, out Transform leftArmTransform, out Transform rightArmTransform, out Transform windKeyTransform, out Transform springTransform, out Animator? visualAnimator, out Transform? jesterMeshTransform, out EmpressRepoJesterAuthoring? authoring) { //IL_0061: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) visualRoot = null; centerTransform = null; headTransform = null; lidTransform = null; leftArmTransform = null; rightArmTransform = null; windKeyTransform = null; springTransform = null; visualAnimator = null; jesterMeshTransform = null; authoring = null; GameObject val = LoadJesterVisualPrefab(); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = Object.Instantiate(val, attachRoot, false); ((Object)val2).name = "JesterVisualRoot"; val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; SetVisualLayerRecursively(val2.transform, ResolveVisualLayer("Enemy")); Collider[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (Collider val3 in componentsInChildren) { val3.enabled = false; } visualRoot = val2.transform; visualAnimator = val2.GetComponentInChildren(true); jesterMeshTransform = FindNamedChildTransform(val2.transform, "JesterMesh"); authoring = val2.GetComponentInChildren(true); if ((Object)(object)authoring != (Object)null) { EmpressRepoJesterAuthoring empressRepoJesterAuthoring = authoring; if (empressRepoJesterAuthoring.DoorPushProbe == null) { empressRepoJesterAuthoring.DoorPushProbe = FindNamedChildTransform(val2.transform, "DoorPushProbe"); } if ((Object)(object)authoring.DoorPushProbe != (Object)null) { Log.LogInfo((object)$"[Jester] Using authored door push probe '{((Object)authoring.DoorPushProbe).name}' with radius {authoring.ResolveDoorPushRadius():0.##}."); } else { Log.LogWarning((object)"[Jester] EmpressRepoJesterAuthoring was found, but DoorPushProbe is not assigned."); } } Bounds? combinedRendererBounds = GetCombinedRendererBounds(val2); ? val4; Bounds value; if (!combinedRendererBounds.HasValue) { val4 = new Vector3(0f, 0.9f, 0f); } else { Transform obj = visualRoot; value = combinedRendererBounds.Value; val4 = obj.InverseTransformPoint(((Bounds)(ref value)).center); } Vector3 val5 = (Vector3)val4; float num; if (!combinedRendererBounds.HasValue) { num = 1.8f; } else { Transform obj2 = visualRoot; value = combinedRendererBounds.Value; float x = ((Bounds)(ref value)).center.x; value = combinedRendererBounds.Value; float y = ((Bounds)(ref value)).max.y; value = combinedRendererBounds.Value; num = obj2.InverseTransformPoint(new Vector3(x, y, ((Bounds)(ref value)).center.z)).y; } float num2 = num; centerTransform = new GameObject("JesterCenter").transform; centerTransform.SetParent(visualRoot, false); centerTransform.localPosition = val5; headTransform = new GameObject("JesterHead").transform; headTransform.SetParent(visualRoot, false); headTransform.localPosition = new Vector3(val5.x, Mathf.Max(val5.y + 0.35f, num2 - 0.15f), val5.z + 0.05f); lidTransform = new GameObject("JesterLidProxy").transform; lidTransform.SetParent(visualRoot, false); lidTransform.localPosition = new Vector3(val5.x, num2 - 0.1f, val5.z - 0.15f); leftArmTransform = new GameObject("JesterLeftArmProxy").transform; leftArmTransform.SetParent(visualRoot, false); leftArmTransform.localPosition = new Vector3(val5.x - 0.3f, val5.y + 0.1f, val5.z); rightArmTransform = new GameObject("JesterRightArmProxy").transform; rightArmTransform.SetParent(visualRoot, false); rightArmTransform.localPosition = new Vector3(val5.x + 0.3f, val5.y + 0.1f, val5.z); windKeyTransform = new GameObject("JesterWindKeyProxy").transform; windKeyTransform.SetParent(visualRoot, false); windKeyTransform.localPosition = new Vector3(val5.x + 0.45f, val5.y, val5.z); springTransform = new GameObject("JesterSpringProxy").transform; springTransform.SetParent(visualRoot, false); springTransform.localPosition = new Vector3(val5.x, val5.y + 0.2f, val5.z); if ((Object)(object)jesterMeshTransform == (Object)null) { Log.LogWarning((object)"[Jester] Could not find child transform 'JesterMesh' in the asset bundle prefab."); } Log.LogInfo((object)"Using asset bundle visual prefab for Jester."); return true; } private static Transform? FindNamedChildTransform(Transform root, string targetName) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (string.Equals(((Object)val).name, targetName, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static GameObject? LoadJesterVisualPrefab() { if ((Object)(object)_jesterVisualPrefab != (Object)null) { return _jesterVisualPrefab; } string text = ResolvePluginFile("empressjester"); if (string.IsNullOrEmpty(text) || !File.Exists(text)) { Log.LogWarning((object)("[Jester] Asset bundle 'empressjester' was not found under " + PluginDirectory)); return null; } if (_jesterBundle == null) { _jesterBundle = AssetBundle.LoadFromFile(text); } if ((Object)(object)_jesterBundle == (Object)null) { Log.LogWarning((object)("[Jester] Failed to load asset bundle: " + text)); return null; } _jesterVisualPrefab = _jesterBundle.LoadAsset("Box Jester"); if ((Object)(object)_jesterVisualPrefab == (Object)null) { Log.LogWarning((object)"[Jester] Could not find prefab 'Box Jester' in asset bundle."); } else { CacheJesterAnimationClips(_jesterBundle); } return _jesterVisualPrefab; } private static void CacheJesterAnimationClips(AssetBundle bundle) { if (JesterAnimationClips.Count > 0) { return; } AnimationClip[] array = bundle.LoadAllAssets(); foreach (AnimationClip val in array) { if ((Object)(object)val != (Object)null && !JesterAnimationClips.ContainsKey(((Object)val).name)) { JesterAnimationClips.Add(((Object)val).name, val); } } Log.LogInfo((object)$"[Jester] Cached {JesterAnimationClips.Count} animation clips from asset bundle."); } internal static string? ResolvePluginFile(string fileName) { string text = Path.Combine(PluginDirectory, fileName); if (File.Exists(text)) { return text; } try { string[] files = Directory.GetFiles(PluginDirectory, fileName, SearchOption.AllDirectories); foreach (string text2 in files) { if (File.Exists(text2)) { return text2; } } } catch (Exception ex) { Log.LogWarning((object)("[Jester] Failed while searching for '" + fileName + "' in plugin directory: " + ex.Message)); } return null; } internal static AnimationClip? GetJesterAnimationClip(string clipName) { LoadJesterVisualPrefab(); AnimationClip value; return JesterAnimationClips.TryGetValue(clipName, out value) ? value : null; } private static Bounds? GetCombinedRendererBounds(GameObject gameObject) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Bounds value = default(Bounds); Renderer[] componentsInChildren = gameObject.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!flag) { value = val.bounds; flag = true; } else { ((Bounds)(ref value)).Encapsulate(val.bounds); } } return flag ? new Bounds?(value) : null; } private static int ResolveVisualLayer(string layerName) { int num = LayerMask.NameToLayer(layerName); return (num >= 0) ? num : 0; } private static void SetVisualLayerRecursively(Transform root, int layer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ((Component)root).gameObject.layer = layer; foreach (Transform item in root) { Transform root2 = item; SetVisualLayerRecursively(root2, layer); } } private static Material FindSeedMaterial(GameObject prefab) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown Renderer[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val.sharedMaterial != (Object)null) { return val.sharedMaterial; } } GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3); try { Renderer component = val2.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMaterial != (Object)null) { return component.sharedMaterial; } } finally { Object.Destroy((Object)(object)val2); } string[] array = new string[4] { "Standard", "Universal Render Pipeline/Lit", "HDRP/Lit", "Sprites/Default" }; foreach (string text in array) { Shader val3 = Shader.Find(text); if ((Object)(object)val3 != (Object)null) { return new Material(val3); } } throw new InvalidOperationException("Could not resolve a fallback material for the Jester visuals."); } private static Material CreateTintedMaterial(Material seedMaterial, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(seedMaterial); if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", color * 0.08f); } return val; } private static Transform CreatePiece(string name, PrimitiveType primitiveType, Transform parent, Vector3 localPosition, Vector3 localScale, Material material, Vector3? localEulerAngles = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) GameObject val = GameObject.CreatePrimitive(primitiveType); ((Object)val).name = name; val.transform.SetParent(parent, false); val.transform.localPosition = localPosition; val.transform.localScale = localScale; val.transform.localRotation = Quaternion.Euler((Vector3)(((??)localEulerAngles) ?? Vector3.zero)); Collider[] components = val.GetComponents(); foreach (Collider val2 in components) { val2.enabled = false; } Renderer component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.sharedMaterial = material; } return val.transform; } private static AudioSource CreateAudioSource(GameObject owner, string name, float spatialBlend, float maxDistance, float volume) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(owner.transform, false); AudioSource val2 = val.AddComponent(); val2.playOnAwake = false; val2.loop = false; val2.spatialBlend = spatialBlend; val2.rolloffMode = (AudioRolloffMode)1; val2.minDistance = 1f; val2.maxDistance = maxDistance; val2.dopplerLevel = 0f; val2.volume = volume; return val2; } } [HarmonyPatch(typeof(EnemyDirector), "Start")] internal static class EmpressRepoJesterEnemyDirectorStartPatch { private static void Postfix() { EmpressRepoJesterPlugin.RefreshSpawnManagerEnemyNames(); } } internal static class RepoEnemyAccess { private static readonly FieldRef EnemyParentEnemyRef = AccessTools.FieldRefAccess("Enemy"); private static readonly FieldRef EnemyParentSetupDoneRef = AccessTools.FieldRefAccess("SetupDone"); private static readonly FieldRef EnemyEnemyParentRef = AccessTools.FieldRefAccess("EnemyParent"); private static readonly FieldRef EnemyHasAttackPhysObjectRef = AccessTools.FieldRefAccess("HasAttackPhysObject"); private static readonly FieldRef EnemyAttackPhysObjectRef = AccessTools.FieldRefAccess("AttackStuckPhysObject"); private static readonly FieldRef EnemyHasHealthRef = AccessTools.FieldRefAccess("HasHealth"); private static readonly FieldRef EnemyHealthRef = AccessTools.FieldRefAccess("Health"); private static readonly FieldRef EnemyHasNavMeshAgentRef = AccessTools.FieldRefAccess("HasNavMeshAgent"); private static readonly FieldRef EnemyNavMeshAgentRef = AccessTools.FieldRefAccess("NavMeshAgent"); private static readonly FieldRef EnemyHasStateSpawnRef = AccessTools.FieldRefAccess("HasStateSpawn"); private static readonly FieldRef EnemyHasStateInvestigateRef = AccessTools.FieldRefAccess("HasStateInvestigate"); private static readonly FieldRef EnemyStateInvestigateRef = AccessTools.FieldRefAccess("StateInvestigate"); private static readonly FieldRef EnemyHasStateChaseBeginRef = AccessTools.FieldRefAccess("HasStateChaseBegin"); private static readonly FieldRef EnemyStateChaseBeginRef = AccessTools.FieldRefAccess("StateChaseBegin"); private static readonly FieldRef EnemyHasStateChaseRef = AccessTools.FieldRefAccess("HasStateChase"); private static readonly FieldRef EnemyStateChaseRef = AccessTools.FieldRefAccess("StateChase"); private static readonly FieldRef EnemyHasStateLookUnderRef = AccessTools.FieldRefAccess("HasStateLookUnder"); private static readonly FieldRef EnemyStateLookUnderRef = AccessTools.FieldRefAccess("StateLookUnder"); private static readonly FieldRef EnemyHasStateStunnedRef = AccessTools.FieldRefAccess("HasStateStunned"); private static readonly FieldRef EnemyHasVisionRef = AccessTools.FieldRefAccess("HasVision"); private static readonly FieldRef EnemyVisionRef = AccessTools.FieldRefAccess("Vision"); private static readonly FieldRef EnemyHasRigidbodyRef = AccessTools.FieldRefAccess("HasRigidbody"); private static readonly FieldRef EnemyRigidbodyRef = AccessTools.FieldRefAccess("Rigidbody"); private static readonly FieldRef EnemyPhotonViewRef = AccessTools.FieldRefAccess("PhotonView"); private static readonly FieldRef EnemyStateSpawnRef = AccessTools.FieldRefAccess("StateSpawn"); private static readonly FieldRef EnemyStateStunnedRef = AccessTools.FieldRefAccess("StateStunned"); private static readonly FieldRef EnemyTargetPlayerViewIdRef = AccessTools.FieldRefAccess("TargetPlayerViewID"); private static readonly FieldRef EnemyVisionMaskRef = AccessTools.FieldRefAccess("VisionMask"); private static readonly FieldRef EnemyNavMeshAgentAgentRef = AccessTools.FieldRefAccess("Agent"); private static readonly FieldRef EnemyStateSpawnEnemyRef = AccessTools.FieldRefAccess("Enemy"); private static readonly FieldRef EnemyStateStunnedEnemyRef = AccessTools.FieldRefAccess("enemy"); private static readonly FieldRef PlayerAvatarDisabledRef = AccessTools.FieldRefAccess("isDisabled"); private static readonly FieldRef PlayerAvatarDeadSetRef = AccessTools.FieldRefAccess("deadSet"); internal static void SetSetupDone(EnemyParent enemyParent, bool value) { EnemyParentSetupDoneRef.Invoke(enemyParent) = value; } internal static void SetEnemyParentEnemy(EnemyParent enemyParent, Enemy enemy) { EnemyParentEnemyRef.Invoke(enemyParent) = enemy; } internal static void SetEnemyParent(Enemy enemy, EnemyParent enemyParent) { EnemyEnemyParentRef.Invoke(enemy) = enemyParent; } internal static void SetPhotonView(Enemy enemy, PhotonView photonView) { EnemyPhotonViewRef.Invoke(enemy) = photonView; } internal static void SetStateSpawn(Enemy enemy, EnemyStateSpawn stateSpawn) { EnemyStateSpawnRef.Invoke(enemy) = stateSpawn; } internal static void SetHasStateSpawn(Enemy enemy, bool value) { EnemyHasStateSpawnRef.Invoke(enemy) = value; } internal static void SetStateStunned(Enemy enemy, EnemyStateStunned stateStunned) { EnemyStateStunnedRef.Invoke(enemy) = stateStunned; } internal static void SetHasStateStunned(Enemy enemy, bool value) { EnemyHasStateStunnedRef.Invoke(enemy) = value; } internal static void SetVisionMask(Enemy enemy, LayerMask visionMask) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) EnemyVisionMaskRef.Invoke(enemy) = visionMask; } internal static void SetTargetPlayerViewId(Enemy enemy, int viewId) { EnemyTargetPlayerViewIdRef.Invoke(enemy) = viewId; } internal static void SetStateSpawnEnemy(EnemyStateSpawn stateSpawn, Enemy enemy) { EnemyStateSpawnEnemyRef.Invoke(stateSpawn) = enemy; } internal static void SetStateStunnedEnemy(EnemyStateStunned stateStunned, Enemy enemy) { EnemyStateStunnedEnemyRef.Invoke(stateStunned) = enemy; } internal static NavMeshAgent GetAgent(EnemyNavMeshAgent enemyNavMeshAgent) { return EnemyNavMeshAgentAgentRef.Invoke(enemyNavMeshAgent); } internal static EnemyParent? GetEnemyParent(Enemy enemy) { return EnemyEnemyParentRef.Invoke(enemy); } internal static bool GetHasVision(Enemy enemy) { return EnemyHasVisionRef.Invoke(enemy); } internal static EnemyVision? GetVision(Enemy enemy) { return EnemyVisionRef.Invoke(enemy); } internal static bool GetHasNavMeshAgent(Enemy enemy) { return EnemyHasNavMeshAgentRef.Invoke(enemy); } internal static EnemyNavMeshAgent? GetNavMeshAgent(Enemy enemy) { return EnemyNavMeshAgentRef.Invoke(enemy); } internal static bool GetHasRigidbody(Enemy enemy) { return EnemyHasRigidbodyRef.Invoke(enemy); } internal static EnemyRigidbody? GetRigidbody(Enemy enemy) { return EnemyRigidbodyRef.Invoke(enemy); } internal static bool GetHasHealth(Enemy enemy) { return EnemyHasHealthRef.Invoke(enemy); } internal static EnemyHealth? GetHealth(Enemy enemy) { return EnemyHealthRef.Invoke(enemy); } internal static bool GetHasStateInvestigate(Enemy enemy) { return EnemyHasStateInvestigateRef.Invoke(enemy); } internal static EnemyStateInvestigate? GetStateInvestigate(Enemy enemy) { return EnemyStateInvestigateRef.Invoke(enemy); } internal static bool GetHasStateChaseBegin(Enemy enemy) { return EnemyHasStateChaseBeginRef.Invoke(enemy); } internal static EnemyStateChaseBegin? GetStateChaseBegin(Enemy enemy) { return EnemyStateChaseBeginRef.Invoke(enemy); } internal static bool GetHasStateChase(Enemy enemy) { return EnemyHasStateChaseRef.Invoke(enemy); } internal static EnemyStateChase? GetStateChase(Enemy enemy) { return EnemyStateChaseRef.Invoke(enemy); } internal static bool GetHasStateLookUnder(Enemy enemy) { return EnemyHasStateLookUnderRef.Invoke(enemy); } internal static EnemyStateLookUnder? GetStateLookUnder(Enemy enemy) { return EnemyStateLookUnderRef.Invoke(enemy); } internal static bool GetHasAttackPhysObject(Enemy enemy) { return EnemyHasAttackPhysObjectRef.Invoke(enemy); } internal static EnemyAttackStuckPhysObject? GetAttackPhysObject(Enemy enemy) { return EnemyAttackPhysObjectRef.Invoke(enemy); } internal static bool IsDisabled(PlayerAvatar player) { return PlayerAvatarDisabledRef.Invoke(player); } internal static bool IsDeadSet(PlayerAvatar player) { return PlayerAvatarDeadSetRef.Invoke(player); } } [DefaultExecutionOrder(-100)] internal sealed class JesterTemplateBootstrap : MonoBehaviour { private const string EnableObjectName = "EnableObject"; private const string EnemyObjectName = "JesterEnemy"; private const string CenterObjectName = "Center"; private const string TemplateContainerName = "EmpressJesterTemplateContainer"; private static readonly HashSet TemplateInstanceIds = new HashSet(); private static GameObject? _templateContainer; private bool _runtimeBuilt; internal static GameObject CreateTemplate(ManualLogSource log) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) GameObject val = EnsureTemplateContainer(); GameObject val2 = new GameObject("EmpressJesterPrefab") { layer = ResolveLayer("Enemy") }; val2.transform.SetParent(val.transform, false); TemplateInstanceIds.Add(((Object)val2).GetInstanceID()); ((Object)val2).hideFlags = (HideFlags)61; val2.transform.position = new Vector3(0f, -5000f, 0f); BuildTemplateCore(val2.transform); log.LogInfo((object)"Created Jester template core."); return val2; } internal static bool IsTemplateInstance(GameObject gameObject) { Transform val = gameObject.transform; while ((Object)(object)val.parent != (Object)null) { val = val.parent; } return TemplateInstanceIds.Contains(((Object)((Component)val).gameObject).GetInstanceID()); } private static GameObject EnsureTemplateContainer() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if ((Object)(object)_templateContainer != (Object)null) { return _templateContainer; } _templateContainer = new GameObject("EmpressJesterTemplateContainer"); ((Object)_templateContainer).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)_templateContainer); _templateContainer.SetActive(false); return _templateContainer; } private void Start() { if (IsTemplateInstance(((Component)this).gameObject) || _runtimeBuilt) { return; } _runtimeBuilt = true; try { BuildRuntimeInstance(); } catch (Exception arg) { EmpressRepoJesterPlugin.Log.LogError((object)$"Failed to finish Jester spawn: {arg}"); } } private static void BuildTemplateCore(Transform root) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) int layer = ResolveLayer("Enemy"); ((Component)root).gameObject.layer = layer; TrySetTag(((Component)root).gameObject, "Enemy"); EnemyParent val = ((Component)root).gameObject.AddComponent(); PhotonView val2 = ((Component)root).gameObject.AddComponent(); val2.Synchronization = (ViewSynchronization)3; ((Behaviour)val2).enabled = false; ((Component)root).gameObject.AddComponent(); GameObject val3 = new GameObject("EnableObject"); val3.transform.SetParent(root, false); val3.layer = layer; TrySetTag(val3, "Enemy"); GameObject val4 = new GameObject("JesterEnemy"); val4.transform.SetParent(val3.transform, false); val4.transform.localPosition = Vector3.zero; val4.layer = layer; val4.SetActive(false); TrySetTag(val4, "Enemy"); GameObject val5 = new GameObject("Center"); val5.transform.SetParent(val4.transform, false); val5.transform.localPosition = new Vector3(0f, 1.1f, 0f); PhotonView val6 = val4.AddComponent(); val6.Synchronization = (ViewSynchronization)3; ((Behaviour)val6).enabled = false; CapsuleCollider val7 = val4.AddComponent(); val7.center = new Vector3(0f, 1.1f, 0f); val7.height = 2.4f; val7.radius = 0.48f; EnemyStateSpawn stateSpawn = val4.AddComponent(); EnemyStateStunned stateStunned = val4.AddComponent(); Enemy val8 = val4.AddComponent(); val.enemyName = "Jester"; val.difficulty = (Difficulty)2; val.actionMultiplier = 1.45f; val.overchargeMultiplier = 1.3f; val.EnableObject = val3; val.SpawnedTimeMin = 25f; val.SpawnedTimeMax = 40f; val.DespawnedTimeMin = 18f; val.DespawnedTimeMax = 32f; RepoEnemyAccess.SetSetupDone(val, value: false); RepoEnemyAccess.SetEnemyParentEnemy(val, val8); RepoEnemyAccess.SetEnemyParent(val8, val); RepoEnemyAccess.SetPhotonView(val8, val6); val8.CenterTransform = val5.transform; val8.KillLookAtTransform = val5.transform; val8.CustomValuableSpawnTransform = val5.transform; RepoEnemyAccess.SetStateSpawn(val8, stateSpawn); RepoEnemyAccess.SetHasStateSpawn(val8, value: true); RepoEnemyAccess.SetStateStunned(val8, stateStunned); RepoEnemyAccess.SetHasStateStunned(val8, value: true); RepoEnemyAccess.SetVisionMask(val8, LayerMask.op_Implicit(LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "HideTriggers" }))); val8.CurrentState = (EnemyState)1; RepoEnemyAccess.SetTargetPlayerViewId(val8, -1); RepoEnemyAccess.SetStateSpawnEnemy(stateSpawn, val8); RepoEnemyAccess.SetStateStunnedEnemy(stateStunned, val8); val4.SetActive(true); val2.ObservedComponents = new List { (Component)(object)val }; val6.ObservedComponents = new List { (Component)(object)val8 }; SetLayerRecursively(root, layer); TrySetTagRecursively(root, "Enemy"); } private void BuildRuntimeInstance() { if (!TryResolveCore(out EnemyParent enemyParent, out Enemy enemy, out EnemyStateSpawn stateSpawn, out EnemyStateStunned stateStunned, out PhotonView rootPhotonView, out PhotonView enemyPhotonView, out Transform centerTransform)) { throw new InvalidOperationException("Jester core components were not present on spawned clone."); } SetHideFlagsRecursively(((Component)this).transform, (HideFlags)0); ((Behaviour)rootPhotonView).enabled = true; ((Behaviour)enemyPhotonView).enabled = true; EnsureRuntimeNavMeshAgent(enemy); EmpressRepoJesterPlugin.ConfigureRuntimeInstance(enemyParent, enemy, stateSpawn, stateStunned, rootPhotonView, enemyPhotonView, centerTransform); } private bool TryResolveCore(out EnemyParent enemyParent, out Enemy enemy, out EnemyStateSpawn stateSpawn, out EnemyStateStunned stateStunned, out PhotonView rootPhotonView, out PhotonView enemyPhotonView, out Transform centerTransform) { enemyParent = ((Component)this).GetComponent(); rootPhotonView = ((Component)this).GetComponent(); enemy = ((Component)this).GetComponentInChildren(true); stateSpawn = ((Component)this).GetComponentInChildren(true); stateStunned = ((Component)this).GetComponentInChildren(true); PhotonView val = (((Object)(object)enemy != (Object)null) ? ((Component)enemy).GetComponent() : null); Transform val2 = (((Object)(object)enemy != (Object)null && (Object)(object)enemy.CenterTransform != (Object)null) ? enemy.CenterTransform : ((Component)this).transform.Find("EnableObject/JesterEnemy/Center")); enemyPhotonView = val; centerTransform = val2; return (Object)(object)enemyParent != (Object)null && (Object)(object)enemy != (Object)null && (Object)(object)stateSpawn != (Object)null && (Object)(object)stateStunned != (Object)null && (Object)(object)rootPhotonView != (Object)null && (Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null; } private static EnemyNavMeshAgent EnsureRuntimeNavMeshAgent(Enemy enemy) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (TryFindNearestNavMeshPoint(enemy, out var hit)) { ((Component)enemy).transform.position = ((NavMeshHit)(ref hit)).position; if ((Object)(object)((Component)enemy).transform.parent != (Object)null) { ((Component)enemy).transform.parent.position = ((NavMeshHit)(ref hit)).position; } } else { EmpressRepoJesterPlugin.Log.LogWarning((object)$"[Jester] Could not find nearby NavMesh for spawned Jester at {((Component)enemy).transform.position}."); } NavMeshAgent val = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); ConfigureNavMeshAgent(val); EnemyNavMeshAgent val2 = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); val2.Agent = val; val2.updateRotation = false; val2.DefaultSpeed = val.speed; val2.DefaultAcceleration = val.acceleration; ((Behaviour)val2).enabled = false; if (!((Behaviour)val).enabled && TryFindNearestNavMeshPoint(enemy, out var hit2)) { ((Behaviour)val).enabled = true; val.Warp(((NavMeshHit)(ref hit2)).position); } return val2; } private static bool TryFindNearestNavMeshPoint(Enemy enemy, out NavMeshHit hit) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0075: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) EnemyParent enemyParent = RepoEnemyAccess.GetEnemyParent(enemy); Vector3[] array = (Vector3[])(object)new Vector3[3] { ((Component)enemy).transform.position, ((Object)(object)((Component)enemy).transform.parent != (Object)null) ? ((Component)enemy).transform.parent.position : ((Component)enemy).transform.position, ((Object)(object)enemyParent != (Object)null) ? ((Component)enemyParent).transform.position : ((Component)enemy).transform.position }; float[] array2 = new float[5] { 6f, 12f, 24f, 48f, 96f }; Vector3[] array3 = array; foreach (Vector3 val in array3) { float[] array4 = array2; foreach (float num in array4) { if (NavMesh.SamplePosition(val, ref hit, num, -1)) { return true; } } } hit = default(NavMeshHit); return false; } private static void ConfigureNavMeshAgent(NavMeshAgent navMeshAgent) { navMeshAgent.speed = 6f; navMeshAgent.acceleration = 48f; navMeshAgent.angularSpeed = 220f; navMeshAgent.stoppingDistance = 1.15f; navMeshAgent.radius = 0.42f; navMeshAgent.height = 2.55f; navMeshAgent.autoTraverseOffMeshLink = true; navMeshAgent.obstacleAvoidanceType = (ObstacleAvoidanceType)4; } private static int ResolveLayer(string layerName) { int num = LayerMask.NameToLayer(layerName); return (num >= 0) ? num : 0; } private static void SetHideFlagsRecursively(Transform root, HideFlags hideFlags) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) ((Object)((Component)root).gameObject).hideFlags = hideFlags; foreach (Transform item in root) { Transform root2 = item; SetHideFlagsRecursively(root2, hideFlags); } } private static void SetLayerRecursively(Transform root, int layer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ((Component)root).gameObject.layer = layer; foreach (Transform item in root) { Transform root2 = item; SetLayerRecursively(root2, layer); } } private static void TrySetTagRecursively(Transform root, string tag) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown TrySetTag(((Component)root).gameObject, tag); foreach (Transform item in root) { Transform root2 = item; TrySetTagRecursively(root2, tag); } } private static void TrySetTag(GameObject gameObject, string tag) { try { gameObject.tag = tag; } catch (UnityException) { } } } [DisallowMultipleComponent] public sealed class EmpressRepoJesterAuthoring : MonoBehaviour { internal const float DefaultDoorPushRadius = 0.55f; internal const float DefaultDoorPushForce = 2.8f; internal const float DefaultDoorPushTorque = 1.1f; public Transform? DoorPushProbe; public bool UseProbeScaleAsRadius = true; public float DoorPushRadius = 0.55f; public float DoorPushForce = 2.8f; public float DoorPushTorque = 1.1f; public float ResolveDoorPushRadius() { //IL_0039: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) float result = Mathf.Max(0.05f, DoorPushRadius); if (!UseProbeScaleAsRadius || (Object)(object)DoorPushProbe == (Object)null) { return result; } Vector3 lossyScale = DoorPushProbe.lossyScale; float num = Mathf.Max(new float[3] { Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z) }) * 0.5f; return Mathf.Max(0.05f, num); } } public sealed class EmpressRepoJesterController : MonoBehaviour { private enum JesterPhase { Boxed, Cranking, Popping, Chasing } private const string IdleAnimationState = "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_idl"; private const string WalkAnimationState = "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_wal"; private const string WindAnimationState = "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_win"; private const string PopAnimationState = "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_pop"; private const string RunAnimationState = "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_run"; private const float WindupPopCueTime = 40f; private const float JesterMeshClosedY = -0.348f; private const float JesterMeshOpenY = -0.156f; private const float DoorPushCooldownTime = 0.12f; private static readonly int DoorPushMask = LayerMask.GetMask(new string[1] { "PhysGrabObjectHinge" }); private static readonly Collider[] DoorPushHits = (Collider[])(object)new Collider[8]; public string TemplateBehaviourTypeName = string.Empty; public Transform VisualRoot = null; public Transform CenterTransform = null; public Transform HeadTransform = null; public Transform LidTransform = null; public Transform LeftArmTransform = null; public Transform RightArmTransform = null; public Transform WindKeyTransform = null; public Transform SpringTransform = null; public Animator? VisualAnimator; public Transform? JesterMeshTransform; public Transform? DoorPushProbeTransform; public float DoorPushRadius = 0.55f; public float DoorPushForce = 2.8f; public float DoorPushTorque = 1.1f; public AudioSource MusicSource = null; public AudioSource SfxSource = null; public AudioSource VoiceSource = null; public AudioClip WindupClip = null; public AudioClip PopClip = null; public AudioClip ScreamClip = null; public AudioClip KillClip = null; public AudioClip[] StompClips = Array.Empty(); private Enemy _enemy = null; private EnemyParent _enemyParent = null; private EnemyVision? _vision; private EnemyNavMeshAgent? _navAgent; private EnemyRigidbody? _enemyBody; private EnemyHealth? _health; private PhotonView _photonView = null; private PlayerAvatar? _targetPlayer; private int _targetViewId = -1; private JesterPhase _phase; private float _phaseTimer; private float _beginCrankingTimer; private float _popTimer; private float _noTargetTimer; private float _speed; private float _roamRetargetTimer; private float _windKeySpin; private float _bodyBobTime; private Vector3 _roamDestination; private bool _spawnedPrevious; private bool _listenersHooked; private float _killCooldown; private bool _audioPausedForStun; private bool _initialized; private bool _windupStarted; private float _windupClipLength; private int _stompIndex; private float _stompTimer; private Vector3 _lastPosition; private float _movementSpeed; private bool _hasLastPosition; private float _doorPushCooldown; private string _currentAnimationState = string.Empty; private float _popAnimationDuration = 0.8f; private Vector3 _jesterMeshClosedLocalPosition; private Vector3 _jesterMeshOpenLocalPosition; private bool _hasJesterMeshPose; private PlayableGraph _animationGraph; private bool _animationGraphCreated; private void Awake() { _enemy = ((Component)this).GetComponent(); _enemyParent = ((Component)this).GetComponentInParent() ?? ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(true); _photonView = ((Component)this).GetComponent(); _vision = (RepoEnemyAccess.GetHasVision(_enemy) ? RepoEnemyAccess.GetVision(_enemy) : null); _navAgent = (RepoEnemyAccess.GetHasNavMeshAgent(_enemy) ? RepoEnemyAccess.GetNavMeshAgent(_enemy) : FindNearbyComponent((Component)(object)_enemy)); _enemyBody = (RepoEnemyAccess.GetHasRigidbody(_enemy) ? RepoEnemyAccess.GetRigidbody(_enemy) : FindNearbyComponent((Component)(object)_enemy)); _health = (RepoEnemyAccess.GetHasHealth(_enemy) ? RepoEnemyAccess.GetHealth(_enemy) : null); } public void InitializeRuntime() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (!_initialized) { if ((Object)(object)VisualAnimator != (Object)null) { ((Behaviour)VisualAnimator).enabled = true; VisualAnimator.applyRootMotion = false; VisualAnimator.runtimeAnimatorController = null; VisualAnimator.Rebind(); VisualAnimator.Update(0f); _popAnimationDuration = GetAnimationDuration("jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_pop", 0.8f); } if ((Object)(object)JesterMeshTransform != (Object)null) { _jesterMeshClosedLocalPosition = JesterMeshTransform.localPosition; _jesterMeshClosedLocalPosition.y = -0.348f; _jesterMeshOpenLocalPosition = _jesterMeshClosedLocalPosition; _jesterMeshOpenLocalPosition.y = -0.156f; JesterMeshTransform.localPosition = _jesterMeshClosedLocalPosition; _hasJesterMeshPose = true; } DisableLegacyBehaviour(); DisableGenericAiModules(); ResetBoxCycle(); ApplyVisualPose(forceClosed: true); _initialized = true; } } private void OnDestroy() { DestroyAnimationGraph(); } private static T? FindNearbyComponent(Component component) where T : Component { return component.GetComponent() ?? component.GetComponentInChildren(true) ?? component.GetComponentInParent(true); } private void OnEnable() { if (_initialized) { HookListeners(); } } private void OnDisable() { UnhookListeners(); } private void Update() { //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_0037: 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) if (!_initialized) { return; } if (_hasLastPosition && Time.deltaTime > 0f) { _movementSpeed = Vector3.Distance(((Component)this).transform.position, _lastPosition) / Time.deltaTime; } _lastPosition = ((Component)this).transform.position; _hasLastPosition = true; _bodyBobTime += Time.deltaTime; _phaseTimer += Time.deltaTime; bool flag = (Object)(object)_enemyParent != (Object)null && _enemyParent.Spawned && ((Object)(object)_enemyParent.EnableObject == (Object)null || _enemyParent.EnableObject.activeSelf); if (flag != _spawnedPrevious) { _spawnedPrevious = flag; if (flag) { ResetBoxCycle(); } else { StopAllAudio(); } } if (!flag) { ApplyVisualPose(forceClosed: true); return; } if (HasAuthority()) { RunAuthorityLogic(); } else { UpdateRemoteAudioState(); } AnimateVisuals(); } private void UpdateRemoteAudioState() { switch (_phase) { case JesterPhase.Boxed: StopAllAudio(); break; case JesterPhase.Cranking: if (!_windupStarted && (Object)(object)MusicSource != (Object)null && (Object)(object)WindupClip != (Object)null) { MusicSource.clip = WindupClip; MusicSource.loop = false; MusicSource.time = 0f; MusicSource.Play(); _windupClipLength = (((Object)(object)MusicSource.clip != (Object)null) ? MusicSource.clip.length : 0f); _windupStarted = true; } break; case JesterPhase.Popping: break; case JesterPhase.Chasing: UpdateStompAudio(); break; } } private void HookListeners() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown if (!_listenersHooked) { if ((Object)(object)_vision != (Object)null) { _vision.onVisionTriggered.AddListener(new UnityAction(OnVisionTriggered)); } if ((Object)(object)_health != (Object)null) { _health.onDeath.AddListener(new UnityAction(OnDeath)); } _listenersHooked = true; } } private void UnhookListeners() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown if (_listenersHooked) { if ((Object)(object)_vision != (Object)null) { _vision.onVisionTriggered.RemoveListener(new UnityAction(OnVisionTriggered)); } if ((Object)(object)_health != (Object)null) { _health.onDeath.RemoveListener(new UnityAction(OnDeath)); } _listenersHooked = false; } } private void DisableLegacyBehaviour() { MonoBehaviour[] components = ((Component)this).GetComponents(); foreach (MonoBehaviour val in components) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)this)) { string name = ((object)val).GetType().Name; if ((!string.IsNullOrEmpty(TemplateBehaviourTypeName) && name.StartsWith(TemplateBehaviourTypeName, StringComparison.Ordinal)) || name.EndsWith("Anim", StringComparison.Ordinal)) { ((Behaviour)val).enabled = false; } } } } private void DisableGenericAiModules() { EnemyStateInvestigate val = (RepoEnemyAccess.GetHasStateInvestigate(_enemy) ? RepoEnemyAccess.GetStateInvestigate(_enemy) : null); if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; } EnemyStateChaseBegin val2 = (RepoEnemyAccess.GetHasStateChaseBegin(_enemy) ? RepoEnemyAccess.GetStateChaseBegin(_enemy) : null); if ((Object)(object)val2 != (Object)null) { ((Behaviour)val2).enabled = false; } EnemyStateChase val3 = (RepoEnemyAccess.GetHasStateChase(_enemy) ? RepoEnemyAccess.GetStateChase(_enemy) : null); if ((Object)(object)val3 != (Object)null) { ((Behaviour)val3).enabled = false; } EnemyStateLookUnder val4 = (RepoEnemyAccess.GetHasStateLookUnder(_enemy) ? RepoEnemyAccess.GetStateLookUnder(_enemy) : null); if ((Object)(object)val4 != (Object)null) { ((Behaviour)val4).enabled = false; } EnemyAttackStuckPhysObject val5 = (RepoEnemyAccess.GetHasAttackPhysObject(_enemy) ? RepoEnemyAccess.GetAttackPhysObject(_enemy) : null); if ((Object)(object)val5 != (Object)null) { ((Behaviour)val5).enabled = false; } } private bool HasAuthority() { return !SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient; } private void RunAuthorityLogic() { if (_killCooldown > 0f) { _killCooldown -= Time.deltaTime; } if (_doorPushCooldown > 0f) { _doorPushCooldown -= Time.deltaTime; } if ((Object)(object)_targetPlayer != (Object)null && !IsTargetValid(_targetPlayer)) { _targetPlayer = null; _targetViewId = -1; } switch (_phase) { case JesterPhase.Boxed: RunBoxedLogic(); break; case JesterPhase.Cranking: RunCrankingLogic(); break; case JesterPhase.Popping: RunPoppingLogic(); break; case JesterPhase.Chasing: RunChasingLogic(); break; } UpdateDoorInteraction(); } private void RunBoxedLogic() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) StopVoiceLoop(); if ((Object)(object)MusicSource != (Object)null) { MusicSource.loop = false; } _speed = Mathf.MoveTowards(_speed, 0f, Time.deltaTime * 8f); AcquireNearestTarget(55f); if (_enemy.IsStunned()) { _beginCrankingTimer -= Time.deltaTime * 12f; } else if ((Object)(object)_targetPlayer != (Object)null) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position); if (num > 7f) { _beginCrankingTimer = 1.15f; MoveTowardsPosition(GetStandOffPosition(((Component)_targetPlayer).transform.position, 5.5f), 1.6f, 7f, 8f, 7f); } else { FaceTowards(((Component)_targetPlayer).transform.position, 8f); StopMoving(); _beginCrankingTimer -= Time.deltaTime; } } else { RoamStep(); _beginCrankingTimer = Mathf.Max(_beginCrankingTimer, 1.15f); } if (_beginCrankingTimer <= 0f) { SwitchPhase(JesterPhase.Cranking); } } private void RunCrankingLogic() { //IL_01b0: Unknown result type (might be due to invalid IL or missing references) _enemyParent.SpawnedTimerPause(0.5f); AcquireNearestTarget(60f); StopMoving(); if (_enemy.IsStunned()) { if (!_audioPausedForStun && (Object)(object)MusicSource != (Object)null && MusicSource.isPlaying) { MusicSource.Pause(); _audioPausedForStun = true; } return; } if (_audioPausedForStun) { AudioSource musicSource = MusicSource; if (musicSource != null) { musicSource.UnPause(); } _audioPausedForStun = false; } if (!_windupStarted && (Object)(object)MusicSource != (Object)null && (Object)(object)WindupClip != (Object)null) { MusicSource.clip = WindupClip; MusicSource.loop = false; MusicSource.pitch = 1f; MusicSource.time = 0f; MusicSource.Play(); _windupClipLength = (((Object)(object)MusicSource.clip != (Object)null) ? MusicSource.clip.length : 0f); _windupStarted = true; } else if (!_windupStarted && (Object)(object)WindupClip == (Object)null) { EmpressRepoJesterPlugin.Log.LogWarning((object)"[Jester] Windup clip was not loaded from the plugin folder."); _windupStarted = true; _windupClipLength = 0f; } if ((Object)(object)_targetPlayer != (Object)null) { FaceTowards(((Component)_targetPlayer).transform.position, 8f); } if (_windupStarted && ShouldBeginPop()) { SwitchPhase(JesterPhase.Popping); } } private void RunPoppingLogic() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) _enemyParent.SpawnedTimerPause(0.5f); StopMoving(); if ((Object)(object)_targetPlayer != (Object)null) { FaceTowards(((Component)_targetPlayer).transform.position, 10f); } if (_windupStarted && ShouldPopNow()) { SwitchPhase(JesterPhase.Chasing); } } private void RunChasingLogic() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) _enemyParent.SpawnedTimerPause(1f); if (_phaseTimer >= 10f) { ExpireChaseMode(); return; } AcquireNearestTarget(250f); if ((Object)(object)_targetPlayer == (Object)null) { _noTargetTimer -= Time.deltaTime; RoamStep(13.5f, 30f, fastRoam: true); UpdateStompAudio(); return; } _noTargetTimer = 5f; _speed = Mathf.MoveTowards(_speed, 17.5f, Time.deltaTime * 4.5f); Vector3 position = ((Component)_targetPlayer).transform.position; if (_enemy.IsStunned()) { StopMoving(); return; } UpdateStompAudio(); MoveTowardsPosition(position, _speed, 12f, Mathf.Max(20f, _speed * 4f), 18f); _enemy.CurrentState = (EnemyState)2; TryKillNearbyPlayer(); } private void RoamStep(float speedOverride = 2.8f, float accelerationOverride = 10f, bool fastRoam = false) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) _roamRetargetTimer -= Time.deltaTime; if (_roamRetargetTimer <= 0f || Vector3.Distance(((Component)this).transform.position, _roamDestination) <= (fastRoam ? 2.2f : 1.2f)) { LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, fastRoam ? 10f : 4f, fastRoam ? 48f : 16f); if ((Object)(object)val == (Object)null) { val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, fastRoam ? 90f : 40f); } if ((Object)(object)val != (Object)null) { _roamDestination = ((Component)val).transform.position; } else { _roamDestination = ((Component)this).transform.position + ((Component)this).transform.forward * (fastRoam ? 8f : 2f); } _roamRetargetTimer = (fastRoam ? Random.Range(0.75f, 1.5f) : Random.Range(2.5f, 5f)); } MoveTowardsPosition(_roamDestination, speedOverride, fastRoam ? 14f : 8f, accelerationOverride, fastRoam ? 18f : 12f); _enemy.CurrentState = (EnemyState)2; } private void MoveTowardsPosition(Vector3 targetPosition, float speed, float turnSpeed, float acceleration, float bodyFollowSpeed) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) bool flag = false; if ((Object)(object)_navAgent != (Object)null && (Object)(object)_navAgent.Agent != (Object)null) { try { _navAgent.Enable(); if (((Behaviour)_navAgent.Agent).enabled && _navAgent.Agent.isOnNavMesh) { _navAgent.UpdateAgent(speed, acceleration); _navAgent.SetDestination(targetPosition); Vector3 desiredVelocity = _navAgent.Agent.desiredVelocity; if (((Vector3)(ref desiredVelocity)).sqrMagnitude > 0.01f) { FaceAlongDirection(desiredVelocity, turnSpeed); } else { FaceTowards(targetPosition, turnSpeed); } flag = true; } } catch { flag = false; } } if (!flag) { FaceTowards(targetPosition, turnSpeed); StopMoving(); } else if ((Object)(object)_enemyBody != (Object)null) { _enemyBody.OverrideFollowPosition(0.15f, bodyFollowSpeed, 18f); _enemyBody.OverrideFollowRotation(0.15f, turnSpeed + 4f); _enemyBody.IdleSet(0f); } } private Vector3 GetStandOffPosition(Vector3 playerPosition, float desiredDistance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position - playerPosition; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 0.001f) { val = -((Component)this).transform.forward; } return playerPosition + ((Vector3)(ref val)).normalized * desiredDistance; } private void StopMoving() { if ((Object)(object)_navAgent != (Object)null) { _navAgent.Stop(0.1f); _navAgent.ResetPath(); } if ((Object)(object)_enemyBody != (Object)null) { _enemyBody.IdleSet(0.25f); } } private void FaceAlongDirection(Vector3 worldDirection, float turnSpeed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0095: Unknown result type (might be due to invalid IL or missing references) Vector3 val = worldDirection; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude <= 0.001f)) { Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, turnSpeed * Time.deltaTime); if ((Object)(object)_enemyBody != (Object)null && (Object)(object)_enemyBody.followTarget != (Object)null) { _enemyBody.followTarget.rotation = ((Component)this).transform.rotation; } } } private void FaceTowards(Vector3 worldPosition, float turnSpeed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_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) //IL_0048: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Vector3 val = worldPosition - ((Component)this).transform.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude <= 0.001f)) { Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, turnSpeed * Time.deltaTime); if ((Object)(object)_enemyBody != (Object)null && (Object)(object)_enemyBody.followTarget != (Object)null) { _enemyBody.followTarget.rotation = ((Component)this).transform.rotation; } } } private void OnVisionTriggered() { if (!((Object)(object)_vision?.onVisionTriggeredPlayer == (Object)null)) { _targetPlayer = _vision.onVisionTriggeredPlayer; _targetViewId = _targetPlayer.photonView.ViewID; if (_phase == JesterPhase.Boxed) { _beginCrankingTimer = Mathf.Min(_beginCrankingTimer, Random.Range(2.5f, 5f)); } } } private void ResetBoxCycle() { _targetPlayer = null; _targetViewId = -1; _beginCrankingTimer = Random.Range(13f, 21f); if ((Object)(object)GameDirector.instance != (Object)null && GameDirector.instance.PlayerList.Count <= 1) { _beginCrankingTimer = Random.Range(18f, 28f); } _popTimer = Random.Range(10.5f, 13.5f); _noTargetTimer = 5f; _roamRetargetTimer = 0f; _speed = 0f; _windupStarted = false; _windupClipLength = 0f; _stompIndex = 0; _stompTimer = 0f; SwitchPhase(JesterPhase.Boxed, broadcast: false); StopAllAudio(); if ((Object)(object)_vision != (Object)null) { _vision.DisableVision(0.4f); } } private void ExpireChaseMode() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) StopAllAudio(); StopMoving(); if ((Object)(object)_health != (Object)null && !_health.dead && !_health.deadImpulse) { _health.Death(Vector3.zero); } else { _enemyParent.Despawn(); } } private bool ShouldPopNow() { if (!_windupStarted) { return false; } if ((Object)(object)MusicSource == (Object)null) { return true; } if ((Object)(object)MusicSource.clip == (Object)null) { return !MusicSource.isPlaying; } float num = ((_windupClipLength > 0f) ? _windupClipLength : MusicSource.clip.length); if (num > 0f && MusicSource.time >= num - 0.03f) { return true; } return !MusicSource.isPlaying && MusicSource.time > 0f; } private bool ShouldBeginPop() { if (!_windupStarted) { return false; } if ((Object)(object)MusicSource == (Object)null || (Object)(object)MusicSource.clip == (Object)null) { return ShouldPopNow(); } float num = Mathf.Min(40f, Mathf.Max(0.05f, MusicSource.clip.length - 0.05f)); return MusicSource.time >= num; } private void UpdateStompAudio() { if ((Object)(object)SfxSource == (Object)null || StompClips == null || StompClips.Length == 0) { return; } if (_movementSpeed < 1.25f || _phase != JesterPhase.Chasing) { if (SfxSource.isPlaying) { SfxSource.Stop(); } _stompTimer = 0f; return; } _stompTimer -= Time.deltaTime; float num = Mathf.InverseLerp(7f, 18f, Mathf.Max(_speed, _movementSpeed)); float stompTimer = Mathf.Lerp(0.52f, 0.18f, num); SfxSource.pitch = Mathf.Lerp(0.95f, 1.18f, num); if (!(_stompTimer > 0f)) { AudioClip val = StompClips[_stompIndex % StompClips.Length]; if ((Object)(object)val != (Object)null) { SfxSource.PlayOneShot(val); } _stompIndex++; _stompTimer = stompTimer; } } private void UpdateDoorInteraction() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) bool flag = _doorPushCooldown > 0f; bool flag2 = flag; if (!flag2) { JesterPhase phase = _phase; bool flag3 = (uint)(phase - 1) <= 1u; flag2 = flag3; } if (flag2) { return; } Vector3 doorPushDirection = GetDoorPushDirection(); if (((Vector3)(ref doorPushDirection)).sqrMagnitude <= 0.04f) { return; } Vector3 val = (((Object)(object)DoorPushProbeTransform != (Object)null) ? DoorPushProbeTransform.position : (CenterTransform.position + doorPushDirection * 0.72f)); float num = Mathf.Max(0.05f, DoorPushRadius); int num2 = Physics.OverlapSphereNonAlloc(val, num, DoorPushHits, DoorPushMask, (QueryTriggerInteraction)1); if (num2 <= 0) { return; } for (int i = 0; i < num2; i++) { Collider val2 = DoorPushHits[i]; DoorPushHits[i] = null; if ((Object)(object)val2 == (Object)null || ((Component)val2).transform.IsChildOf(((Component)this).transform)) { continue; } PhysGrabHinge componentInParent = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { continue; } PhysGrabObject component = ((Component)componentInParent).GetComponent(); Rigidbody component2 = ((Component)componentInParent).GetComponent(); HingeJoint component3 = ((Component)componentInParent).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null) && !((Object)(object)component3 == (Object)null) && !component2.isKinematic) { Vector3 val3 = val2.ClosestPoint(val); Vector3 val4 = doorPushDirection * DoorPushForce; val4.y = Mathf.Max(val4.y, 0.08f); Vector3 val5 = ((Component)componentInParent).transform.position - ((Component)this).transform.position; val5.y = 0f; float num3 = Mathf.Sign(Vector3.Dot(Vector3.Cross(val5, doorPushDirection), Vector3.up)); if (Mathf.Abs(num3) < 0.01f) { num3 = 1f; } component.EnemyInteractTimeSet(); component2.AddForceAtPosition(val4, val3, (ForceMode)1); component2.AddTorque(Vector3.up * (DoorPushTorque * num3), (ForceMode)1); _doorPushCooldown = 0.12f; break; } } } private Vector3 GetDoorPushDirection() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; if ((Object)(object)_navAgent != (Object)null && (Object)(object)_navAgent.Agent != (Object)null && ((Behaviour)_navAgent.Agent).enabled && _navAgent.Agent.isOnNavMesh) { val = _navAgent.Agent.desiredVelocity; } val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.04f) { return ((Vector3)(ref val)).normalized; } Vector3 forward = ((Component)this).transform.forward; forward.y = 0f; return (((Vector3)(ref forward)).sqrMagnitude > 0.001f) ? ((Vector3)(ref forward)).normalized : Vector3.zero; } private void SwitchPhase(JesterPhase phase, bool broadcast = true) { _phase = phase; _phaseTimer = 0f; _audioPausedForStun = false; switch (phase) { case JesterPhase.Boxed: StopAllAudio(); break; case JesterPhase.Cranking: StopVoiceLoop(); _windupStarted = false; _windupClipLength = 0f; if ((Object)(object)MusicSource != (Object)null) { MusicSource.clip = WindupClip; MusicSource.loop = false; MusicSource.time = 0f; } break; case JesterPhase.Chasing: StopAllAudio(); _stompTimer = 0f; _stompIndex = 0; _speed = 0f; break; } if (broadcast && SemiFunc.IsMultiplayer() && PhotonNetwork.IsMasterClient) { _photonView.RPC("SyncPhaseRpc", (RpcTarget)1, new object[1] { (int)phase }); } } [PunRPC] private void SyncPhaseRpc(int phase, PhotonMessageInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.MasterOnlyRPC(info)) { return; } _phase = (JesterPhase)phase; _phaseTimer = 0f; _audioPausedForStun = false; switch (_phase) { case JesterPhase.Boxed: StopAllAudio(); break; case JesterPhase.Cranking: StopVoiceLoop(); _windupStarted = false; _windupClipLength = 0f; if ((Object)(object)MusicSource != (Object)null) { MusicSource.clip = WindupClip; MusicSource.loop = false; MusicSource.time = 0f; } break; case JesterPhase.Popping: break; case JesterPhase.Chasing: StopAllAudio(); _stompTimer = 0f; _stompIndex = 0; break; } } [PunRPC] private void PlayKillCueRpc(PhotonMessageInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { SfxSource.PlayOneShot(KillClip); } } private void TryKillNearbyPlayer() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (_killCooldown > 0f || (Object)(object)GameDirector.instance == (Object)null) { return; } PlayerAvatar val = null; float num = 2.15f; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (IsTargetValid(player)) { float num2 = Vector3.Distance(CenterTransform.position, ((Component)player).transform.position); if (num2 <= num) { num = num2; val = player; } } } if (!((Object)(object)val == (Object)null)) { val.playerHealth.HurtOther(999, ((Component)val).transform.position, false, SemiFunc.EnemyGetIndex(_enemy), false); _killCooldown = 2.2f; SfxSource.PlayOneShot(KillClip); if (SemiFunc.IsMultiplayer()) { _photonView.RPC("PlayKillCueRpc", (RpcTarget)1, Array.Empty()); } } } private void AcquireNearestTarget(float maxDistance) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameDirector.instance == (Object)null) { _targetPlayer = null; _targetViewId = -1; return; } float num = maxDistance; PlayerAvatar val = null; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (IsTargetValid(player)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (num2 < num) { num = num2; val = player; } } } _targetPlayer = val; _targetViewId = (((Object)(object)val != (Object)null) ? val.photonView.ViewID : (-1)); } private bool IsTargetValid(PlayerAvatar? player) { return (Object)(object)player != (Object)null && !RepoEnemyAccess.IsDisabled(player) && !RepoEnemyAccess.IsDeadSet(player) && (Object)(object)player.playerHealth != (Object)null; } private void AnimateVisuals() { //IL_0162: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) UpdateAnimatorState(); UpdateJesterMeshPose(); if (!((Object)(object)VisualAnimator != (Object)null)) { float num = ((_phase == JesterPhase.Chasing) ? 1f : 0f); float num2 = ((_phase == JesterPhase.Cranking) ? 1f : 0f); float num3 = ((_phase == JesterPhase.Chasing) ? Mathf.Clamp01(_phaseTimer * 2.5f + num * 0.2f) : 0f); float num4 = ((_phase == JesterPhase.Chasing) ? Mathf.Lerp(0f, -100f, Mathf.Clamp01(num3)) : 0f); float num5 = ((num2 > 0f) ? (Mathf.Sin(_bodyBobTime * 10f) * 3.5f) : (Mathf.Sin(_bodyBobTime * 2.2f) * 0.5f)); float num6 = Mathf.Lerp(15f, 105f, num); float num7 = ((_phase == JesterPhase.Chasing) ? Mathf.Lerp(0.35f, 1f, num3) : 0.35f); float num8 = ((_phase == JesterPhase.Chasing) ? Mathf.Lerp(0f, 0.6f, num3) : 0f); VisualRoot.localPosition = new Vector3(0f, 0.1f + Mathf.Sin(_bodyBobTime * 2.1f) * 0.02f * num, 0f); LidTransform.localRotation = Quaternion.Euler(num4 + ((_phase == JesterPhase.Cranking) ? num5 : 0f), 0f, 0f); SpringTransform.localScale = new Vector3(1f, num7, 1f); HeadTransform.parent.localPosition = new Vector3(0f, 1.2f + num8, 0f); HeadTransform.localRotation = ResolveHeadRotation(); LeftArmTransform.localRotation = Quaternion.Euler(0f, 0f, num6); RightArmTransform.localRotation = Quaternion.Euler(0f, 0f, 0f - num6); _windKeySpin += Time.deltaTime * ((_phase == JesterPhase.Cranking) ? 720f : ((_phase == JesterPhase.Chasing) ? 220f : 80f)); WindKeyTransform.localRotation = Quaternion.Euler(0f, 0f, _windKeySpin); } } private void ApplyVisualPose(bool forceClosed) { //IL_004d: 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_0092: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (forceClosed) { ApplyJesterMeshPosition(0f); } if ((Object)(object)VisualAnimator != (Object)null) { if (forceClosed) { PlayAnimationState("jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_idl", forceRestart: true); } } else if (forceClosed) { LidTransform.localRotation = Quaternion.identity; SpringTransform.localScale = new Vector3(1f, 0.35f, 1f); HeadTransform.parent.localPosition = new Vector3(0f, 1.2f, 0f); HeadTransform.localRotation = Quaternion.identity; LeftArmTransform.localRotation = Quaternion.Euler(0f, 0f, 15f); RightArmTransform.localRotation = Quaternion.Euler(0f, 0f, -15f); } } private void UpdateJesterMeshPose() { if (_hasJesterMeshPose) { JesterPhase phase = _phase; if (1 == 0) { } float num = phase switch { JesterPhase.Popping => (_popAnimationDuration > 0.01f) ? Mathf.Clamp01(_phaseTimer / _popAnimationDuration) : 1f, JesterPhase.Chasing => 1f, _ => 0f, }; if (1 == 0) { } float openAlpha = num; ApplyJesterMeshPosition(openAlpha); } } private void ApplyJesterMeshPosition(float openAlpha) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (_hasJesterMeshPose && !((Object)(object)JesterMeshTransform == (Object)null)) { Vector3 localPosition = Vector3.Lerp(_jesterMeshClosedLocalPosition, _jesterMeshOpenLocalPosition, Mathf.Clamp01(openAlpha)); JesterMeshTransform.localPosition = localPosition; } } private Quaternion ResolveHeadRotation() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_targetPlayer == (Object)null || _phase != JesterPhase.Chasing) { return Quaternion.identity; } Vector3 val = ((Component)_targetPlayer).transform.position - HeadTransform.position; if (((Vector3)(ref val)).sqrMagnitude <= 0.001f) { return Quaternion.identity; } Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); Quaternion val3 = Quaternion.Inverse(HeadTransform.parent.rotation) * val2; Vector3 eulerAngles = ((Quaternion)(ref val3)).eulerAngles; float num = NormalizeAngle(eulerAngles.x); float num2 = NormalizeAngle(eulerAngles.y); return Quaternion.Euler(Mathf.Clamp(num, -25f, 35f), Mathf.Clamp(num2, -60f, 60f), 0f); } private void UpdateAnimatorState() { if (!((Object)(object)VisualAnimator == (Object)null)) { switch (_phase) { case JesterPhase.Boxed: { bool flag = _movementSpeed > 0.08f || ((Object)(object)_navAgent != (Object)null && (Object)(object)_navAgent.Agent != (Object)null && _navAgent.Agent.hasPath); PlayAnimationState(flag ? "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_wal" : "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_idl"); break; } case JesterPhase.Cranking: PlayAnimationState("jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_win"); break; case JesterPhase.Popping: PlayAnimationState("jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_pop"); break; case JesterPhase.Chasing: PlayAnimationState((_movementSpeed > 0.4f) ? "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_run" : "jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_jester_lc_jester.dmx_skeleton_idl"); break; } } } private void PlayAnimationState(string stateName, bool forceRestart = false) { if (!((Object)(object)VisualAnimator == (Object)null) && (forceRestart || !(_currentAnimationState == stateName))) { AnimationClip jesterAnimationClip = EmpressRepoJesterPlugin.GetJesterAnimationClip(stateName); if ((Object)(object)jesterAnimationClip == (Object)null) { EmpressRepoJesterPlugin.Log.LogWarning((object)("[Jester] Could not find animation clip '" + stateName + "' in the loaded asset bundle.")); return; } RebuildAnimationGraph(jesterAnimationClip); _currentAnimationState = stateName; } } private float GetAnimationDuration(string stateName, float fallback) { AnimationClip jesterAnimationClip = EmpressRepoJesterPlugin.GetJesterAnimationClip(stateName); return ((Object)(object)jesterAnimationClip != (Object)null) ? Mathf.Max(0.05f, jesterAnimationClip.length) : fallback; } private void RebuildAnimationGraph(AnimationClip clip) { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0076: Unknown result type (might be due to invalid IL or missing references) DestroyAnimationGraph(); if (!((Object)(object)VisualAnimator == (Object)null)) { _animationGraph = PlayableGraph.Create($"JesterAnim_{((Object)this).GetInstanceID()}"); ((PlayableGraph)(ref _animationGraph)).SetTimeUpdateMode((DirectorUpdateMode)1); AnimationPlayableOutput val = AnimationPlayableOutput.Create(_animationGraph, "JesterAnimOutput", VisualAnimator); AnimationClipPlayable val2 = AnimationClipPlayable.Create(_animationGraph, clip); ((AnimationClipPlayable)(ref val2)).SetApplyFootIK(false); PlayableOutputExtensions.SetSourcePlayable(val, val2); ((PlayableGraph)(ref _animationGraph)).Play(); _animationGraphCreated = true; } } private void DestroyAnimationGraph() { if (_animationGraphCreated) { ((PlayableGraph)(ref _animationGraph)).Destroy(); _animationGraphCreated = false; } } private static float NormalizeAngle(float angle) { while (angle > 180f) { angle -= 360f; } while (angle < -180f) { angle += 360f; } return angle; } private void StopAllAudio() { AudioSource musicSource = MusicSource; if (musicSource != null) { musicSource.Stop(); } AudioSource voiceSource = VoiceSource; if (voiceSource != null) { voiceSource.Stop(); } if ((Object)(object)SfxSource != (Object)null) { SfxSource.Stop(); SfxSource.loop = false; SfxSource.pitch = 1f; } } private void StopVoiceLoop() { AudioSource voiceSource = VoiceSource; if (voiceSource != null) { voiceSource.Stop(); } } private void OnDeath() { StopAllAudio(); } } internal static class EmpressRepoJesterAudioBank { private const string WindupFileName = "lethal-company-jester-wind-up.mp3"; private static readonly string[] StompFileNames = new string[3] { "0667. Jester Stomp1.mp3", "0668. Jester Stomp2.mp3", "0669. Jester Stomp3.mp3" }; private static bool _started; private static bool _loaded; private static readonly List LoadedStomps = new List(); internal static AudioClip? WindupClip { get; private set; } internal static bool Loaded => _loaded; internal static IEnumerator LoadAudioAsync(ManualLogSource log) { if (_started) { yield break; } _started = true; yield return LoadClipAsync("lethal-company-jester-wind-up.mp3", delegate(AudioClip clip) { WindupClip = clip; }, log); string[] stompFileNames = StompFileNames; foreach (string stompFileName in stompFileNames) { yield return LoadClipAsync(stompFileName, delegate(AudioClip clip) { LoadedStomps.Add(clip); }, log); } _loaded = true; log.LogInfo((object)$"Jester audio load complete. windup={(Object)(object)WindupClip != (Object)null}, stomps={LoadedStomps.Count}"); } internal static AudioClip[] GetStompClips() { return (AudioClip[])((LoadedStomps.Count > 0) ? ((Array)LoadedStomps.ToArray()) : ((Array)Array.Empty())); } private static IEnumerator LoadClipAsync(string fileName, Action assign, ManualLogSource log) { string assetStem = Path.GetFileNameWithoutExtension(fileName); string resolvedPath = EmpressRepoJesterPlugin.ResolvePluginFile(fileName); if (string.IsNullOrEmpty(resolvedPath)) { log.LogWarning((object)("Jester audio clip '" + fileName + "' was not found under " + EmpressRepoJesterPlugin.PluginDirectory)); yield break; } UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip("file:///" + resolvedPath.Replace("\\", "/"), GetAudioType(resolvedPath)); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { log.LogWarning((object)("Failed to load Jester audio clip from " + resolvedPath + ": " + request.error)); yield break; } AudioClip clip = DownloadHandlerAudioClip.GetContent(request); ((Object)clip).name = assetStem; ((Object)clip).hideFlags = (HideFlags)61; assign(clip); } finally { ((IDisposable)request)?.Dispose(); } } private static AudioType GetAudioType(string path) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) string text = Path.GetExtension(path).ToLowerInvariant(); if (1 == 0) { } AudioType result = ((text == ".wav") ? ((AudioType)20) : ((!(text == ".ogg")) ? ((AudioType)13) : ((AudioType)14))); if (1 == 0) { } return result; } } internal static class EmpressRepoJesterAudio { private static AudioClip? _windupClip; private static AudioClip? _popClip; private static AudioClip? _screamClip; private static AudioClip? _killClip; private static AudioClip? _chaseLoopClip; internal static AudioClip BuildWindupClip() { if ((Object)(object)_windupClip != (Object)null) { return _windupClip; } int num = Mathf.CeilToInt(141120f); float[] array = new float[num]; float[] array2 = new float[16] { 392f, 523.25f, 659.25f, 523.25f, 440f, 587.33f, 698.46f, 587.33f, 392f, 523.25f, 659.25f, 783.99f, 698.46f, 659.25f, 587.33f, 523.25f }; int num2 = num / array2.Length; for (int i = 0; i < num; i++) { int num3 = Mathf.Clamp(i / num2, 0, array2.Length - 1); float num4 = (float)(i % num2) / (float)num2; float num5 = Mathf.Clamp01(1f - num4 * 0.9f); float num6 = Mathf.Sin((float)i / 22050f * 6f) * 0.004f; float num7 = Mathf.Sin(MathF.PI * 2f * array2[num3] * (float)i / 22050f); num7 += Mathf.Sin(MathF.PI * 2f * array2[num3] * 2f * (float)i / 22050f) * 0.35f; array[i] = num7 * 0.18f * num5 + num6; } _windupClip = AudioClip.Create("EmpressJesterWindup", num, 1, 22050, false); _windupClip.SetData(array, 0); return _windupClip; } internal static AudioClip BuildPopClip() { if ((Object)(object)_popClip != (Object)null) { return _popClip; } int num = Mathf.CeilToInt(12127.5f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 22050f; float num3 = Mathf.Exp((0f - num2) * 11f); float num4 = Mathf.Sin(MathF.PI * 2f * (110f + num2 * 440f) * num2) * 0.5f; float num5 = (Mathf.PerlinNoise(num2 * 160f, 0f) * 2f - 1f) * 0.25f; array[i] = (num4 + num5) * num3; } _popClip = AudioClip.Create("EmpressJesterPop", num, 1, 22050, false); _popClip.SetData(array, 0); return _popClip; } internal static AudioClip BuildScreamClip() { if ((Object)(object)_screamClip != (Object)null) { return _screamClip; } int num = Mathf.CeilToInt(55125f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 22050f; float num3 = Mathf.Sin(MathF.PI * 2f * (220f + Mathf.Sin(num2 * 8f) * 55f) * num2); float num4 = Mathf.Sin(MathF.PI * 2f * (440f + Mathf.Sin(num2 * 6f) * 95f) * num2) * 0.45f; float num5 = (Mathf.PerlinNoise(num2 * 90f, 0.31f) * 2f - 1f) * 0.18f; float num6 = 0.45f + Mathf.Sin(num2 * MathF.PI / 2.5f) * 0.25f; array[i] = (num3 * 0.28f + num4 + num5) * num6; } _screamClip = AudioClip.Create("EmpressJesterScream", num, 1, 22050, false); _screamClip.SetData(array, 0); return _screamClip; } internal static AudioClip BuildKillClip() { if ((Object)(object)_killClip != (Object)null) { return _killClip; } int num = Mathf.CeilToInt(9261f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 22050f; float num3 = Mathf.Sin(MathF.PI * 2f * (180f + num2 * 600f) * num2) * 0.36f; float num4 = (Mathf.PerlinNoise(num2 * 220f, 0.77f) * 2f - 1f) * 0.25f; float num5 = Mathf.Exp((0f - num2) * 14f); array[i] = (num3 + num4) * num5; } _killClip = AudioClip.Create("EmpressJesterKill", num, 1, 22050, false); _killClip.SetData(array, 0); return _killClip; } internal static AudioClip BuildChaseLoopClip() { if ((Object)(object)_chaseLoopClip != (Object)null) { return _chaseLoopClip; } int num = Mathf.CeilToInt(29767.5f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 22050f; float num3 = Mathf.Sin(MathF.PI * 15f * num2); float num4 = Mathf.Sin(MathF.PI * 2f * (95f + Mathf.Sin(num2 * 18f) * 18f) * num2) * 0.22f; float num5 = Mathf.Sin(MathF.PI * 620f * num2) * Mathf.Clamp01(num3 * 0.5f + 0.5f) * 0.12f; float num6 = (Mathf.PerlinNoise(num2 * 38f, 0.19f) * 2f - 1f) * 0.08f; array[i] = num4 + num5 + num6; } _chaseLoopClip = AudioClip.Create("EmpressJesterChaseLoop", num, 1, 22050, false); _chaseLoopClip.SetData(array, 0); return _chaseLoopClip; } } }