Decompiled source of LethalCorporation v1.0.4

OrianaGames/OrianaGamesLethalCompany.dll

Decompiled 8 months ago
using System;
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 BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("OrianaGamesLethalCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("By Lunastellia")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("OrianaGamesLethalCompany")]
[assembly: AssemblyTitle("OrianaGamesLethalCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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 OrianaCore
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "OrianaGamesLethalCompany";

		public const string PLUGIN_NAME = "OrianaGamesLethalCompany";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}
namespace OrianaGamesLC
{
	public class LightCheck : MonoBehaviour
	{
		private MeshRenderer mainRend;

		private Light thisLight;

		private Shovel thisHitdamage;

		private static bool IsActived;

		private void Start()
		{
			thisLight = ((Component)this).GetComponentInChildren<Light>();
			mainRend = ((Component)this).GetComponentInChildren<MeshRenderer>();
			thisHitdamage = ((Component)this).GetComponentInChildren<Shovel>();
			thisHitdamage.shovelHitForce = Config.lightsaberDamage.Value;
		}

		private void On()
		{
			IsActived = true;
		}

		private void Off()
		{
			IsActived = false;
		}

		private void Update()
		{
			((Behaviour)thisLight).enabled = ((Renderer)mainRend).enabled;
			if ((((GrabbableObject)thisHitdamage).isHeld && !((GrabbableObject)thisHitdamage).isPocketed) || ((GrabbableObject)thisHitdamage).isHeldByEnemy)
			{
				On();
			}
			else
			{
				Off();
			}
			thisHitdamage.shovelHitForce = Config.lightsaberDamage.Value;
			if (IsActived)
			{
				thisLight.intensity = 0f + Config.lightsaberIntensity.Value;
				thisLight.range = 0f + Config.lightsaberRange.Value;
				((Behaviour)thisLight).enabled = true;
			}
			else
			{
				thisLight.intensity = 0f;
				thisLight.range = 0f;
				((Behaviour)thisLight).enabled = false;
			}
		}
	}
	public class Config
	{
		public static ConfigEntry<int> lightsaberPrice;

		public static ConfigEntry<int> lightsaberColor;

		public static ConfigEntry<float> lightsaberIntensity;

		public static ConfigEntry<float> lightsaberRange;

		public static ConfigEntry<bool> lightsaberCanscrap;

		public static ConfigEntry<int> lightsaberScrap;

		public static ConfigEntry<int> lightsaberDamage;

		public static ConfigEntry<bool> usefriendlyfire;

		public static ConfigEntry<int> friendlydamages;

		public static ConfigFile Configfile;

		public static void Load()
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			lightsaberPrice = Plugin.config.Bind<int>("Lasersaber", "Price", 50, "Change price to Lasersaber, Default = 50");
			lightsaberColor = Plugin.config.Bind<int>("Lasersaber", "Buyable Color", 0, "0 - random 1 - green, 2 - red, 3 - blue, 4 - purple, Default = 0");
			lightsaberCanscrap = Plugin.config.Bind<bool>("Lasersaber", "Can Scrap", true, "Can scrap Lasersaber in dungeon, Default = true");
			lightsaberScrap = Plugin.config.Bind<int>("Lasersaber", "Scrap spawn value", 10, "Spawn rarity (range 0-100), Default = 10");
			lightsaberIntensity = Plugin.config.Bind<float>("Lasersaber", "Intensity", 40f, "Change intencity to Lasersaber, Default = 40");
			lightsaberRange = Plugin.config.Bind<float>("Lasersaber", "Range", 15f, "Change light range to Lasersaber, Default = 15");
			lightsaberDamage = Plugin.config.Bind<int>("Lasersaber", "Damage multiplier", 1, "Damage multiplier, (Shovel damage = x1), Default = 1");
			usefriendlyfire = Plugin.config.Bind<bool>("Friendly damages", "Enable custom Friendly damages", true, "for compatibility with other mods, Default = true");
			friendlydamages = Plugin.config.Bind<int>("Friendly damages", "damage to other player", 30, "from shovel, lasersaber and other similar weapon, Default = 30");
			Configfile = new ConfigFile(Paths.ConfigPath + "\\OrianaGames.LethalCorporation.cfg", true);
		}
	}
	[HarmonyPatch]
	internal class DamagePatch
	{
		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientServerRpc")]
		[HarmonyPrefix]
		public static void DamagePlayerFromOtherClientServerRpc(ref int damageAmount, Vector3 hitDirection, int playerWhoHit)
		{
			if (Config.usefriendlyfire.Value)
			{
				damageAmount = Config.friendlydamages.Value;
			}
		}
	}
	public static class PluginInfo
	{
		public const string GUID = "Orianagames.LethalCorporation";

		public const string NAME = "LethalCorporation";

		public const string VERSION = "1.0.3";
	}
	[BepInPlugin("Orianagames.LethalCorporation", "LethalCorporation", "1.0.3")]
	internal class Plugin : BaseUnityPlugin
	{
		public static ConfigFile config;

		private readonly Harmony harmony = new Harmony("Orianagames.LethalCorporation");

		private static Plugin instance;

		private static string Debugg = "*";

		public void Awake()
		{
			config = ((BaseUnityPlugin)this).Config;
			Config.Load();
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
				string[] array = new string[4] { "0LS", "1LS", "2LS", "3LS" };
				string[] array2 = new string[4] { "GreenLightsaber", "RedLightsaber", "BlueLightsaber", "PurpleLightsaber" };
				int num = 2;
				num = ((Config.lightsaberColor.Value == 0) ? Random.Range(0, 4) : ((Config.lightsaberColor.Value != 1) ? ((Config.lightsaberColor.Value == 2) ? 1 : ((Config.lightsaberColor.Value == 3) ? 2 : ((Config.lightsaberColor.Value != 4) ? Random.Range(0, 4) : 3))) : 0));
				for (int i = 0; i < 4; i++)
				{
					string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), array[i]);
					AssetBundle val = AssetBundle.LoadFromFile(text);
					string text2 = "Assets/" + array2[i] + ".asset";
					Item val2 = val.LoadAsset<Item>(text2);
					val2.itemName = "LaserSaber";
					val2.weight = 1.05f;
					val2.isConductiveMetal = true;
					val2.canBeGrabbedBeforeGameStart = true;
					NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
					Utilities.FixMixerGroups(val2.spawnPrefab);
					Shovel component = val2.spawnPrefab.GetComponent<Shovel>();
					component.shovelHitForce = Config.lightsaberDamage.Value;
					LightCheck lightCheck = val2.spawnPrefab.AddComponent<LightCheck>();
					if (Config.lightsaberCanscrap.Value)
					{
						Items.RegisterScrap(val2, Config.lightsaberScrap.Value, (LevelTypes)(-1));
					}
					else
					{
						Items.RegisterScrap(val2, 0, (LevelTypes)(-1));
					}
					if (i == num)
					{
						TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
						val3.clearPreviousText = true;
						val3.displayText = "A f*ckin lazersaber!\n\n";
						Items.RegisterShopItem(val2, (TerminalNode)null, (TerminalNode)null, val3, Config.lightsaberPrice.Value);
						if (num == 0)
						{
							Debugg = " - (LightsaberColor = Green)";
						}
						if (num == 0)
						{
							Debugg = " - (LightsaberColor = Red)";
						}
						if (num == 0)
						{
							Debugg = " - (LightsaberColor = Bleu)";
						}
						if (num == 0)
						{
							Debugg = " - (LightsaberColor = Purple)";
						}
					}
				}
			}
			harmony.PatchAll(typeof(Plugin).Assembly);
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)("OrianaGames - LethalCorporation loaded!" + Debugg));
		}
	}
	public static class MainMenuManager_Patch
	{
		[HarmonyPatch(typeof(MenuManager), "Awake")]
		public static class MainMenuManagerPatch
		{
			public static void Postfix(MenuManager __instance)
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Expected O, but got Unknown
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject;
					GameObject gameObject2 = ((Component)gameObject.transform.Find("MenuContainer").Find("VersionNum")).gameObject;
					GameObject gameObject3 = ((Component)gameObject.transform.Find("MenuContainer").Find("MainButtons").Find("HeaderImage")).gameObject;
					if (!Object.op_Implicit((Object)(object)GameObject.Find("VersionText")))
					{
						GameObject val = new GameObject("VersionText");
						val.transform.position = gameObject3.transform.position;
						TextMesh val2 = val.AddComponent<TextMesh>();
						val2.fontStyle = (FontStyle)1;
						val2.alignment = (TextAlignment)1;
						val2.text = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<size=25><color=#ffff66>LethalCorporation</color> <color=#0066cc>[1.0.2]</color><color=#ff0000>\n- </color><color=#ff00ff> By Lunastellia </color><color=#3399ff>(OrianaGames)</color></size>";
					}
				}
				catch (Exception)
				{
				}
			}
		}
	}
}