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.Playables; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("Mita")] [assembly: AssemblyTitle("Mita")] [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.Mita { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Empress.REPO.Mita", "Empress REPO Mita", "1.0.0")] public sealed class EmpressRepoMitaPlugin : BaseUnityPlugin { private const string MitaBundleFileName = "empressmita"; private const string MitaAudioBundleFileName = "empressmitaaudio"; private const float MitaBundleVisualScale = 0.96f; private const string BodyAlbedoTextureFileName = "CreepyMitaBody.png"; private const string BodyNormalTextureFileName = ""; private const string ClothesAlbedoTextureFileName = "CreepyMitaClothes.png"; private const string ClothesNormalTextureFileName = ""; private const string FaceAlbedoTextureFileName = "Face_2.png"; private const string HairAlbedoTextureFileName = "TestHairsalpha2.png"; private const string HairNormalTextureFileName = "TestHairsN2.png"; private const string TeddyAlbedoTextureFileName = "TeddyBear.png"; private static readonly string[] MitaBundlePrefabCandidates = new string[4] { "MitaCreepy", "Mita", "MitaCreepyVisual", "CreepyMita" }; 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.Mita"; internal const string PluginName = "Empress REPO Mita"; internal const string PluginVersion = "1.0.0"; internal const string TemplatePrefabName = "EmpressMitaPrefab"; private static Harmony? _harmony; private static bool _registered; private static MethodInfo? _spawnManagerRefreshMethod; private static AssetBundle? _mitaBundle; private static AssetBundle? _mitaAudioBundle; private static GameObject? _mitaVisualPrefab; internal static AnimationClip[]? BundleAnimationClips; private static Material? _bodyMaterial; private static Material? _clothesMaterial; private static Material? _faceMaterial; private static Material? _hairMaterial; private static Material? _teddyMaterial; private static Texture2D? _bodyAlbedoTexture; private static Texture2D? _bodyNormalTexture; private static Texture2D? _clothesAlbedoTexture; private static Texture2D? _clothesNormalTexture; private static Texture2D? _faceAlbedoTexture; private static Texture2D? _hairAlbedoTexture; private static Texture2D? _hairNormalTexture; private static Texture2D? _teddyAlbedoTexture; private static PhysAttribute? _grabPhysAttribute; private static Durability? _grabDurability; internal static ManualLogSource Log { get; private set; } = null; internal static string PluginDirectory { get; private set; } = string.Empty; private void Awake() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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.Mita"); } PatchTemplateGuards(_harmony); RegisterEnemy(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Empress REPO Mita v1.0.0"); } private void RegisterEnemy() { if (!_registered) { GameObject item = MitaTemplateBootstrap.CreateTemplate(((BaseUnityPlugin)this).Logger); RarityPreset val = ScriptableObject.CreateInstance(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Rarity - Mita"; val.chance = 100f; EnemySetup val2 = ScriptableObject.CreateInstance(); ((Object)val2).hideFlags = (HideFlags)61; ((Object)val2).name = "Enemy - Mita"; 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 = "EnemyContentEmpressMita"; EnemySetupField.SetValue(val3, val2); SpawnObjectsField.SetValue(val3, new List { item }); Enemies.RegisterEnemy(val3); _registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered the Mita enemy with REPOLib."); } } internal static void ConfigureRuntimeInstance(EnemyParent enemyParent, Enemy enemy, EnemyStateSpawn stateSpawn, EnemyStateStunned stateStunned, PhotonView rootPhotonView, PhotonView enemyPhotonView, Transform centerTransform) { //IL_000f: 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_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_021d: 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_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Expected O, but got Unknown //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Expected O, but got Unknown //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Expected O, but got Unknown //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Expected O, but got Unknown //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Expected O, but got Unknown //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Expected O, but got Unknown //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Expected O, but got Unknown Transform centerTransform2; Transform headTransform; Animator visualAnimator; Transform val = BuildMitaVisualRig(enemy, out centerTransform2, out headTransform, out visualAnimator); enemy.Type = (EnemyType)3; enemy.CenterTransform = centerTransform2; enemy.KillLookAtTransform = headTransform; enemy.CustomValuableSpawnTransform = centerTransform2; enemy.CurrentState = (EnemyState)1; EmpressRepoMitaController empressRepoMitaController = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); empressRepoMitaController.VisualRoot = val; empressRepoMitaController.CenterTransform = centerTransform2; empressRepoMitaController.HeadTransform = headTransform; empressRepoMitaController.VisualAnimator = visualAnimator; PhotonTransformView val2 = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); PhysGrabObject val3 = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); PhysGrabObjectImpactDetector val4 = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); RoomVolumeCheck val5 = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); NotValuableObject val6 = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); ConfigureGrabbableBody(((Component)enemy).gameObject, val, val3); Rigidbody component = ((Component)enemy).GetComponent(); if ((Object)(object)component != (Object)null) { component.mass = 3f; component.interpolation = (RigidbodyInterpolation)1; component.collisionDetectionMode = (CollisionDetectionMode)2; } val3.overrideTagsAndLayers = false; val3.photonView = enemyPhotonView; val3.photonTransformView = val2; val3.rb = component; val3.roomVolumeCheck = val5; val3.impactDetector = val4; val3.massOriginal = 3f; val4.physGrabObject = val3; val4.photonView = enemyPhotonView; val4.rb = component; val4.playerHurtDisable = false; val4.slidingDisable = true; val4.destroyDisable = true; val4.canHurtLogic = true; val6.physAttributePreset = GetOrCreateGrabPhysAttribute(); val6.durabilityPreset = GetOrCreateGrabDurability(); val6.audioPreset = null; val6.audioPresetPitch = 1f; val6.hasHealth = false; val6.rb = component; val6.physGrabObject = val3; RoomVolumeCheck val7 = val5; if (val7.CurrentRooms == null) { val7.CurrentRooms = new List(); } val5.CheckPosition = new Vector3(0f, 1.2f, 0f); val5.currentSize = new Vector3(1.45f, 3.05f, 1.45f); EnemyHealth val8 = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); EnemyHealth val9 = val8; if (val9.onHurt == null) { val9.onHurt = new UnityEvent(); } val9 = val8; if (val9.onDeathStart == null) { val9.onDeathStart = new UnityEvent(); } val9 = val8; if (val9.onDeath == null) { val9.onDeath = new UnityEvent(); } val9 = val8; if (val9.onObjectHurt == null) { val9.onObjectHurt = new UnityEvent(); } val8.health = 130; val8.healthCurrent = val8.health; val8.meshParent = val; val8.spawnValuable = true; val8.spawnValuableMax = 1; val8.objectHurt = true; val8.objectHurtStun = true; val8.objectHurtStunTime = 1.15f; val8.impactHurt = true; val8.impactLightDamage = 5; val8.impactMediumDamage = 12; val8.impactHeavyDamage = 22; val8.onHurt.AddListener(new UnityAction(empressRepoMitaController.HandleHurt)); val8.onDeathStart.AddListener(new UnityAction(empressRepoMitaController.HandleDeathStart)); val8.onObjectHurt.AddListener(new UnityAction(empressRepoMitaController.HandleObjectHurt)); val8.onDeath.AddListener(new UnityAction(empressRepoMitaController.HandleDeath)); empressRepoMitaController.Health = val8; empressRepoMitaController.GrabObject = val3; RefreshHealthVisuals(val8, val); val8.OnSpawn(); if (stateSpawn.OnSpawn == null) { stateSpawn.OnSpawn = new UnityEvent(); } stateSpawn.OnSpawn.AddListener(new UnityAction(empressRepoMitaController.HandleSpawn)); EnemyStateStunned val10 = stateStunned; if (val10.onStunnedStart == null) { val10.onStunnedStart = new UnityEvent(); } val10 = stateStunned; if (val10.onStunnedEnd == null) { val10.onStunnedEnd = new UnityEvent(); } stateStunned.onStunnedStart.AddListener(new UnityAction(empressRepoMitaController.HandleStunnedStart)); stateStunned.onStunnedEnd.AddListener(new UnityAction(empressRepoMitaController.HandleStunnedEnd)); EnemyStateInvestigate val11 = ((Component)enemy).GetComponent() ?? ((Component)enemy).gameObject.AddComponent(); val11.Enemy = enemy; val11.PhotonView = enemyPhotonView; val11.OnlyEvent = true; val11.rangeMultiplier = 1.2f; EnemyStateInvestigate val12 = val11; if (val12.onInvestigateTriggered == null) { val12.onInvestigateTriggered = new UnityEvent(); } val11.onInvestigateTriggered.AddListener(new UnityAction(empressRepoMitaController.HandleInvestigate)); RepoEnemyAccess.SetEnemyParentEnemy(enemyParent, enemy); RepoEnemyAccess.SetEnemyParent(enemy, enemyParent); RepoEnemyAccess.SetPhotonView(enemy, enemyPhotonView); RepoEnemyAccess.SetHealth(enemy, val8); RepoEnemyAccess.SetHasHealth(enemy, value: true); RepoEnemyAccess.SetStateInvestigate(enemy, val11); RepoEnemyAccess.SetHasStateInvestigate(enemy, value: true); RepoEnemyAccess.SetStateSpawn(enemy, stateSpawn); RepoEnemyAccess.SetHasStateSpawn(enemy, value: true); RepoEnemyAccess.SetStateStunned(enemy, stateStunned); RepoEnemyAccess.SetHasStateStunned(enemy, value: true); RepoEnemyAccess.SetVisionMask(enemy, LayerMask.op_Implicit(LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "HideTriggers" }))); RepoEnemyAccess.SetTargetPlayerViewId(enemy, -1); RepoEnemyAccess.SetNavMeshAgent(enemy, empressRepoMitaController.NavAgent); RepoEnemyAccess.SetHasNavMeshAgent(enemy, (Object)(object)empressRepoMitaController.NavAgent != (Object)null); RepoEnemyAccess.SetStateSpawnEnemy(stateSpawn, enemy); RepoEnemyAccess.SetStateStunnedEnemy(stateStunned, enemy); rootPhotonView.ObservedComponents = new List { (Component)(object)enemyParent }; enemyPhotonView.ObservedComponents = new List { (Component)(object)enemy, (Component)(object)val2, (Component)(object)val3, (Component)(object)val4 }; empressRepoMitaController.InitializeRuntime(); RepoEnemyAccess.SetSetupDone(enemyParent, value: true); } 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); } } private static Transform BuildMitaVisualRig(Enemy enemy, out Transform centerTransform, out Transform headTransform, out Animator? visualAnimator) { if (TryBuildBundleVisualRig(((Component)enemy).transform, out Transform visualRoot, out centerTransform, out headTransform, out visualAnimator)) { return visualRoot; } visualAnimator = null; return BuildFallbackVisualRig(((Component)enemy).transform, out centerTransform, out headTransform); } private static bool TryBuildBundleVisualRig(Transform attachRoot, out Transform visualRoot, out Transform centerTransform, out Transform headTransform, out Animator? visualAnimator) { //IL_003d: 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_005e: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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) visualRoot = null; centerTransform = null; headTransform = null; visualAnimator = null; GameObject val = LoadMitaVisualPrefab(); if ((Object)(object)val == (Object)null) { return false; } RemoveExistingVisualRoots(attachRoot); GameObject val2 = Object.Instantiate(val, attachRoot); ((Object)val2).name = "MitaVisualRoot"; val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; Transform transform = val2.transform; transform.localScale *= 0.96f; SetVisualLayerRecursively(val2.transform, ResolveVisualLayer("Enemy")); SanitizeBundleInstance(val2.transform); ConvertBundleMaterials(val2); Collider[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (Collider val3 in componentsInChildren) { val3.enabled = false; } NavMeshAgent[] componentsInChildren2 = val2.GetComponentsInChildren(true); foreach (NavMeshAgent val4 in componentsInChildren2) { ((Behaviour)val4).enabled = false; Object.Destroy((Object)(object)val4); } visualRoot = val2.transform; visualAnimator = val2.GetComponentInChildren(true); if ((Object)(object)visualAnimator != (Object)null) { ((Behaviour)visualAnimator).enabled = true; visualAnimator.applyRootMotion = false; visualAnimator.cullingMode = (AnimatorCullingMode)0; visualAnimator.Rebind(); visualAnimator.Update(0f); } PruneExtraBundleActors(val2.transform, visualAnimator); Transform val5 = FindChildByName(val2.transform, "Head") ?? FindChildByName(val2.transform, "head") ?? FindChildByName(val2.transform, "ORG-head"); headTransform = val5 ?? val2.transform; Bounds? combinedRendererBounds = GetCombinedRendererBounds(val2); GameObject val6 = new GameObject("MitaCenter"); val6.transform.SetParent(attachRoot, false); Transform transform2 = val6.transform; Vector3 position; if (!combinedRendererBounds.HasValue) { position = attachRoot.position + Vector3.up * 1.5f; } else { Bounds valueOrDefault = combinedRendererBounds.GetValueOrDefault(); position = ((Bounds)(ref valueOrDefault)).center; } transform2.position = position; val6.transform.rotation = Quaternion.identity; centerTransform = val6.transform; Log.LogInfo((object)"Using asset bundle visual prefab for Mita."); return true; } private static void RemoveExistingVisualRoots(Transform attachRoot) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown List list = new List(); foreach (Transform item in attachRoot) { Transform val = item; if (string.Equals(((Object)val).name, "MitaVisualRoot", StringComparison.Ordinal) || string.Equals(((Object)val).name, "MitaVisualRoot(Clone)", StringComparison.Ordinal)) { list.Add(((Component)val).gameObject); } } foreach (GameObject item2 in list) { Object.Destroy((Object)(object)item2); } } private static void PruneExtraBundleActors(Transform root, Animator? primaryAnimator) { if ((Object)(object)primaryAnimator == (Object)null) { return; } Animator[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Animator val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)primaryAnimator)) { ((Behaviour)val).enabled = false; ((Component)val).gameObject.SetActive(false); Log.LogInfo((object)("Disabled extra Mita bundle actor '" + ((Object)val).name + "'.")); } } } private static void SanitizeBundleInstance(Transform root) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (ShouldHideBundleHelperObject(val)) { ((Component)val).gameObject.SetActive(false); } } } private static bool ShouldHideBundleHelperObject(Transform candidate) { string name = ((Object)candidate).name; if (name.IndexOf("MapDot", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("ScanNode", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("Debug", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("Point", StringComparison.OrdinalIgnoreCase) < 0) { return name.IndexOf("Trigger", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static void ConvertBundleMaterials(GameObject instance) { Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[Mita] Could not find Standard shader for material conversion."); return; } Material orCreateBodyMaterial = GetOrCreateBodyMaterial(val); Material orCreateClothesMaterial = GetOrCreateClothesMaterial(val); Material orCreateFaceMaterial = GetOrCreateFaceMaterial(val); Material orCreateHairMaterial = GetOrCreateHairMaterial(val); Material orCreateTeddyMaterial = GetOrCreateTeddyMaterial(val); Renderer[] componentsInChildren = instance.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!val2.enabled || ShouldHideBundleHelperObject(((Component)val2).transform)) { val2.enabled = false; continue; } Material[] sharedMaterials = val2.sharedMaterials; bool flag = false; for (int j = 0; j < sharedMaterials.Length; j++) { Material val3 = sharedMaterials[j]; string text = (((Object)(object)val3 != (Object)null) ? ((Object)val3).name : string.Empty); string name = ((Object)val2).name; Material val4 = ((text.IndexOf("tedd", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("tedd", StringComparison.OrdinalIgnoreCase) < 0) ? ((text.IndexOf("hair", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("hair", StringComparison.OrdinalIgnoreCase) < 0) ? ((text.IndexOf("cloth", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("skirt", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("cloth", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("skirt", StringComparison.OrdinalIgnoreCase) < 0) ? ((text.IndexOf("head", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("face", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("head", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("face", StringComparison.OrdinalIgnoreCase) < 0) ? orCreateBodyMaterial : orCreateFaceMaterial) : orCreateClothesMaterial) : orCreateHairMaterial) : orCreateTeddyMaterial); if (sharedMaterials[j] != val4) { sharedMaterials[j] = val4; flag = true; } } if (flag) { val2.sharedMaterials = sharedMaterials; } } } private static Material GetOrCreateBodyMaterial(Shader standardShader) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if ((Object)(object)_bodyMaterial != (Object)null) { return _bodyMaterial; } _bodyMaterial = new Material(standardShader) { name = "MitaBodyBuiltIn", hideFlags = (HideFlags)61, color = Color.white }; Texture2D val = ResolvePreferredTexture("CreepyMitaBody.png", ref _bodyAlbedoTexture, isNormalMap: false); Texture2D val2 = ResolvePreferredTexture("", ref _bodyNormalTexture, isNormalMap: true); if ((Object)(object)val != (Object)null) { _bodyMaterial.mainTexture = (Texture)(object)val; _bodyMaterial.SetTexture("_MainTex", (Texture)(object)val); } if ((Object)(object)val2 != (Object)null) { _bodyMaterial.SetTexture("_BumpMap", (Texture)(object)val2); _bodyMaterial.EnableKeyword("_NORMALMAP"); _bodyMaterial.SetFloat("_BumpScale", 0.8f); } _bodyMaterial.SetFloat("_Metallic", 0.18f); _bodyMaterial.SetFloat("_Glossiness", 0.42f); return _bodyMaterial; } private static Material GetOrCreateClothesMaterial(Shader standardShader) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if ((Object)(object)_clothesMaterial != (Object)null) { return _clothesMaterial; } _clothesMaterial = new Material(standardShader) { name = "MitaClothesBuiltIn", hideFlags = (HideFlags)61, color = Color.white }; Texture2D val = ResolvePreferredTexture("CreepyMitaClothes.png", ref _clothesAlbedoTexture, isNormalMap: false); Texture2D val2 = ResolvePreferredTexture("", ref _clothesNormalTexture, isNormalMap: true); if ((Object)(object)val != (Object)null) { _clothesMaterial.mainTexture = (Texture)(object)val; _clothesMaterial.SetTexture("_MainTex", (Texture)(object)val); } if ((Object)(object)val2 != (Object)null) { _clothesMaterial.SetTexture("_BumpMap", (Texture)(object)val2); _clothesMaterial.EnableKeyword("_NORMALMAP"); _clothesMaterial.SetFloat("_BumpScale", 0.75f); } _clothesMaterial.SetFloat("_Metallic", 0.02f); _clothesMaterial.SetFloat("_Glossiness", 0.24f); return _clothesMaterial; } private static Material GetOrCreateFaceMaterial(Shader standardShader) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if ((Object)(object)_faceMaterial != (Object)null) { return _faceMaterial; } _faceMaterial = new Material(standardShader) { name = "MitaFaceBuiltIn", hideFlags = (HideFlags)61, color = Color.white }; Texture2D val = ResolvePreferredTexture("Face_2.png", ref _faceAlbedoTexture, isNormalMap: false); if ((Object)(object)val != (Object)null) { _faceMaterial.mainTexture = (Texture)(object)val; _faceMaterial.SetTexture("_MainTex", (Texture)(object)val); } _faceMaterial.SetFloat("_Glossiness", 0.18f); return _faceMaterial; } private static Material GetOrCreateHairMaterial(Shader standardShader) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if ((Object)(object)_hairMaterial != (Object)null) { return _hairMaterial; } _hairMaterial = new Material(standardShader) { name = "MitaHairBuiltIn", hideFlags = (HideFlags)61, color = Color.white }; Texture2D val = ResolvePreferredTexture("TestHairsalpha2.png", ref _hairAlbedoTexture, isNormalMap: false); Texture2D val2 = ResolvePreferredTexture("TestHairsN2.png", ref _hairNormalTexture, isNormalMap: true); if ((Object)(object)val != (Object)null) { _hairMaterial.mainTexture = (Texture)(object)val; _hairMaterial.SetTexture("_MainTex", (Texture)(object)val); } if ((Object)(object)val2 != (Object)null) { _hairMaterial.SetTexture("_BumpMap", (Texture)(object)val2); _hairMaterial.EnableKeyword("_NORMALMAP"); _hairMaterial.SetFloat("_BumpScale", 0.85f); } _hairMaterial.SetFloat("_Glossiness", 0.28f); _hairMaterial.SetFloat("_Cutoff", 0.58f); ConfigureCutoutMaterial(_hairMaterial, 0.58f); return _hairMaterial; } private static void ConfigureCutoutMaterial(Material material, float cutoff) { material.SetFloat("_Mode", 1f); material.SetFloat("_Cutoff", cutoff); material.SetFloat("_SrcBlend", 1f); material.SetFloat("_DstBlend", 0f); material.SetFloat("_ZWrite", 1f); material.DisableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.EnableKeyword("_ALPHATEST_ON"); material.renderQueue = 2450; } private static Material GetOrCreateTeddyMaterial(Shader standardShader) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if ((Object)(object)_teddyMaterial != (Object)null) { return _teddyMaterial; } _teddyMaterial = new Material(standardShader) { name = "MitaTeddyBuiltIn", hideFlags = (HideFlags)61, color = Color.white }; Texture2D val = ResolvePreferredTexture("TeddyBear.png", ref _teddyAlbedoTexture, isNormalMap: false); if ((Object)(object)val != (Object)null) { _teddyMaterial.mainTexture = (Texture)(object)val; _teddyMaterial.SetTexture("_MainTex", (Texture)(object)val); } _teddyMaterial.SetFloat("_Glossiness", 0.08f); return _teddyMaterial; } private static Texture2D? ResolvePreferredTexture(string expectedFileName, ref Texture2D? cache, bool isNormalMap) { if (string.IsNullOrWhiteSpace(expectedFileName)) { return null; } if ((Object)(object)cache != (Object)null) { return cache; } string text = ResolvePluginFile(expectedFileName); if (!string.IsNullOrEmpty(text)) { cache = LoadTextureFromDisk(text, expectedFileName, isNormalMap); if ((Object)(object)cache != (Object)null) { return cache; } } if ((Object)(object)_mitaBundle == (Object)null) { return null; } Texture2D[] array = _mitaBundle.LoadAllAssets(); foreach (Texture2D val in array) { if (!((Object)(object)val == (Object)null) && (string.Equals(((Object)val).name, Path.GetFileNameWithoutExtension(expectedFileName), StringComparison.OrdinalIgnoreCase) || string.Equals(((Object)val).name, expectedFileName, StringComparison.OrdinalIgnoreCase))) { cache = val; return cache; } } return null; } private static Texture2D? LoadTextureFromDisk(string path, string textureName, bool isNormalMap) { //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_001d: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown try { byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, isNormalMap) { name = Path.GetFileNameWithoutExtension(textureName), wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; if (!ImageConversion.LoadImage(val, array, false)) { Object.Destroy((Object)(object)val); return null; } val.Apply(true, false); return val; } catch (Exception ex) { Log.LogWarning((object)("[Mita] Failed to load texture '" + path + "': " + ex.Message)); return null; } } private static Transform BuildFallbackVisualRig(Transform attachRoot, out Transform centerTransform, out Transform headTransform) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: 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_0210: 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_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0372: 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) GameObject val = new GameObject("MitaVisualRoot"); val.transform.SetParent(attachRoot, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; Material seedMaterial = FindSeedMaterial(val); Material material = CreateTintedMaterial(seedMaterial, new Color(0.42f, 0.2f, 0.54f)); Material material2 = CreateTintedMaterial(seedMaterial, new Color(0.32f, 0.32f, 0.34f)); Material material3 = CreateTintedMaterial(seedMaterial, new Color(0.96f, 0.96f, 0.96f)); Transform val2 = CreatePiece("Torso", (PrimitiveType)1, val.transform, new Vector3(0f, 1.2f, 0f), new Vector3(0.5f, 0.78f, 0.42f), material); Transform val3 = CreatePiece("Head", (PrimitiveType)0, val.transform, new Vector3(0f, 2.15f, 0.1f), new Vector3(0.48f, 0.48f, 0.48f), material); CreatePiece("LeftEye", (PrimitiveType)0, val3, new Vector3(-0.1f, 0.03f, 0.42f), new Vector3(0.12f, 0.12f, 0.08f), material3); CreatePiece("RightEye", (PrimitiveType)0, val3, new Vector3(0.1f, 0.03f, 0.42f), new Vector3(0.12f, 0.12f, 0.08f), material3); CreatePiece("LeftArm", (PrimitiveType)2, val.transform, new Vector3(-0.68f, 1.25f, 0f), new Vector3(0.11f, 0.52f, 0.11f), material, (Vector3?)new Vector3(0f, 0f, 34f)); CreatePiece("RightArm", (PrimitiveType)2, val.transform, new Vector3(0.68f, 1.25f, 0f), new Vector3(0.11f, 0.52f, 0.11f), material, (Vector3?)new Vector3(0f, 0f, -12f)); CreatePiece("LeftLeg", (PrimitiveType)2, val.transform, new Vector3(-0.21f, 0.42f, 0f), new Vector3(0.13f, 0.48f, 0.13f), material); CreatePiece("RightLeg", (PrimitiveType)2, val.transform, new Vector3(0.21f, 0.42f, 0f), new Vector3(0.13f, 0.48f, 0.13f), material); CreatePiece("AxeHandle", (PrimitiveType)2, val.transform, new Vector3(0.95f, 1.05f, 0f), new Vector3(0.07f, 0.8f, 0.07f), material2, (Vector3?)new Vector3(0f, 0f, 22f)); CreatePiece("AxeHead", (PrimitiveType)3, val.transform, new Vector3(1.18f, 1.55f, 0f), new Vector3(0.18f, 0.36f, 0.72f), material2); centerTransform = new GameObject("MitaCenter").transform; centerTransform.SetParent(attachRoot, false); centerTransform.localPosition = new Vector3(0f, 1.45f, 0f); headTransform = val3; return val.transform; } private static void ConfigureGrabbableBody(GameObject enemyObject, Transform visualRoot, PhysGrabObject physGrabObject) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) Transform transform = enemyObject.transform; Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(transform.position + Vector3.up * 1.4f, new Vector3(0.9f, 2.8f, 0.9f)); Renderer[] componentsInChildren = ((Component)visualRoot).GetComponentsInChildren(true); if (componentsInChildren.Length != 0) { bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && componentsInChildren[i].enabled) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } } } Vector3 val = transform.InverseTransformPoint(((Bounds)(ref bounds)).center); physGrabObject.colliders.Clear(); if (!ConfigureMeshGrabColliders(visualRoot, physGrabObject)) { ConfigureFallbackGrabCollider(transform, val, bounds, physGrabObject); } Transform val2 = transform.Find("Center of Mass"); if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("Center of Mass"); val3.transform.SetParent(transform, false); val2 = val3.transform; } val2.localPosition = val; val2.localRotation = Quaternion.identity; val2.localScale = Vector3.one; Transform val4 = transform.Find("ForceCenterPoint"); if ((Object)(object)val4 == (Object)null) { GameObject val5 = new GameObject("ForceCenterPoint"); val5.transform.SetParent(transform, false); val4 = val5.transform; } val4.localPosition = val + new Vector3(0f, 0.1f, 0.08f); val4.localRotation = Quaternion.identity; val4.localScale = Vector3.one; } private static bool ConfigureMeshGrabColliders(Transform visualRoot, PhysGrabObject physGrabObject) { int num = LayerMask.NameToLayer("PhysGrabObject"); int num2 = 0; SkinnedMeshRenderer[] componentsInChildren = ((Component)visualRoot).GetComponentsInChildren(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { if ((Object)(object)val == (Object)null || !((Renderer)val).enabled || (Object)(object)val.sharedMesh == (Object)null || ShouldHideBundleHelperObject(((Component)val).transform)) { continue; } string name = ((Object)val).name; if (name.IndexOf("hair", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("face", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("eye", StringComparison.OrdinalIgnoreCase) < 0 && name.IndexOf("teddy", StringComparison.OrdinalIgnoreCase) < 0) { GameObject gameObject = ((Component)val).gameObject; if (num >= 0) { gameObject.layer = num; } try { gameObject.tag = "Phys Grab Object"; } catch (UnityException) { } MeshCollider val3 = gameObject.GetComponent() ?? gameObject.AddComponent(); val3.sharedMesh = val.sharedMesh; val3.convex = true; ((Collider)val3).isTrigger = false; PhysGrabObjectCollider val4 = gameObject.GetComponent() ?? gameObject.AddComponent(); val4.colliderID = num2++; val4.physGrabObject = physGrabObject; if (!physGrabObject.colliders.Contains(gameObject.transform)) { physGrabObject.colliders.Add(gameObject.transform); } } } return physGrabObject.colliders.Count > 0; } private static void ConfigureFallbackGrabCollider(Transform enemyTransform, Vector3 centerLocal, Bounds bounds, PhysGrabObject physGrabObject) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003c: 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_0058: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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) Transform val = enemyTransform.Find("Grab Collider"); GameObject val2; if ((Object)(object)val == (Object)null) { val2 = new GameObject("Grab Collider"); val2.transform.SetParent(enemyTransform, false); } else { val2 = ((Component)val).gameObject; } val2.transform.localPosition = centerLocal; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; int num = LayerMask.NameToLayer("PhysGrabObject"); val2.layer = ((num >= 0) ? num : 0); try { val2.tag = "Phys Grab Object"; } catch (UnityException) { } CapsuleCollider val4 = val2.GetComponent() ?? val2.AddComponent(); ((Collider)val4).isTrigger = false; val4.direction = 1; val4.center = Vector3.zero; val4.height = Mathf.Clamp(((Bounds)(ref bounds)).size.y * 0.86f, 1.65f, 2.8f); val4.radius = Mathf.Clamp(Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z) * 0.18f, 0.22f, 0.46f); PhysGrabObjectCollider val5 = val2.GetComponent() ?? val2.AddComponent(); val5.colliderID = 0; val5.physGrabObject = physGrabObject; physGrabObject.colliders.Add(val2.transform); } private static PhysAttribute GetOrCreateGrabPhysAttribute() { if ((Object)(object)_grabPhysAttribute != (Object)null) { return _grabPhysAttribute; } _grabPhysAttribute = ScriptableObject.CreateInstance(); ((Object)_grabPhysAttribute).hideFlags = (HideFlags)61; ((Object)_grabPhysAttribute).name = "PhysAttributeMitaGrab"; _grabPhysAttribute.mass = 3f; return _grabPhysAttribute; } private static Durability GetOrCreateGrabDurability() { if ((Object)(object)_grabDurability != (Object)null) { return _grabDurability; } _grabDurability = ScriptableObject.CreateInstance(); ((Object)_grabDurability).hideFlags = (HideFlags)61; ((Object)_grabDurability).name = "DurabilityMitaGrab"; _grabDurability.fragility = 100f; _grabDurability.durability = 100f; return _grabDurability; } private static void RefreshHealthVisuals(EnemyHealth health, Transform meshRoot) { //IL_0162: Unknown result type (might be due to invalid IL or missing references) health.meshParent = meshRoot; health.renderers = new List(); health.sharedMaterials = new List(); health.instancedMaterials = new List(); health.renderers.AddRange(((Component)meshRoot).GetComponentsInChildren(true)); foreach (MeshRenderer renderer in health.renderers) { Material val = null; foreach (Material sharedMaterial in health.sharedMaterials) { if ((Object)(object)((Renderer)renderer).sharedMaterial != (Object)null && ((Object)((Renderer)renderer).sharedMaterial).name == ((Object)sharedMaterial).name) { val = sharedMaterial; ((Renderer)renderer).sharedMaterial = health.instancedMaterials[health.sharedMaterials.IndexOf(sharedMaterial)]; break; } } if ((Object)(object)val == (Object)null) { val = ((Renderer)renderer).sharedMaterial; if (!((Object)(object)val == (Object)null)) { health.sharedMaterials.Add(val); health.instancedMaterials.Add(((Renderer)renderer).material); } } } health.materialHurtColor = Shader.PropertyToID("_ColorOverlay"); health.materialHurtAmount = Shader.PropertyToID("_ColorOverlayAmount"); foreach (Material instancedMaterial in health.instancedMaterials) { instancedMaterial.SetColor(health.materialHurtColor, health.hurtColor); instancedMaterial.SetFloat(health.materialHurtAmount, 0f); } } private static GameObject? LoadMitaVisualPrefab() { if ((Object)(object)_mitaVisualPrefab != (Object)null) { return _mitaVisualPrefab; } string text = ResolvePluginFile("empressmita"); if (string.IsNullOrEmpty(text)) { return null; } try { if (_mitaBundle == null) { _mitaBundle = AssetBundle.LoadFromFile(text); } if ((Object)(object)_mitaBundle == (Object)null) { Log.LogWarning((object)("[Mita] Failed to load asset bundle at " + text)); return null; } if (BundleAnimationClips == null) { BundleAnimationClips = _mitaBundle.LoadAllAssets(); } string[] mitaBundlePrefabCandidates = MitaBundlePrefabCandidates; foreach (string text2 in mitaBundlePrefabCandidates) { GameObject val = _mitaBundle.LoadAsset(text2); if ((Object)(object)val != (Object)null) { _mitaVisualPrefab = val; return _mitaVisualPrefab; } } GameObject[] array = _mitaBundle.LoadAllAssets(); foreach (GameObject val2 in array) { if (!((Object)(object)val2 == (Object)null)) { _mitaVisualPrefab = val2; Log.LogWarning((object)("[Mita] Falling back to first prefab '" + ((Object)val2).name + "' from asset bundle.")); return _mitaVisualPrefab; } } } catch (Exception ex) { Log.LogWarning((object)("[Mita] Failed while loading visual asset bundle: " + ex.Message)); } return null; } internal static AssetBundle? LoadMitaAudioBundle() { if ((Object)(object)_mitaAudioBundle != (Object)null) { return _mitaAudioBundle; } string text = ResolvePluginFile("empressmitaaudio"); if (string.IsNullOrEmpty(text)) { return null; } try { _mitaAudioBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_mitaAudioBundle == (Object)null) { Log.LogWarning((object)("[Mita] Failed to load audio asset bundle at " + text)); } return _mitaAudioBundle; } catch (Exception ex) { Log.LogWarning((object)("[Mita] Failed while loading audio asset bundle: " + ex.Message)); return null; } } internal static AudioClip? LoadAudioClip(string clipName) { AssetBundle val = LoadMitaAudioBundle(); if ((Object)(object)val == (Object)null) { return null; } try { return val.LoadAsset(clipName); } catch (Exception ex) { Log.LogWarning((object)("[Mita] Failed to load audio clip '" + clipName + "': " + ex.Message)); return null; } } internal static AudioClip[] LoadAudioClips(IEnumerable clipNames) { List list = new List(); foreach (string clipName in clipNames) { AudioClip val = LoadAudioClip(clipName); if ((Object)(object)val != (Object)null) { list.Add(val); } } return list.ToArray(); } internal static string? ResolvePluginFile(string fileName) { if (string.IsNullOrWhiteSpace(PluginDirectory) || !Directory.Exists(PluginDirectory)) { return null; } string text = Path.Combine(PluginDirectory, fileName); if (File.Exists(text)) { return text; } try { foreach (string item in Directory.EnumerateFiles(PluginDirectory, fileName, SearchOption.AllDirectories)) { if (File.Exists(item)) { return item; } } } catch (Exception ex) { Log.LogWarning((object)("[Mita] Failed while searching for '" + fileName + "' in plugin directory: " + ex.Message)); } return null; } private static Transform? FindChildByName(Transform root, string name) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (string.Equals(((Object)val).name, name, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } private static Bounds? GetCombinedRendererBounds(GameObject gameObject) { //IL_0004: 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_0037: 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) bool flag = false; Bounds value = default(Bounds); Renderer[] componentsInChildren = gameObject.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (val.enabled) { if (!flag) { value = val.bounds; flag = true; } else { ((Bounds)(ref value)).Encapsulate(val.bounds); } } } if (!flag) { return null; } return value; } private static int ResolveVisualLayer(string layerName) { int num = LayerMask.NameToLayer(layerName); if (num < 0) { return 0; } return num; } private static void SetVisualLayerRecursively(Transform root, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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); } Shader val3 = Shader.Find("Standard"); if ((Object)(object)val3 != (Object)null) { return new Material(val3); } throw new InvalidOperationException("Could not resolve a fallback material for the Mita visuals."); } private static Material CreateTintedMaterial(Material seedMaterial, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001a: 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) Material val = new Material(seedMaterial); if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } return val; } private static Transform CreatePiece(string name, PrimitiveType primitiveType, Transform parent, Vector3 localPosition, Vector3 localScale, Material material, Vector3? localEulerAngles = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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) 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 void PatchTemplateGuards(Harmony harmony) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyParent), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "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(EmpressRepoMitaPlugin), "SkipTemplateEnemyStateStunnedUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool SkipTemplateEnemyParentAwake(EnemyParent __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyParentUpdate(EnemyParent __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyAwake(Enemy __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyStart(Enemy __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyUpdate(Enemy __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyNavMeshAgentAwake(EnemyNavMeshAgent __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyNavMeshAgentOnEnable(EnemyNavMeshAgent __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyNavMeshAgentUpdate(EnemyNavMeshAgent __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyStateSpawnUpdate(EnemyStateSpawn __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyStateStunnedUpdate(EnemyStateStunned __instance) { return !MitaTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } } [HarmonyPatch(typeof(EnemyDirector), "Start")] internal static class EmpressRepoMitaEnemyDirectorStartPatch { private static void Postfix() { EmpressRepoMitaPlugin.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 EnemyHasHealthRef = AccessTools.FieldRefAccess("HasHealth"); private static readonly FieldRef EnemyHasNavMeshAgentRef = AccessTools.FieldRefAccess("HasNavMeshAgent"); private static readonly FieldRef EnemyHasStateInvestigateRef = AccessTools.FieldRefAccess("HasStateInvestigate"); private static readonly FieldRef EnemyHasStateSpawnRef = AccessTools.FieldRefAccess("HasStateSpawn"); private static readonly FieldRef EnemyHasStateStunnedRef = AccessTools.FieldRefAccess("HasStateStunned"); private static readonly FieldRef EnemyHealthRef = AccessTools.FieldRefAccess("Health"); private static readonly FieldRef EnemyNavMeshAgentRef = AccessTools.FieldRefAccess("NavMeshAgent"); private static readonly FieldRef EnemyPhotonViewRef = AccessTools.FieldRefAccess("PhotonView"); private static readonly FieldRef EnemyStateInvestigateRef = AccessTools.FieldRefAccess("StateInvestigate"); private static readonly FieldRef EnemyStateSpawnRef = AccessTools.FieldRefAccess("StateSpawn"); private static readonly FieldRef EnemyStateStunnedRef = AccessTools.FieldRefAccess("StateStunned"); private static readonly FieldRef EnemyVisionMaskRef = AccessTools.FieldRefAccess("VisionMask"); private static readonly FieldRef EnemyStateSpawnEnemyRef = AccessTools.FieldRefAccess("Enemy"); private static readonly FieldRef EnemyStateStunnedEnemyRef = AccessTools.FieldRefAccess("enemy"); 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 SetHealth(Enemy enemy, EnemyHealth health) { EnemyHealthRef.Invoke(enemy) = health; } internal static void SetHasHealth(Enemy enemy, bool value) { EnemyHasHealthRef.Invoke(enemy) = value; } internal static void SetNavMeshAgent(Enemy enemy, EnemyNavMeshAgent? navMeshAgent) { EnemyNavMeshAgentRef.Invoke(enemy) = navMeshAgent; } internal static void SetHasNavMeshAgent(Enemy enemy, bool value) { EnemyHasNavMeshAgentRef.Invoke(enemy) = value; } internal static void SetStateInvestigate(Enemy enemy, EnemyStateInvestigate stateInvestigate) { EnemyStateInvestigateRef.Invoke(enemy) = stateInvestigate; } internal static void SetHasStateInvestigate(Enemy enemy, bool value) { EnemyHasStateInvestigateRef.Invoke(enemy) = value; } 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) { enemy.TargetPlayerViewID = 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; } } [DefaultExecutionOrder(-100)] internal sealed class MitaTemplateBootstrap : MonoBehaviour { private const string EnableObjectName = "EnableObject"; private const string EnemyObjectName = "MitaEnemy"; private const string CenterObjectName = "Center"; private const string TemplateContainerName = "EmpressMitaTemplateContainer"; private static readonly HashSet TemplateInstanceIds = new HashSet(); private static GameObject? _templateContainer; private bool _runtimeBuilt; internal static GameObject CreateTemplate(ManualLogSource log) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) GameObject val = EnsureTemplateContainer(); GameObject val2 = new GameObject("EmpressMitaPrefab") { 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 Mita 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if ((Object)(object)_templateContainer != (Object)null) { return _templateContainer; } _templateContainer = new GameObject("EmpressMitaTemplateContainer"); ((Object)_templateContainer).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)_templateContainer); _templateContainer.SetActive(false); return _templateContainer; } private static void BuildTemplateCore(Transform root) { //IL_0041: 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_0064: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: 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("MitaEnemy"); 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.45f, 0f); PhotonView val6 = val4.AddComponent(); val6.Synchronization = (ViewSynchronization)3; ((Behaviour)val6).enabled = false; CapsuleCollider val7 = val4.AddComponent(); val7.center = new Vector3(0f, 1.42f, 0f); val7.height = 3.18f; val7.radius = 0.66f; Rigidbody val8 = val4.AddComponent(); val8.isKinematic = true; val8.useGravity = false; val8.collisionDetectionMode = (CollisionDetectionMode)3; val8.constraints = (RigidbodyConstraints)112; EnemyStateSpawn stateSpawn = val4.AddComponent(); EnemyStateStunned stateStunned = val4.AddComponent(); Enemy val9 = val4.AddComponent(); val.enemyName = "Mita"; val.difficulty = (Difficulty)1; val.actionMultiplier = 1.55f; val.overchargeMultiplier = 1.2f; val.EnableObject = val3; val.SpawnedTimeMin = 30f; val.SpawnedTimeMax = 55f; val.DespawnedTimeMin = 18f; val.DespawnedTimeMax = 28f; RepoEnemyAccess.SetSetupDone(val, value: false); RepoEnemyAccess.SetEnemyParentEnemy(val, val9); RepoEnemyAccess.SetEnemyParent(val9, val); RepoEnemyAccess.SetPhotonView(val9, val6); val9.CenterTransform = val5.transform; val9.KillLookAtTransform = val5.transform; val9.CustomValuableSpawnTransform = val5.transform; RepoEnemyAccess.SetStateSpawn(val9, stateSpawn); RepoEnemyAccess.SetHasStateSpawn(val9, value: true); RepoEnemyAccess.SetStateStunned(val9, stateStunned); RepoEnemyAccess.SetHasStateStunned(val9, value: true); RepoEnemyAccess.SetVisionMask(val9, LayerMask.op_Implicit(LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "HideTriggers" }))); RepoEnemyAccess.SetTargetPlayerViewId(val9, -1); val9.CurrentState = (EnemyState)1; RepoEnemyAccess.SetStateSpawnEnemy(stateSpawn, val9); RepoEnemyAccess.SetStateStunnedEnemy(stateStunned, val9); val4.SetActive(true); val2.ObservedComponents = new List { (Component)(object)val }; val6.ObservedComponents = new List { (Component)(object)val9 }; SetLayerRecursively(root, layer); TrySetTagRecursively(root, "Enemy"); } private void Start() { if (IsTemplateInstance(((Component)this).gameObject) || _runtimeBuilt) { return; } _runtimeBuilt = true; try { BuildRuntimeInstance(); } catch (Exception arg) { EmpressRepoMitaPlugin.Log.LogError((object)$"Failed to finish Mita spawn: {arg}"); } } 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("Mita core components were not present on spawned clone."); } SetHideFlagsRecursively(((Component)this).transform, (HideFlags)0); ((Behaviour)rootPhotonView).enabled = true; ((Behaviour)enemyPhotonView).enabled = true; EnsureRuntimeNavMeshAgent(enemy); EmpressRepoMitaPlugin.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/MitaEnemy/Center")); enemyPhotonView = val; centerTransform = val2; if ((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) { return (Object)(object)val2 != (Object)null; } return false; } private static EnemyNavMeshAgent EnsureRuntimeNavMeshAgent(Enemy enemy) { //IL_0058: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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 { EmpressRepoMitaPlugin.Log.LogWarning((object)$"[Mita] Could not find nearby NavMesh for spawned Mita 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 = true; if (!((Behaviour)val).enabled && TryFindNearestNavMeshPoint(enemy, out var hit2)) { ((Behaviour)val).enabled = true; if (val.isOnNavMesh) { val.Warp(((NavMeshHit)(ref hit2)).position); } } return val2; } private static bool TryFindNearestNavMeshPoint(Enemy enemy, out NavMeshHit hit) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0033: 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_0077: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) 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)enemy.EnemyParent != (Object)null) ? ((Component)enemy.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 = 3.15f; navMeshAgent.acceleration = 24f; navMeshAgent.angularSpeed = 220f; navMeshAgent.stoppingDistance = 0.9f; navMeshAgent.radius = 0.48f; navMeshAgent.height = 2.9f; navMeshAgent.autoTraverseOffMeshLink = true; navMeshAgent.obstacleAvoidanceType = (ObstacleAvoidanceType)4; } private static int ResolveLayer(string layerName) { int num = LayerMask.NameToLayer(layerName); if (num < 0) { return 0; } return num; } private static void SetHideFlagsRecursively(Transform root, HideFlags hideFlags) { //IL_0006: 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_0021: Expected O, but got Unknown //IL_0022: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) { } } } public sealed class EmpressRepoMitaController : MonoBehaviour { private enum MitaState { Roaming, Stalking, Chasing, Attacking, Recovering, Leaving, Dead } private const float RoamSpeed = 1.3f; private const float StalkSpeed = 1.75f; private const float ChaseSpeed = 3.25f; private const float LeaveSpeed = 2.25f; private const float DetectionRange = 20f; private const float ForcedDetectDistance = 5f; private const float LoseTargetDistance = 34f; private const float TeleportDistanceMin = 9.5f; private const float AttackDistance = 1.45f; private const float AttackCooldown = 2.8f; private const float RecoverDuration = 0.95f; private const float LeaveDuration = 6.5f; private const float StareDurationMin = 0.25f; private const float StareDurationMax = 0.65f; private const float AmbushChance = 0.14f; private const float TurnSpeed = 10f; private const float BreathIntervalMin = 6.5f; private const float BreathIntervalMax = 11f; private const float StareIntervalMin = 5.5f; private const float StareIntervalMax = 9.5f; private const float VoiceIntervalMin = 5.5f; private const float VoiceIntervalMax = 13f; private const float VoiceGlitchDurationMin = 0.85f; private const float VoiceGlitchDurationMax = 4.75f; private const float HauntRushDurationMin = 1.35f; private const float HauntRushDurationMax = 2.45f; private const float HauntRushSpeedBonus = 0.72f; private const float MemoryHuntDuration = 4.2f; private const float StepMoveThreshold = 0.92f; private const float AttackDamage = 25f; private const float DoorPushCooldownTime = 0.1f; private const float DoorPushRadius = 0.72f; private const float DoorPushForce = 3.1f; private const float DoorPushTorque = 1.35f; private const float ObjectPushRadius = 0.9f; private const float ObjectPushForce = 2.2f; private const float ObjectPushUpward = 0.12f; private const string BreathClipName = "Ambient MitaNear"; private const string StareClipName = "MitaBreath"; private const string TeleportClipName = "MitaHide"; private const string AttackSwingClipName = "Move MitaAttack"; private const string AttackHitClipPrimaryName = "MitaCreepy Hit 1"; private const string AttackHitSecondaryName = "MitaCreepy Hit 2"; private static readonly string[] VoiceClipNames = new string[3] { "Mita Creepy", "MitaCreepy Killing", "Mita Screamer" }; private static readonly string[] StepClipNames = new string[1] { "MitaStep" }; private static readonly int DoorPushMask = LayerMask.GetMask(new string[1] { "PhysGrabObjectHinge" }); private static readonly int ObjectPushMask = LayerMask.GetMask(new string[1] { "PhysGrabObject" }); private static readonly Collider[] DoorPushHits = (Collider[])(object)new Collider[8]; private static readonly Collider[] ObjectPushHits = (Collider[])(object)new Collider[12]; private const string IdleStateName = "Idle"; private const string AttackRunningStateName = "Mita Attack"; private const string AttackHorizontalStateName = "Mita Attack"; private const string AttackStationaryStateName = "Mita Attack"; private const string AttackBackLeftStateName = "Mita Attack"; private const string AttackBackRightStateName = "Mita Attack"; private const string TeleportForwardStateName = "Mita Appear"; private const string TeleportBackwardStateName = "Mita Appear"; private const string DeathStateName = "Mita Break"; private const string MovementStateName = "Walk"; public Transform VisualRoot; public Transform CenterTransform; public Transform HeadTransform; public Animator? VisualAnimator; public EnemyHealth? Health; public PhysGrabObject? GrabObject; private Enemy _enemy; private EnemyParent _enemyParent; private PhotonView _photonView; private EnemyNavMeshAgent? _navAgent; private PlayerAvatar? _targetPlayer; private MitaState _state; private bool _initialized; private bool _spawnedPrevious; private bool _dead; private bool _dying; private bool _attackDamageDone; private bool _stateAware; private float _stateTimer; private float _targetRefreshTimer; private float _attackCooldownTimer; private float _teleportCooldownTimer; private float _roamRetargetTimer; private float _stareDuration; private float _movementSpeed; private float _attackDuration; private float _attackHitTime; private Vector3 _roamDestination; private Vector3 _leaveDestination; private Vector3 _lastPosition; private Vector3 _lastKnownTargetPosition; private bool _hasLastPosition; private bool _hasLastKnownTargetPosition; private bool _wasStunned; private int _syncedTargetViewId = -1; private bool _animatorHasSpeed; private bool _animatorHasAware; private bool _animatorHasStress; private bool _animatorHasMoveValue; private bool _animatorHasArming; private bool _animatorHasAttackSpeed; private float _animatorLockTimer; private float _nextBreathTime; private float _nextStareTime; private float _nextVoiceTime; private float _stepTimer; private float _doorPushCooldown; private float _locomotionSuppressTimer; private float _hauntRushTimer; private float _memoryHuntTimer; private string? _lockedAnimatorStateName; private string? _lastRequestedAnimatorStateName; private PlayableGraph _oneShotGraph; private bool _oneShotGraphValid; private AnimationClipPlayable _activeClipPlayable; private bool _activeClipLooping; private float _activeClipLength; private float _oneShotTimer; private string? _activeOneShotClipName; private Transform? _leftArmBone; private Transform? _rightArmBone; private Transform? _chestBone; private Transform? _headBone; private Quaternion _leftArmBaseRotation; private Quaternion _rightArmBaseRotation; private Quaternion _chestBaseRotation; private Quaternion _headBaseRotation; private Renderer[]? _teddyRenderers; private bool _teddyVisible = true; private float _glitchTimer; private float _glitchDuration; private Vector3 _visualRootBaseLocalPosition; private Quaternion _visualRootBaseLocalRotation; private bool _hasVisualRootBaseTransform; private AudioSource? _voiceSource; private AudioSource? _stepSource; private AudioSource? _fxSource; private static AudioClip? _breathClip; private static AudioClip? _stareClip; private static AudioClip[]? _stepClips; private static AudioClip? _teleportClip; private static AudioClip? _attackSwingClip; private static AudioClip? _attackHitClip; private static AudioClip[]? _voiceClips; internal EnemyNavMeshAgent? NavAgent => _navAgent; private void Awake() { _enemy = ((Component)this).GetComponent(); _enemyParent = ((Component)this).GetComponentInParent() ?? ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(true); _photonView = ((Component)this).GetComponent(); _navAgent = (EnemyNavMeshAgent?)(_enemy.HasNavMeshAgent ? ((object)_enemy.NavMeshAgent) : ((object)FindNearbyComponent((Component)(object)_enemy))); } private void OnDestroy() { StopOneShotClipPlayback(); } public void InitializeRuntime() { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (_initialized) { return; } if ((Object)(object)VisualAnimator != (Object)null) { ((Behaviour)VisualAnimator).enabled = true; VisualAnimator.applyRootMotion = false; _animatorHasSpeed = HasAnimatorParameter(VisualAnimator, "Speed", (AnimatorControllerParameterType)1); _animatorHasAware = HasAnimatorParameter(VisualAnimator, "IsAware", (AnimatorControllerParameterType)4); _animatorHasStress = HasAnimatorParameter(VisualAnimator, "Stress", (AnimatorControllerParameterType)1); _animatorHasMoveValue = HasAnimatorParameter(VisualAnimator, "MoveValue", (AnimatorControllerParameterType)1); _animatorHasArming = HasAnimatorParameter(VisualAnimator, "Arming", (AnimatorControllerParameterType)1); _animatorHasAttackSpeed = HasAnimatorParameter(VisualAnimator, "AttackSpeed", (AnimatorControllerParameterType)1); VisualAnimator.Rebind(); for (int i = 0; i < VisualAnimator.layerCount; i++) { VisualAnimator.SetLayerWeight(i, (i == 0) ? 1f : 0f); } VisualAnimator.Update(0f); BindProceduralBones(); BindTeddyRenderers(); } if ((Object)(object)VisualRoot != (Object)null) { _visualRootBaseLocalPosition = VisualRoot.localPosition; _visualRootBaseLocalRotation = VisualRoot.localRotation; _hasVisualRootBaseTransform = true; } EnsureAudio(); _state = MitaState.Roaming; _initialized = true; _nextBreathTime = Time.time + Random.Range(0.8f, 2.2f); _nextStareTime = Time.time + Random.Range(2.4f, 4.8f); _nextVoiceTime = Time.time + Random.Range(3.5f, 7.5f); _stepTimer = 0f; UpdateAnimatorState(forceIdle: true); UpdateTeddyVisibility(force: true); } private static T? FindNearbyComponent(Component component) where T : Component { return component.GetComponent() ?? component.GetComponentInChildren(true) ?? component.GetComponentInParent(true); } private void BindProceduralBones() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)VisualRoot == (Object)null)) { _leftArmBone = FindChildRecursive(VisualRoot, "Left arm"); _rightArmBone = FindChildRecursive(VisualRoot, "Right arm"); _chestBone = FindChildRecursive(VisualRoot, "Chest"); _headBone = FindChildRecursive(VisualRoot, "Head"); _leftArmBaseRotation = (((Object)(object)_leftArmBone != (Object)null) ? _leftArmBone.localRotation : Quaternion.identity); _rightArmBaseRotation = (((Object)(object)_rightArmBone != (Object)null) ? _rightArmBone.localRotation : Quaternion.identity); _chestBaseRotation = (((Object)(object)_chestBone != (Object)null) ? _chestBone.localRotation : Quaternion.identity); _headBaseRotation = (((Object)(object)_headBone != (Object)null) ? _headBone.localRotation : Quaternion.identity); } } private void BindTeddyRenderers() { if ((Object)(object)VisualRoot == (Object)null) { _teddyRenderers = Array.Empty(); return; } List list = new List(); Renderer[] componentsInChildren = ((Component)VisualRoot).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { string name = ((Object)val).name; string text = (((Object)(object)val.sharedMaterial != (Object)null) ? ((Object)val.sharedMaterial).name : string.Empty); if (name.IndexOf("teddy", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("bear", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("teddy", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("bear", StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(val); } } } _teddyRenderers = list.ToArray(); _teddyVisible = true; } private static Transform? FindChildRecursive(Transform root, string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown foreach (Transform item in root) { Transform val = item; if (string.Equals(((Object)val).name, name, StringComparison.OrdinalIgnoreCase)) { return val; } Transform val2 = FindChildRecursive(val, name); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } private void UpdateProceduralPose() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_leftArmBone == (Object)null) || !((Object)(object)_rightArmBone == (Object)null) || !((Object)(object)_chestBone == (Object)null) || !((Object)(object)_headBone == (Object)null)) { bool flag = _state == MitaState.Attacking; float num = ((flag && _attackDuration > 0.01f) ? Mathf.Clamp01(_stateTimer / _attackDuration) : 0f); if (!flag) { RestoreProceduralBone(_leftArmBone, _leftArmBaseRotation, 12f); RestoreProceduralBone(_rightArmBone, _rightArmBaseRotation, 12f); RestoreProceduralBone(_chestBone, _chestBaseRotation, 10f); RestoreProceduralBone(_headBone, _headBaseRotation, 10f); return; } float num2 = Mathf.Clamp01(num / 0.35f); float num3 = ((num < 0.35f) ? (num2 * 0.55f) : Mathf.Sin(Mathf.Clamp01((num - 0.35f) / 0.45f) * MathF.PI)); float num4 = Mathf.SmoothStep(1f, 0f, Mathf.Clamp01((num - 0.72f) / 0.28f)); float num5 = Mathf.Clamp01(Mathf.Max(num3, num2 * num4)); SetProceduralBone(_leftArmBone, _leftArmBaseRotation * Quaternion.Euler(Mathf.Lerp(0f, -48f, num5), Mathf.Lerp(0f, -18f, num5), Mathf.Lerp(0f, 24f, num5)), 22f); SetProceduralBone(_rightArmBone, _rightArmBaseRotation * Quaternion.Euler(Mathf.Lerp(0f, -74f, num5), Mathf.Lerp(0f, 24f, num5), Mathf.Lerp(0f, -30f, num5)), 22f); SetProceduralBone(_chestBone, _chestBaseRotation * Quaternion.Euler(Mathf.Lerp(0f, 12f, num5), 0f, Mathf.Lerp(0f, -9f, num5)), 18f); SetProceduralBone(_headBone, _headBaseRotation * Quaternion.Euler(Mathf.Lerp(0f, 7f, num5), 0f, Mathf.Lerp(0f, 5f, num5)), 18f); } } private static void RestoreProceduralBone(Transform? bone, Quaternion baseRotation, float speed) { //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_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)bone == (Object)null)) { bone.localRotation = Quaternion.Slerp(bone.localRotation, baseRotation, Mathf.Clamp01(Time.deltaTime * speed)); } } private static void SetProceduralBone(Transform? bone, Quaternion targetRotation, float speed) { //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_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)bone == (Object)null)) { bone.localRotation = Quaternion.Slerp(bone.localRotation, targetRotation, Mathf.Clamp01(Time.deltaTime * speed)); } } private void TriggerCorruptionGlitch(float duration) { if (!((Object)(object)VisualRoot == (Object)null) && _hasVisualRootBaseTransform) { _glitchDuration = Mathf.Clamp(duration, 0.85f, 4.75f); _glitchTimer = _glitchDuration; } } private void UpdateCorruptionGlitch() { //IL_0030: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)VisualRoot == (Object)null) && _hasVisualRootBaseTransform) { if (_glitchTimer <= 0f) { VisualRoot.localPosition = Vector3.Lerp(VisualRoot.localPosition, _visualRootBaseLocalPosition, Mathf.Clamp01(Time.deltaTime * 18f)); VisualRoot.localRotation = Quaternion.Slerp(VisualRoot.localRotation, _visualRootBaseLocalRotation, Mathf.Clamp01(Time.deltaTime * 18f)); return; } _glitchTimer -= Time.deltaTime; float num = ((_glitchDuration > 0.01f) ? Mathf.Clamp01(_glitchTimer / _glitchDuration) : 0f); float num2 = ((_glitchDuration > 0.01f) ? Mathf.Clamp01(1f - num) : 1f); float num3 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num2 / 0.12f)) * Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num / 0.08f)); float num4 = Mathf.Lerp(0.7f, 1.45f, Mathf.PerlinNoise(Time.time * 22f, (float)((Object)this).GetInstanceID() * 0.013f)); float num5 = ((Random.value < 0.46f) ? 1f : 0.42f); Vector3 val = new Vector3(Random.Range(-0.052f, 0.052f), Random.Range(-0.026f, 0.052f), Random.Range(-0.052f, 0.052f)) * num3 * num4 * num5; Quaternion val2 = Quaternion.Euler(Random.Range(-4.5f, 4.5f) * num3 * num4 * num5, Random.Range(-11f, 11f) * num3 * num4 * num5, Random.Range(-7f, 7f) * num3 * num4 * num5); VisualRoot.localPosition = _visualRootBaseLocalPosition + val; VisualRoot.localRotation = _visualRootBaseLocalRotation * val2; } } private void Update() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) 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; _stateTimer += Time.deltaTime; if (_attackCooldownTimer > 0f) { _attackCooldownTimer -= Time.deltaTime; } if (_teleportCooldownTimer > 0f) { _teleportCooldownTimer -= Time.deltaTime; } if (_doorPushCooldown > 0f) { _doorPushCooldown -= Time.deltaTime; } if (_locomotionSuppressTimer > 0f) { _locomotionSuppressTimer -= Time.deltaTime; } if (_hauntRushTimer > 0f) { _hauntRushTimer -= Time.deltaTime; } if (_memoryHuntTimer > 0f) { _memoryHuntTimer -= Time.deltaTime; } if (_animatorLockTimer > 0f) { _animatorLockTimer -= Time.deltaTime; if (_animatorLockTimer <= 0f) { _animatorLockTimer = 0f; _lockedAnimatorStateName = null; } } if (_oneShotTimer > 0f) { _oneShotTimer -= Time.deltaTime; if (_activeClipLooping && _oneShotGraphValid && _activeClipLength > 0.05f && PlayableExtensions.IsValid(_activeClipPlayable)) { double time = PlayableExtensions.GetTime(_activeClipPlayable); if (time >= (double)_activeClipLength) { PlayableExtensions.SetTime(_activeClipPlayable, time % (double)_activeClipLength); } } if (_oneShotTimer <= 0f) { StopOneShotClipPlayback(); } } 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) { ResetBehaviour(); } } if (!flag) { StopMoving(); StopLoopingAudio(); UpdateAnimatorState(forceIdle: true); return; } if (HasAuthority()) { RunAuthorityLogic(); } else { ClientUpdateFacing(); } UpdatePhysicalInteraction(); UpdateAudio(); UpdateAnimatorState(forceIdle: false); UpdateProceduralPose(); UpdateCorruptionGlitch(); UpdateTeddyVisibility(); } private void ResetBehaviour() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) _dead = false; _dying = false; _state = MitaState.Roaming; _stateAware = false; _stateTimer = 0f; _targetRefreshTimer = 0f; _attackCooldownTimer = 1f; _teleportCooldownTimer = 2f; _roamRetargetTimer = 0f; _stareDuration = Random.Range(0.25f, 0.65f); _attackDamageDone = false; _locomotionSuppressTimer = 0.25f; _hauntRushTimer = 0f; _memoryHuntTimer = 0f; _targetPlayer = null; _syncedTargetViewId = -1; _hasLastKnownTargetPosition = false; _wasStunned = false; _leaveDestination = ((Component)this).transform.position; _lockedAnimatorStateName = null; _lastRequestedAnimatorStateName = null; _animatorLockTimer = 0f; StopOneShotClipPlayback(); _nextBreathTime = Time.time + Random.Range(1.2f, 2.8f); _nextStareTime = Time.time + Random.Range(3.2f, 6.2f); _nextVoiceTime = Time.time + Random.Range(3.5f, 7.5f); _stepTimer = 0f; RepoEnemyAccess.SetTargetPlayerViewId(_enemy, -1); StopMoving(); UpdateTeddyVisibility(force: true); BroadcastState(); } private bool HasAuthority() { if (SemiFunc.IsMultiplayer()) { return PhotonNetwork.IsMasterClient; } return true; } private void RunAuthorityLogic() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) if (_dead || _dying || _state == MitaState.Dead) { return; } if ((int)_enemy.CurrentState == 1) { StopMoving(); _stateAware = false; return; } if (_enemy.IsStunned() || (int)_enemy.CurrentState == 9) { if (!_wasStunned) { HandleStunnedStart(); } _wasStunned = true; StopMoving(); return; } if (_wasStunned) { _wasStunned = false; HandleStunnedEnd(); } if (IsBeingGrabbed()) { StopMoving(); _stateAware = false; return; } if (SemiFunc.EnemyForceLeave(_enemy)) { StartLeaving(); } if (_state == MitaState.Leaving) { HandleLeaving(); return; } _targetRefreshTimer -= Time.deltaTime; if (_targetRefreshTimer <= 0f) { _targetRefreshTimer = 0.35f; AcquireNearestTarget(); } if (_state == MitaState.Attacking) { HandleAttacking(); return; } if (_state == MitaState.Recovering) { HandleRecovering(); return; } if ((Object)(object)_targetPlayer == (Object)null || !IsTargetValid(_targetPlayer)) { _targetPlayer = null; _syncedTargetViewId = -1; RepoEnemyAccess.SetTargetPlayerViewId(_enemy, -1); _stateAware = false; SetState(MitaState.Roaming); HandleRoam(); return; } Vector3 position = ((Component)_targetPlayer).transform.position; float num = Vector3.Distance(((Component)this).transform.position, position); bool flag = HasLineOfSightTo(_targetPlayer); _lastKnownTargetPosition = position; _hasLastKnownTargetPosition = true; if (!flag && num > 34f) { BeginMemoryHunt(position); HandleRoam(); return; } _stateAware = true; switch (_state) { case MitaState.Roaming: SetState(MitaState.Stalking); break; case MitaState.Stalking: HandleStalking(position, num, flag); break; case MitaState.Chasing: HandleChasing(position, num, flag); break; default: SetState(MitaState.Stalking); break; } } private void HandleStalking(Vector3 targetPosition, float distance, bool hasLineOfSight) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (distance <= 1.45f && _attackCooldownTimer <= 0f) { BeginAttack(runningAttack: false); return; } bool flag = _teleportCooldownTimer <= 0f && (distance >= 9.5f || !hasLineOfSight || Random.value < 0.14f); if (!flag) { if (hasLineOfSight) { SetState(MitaState.Chasing); } else { MoveTowards(targetPosition, GetStalkSpeed()); } return; } StopMoving(); FaceTowards(targetPosition, 12f); if (!(_stateTimer < _stareDuration)) { if (flag) { TryTeleportAroundTarget(); _stareDuration = Random.Range(0.25f, 0.65f); } else { SetState(MitaState.Chasing); } } } private void HandleChasing(Vector3 targetPosition, float distance, bool hasLineOfSight) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (distance <= 1.45f && _attackCooldownTimer <= 0f) { BeginAttack(runningAttack: false); return; } if (_teleportCooldownTimer <= 0f && (!hasLineOfSight || distance >= 11.5f)) { TryTeleportAroundTarget(); return; } float speed = ((hasLineOfSight && distance < 7f) ? GetChaseSpeed() : GetStalkSpeed()); MoveTowards(targetPosition, speed); } private float GetStalkSpeed() { if (!(_hauntRushTimer > 0f)) { return 1.75f; } return 2.47f; } private float GetChaseSpeed() { if (!(_hauntRushTimer > 0f)) { return 3.25f; } return 3.97f; } private void HandleRoam() { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.EnemySpawnIdlePause()) { StopMoving(); return; } if (_memoryHuntTimer > 0f && _hasLastKnownTargetPosition) { if (!(Vector3.Distance(((Component)this).transform.position, _roamDestination) <= 1.35f)) { MoveTowards(_roamDestination, GetStalkSpeed()); return; } _memoryHuntTimer = 0f; } _roamRetargetTimer -= Time.deltaTime; if (_roamRetargetTimer <= 0f || !HasPath()) { _roamRetargetTimer = Random.Range(2.6f, 4.8f); _roamDestination = PickRoamDestination(); } MoveTowards(_roamDestination, 1.3f); } private void BeginMemoryHunt(Vector3 lastKnownPosition) { //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_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_0036: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) _lastKnownTargetPosition = lastKnownPosition; _hasLastKnownTargetPosition = true; _targetPlayer = null; _syncedTargetViewId = -1; _stateAware = false; _memoryHuntTimer = 4.2f; Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(0.8f, 2.4f); _roamDestination = ResolveInvestigateDestination(lastKnownPosition + new Vector3(val.x, 0f, val.y)); _roamRetargetTimer = 4.2f; RepoEnemyAccess.SetTargetPlayerViewId(_enemy, -1); SetState(MitaState.Roaming); _nextVoiceTime = Mathf.Min(_nextVoiceTime, Time.time + Random.Range(0.35f, 1.15f)); } private void HandleAttacking() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) StopMoving(); if ((Object)(object)_targetPlayer != (Object)null && IsTargetValid(_targetPlayer)) { FaceTowards(((Component)_targetPlayer).transform.position, 14f); } if (!_attackDamageDone && _stateTimer >= _attackHitTime) { _attackDamageDone = true; DoAttackHit(); } if (_stateTimer >= _attackDuration) { _attackCooldownTimer = 2.8f; SetState(MitaState.Recovering); } } private void HandleRecovering() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) StopMoving(); if ((Object)(object)_targetPlayer != (Object)null && IsTargetValid(_targetPlayer)) { FaceTowards(((Component)_targetPlayer).transform.position, 10f); } if (_stateTimer >= 0.95f) { SetState(((Object)(object)_targetPlayer != (Object)null) ? MitaState.Chasing : MitaState.Roaming); } } private void StartLeaving() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) _targetPlayer = null; _syncedTargetViewId = -1; _stateAware = false; _attackDamageDone = true; RepoEnemyAccess.SetTargetPlayerViewId(_enemy, -1); SemiFunc.EnemyLeaveStart(_enemy); _leaveDestination = PickLeaveDestination(); SetState(MitaState.Leaving); } private void HandleLeaving() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_enemyParent == (Object)null) && _enemyParent.Spawned) { if (Vector3.Distance(((Component)this).transform.position, _leaveDestination) <= 1.25f || _stateTimer >= 6.5f) { StopMoving(); _enemyParent.SpawnedTimerSet(0f); } else { MoveTowards(_leaveDestination, 2.25f); } } } private bool IsBeingGrabbed() { if ((Object)(object)GrabObject != (Object)null) { if (!GrabObject.grabbed && !GrabObject.grabbedLocal) { return GrabObject.playerGrabbing.Count > 0; } return true; } return false; } private void AcquireNearestTarget() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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 ((Object)(object)GameDirector.instance == (Object)null) { _targetPlayer = null; _syncedTargetViewId = -1; RepoEnemyAccess.SetTargetPlayerViewId(_enemy, -1); BroadcastState(); return; } PlayerAvatar val = null; float num = 20f; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (IsTargetValid(player)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (!(num2 > 20f) && (!(num2 > 5f) || CanDetectPlayer(player)) && num2 < num) { val = player; num = num2; } } } int syncedTargetViewId = _syncedTargetViewId; _targetPlayer = val; _syncedTargetViewId = (((Object)(object)val != (Object)null) ? val.photonView.ViewID : (-1)); if ((Object)(object)val != (Object)null) { _memoryHuntTimer = 0f; _lastKnownTargetPosition = ((Component)val).transform.position; _hasLastKnownTargetPosition = true; } RepoEnemyAccess.SetTargetPlayerViewId(_enemy, _syncedTargetViewId); if (syncedTargetViewId != _syncedTargetViewId) { BroadcastState(); } } private PlayerAvatar? FindNearestPlayerTo(Vector3 position, float range) { //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 ((Object)(object)GameDirector.instance == (Object)null) { return null; } PlayerAvatar result = null; float num = range; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (IsTargetValid(player)) { float num2 = Vector3.Distance(position, ((Component)player).transform.position); if (num2 < num) { result = player; num = num2; } } } return result; } private static Vector3 ResolveInvestigateDestination(Vector3 position) { //IL_0000: 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_0012: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 8f, -1)) { return ((NavMeshHit)(ref val)).position; } return position; } private bool CanDetectPlayer(PlayerAvatar player) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) if (!IsTargetValid(player)) { return false; } Vector3 val = (((Object)(object)HeadTransform != (Object)null) ? HeadTransform.position : CenterTransform.position); Transform val2 = (((Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.PlayerVisionTarget.VisionTransform != (Object)null) ? player.PlayerVisionTarget.VisionTransform : ((Component)player).transform); Vector3 val3 = val2.position - val; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude <= 5f) { return true; } if (magnitude > 20f) { return false; } float num = Vector3.Angle(((Component)this).transform.forward, val3); if (num > 75f) { return false; } int num2 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()); RaycastHit val4 = default(RaycastHit); if (Physics.Linecast(val, val2.position, ref val4, num2, (QueryTriggerInteraction)1) && !((RaycastHit)(ref val4)).transform.IsChildOf(((Component)player).transform)) { return false; } return true; } private bool HasLineOfSightTo(PlayerAvatar player) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0067: 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_0074: Unknown result type (might be due to invalid IL or missing references) if (!IsTargetValid(player)) { return false; } Vector3 val = (((Object)(object)HeadTransform != (Object)null) ? HeadTransform.position : CenterTransform.position); Transform val2 = (((Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.PlayerVisionTarget.VisionTransform != (Object)null) ? player.PlayerVisionTarget.VisionTransform : ((Component)player).transform); int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()); RaycastHit val3 = default(RaycastHit); if (Physics.Linecast(val, val2.position, ref val3, num, (QueryTriggerInteraction)1) && !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)player).transform)) { return false; } return true; } private void BeginAttack(bool runningAttack) { _attackDamageDone = false; _attackDuration = (runningAttack ? 1.25f : 1.05f); _attackHitTime = (runningAttack ? 0.62f : 0.48f); SetState(MitaState.Attacking); StopMoving(); _movementSpeed = 0f; string text = SelectAttackState(runningAttack); if (!PlayLockedAnimation(text, 0.05f, _attackDuration + 0.08f)) { PlayLockedAnimatorState(text, 0.05f, _attackDuration + 0.08f); } PlayAttackSwingAudio(); if (SemiFunc.IsMultiplayer()) { _photonView.RPC("PlayAttackRpc", (RpcTarget)1, new object[1] { text }); } } private void DoAttackHit() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0092: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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) if ((Object)(object)GameDirector.instance == (Object)null) { return; } Vector3 val = (((Object)(object)CenterTransform != (Object)null) ? CenterTransform.position : ((Component)this).transform.position); Vector3 forward = ((Component)this).transform.forward; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!IsTargetValid(player)) { continue; } Vector3 val2 = ((Component)player).transform.position - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude > 2.05f) && !(Vector3.Angle(forward, val2) > 54f)) { PlayAttackHitAudio(); Vector3 val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val2)).normalized : forward); val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude <= 0.001f) { val3 = forward; } player.playerHealth.HurtOther(25, ((Component)player).transform.position, true, SemiFunc.EnemyGetIndex(_enemy), false); if ((Object)(object)player.tumble != (Object)null) { player.tumble.TumbleRequest(true, false); player.tumble.TumbleForce(((Vector3)(ref val3)).normalized * 8.5f + Vector3.up * 3.25f); player.tumble.TumbleTorque(Vector3.up * Random.Range(-7f, 7f) + ((Component)this).transform.right * Random.Range(3.5f, 6f)); player.tumble.OverrideLookAtCamera(0.45f, 6f, 4f); player.tumble.OverrideEnemyHurt(0.4f); player.tumble.ImpactHurtSet(0.35f, 0); } } } } private void TryTeleportAroundTarget() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0096: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_targetPlayer == (Object)null || !IsTargetValid(_targetPlayer)) { return; } Vector3 position = ((Component)_targetPlayer).transform.position; Vector3 val = default(Vector3); NavMeshHit val4 = default(NavMeshHit); for (int i = 0; i < 8; i++) { if (i == 0) { val = -((Component)_targetPlayer).transform.forward * Random.Range(5.2f, 7.6f); } else { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val2 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(5.2f, 8.4f); ((Vector3)(ref val))..ctor(val2.x, 0f, val2.y); } Vector3 val3 = position + val; if (NavMesh.SamplePosition(val3, ref val4, 8f, -1) && !(Vector3.Distance(((NavMeshHit)(ref val4)).position, position) < 4.5f)) { Vector3 forward = ((Component)_targetPlayer).transform.forward; Vector3 val5 = ((Component)this).transform.position - position; bool backward = Vector3.Dot(forward, ((Vector3)(ref val5)).normalized) > 0f; PerformTeleport(((NavMeshHit)(ref val4)).position, backward); break; } } } private void PerformTeleport(Vector3 newPosition, bool backward) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) StopMoving(); if ((Object)(object)_navAgent != (Object)null && (Object)(object)_navAgent.Agent != (Object)null) { ((Behaviour)_navAgent.Agent).enabled = true; if (_navAgent.Agent.isOnNavMesh) { _navAgent.Agent.Warp(newPosition); } } ((Component)this).transform.position = newPosition; if ((Object)(object)((Component)this).transform.parent != (Object)null) { ((Component)this).transform.parent.position = newPosition; } _teleportCooldownTimer = Random.Range(10f, 16f); SetState(MitaState.Stalking); _lastPosition = newPosition; _hasLastPosition = true; _movementSpeed = 0f; string text = (backward ? "Mita Appear" : "Mita Appear"); if (!PlayLockedAnimation(text, 0.08f, 0.72f)) { PlayLockedAnimatorState(text, 0.08f, 0.72f); } PlayTeleportAudio(); if (SemiFunc.IsMultiplayer()) { _photonView.RPC("PlayTeleportRpc", (RpcTarget)1, new object[1] { backward }); } } private Vector3 PickRoamDestination() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0029: 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_002b: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0067: 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) Vector3 position = ((Component)this).transform.position; NavMeshHit val3 = default(NavMeshHit); for (int i = 0; i < 8; i++) { Vector2 val = Random.insideUnitCircle * Random.Range(5f, 12f); Vector3 val2 = position + new Vector3(val.x, 0f, val.y); if (NavMesh.SamplePosition(val2, ref val3, 8f, -1)) { return ((NavMeshHit)(ref val3)).position; } } return position; } private Vector3 PickLeaveDestination() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00eb: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) Vector3 position = ((Component)this).transform.position; LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(position, 28f, 55f, false); if ((Object)(object)val == (Object)null) { val = SemiFunc.LevelPointGetFurthestFromPlayer(position, 5f); } if ((Object)(object)val != (Object)null) { NavMeshHit val3 = default(NavMeshHit); for (int i = 0; i < 6; i++) { Vector3 val2 = ((Component)val).transform.position + Random.insideUnitSphere * 3f; if (NavMesh.SamplePosition(val2, ref val3, 6f, -1) && Physics.Raycast(((NavMeshHit)(ref val3)).position + Vector3.up * 0.35f, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" }))) { return ((NavMeshHit)(ref val3)).position; } } } NavMeshHit val6 = default(NavMeshHit); for (int j = 0; j < 8; j++) { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val4 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(12f, 20f); Vector3 val5 = position + new Vector3(val4.x, 0f, val4.y); if (NavMesh.SamplePosition(val5, ref val6, 10f, -1)) { return ((NavMeshHit)(ref val6)).position; } } return position; } private bool HasPath() { if ((Object)(object)_navAgent != (Object)null && (Object)(object)_navAgent.Agent != (Object)null) { return _navAgent.Agent.hasPath; } return false; } private void MoveTowards(Vector3 targetPosition, float speed) { //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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_navAgent == (Object)null || (Object)(object)_navAgent.Agent == (Object)null) { return; } try { _locomotionSuppressTimer = 0f; _navAgent.Stop(0f); _navAgent.UpdateAgent(speed, Mathf.Max(26f, speed * 8f)); _navAgent.SetDestination(targetPosition); Vector3 desiredVelocity = _navAgent.Agent.desiredVelocity; if (((Vector3)(ref desiredVelocity)).sqrMagnitude > 0.01f) { FaceAlongDirection(desiredVelocity, 10f); } else { FaceTowards(targetPosition, 10f); } } catch { StopMoving(); } } private void StopMoving() { //IL_0047: 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) if ((Object)(object)_navAgent != (Object)null) { _navAgent.Stop(0.15f); _navAgent.ResetPath(); if ((Object)(object)_navAgent.Agent != (Object)null) { try { _navAgent.Agent.velocity = Vector3.zero; _navAgent.Agent.nextPosition = ((Component)this).transform.position; } catch { } } } _movementSpeed = 0f; _locomotionSuppressTimer = Mathf.Max(_locomotionSuppressTimer, 0.18f); } private void UpdatePhysicalInteraction() { //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_0073: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007b: 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_0086: Unknown result type (might be due to invalid IL or missing references) if (_doorPushCooldown > 0f || _dead || _state == MitaState.Attacking || _state == MitaState.Recovering) { return; } Vector3 interactionDirection = GetInteractionDirection(); if (!(((Vector3)(ref interactionDirection)).sqrMagnitude <= 0.05f)) { Vector3 probeOrigin = (((Object)(object)CenterTransform != (Object)null) ? CenterTransform.position : (((Component)this).transform.position + Vector3.up * 1.1f)); if (!TryPushDoor(probeOrigin, interactionDirection)) { TryPushObjects(probeOrigin, interactionDirection); } } } private Vector3 GetInteractionDirection() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) //IL_0049: 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) { val = _navAgent.Agent.desiredVelocity; } if (((Vector3)(ref val)).sqrMagnitude <= 0.04f) { val = ((Component)this).transform.forward * Mathf.Max(_movementSpeed, 0f); } val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude > 0.001f)) { return Vector3.zero; } return ((Vector3)(ref val)).normalized; } private bool TryPushDoor(Vector3 probeOrigin, Vector3 direction) { //IL_0000: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c2: 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_00e2: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(probeOrigin, 0.72f, DoorPushHits, DoorPushMask, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = DoorPushHits[i]; DoorPushHits[i] = null; if ((Object)(object)val == (Object)null || ((Component)val).transform.IsChildOf(((Component)this).transform)) { continue; } PhysGrabHinge componentInParent = ((Component)val).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 val2 = val.ClosestPoint(probeOrigin); Vector3 val3 = direction * 3.1f; val3.y = Mathf.Max(val3.y, 0.08f); Vector3 val4 = ((Component)componentInParent).transform.position - ((Component)this).transform.position; val4.y = 0f; float num2 = Mathf.Sign(Vector3.Dot(Vector3.Cross(val4, direction), Vector3.up)); if (Mathf.Abs(num2) < 0.01f) { num2 = 1f; } component.EnemyInteractTimeSet(); component2.AddForceAtPosition(val3, val2, (ForceMode)1); component2.AddTorque(Vector3.up * (1.35f * num2), (ForceMode)1); _doorPushCooldown = 0.1f; return true; } } return false; } private void TryPushObjects(Vector3 probeOrigin, Vector3 direction) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(probeOrigin, 0.9f, ObjectPushHits, ObjectPushMask, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = ObjectPushHits[i]; ObjectPushHits[i] = null; if (!((Object)(object)val == (Object)null) && !((Component)val).transform.IsChildOf(((Component)this).transform)) { PhysGrabObject componentInParent = ((Component)val).GetComponentInParent(); Rigidbody val2 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.rb : val.attachedRigidbody); if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)val2 == (Object)null) && !val2.isKinematic) { Vector3 val3 = direction * 2.2f; val3.y = 0.12f; Vector3 val4 = val.ClosestPoint(probeOrigin); componentInParent.EnemyInteractTimeSet(); val2.AddForceAtPosition(val3, val4, (ForceMode)1); } } } } private void FaceAlongDirection(Vector3 worldDirection, float turnSpeed) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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_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_0048: 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); } } private void FaceTowards(Vector3 worldPosition, float turnSpeed) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_004b: 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_0058: 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); } } private void ClientUpdateFacing() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (_state != MitaState.Dead) { if ((Object)(object)_targetPlayer == (Object)null || !IsTargetValid(_targetPlayer)) { _targetPlayer = ResolveTargetFromViewId(_syncedTargetViewId); } if ((Object)(object)_targetPlayer != (Object)null && (_state == MitaState.Chasing || _state == MitaState.Stalking || _state == MitaState.Attacking)) { FaceTowards(((Component)_targetPlayer).transform.position, 7f); } } } private void SetState(MitaState newState) { if (_state != newState) { MitaState state = _state; _state = newState; _stateTimer = 0f; SyncRepoEnemyState(newState); if ((state == MitaState.Attacking || state == MitaState.Recovering) && (newState == MitaState.Roaming || newState == MitaState.Stalking || newState == MitaState.Chasing)) { _lockedAnimatorStateName = null; _animatorLockTimer = 0f; StopOneShotClipPlayback(); _lastRequestedAnimatorStateName = null; } if (newState == MitaState.Stalking) { _stareDuration = Random.Range(0.25f, 0.65f); } BroadcastState(); } } private void SyncRepoEnemyState(MitaState newState) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0059: 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_0061: 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_0069: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) if (!((Object)(object)_enemy == (Object)null) && newState != MitaState.Dead && (int)_enemy.CurrentState != 9 && (int)_enemy.CurrentState != 11) { Enemy enemy = _enemy; enemy.CurrentState = (EnemyState)(newState switch { MitaState.Roaming => 2, MitaState.Stalking => 3, MitaState.Chasing => 4, MitaState.Attacking => 4, MitaState.Recovering => 6, MitaState.Leaving => 2, _ => _enemy.CurrentState, }); } } private void BroadcastState() { _syncedTargetViewId = (((Object)(object)_targetPlayer != (Object)null && (Object)(object)_targetPlayer.photonView != (Object)null) ? _targetPlayer.photonView.ViewID : (-1)); RepoEnemyAccess.SetTargetPlayerViewId(_enemy, _syncedTargetViewId); if (SemiFunc.IsMultiplayer()) { _photonView.RPC("SyncStateRpc", (RpcTarget)1, new object[3] { (int)_state, _syncedTargetViewId, _stateAware }); } } [PunRPC] private void SyncStateRpc(int state, int targetViewId, bool aware, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { _state = (MitaState)state; _stateTimer = 0f; _syncedTargetViewId = targetViewId; _stateAware = aware; _targetPlayer = ResolveTargetFromViewId(targetViewId); } } [PunRPC] private void PlayAttackRpc(string attackStateName, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { if (!PlayLockedAnimation(attackStateName, 0.05f, 1.35f)) { PlayLockedAnimatorState(attackStateName, 0.05f, 1.35f); } PlayAttackSwingAudio(); } } [PunRPC] private void PlayTeleportRpc(bool backward, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { string text = (backward ? "Mita Appear" : "Mita Appear"); if (!PlayLockedAnimation(text, 0.06f, 0.82f)) { PlayLockedAnimatorState(text, 0.06f, 0.82f); } PlayTeleportAudio(); } } [PunRPC] private void PlayVoiceRpc(int clipIndex, float volume, float pitch, float glitchDuration, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { PlayVoiceEvent(clipIndex, volume, pitch, glitchDuration); } } [PunRPC] private void SyncDeathRpc(PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { EnterDeadState(); } } private void UpdateAnimatorState(bool forceIdle) { //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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Invalid comparison between Unknown and I4 if ((Object)(object)VisualAnimator == (Object)null || _state == MitaState.Dead) { return; } float num = 0f; if ((Object)(object)_navAgent != (Object)null && (Object)(object)_navAgent.Agent != (Object)null && ((Behaviour)_navAgent.Agent).enabled) { try { Vector3 desiredVelocity = _navAgent.Agent.desiredVelocity; num = ((Vector3)(ref desiredVelocity)).magnitude; } catch { num = 0f; } } if (_locomotionSuppressTimer > 0f) { num = 0f; } float num2 = Mathf.Max(_movementSpeed, num); bool flag = !forceIdle && (_state == MitaState.Roaming || _state == MitaState.Stalking || _state == MitaState.Chasing || _state == MitaState.Leaving) && num2 > 0.08f; float num3 = 0f; if (flag) { num3 = ((_state == MitaState.Chasing) ? 4f : 2f); } float num4 = Mathf.Clamp01(num2 / 3.25f); if (_state == MitaState.Attacking) { num4 = 0f; } if ((Object)(object)VisualAnimator != (Object)null) { AnimatorControllerParameter[] parameters = VisualAnimator.parameters; foreach (AnimatorControllerParameter val in parameters) { if ((int)val.type == 4 && string.Equals(val.name, "Walk", StringComparison.Ordinal)) { VisualAnimator.SetBool(val.name, flag); break; } } } if (_animatorHasSpeed) { VisualAnimator.SetFloat("Speed", num3); } if (_animatorHasAware) { VisualAnimator.SetBool("IsAware", false); } if (_animatorHasStress) { VisualAnimator.SetFloat("Stress", (_state == MitaState.Chasing || _state == MitaState.Attacking) ? 1f : 0f); } if (_animatorHasMoveValue) { VisualAnimator.SetFloat("MoveValue", num4); } if (_animatorHasArming) { float num5 = ((_stateAware || _state == MitaState.Chasing || _state == MitaState.Attacking || _state == MitaState.Recovering) ? 1f : 0f); VisualAnimator.SetFloat("Arming", num5); } if (_animatorHasAttackSpeed) { VisualAnimator.SetFloat("AttackSpeed", 1f); } if (!(_animatorLockTimer > 0f) || string.IsNullOrWhiteSpace(_lockedAnimatorStateName)) { if (flag) { PlayAnimatorState("Walk", 0.12f); } else if (forceIdle || ((_state == MitaState.Roaming || _state == MitaState.Stalking || _state == MitaState.Recovering) && num4 < 0.08f)) { PlayAnimatorState("Idle", 0.15f); } } } private void PlayAnimatorState(string stateName, float transitionTime) { if ((Object)(object)VisualAnimator == (Object)null) { return; } try { AnimationClip val = ResolveAnimationClip(stateName); int layerIndex; string resolvedStateName; if ((Object)(object)val != (Object)null && PlayLoopingAnimation(val, stateName)) { _lastRequestedAnimatorStateName = stateName; } else if (TryResolveAnimatorState(stateName, out layerIndex, out resolvedStateName) && !string.Equals(_lastRequestedAnimatorStateName, resolvedStateName, StringComparison.Ordinal)) { _lastRequestedAnimatorStateName = resolvedStateName; VisualAnimator.CrossFadeInFixedTime(resolvedStateName, Mathf.Max(transitionTime, 0.18f), layerIndex); } } catch { } } private bool PlayLoopingAnimation(AnimationClip clip, string stateName) { //IL_0032: 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_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_0067: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)VisualAnimator == (Object)null) { return false; } if (string.Equals(_activeOneShotClipName, ((Object)clip).name, StringComparison.Ordinal)) { return true; } StopOneShotClipPlayback(); try { _oneShotGraph = PlayableGraph.Create("MitaLoop"); ((PlayableGraph)(ref _oneShotGraph)).SetTimeUpdateMode((DirectorUpdateMode)1); AnimationPlayableOutput val = AnimationPlayableOutput.Create(_oneShotGraph, "Animation", VisualAnimator); clip.wrapMode = (WrapMode)2; AnimationClipPlayable val2 = AnimationClipPlayable.Create(_oneShotGraph, clip); ((AnimationClipPlayable)(ref val2)).SetApplyFootIK(false); ((AnimationClipPlayable)(ref val2)).SetApplyPlayableIK(false); PlayableExtensions.SetTime(val2, 0.0); PlayableExtensions.SetSpeed(val2, 1.0); PlayableExtensions.SetDuration(val2, (double)Mathf.Max(clip.length, 0.1f)); PlayableExtensions.SetTimeWrapMode(val2, (DirectorWrapMode)1); PlayableOutputExtensions.SetSourcePlayable(val, val2); ((PlayableGraph)(ref _oneShotGraph)).Play(); _oneShotGraphValid = true; _activeClipPlayable = val2; _activeClipLooping = true; _activeClipLength = Mathf.Max(clip.length, 0.1f); _oneShotTimer = 9999f; _activeOneShotClipName = ((Object)clip).name; _lastRequestedAnimatorStateName = stateName; return true; } catch { StopOneShotClipPlayback(); return false; } } private void PlayLockedAnimatorState(string stateName, float transitionTime, float lockDuration) { _lockedAnimatorStateName = stateName; _lastRequestedAnimatorStateName = stateName; _animatorLockTimer = Mathf.Max(_animatorLockTimer, lockDuration); if (PlayLockedAnimation(stateName, transitionTime, lockDuration) || (Object)(object)VisualAnimator == (Object)null) { return; } try { if (TryResolveAnimatorState(stateName, out int layerIndex, out string resolvedStateName)) { VisualAnimator.Play(resolvedStateName, layerIndex, 0f); VisualAnimator.Update(0f); } } catch { } } private bool PlayLockedAnimation(string clipOrStateName, float transitionTime, float lockDuration) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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) _lockedAnimatorStateName = clipOrStateName; _lastRequestedAnimatorStateName = clipOrStateName; _animatorLockTimer = Mathf.Max(_animatorLockTimer, lockDuration); AnimationClip val = ResolveAnimationClip(clipOrStateName); if ((Object)(object)val == (Object)null || (Object)(object)VisualAnimator == (Object)null) { return false; } StopOneShotClipPlayback(); try { _oneShotGraph = PlayableGraph.Create("MitaOneShot"); ((PlayableGraph)(ref _oneShotGraph)).SetTimeUpdateMode((DirectorUpdateMode)1); AnimationPlayableOutput val2 = AnimationPlayableOutput.Create(_oneShotGraph, "Animation", VisualAnimator); AnimationClipPlayable val3 = AnimationClipPlayable.Create(_oneShotGraph, val); ((AnimationClipPlayable)(ref val3)).SetApplyFootIK(false); ((AnimationClipPlayable)(ref val3)).SetApplyPlayableIK(false); PlayableExtensions.SetTimeWrapMode(val3, (DirectorWrapMode)0); PlayableOutputExtensions.SetSourcePlayable(val2, val3); ((PlayableGraph)(ref _oneShotGraph)).Play(); _oneShotGraphValid = true; _activeClipPlayable = val3; _activeClipLooping = false; _activeClipLength = Mathf.Max(val.length, 0.1f); _oneShotTimer = Mathf.Max(lockDuration, val.length); _activeOneShotClipName = ((Object)val).name; return true; } catch { StopOneShotClipPlayback(); return false; } } private void StopOneShotClipPlayback() { _oneShotTimer = 0f; _activeOneShotClipName = null; _activeClipLooping = false; _activeClipLength = 0f; if (_oneShotGraphValid) { try { ((PlayableGraph)(ref _oneShotGraph)).Destroy(); } catch { } _oneShotGraphValid = false; } } private AnimationClip? ResolveAnimationClip(string clipOrStateName) { AnimationClip[] array = EmpressRepoMitaPlugin.BundleAnimationClips; if ((array == null || array.Length == 0) && (Object)(object)VisualAnimator != (Object)null && (Object)(object)VisualAnimator.runtimeAnimatorController != (Object)null) { array = VisualAnimator.runtimeAnimatorController.animationClips; } if (array == null || array.Length == 0) { return null; } List list = new List(); if (string.Equals(clipOrStateName, "Walk", StringComparison.OrdinalIgnoreCase)) { list.Add("MitaCreepy Walk4"); } else if (string.Equals(clipOrStateName, "Idle", StringComparison.OrdinalIgnoreCase)) { list.Add("MitaCreepy Idle"); } else if (string.Equals(clipOrStateName, "Mita Attack", StringComparison.OrdinalIgnoreCase) || string.Equals(clipOrStateName, "Mita Attack", StringComparison.OrdinalIgnoreCase) || string.Equals(clipOrStateName, "Mita Attack", StringComparison.OrdinalIgnoreCase) || string.Equals(clipOrStateName, "Mita Attack", StringComparison.OrdinalIgnoreCase) || string.Equals(clipOrStateName, "Mita Attack", StringComparison.OrdinalIgnoreCase)) { list.Add("Mita Attack"); list.Add("MitaCreepy Kill"); list.Add("Mita ThrowPlayer"); } else if (string.Equals(clipOrStateName, "Mita Appear", StringComparison.OrdinalIgnoreCase) || string.Equals(clipOrStateName, "Mita Appear", StringComparison.OrdinalIgnoreCase)) { list.Add("Mita Appear"); } else if (string.Equals(clipOrStateName, "Mita Break", StringComparison.OrdinalIgnoreCase)) { list.Add("Mita Break"); list.Add("MitaCreepy End"); } else { list.Add(clipOrStateName); } foreach (string item in list) { AnimationClip val = FindExact(array, item); if ((Object)(object)val != (Object)null) { return val; } } return null; static AnimationClip? FindExact(IEnumerable clips, string name) { foreach (AnimationClip clip in clips) { if ((Object)(object)clip != (Object)null && string.Equals(((Object)clip).name, name, StringComparison.OrdinalIgnoreCase)) { return clip; } } return null; } } private bool TryResolveAnimatorState(string stateName, out int layerIndex, out string resolvedStateName) { layerIndex = 0; resolvedStateName = stateName; if ((Object)(object)VisualAnimator == (Object)null) { return false; } for (int i = 0; i < VisualAnimator.layerCount; i++) { if (VisualAnimator.HasState(i, Animator.StringToHash(stateName))) { layerIndex = i; resolvedStateName = stateName; return true; } string text = "Base Layer." + stateName; if (VisualAnimator.HasState(i, Animator.StringToHash(text))) { layerIndex = i; resolvedStateName = text; return true; } } return false; } private void UpdateTeddyVisibility(bool force = false) { if (_teddyRenderers == null || _teddyRenderers.Length == 0) { return; } bool flag = IsMovingIntentionally(); bool flag2 = _state == MitaState.Roaming && !_stateAware && (Object)(object)_targetPlayer == (Object)null && _locomotionSuppressTimer <= 0f && !flag; if (!force && flag2 == _teddyVisible) { return; } _teddyVisible = flag2; Renderer[] teddyRenderers = _teddyRenderers; foreach (Renderer val in teddyRenderers) { if ((Object)(object)val != (Object)null) { val.enabled = flag2; } } } private bool IsMovingIntentionally() { //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) if (_locomotionSuppressTimer > 0f) { return false; } if (_state != 0 && _state != MitaState.Stalking && _state != MitaState.Chasing && _state != MitaState.Leaving) { return false; } if (_movementSpeed > 0.18f) { return true; } if ((Object)(object)_navAgent == (Object)null || (Object)(object)_navAgent.Agent == (Object)null || !((Behaviour)_navAgent.Agent).enabled) { return false; } try { if (_navAgent.IsStopped()) { return false; } Vector3 desiredVelocity = _navAgent.Agent.desiredVelocity; return ((Vector3)(ref desiredVelocity)).sqrMagnitude > 0.04f || (_navAgent.Agent.hasPath && _navAgent.Agent.remainingDistance > Mathf.Max(_navAgent.Agent.stoppingDistance, 0.35f)); } catch { return false; } } public void HandleSpawn() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (_initialized && !_dead && !_dying && (!HasAuthority() || SemiFunc.EnemySpawn(_enemy))) { ResetBehaviour(); _enemy.CurrentState = (EnemyState)1; } } public void HandleStunnedStart() { if (_initialized && !_dead && !_dying) { _stateAware = false; _attackDamageDone = true; _lockedAnimatorStateName = null; _animatorLockTimer = 0f; StopOneShotClipPlayback(); StopMoving(); BroadcastState(); } } public void HandleStunnedEnd() { if (_initialized && !_dead && !_dying) { _wasStunned = false; _attackCooldownTimer = Mathf.Max(_attackCooldownTimer, 0.75f); _teleportCooldownTimer = Mathf.Max(_teleportCooldownTimer, 1.25f); SetState(((Object)(object)_targetPlayer != (Object)null && IsTargetValid(_targetPlayer)) ? MitaState.Stalking : MitaState.Roaming); } } public void HandleInvestigate() { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if (!_initialized || _dead || _dying || !HasAuthority() || (Object)(object)_enemy == (Object)null || !_enemy.HasStateInvestigate) { return; } Vector3 onInvestigateTriggeredPosition = _enemy.StateInvestigate.onInvestigateTriggeredPosition; if (onInvestigateTriggeredPosition == Vector3.zero) { return; } float num = Vector3.Distance(((Component)this).transform.position, onInvestigateTriggeredPosition); if (!(num > 20f * _enemy.StateInvestigate.rangeMultiplier)) { PlayerAvatar val = FindNearestPlayerTo(onInvestigateTriggeredPosition, 7.5f); if ((Object)(object)val != (Object)null) { _targetPlayer = val; _syncedTargetViewId = val.photonView.ViewID; _stateAware = true; SetState(MitaState.Stalking); } else { _targetPlayer = null; _syncedTargetViewId = -1; _stateAware = false; _roamDestination = ResolveInvestigateDestination(onInvestigateTriggeredPosition); _roamRetargetTimer = Random.Range(3.5f, 5.5f); SetState(MitaState.Roaming); } } } public void HandleObjectHurt() { if (!_dead && !_dying) { _stateAware = true; if ((Object)(object)_targetPlayer == (Object)null || !IsTargetValid(_targetPlayer)) { AcquireNearestTarget(); } if ((Object)(object)_targetPlayer != (Object)null) { SetState(MitaState.Chasing); } } } public void HandleHurt() { if (!_dead && !_dying) { ((MonoBehaviour)this).StartCoroutine(HurtFlashRoutine()); } } private IEnumerator HurtFlashRoutine() { if ((Object)(object)Health == (Object)null || Health.instancedMaterials == null || Health.instancedMaterials.Count == 0) { yield break; } List<(Material material, Color color, Color emission)> originals = new List<(Material, Color, Color)>(); foreach (Material instancedMaterial in Health.instancedMaterials) { if (!((Object)(object)instancedMaterial == (Object)null)) { Color val = (instancedMaterial.HasProperty("_Color") ? instancedMaterial.color : Color.white); Color val2 = (instancedMaterial.HasProperty("_EmissionColor") ? instancedMaterial.GetColor("_EmissionColor") : Color.black); originals.Add((instancedMaterial, val, val2)); if (instancedMaterial.HasProperty("_Color")) { Color color = Color.Lerp(val, new Color(1f, 0.2f, 0.2f, val.a), 0.78f); instancedMaterial.color = color; } if (instancedMaterial.HasProperty("_EmissionColor")) { instancedMaterial.SetColor("_EmissionColor", val2 + new Color(0.55f, 0.08f, 0.08f, 0f)); } } } yield return (object)new WaitForSeconds(0.18f); foreach (var (val3, color2, val4) in originals) { if (!((Object)(object)val3 == (Object)null)) { if (val3.HasProperty("_Color")) { val3.color = color2; } if (val3.HasProperty("_EmissionColor")) { val3.SetColor("_EmissionColor", val4); } } } } public void HandleDeathStart() { if (!_dead) { EnterDeadState(); } } public void HandleDeath() { if (!_dead) { _dead = true; if (SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)_enemyParent != (Object)null) { _enemyParent.Despawn(); } } } private void EnterDeadState() { _dying = true; _state = MitaState.Dead; _stateAware = false; StopMoving(); StopLoopingAudio(); if (!PlayLockedAnimation("Mita Break", 0.1f, 5.5f)) { PlayAnimatorState("Idle", 0.1f); } } private IEnumerator DisableAfterDelay() { yield return (object)new WaitForSeconds(6f); if ((Object)(object)_enemyParent != (Object)null && (Object)(object)_enemyParent.EnableObject != (Object)null) { _enemyParent.EnableObject.SetActive(false); } else { ((Component)this).gameObject.SetActive(false); } } private PlayerAvatar? ResolveTargetFromViewId(int viewId) { if (viewId <= 0 || (Object)(object)GameDirector.instance == (Object)null) { return null; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player != (Object)null && (Object)(object)player.photonView != (Object)null && player.photonView.ViewID == viewId) { return player; } } return null; } private static bool HasAnimatorParameter(Animator animator, string parameterName, AnimatorControllerParameterType parameterType) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) AnimatorControllerParameter[] parameters = animator.parameters; foreach (AnimatorControllerParameter val in parameters) { if (val.type == parameterType && string.Equals(val.name, parameterName, StringComparison.Ordinal)) { return true; } } return false; } private bool IsTargetValid(PlayerAvatar? player) { if ((Object)(object)player != (Object)null && !player.isDisabled && !player.deadSet) { return (Object)(object)player.playerHealth != (Object)null; } return false; } private string SelectAttackState(bool runningAttack) { return "Mita Attack"; } private void EnsureAudio() { if (!((Object)(object)_voiceSource != (Object)null) || !((Object)(object)_stepSource != (Object)null) || !((Object)(object)_fxSource != (Object)null)) { _voiceSource = CreateAudioSource("Voice", 0.8f, 2.2f, 16f); _stepSource = CreateAudioSource("Steps", 0.95f, 1.3f, 14f); _fxSource = CreateAudioSource("FX", 0.9f, 2.2f, 18f); if (_breathClip == null) { _breathClip = EmpressRepoMitaPlugin.LoadAudioClip("Ambient MitaNear") ?? CreateBreathClip(); } if (_stareClip == null) { _stareClip = EmpressRepoMitaPlugin.LoadAudioClip("MitaBreath"); } if (_voiceClips == null) { _voiceClips = EmpressRepoMitaPlugin.LoadAudioClips(VoiceClipNames); } if (_stepClips == null) { _stepClips = EmpressRepoMitaPlugin.LoadAudioClips(StepClipNames); } if (_stepClips.Length == 0) { _stepClips = (AudioClip[]?)(object)new AudioClip[1] { CreateStepClip() }; } if (_teleportClip == null) { _teleportClip = EmpressRepoMitaPlugin.LoadAudioClip("MitaHide") ?? CreateTeleportClip(); } if (_attackSwingClip == null) { _attackSwingClip = EmpressRepoMitaPlugin.LoadAudioClip("Move MitaAttack") ?? CreateAttackSwingClip(); } if (_attackHitClip == null) { _attackHitClip = EmpressRepoMitaPlugin.LoadAudioClip("MitaCreepy Hit 1") ?? EmpressRepoMitaPlugin.LoadAudioClip("MitaCreepy Hit 2") ?? CreateAttackHitClip(); } } } private AudioSource CreateAudioSource(string name, float volume, float minDistance, float maxDistance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) Transform val = (Transform)(((Object)(object)HeadTransform != (Object)null) ? HeadTransform : (((Object)(object)CenterTransform != (Object)null) ? ((object)CenterTransform) : ((object)((Component)this).transform))); GameObject val2 = new GameObject(name + "Audio"); val2.transform.SetParent(val, false); val2.transform.localPosition = Vector3.zero; AudioSource val3 = val2.AddComponent(); val3.playOnAwake = false; val3.loop = false; val3.spatialBlend = 1f; val3.rolloffMode = (AudioRolloffMode)1; val3.dopplerLevel = 0f; val3.spread = 20f; val3.minDistance = minDistance; val3.maxDistance = maxDistance; val3.volume = volume; return val3; } private static float CalculateVoiceGlitchDuration(AudioClip clip) { return Mathf.Clamp(clip.length * 0.92f, 0.85f, 4.75f); } private void PlayVoiceEvent(int clipIndex, float volume, float pitch, float glitchDuration) { if (!((Object)(object)_voiceSource == (Object)null) && _voiceClips != null && clipIndex >= 0 && clipIndex < _voiceClips.Length) { AudioClip val = _voiceClips[clipIndex]; if (!((Object)(object)val == (Object)null)) { _voiceSource.pitch = Mathf.Clamp(pitch, 0.75f, 1.25f); _voiceSource.PlayOneShot(val, Mathf.Clamp01(volume)); TriggerCorruptionGlitch(glitchDuration); _nextBreathTime = Mathf.Max(_nextBreathTime, Time.time + 1.5f); _nextStareTime = Mathf.Max(_nextStareTime, Time.time + 2.5f); } } } private void ApplyVoiceHauntPressure() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (_dead || _dying || _state == MitaState.Attacking || _state == MitaState.Recovering || _state == MitaState.Leaving) { return; } _hauntRushTimer = Mathf.Max(_hauntRushTimer, Random.Range(1.35f, 2.45f)); if ((Object)(object)_targetPlayer != (Object)null && IsTargetValid(_targetPlayer)) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position); if (num > 2.45f && num < 13.5f && Random.value < 0.38f) { _teleportCooldownTimer = Mathf.Min(_teleportCooldownTimer, Random.Range(0.45f, 1.35f)); } } else if (_hasLastKnownTargetPosition && _memoryHuntTimer <= 0f && Random.value < 0.55f) { BeginMemoryHunt(_lastKnownTargetPosition); } } private void UpdateAudio() { if (_dead) { return; } bool flag = (Object)(object)_voiceSource != (Object)null && _voiceSource.isPlaying; if (HasAuthority() && Time.time >= _nextVoiceTime && (Object)(object)_voiceSource != (Object)null && _voiceClips != null && _voiceClips.Length != 0 && !flag && (_state == MitaState.Roaming || _state == MitaState.Stalking || _state == MitaState.Chasing)) { int num = Random.Range(0, _voiceClips.Length); AudioClip clip = _voiceClips[num]; float num2 = ((_state == MitaState.Chasing) ? 0.78f : ((_state == MitaState.Stalking) ? 0.64f : 0.46f)); float num3 = Random.Range(0.95f, 1.04f); float num4 = CalculateVoiceGlitchDuration(clip); PlayVoiceEvent(num, num2, num3, num4); ApplyVoiceHauntPressure(); if (SemiFunc.IsMultiplayer()) { _photonView.RPC("PlayVoiceRpc", (RpcTarget)1, new object[4] { num, num2, num3, num4 }); } _nextVoiceTime = Time.time + Random.Range(5.5f, 13f); _nextBreathTime = Mathf.Max(_nextBreathTime, Time.time + 1.5f); _nextStareTime = Mathf.Max(_nextStareTime, Time.time + 2.5f); flag = true; } if (Time.time >= _nextStareTime && (Object)(object)_voiceSource != (Object)null && (Object)(object)_stareClip != (Object)null && !flag && (_state == MitaState.Stalking || _state == MitaState.Chasing)) { _voiceSource.pitch = Random.Range(0.98f, 1.02f); _voiceSource.PlayOneShot(_stareClip, (_state == MitaState.Chasing) ? 0.52f : 0.42f); _nextStareTime = Time.time + Random.Range(7f, 12f); flag = true; } if (Time.time >= _nextBreathTime && (Object)(object)_voiceSource != (Object)null && (Object)(object)_breathClip != (Object)null && !flag) { float num5 = ((_state == MitaState.Chasing || _state == MitaState.Attacking) ? 0.7f : 0.42f); _voiceSource.pitch = Random.Range(0.97f, 1.01f); _voiceSource.PlayOneShot(_breathClip, num5); _nextBreathTime = Time.time + Random.Range(6.5f, 11f); flag = true; } if (_movementSpeed > 0.92f && (_state == MitaState.Roaming || _state == MitaState.Stalking || _state == MitaState.Chasing || _state == MitaState.Leaving)) { float num6 = ((_state == MitaState.Chasing) ? 0.92f : ((_state == MitaState.Stalking) ? 1.12f : 1.34f)); _stepTimer -= Time.deltaTime; if (_stepTimer <= 0f && (Object)(object)_stepSource != (Object)null && _stepClips != null && _stepClips.Length != 0 && !_stepSource.isPlaying) { AudioClip val = _stepClips[Random.Range(0, _stepClips.Length)]; _stepSource.pitch = ((_state == MitaState.Chasing) ? Random.Range(0.94f, 0.99f) : Random.Range(0.9f, 0.96f)); _stepSource.PlayOneShot(val, (_state == MitaState.Chasing) ? 0.58f : 0.42f); _stepTimer = Mathf.Max(num6, val.length * 0.9f); } } else { _stepTimer = 0f; } } private void StopLoopingAudio() { if ((Object)(object)_voiceSource != (Object)null) { _voiceSource.Stop(); } if ((Object)(object)_stepSource != (Object)null) { _stepSource.Stop(); } if ((Object)(object)_fxSource != (Object)null) { _fxSource.Stop(); } } private void PlayTeleportAudio() { if (!((Object)(object)_fxSource == (Object)null) && !((Object)(object)_teleportClip == (Object)null)) { _fxSource.pitch = Random.Range(0.9f, 1.05f); _fxSource.PlayOneShot(_teleportClip, 0.95f); } } private void PlayAttackSwingAudio() { if (!((Object)(object)_fxSource == (Object)null) && !((Object)(object)_attackSwingClip == (Object)null)) { _fxSource.pitch = Random.Range(0.94f, 1.06f); _fxSource.PlayOneShot(_attackSwingClip, 0.92f); } } private void PlayAttackHitAudio() { if (!((Object)(object)_fxSource == (Object)null) && !((Object)(object)_attackHitClip == (Object)null)) { _fxSource.pitch = Random.Range(0.92f, 1f); _fxSource.PlayOneShot(_attackHitClip, 1f); } } private static AudioClip CreateBreathClip() { int num = Mathf.CeilToInt(27600f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 24000f; float num3 = Mathf.Sin(Mathf.Clamp01(num2 / 1.15f) * MathF.PI); float num4 = Mathf.Sin(MathF.PI * 184f * num2) * 0.3f + Mathf.Sin(MathF.PI * 276f * num2) * 0.18f; float num5 = (Mathf.PerlinNoise(num2 * 21f, 0.17f) - 0.5f) * 0.16f; array[i] = (num4 + num5) * num3 * 0.5f; } return CreateClip("MitaBreath", array, 24000); } private static AudioClip CreateStepClip() { int num = Mathf.CeilToInt(8160f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 24000f; float num3 = Mathf.Exp(-18f * num2); float num4 = Mathf.Sin(MathF.PI * 104f * num2) * num3; float num5 = (Mathf.PerlinNoise(num2 * 85f, 0.41f) - 0.5f) * num3 * 0.55f; array[i] = (num4 * 0.8f + num5 * 0.32f) * 0.9f; } return CreateClip("MitaStep", array, 24000); } private static AudioClip CreateTeleportClip() { int num = Mathf.CeilToInt(12480f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 24000f; float num3 = Mathf.Sin(Mathf.Clamp01(num2 / 0.52f) * MathF.PI); float num4 = Mathf.Lerp(780f, 120f, num2 / 0.52f); float num5 = Mathf.Sin(MathF.PI * 2f * num4 * num2); float num6 = (Mathf.PerlinNoise(num2 * 140f, 0.63f) - 0.5f) * 0.65f; array[i] = (num5 * 0.22f + num6 * 0.4f) * num3; } return CreateClip("MitaTeleport", array, 24000); } private static AudioClip CreateAttackSwingClip() { int num = Mathf.CeilToInt(6720f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 24000f; float num3 = Mathf.Exp(-12f * num2); float num4 = Mathf.Lerp(420f, 160f, num2 / 0.28f); float num5 = (Mathf.PerlinNoise(num2 * 180f, 0.12f) - 0.5f) * 0.75f; float num6 = Mathf.Sin(MathF.PI * 2f * num4 * num2) * 0.2f; array[i] = (num5 * 0.5f + num6) * num3; } return CreateClip("MitaAttackSwing", array, 24000); } private static AudioClip CreateAttackHitClip() { int num = Mathf.CeilToInt(5760f); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 24000f; float num3 = Mathf.Exp(-20f * num2); float num4 = Mathf.Sin(MathF.PI * 132f * num2) * 0.65f; float num5 = (Mathf.PerlinNoise(num2 * 240f, 0.91f) - 0.5f) * 0.85f; array[i] = (num4 + num5 * 0.42f) * num3; } return CreateClip("MitaAttackHit", array, 24000); } private static AudioClip CreateClip(string name, float[] samples, int sampleRate) { AudioClip val = AudioClip.Create(name, samples.Length, 1, sampleRate, false); val.SetData(samples, 0); return val; } } }