Decompiled source of LethalFortress2 v0.1.1

BepInEx/plugins/LethalFortress2.dll

Decompiled 11 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 BepInEx.Configuration;
using HarmonyLib;
using LethalFortress2.Replacements;
using Microsoft.CodeAnalysis;
using ModelReplacement;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LethalFortress2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalFortress2")]
[assembly: AssemblyTitle("LethalFortress2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LethalFortress2
{
	[BepInPlugin("meow.LethalFortress2", "Lethal Fortress 2", "0.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigFile config;

		public static ConfigEntry<bool> defaultScoutSkin { get; private set; }

		private static void InitConfig()
		{
			defaultScoutSkin = config.Bind<bool>("Suits to Replace Settings", "Enable Scout as default", false, "Enable to replace every non-TF2 suit with Scout.");
		}

		private void Awake()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			config = ((BaseUnityPlugin)this).Config;
			InitConfig();
			Assets.PopulateAssets();
			ModelReplacementAPI.RegisterSuitModelReplacement("Engineer", typeof(EngineerReplacement));
			ModelReplacementAPI.RegisterSuitModelReplacement("Spy", typeof(SpyReplacement));
			ModelReplacementAPI.RegisterSuitModelReplacement("Sniper", typeof(SniperReplacement));
			ModelReplacementAPI.RegisterSuitModelReplacement("Pyro", typeof(PyroReplacement));
			ModelReplacementAPI.RegisterSuitModelReplacement("Demoman", typeof(DemoReplacement));
			ModelReplacementAPI.RegisterSuitModelReplacement("Scout", typeof(ScoutReplacement));
			ModelReplacementAPI.RegisterSuitModelReplacement("Soldier", typeof(SoldierReplacement));
			ModelReplacementAPI.RegisterSuitModelReplacement("Heavy", typeof(HeavyReplacement));
			ModelReplacementAPI.RegisterSuitModelReplacement("Medic", typeof(MedicReplacement));
			if (defaultScoutSkin.Value)
			{
				ModelReplacementAPI.RegisterModelReplacementDefault(typeof(ScoutReplacement));
			}
			Harmony val = new Harmony("meow.LethalFortress2");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin meow.LethalFortress2 is loaded!");
		}
	}
	public static class Assets
	{
		public class RandomAudioClip
		{
			private List<AudioClip> audioClipList = new List<AudioClip>();

			public AudioClip GetRandomAudio(int seed)
			{
				Random random = new Random();
				int num = random.Next(audioClipList.Count);
				Console.WriteLine($"Get audio N {audioClipList.Count} > {num}");
				return audioClipList[num];
			}

			public void AddAudio(string name)
			{
				AudioClip audioClipFromName = GetAudioClipFromName(name);
				if ((Object)(object)audioClipFromName != (Object)null)
				{
					audioClipList.Add(audioClipFromName);
				}
				else
				{
					Console.WriteLine("clip " + name + " null");
				}
			}
		}

		public static string mainAssetBundleName = "tf2bundle";

		public static AssetBundle MainAssetBundle = null;

		public static RandomAudioClip scoutE1 = new RandomAudioClip();

		public static RandomAudioClip scoutE2 = new RandomAudioClip();

		public static RandomAudioClip engineerE1 = new RandomAudioClip();

		public static RandomAudioClip engineerE2 = new RandomAudioClip();

		public static RandomAudioClip spyE1 = new RandomAudioClip();

		public static RandomAudioClip spyE2 = new RandomAudioClip();

		public static RandomAudioClip sniperE1 = new RandomAudioClip();

		public static RandomAudioClip sniperE2 = new RandomAudioClip();

		public static RandomAudioClip pyroE1 = new RandomAudioClip();

		public static RandomAudioClip pyroE2 = new RandomAudioClip();

		public static RandomAudioClip demoE1 = new RandomAudioClip();

		public static RandomAudioClip demoE2 = new RandomAudioClip();

		public static RandomAudioClip soldierE1 = new RandomAudioClip();

		public static RandomAudioClip soldierE2 = new RandomAudioClip();

		public static RandomAudioClip heavyE1 = new RandomAudioClip();

		public static RandomAudioClip heavyE2 = new RandomAudioClip();

		public static RandomAudioClip medicE1 = new RandomAudioClip();

		public static RandomAudioClip medicE2 = new RandomAudioClip();

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().FullName.Split(',')[0];
		}

		public static void PopulateAssets()
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName);
				MainAssetBundle = AssetBundle.LoadFromStream(stream);
			}
			scoutE1.AddAudio("Scout_cheers01");
			scoutE1.AddAudio("Scout_battlecry01");
			scoutE1.AddAudio("Scout_cheers05");
			scoutE2.AddAudio("Scout_jeers02");
			scoutE2.AddAudio("Scout_invinciblenotready02");
			scoutE2.AddAudio("Scout_invinciblenotready02");
			scoutE2.AddAudio("Scout_award09");
			scoutE2.AddAudio("Scout_cloakedspy03");
			engineerE1.AddAudio("Engineer_cheers02");
			engineerE1.AddAudio("Engineer_battlecry07");
			engineerE2.AddAudio("Engineer_dominationspy07");
			engineerE2.AddAudio("Engineer_cloakedspy03");
			spyE1.AddAudio("Spy_autocappedintelligence03");
			spyE1.AddAudio("Spy_battlecry01");
			spyE2.AddAudio("Spy_DominationScout01");
			spyE2.AddAudio("Spy_taunts05");
			sniperE1.AddAudio("Cm_sniper_matchwon_08");
			sniperE1.AddAudio("Sniper_cheers04");
			sniperE1.AddAudio("Sniper_cheers02");
			sniperE1.AddAudio("Sniper_battlecry05");
			sniperE2.AddAudio("Sniper_domination13");
			sniperE2.AddAudio("Sniper_specialcompleted13");
			sniperE2.AddAudio("Sniper_jeers03");
			sniperE2.AddAudio("Sniper_cloakedspy02");
			sniperE2.AddAudio("Sniper_go01");
			pyroE1.AddAudio("Pyro_laughevil04");
			pyroE1.AddAudio("Pyro_positivevocalization01");
			pyroE1.AddAudio("Pyro_laughevil02");
			pyroE2.AddAudio("Pyro_jeers02");
			pyroE2.AddAudio("Pyro_battlecry02");
			pyroE2.AddAudio("Pyro_cloakedspy01");
			demoE1.AddAudio("Demoman_goodjob01");
			demoE1.AddAudio("Demoman_cheers02");
			demoE1.AddAudio("Demoman_battlecry06");
			demoE1.AddAudio("Demoman_battlecry01");
			demoE2.AddAudio("Demoman_jeers01");
			demoE2.AddAudio("Demoman_cloakedspy01");
			demoE2.AddAudio("Demoman_cloakedspy02");
			demoE2.AddAudio("Demoman_go01");
			soldierE1.AddAudio("Soldier_sf12_badmagic12");
			soldierE1.AddAudio("Soldier_cheers01");
			soldierE1.AddAudio("Soldier_cheers06");
			soldierE1.AddAudio("Soldier_cheers03");
			soldierE2.AddAudio("Cm_soldier_summary_callout_01");
			soldierE2.AddAudio("Soldier_DominationSpy05");
			soldierE2.AddAudio("Soldier_HatOverHeartTaunt02");
			soldierE2.AddAudio("Soldier_HatOverHeartTaunt01");
			soldierE2.AddAudio("Soldier_jeers01");
			soldierE2.AddAudio("Soldier_cloakedspy02");
			heavyE1.AddAudio("Cm_heavy_summary_callout_06");
			heavyE1.AddAudio("Cm_heavy_matchwon_10");
			heavyE1.AddAudio("Cm_heavy_pregamefirst_09");
			heavyE1.AddAudio("Heavy_specialcompleted11");
			heavyE1.AddAudio("Heavy_laughterbig01");
			heavyE1.AddAudio("Heavy_positivevocalization02");
			heavyE2.AddAudio("Heavy_jeers03");
			heavyE2.AddAudio("Heavy_specialcompleted09");
			heavyE2.AddAudio("Heavy_meleedare07");
			heavyE2.AddAudio("Heavy_cloakedspy03");
			heavyE2.AddAudio("Heavy_go03");
			medicE1.AddAudio("Medic_positivevocalization02");
			medicE1.AddAudio("Medic_cheers01");
			medicE2.AddAudio("Medic_autocappedintelligence02");
			medicE2.AddAudio("Medic_jeers05");
			medicE2.AddAudio("Medic_cloakedspy02");
		}

		public static AudioClip GetAudioClipFromName(string name)
		{
			Object obj = MainAssetBundle.LoadAsset(name);
			return (AudioClip)(object)((obj is AudioClip) ? obj : null);
		}
	}
}
namespace LethalFortress2.Replacements
{
	public class EngineerReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "engineerPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.engineerE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.engineerE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
	public class SpyReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "spyPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.spyE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.spyE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
	public class SniperReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "sniperPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.sniperE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.sniperE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
	public class PyroReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "pyroPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.pyroE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.pyroE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
	public class DemoReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "demoPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.demoE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.demoE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
	public class ScoutReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "scoutPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.scoutE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.scoutE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
	public class SoldierReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "soldierPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.soldierE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.soldierE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
	public class HeavyReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "heavyPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.heavyE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.heavyE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
	public class MedicReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "medicPrefab";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}

		protected override void OnEmoteStart(int emoteId)
		{
			if (emoteId == 1)
			{
				AudioClip randomAudio = Assets.medicE1.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio, 0.8f);
			}
			if (emoteId == 2)
			{
				AudioClip randomAudio2 = Assets.medicE2.GetRandomAudio(StartOfRound.Instance.randomMapSeed);
				((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(randomAudio2, 0.8f);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}