Decompiled source of LethalUkraine v0.0.6

LethalUkraine.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalUkraine")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e58a2b2fd955c62505237d125e3c908080cedcc1")]
[assembly: AssemblyProduct("LethalUkraine")]
[assembly: AssemblyTitle("LethalUkraine")]
[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 LethalUkraine
{
	[HarmonyPatch(typeof(RoundManager))]
	public class AtbCompanyPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")]
		private static void RefreshEnemiesList(RoundManager __instance)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			LethalUkrainePlugin.logger.LogInfo((object)"Spawning atb logo");
			if (((Object)__instance.currentLevel).name == "CompanyBuildingLevel" && !HasAtb())
			{
				LethalUkrainePlugin.logger.LogInfo((object)"Spawning atb logo 2");
				Object.Instantiate<GameObject>(getAtbLogo(), new Vector3(-28.1707f, 3.4476f, -31.9498f), Quaternion.Euler(0f, -90f, 0f)).GetComponent<NetworkObject>().Spawn(false);
			}
		}

		private static bool HasAtb()
		{
			return Object.FindObjectsOfType<GameObject>().Count(delegate(GameObject o)
			{
				string name = ((Object)o).name;
				return (name == "atb(Clone)" || name == "atb") ? true : false;
			}) > 0;
		}

		private static GameObject getAtbLogo()
		{
			return AssetBundle.GetAllLoadedAssetBundles().First((AssetBundle assetBundle) => ((Object)assetBundle).name == "lethalukraine").LoadAsset<GameObject>("assets/atb.prefab");
		}
	}
	public class DebugMenu : MonoBehaviour
	{
	}
	[HarmonyPatch]
	public class DebugMenuPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		public static void Start(StartOfRound __instance)
		{
		}
	}
	public class FlagItem : GrabbableObject
	{
		public AudioClip AudioClip;

		public override void EquipItem()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			LethalUkrainePlugin.logger.LogInfo((object)"playing sound");
			((Component)this).GetComponent<AudioSource>().PlayOneShot(AudioClip);
			Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)this).transform.position, 50f, 0.9f, 0, false, 0);
		}

		public override void OnHitGround()
		{
			LethalUkrainePlugin.logger.LogInfo((object)"stopped sound :(");
			((Component)this).gameObject.GetComponent<AudioSource>().Stop();
		}
	}
	[BepInPlugin("LethalUkraine", "LethalUkraine", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LethalUkrainePlugin : BaseUnityPlugin
	{
		public static LethalUkrainePlugin Instance;

		public static ManualLogSource logger;

		public static GameObject atb;

		private readonly Harmony harmony = new Harmony("Teheidoma.LethalUkraine");

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				logger = ((BaseUnityPlugin)this).Logger;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalUkraine is loaded!");
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethalukraine"));
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"failed to load assets");
				return;
			}
			Item obj = val.LoadAsset<Item>("assets/flag.asset");
			NetworkPrefabs.RegisterNetworkPrefab(obj.spawnPrefab);
			Items.RegisterScrap(obj, 60, (LevelTypes)(-1));
			atb = val.LoadAsset<GameObject>("assets/atb.asset");
			Item obj2 = val.LoadAsset<Item>("assets/revo.asset");
			NetworkPrefabs.RegisterNetworkPrefab(obj2.spawnPrefab);
			Items.RegisterShopItem(obj2, 30);
			Item obj3 = val.LoadAsset<Item>("assets/salut.asset");
			NetworkPrefabs.RegisterNetworkPrefab(obj3.spawnPrefab);
			Items.RegisterShopItem(obj3, 20);
			harmony.PatchAll(typeof(AtbCompanyPatch));
			NetcodePatcher();
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[HarmonyPatch]
	internal class PesPatronPatch
	{
		[HarmonyPatch(typeof(HoarderBugAI), "Start")]
		[HarmonyPostfix]
		private static void CreatePesPatron(HoarderBugAI __instance)
		{
			Renderer[] componentsInChildren = ((Component)((Component)__instance).transform.Find("HoarderBugModel")).GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Object.Instantiate<GameObject>(getPesPatronPrefab(), ((Component)((Component)__instance).gameObject.transform).transform);
			((Object)((Component)__instance).gameObject.transform).name = "Pes Patron";
			((Component)((Component)__instance).gameObject.transform.Find("Scan Node")).GetComponent<ScanNodeProperties>().headerText = "Pes Patron";
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		public static void GameStart(RoundManager __instance, int randomSeed, int levelID)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (levelID == 3)
			{
				EnemyType val = Resources.FindObjectsOfTypeAll<EnemyType>().First((EnemyType type) => type.enemyName == "Hoarding bug");
				__instance.SpawnEnemyGameObject(((Component)__instance.playersManager.localPlayerController).transform.position, 0f, 1, val);
			}
		}

		private static GameObject getPesPatronPrefab()
		{
			return AssetBundle.GetAllLoadedAssetBundles().First((AssetBundle assetBundle) => ((Object)assetBundle).name == "lethalukraine").LoadAsset<GameObject>("assets/atb.prefab");
		}
	}
	public class RevoBuff : NetworkBehaviour
	{
		public float secondsLeft;

		public float originalSpeed;

		private PlayerControllerB _playerController;

		public void Start()
		{
			_playerController = ((Component)this).GetComponent<PlayerControllerB>();
			((MonoBehaviour)this).StartCoroutine(SpeedUp(_playerController));
		}

		public override void OnDestroy()
		{
			if (Math.Abs(_playerController.movementSpeed - originalSpeed) > 0.1f)
			{
				_playerController.movementSpeed = originalSpeed;
			}
		}

		private IEnumerator SpeedUp(PlayerControllerB player)
		{
			originalSpeed = player.movementSpeed;
			LethalUkrainePlugin.logger.LogInfo((object)("PLAYER " + player.playerUsername + " buffed with REVASIK"));
			player.movementSpeed *= 3f;
			for (float buffTime = 180f; buffTime > 0f; buffTime -= 1f)
			{
				secondsLeft = buffTime;
				yield return (object)new WaitForSeconds(1f);
			}
			LethalUkrainePlugin.logger.LogInfo((object)("PLAYER " + player.playerUsername + " end buff with REVASIK"));
			player.movementSpeed = originalSpeed;
			EndEffectServerRpc();
		}

		[ServerRpc]
		public void EndEffectServerRpc()
		{
			EndEffectClientRpc();
		}

		[ClientRpc]
		public void EndEffectClientRpc()
		{
			Object.Destroy((Object)(object)this);
		}
	}
	public class RevoItem : GrabbableObject
	{
		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (Object.op_Implicit((Object)(object)((Component)base.playerHeldBy).GetComponent<RevoBuff>()))
			{
				LethalUkrainePlugin.logger.LogInfo((object)"PLAYER ALREADY HAVE BUFF");
				return;
			}
			base.playerHeldBy.activatingItem = true;
			LethalUkrainePlugin.logger.LogInfo((object)"ITEM CONSUMED");
			UseRevoServerRpc();
		}

		[ServerRpc(RequireOwnership = false)]
		public void UseRevoServerRpc()
		{
			LethalUkrainePlugin.logger.LogInfo((object)"ServerRPC revo");
			UseRevoClientRpc();
		}

		[ClientRpc]
		private void UseRevoClientRpc()
		{
			LethalUkrainePlugin.logger.LogInfo((object)"ClientRPC revo");
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				base.playerHeldBy.activatingItem = false;
				((Component)base.playerHeldBy).gameObject.AddComponent<RevoBuff>();
				base.playerHeldBy.DestroyItemInSlotAndSync(base.playerHeldBy.currentItemSlot);
			}
		}
	}
	public class SalutItem : GrabbableObject
	{
		public bool LookAt = true;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			LethalUkrainePlugin.logger.LogInfo((object)"Activate Salut");
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				SalutHealServerRpc();
			}
		}

		[ServerRpc]
		public void SalutHealServerRpc()
		{
			LethalUkrainePlugin.logger.LogInfo((object)"Activate Salut server");
			SalutHealClientRpc();
		}

		[ClientRpc]
		private void SalutHealClientRpc()
		{
			LethalUkrainePlugin.logger.LogInfo((object)"Activate client");
			base.playerHeldBy.health = 100;
			base.playerHeldBy.criticallyInjured = false;
			base.playerHeldBy.bleedingHeavily = false;
			base.playerHeldBy.DestroyItemInSlot(base.playerHeldBy.currentItemSlot);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalUkraine";

		public const string PLUGIN_NAME = "LethalUkraine";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}