using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using ChineseBrideAudioReplace.Patches;
using ChineseBrideModelReplace.Patches;
using EveryoneCanSeeGirl.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using MAIN;
using NewYearAudioReplace.Patches;
using NewYearModelReplace.Patches;
using Unity.Netcode;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MAIN
{
[BepInPlugin("TShine.ChineseBrideAndNewYearGhostgirl", "ChineseBride And NewYear Ghostgirl", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "TShine.ChineseBrideAndNewYearGhostgirl";
private const string modName = "ChineseBride And NewYear Ghostgirl";
private const string modVersion = "1.0.0";
private static ConfigEntry<bool> enableNewYearAudioReplace;
private static ConfigEntry<bool> enableNewYearModelReplace;
private static ConfigEntry<string> enableChineseModelReplace;
private static ConfigEntry<bool> enableChineseAudioReplace;
private static ConfigEntry<bool> MeMeAudioReplace;
private static ConfigEntry<bool> EveryoneCanSee;
private readonly Harmony harmony = new Harmony("TShine.ChineseBrideAndNewYearGhostgirl");
public static Plugin Instance;
internal static AssetBundle MyPrefabBundle;
public static GameObject NYModelPrefab;
public static GameObject ChineseModelPrefab1;
public static GameObject ChineseModelPrefab2;
public static Material NewYearGirlMaterial;
public static Material ChineseGirlMaterial1;
public static Material ChineseGirlMaterial2;
public static AudioClip NewYearbreathingAudio;
public static AudioClip NewYearheartbeatMusicAudio;
public static AudioClip Girlclip1;
public static AudioClip Girlclip2;
public static AudioClip Girlclip3;
public static AudioClip Girlclip4;
public static AudioClip Girlclip5;
public static AudioClip Girlclip6;
public static AudioClip Girlclip7;
public static AudioClip Girlclip8;
public static AudioClip Girlclip9;
public static AudioClip PlayerDie;
public static AudioClip MeMeAudio;
public static AudioClip ChineseGirlclipP1;
public static AudioClip ChineseGirlclipP2;
public static AudioClip ChineseGirlclipP3;
public static AudioClip ChineseGirlclipB1;
public static AudioClip ChineseGirlclipB2;
public static AudioClip ChineseGirlclipB3;
public static AudioClip ChineseGirlclipH1;
public static AudioClip ChineseGirlclipH2;
public static AudioClip ChineseGirlclipH3;
public static AudioClip ChineseGirlclipH4;
public static AudioClip ChineseGirlclipL1;
public static AudioClip ChineseGirlclipL2;
public static AudioClip ChineseGirlclipL3;
public static AudioClip ChineseGirlclipL4;
public static AudioClip ChineseGirlclipL5;
public static AudioClip ChineseGirlclipbreath;
public static AudioClip[] ChineseheartbeatMusicClips;
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)this);
}
else
{
Instance = this;
}
Debug.Log((object)"ChineseBride And NewYear Ghostgirl Mod loaded 小女孩来喽~~~");
string text = ((BaseUnityPlugin)Instance).Info.Location.TrimEnd("TShine.ChineseBride And NewYear Ghostgirl.dll".ToCharArray());
MyPrefabBundle = AssetBundle.LoadFromFile(text + "ghostgirl");
if ((Object)(object)MyPrefabBundle != (Object)null)
{
NYModelPrefab = MyPrefabBundle.LoadAsset<GameObject>("Assets/GhostGirl/NY.prefab");
ChineseModelPrefab1 = MyPrefabBundle.LoadAsset<GameObject>("Assets/GhostGirl/dress.prefab");
ChineseModelPrefab2 = MyPrefabBundle.LoadAsset<GameObject>("Assets/GhostGirl/nodress.prefab");
NewYearGirlMaterial = MyPrefabBundle.LoadAsset<Material>("Assets/GhostGirl/Materials/NY.mat");
ChineseGirlMaterial1 = MyPrefabBundle.LoadAsset<Material>("Assets/GhostGirl/Materials/dress.mat");
ChineseGirlMaterial2 = MyPrefabBundle.LoadAsset<Material>("Assets/GhostGirl/Materials/nodress.mat");
NewYearbreathingAudio = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/NY.wav");
Girlclip1 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/BP.wav");
Girlclip2 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/laugh1.wav");
Girlclip3 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/laugh2.wav");
Girlclip4 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/laugh3.wav");
Girlclip5 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/laugh4.wav");
Girlclip6 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/money1.wav");
Girlclip7 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/money2.wav");
Girlclip8 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/money3.wav");
Girlclip9 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/money4.wav");
PlayerDie = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/die.wav");
MeMeAudio = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/facai.wav");
NewYearheartbeatMusicAudio = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/BP2.wav");
ChineseGirlclipP1 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/P1.wav");
ChineseGirlclipP2 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/P2.wav");
ChineseGirlclipP3 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/P3.wav");
ChineseGirlclipB1 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/B1.wav");
ChineseGirlclipB2 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/B2.wav");
ChineseGirlclipB3 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/B3.wav");
ChineseGirlclipH1 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/H1.wav");
ChineseGirlclipH2 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/H2.wav");
ChineseGirlclipH3 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/H3.wav");
ChineseGirlclipH4 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/H4.wav");
ChineseGirlclipL1 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/L1.wav");
ChineseGirlclipL2 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/L2.wav");
ChineseGirlclipL3 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/L3.wav");
ChineseGirlclipL4 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/L4.wav");
ChineseGirlclipL5 = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/L5.wav");
ChineseGirlclipbreath = MyPrefabBundle.LoadAsset<AudioClip>("Assets/GhostGirl/breath.wav");
ChineseheartbeatMusicClips = (AudioClip[])(object)new AudioClip[5] { ChineseGirlclipL1, ChineseGirlclipL2, ChineseGirlclipL3, ChineseGirlclipL4, ChineseGirlclipL5 };
Debug.Log((object)"Asset bundle loaded");
}
else
{
Debug.LogError((object)"Asset bundle not loaded!");
}
EveryoneCanSee = ((BaseUnityPlugin)this).Config.Bind<bool>("可见性/Visibility", "EnableAudioReplace", false, "设置为true的时候,所有人都能看到小女孩\n注意:开启此功能会有非常奇怪的模型渲染逻辑,包括无动作,显示逻辑,不同步等问题。\nIf set to true,everyone can see the girl.\nNote:Enabling this feature will make very strange model rendering logic, including issues such as no action, display logic error, and out of sync.");
MeMeAudioReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("刘德华《恭喜发财》/MeMeAudio", "MeMeAudioReplace", false, "设置为true将会把小女孩的音乐由《红包拿来》改为为刘德华的《恭喜发财》\n注意:当音频替换为false但该选项设置为true时,可以替换为恭喜发财的音乐。当音频替换和该选项都设置为true时,音频也将替换为《恭喜发财》\nSet to true will change the girl's music from \"Give me the red envelope\" to Andy Lau's \"Wishing you prosperity\"\nNote: When enableAudioReplace is false but enableMeMeReplaceset is true, it can be replaced with music from \"Wishing you prosperity\". \nWhen both of them set to true, the audio will also be replaced with \"Wishing you prosperity\"");
enableNewYearAudioReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("新年音频/NewYearAudio", "EnableNewYearAudioReplace", false, "true为开启新年音频替换/Set to true to enable the NewYear audio replacement.");
enableNewYearModelReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("新年模型/NewYearModel", "EnableNewYearModelReplace", false, "true为开启小女孩新年模型替换/Set to true to enable the NewYear DressGirl Model replacement");
enableChineseAudioReplace = ((BaseUnityPlugin)this).Config.Bind<bool>("国风新娘音频/ChineseBrideAudio", "EnableChineseBrideAudioReplace", true, "true为开启小女孩国风新娘音频替换/Set to true to enable the ChineseBride audio replacement.");
enableChineseModelReplace = ((BaseUnityPlugin)this).Config.Bind<string>("国风新娘模型/ChineseBrideModel", "EnableChineseBrideModelReplace", "dress", "dress为开启小女孩国风新娘模型替换,none为关闭,nodress为去掉裙子。 /Set to \"dress\" to enable the ChineseBride DressGirl Model replacement.\"None\" is closed, and \"nodress\" is removing the skirt.");
if (enableNewYearModelReplace.Value)
{
harmony.PatchAll(typeof(DressGirlNewYearModelPatch));
}
if (enableChineseModelReplace.Value.Equals("dress", StringComparison.OrdinalIgnoreCase))
{
harmony.PatchAll(typeof(DressGirlChineseModelPatch));
}
else if (enableChineseModelReplace.Value.Equals("nodress", StringComparison.OrdinalIgnoreCase))
{
harmony.PatchAll(typeof(DressGirlChineseModelPatch2));
}
else if (!enableChineseModelReplace.Value.Equals("none", StringComparison.OrdinalIgnoreCase))
{
}
if (enableChineseAudioReplace.Value)
{
harmony.PatchAll(typeof(ChineseBrideAudioPatch));
harmony.PatchAll(typeof(ChineseBreathingSFXPatch));
harmony.PatchAll(typeof(ChinesePlayerDieAudioPatch));
}
if (EveryoneCanSee.Value)
{
harmony.PatchAll(typeof(EveryoneCanSeeGirlPatch));
harmony.PatchAll(typeof(EveryoneCanSeeGirlPatch2));
}
if (enableNewYearAudioReplace.Value && !MeMeAudioReplace.Value)
{
harmony.PatchAll(typeof(BreathingSFXPatch));
harmony.PatchAll(typeof(AppearStaringSFXPatch));
harmony.PatchAll(typeof(PlayerDieAudioPatch));
}
if (!enableNewYearAudioReplace.Value && MeMeAudioReplace.Value)
{
harmony.PatchAll(typeof(BreathingSFXPatch2));
}
if (enableNewYearAudioReplace.Value && MeMeAudioReplace.Value)
{
harmony.PatchAll(typeof(BreathingSFXPatch2));
harmony.PatchAll(typeof(AppearStaringSFXPatch));
harmony.PatchAll(typeof(PlayerDieAudioPatch));
}
((BaseUnityPlugin)this).Logger.LogInfo((object)$"New Year Model Replace Mod: Enabled = {enableNewYearModelReplace.Value}");
((BaseUnityPlugin)this).Logger.LogInfo((object)$"New Year Audio Replace Mod: Enabled = {enableNewYearAudioReplace.Value}");
((BaseUnityPlugin)this).Logger.LogInfo((object)("Chinese Bride Model Replace Mod: Enabled = " + enableChineseModelReplace.Value));
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Chinese Bride Audio Replace Mod: Enabled = {enableChineseAudioReplace.Value}");
((BaseUnityPlugin)this).Logger.LogInfo((object)$"MeMe Audio: Enabled = {MeMeAudioReplace.Value}");
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Everyone Can See Girl: Enabled = {EveryoneCanSee.Value}");
}
}
}
namespace NewYearModelReplace.Patches
{
[HarmonyPatch(typeof(DressGirlAI))]
internal class DressGirlNewYearModelPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPatch(DressGirlAI __instance)
{
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance).transform.Find("DressGirlModel");
Transform val2 = val.Find("AnimContainer").Find("metarig");
SkinnedMeshRenderer component = ((Component)val.Find("basemesh")).GetComponent<SkinnedMeshRenderer>();
if (!((Object)(object)component != (Object)null) || !((Renderer)component).enabled)
{
return;
}
((Renderer)component).enabled = false;
MeshRenderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer val3 in componentsInChildren)
{
((Renderer)val3).enabled = false;
}
GameObject val4 = Object.Instantiate<GameObject>(Plugin.NYModelPrefab);
val4.transform.SetParent(val);
val4.transform.localPosition = Vector3.zero;
val4.transform.localRotation = Quaternion.identity;
val4.transform.localScale = Vector3.one;
Transform val5 = val4.transform.Find("metarig");
val5.SetParent(val2.parent, true);
((Component)val5).transform.localScale = ((Component)val2).transform.localScale;
((Component)val5).transform.localRotation = ((Component)val2).transform.localRotation;
((Component)val5).transform.localPosition = ((Component)val2).transform.localPosition;
List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>(((EnemyAI)__instance).skinnedMeshRenderers);
Transform[] array = (Transform[])(object)new Transform[2]
{
val4.transform.Find("girl"),
val4.transform.Find("dress")
};
Transform[] array2 = array;
foreach (Transform val6 in array2)
{
if ((Object)(object)val6 != (Object)null)
{
SkinnedMeshRenderer component2 = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
if ((Object)(object)component2 != (Object)null)
{
component2.rootBone = val5;
((Component)component2).gameObject.tag = "DoNotSet";
((Component)component2).gameObject.layer = LayerMask.NameToLayer("EnemiesNotRendered");
((Renderer)component2).material = Plugin.NewYearGirlMaterial;
list.Add(component2);
}
}
}
((EnemyAI)__instance).skinnedMeshRenderers = list.ToArray();
((Object)val2).name = "old_metarig";
}
}
}
namespace NewYearAudioReplace.Patches
{
[HarmonyPatch(typeof(DressGirlAI), "Start")]
internal class BreathingSFXPatch
{
[HarmonyPrefix]
public static void StartPatch(DressGirlAI __instance)
{
__instance.breathingSFX = Plugin.NewYearbreathingAudio;
__instance.heartbeatMusic.clip = Plugin.NewYearheartbeatMusicAudio;
__instance.heartbeatMusic.Play();
}
}
[HarmonyPatch(typeof(DressGirlAI), "SetHauntStarePosition")]
internal class AppearStaringSFXPatch
{
[HarmonyPrefix]
public static bool PlayRandomClipPrefix(DressGirlAI __instance)
{
AudioClip girlclip = Plugin.Girlclip1;
AudioClip girlclip2 = Plugin.Girlclip2;
AudioClip girlclip3 = Plugin.Girlclip3;
AudioClip girlclip4 = Plugin.Girlclip4;
AudioClip girlclip5 = Plugin.Girlclip5;
AudioClip girlclip6 = Plugin.Girlclip6;
AudioClip girlclip7 = Plugin.Girlclip7;
AudioClip girlclip8 = Plugin.Girlclip8;
AudioClip girlclip9 = Plugin.Girlclip9;
if ((Object)(object)girlclip != (Object)null && (Object)(object)girlclip2 != (Object)null && (Object)(object)girlclip3 != (Object)null && (Object)(object)girlclip4 != (Object)null && (Object)(object)girlclip5 != (Object)null && (Object)(object)girlclip6 != (Object)null && (Object)(object)girlclip7 != (Object)null && (Object)(object)girlclip8 != (Object)null && (Object)(object)girlclip9 != (Object)null)
{
AudioClip[] appearStaringSFX = (AudioClip[])(object)new AudioClip[9] { girlclip, girlclip2, girlclip3, girlclip4, girlclip5, girlclip6, girlclip7, girlclip8, girlclip9 };
__instance.appearStaringSFX = appearStaringSFX;
}
else
{
Debug.LogError((object)"One or more custom AudioClips are not available.");
}
return true;
}
}
internal static class PlayerDieAudioPatch
{
public static AudioSource audioSource;
private static bool shouldPlayAudio;
[HarmonyPatch(typeof(DressGirlAI), "OnCollideWithPlayer")]
[HarmonyPrefix]
public static void UpdatePrefix(DressGirlAI __instance)
{
shouldPlayAudio = ((EnemyAI)__instance).currentBehaviourStateIndex == 1;
if ((Object)(object)audioSource == (Object)null || !((Component)audioSource).gameObject.activeInHierarchy)
{
audioSource = CreateAndSetupAudioSource(__instance);
}
}
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
[HarmonyPostfix]
public static void KillPlayerPostfix()
{
if (shouldPlayAudio)
{
audioSource.Play();
Debug.LogError((object)"音频准备开始播放!");
shouldPlayAudio = false;
}
}
public static AudioSource CreateAndSetupAudioSource(DressGirlAI dressGirl)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Die Audio");
val.transform.SetParent(((Component)dressGirl).transform);
val.transform.localPosition = Vector3.zero;
AudioSource val2 = val.AddComponent<AudioSource>();
SetupAudioSource(val2);
return val2;
}
public static void SetupAudioSource(AudioSource source)
{
source.loop = false;
source.clip = Plugin.PlayerDie;
Debug.LogError((object)"音频加载成功!");
source.volume = 1f;
}
}
[HarmonyPatch(typeof(DressGirlAI), "Start")]
internal class BreathingSFXPatch2
{
[HarmonyPrefix]
public static void StartPatch(DressGirlAI __instance)
{
__instance.breathingSFX = Plugin.MeMeAudio;
__instance.heartbeatMusic.clip = Plugin.NewYearheartbeatMusicAudio;
__instance.heartbeatMusic.Play();
}
}
}
namespace EveryoneCanSeeGirl.Patches
{
[HarmonyPatch(typeof(DressGirlAI), "Update")]
internal class EveryoneCanSeeGirlPatch
{
[HarmonyPrefix]
public static bool PrefixUpdate(DressGirlAI __instance, ref bool ___enemyMeshEnabled)
{
if (!((NetworkBehaviour)__instance).IsOwner)
{
___enemyMeshEnabled = true;
((EnemyAI)__instance).EnableEnemyMesh(false, true);
return false;
}
return true;
}
}
[HarmonyPatch(typeof(EnemyAI), "EnableEnemyMesh")]
internal class EveryoneCanSeeGirlPatch2
{
[HarmonyPrefix]
public static void PrefixEnableEnemyMesh(ref bool enable)
{
enable = true;
}
}
}
namespace ChineseBrideAudioReplace.Patches
{
internal class ChineseBrideAudioPatch
{
private static int count;
[HarmonyPatch(typeof(DressGirlAI), "Start")]
[HarmonyPostfix]
public static void ResetCountOnStart()
{
count = 0;
Debug.LogError((object)"重置计数为0");
}
[HarmonyPatch(typeof(DressGirlAI), "OnCollideWithPlayer")]
[HarmonyPostfix]
public static void OnCollideWithPlayerPostfix(DressGirlAI __instance)
{
if (((EnemyAI)__instance).currentBehaviourStateIndex == 1)
{
Debug.LogError((object)"重置计数为0");
}
}
[HarmonyPatch(typeof(DressGirlAI), "SetHauntStarePosition")]
[HarmonyPrefix]
public static bool PlayRandomClipPrefix(DressGirlAI __instance)
{
count++;
switch (count)
{
case 1:
__instance.appearStaringSFX = (AudioClip[])(object)new AudioClip[1] { Plugin.ChineseGirlclipP1 };
__instance.breathingSFX = Plugin.ChineseGirlclipB1;
break;
case 2:
__instance.appearStaringSFX = (AudioClip[])(object)new AudioClip[1] { Plugin.ChineseGirlclipP2 };
__instance.breathingSFX = Plugin.ChineseGirlclipB2;
break;
case 3:
__instance.appearStaringSFX = (AudioClip[])(object)new AudioClip[1] { Plugin.ChineseGirlclipP3 };
__instance.breathingSFX = Plugin.ChineseGirlclipB3;
break;
default:
if (count > 3)
{
__instance.appearStaringSFX = (AudioClip[])(object)new AudioClip[9]
{
Plugin.ChineseGirlclipH1,
Plugin.ChineseGirlclipH2,
Plugin.ChineseGirlclipH3,
Plugin.ChineseGirlclipH4,
Plugin.ChineseGirlclipL1,
Plugin.ChineseGirlclipL2,
Plugin.ChineseGirlclipL3,
Plugin.ChineseGirlclipL4,
Plugin.ChineseGirlclipL5
};
__instance.breathingSFX = Plugin.ChineseGirlclipbreath;
}
break;
}
return true;
}
}
[HarmonyPatch(typeof(DressGirlAI), "SetHauntStarePosition")]
internal class ChineseBreathingSFXPatch
{
[HarmonyPrefix]
public static void StartPatch(DressGirlAI __instance)
{
Random.InitState(Environment.TickCount);
int num = Random.Range(0, Plugin.ChineseheartbeatMusicClips.Length);
__instance.heartbeatMusic.clip = Plugin.ChineseheartbeatMusicClips[num];
__instance.heartbeatMusic.Play();
}
}
internal static class ChinesePlayerDieAudioPatch
{
public static AudioSource audioSource;
private static bool shouldPlayAudio;
[HarmonyPatch(typeof(DressGirlAI), "OnCollideWithPlayer")]
[HarmonyPrefix]
public static void UpdatePrefix(DressGirlAI __instance)
{
shouldPlayAudio = ((EnemyAI)__instance).currentBehaviourStateIndex == 1;
if ((Object)(object)audioSource == (Object)null || !((Component)audioSource).gameObject.activeInHierarchy)
{
audioSource = CreateAndSetupAudioSource(__instance);
}
}
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
[HarmonyPostfix]
public static void KillPlayerPostfix()
{
if (shouldPlayAudio)
{
Random.InitState(Environment.TickCount);
int num = Random.Range(0, Plugin.ChineseheartbeatMusicClips.Length);
audioSource.clip = Plugin.ChineseheartbeatMusicClips[num];
audioSource.Play();
Debug.LogError((object)"音频准备开始播放!");
shouldPlayAudio = false;
}
}
public static AudioSource CreateAndSetupAudioSource(DressGirlAI dressGirl)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Die Audio 2");
val.transform.SetParent(((Component)dressGirl).transform);
val.transform.localPosition = Vector3.zero;
AudioSource val2 = val.AddComponent<AudioSource>();
SetupAudioSource(val2);
return val2;
}
public static void SetupAudioSource(AudioSource source)
{
source.loop = false;
Debug.LogError((object)"音频加载成功!");
source.volume = 1f;
}
}
}
namespace ChineseBrideModelReplace.Patches
{
[HarmonyPatch(typeof(DressGirlAI))]
internal class DressGirlChineseModelPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPatch(DressGirlAI __instance)
{
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance).transform.Find("DressGirlModel");
Transform val2 = val.Find("AnimContainer").Find("metarig");
SkinnedMeshRenderer component = ((Component)val.Find("basemesh")).GetComponent<SkinnedMeshRenderer>();
if (!((Object)(object)component != (Object)null) || !((Renderer)component).enabled)
{
return;
}
((Renderer)component).enabled = false;
MeshRenderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer val3 in componentsInChildren)
{
((Renderer)val3).enabled = false;
}
GameObject val4 = Object.Instantiate<GameObject>(Plugin.ChineseModelPrefab1);
val4.transform.SetParent(val);
val4.transform.localPosition = Vector3.zero;
val4.transform.localRotation = Quaternion.identity;
val4.transform.localScale = Vector3.one;
Transform val5 = val4.transform.Find("metarig");
val5.SetParent(val2.parent, true);
((Component)val5).transform.localScale = ((Component)val2).transform.localScale;
((Component)val5).transform.localRotation = ((Component)val2).transform.localRotation;
((Component)val5).transform.localPosition = ((Component)val2).transform.localPosition;
List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>(((EnemyAI)__instance).skinnedMeshRenderers);
Transform[] array = (Transform[])(object)new Transform[3]
{
val4.transform.Find("body"),
val4.transform.Find("dress"),
val4.transform.Find("head")
};
Transform[] array2 = array;
foreach (Transform val6 in array2)
{
if ((Object)(object)val6 != (Object)null)
{
SkinnedMeshRenderer component2 = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
if ((Object)(object)component2 != (Object)null)
{
component2.rootBone = val5;
((Component)component2).gameObject.tag = "DoNotSet";
((Component)component2).gameObject.layer = LayerMask.NameToLayer("EnemiesNotRendered");
((Renderer)component2).material = Plugin.ChineseGirlMaterial1;
list.Add(component2);
}
}
((EnemyAI)__instance).skinnedMeshRenderers = list.ToArray();
((Object)val2).name = "old_metarig2";
}
}
}
[HarmonyPatch(typeof(DressGirlAI))]
internal class DressGirlChineseModelPatch2
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPatch(DressGirlAI __instance)
{
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance).transform.Find("DressGirlModel");
Transform val2 = val.Find("AnimContainer").Find("metarig");
SkinnedMeshRenderer component = ((Component)val.Find("basemesh")).GetComponent<SkinnedMeshRenderer>();
if (!((Object)(object)component != (Object)null) || !((Renderer)component).enabled)
{
return;
}
((Renderer)component).enabled = false;
MeshRenderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer val3 in componentsInChildren)
{
((Renderer)val3).enabled = false;
}
GameObject val4 = Object.Instantiate<GameObject>(Plugin.ChineseModelPrefab2);
val4.transform.SetParent(val);
val4.transform.localPosition = Vector3.zero;
val4.transform.localRotation = Quaternion.identity;
val4.transform.localScale = Vector3.one;
Transform val5 = val4.transform.Find("metarig");
val5.SetParent(val2.parent, true);
((Component)val5).transform.localScale = ((Component)val2).transform.localScale;
((Component)val5).transform.localRotation = ((Component)val2).transform.localRotation;
((Component)val5).transform.localPosition = ((Component)val2).transform.localPosition;
List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>(((EnemyAI)__instance).skinnedMeshRenderers);
Transform[] array = (Transform[])(object)new Transform[3]
{
val4.transform.Find("body"),
val4.transform.Find("dress"),
val4.transform.Find("head")
};
Transform[] array2 = array;
foreach (Transform val6 in array2)
{
if ((Object)(object)val6 != (Object)null)
{
SkinnedMeshRenderer component2 = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
if ((Object)(object)component2 != (Object)null)
{
component2.rootBone = val5;
((Component)component2).gameObject.tag = "DoNotSet";
((Component)component2).gameObject.layer = LayerMask.NameToLayer("EnemiesNotRendered");
((Renderer)component2).material = Plugin.ChineseGirlMaterial2;
list.Add(component2);
}
}
((EnemyAI)__instance).skinnedMeshRenderers = list.ToArray();
((Object)val2).name = "old_metarig3";
}
}
}
}