using System.Collections;
using System.Diagnostics;
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 UnityEngine;
using UnityEngine.Networking;
[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 = "")]
[assembly: AssemblyCompany("HayateArmyMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HayateArmyMod")]
[assembly: AssemblyTitle("HayateArmyMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HayateArmyMod
{
[BepInPlugin("org.justdankas.hayate_army", "Greek_Hayate_Army", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "org.justdankas.hayate_army";
private const string modName = "Greek_Hayate_Army";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("org.justdankas.hayate_army");
private static Plugin Instance;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin org.justdankas.hayate_army is loaded!");
harmony.PatchAll();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "HayateArmyMod";
public const string PLUGIN_NAME = "HayateArmyMod";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace HayateArmyMod.Patches
{
internal static class AudioUtil
{
public static string modFolder = "JustDankas-Greek_Hayate_Army";
public static AudioClip getAudioClip(string fileName, string folder = "")
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Invalid comparison between Unknown and I4
string text = "";
if (folder != "")
{
text = text + "\\" + folder;
}
text = text + "\\" + fileName;
string text2 = "file://" + Paths.PluginPath + "\\" + modFolder + text;
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(text2, (AudioType)13);
audioClip.SendWebRequest();
while (!audioClip.isDone)
{
}
if ((int)audioClip.result == 1)
{
return DownloadHandlerAudioClip.GetContent(audioClip);
}
return null;
}
}
[HarmonyPatch(typeof(BoomboxItem))]
internal class BoomboxPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void PatchBoomBox(BoomboxItem __instance)
{
AudioClip audioClip = AudioUtil.getAudioClip("makedonia.mp3", "CustomBoombox");
AudioClip audioClip2 = AudioUtil.getAudioClip("ethnikogamisths.mp3", "CustomBoombox");
AudioClip audioClip3 = AudioUtil.getAudioClip("albanos.mp3", "CustomBoombox");
AudioClip[] musicAudios = (AudioClip[])(object)new AudioClip[3] { audioClip, audioClip2, audioClip3 };
__instance.musicAudios = musicAudios;
}
}
[HarmonyPatch(typeof(ForestGiantAI))]
internal class ForestGiantPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void PatchAudio(ForestGiantAI __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
if ((Object)__instance != (Object)null)
{
ManualLogSource val = Logger.CreateLogSource("JustDankas.ForestGiantPatch");
AudioClip audioClip = AudioUtil.getAudioClip("piperakos_egefaliko.mp3", "GiantSFX");
AudioClip audioClip2 = AudioUtil.getAudioClip("merenda.mp3", "GiantSFX");
AudioClip audioClip3 = AudioUtil.getAudioClip("piperakos_stun.mp3", "GiantSFX");
if ((Object)(object)audioClip != (Object)null && (Object)(object)audioClip2 != (Object)null && (Object)(object)audioClip3 != (Object)null)
{
val.LogInfo((object)"Ο πιπεράκος έσπασε και το τράπεζι, όλα τα πάθε");
GameObject gameObject = ((Component)((EnemyAI)__instance).agent).gameObject;
GiantAudio giantAudio = gameObject.AddComponent<GiantAudio>();
giantAudio.mls = val;
giantAudio.egefalikoClip = audioClip;
giantAudio.merendaClip = audioClip2;
((EnemyAI)__instance).enemyType.stunSFX = audioClip3;
}
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void PatchUpdate(ForestGiantAI __instance, bool ___chasingPlayerInLOS, bool ___inEatingPlayerAnimation, AudioSource ___creatureVoice)
{
GiantAudio component = ((Component)((EnemyAI)__instance).agent).gameObject.GetComponent<GiantAudio>();
AudioSource component2 = ((Component)((EnemyAI)__instance).agent).gameObject.GetComponent<AudioSource>();
if (___chasingPlayerInLOS && !___inEatingPlayerAnimation && !___creatureVoice.isPlaying)
{
___creatureVoice.PlayOneShot(component.egefalikoClip);
}
if (___inEatingPlayerAnimation && !component.playingMerenda)
{
component2.PlayOneShot(component.merendaClip);
component.eatMerenda();
}
}
}
internal class GiantAudio : MonoBehaviour
{
public ManualLogSource mls;
public AudioClip merendaClip;
public AudioClip egefalikoClip;
public bool playingMerenda = false;
public void eatMerenda()
{
playingMerenda = true;
((MonoBehaviour)this).StartCoroutine(StopEatingMerendaCoroutine());
}
private IEnumerator StopEatingMerendaCoroutine()
{
mls.LogInfo((object)$"Coroutine started, restarting merenda in {merendaClip.length} seconds!");
yield return (object)new WaitForSeconds(merendaClip.length);
playingMerenda = false;
}
}
[HarmonyPatch(typeof(MouthDogAI))]
internal class MouthDogPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void AudioPatch(MouthDogAI __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
if ((Object)__instance != (Object)null)
{
AudioClip audioClip = AudioUtil.getAudioClip("piperakos.mp3", "DogSFX");
ManualLogSource val = Logger.CreateLogSource("JustDankas.DogPatch");
val.LogInfo((object)"Patching hayate dog audios...");
__instance.screamSFX = audioClip;
}
}
}
[HarmonyPatch(typeof(PufferAI))]
internal class PufferPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void PatchPuffer(PufferAI __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
if ((Object)__instance != (Object)null)
{
ManualLogSource val = Logger.CreateLogSource("JustDankas.PufferPatch");
AudioClip audioClip = AudioUtil.getAudioClip("nicktron_cry.mp3", "PufferSFX");
AudioClip audioClip2 = AudioUtil.getAudioClip("nicktron_katalabes.mp3", "PufferSFX");
AudioClip audioClip3 = AudioUtil.getAudioClip("nicktron_perifronisi.mp3", "PufferSFX");
if ((Object)(object)audioClip != (Object)null && (Object)(object)audioClip2 != (Object)null && (Object)(object)audioClip3 != (Object)null)
{
AudioClip[] frightenSFX = (AudioClip[])(object)new AudioClip[3] { audioClip, audioClip2, audioClip3 };
__instance.frightenSFX = frightenSFX;
val.LogInfo((object)"Ο nicktron τον πήρε από τον κώλο με επυτιχία");
}
else
{
val.LogInfo((object)"Το πουστράκι μου ξέφυγε");
}
}
}
}
}