using System; 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 Dissonance; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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-CSharp")] [assembly: AssemblyCompany("Angels of Delusion")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Angels of Delusion")] [assembly: AssemblyTitle("Angels of Delusion")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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; } } } namespace ModelReplacement { public class MRSUNNAALT : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset("SunnaAlt"); } protected override void AddModelScripts() { Transform val = FaceSyncHelper.FindDeepChild(base.replacementModel.transform, "Body"); SkinnedMeshRenderer faceMesh = default(SkinnedMeshRenderer); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref faceMesh)) { FaceSync faceSync = ((Component)val).gameObject.AddComponent(); faceSync.player = ((BodyReplacementBase)this).controller; faceSync.faceMesh = faceMesh; faceSync.mouthShapeName = "Ah"; faceSync.blinkShapeName = "Blink"; faceSync.povDropAmount = 0.21f; faceSync.init(); } } } public class MRSUNNA : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset("Sunna"); } protected override void AddModelScripts() { Transform val = FaceSyncHelper.FindDeepChild(base.replacementModel.transform, "Body"); SkinnedMeshRenderer faceMesh = default(SkinnedMeshRenderer); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref faceMesh)) { FaceSync faceSync = ((Component)val).gameObject.AddComponent(); faceSync.player = ((BodyReplacementBase)this).controller; faceSync.faceMesh = faceMesh; faceSync.mouthShapeName = "あ"; faceSync.blinkShapeName = "まばたき"; faceSync.povDropAmount = 0.21f; faceSync.init(); } } } public class MRNANGONGALT : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset("NangongAlt"); } protected override void AddModelScripts() { Transform val = FaceSyncHelper.FindDeepChild(base.replacementModel.transform, "Body"); SkinnedMeshRenderer faceMesh = default(SkinnedMeshRenderer); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref faceMesh)) { FaceSync faceSync = ((Component)val).gameObject.AddComponent(); faceSync.player = ((BodyReplacementBase)this).controller; faceSync.faceMesh = faceMesh; faceSync.mouthShapeName = "Ah"; faceSync.blinkShapeName = "Blink"; faceSync.povDropAmount = 0.2f; faceSync.init(); } } } public class MRARIA : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset("Aria"); } protected override void AddModelScripts() { Transform val = FaceSyncHelper.FindDeepChild(base.replacementModel.transform, "Body"); SkinnedMeshRenderer faceMesh = default(SkinnedMeshRenderer); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref faceMesh)) { FaceSync faceSync = ((Component)val).gameObject.AddComponent(); faceSync.player = ((BodyReplacementBase)this).controller; faceSync.faceMesh = faceMesh; faceSync.mouthShapeName = "Ah"; faceSync.blinkShapeName = "Blink"; faceSync.povDropAmount = 0.3f; faceSync.init(); } } } public class MRARIAALT : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset("AriaAlt"); } protected override void AddModelScripts() { Transform val = FaceSyncHelper.FindDeepChild(base.replacementModel.transform, "Body"); SkinnedMeshRenderer faceMesh = default(SkinnedMeshRenderer); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref faceMesh)) { FaceSync faceSync = ((Component)val).gameObject.AddComponent(); faceSync.player = ((BodyReplacementBase)this).controller; faceSync.faceMesh = faceMesh; faceSync.mouthShapeName = "Ah"; faceSync.blinkShapeName = "Blink"; faceSync.povDropAmount = 0.3f; faceSync.init(); } } } public class MRNANGONG : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset("Nangong"); } protected override void AddModelScripts() { Transform val = FaceSyncHelper.FindDeepChild(base.replacementModel.transform, "Body"); SkinnedMeshRenderer faceMesh = default(SkinnedMeshRenderer); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref faceMesh)) { FaceSync faceSync = ((Component)val).gameObject.AddComponent(); faceSync.player = ((BodyReplacementBase)this).controller; faceSync.faceMesh = faceMesh; faceSync.mouthShapeName = "Ah"; faceSync.blinkShapeName = "Blink"; faceSync.povDropAmount = 0.2f; faceSync.init(); } } } public class MRARIAROB : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset("AriaRob"); } protected override void AddModelScripts() { Transform val = FaceSyncHelper.FindDeepChild(base.replacementModel.transform, "Body"); SkinnedMeshRenderer faceMesh = default(SkinnedMeshRenderer); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref faceMesh)) { FaceSync faceSync = ((Component)val).gameObject.AddComponent(); faceSync.player = ((BodyReplacementBase)this).controller; faceSync.faceMesh = faceMesh; faceSync.mouthShapeName = "Ah"; faceSync.isRobot = true; faceSync.robotMaterialIndex = 1; faceSync.eyesClosedTex = Assets.MainAssetBundle.LoadAsset("Angry2"); faceSync.eyesOpenTex = Assets.MainAssetBundle.LoadAsset("ariaeyes"); faceSync.povDropAmount = 0.3f; faceSync.init(); } } } public class MRARIAROBALT : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { return Assets.MainAssetBundle.LoadAsset("AriaRobAlt"); } protected override void AddModelScripts() { Transform val = FaceSyncHelper.FindDeepChild(base.replacementModel.transform, "Body"); SkinnedMeshRenderer faceMesh = default(SkinnedMeshRenderer); if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent(ref faceMesh)) { FaceSync faceSync = ((Component)val).gameObject.AddComponent(); faceSync.player = ((BodyReplacementBase)this).controller; faceSync.faceMesh = faceMesh; faceSync.mouthShapeName = "Ah"; faceSync.isRobot = true; faceSync.robotMaterialIndex = 1; faceSync.eyesClosedTex = Assets.MainAssetBundle.LoadAsset("Angry2"); faceSync.eyesOpenTex = Assets.MainAssetBundle.LoadAsset("ariaeyes"); faceSync.povDropAmount = 0.3f; faceSync.init(); } } } public static class FaceSyncHelper { public static Transform FindDeepChild(Transform aParent, string aName) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown Queue queue = new Queue(); queue.Enqueue(aParent); while (queue.Count > 0) { Transform val = queue.Dequeue(); if (((Object)val).name == aName) { return val; } foreach (Transform item2 in val) { Transform item = item2; queue.Enqueue(item); } } return null; } } public class FaceSync : MonoBehaviour { public PlayerControllerB player; public SkinnedMeshRenderer faceMesh; public float povDropAmount = 0f; public static float currentCameraDrop; [Header("Human Settings")] public string mouthShapeName = ""; public string blinkShapeName = ""; private int mouthIndex = -1; private int blinkIndex = -1; [Header("Robot Settings")] public bool isRobot = false; public int robotMaterialIndex = 0; public Texture2D eyesClosedTex; public Texture2D eyesOpenTex; private Material faceMaterial; [Header("Voice Settings")] public float voiceSensitivity = 1500f; protected VoicePlayerState voice; [Header("Blink Settings")] private int blinkState = 0; private float currentBlinkWeight = 0f; public float blinkSpeed = 800f; private float blinkTimer = 0f; private float nextBlinkTime = 3f; private void Start() { if ((Object)(object)faceMesh != (Object)null) { if (!string.IsNullOrEmpty(mouthShapeName)) { mouthIndex = faceMesh.sharedMesh.GetBlendShapeIndex(mouthShapeName); } if (!string.IsNullOrEmpty(blinkShapeName)) { blinkIndex = faceMesh.sharedMesh.GetBlendShapeIndex(blinkShapeName); } if (isRobot && ((Renderer)faceMesh).materials.Length > robotMaterialIndex) { faceMaterial = ((Renderer)faceMesh).materials[robotMaterialIndex]; } } } private void OnEnable() { if ((Object)(object)player != (Object)null && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)player == (Object)(object)StartOfRound.Instance.localPlayerController) { currentCameraDrop = povDropAmount; } } private void OnDisable() { if ((Object)(object)player != (Object)null && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)player == (Object)(object)StartOfRound.Instance.localPlayerController) { currentCameraDrop = 0f; } } private void Update() { if ((Object)(object)faceMesh == (Object)null) { return; } if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.voiceChatModule != (Object)null && mouthIndex != -1) { if (voice == null) { init(); } else { float num = 0f; if (voice.IsSpeaking && (Object)(object)player != (Object)null && !player.isPlayerDead) { num = Mathf.Clamp(voice.Amplitude * voiceSensitivity, 0f, 100f); } faceMesh.SetBlendShapeWeight(mouthIndex, num); } } if (!((Object)(object)player != (Object)null) || player.isPlayerDead) { return; } if (isRobot) { blinkTimer += Time.deltaTime; if (blinkState == 0 && blinkTimer >= nextBlinkTime) { blinkState = 1; blinkTimer = 0f; if ((Object)(object)faceMaterial != (Object)null && (Object)(object)eyesClosedTex != (Object)null) { faceMaterial.SetTexture("_BaseColorMap", (Texture)(object)eyesClosedTex); faceMaterial.SetTexture("_MainTex", (Texture)(object)eyesClosedTex); } } else if (blinkState == 1 && blinkTimer >= 0.15f) { blinkState = 0; blinkTimer = 0f; nextBlinkTime = Random.Range(2.5f, 6.5f); if ((Object)(object)faceMaterial != (Object)null && (Object)(object)eyesOpenTex != (Object)null) { faceMaterial.SetTexture("_BaseColorMap", (Texture)(object)eyesOpenTex); faceMaterial.SetTexture("_MainTex", (Texture)(object)eyesOpenTex); } } } else { if (blinkIndex == -1) { return; } if (blinkState == 0) { blinkTimer += Time.deltaTime; if (blinkTimer >= nextBlinkTime) { blinkState = 1; blinkTimer = 0f; nextBlinkTime = Random.Range(2.5f, 6.5f); } } else if (blinkState == 1) { currentBlinkWeight += blinkSpeed * Time.deltaTime; if (currentBlinkWeight >= 100f) { currentBlinkWeight = 100f; blinkState = 2; } faceMesh.SetBlendShapeWeight(blinkIndex, currentBlinkWeight); } else if (blinkState == 2) { currentBlinkWeight -= blinkSpeed * Time.deltaTime; if (currentBlinkWeight <= 0f) { currentBlinkWeight = 0f; blinkState = 0; } faceMesh.SetBlendShapeWeight(blinkIndex, currentBlinkWeight); } } } public void init() { if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects(); if ((Object)(object)player != (Object)null) { voice = player.voicePlayerState; if (voice == null && (Object)(object)player == (Object)(object)StartOfRound.Instance.localPlayerController) { voice = StartOfRound.Instance.voiceChatModule.FindPlayer(StartOfRound.Instance.voiceChatModule.LocalPlayerName); } } } } [BepInPlugin("com.red88.AOD", "Angels of Delusion", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown Assets.PopulateAssets(); ModelReplacementAPI.RegisterSuitModelReplacement("Sunna", typeof(MRSUNNA)); ModelReplacementAPI.RegisterSuitModelReplacement("Sunna-Afternoon_Tea_Break", typeof(MRSUNNAALT)); ModelReplacementAPI.RegisterSuitModelReplacement("Nangong_Yu", typeof(MRNANGONG)); ModelReplacementAPI.RegisterSuitModelReplacement("Nangong_Yu-Rhapsody's_Muse", typeof(MRNANGONGALT)); ModelReplacementAPI.RegisterSuitModelReplacement("Aria", typeof(MRARIA)); ModelReplacementAPI.RegisterSuitModelReplacement("Aria-Discordant_Note", typeof(MRARIAALT)); ModelReplacementAPI.RegisterSuitModelReplacement("Aria_Robot", typeof(MRARIAROB)); ModelReplacementAPI.RegisterSuitModelReplacement("Aria_Robot-Discordant_Note", typeof(MRARIAROBALT)); Harmony val = new Harmony("com.red88.AOD"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.red88.AOD is loaded and suits are mapped!"); } } public static class Assets { public static string mainAssetBundleName = "angelsofdelusion"; public static AssetBundle MainAssetBundle = null; public static void PopulateAssets() { if (!((Object)(object)MainAssetBundle == (Object)null)) { return; } string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); string text = ""; string[] array = manifestResourceNames; foreach (string text2 in array) { if (text2.EndsWith(mainAssetBundleName)) { text = text2; break; } } if (string.IsNullOrEmpty(text)) { Debug.LogError((object)("[FATAL ERROR] Could not find " + mainAssetBundleName + " baked inside the .dll!")); return; } using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text)) { MainAssetBundle = AssetBundle.LoadFromStream(stream); } if ((Object)(object)MainAssetBundle == (Object)null) { Debug.LogError((object)"[FATAL ERROR] Found the embedded file, but Unity failed to read it."); } } } [HarmonyPatch(typeof(PlayerControllerB))] public class CameraFixPatch { [HarmonyPatch("Update")] [HarmonyPostfix] public static void LowerCameraUpdate(PlayerControllerB __instance) { ApplyCameraDrop(__instance); } [HarmonyPatch("LateUpdate")] [HarmonyPostfix] public static void LowerCameraLateUpdate(PlayerControllerB __instance) { ApplyCameraDrop(__instance); } private static void ApplyCameraDrop(PlayerControllerB __instance) { //IL_00c9: 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) if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController || __instance.isPlayerDead || (Object)(object)__instance.gameplayCamera == (Object)null || FaceSync.currentCameraDrop == 0f) { return; } if (__instance.inTerminalMenu || __instance.inSpecialInteractAnimation) { ((Component)__instance.gameplayCamera).transform.localPosition = Vector3.zero; if ((Object)(object)__instance.localVisor != (Object)null) { ((Component)__instance.localVisor).gameObject.SetActive(true); } } else { ((Component)__instance.gameplayCamera).transform.localPosition = new Vector3(0f, 0f - FaceSync.currentCameraDrop, 0f); if ((Object)(object)__instance.localVisor != (Object)null) { ((Component)__instance.localVisor).gameObject.SetActive(false); } } } } [DefaultExecutionOrder(-1)] public class ArmOffset : MonoBehaviour { private GameObject armOffset; internal PlayerControllerB playerControllerB; private void LateUpdate() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)playerControllerB == (Object)null) { return; } if ((Object)(object)armOffset == (Object)null) { armOffset = new GameObject("LocalArmOffset"); } armOffset.transform.parent = playerControllerB.localArmsTransform.parent; Vector3 val = armOffset.transform.parent.localPosition; if (((Component)playerControllerB.gameplayCamera).transform.localPosition != Vector3.zero && !playerControllerB.inTerminalMenu && !playerControllerB.inSpecialInteractAnimation) { float y = ((Component)playerControllerB.gameplayCamera).transform.localPosition.y; if (y == 0f - FaceSync.currentCameraDrop && FaceSync.currentCameraDrop != 0f) { val += new Vector3(0f, y, 0f); } } if (armOffset.transform.parent.localPosition != val) { armOffset.transform.parent.localPosition = val; } } } [HarmonyPatch(typeof(StartOfRound))] public class ModelHeightOffset : MonoBehaviour { private PlayerControllerB localPlayer; private ArmOffset modelArmOffset; [HarmonyPatch("Awake")] [HarmonyPostfix] private static void PostFix(ref StartOfRound __instance) { ((Component)__instance).gameObject.AddComponent(); } private void Start() { if ((Object)(object)modelArmOffset == (Object)null) { modelArmOffset = ((Component)this).gameObject.AddComponent(); } } private void Update() { if ((Object)(object)localPlayer == (Object)null) { localPlayer = StartOfRound.Instance.localPlayerController; modelArmOffset.playerControllerB = localPlayer; } } private void OnDisable() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)localPlayer != (Object)null) { ((Component)localPlayer.gameplayCamera).transform.localPosition = Vector3.zero; } } } [HarmonyPatch] public class InteractionFixPatch { [HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")] [HarmonyPrefix] public static void LowerCameraForInteraction(PlayerControllerB __instance) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)StartOfRound.Instance == (Object)null) && !((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController) && FaceSync.currentCameraDrop != 0f) { ((Component)__instance.gameplayCamera).transform.localPosition = new Vector3(0f, 0f - FaceSync.currentCameraDrop, 0f); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }