using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LCSoundTool;
using MikuBraken.Patches;
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.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MikuBraken
{
public class ConfigManager
{
private const string SectionGeneral = "General";
private const string SectionSound = "Sound";
public static ConfigEntry<bool> MikuModel;
public static ConfigEntry<bool> MikuTerminal;
public static ConfigEntry<bool> MikuDeleteOnKilled;
public static ConfigEntry<bool> MikuScanTag;
public static ConfigEntry<bool> MikuGlowingEyes;
public static ConfigEntry<bool> MikuAngry;
public static ConfigEntry<bool> MikuCaught;
public static ConfigEntry<bool> MikuDies;
public static ConfigEntry<bool> MikuFootsteps;
public static ConfigEntry<bool> MikuCrackNeck;
public static ConfigEntry<bool> MikuStun;
public ConfigManager(ConfigFile cfg)
{
MikuModel = cfg.Bind<bool>("General", "MikuModel", true, "The Braken's model will be replaced by Miku");
MikuGlowingEyes = cfg.Bind<bool>("General", "MikuGlowingEyes", true, "Miku will have glowing eyes similar to the Braken");
MikuTerminal = cfg.Bind<bool>("General", "Terminal", true, "The Braken's bestiary entry will be replaced by Miku");
MikuDeleteOnKilled = cfg.Bind<bool>("General", "DeleteOnKilled", false, "Miku's model is deleted on death");
MikuScanTag = cfg.Bind<bool>("General", "ScanTag", true, "The Braken's scan tag is replaced with 'Hatune Miku'");
MikuAngry = cfg.Bind<bool>("Sound", "MikuAngry", true, "Replaces the sound when the Braken begins to chase the player");
MikuCaught = cfg.Bind<bool>("Sound", "MikuCaught", true, "Replaces the sound when a player spots the Braken in stealth");
MikuDies = cfg.Bind<bool>("Sound", "MikuDies", true, "Replaces the Braken's death sound");
MikuFootsteps = cfg.Bind<bool>("Sound", "MikuFootsteps", true, "Replaces the Braken's footstep sounds");
MikuCrackNeck = cfg.Bind<bool>("Sound", "MikuCrackNeck", true, "Adds a sound after Miku kills a player");
MikuStun = cfg.Bind<bool>("Sound", "MikuStun", true, "Replaces the Braken's stun sound");
}
}
[BepInPlugin("Wolfmyths.MikuBraken", "Miku Braken", "1.2.1")]
public class MikuBrakenBase : BaseUnityPlugin
{
private const string modGUID = "Wolfmyths.MikuBraken";
private const string modName = "Miku Braken";
private const string modVersion = "1.2.1";
private readonly Harmony harmony = new Harmony("Wolfmyths.MikuBraken");
internal static MikuBrakenBase Instance;
internal static ManualLogSource mls;
private static List<AudioClip> SoundFX;
internal static AudioClip Miku_Angry;
internal static AudioClip Miku_Angry1;
internal static AudioClip Miku_Caught;
internal static AudioClip Miku_Caught1;
internal static AudioClip Miku_Caught2;
internal static AudioClip Miku_CrackNeck;
internal static AudioClip Miku_Dies;
internal static AudioClip Miku_Footsteps;
internal static AudioClip Miku_Footsteps1;
internal static AudioClip Miku_Footsteps2;
internal static AudioClip Miku_Footsteps3;
internal static AudioClip Miku_Stun;
internal static List<GameObject> Prefabs;
internal static GameObject Miku;
internal static GameObject Miku_Eyes;
internal static AssetBundle SFXBundle;
internal static AssetBundle PrefabBundle;
public static ConfigManager myConfig { get; internal set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
myConfig = new ConfigManager(((BaseUnityPlugin)this).Config);
mls = Logger.CreateLogSource("Wolfmyths.MikuBraken");
Log_Info("Mikudayooo");
mls = ((BaseUnityPlugin)this).Logger;
SoundFX = new List<AudioClip>();
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("MikuBraken.dll".ToCharArray());
SFXBundle = AssetBundle.LoadFromFile(location + "sounds");
PrefabBundle = AssetBundle.LoadFromFile(location + "model");
if ((Object)(object)SFXBundle != (Object)null && (Object)(object)PrefabBundle != (Object)null)
{
Log_Info("Asset bundles loaded");
SoundFX = SFXBundle.LoadAllAssets<AudioClip>().ToList();
Miku_Angry = SoundFX[0];
Miku_Angry1 = SoundFX[1];
Miku_Caught = SoundFX[2];
Miku_Caught1 = SoundFX[3];
Miku_Caught2 = SoundFX[4];
Miku_CrackNeck = SoundFX[5];
Miku_Dies = SoundFX[6];
Miku_Footsteps = SoundFX[7];
Miku_Footsteps1 = SoundFX[8];
Miku_Footsteps2 = SoundFX[9];
Miku_Footsteps3 = SoundFX[10];
Miku_Stun = SoundFX[11];
Prefabs = PrefabBundle.LoadAllAssets<GameObject>().ToList();
Miku_Eyes = Prefabs[0];
Miku = Prefabs[1];
}
else
{
if ((Object)(object)SFXBundle == (Object)null)
{
Log_Error("Failed to load SoundFX bundle");
}
if ((Object)(object)PrefabBundle == (Object)null)
{
Log_Error("Failed to load Prefab bundle");
}
}
harmony.PatchAll(typeof(MikuBrakenBase));
harmony.PatchAll(typeof(FlowerManAIPatch));
harmony.PatchAll(typeof(TerminalPatch));
}
private void Start()
{
if (ConfigManager.MikuFootsteps.Value)
{
SoundTool.ReplaceAudioClip("Step1", Miku_Footsteps, 1f, "Flowerman(Clone)");
SoundTool.ReplaceAudioClip("Step2", Miku_Footsteps1, 1f, "Flowerman(Clone)");
SoundTool.ReplaceAudioClip("Step3", Miku_Footsteps2, 1f, "Flowerman(Clone)");
SoundTool.ReplaceAudioClip("Step4", Miku_Footsteps3, 1f, "Flowerman(Clone)");
}
if (ConfigManager.MikuCaught.Value)
{
SoundTool.ReplaceAudioClip("Found1", Miku_Caught, 0.35f, "Flowerman(Clone)");
SoundTool.ReplaceAudioClip("Found1", Miku_Caught1, 0.35f, "Flowerman(Clone)");
SoundTool.ReplaceAudioClip("Found1", Miku_Caught2, 0.3f, "Flowerman(Clone)");
}
if (ConfigManager.MikuAngry.Value)
{
SoundTool.ReplaceAudioClip("Angered", Miku_Angry, 0.5f);
SoundTool.ReplaceAudioClip("Angered", Miku_Angry1, 0.5f);
}
}
public static void Log_UnityObject_List(List<AudioClip> list)
{
foreach (AudioClip item in list)
{
Log_Info(((Object)item).name);
}
}
public static void Log_UnityObject_List(List<GameObject> list)
{
foreach (GameObject item in list)
{
Log_Info(((Object)item).name);
}
}
public static void Log_Info(string msg)
{
mls.LogInfo((object)msg);
}
public static void Log_Warning(string msg)
{
mls.LogWarning((object)msg);
}
public static void Log_Error(string msg)
{
mls.LogError((object)msg);
}
}
}
namespace MikuBraken.Patches
{
[HarmonyPatch(typeof(FlowermanAI))]
internal class FlowerManAIPatch
{
[HarmonyPatch(typeof(FlowermanAI), "Start")]
[HarmonyPostfix]
private static void OverrideStart(FlowermanAI __instance)
{
//IL_003b: 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)
if (ConfigManager.MikuModel.Value)
{
GameObject val = Object.Instantiate<GameObject>(MikuBrakenBase.Miku, ((Component)__instance).gameObject.transform);
((Object)val).name = "Miku(Clone)";
val.transform.localPosition = Vector3.zero;
val.SetActive(true);
if (ConfigManager.MikuGlowingEyes.Value)
{
GameObject val2 = Object.Instantiate<GameObject>(MikuBrakenBase.Miku_Eyes, val.gameObject.transform);
((Object)val2).name = "MikuEyes(Clone)";
val2.SetActive(true);
val2.transform.localPosition = new Vector3(-0.0817f, 2.5481f, 0.1302f);
}
Renderer[] componentsInChildren = ((Component)((Component)__instance).transform.Find("FlowermanModel")).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val3 in array)
{
val3.enabled = false;
}
}
if (ConfigManager.MikuScanTag.Value)
{
((Component)__instance).GetComponentInChildren<ScanNodeProperties>().headerText = "Hatsune Miku";
}
if (ConfigManager.MikuAngry.Value)
{
__instance.creatureAngerVoice.maxDistance = 40f;
}
if (ConfigManager.MikuDies.Value)
{
((EnemyAI)__instance).dieSFX = MikuBrakenBase.Miku_Dies;
}
if (ConfigManager.MikuStun.Value)
{
((EnemyAI)__instance).enemyType.stunSFX = MikuBrakenBase.Miku_Stun;
}
}
[HarmonyPatch(typeof(FlowermanAI), "killAnimation")]
[HarmonyPostfix]
private static void OverrideKillAnimation(FlowermanAI __instance)
{
if (ConfigManager.MikuCrackNeck.Value)
{
__instance.crackNeckAudio.PlayOneShot(MikuBrakenBase.Miku_CrackNeck);
}
}
[HarmonyPatch(typeof(FlowermanAI), "KillEnemy")]
[HarmonyPostfix]
private static void overrideKillEnemy(FlowermanAI __instance)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if (ConfigManager.MikuModel.Value)
{
if (!ConfigManager.MikuDeleteOnKilled.Value)
{
Transform val = ((Component)__instance).transform.Find("Miku(Clone)");
Quaternion rotation = val.rotation;
float y = ((Quaternion)(ref rotation)).eulerAngles.y;
rotation = ((Component)__instance).transform.rotation;
val.rotation = Quaternion.Euler(-90f, y, ((Quaternion)(ref rotation)).eulerAngles.z);
}
else
{
((Component)((Component)__instance).transform.Find("Miku(Clone)")).gameObject.SetActive(false);
}
}
}
}
internal class TerminalPatch
{
[HarmonyPatch(typeof(Terminal), "Awake")]
[HarmonyPostfix]
private static void OverrideTerminal(Terminal __instance)
{
if (!ConfigManager.MikuTerminal.Value)
{
return;
}
for (int i = 0; i < __instance.enemyFiles.Count; i++)
{
TerminalNode val = __instance.enemyFiles[i];
if (val.creatureName == "Brackens")
{
val.creatureName = "Hatsune Miku";
val.displayText = "PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\n\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPi-\r\n\r\nPiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii!\r\n\r\n\r\nSaa nome, o mae suki darou? Yasai jusu\r\nWatashi ga kimeta, ima kimeta\r\nDakara nonde watashi no yasai JUICE,\r\nKakaku wa nihyaku en~!\r\n\r\nsoiya! soiya!\r\ndotsee! dotsee!\r\nsoiya! soiya!\r\ndotsee! dotsee!\r\n\r\n\r\nMaroyaka, yasai JUICE,\r\nFuwa fuwa yasai juice\r\nIchiban osusume na no wa\r\nMidori no jusuuu~!\r\n\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nVegitabura-na a-aa-aa-a-a-aaa!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nSeimei afureta, a-aa-aa-a-a-aaa!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nAnata mo ima a-aa-aa-a-a-aaa!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nYasai jusu ga suki ni naru!\r\n\r\n\r\nPiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii!\r\n\r\nCome now, don't you love\r\nit? Vegetable juice\r\nThat's my decision, I've decided it now.\r\nThus you should drink\r\nmy vegetable juice,\r\nIt costs just 200 yen~!\r\n\r\nsoiya! soiya!\r\ndotsee! dotsee!\r\nsoiya! soiya!\r\ndotsee! dotsee!\r\n\r\n\r\nIt'll agree with you, vegetable juice,\r\nLight-weighted vegetable juice\r\nThe best juice I choose for you would be\r\nthe green vegtable juice~!\r\n\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nWe are vegetarian a-aa-aa-a-a-aaa!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nbursting with life, a-aa-aa-a-a-aaa!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nhappy vegetarians a-aa-aa-a-a-aaa!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nPoPiPoPiPo PoPiPo! PoPiPoPiPo PoPiPo!\r\nY.A.S.A Come here to love\r\n\r\nvegetable juice!";
break;
}
}
for (int j = 0; j < __instance.terminalNodes.allKeywords.Count(); j++)
{
TerminalKeyword val2 = __instance.terminalNodes.allKeywords[j];
if (val2.word == "brackens")
{
val2.word = "hatsune miku";
break;
}
}
}
}
}