using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2.CharacterSpeech;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2.CharacterSpeech;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Voice Acted Mithrix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Voice Acted Mithrix")]
[assembly: AssemblyTitle("Voice Acted Mithrix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Voice_Acted_Mithrix.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("Voice_Acted_Mithrix.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal Resources()
{
}
}
}
namespace VoiceActedMithrix
{
internal class BossLineEvent
{
public string eventName;
public GameObject source;
public bool angyLine;
public BossLineEvent(string name, GameObject gameObject, bool angy = false)
{
eventName = name;
source = gameObject;
angyLine = angy;
}
public uint Play()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
uint result = AkSoundEngine.PostEvent(eventName, source, 1u, new EventCallback(EndEventCallback), (object)null);
if (NetworkServer.active)
{
NetMessageExtensions.Send((INetMessage)(object)new NetworkBossVoiceMessage
{
name = eventName,
source = source
}, (NetworkDestination)1);
}
return result;
}
private void EndEventCallback(object in_cookie, AkCallbackType callbackType, object in_info)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)callbackType == 1 && NetworkServer.active && Object.op_Implicit((Object)(object)source))
{
BossVoiceComponent bossVoiceComponent = source.GetComponent<BossVoiceComponent>();
if (!Object.op_Implicit((Object)(object)bossVoiceComponent))
{
bossVoiceComponent = source.AddComponent<BossVoiceComponent>();
}
if (angyLine)
{
bossVoiceComponent.angy = false;
}
bossVoiceComponent.playingLine = false;
}
}
}
internal class BossVoiceComponent : MonoBehaviour
{
internal bool playingLine = false;
internal bool delaying = false;
private List<BossLineEvent> queuedLines = new List<BossLineEvent>();
internal bool gone = false;
internal bool angy = false;
private bool hurt = false;
private int angyCounter = 2;
private float timer;
private float baseDelay = 1f;
private float deltaDelay = 0.3f;
private void Start()
{
timer = baseDelay + Random.Range(0f - deltaDelay, deltaDelay);
}
internal void FixedUpdate()
{
if (timer > 0f)
{
timer -= Time.fixedDeltaTime;
}
else
{
delaying = false;
}
if (queuedLines.Count > 0 && !playingLine && !delaying)
{
PlaySound(queuedLines[0]);
queuedLines.RemoveAt(0);
}
}
internal void TryVoiceLine(BossLineEvent sound)
{
if (!angy)
{
if (!hurt && sound.eventName.Contains("BROTHERHURT"))
{
hurt = true;
}
if (queuedLines.Count > 2)
{
BecomePissed(sound.source);
}
else if (playingLine || delaying || queuedLines.Count > 0)
{
queuedLines.Add(sound);
}
else
{
PlaySound(sound);
}
}
}
internal void BecomePissed(GameObject source)
{
queuedLines.Clear();
if (Random.Range(0, angyCounter * 4 + 1) == 0)
{
angy = true;
BossLineEvent item = ((!((Object)((Component)this).gameObject).name.Contains("FalseSon")) ? (hurt ? new BossLineEvent("VAMR_" + Configuration.MithrixVoice.Value + "_BROTHERHURT_QUEUEFULL", source, angy: true) : new BossLineEvent("VAMR_" + Configuration.MithrixVoice.Value + "_BROTHER_QUEUEFULL", source, angy: true)) : new BossLineEvent("VAMR_" + Configuration.FalseSonVoice.Value + "_FALSESON_QUEUEFULL", source, angy: true));
queuedLines.Add(item);
angyCounter = 2;
}
else
{
angyCounter--;
}
}
internal void PlaySound(BossLineEvent soundEvent)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0052: Invalid comparison between Unknown and I4
timer = baseDelay + Random.Range(0f - deltaDelay, deltaDelay);
playingLine = true;
delaying = true;
uint value = soundEvent.Play();
uint[] array = new uint[10];
uint num = (uint)array.Length;
AKRESULT playingIDsFromGameObject = AkSoundEngine.GetPlayingIDsFromGameObject(soundEvent.source, ref num, array);
if ((int)playingIDsFromGameObject != 1 || !array.Contains(value))
{
playingLine = (angy = false);
}
}
}
internal class Configuration
{
private static ConfigFile configFile;
internal const int DefaultMithrixVoice = 0;
internal const int DefaultFalseSonVoice = 0;
internal static ConfigEntry<int> MithrixVoice { get; private set; }
internal static ConfigEntry<int> FalseSonVoice { get; private set; }
internal static void LoadConfig()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
configFile = new ConfigFile(Paths.ConfigPath + "/VAMithrix.cfg", true);
MithrixVoice = configFile.Bind<int>("Voices", "Mithrix VA", 0, "Voice actor to use for Mithrix boss. 0: MotherEgg | 1: KKing");
FalseSonVoice = configFile.Bind<int>("Voices", "False Son VA", 0, "Voice actor to use for False Son boss. 0: SkellyVA | 1: KKing");
}
}
internal class NetworkBossVoiceMessage : INetMessage, ISerializableObject
{
internal string name;
internal GameObject source;
public void Serialize(NetworkWriter writer)
{
writer.Write(name);
writer.Write(source);
}
public void Deserialize(NetworkReader reader)
{
name = reader.ReadString();
source = reader.ReadGameObject();
}
public void OnReceived()
{
if (Object.op_Implicit((Object)(object)source) && !NetworkServer.active)
{
AkSoundEngine.PostEvent(name, source);
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Egg.VoiceActedMithrix", "Voice Acted Mithrix Redux", "1.0.3")]
public class VoiceActedMithrix : BaseUnityPlugin
{
public const string MODNAME = "com.Egg.VoiceActedMithrix";
public const string MODTITLE = "Voice Acted Mithrix Redux";
public const string MODVERS = "1.0.3";
internal static string BankPathBrother;
internal static string BankPathFalseson;
private string[] brotherFileNames = new string[2] { "vamithrixredux.bnk", "vakkingmithrix.bnk" };
private string[] falseSonFileNames = new string[2] { "vafalseson.bnk", "vakkingfalseson.bnk" };
private void Awake()
{
Configuration.LoadConfig();
BankPathBrother = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "soundbanks", brotherFileNames[Configuration.MithrixVoice.Value]);
BankPathFalseson = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "soundbanks", falseSonFileNames[Configuration.FalseSonVoice.Value]);
SoundBanks.Add(BankPathBrother);
SoundBanks.Add(BankPathFalseson);
NetworkingAPI.RegisterMessageType<NetworkBossVoiceMessage>();
if (Configuration.MithrixVoice.Value == 0)
{
HereticKurskanFix();
}
}
private void OnEnable()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
BrotherSpeechDriver.SendReponseFromPool += new hook_SendReponseFromPool(BrotherSpeechDriver_SendReponseFromPool);
FalseSonBossSpeechDriver.SendReponseFromPool += new hook_SendReponseFromPool(FalseSonBossSpeechDriver_SendReponseFromPool);
CharacterSpeechController.SpeakNow += new hook_SpeakNow(OnSpeak);
}
private void OnDisable()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
BrotherSpeechDriver.SendReponseFromPool -= new hook_SendReponseFromPool(BrotherSpeechDriver_SendReponseFromPool);
FalseSonBossSpeechDriver.SendReponseFromPool -= new hook_SendReponseFromPool(FalseSonBossSpeechDriver_SendReponseFromPool);
CharacterSpeechController.SpeakNow -= new hook_SpeakNow(OnSpeak);
}
private void OnSpeak(orig_SpeakNow orig, CharacterSpeechController self, ref SpeechInfo speechInfo)
{
orig.Invoke(self, ref speechInfo);
GameObject val = ((Component)self.currentCharacterBody).gameObject;
string text = "VAMR_" + (((Object)val).name.Contains("Brother") ? Configuration.MithrixVoice.Value : Configuration.FalseSonVoice.Value) + "_" + speechInfo.token;
BossVoiceComponent bossVoiceComponent = val.GetComponent<BossVoiceComponent>();
if (!Object.op_Implicit((Object)(object)bossVoiceComponent))
{
bossVoiceComponent = val.AddComponent<BossVoiceComponent>();
}
if (text.Contains("FALSESONBOSS") && (text.Contains("_DEATH_") || text.Contains("PURIFICATION")))
{
val = GameObject.Find("MeridianEventTriggerCore");
}
bossVoiceComponent.TryVoiceLine(new BossLineEvent(text, val));
}
private void HereticKurskanFix()
{
LanguageAPI.Add("BROTHER_SEE_HERETIC_1", "Regret this journey, Kur-skan.", "en");
LanguageAPI.Add("BROTHER_KILL_HERETIC_2", "Die again, Kur-skan.", "en");
LanguageAPI.Add("BROTHERHURT_KILL_HERETIC_2", "DIE AGAIN, KUR-SKAN.", "en");
}
private void FalseSonBossSpeechDriver_SendReponseFromPool(orig_SendReponseFromPool orig, FalseSonBossSpeechDriver self, SpeechInfo[] responsePool)
{
if (responsePool.Length != 0)
{
((BaseCharacterSpeechDriver)self).characterSpeechController.EnqueueSpeech(ref responsePool[Random.Range(0, responsePool.Length)]);
}
}
private void BrotherSpeechDriver_SendReponseFromPool(orig_SendReponseFromPool orig, BrotherSpeechDriver self, SpeechInfo[] responsePool)
{
if (responsePool.Length != 0)
{
((BaseCharacterSpeechDriver)self).characterSpeechController.EnqueueSpeech(ref responsePool[Random.Range(0, responsePool.Length)]);
}
}
}
}