Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of GhostGirl Enemy v1.0.1
BepInEx\plugins\Empress-GhostGirl\GhostGirl.dll
Decompiled 3 hours ago
The result has been truncated due to the large size, download it to view full contents!
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.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GhostGirl")] [assembly: AssemblyTitle("GhostGirl")] [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.GhostGirl { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Empress.REPO.GhostGirl", "Empress REPO Ghost Girl", "1.0.0")] public sealed class EmpressRepoGhostGirlPlugin : BaseUnityPlugin { private const string GhostGirlBundleFileName = "empressghostgirl"; private const float GhostGirlBundleVisualScale = 0.96f; private const float GhostGirlVisualAlpha = 0.62f; private const string GhostGirlAlbedoTextureFileName = "GirlInDressBigTex.png"; private const string GhostGirlNormalTextureFileName = "GhostGirlNormal.png"; private static readonly string[] GhostGirlBundlePrefabCandidates = new string[4] { "DressGirl", "GhostGirl", "Dress Girl", "DressGirlModel" }; 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.GhostGirl"; internal const string PluginName = "Empress REPO Ghost Girl"; internal const string PluginVersion = "1.0.0"; internal const string TemplatePrefabName = "EmpressGhostGirlPrefab"; private static Harmony? _harmony; private static bool _registered; private static MethodInfo? _spawnManagerRefreshMethod; private static AssetBundle? _ghostgirlBundle; private static GameObject? _ghostgirlVisualPrefab; private static Material? _ghostgirlVisibleMaterial; private static Texture2D? _ghostgirlAlbedoTexture; private static Texture2D? _ghostgirlNormalTexture; internal static ManualLogSource Log { get; private set; } = null; internal static string PluginDirectory { get; private set; } = string.Empty; private void Awake() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin location: " + ((BaseUnityPlugin)this).Info.Location)); PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty; ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); if (_harmony == null) { _harmony = new Harmony("Empress.REPO.GhostGirl"); } PatchTemplateGuards(_harmony); ((MonoBehaviour)this).StartCoroutine(EmpressRepoGhostGirlAudioBank.LoadAudioAsync(((BaseUnityPlugin)this).Logger)); RegisterEnemy(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Empress REPO Ghost Girl v1.0.0"); } private void RegisterEnemy() { if (!_registered) { GameObject item = GhostGirlTemplateBootstrap.CreateTemplate(((BaseUnityPlugin)this).Logger); RarityPreset val = ScriptableObject.CreateInstance<RarityPreset>(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Rarity - Ghost Girl"; val.chance = 60f; EnemySetup val2 = ScriptableObject.CreateInstance<EnemySetup>(); ((Object)val2).hideFlags = (HideFlags)61; ((Object)val2).name = "Enemy - Ghost Girl"; val2.spawnObjects = new List<PrefabRef>(); val2.levelsCompletedCondition = false; val2.levelsCompletedMin = 0; val2.levelsCompletedMax = 10; val2.rarityPreset = val; val2.runsPlayed = 0; EnemyContent val3 = ScriptableObject.CreateInstance<EnemyContent>(); ((Object)val3).hideFlags = (HideFlags)61; ((Object)val3).name = "EnemyContentEmpressGhostGirl"; EnemySetupField.SetValue(val3, val2); SpawnObjectsField.SetValue(val3, new List<GameObject> { item }); Enemies.RegisterEnemy(val3); _registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered the Ghost Girl enemy with REPOLib."); } } internal static void ConfigureRuntimeInstance(EnemyParent enemyParent, Enemy enemy, EnemyStateSpawn stateSpawn, EnemyStateStunned stateStunned, PhotonView rootPhotonView, PhotonView enemyPhotonView, Transform centerTransform) { //IL_0010: 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_0150: 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) Transform centerTransform2; Transform headTransform; Animator visualAnimator; Transform visualRoot = BuildGhostGirlVisualRig(enemy, out centerTransform2, out headTransform, out visualAnimator); enemy.Type = (EnemyType)3; enemy.CenterTransform = centerTransform2; enemy.KillLookAtTransform = headTransform; enemy.CustomValuableSpawnTransform = centerTransform2; enemy.CurrentState = (EnemyState)1; AudioSource voiceSource = CreateAudioSource(((Component)enemy).gameObject, "GhostGirlVoice", 1f, 14f, 0.94f); AudioSource movementSource = CreateAudioSource(((Component)enemy).gameObject, "GhostGirlMovement", 1f, 10f, 0.72f); AudioSource heartbeatSource = CreateAudioSource(((Component)enemy).gameObject, "GhostGirlHeartbeat", 1f, 18f, 0.85f); EmpressRepoGhostGirlController empressRepoGhostGirlController = ((Component)enemy).GetComponent<EmpressRepoGhostGirlController>() ?? ((Component)enemy).gameObject.AddComponent<EmpressRepoGhostGirlController>(); empressRepoGhostGirlController.VisualRoot = visualRoot; empressRepoGhostGirlController.CenterTransform = centerTransform2; empressRepoGhostGirlController.HeadTransform = headTransform; empressRepoGhostGirlController.VisualAnimator = visualAnimator; empressRepoGhostGirlController.VoiceSource = voiceSource; empressRepoGhostGirlController.MovementSource = movementSource; empressRepoGhostGirlController.HeartbeatSource = heartbeatSource; empressRepoGhostGirlController.AppearClips = EmpressRepoGhostGirlAudioBank.GetAppearClips(); empressRepoGhostGirlController.StepClips = EmpressRepoGhostGirlAudioBank.GetStepClips(); empressRepoGhostGirlController.HeartbeatClips = EmpressRepoGhostGirlAudioBank.GetHeartbeatClips(); empressRepoGhostGirlController.BreathingClip = EmpressRepoGhostGirlAudioBank.BreathingClip; RepoEnemyAccess.SetEnemyParentEnemy(enemyParent, enemy); RepoEnemyAccess.SetEnemyParent(enemy, enemyParent); RepoEnemyAccess.SetPhotonView(enemy, enemyPhotonView); RepoEnemyAccess.SetStateSpawn(enemy, stateSpawn); RepoEnemyAccess.SetHasStateSpawn(enemy, value: true); RepoEnemyAccess.SetStateStunned(enemy, stateStunned); RepoEnemyAccess.SetHasStateStunned(enemy, value: true); RepoEnemyAccess.SetVisionMask(enemy, LayerMask.op_Implicit(LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "HideTriggers" }))); RepoEnemyAccess.SetTargetPlayerViewId(enemy, -1); RepoEnemyAccess.SetNavMeshAgent(enemy, null); RepoEnemyAccess.SetHasNavMeshAgent(enemy, value: false); RepoEnemyAccess.SetStateSpawnEnemy(stateSpawn, enemy); RepoEnemyAccess.SetStateStunnedEnemy(stateStunned, enemy); rootPhotonView.ObservedComponents = new List<Component> { (Component)(object)enemyParent }; enemyPhotonView.ObservedComponents = new List<Component> { (Component)(object)enemy }; empressRepoGhostGirlController.KillClip = EmpressRepoGhostGirlAudioBank.KillClip; empressRepoGhostGirlController.InitializeRuntime(); } 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 BuildGhostGirlVisualRig(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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) visualRoot = null; centerTransform = null; headTransform = null; visualAnimator = null; GameObject val = LoadGhostGirlVisualPrefab(); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = Object.Instantiate<GameObject>(val, attachRoot); ((Object)val2).name = "GhostGirlVisualRoot"; val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; Transform transform = val2.transform; transform.localScale *= 0.96f; SanitizeBundleVisualPrefab(val2); SetVisualLayerRecursively(val2.transform, ResolveVisualLayer("Enemy")); HideBundleHelperObjects(val2.transform); ConvertBundleMaterials(val2); Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true); foreach (Collider val3 in componentsInChildren) { val3.enabled = false; } visualRoot = val2.transform; visualAnimator = val2.GetComponentInChildren<Animator>(true); if ((Object)(object)visualAnimator != (Object)null) { ((Behaviour)visualAnimator).enabled = true; visualAnimator.applyRootMotion = false; visualAnimator.cullingMode = (AnimatorCullingMode)0; visualAnimator.Rebind(); visualAnimator.Update(0f); } Transform val4 = FindChildByName(val2.transform, "spine.006") ?? FindChildByName(val2.transform, "head") ?? FindChildByName(val2.transform, "DressGirlModel"); headTransform = val4 ?? val2.transform; Bounds? combinedRendererBounds = GetCombinedRendererBounds(val2); GameObject val5 = new GameObject("GhostGirlCenter"); val5.transform.SetParent(attachRoot, false); Transform transform2 = val5.transform; Vector3 position; if (!combinedRendererBounds.HasValue) { position = attachRoot.position + Vector3.up * 1.35f; } else { Bounds valueOrDefault = combinedRendererBounds.GetValueOrDefault(); position = ((Bounds)(ref valueOrDefault)).center; } transform2.position = position; val5.transform.rotation = Quaternion.identity; centerTransform = val5.transform; Log.LogInfo((object)"Using asset bundle visual prefab for GhostGirl."); return true; } private static void ConvertBundleMaterials(GameObject instance) { Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[GhostGirl] Could not find Standard shader for material conversion."); return; } Material val2 = BuildPreferredVisibleMaterial(val); Dictionary<Material, Material> dictionary = new Dictionary<Material, Material>(); Renderer[] componentsInChildren = instance.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { if (!val3.enabled || ShouldHideBundleHelperObject(((Component)val3).transform)) { val3.enabled = false; continue; } Material[] sharedMaterials = val3.sharedMaterials; if ((Object)(object)val2 != (Object)null && sharedMaterials.Length != 0) { Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int j = 0; j < array.Length; j++) { array[j] = val2; } val3.sharedMaterials = array; val3.shadowCastingMode = (ShadowCastingMode)0; val3.receiveShadows = false; continue; } bool flag = false; for (int k = 0; k < sharedMaterials.Length; k++) { Material val4 = sharedMaterials[k]; if (!((Object)(object)val4 == (Object)null)) { if (!dictionary.TryGetValue(val4, out var value)) { value = ConvertMaterialToBuiltIn(val4, val); dictionary.Add(val4, value); } if (sharedMaterials[k] != value) { sharedMaterials[k] = value; flag = true; } } } if (flag) { val3.sharedMaterials = sharedMaterials; } val3.shadowCastingMode = (ShadowCastingMode)0; val3.receiveShadows = false; } } private static void HideBundleHelperObjects(Transform root) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(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; return name.IndexOf("MapDot", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("ScanNode", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("VoiceSFX", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("HeartbeatMusic", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("turnCompass", StringComparison.OrdinalIgnoreCase) >= 0; } private static Material? BuildPreferredVisibleMaterial(Shader standardShader) { //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ghostgirlVisibleMaterial != (Object)null) { return _ghostgirlVisibleMaterial; } if ((Object)(object)_ghostgirlBundle == (Object)null) { return null; } Material val = null; string[] array = new string[4] { "DressGirl", "GhostGirl", "FancyDresserMat", "GhostSheetMat" }; foreach (string text in array) { val = _ghostgirlBundle.LoadAsset<Material>(text); if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { Material[] array2 = _ghostgirlBundle.LoadAllAssets<Material>(); foreach (Material val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { if (((Object)val2).name.IndexOf("dress", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val2).name.IndexOf("girl", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val2).name.IndexOf("fancy", StringComparison.OrdinalIgnoreCase) >= 0) { val = val2; break; } if (val == null) { val = val2; } } } } if ((Object)(object)val != (Object)null) { _ghostgirlVisibleMaterial = ConvertMaterialToBuiltIn(val, standardShader); } else { _ghostgirlVisibleMaterial = new Material(standardShader) { name = "GhostGirlBuiltIn" }; ((Object)_ghostgirlVisibleMaterial).hideFlags = (HideFlags)61; } Texture2D val3 = ResolvePreferredTexture("GirlInDressBigTex.png", ref _ghostgirlAlbedoTexture, isNormalMap: false); Texture2D val4 = ResolvePreferredTexture("GhostGirlNormal.png", ref _ghostgirlNormalTexture, isNormalMap: true); if ((Object)(object)val3 != (Object)null) { _ghostgirlVisibleMaterial.mainTexture = (Texture)(object)val3; _ghostgirlVisibleMaterial.SetTexture("_MainTex", (Texture)(object)val3); } if ((Object)(object)val4 != (Object)null) { _ghostgirlVisibleMaterial.SetTexture("_BumpMap", (Texture)(object)val4); _ghostgirlVisibleMaterial.EnableKeyword("_NORMALMAP"); _ghostgirlVisibleMaterial.SetFloat("_BumpScale", 0.68f); } _ghostgirlVisibleMaterial.color = Color.white; _ghostgirlVisibleMaterial.SetFloat("_Metallic", 0.02f); _ghostgirlVisibleMaterial.SetFloat("_Glossiness", 0.22f); ConfigureGhostMaterialAppearance(_ghostgirlVisibleMaterial); ((Object)_ghostgirlVisibleMaterial).hideFlags = (HideFlags)61; return _ghostgirlVisibleMaterial; } private static Texture2D? ResolvePreferredTexture(string expectedFileName, ref Texture2D? cache, bool isNormalMap) { 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)_ghostgirlBundle == (Object)null) { return null; } Texture2D[] array = _ghostgirlBundle.LoadAllAssets<Texture2D>(); foreach (Texture2D val in array) { if (!((Object)(object)val == (Object)null)) { string text2 = ((Object)val).name ?? string.Empty; bool flag = string.Equals(text2, Path.GetFileNameWithoutExtension(expectedFileName), StringComparison.OrdinalIgnoreCase) || string.Equals(text2, expectedFileName, StringComparison.OrdinalIgnoreCase); if (!flag) { flag = ((!isNormalMap) ? ((text2.IndexOf("dress", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("girl", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("fancy", StringComparison.OrdinalIgnoreCase) >= 0) && text2.IndexOf("normal", StringComparison.OrdinalIgnoreCase) < 0) : (text2.IndexOf("normal", StringComparison.OrdinalIgnoreCase) >= 0)); } if (flag) { cache = val; return cache; } } } return null; } private static Texture2D? LoadTextureFromDisk(string path, string textureName, bool isNormalMap) { //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_0020: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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)("[GhostGirl] Failed to load texture '" + path + "': " + ex.Message)); return null; } } private static Material ConvertMaterialToBuiltIn(Material original, Shader standardShader) { //IL_0002: 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_001f: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(standardShader) { name = ((Object)original).name + "_BuiltIn" }; Texture val2 = (original.HasProperty("_BaseColorMap") ? original.GetTexture("_BaseColorMap") : (original.HasProperty("_MainTex") ? original.GetTexture("_MainTex") : null)); Texture val3 = (original.HasProperty("_NormalMap") ? original.GetTexture("_NormalMap") : (original.HasProperty("_BumpMap") ? original.GetTexture("_BumpMap") : null)); if ((Object)(object)val2 != (Object)null) { val.mainTexture = val2; val.SetTexture("_MainTex", val2); } if ((Object)(object)val3 != (Object)null) { val.SetTexture("_BumpMap", val3); val.EnableKeyword("_NORMALMAP"); } if (original.HasProperty("_BaseColor")) { val.color = original.GetColor("_BaseColor"); } else if (original.HasProperty("_Color")) { val.color = original.GetColor("_Color"); } if (original.HasProperty("_Metallic")) { val.SetFloat("_Metallic", original.GetFloat("_Metallic")); } if (original.HasProperty("_Smoothness")) { val.SetFloat("_Glossiness", original.GetFloat("_Smoothness")); } else if (original.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", original.GetFloat("_Glossiness")); } if (original.HasProperty("_BumpScale")) { val.SetFloat("_BumpScale", original.GetFloat("_BumpScale")); } else if (original.HasProperty("_NormalScale")) { val.SetFloat("_BumpScale", original.GetFloat("_NormalScale")); } ConfigureGhostMaterialAppearance(val); ((Object)val).hideFlags = (HideFlags)61; return val; } private static void ConfigureGhostMaterialAppearance(Material material) { //IL_0002: 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_0015: 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_00b5: Unknown result type (might be due to invalid IL or missing references) Color color = material.color; color.a = 0.62f; material.color = color; material.SetFloat("_Mode", 3f); material.SetOverrideTag("RenderType", "Transparent"); material.SetInt("_SrcBlend", 5); material.SetInt("_DstBlend", 10); material.SetInt("_ZWrite", 0); material.DisableKeyword("_ALPHATEST_ON"); material.EnableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.EnableKeyword("_EMISSION"); material.SetColor("_EmissionColor", new Color(0.16f, 0.22f, 0.32f) * 0.18f); material.renderQueue = 3000; } private static Transform BuildFallbackVisualRig(Transform attachRoot, out Transform centerTransform, out Transform headTransform) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0020: 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_0053: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_01b7: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("GhostGirlVisualRoot"); 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.7f, 0.69f, 0.66f)); Material material2 = CreateTintedMaterial(seedMaterial, new Color(0.14f, 0.14f, 0.16f)); Material material3 = CreateTintedMaterial(seedMaterial, new Color(0.9f, 0.88f, 0.84f)); Material material4 = CreateTintedMaterial(seedMaterial, new Color(0.08f, 0.08f, 0.1f)); Transform val2 = CreatePiece("Torso", (PrimitiveType)1, val.transform, new Vector3(0f, 1.22f, 0f), new Vector3(0.23f, 0.48f, 0.23f), material); Transform val3 = CreatePiece("Skirt", (PrimitiveType)2, val.transform, new Vector3(0f, 0.78f, 0f), new Vector3(0.44f, 0.28f, 0.44f), material2); val3.localRotation = Quaternion.Euler(180f, 0f, 0f); Transform val4 = CreatePiece("Head", (PrimitiveType)0, val.transform, new Vector3(0f, 1.92f, 0f), new Vector3(0.25f, 0.3f, 0.25f), material3); CreatePiece("Hair", (PrimitiveType)1, val4, new Vector3(0f, -0.02f, -0.02f), new Vector3(0.26f, 0.26f, 0.26f), material4); CreatePiece("LeftArm", (PrimitiveType)2, val.transform, new Vector3(-0.26f, 1.26f, 0f), new Vector3(0.05f, 0.33f, 0.05f), material3, (Vector3?)new Vector3(0f, 0f, 18f)); CreatePiece("RightArm", (PrimitiveType)2, val.transform, new Vector3(0.26f, 1.26f, 0f), new Vector3(0.05f, 0.33f, 0.05f), material3, (Vector3?)new Vector3(0f, 0f, -18f)); CreatePiece("LeftLeg", (PrimitiveType)2, val.transform, new Vector3(-0.1f, 0.23f, 0f), new Vector3(0.05f, 0.23f, 0.05f), material3); CreatePiece("RightLeg", (PrimitiveType)2, val.transform, new Vector3(0.1f, 0.23f, 0f), new Vector3(0.05f, 0.23f, 0.05f), material3); centerTransform = new GameObject("GhostGirlCenter").transform; centerTransform.SetParent(attachRoot, false); centerTransform.localPosition = new Vector3(0f, 1.18f, 0f); headTransform = val4; return val.transform; } private static GameObject? LoadGhostGirlVisualPrefab() { if ((Object)(object)_ghostgirlVisualPrefab != (Object)null) { return _ghostgirlVisualPrefab; } string text = ResolvePluginFile("empressghostgirl"); if (string.IsNullOrEmpty(text)) { return null; } try { if (_ghostgirlBundle == null) { _ghostgirlBundle = AssetBundle.LoadFromFile(text); } if ((Object)(object)_ghostgirlBundle == (Object)null) { Log.LogWarning((object)("[GhostGirl] Failed to load asset bundle at " + text)); return null; } string[] ghostGirlBundlePrefabCandidates = GhostGirlBundlePrefabCandidates; foreach (string text2 in ghostGirlBundlePrefabCandidates) { GameObject val = _ghostgirlBundle.LoadAsset<GameObject>(text2); if ((Object)(object)val != (Object)null) { SanitizeBundleVisualPrefab(val); _ghostgirlVisualPrefab = val; return _ghostgirlVisualPrefab; } } GameObject[] array = _ghostgirlBundle.LoadAllAssets<GameObject>(); foreach (GameObject val2 in array) { if (!((Object)(object)val2 == (Object)null)) { SanitizeBundleVisualPrefab(val2); _ghostgirlVisualPrefab = val2; Log.LogWarning((object)("[GhostGirl] Falling back to first prefab '" + ((Object)val2).name + "' from asset bundle.")); return _ghostgirlVisualPrefab; } } } catch (Exception ex) { Log.LogWarning((object)("[GhostGirl] Failed while loading visual asset bundle: " + ex.Message)); } return null; } private static void SanitizeBundleVisualPrefab(GameObject prefab) { NavMeshAgent[] componentsInChildren = prefab.GetComponentsInChildren<NavMeshAgent>(true); foreach (NavMeshAgent val in componentsInChildren) { ((Behaviour)val).enabled = false; Object.DestroyImmediate((Object)(object)val, true); } } 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)("[GhostGirl] 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<Transform>(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_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Bounds value = default(Bounds); Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!flag) { value = val.bounds; flag = true; } else { ((Bounds)(ref value)).Encapsulate(val.bounds); } } return flag ? new Bounds?(value) : null; } private static int ResolveVisualLayer(string layerName) { int num = LayerMask.NameToLayer(layerName); return (num >= 0) ? num : 0; } private static void SetVisualLayerRecursively(Transform root, int layer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ((Component)root).gameObject.layer = layer; foreach (Transform item in root) { Transform root2 = item; SetVisualLayerRecursively(root2, layer); } } private static Material FindSeedMaterial(GameObject prefab) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(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<Renderer>(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMaterial != (Object)null) { return component.sharedMaterial; } } finally { Object.Destroy((Object)(object)val2); } string[] array = new string[4] { "Standard", "Universal Render Pipeline/Lit", "HDRP/Lit", "Sprites/Default" }; foreach (string text in array) { Shader val3 = Shader.Find(text); if ((Object)(object)val3 != (Object)null) { return new Material(val3); } } throw new InvalidOperationException("Could not resolve a fallback material for the GhostGirl visuals."); } private static Material CreateTintedMaterial(Material seedMaterial, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) 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 AudioSource CreateAudioSource(GameObject owner, string name, float spatialBlend, float maxDistance, float volume) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(owner.transform, false); AudioSource val2 = val.AddComponent<AudioSource>(); val2.playOnAwake = false; val2.loop = false; val2.spatialBlend = spatialBlend; val2.rolloffMode = (AudioRolloffMode)1; val2.minDistance = 1f; val2.maxDistance = maxDistance; val2.dopplerLevel = 0f; val2.volume = volume; return val2; } private static Transform CreatePiece(string name, PrimitiveType primitiveType, Transform parent, Vector3 localPosition, Vector3 localScale, Material material, Vector3? localEulerAngles = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(primitiveType); ((Object)val).name = name; val.transform.SetParent(parent, false); val.transform.localPosition = localPosition; val.transform.localScale = localScale; val.transform.localRotation = Quaternion.Euler((Vector3)(((??)localEulerAngles) ?? Vector3.zero)); Collider[] components = val.GetComponents<Collider>(); foreach (Collider val2 in components) { val2.enabled = false; } Renderer component = val.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.sharedMaterial = material; } return val.transform; } private static void PatchTemplateGuards(Harmony harmony) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyParent), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "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(EmpressRepoGhostGirlPlugin), "SkipTemplateEnemyStateStunnedUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.Method(typeof(DebugLogHandler), "LogFormat", new Type[4] { typeof(LogType), typeof(Object), typeof(string), typeof(object[]) }, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(EmpressRepoGhostGirlPlugin), "FilterNavMeshAgentWarning", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static bool SkipTemplateEnemyParentAwake(EnemyParent __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyParentUpdate(EnemyParent __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyAwake(Enemy __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyStart(Enemy __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyUpdate(Enemy __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyNavMeshAgentAwake(EnemyNavMeshAgent __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject) && !IsGhostGirlRuntimeNavAgent(__instance); } private static bool SkipTemplateEnemyNavMeshAgentOnEnable(EnemyNavMeshAgent __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject) && !IsGhostGirlRuntimeNavAgent(__instance); } private static bool SkipTemplateEnemyNavMeshAgentUpdate(EnemyNavMeshAgent __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject) && !IsGhostGirlRuntimeNavAgent(__instance); } private static bool SkipTemplateEnemyStateSpawnUpdate(EnemyStateSpawn __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool SkipTemplateEnemyStateStunnedUpdate(EnemyStateStunned __instance) { return !GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject); } private static bool FilterNavMeshAgentWarning(LogType logType, Object context, string format, object[] args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 return (int)logType != 2 || string.IsNullOrEmpty(format) || format.IndexOf("Failed to create agent because it is not close enough to the NavMesh", StringComparison.OrdinalIgnoreCase) < 0; } private static bool IsGhostGirlRuntimeNavAgent(EnemyNavMeshAgent instance) { if ((Object)(object)instance == (Object)null || (Object)(object)((Component)instance).gameObject == (Object)null) { return false; } if (GhostGirlTemplateBootstrap.IsTemplateInstance(((Component)instance).gameObject)) { return false; } EnemyParent componentInParent = ((Component)instance).GetComponentInParent<EnemyParent>(true); return (Object)(object)componentInParent != (Object)null && string.Equals(componentInParent.enemyName, "GhostGirl", StringComparison.OrdinalIgnoreCase); } } [HarmonyPatch(typeof(EnemyDirector), "Start")] internal static class EmpressRepoGhostGirlEnemyDirectorStartPatch { private static void Postfix() { EmpressRepoGhostGirlPlugin.RefreshSpawnManagerEnemyNames(); } } internal static class RepoEnemyAccess { private static readonly FieldRef<EnemyParent, Enemy> EnemyParentEnemyRef = AccessTools.FieldRefAccess<EnemyParent, Enemy>("Enemy"); private static readonly FieldRef<EnemyParent, bool> EnemyParentSetupDoneRef = AccessTools.FieldRefAccess<EnemyParent, bool>("SetupDone"); private static readonly FieldRef<Enemy, EnemyParent> EnemyEnemyParentRef = AccessTools.FieldRefAccess<Enemy, EnemyParent>("EnemyParent"); private static readonly FieldRef<Enemy, bool> EnemyHasNavMeshAgentRef = AccessTools.FieldRefAccess<Enemy, bool>("HasNavMeshAgent"); private static readonly FieldRef<Enemy, bool> EnemyHasStateSpawnRef = AccessTools.FieldRefAccess<Enemy, bool>("HasStateSpawn"); private static readonly FieldRef<Enemy, bool> EnemyHasStateStunnedRef = AccessTools.FieldRefAccess<Enemy, bool>("HasStateStunned"); private static readonly FieldRef<Enemy, EnemyNavMeshAgent> EnemyNavMeshAgentRef = AccessTools.FieldRefAccess<Enemy, EnemyNavMeshAgent>("NavMeshAgent"); private static readonly FieldRef<Enemy, PhotonView> EnemyPhotonViewRef = AccessTools.FieldRefAccess<Enemy, PhotonView>("PhotonView"); private static readonly FieldRef<Enemy, EnemyStateSpawn> EnemyStateSpawnRef = AccessTools.FieldRefAccess<Enemy, EnemyStateSpawn>("StateSpawn"); private static readonly FieldRef<Enemy, EnemyStateStunned> EnemyStateStunnedRef = AccessTools.FieldRefAccess<Enemy, EnemyStateStunned>("StateStunned"); private static readonly FieldRef<Enemy, int> EnemyTargetPlayerViewIdRef = AccessTools.FieldRefAccess<Enemy, int>("TargetPlayerViewID"); private static readonly FieldRef<Enemy, LayerMask> EnemyVisionMaskRef = AccessTools.FieldRefAccess<Enemy, LayerMask>("VisionMask"); private static readonly FieldRef<EnemyStateSpawn, Enemy> EnemyStateSpawnEnemyRef = AccessTools.FieldRefAccess<EnemyStateSpawn, Enemy>("Enemy"); private static readonly FieldRef<EnemyStateStunned, Enemy> EnemyStateStunnedEnemyRef = AccessTools.FieldRefAccess<EnemyStateStunned, Enemy>("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 SetNavMeshAgent(Enemy enemy, EnemyNavMeshAgent? navMeshAgent) { EnemyNavMeshAgentRef.Invoke(enemy) = navMeshAgent; } internal static void SetHasNavMeshAgent(Enemy enemy, bool value) { EnemyHasNavMeshAgentRef.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 GhostGirlTemplateBootstrap : MonoBehaviour { private const string EnableObjectName = "EnableObject"; private const string EnemyObjectName = "GhostGirlEnemy"; private const string CenterObjectName = "Center"; private const string TemplateContainerName = "EmpressGhostGirlTemplateContainer"; private static readonly HashSet<int> TemplateInstanceIds = new HashSet<int>(); private static GameObject? _templateContainer; private bool _runtimeBuilt; internal static GameObject CreateTemplate(ManualLogSource log) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) GameObject val = EnsureTemplateContainer(); GameObject val2 = new GameObject("EmpressGhostGirlPrefab") { 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 GhostGirl template core."); return val2; } internal static bool IsTemplateInstance(GameObject gameObject) { Transform val = gameObject.transform; while ((Object)(object)val.parent != (Object)null) { val = val.parent; } return TemplateInstanceIds.Contains(((Object)((Component)val).gameObject).GetInstanceID()); } private static GameObject EnsureTemplateContainer() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if ((Object)(object)_templateContainer != (Object)null) { return _templateContainer; } _templateContainer = new GameObject("EmpressGhostGirlTemplateContainer"); ((Object)_templateContainer).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)_templateContainer); _templateContainer.SetActive(false); return _templateContainer; } private static void BuildTemplateCore(Transform root) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0297: 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<EnemyParent>(); PhotonView val2 = ((Component)root).gameObject.AddComponent<PhotonView>(); val2.Synchronization = (ViewSynchronization)3; ((Behaviour)val2).enabled = false; ((Component)root).gameObject.AddComponent<GhostGirlTemplateBootstrap>(); GameObject val3 = new GameObject("EnableObject"); val3.transform.SetParent(root, false); val3.layer = layer; TrySetTag(val3, "Enemy"); GameObject val4 = new GameObject("GhostGirlEnemy"); 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.35f, 0f); PhotonView val6 = val4.AddComponent<PhotonView>(); val6.Synchronization = (ViewSynchronization)3; ((Behaviour)val6).enabled = false; CapsuleCollider val7 = val4.AddComponent<CapsuleCollider>(); val7.center = new Vector3(0f, 1.35f, 0f); val7.height = 3f; val7.radius = 0.45f; EnemyStateSpawn stateSpawn = val4.AddComponent<EnemyStateSpawn>(); EnemyStateStunned stateStunned = val4.AddComponent<EnemyStateStunned>(); Enemy val8 = val4.AddComponent<Enemy>(); val.enemyName = "GhostGirl"; val.difficulty = (Difficulty)2; val.actionMultiplier = 1.55f; val.overchargeMultiplier = 1.25f; val.EnableObject = val3; val.SpawnedTimeMin = 25f; val.SpawnedTimeMax = 45f; val.DespawnedTimeMin = 18f; val.DespawnedTimeMax = 28f; RepoEnemyAccess.SetSetupDone(val, value: false); RepoEnemyAccess.SetEnemyParentEnemy(val, val8); RepoEnemyAccess.SetEnemyParent(val8, val); RepoEnemyAccess.SetPhotonView(val8, val6); val8.CenterTransform = val5.transform; val8.KillLookAtTransform = val5.transform; val8.CustomValuableSpawnTransform = val5.transform; RepoEnemyAccess.SetStateSpawn(val8, stateSpawn); RepoEnemyAccess.SetHasStateSpawn(val8, value: true); RepoEnemyAccess.SetStateStunned(val8, stateStunned); RepoEnemyAccess.SetHasStateStunned(val8, value: true); RepoEnemyAccess.SetVisionMask(val8, LayerMask.op_Implicit(LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "HideTriggers" }))); RepoEnemyAccess.SetTargetPlayerViewId(val8, -1); val8.CurrentState = (EnemyState)1; RepoEnemyAccess.SetStateSpawnEnemy(stateSpawn, val8); RepoEnemyAccess.SetStateStunnedEnemy(stateStunned, val8); val4.SetActive(true); val2.ObservedComponents = new List<Component> { (Component)(object)val }; val6.ObservedComponents = new List<Component> { (Component)(object)val8 }; SetLayerRecursively(root, layer); TrySetTagRecursively(root, "Enemy"); } private void Start() { if (IsTemplateInstance(((Component)this).gameObject) || _runtimeBuilt) { return; } _runtimeBuilt = true; try { BuildRuntimeInstance(); } catch (Exception arg) { EmpressRepoGhostGirlPlugin.Log.LogError((object)$"Failed to finish GhostGirl 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("GhostGirl core components were not present on spawned clone."); } SetHideFlagsRecursively(((Component)this).transform, (HideFlags)0); ((Behaviour)rootPhotonView).enabled = true; ((Behaviour)enemyPhotonView).enabled = true; EnsureRuntimeNavMeshAgent(enemy); EmpressRepoGhostGirlPlugin.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<EnemyParent>(); rootPhotonView = ((Component)this).GetComponent<PhotonView>(); enemy = ((Component)this).GetComponentInChildren<Enemy>(true); stateSpawn = ((Component)this).GetComponentInChildren<EnemyStateSpawn>(true); stateStunned = ((Component)this).GetComponentInChildren<EnemyStateStunned>(true); PhotonView val = (((Object)(object)enemy != (Object)null) ? ((Component)enemy).GetComponent<PhotonView>() : null); Transform val2 = (((Object)(object)enemy != (Object)null && (Object)(object)enemy.CenterTransform != (Object)null) ? enemy.CenterTransform : ((Component)this).transform.Find("EnableObject/GhostGirlEnemy/Center")); enemyPhotonView = val; centerTransform = val2; return (Object)(object)enemyParent != (Object)null && (Object)(object)enemy != (Object)null && (Object)(object)stateSpawn != (Object)null && (Object)(object)stateStunned != (Object)null && (Object)(object)rootPhotonView != (Object)null && (Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null; } private static NavMeshAgent EnsureRuntimeNavMeshAgent(Enemy enemy) { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_01c0: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)enemy).transform.position; if (TryFindNearestNavMeshPoint(enemy, out var hit)) { position = ((NavMeshHit)(ref hit)).position; if ((Object)(object)((Component)enemy).transform.parent != (Object)null) { ((Component)enemy).transform.parent.position = ((NavMeshHit)(ref hit)).position; } ((Component)enemy).transform.position = ((NavMeshHit)(ref hit)).position; } NavMeshAgent val = ((Component)enemy).GetComponent<NavMeshAgent>(); if ((Object)(object)val == (Object)null) { bool activeSelf = ((Component)enemy).gameObject.activeSelf; if (activeSelf) { ((Component)enemy).gameObject.SetActive(false); } val = ((Component)enemy).gameObject.AddComponent<NavMeshAgent>(); if (activeSelf) { ((Component)enemy).gameObject.SetActive(true); } } ConfigureNavMeshAgent(val); ((Behaviour)val).enabled = false; NavMeshHit val2 = default(NavMeshHit); if (TryFindNearestNavMeshPoint(enemy, out var hit2)) { if ((Object)(object)((Component)enemy).transform.parent != (Object)null) { ((Component)enemy).transform.parent.position = ((NavMeshHit)(ref hit2)).position; } ((Component)enemy).transform.position = ((NavMeshHit)(ref hit2)).position; ((Behaviour)val).enabled = true; if (val.isOnNavMesh) { val.Warp(((NavMeshHit)(ref hit2)).position); } } else if (NavMesh.SamplePosition(position, ref val2, 128f, -1)) { if ((Object)(object)((Component)enemy).transform.parent != (Object)null) { ((Component)enemy).transform.parent.position = ((NavMeshHit)(ref val2)).position; } ((Component)enemy).transform.position = ((NavMeshHit)(ref val2)).position; ((Behaviour)val).enabled = true; if (val.isOnNavMesh) { val.Warp(((NavMeshHit)(ref val2)).position); } } return val; } private static bool TryFindNearestNavMeshPoint(Enemy enemy, out NavMeshHit hit) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004b: 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_0066: 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_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_00e9: 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) 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 = 6.25f; navMeshAgent.acceleration = 60f; navMeshAgent.angularSpeed = 240f; navMeshAgent.stoppingDistance = 0.8f; navMeshAgent.radius = 0.42f; navMeshAgent.height = 2.9f; navMeshAgent.autoTraverseOffMeshLink = true; navMeshAgent.obstacleAvoidanceType = (ObstacleAvoidanceType)4; } private static int ResolveLayer(string layerName) { int num = LayerMask.NameToLayer(layerName); return (num >= 0) ? num : 0; } private static void SetHideFlagsRecursively(Transform root, HideFlags hideFlags) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) ((Object)((Component)root).gameObject).hideFlags = hideFlags; foreach (Transform item in root) { Transform root2 = item; SetHideFlagsRecursively(root2, hideFlags); } } private static void SetLayerRecursively(Transform root, int layer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ((Component)root).gameObject.layer = layer; foreach (Transform item in root) { Transform root2 = item; SetLayerRecursively(root2, layer); } } private static void TrySetTagRecursively(Transform root, string tag) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown TrySetTag(((Component)root).gameObject, tag); foreach (Transform item in root) { Transform root2 = item; TrySetTagRecursively(root2, tag); } } private static void TrySetTag(GameObject gameObject, string tag) { try { gameObject.tag = tag; } catch (UnityException) { } } } internal static class EmpressRepoGhostGirlAudioBank { private static readonly string[] AppearFileNames = new string[2] { "GhostlySynth.ogg", "GhostlySynth2.ogg" }; private static readonly string[] HeartbeatFileNames = new string[5] { "HeartBeat.ogg", "Heartbeat1.ogg", "Heartbeat2.ogg", "HeartBeat2_0.ogg", "Heartbeat3.ogg" }; private static readonly string[] StepFileNames = new string[7] { "SkipWalk.ogg", "SkipWalk1.ogg", "SkipWalk2.ogg", "SkipWalk3.ogg", "SkipWalk4.ogg", "SkipWalk5.ogg", "SkipWalk6.ogg" }; private const string BreathingFileName = "Breathing.ogg"; private const string KillFileName = "GhostlySynth2.ogg"; private static bool _started; private static readonly List<AudioClip> LoadedAppearClips = new List<AudioClip>(); private static readonly List<AudioClip> LoadedHeartbeatClips = new List<AudioClip>(); private static readonly List<AudioClip> LoadedStepClips = new List<AudioClip>(); internal static AudioClip? BreathingClip { get; private set; } internal static AudioClip? KillClip { get; private set; } internal static IEnumerator LoadAudioAsync(ManualLogSource log) { if (_started) { yield break; } _started = true; string[] appearFileNames = AppearFileNames; foreach (string fileName in appearFileNames) { yield return LoadClipAsync(fileName, delegate(AudioClip clip) { LoadedAppearClips.Add(clip); }, log); } string[] heartbeatFileNames = HeartbeatFileNames; foreach (string fileName3 in heartbeatFileNames) { yield return LoadClipAsync(fileName3, delegate(AudioClip clip) { LoadedHeartbeatClips.Add(clip); }, log); } string[] stepFileNames = StepFileNames; foreach (string fileName2 in stepFileNames) { yield return LoadClipAsync(fileName2, delegate(AudioClip clip) { LoadedStepClips.Add(clip); }, log); } yield return LoadClipAsync("Breathing.ogg", delegate(AudioClip clip) { BreathingClip = clip; }, log); yield return LoadClipAsync("GhostlySynth2.ogg", delegate(AudioClip clip) { KillClip = clip; }, log); log.LogInfo((object)$"Ghost Girl audio load complete. appear={LoadedAppearClips.Count}, heartbeat={LoadedHeartbeatClips.Count}, steps={LoadedStepClips.Count}, breathing={(Object)(object)BreathingClip != (Object)null}, kill={(Object)(object)KillClip != (Object)null}"); } internal static AudioClip[] GetAppearClips() { return (AudioClip[])((LoadedAppearClips.Count > 0) ? ((Array)LoadedAppearClips.ToArray()) : ((Array)Array.Empty<AudioClip>())); } internal static AudioClip[] GetHeartbeatClips() { return (AudioClip[])((LoadedHeartbeatClips.Count > 0) ? ((Array)LoadedHeartbeatClips.ToArray()) : ((Array)Array.Empty<AudioClip>())); } internal static AudioClip[] GetStepClips() { return (AudioClip[])((LoadedStepClips.Count > 0) ? ((Array)LoadedStepClips.ToArray()) : ((Array)Array.Empty<AudioClip>())); } private static IEnumerator LoadClipAsync(string fileName, Action<AudioClip> assign, ManualLogSource log) { string resolvedPath = EmpressRepoGhostGirlPlugin.ResolvePluginFile(fileName); if (string.IsNullOrEmpty(resolvedPath)) { log.LogWarning((object)("Ghost Girl audio clip '" + fileName + "' was not found under " + EmpressRepoGhostGirlPlugin.PluginDirectory)); yield break; } UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip("file:///" + resolvedPath.Replace("\\", "/"), GetAudioType(resolvedPath)); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { log.LogWarning((object)("Failed to load Ghost Girl audio clip from " + resolvedPath + ": " + request.error)); yield break; } AudioClip clip = DownloadHandlerAudioClip.GetContent(request); ((Object)clip).name = Path.GetFileNameWithoutExtension(fileName); ((Object)clip).hideFlags = (HideFlags)61; assign(clip); } finally { ((IDisposable)request)?.Dispose(); } } private static AudioType GetAudioType(string path) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) string text = Path.GetExtension(path).ToLowerInvariant(); if (1 == 0) { } AudioType result = ((text == ".wav") ? ((AudioType)20) : ((!(text == ".mp3")) ? ((AudioType)14) : ((AudioType)13))); if (1 == 0) { } return result; } } public sealed class EmpressRepoGhostGirlController : MonoBehaviour { private enum GhostGirlState { Hidden, Manifesting, Stalking, Recovering } private const float AttackSpeed = 4.2f; private const float ManifestDistance = 6.5f; private const float ManifestDurationMin = 2.8f; private const float ManifestDurationMax = 5.25f; private const float RecoverDuration = 4.25f; private const float AttackDuration = 10f; private const float DisappearDistance = 2.15f; private const float AttackContactDistance = 1.15f; private const float AttackKillChance = 0.22f; private const float PostAttackCooldownMin = 20f; private const float PostAttackCooldownMax = 60f; private const float TargetRefreshInterval = 0.7f; private const float HiddenTeleportMinDistance = 8f; private const float HiddenTeleportMaxDistance = 14f; private const float HauntKillDelay = 300f; private const string AnimatorBaseLayerIdleStare = "Base Layer.IdleStare"; private const string AnimatorBaseLayerWalk = "Base Layer.Walk"; private const float GhostThrowFloatDuration = 1.15f; private const float GhostThrowLaunchForce = 8.5f; public Transform VisualRoot = null; public Transform CenterTransform = null; public Transform HeadTransform = null; public Animator? VisualAnimator; public AudioSource VoiceSource = null; public AudioSource MovementSource = null; public AudioSource HeartbeatSource = null; public AudioClip[] AppearClips = Array.Empty<AudioClip>(); public AudioClip[] StepClips = Array.Empty<AudioClip>(); public AudioClip[] HeartbeatClips = Array.Empty<AudioClip>(); public AudioClip? BreathingClip; public AudioClip? KillClip; private Enemy _enemy = null; private EnemyParent _enemyParent = null; private PhotonView _photonView = null; private NavMeshAgent? _navAgent; private PlayerAvatar? _targetPlayer; private Collider? _bodyCollider; private GhostGirlState _state; private bool _initialized; private bool _spawnedPrevious; private bool _manifested; private bool _animatorHasWalkBool; private bool _animatorHasIdleStareState; private bool _animatorHasWalkState; private bool _networkInitialized; private bool _walkAnimationActive; private float _stateTimer; private float _targetRefreshTimer; private float _movementSpeed; private float _movementAudioTimer; private float _heartbeatTimer; private float _breathingTimer; private float _killCooldown; private float _hauntTimer; private float _currentManifestDuration; private float _postAttackCooldownTimer; private Vector3 _lastPosition; private Vector3 _recentMovementDelta; private bool _hasLastPosition; private int _stepIndex; private Coroutine? _ghostThrowRoutine; private void Awake() { _enemy = ((Component)this).GetComponent<Enemy>(); _enemyParent = ((Component)this).GetComponentInParent<EnemyParent>() ?? ((Component)this).GetComponent<EnemyParent>() ?? ((Component)this).GetComponentInChildren<EnemyParent>(true); _photonView = ((Component)this).GetComponent<PhotonView>(); _navAgent = ((Component)this).GetComponent<NavMeshAgent>() ?? FindNearbyComponent<NavMeshAgent>((Component)(object)_enemy); _bodyCollider = ((Component)this).GetComponent<Collider>(); } public void InitializeRuntime() { if (!_initialized) { EnsureRuntimeBindings(); if ((Object)(object)VisualAnimator != (Object)null) { ((Behaviour)VisualAnimator).enabled = true; VisualAnimator.applyRootMotion = false; _animatorHasWalkBool = HasAnimatorParameter(VisualAnimator, "Walk", (AnimatorControllerParameterType)4); _animatorHasIdleStareState = HasAnimatorState(VisualAnimator, "Base Layer.IdleStare"); _animatorHasWalkState = HasAnimatorState(VisualAnimator, "Base Layer.Walk"); } _initialized = true; ResetBehaviour(); _networkInitialized = true; } } private void EnsureRuntimeBindings() { if (_enemy == null) { _enemy = ((Component)this).GetComponent<Enemy>(); } if (_enemyParent == null) { _enemyParent = ((Component)this).GetComponentInParent<EnemyParent>() ?? ((Component)this).GetComponent<EnemyParent>() ?? ((Component)this).GetComponentInChildren<EnemyParent>(true); } if (_photonView == null) { _photonView = ((Component)this).GetComponent<PhotonView>(); } if (_navAgent == null) { _navAgent = (NavMeshAgent?)(((Component)this).GetComponent<NavMeshAgent>() ?? (((Object)(object)_enemy != (Object)null) ? ((object)FindNearbyComponent<NavMeshAgent>((Component)(object)_enemy)) : ((object)((Component)this).GetComponentInChildren<NavMeshAgent>(true)))); } if (_bodyCollider == null) { _bodyCollider = ((Component)this).GetComponent<Collider>(); } } private static T? FindNearbyComponent<T>(Component component) where T : Component { return component.GetComponent<T>() ?? component.GetComponentInChildren<T>(true) ?? component.GetComponentInParent<T>(true); } private void Update() { //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!_initialized) { return; } if (_hasLastPosition && Time.deltaTime > 0f) { _recentMovementDelta = ((Component)this).transform.position - _lastPosition; _movementSpeed = ((Vector3)(ref _recentMovementDelta)).magnitude / Time.deltaTime; } else { _recentMovementDelta = Vector3.zero; } _lastPosition = ((Component)this).transform.position; _hasLastPosition = true; _stateTimer += Time.deltaTime; _targetRefreshTimer -= Time.deltaTime; if (_killCooldown > 0f) { _killCooldown -= Time.deltaTime; } if (_postAttackCooldownTimer > 0f) { _postAttackCooldownTimer -= Time.deltaTime; } bool flag = (Object)(object)_enemyParent != (Object)null && _enemyParent.Spawned && ((Object)(object)_enemyParent.EnableObject == (Object)null || _enemyParent.EnableObject.activeSelf); if (flag != _spawnedPrevious) { _spawnedPrevious = flag; if (flag) { ResetBehaviour(); } } if (!flag) { ApplyManifestedState(manifested: false, playAppear: false); StopAllAudio(); StopMoving(); return; } if (HasAuthority()) { RunAuthorityLogic(); } else { ResolveSyncedTargetPlayer(); } UpdatePresentation(); } private void ResetBehaviour() { EnsureRuntimeBindings(); _state = GhostGirlState.Hidden; _stateTimer = 0f; _targetRefreshTimer = 0f; _movementAudioTimer = 0f; _heartbeatTimer = 0f; _breathingTimer = 0f; _stepIndex = 0; _walkAnimationActive = false; _hauntTimer = 300f; _currentManifestDuration = Random.Range(2.8f, 5.25f); _targetPlayer = null; _postAttackCooldownTimer = 0f; RepoEnemyAccess.SetTargetPlayerViewId(_enemy, -1); ApplyManifestedState(manifested: false, playAppear: false); StopAllAudio(); StopMoving(); if (_networkInitialized) { BroadcastState(); } } private bool HasAuthority() { return !SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient; } private void RunAuthorityLogic() { if (_targetRefreshTimer <= 0f) { _targetRefreshTimer = 0.7f; AcquireHauntTarget(); } if (IsTargetValid(_targetPlayer)) { _hauntTimer -= Time.deltaTime; if (_hauntTimer <= 0f) { KillHauntedTarget(); return; } } switch (_state) { case GhostGirlState.Hidden: RunHiddenState(); break; case GhostGirlState.Manifesting: RunManifestingState(); break; case GhostGirlState.Stalking: RunStalkingState(); break; case GhostGirlState.Recovering: RunRecoveringState(); break; } } private void RunHiddenState() { ApplyManifestedState(manifested: false, playAppear: false); StopMoving(); if (IsTargetValid(_targetPlayer) && !(_stateTimer < 0.35f) && !(_postAttackCooldownTimer > 0f)) { WarpNearTarget(_targetPlayer, 8f, 14f); TransitionTo(GhostGirlState.Manifesting, manifested: true); } } private void RunStalkingState() { //IL_0069: 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_009b: 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) if (!IsTargetValid(_targetPlayer)) { TransitionTo(GhostGirlState.Hidden, manifested: false); return; } ApplyManifestedState(manifested: true, playAppear: false); if (IsPlayerLookingAtMe(_targetPlayer, 18f, 30f)) { BeginPostAttackCooldown(resetTarget: true); TransitionTo(GhostGirlState.Recovering, manifested: false); return; } MoveTowards(((Component)_targetPlayer).transform.position, 4.2f); FaceTowards(((Component)_targetPlayer).transform.position, 10f); float num = Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position); if (num <= 1.15f) { if (Random.value <= 0.22f) { KillHauntedTarget(); return; } TriggerGhostThrow(_targetPlayer); BeginPostAttackCooldown(resetTarget: true); TransitionTo(GhostGirlState.Recovering, manifested: false); } else if (_stateTimer >= 10f) { BeginPostAttackCooldown(resetTarget: true); TransitionTo(GhostGirlState.Recovering, manifested: false); } } private void RunManifestingState() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!IsTargetValid(_targetPlayer)) { TransitionTo(GhostGirlState.Hidden, manifested: false); return; } ApplyManifestedState(manifested: true, playAppear: false); StopMoving(); FaceTowards(((Component)_targetPlayer).transform.position, 10f); if (IsAnyPlayerTooClose(2.15f)) { TransitionTo(GhostGirlState.Recovering, manifested: false); } else if (_stateTimer >= _currentManifestDuration) { bool flag = Random.value <= 0.32f && !IsPlayerLookingAtMe(_targetPlayer, 20f, 28f); TransitionTo(flag ? GhostGirlState.Stalking : GhostGirlState.Recovering, flag); } } private void RunRecoveringState() { ApplyManifestedState(manifested: false, playAppear: false); StopMoving(); if (_stateTimer >= 4.25f) { TransitionTo(GhostGirlState.Hidden, manifested: false); } } private void TransitionTo(GhostGirlState newState, bool manifested) { bool flag = _state != newState; bool flag2 = _manifested != manifested; if (flag || flag2) { _state = newState; _stateTimer = 0f; if (newState == GhostGirlState.Manifesting) { _currentManifestDuration = Random.Range(2.8f, 5.25f); } ApplyManifestedState(manifested, manifested && !_manifested); ApplyStateAnimation(); BroadcastState(); } } private void BroadcastState() { if (SemiFunc.IsMultiplayer()) { _photonView.RPC("SyncStateRpc", (RpcTarget)1, new object[2] { (int)_state, _manifested }); } } [PunRPC] private void SyncStateRpc(int state, bool manifested, PhotonMessageInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { _state = (GhostGirlState)state; _stateTimer = 0f; ApplyManifestedState(manifested, manifested && !_manifested); ApplyStateAnimation(); } } private void ApplyManifestedState(bool manifested, bool playAppear) { bool flag = _manifested != manifested; if (!manifested) { _walkAnimationActive = false; } if ((Object)(object)VisualRoot != (Object)null) { ((Component)VisualRoot).gameObject.SetActive(manifested); } if ((Object)(object)_bodyCollider != (Object)null) { _bodyCollider.enabled = manifested; } if (_animatorHasWalkBool && (Object)(object)VisualAnimator != (Object)null) { if (!manifested) { VisualAnimator.SetBool("Walk", false); } else if (flag) { VisualAnimator.SetBool("Walk", false); PlayAnimatorIdle(forceRestart: true); } } if (!manifested) { StopMoving(); StopMovementAudio(); StopHeartbeatAudio(); } else if (playAppear) { PlayAppearCue(); } _manifested = manifested; } private void ApplyStateAnimation() { if ((Object)(object)VisualAnimator == (Object)null) { return; } if (_state == GhostGirlState.Manifesting) { if (_animatorHasWalkBool) { VisualAnimator.SetBool("Walk", false); } _walkAnimationActive = false; PlayAnimatorIdle(forceRestart: true); } else if (_state == GhostGirlState.Stalking) { PlayAnimatorWalk(forceRestart: true); } } private void UpdatePresentation() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) bool flag = _manifested && _state == GhostGirlState.Stalking; if (_animatorHasWalkBool && (Object)(object)VisualAnimator != (Object)null) { VisualAnimator.SetBool("Walk", flag); } UpdateWalkAnimationPlayback(flag); if (!HasAuthority() && IsTargetValid(_targetPlayer) && (_state == GhostGirlState.Stalking || _state == GhostGirlState.Manifesting)) { FaceTowards(((Component)_targetPlayer).transform.position, 9f); } UpdateMovementAudio(flag && _movementSpeed > 0.08f); UpdateHeartbeatAudio(); UpdateBreathingAudio(); } private void UpdateWalkAnimationPlayback(bool moving) { if (!((Object)(object)VisualAnimator == (Object)null) && moving != _walkAnimationActive) { _walkAnimationActive = moving; if (moving) { PlayAnimatorWalk(forceRestart: true); } else { PlayAnimatorIdle(forceRestart: true); } } } private void PlayAnimatorWalk(bool forceRestart) { if (!((Object)(object)VisualAnimator == (Object)null) && _animatorHasWalkState) { if (_animatorHasWalkBool) { VisualAnimator.SetBool("Walk", true); } if (forceRestart) { VisualAnimator.CrossFadeInFixedTime("Base Layer.Walk", 0.04f, 0, 0f); } } } private void PlayAnimatorIdle(bool forceRestart) { if (!((Object)(object)VisualAnimator == (Object)null) && _animatorHasIdleStareState) { if (_animatorHasWalkBool) { VisualAnimator.SetBool("Walk", false); } if (forceRestart) { VisualAnimator.CrossFadeInFixedTime("Base Layer.IdleStare", 0.04f, 0, 0f); } } } private void UpdateMovementAudio(bool moving) { if (!moving || (Object)(object)MovementSource == (Object)null || StepClips.Length == 0) { StopMovementAudio(); return; } _movementAudioTimer -= Time.deltaTime; float movementAudioTimer = 0.48f; if (!(_movementAudioTimer > 0f)) { AudioClip val = StepClips[_stepIndex % StepClips.Length]; if ((Object)(object)val != (Object)null) { MovementSource.pitch = Random.Range(0.92f, 1.02f); MovementSource.PlayOneShot(val); } _stepIndex++; _movementAudioTimer = movementAudioTimer; } } private void UpdateHeartbeatAudio() { if (!_manifested || (Object)(object)HeartbeatSource == (Object)null || HeartbeatClips.Length == 0) { StopHeartbeatAudio(); return; } _heartbeatTimer -= Time.deltaTime; if (!(_heartbeatTimer > 0f)) { float num = ((_state == GhostGirlState.Manifesting) ? 0.7f : 1.05f); float num2 = ((_state == GhostGirlState.Manifesting) ? 1.05f : 1.45f); HeartbeatSource.pitch = 1f; HeartbeatSource.PlayOneShot(HeartbeatClips[Random.Range(0, HeartbeatClips.Length)]); _heartbeatTimer = Random.Range(num, num2); } } private void UpdateBreathingAudio() { if (_manifested && !((Object)(object)VoiceSource == (Object)null) && !((Object)(object)BreathingClip == (Object)null)) { _breathingTimer -= Time.deltaTime; if (!(_breathingTimer > 0f) && _state == GhostGirlState.Manifesting) { VoiceSource.pitch = 1f; VoiceSource.PlayOneShot(BreathingClip); _breathingTimer = 5.4f; } } } private void PlayAppearCue() { if (!((Object)(object)VoiceSource == (Object)null) && AppearClips.Length != 0) { VoiceSource.pitch = Random.Range(0.98f, 1.05f); VoiceSource.PlayOneShot(AppearClips[Random.Range(0, AppearClips.Length)]); } } private void StopMovementAudio() { AudioSource movementSource = MovementSource; if (movementSource != null) { movementSource.Stop(); } _movementAudioTimer = 0f; } private void StopHeartbeatAudio() { AudioSource heartbeatSource = HeartbeatSource; if (heartbeatSource != null) { heartbeatSource.Stop(); } _heartbeatTimer = 0f; } private void StopAllAudio() { AudioSource voiceSource = VoiceSource; if (voiceSource != null) { voiceSource.Stop(); } AudioSource movementSource = MovementSource; if (movementSource != null) { movementSource.Stop(); } AudioSource heartbeatSource = HeartbeatSource; if (heartbeatSource != null) { heartbeatSource.Stop(); } _movementAudioTimer = 0f; _heartbeatTimer = 0f; _breathingTimer = 0f; } private void AcquireHauntTarget() { if ((Object)(object)GameDirector.instance == (Object)null) { _targetPlayer = null; RepoEnemyAccess.SetTargetPlayerViewId(_enemy, -1); return; } if (IsTargetValid(_targetPlayer)) { RepoEnemyAccess.SetTargetPlayerViewId(_enemy, _targetPlayer.photonView.ViewID); return; } List<PlayerAvatar> list = new List<PlayerAvatar>(); foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (IsTargetValid(player)) { list.Add(player); } } _targetPlayer = ((list.Count > 0) ? list[Random.Range(0, list.Count)] : null); _hauntTimer = 300f; RepoEnemyAccess.SetTargetPlayerViewId(_enemy, ((Object)(object)_targetPlayer != (Object)null) ? _targetPlayer.photonView.ViewID : (-1)); } private void ResolveSyncedTargetPlayer() { if ((Object)(object)GameDirector.instance == (Object)null) { _targetPlayer = null; return; } int targetPlayerViewID = _enemy.TargetPlayerViewID; if (targetPlayerViewID <= 0) { _targetPlayer = null; } else { if ((Object)(object)_targetPlayer != (Object)null && (Object)(object)_targetPlayer.photonView != (Object)null && _targetPlayer.photonView.ViewID == targetPlayerViewID && IsTargetValid(_targetPlayer)) { return; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player.photonView != (Object)null && player.photonView.ViewID == targetPlayerViewID) { _targetPlayer = player; return; } } _targetPlayer = null; } } private bool IsAnyPlayerTooClose(float maxDistance) { //IL_004a: 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) if ((Object)(object)GameDirector.instance == (Object)null) { return false; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!IsTargetValid(player) || !(Vector3.Distance(CenterTransform.position, ((Component)player).transform.position) <= maxDistance)) { continue; } return true; } return false; } private void MoveTowards(Vector3 targetPosition, float speed) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_navAgent == (Object)null) { return; } try { if (!((Behaviour)_navAgent).enabled || !_navAgent.isOnNavMesh) { NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(((Component)this).transform.position, ref val, 6f, -1)) { return; } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)_navAgent).enabled = true; if (_navAgent.isOnNavMesh) { _navAgent.Warp(((NavMeshHit)(ref val)).position); } } _navAgent.speed = speed; _navAgent.acceleration = Mathf.Max(28f, speed * 8f); _navAgent.isStopped = false; _navAgent.SetDestination(targetPosition); Vector3 desiredVelocity = _navAgent.desiredVelocity; if (((Vector3)(ref desiredVelocity)).sqrMagnitude > 0.01f) { FaceAlongDirection(desiredVelocity, 14f); } else { FaceTowards(targetPosition, 10f); } } catch { StopMoving(); } } private void StopMoving() { if ((Object)(object)_navAgent != (Object)null && ((Behaviour)_navAgent).enabled && _navAgent.isOnNavMesh) { _navAgent.isStopped = true; _navAgent.ResetPath(); } } private Vector3 GetStalkPointAroundTarget(PlayerAvatar target, float minDistance, float maxDistance) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0032: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00b8: 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_00e3: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)target).transform; Vector3 val = transform.forward; Vector3 val2; if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f)) { val2 = Vector3.forward; } else { val = transform.forward; val2 = ((Vector3)(ref val)).normalized; } Vector3 val3 = val2; val = transform.right; Vector3 val4; if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f)) { val4 = Vector3.right; } else { val = transform.right; val4 = ((Vector3)(ref val)).normalized; } Vector3 val5 = val4; NavMeshHit val7 = default(NavMeshHit); for (int i = 0; i < 10; i++) { float num = Random.Range(minDistance, maxDistance); float num2 = Random.Range(-2.4f, 2.4f); Vector3 val6 = transform.position - val3 * num + val5 * num2; if (NavMesh.SamplePosition(val6, ref val7, 5f, -1)) { return ((NavMeshHit)(ref val7)).position; } } return ((Component)this).transform.position; } private void WarpNearTarget(PlayerAvatar target, float minDistance, float maxDistance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0039: 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_00a0: Unknown result type (might be due to invalid IL or missing references) Vector3 stalkPointAroundTarget = GetStalkPointAroundTarget(target, minDistance, maxDistance); if ((Object)(object)((Component)this).transform.parent != (Object)null) { ((Component)this).transform.parent.position = stalkPointAroundTarget; ((Component)this).transform.localPosition = Vector3.zero; } else { ((Component)this).transform.position = stalkPointAroundTarget; } if ((Object)(object)_navAgent != (Object)null) { if (!((Behaviour)_navAgent).enabled) { ((Behaviour)_navAgent).enabled = true; } if (_navAgent.isOnNavMesh) { _navAgent.Warp(stalkPointAroundTarget); } } FaceTowards(((Component)target).transform.position, 100f); } private void FaceAlongDirection(Vector3 worldDirection, float turnSpeed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) 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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) 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 bool IsPlayerLookingAtMe(PlayerAvatar player, float maxAngle, float maxDistance) { //IL_0072: 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_0077: 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_007f: 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_00a9: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.P