Decompiled source of CrazyFrenchSisyphus v1.0.2

doomahreal.ultrakill.crazyrussiansisyphus/CrazyRussianSisyphus.dll

Decompiled 2 months ago
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 Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("CrazyRussianSisyphus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CrazyRussianSisyphus")]
[assembly: AssemblyTitle("CrazyRussianSisyphus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CrazyRussianSisyphus
{
	[BepInPlugin("doomahreal.ultrakill.crazyrussiansisyphus", "Crazy Russian Sisyphus", "1.0.0")]
	public class CrazyRussianSisyphusPlugin : BaseUnityPlugin
	{
		private AssetBundle bundle = null;

		private Dictionary<string, AudioClip> replacements = new Dictionary<string, AudioClip>();

		private float updateInterval = 1f / 60f;

		private float timeSinceLastUpdate = 0f;

		public string targetSceneName = "1f290c2101e628540bf9c6d1d2140750";

		private void Awake()
		{
			LoadAssetBundle();
			LoadReplacements();
		}

		private void LoadAssetBundle()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using Stream stream = executingAssembly.GetManifestResourceStream("CrazyRussianSisyphus.funnyassets.bundle");
			if (stream != null)
			{
				bundle = AssetBundle.LoadFromStream(stream);
				if ((Object)(object)bundle == (Object)null)
				{
					Debug.LogError((object)"Failed to load asset bundle.");
				}
			}
			else
			{
				Debug.LogError((object)"Asset bundle stream is null.");
			}
		}

		private void LoadReplacements()
		{
			if ((Object)(object)bundle == (Object)null)
			{
				Debug.LogError((object)"Asset bundle is not loaded. Cannot load replacements.");
				return;
			}
			replacements["destroy1.wav"] = bundle.LoadAsset<AudioClip>("assets/destroy.mp3");
			replacements["clap1.wav"] = bundle.LoadAsset<AudioClip>("assets/begone.mp3");
			replacements["explode1.wav"] = bundle.LoadAsset<AudioClip>("assets/this_will_hurt2.mp3");
			replacements["taunt1.wav"] = bundle.LoadAsset<AudioClip>("assets/nice_try.mp3");
			replacements["player_death1.wav"] = bundle.LoadAsset<AudioClip>("assets/you_cant_escape2.mp3");
			replacements["phase.wav"] = bundle.LoadAsset<AudioClip>("assets/yes_thats_it.mp3");
		}

		private void Update()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			timeSinceLastUpdate += Time.deltaTime;
			if (!(timeSinceLastUpdate >= updateInterval))
			{
				return;
			}
			SisyphusPrime val = Object.FindObjectOfType<SisyphusPrime>();
			if ((Object)(object)val != (Object)null)
			{
				ReplaceVoiceLines(val.uppercutComboVoice, "destroy1.wav");
				ReplaceVoiceLines(val.clapVoice, "clap1.wav");
				ReplaceVoiceLines(val.explosionVoice, "explode1.wav");
				ReplaceVoiceLines(val.tauntVoice, "taunt1.wav");
				ReplaceVoiceLines(val.stompComboVoice, "player_death1.wav");
				ReplaceVoiceLine(ref val.phaseChangeVoice, "phase.wav");
			}
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (name == targetSceneName)
			{
				GameObject val2 = GameObject.Find("Main Section/9 - Boss Arena/Boss Stuff(Clone)/PrimeIntro/SisyphusPrimeIntro/VoiceDelayer");
				if ((Object)(object)val2 != (Object)null)
				{
					Transform val3 = val2.transform.Find("Voice");
					if ((Object)(object)val3 != (Object)null)
					{
						AudioSource component = ((Component)val3).GetComponent<AudioSource>();
						if ((Object)(object)component != (Object)null && (Object)(object)component.clip != (Object)null && ((Object)component.clip).name == "sp_intro")
						{
							component.clip = bundle.LoadAsset<AudioClip>("a_visitor.mp3");
						}
					}
				}
				GameObject val4 = GameObject.Find("Main Section/9 - Boss Arena/Boss Stuff(Clone)/PrisonPhase/Flesh Prison 2/DelayedInstakill");
				if ((Object)(object)val4 != (Object)null)
				{
					Transform val5 = val4.transform.Find("Voice");
					if ((Object)(object)val5 != (Object)null)
					{
						AudioSource component2 = ((Component)val5).GetComponent<AudioSource>();
						if ((Object)(object)component2 != (Object)null && (Object)(object)component2.clip != (Object)null && ((Object)component2.clip).name == "sp_thisprison")
						{
							component2.clip = bundle.LoadAsset<AudioClip>("this_prison.mp3");
						}
					}
				}
				GameObject val6 = GameObject.Find("Main Section/9 - Boss Arena/Boss Stuff(Clone)/PrimePhase/SisyphusPrime/OutroDelay/Outro");
				if ((Object)(object)val6 != (Object)null)
				{
					AudioSource component3 = val6.GetComponent<AudioSource>();
					if ((Object)(object)component3 != (Object)null && (Object)(object)component3.clip != (Object)null && ((Object)component3.clip).name == "sp_outro")
					{
						component3.clip = bundle.LoadAsset<AudioClip>("end_dialogue.mp3");
					}
				}
				GameObject[] array = Object.FindObjectsOfType<GameObject>();
				GameObject[] array2 = array;
				foreach (GameObject val7 in array2)
				{
					if (!(((Object)val7).name == "KeepThemComing"))
					{
						continue;
					}
					AudioSource component4 = val7.GetComponent<AudioSource>();
					if ((Object)(object)component4 != (Object)null && (Object)(object)component4.clip != (Object)null && ((Object)component4.clip).name == "sp_keepthemcoming")
					{
						AudioClip val8 = bundle.LoadAsset<AudioClip>("assets/keep_em_coming.mp3");
						if ((Object)(object)val8 != (Object)null)
						{
							component4.clip = val8;
							component4.Play();
						}
					}
				}
			}
			Material[] array3 = Resources.FindObjectsOfTypeAll<Material>();
			Material[] array4 = array3;
			foreach (Material val9 in array4)
			{
				if (((Object)val9).name == "SisyHead3 (Instance)" || ((Object)val9).name == "SisyHead2 (Instance)" || ((Object)val9).name == "SisyHead2" || ((Object)val9).name == "SisyHead3")
				{
					Texture2D val10 = bundle.LoadAsset<Texture2D>("sisyphusheadfriend3");
					if ((Object)(object)val9.mainTexture != (Object)(object)val10)
					{
						val9.mainTexture = (Texture)(object)val10;
					}
				}
			}
			timeSinceLastUpdate = 0f;
		}

		private void ReplaceVoiceLine(ref AudioClip voiceLine, string replacementName)
		{
			if (replacements.ContainsKey(replacementName))
			{
				voiceLine = replacements[replacementName];
			}
		}

		private void ReplaceVoiceLines(AudioClip[] voiceLines, string replacementName)
		{
			if (replacements.ContainsKey(replacementName))
			{
				for (int i = 0; i < voiceLines.Length; i++)
				{
					voiceLines[i] = replacements[replacementName];
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CrazyRussianSisyphus";

		public const string PLUGIN_NAME = "CrazyRussianSisyphus";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}