Decompiled source of MinoMod v1.0.5

plugins/MinoMod/MinoMod.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using MinoMod.Library.Items;
using MinoMod.Scrap;
using On;
using Unity.Netcode;
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: AssemblyCompany("MinoMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("First Lethal Company mod attempt")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+a2078864df28b8345db1aeb251d07ae2dd041041")]
[assembly: AssemblyProduct("MinoMod")]
[assembly: AssemblyTitle("MinoMod")]
[assembly: NeutralResourcesLanguage("aa-ER")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.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 MinoMod
{
	[BepInPlugin("MinoMod", "MinoMod", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MinoMod is loaded!");
			SpecialScrap.Init();
			SpecialScrap.Load();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MinoMod";

		public const string PLUGIN_NAME = "MinoMod";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}
namespace MinoMod.Scrap
{
	public class SpecialScrap
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__StartOfRound_Awake;

			public static hook_Start <1>__GameNetworkManager_Start;
		}

		public static AssetBundle MainAssets;

		public static Item item;

		public static void Init()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			object obj = <>O.<0>__StartOfRound_Awake;
			if (obj == null)
			{
				hook_Awake val = StartOfRound_Awake;
				<>O.<0>__StartOfRound_Awake = val;
				obj = (object)val;
			}
			StartOfRound.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__GameNetworkManager_Start;
			if (obj2 == null)
			{
				hook_Start val2 = GameNetworkManager_Start;
				<>O.<1>__GameNetworkManager_Start = val2;
				obj2 = (object)val2;
			}
			GameNetworkManager.Start += (hook_Start)obj2;
		}

		public static void Load()
		{
			if ((Object)(object)MainAssets == (Object)null)
			{
				MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "toasty"));
			}
			item = MainAssets.LoadAsset<Item>("Assets/Custom/Toasty/ToastyItem.asset");
		}

		private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			orig.Invoke(self);
			SelectableLevel[] levels = self.levels;
			foreach (SelectableLevel val in levels)
			{
				SpawnableItemWithRarity val2 = new SpawnableItemWithRarity
				{
					spawnableItem = item,
					rarity = 7
				};
				if (!val.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)item))
				{
					val.spawnableScrap.Add(val2);
				}
			}
			if (!self.allItemsList.itemsList.Contains(item))
			{
				self.allItemsList.itemsList.Add(item);
			}
		}

		private static void GameNetworkManager_Start(orig_Start orig, GameNetworkManager self)
		{
			orig.Invoke(self);
			((Component)self).GetComponent<NetworkManager>().AddNetworkPrefab(item.spawnPrefab);
		}
	}
	public class Toasty : MinoMod.Library.Items.Scrap
	{
		[HideInInspector]
		public bool trapSprung = false;

		public override void GrabItem()
		{
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			base.GrabItem();
			Debug.Log((object)$"Toasty was picked up. Client is owner: {((NetworkBehaviour)this).IsOwner}");
			Debug.Log((object)$"Toasty is server?: {((NetworkBehaviour)this).IsServer}");
			Debug.Log((object)$"Trap was sprung already?: {trapSprung}");
			if (trapSprung)
			{
				return;
			}
			Debug.Log((object)"TRAP HAS BEEN SPRUNG!");
			trapSprung = true;
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			List<int> list = new List<int>();
			List<SpawnableEnemyWithRarity> enemies = RoundManager.Instance.currentLevel.Enemies;
			int item = -1;
			for (int i = 0; i < enemies.Count; i++)
			{
				list.Add(i);
				list.Add(i);
				list.Add(i);
				if (enemies[i].enemyType.enemyName.ToLower() == "hoarding bug")
				{
					item = i;
				}
			}
			list.Add(-1);
			list.Add(-1);
			list.Add(-1);
			while (list.Count < 100)
			{
				list.Add(item);
			}
			int index = randomizer.Next(0, list.Count);
			int num = list[index];
			EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
			foreach (EnemyVent val in allEnemyVents)
			{
				if (num >= 0 && num < enemies.Count)
				{
					Vector3 position = val.floorNode.position;
					float y = val.floorNode.eulerAngles.y;
					RoundManager.Instance.SpawnEnemyOnServer(position, y, num);
				}
			}
		}
	}
}
namespace MinoMod.Library.Items
{
	public class Scrap : GrabbableObject
	{
		[Space(5f)]
		[Header("Animation")]
		public Animator triggerAnimator;

		[Space(5f)]
		[Header("Audio")]
		public AudioSource SFXSource;

		public AudioSource SFXSourceFar;

		[Space(5f)]
		[Header("Sound Effects")]
		public AudioClip equipSFX;

		[Space(3f)]
		public AudioClip dropSFX;

		public AudioClip grabSFX;

		[Space(3f)]
		public AudioClip activateSFX;

		public AudioClip activateSFXFar;

		[Space(5f)]
		[Header("Sound settings")]
		public float noiseRange;

		public float minVolume;

		public float maxVolume;

		public float minPitch;

		public float maxPitch;

		[HideInInspector]
		protected Random randomizer;

		[HideInInspector]
		protected bool wasHeldBeforeEquip = false;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			randomizer = new Random(StartOfRound.Instance.randomMapSeed + 85);
			if ((Object)(object)dropSFX != (Object)null)
			{
				base.itemProperties.dropSFX = dropSFX;
			}
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			wasHeldBeforeEquip = false;
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			if ((Object)(object)SFXSource != (Object)null && (Object)(object)equipSFX != (Object)null && wasHeldBeforeEquip)
			{
				float num = (float)randomizer.Next((int)(minVolume * 100f), (int)(maxVolume * 100f)) / 100f;
				float pitch = (float)randomizer.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
				SFXSource.pitch = pitch;
				SFXSource.PlayOneShot(equipSFX, num);
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if ((Object)(object)SFXSource != (Object)null && (Object)(object)grabSFX != (Object)null)
			{
				float num = (float)randomizer.Next((int)(minVolume * 100f), (int)(maxVolume * 100f)) / 100f;
				float pitch = (float)randomizer.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
				SFXSource.pitch = pitch;
				SFXSource.PlayOneShot(grabSFX, num);
			}
			wasHeldBeforeEquip = true;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			if ((Object)(object)SFXSource != (Object)null && (Object)(object)activateSFX != (Object)null)
			{
				float num = (float)randomizer.Next((int)(minVolume * 100f), (int)(maxVolume * 100f)) / 100f;
				float pitch = (float)randomizer.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
				SFXSource.pitch = pitch;
				SFXSource.PlayOneShot(activateSFX, num);
				if ((Object)(object)SFXSourceFar != (Object)null && (Object)(object)activateSFXFar != (Object)null)
				{
					SFXSourceFar.pitch = pitch;
					SFXSourceFar.PlayOneShot(activateSFXFar, num);
				}
				WalkieTalkie.TransmitOneShotAudio(SFXSource, activateSFX, num);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, num, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
				if (num >= 0.6f && (Object)(object)base.playerHeldBy != (Object)null)
				{
					base.playerHeldBy.timeSinceMakingLoudNoise = 0f;
				}
			}
			Animator obj = triggerAnimator;
			if (obj != null)
			{
				obj.SetTrigger("playAnim");
			}
		}
	}
	internal class Weapon
	{
	}
}