Decompiled source of Sinister Company2 v1.0.1

plugins/LethalComFunny/LethalComFunny.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LC_API.Networking;
using LC_API.Networking.Serializers;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[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: AssemblyCompany("LethalComFunny")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A funny mod for lethal company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("LethalComFunny")]
[assembly: AssemblyTitle("LethalComFunny")]
[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 LethalComFunny
{
	[BepInPlugin("LethalComFunny", "LethalComFunny", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("LethalComFunny");

		public static Plugin instance;

		private static InputAction action = new InputAction((string)null, (InputActionType)0, "<Keyboard>/y", (string)null, (string)null, (string)null);

		private static bool allowDeadSpawns = false;

		public static ManualLogSource Logger;

		private static List<Landmine> mines = new List<Landmine>();

		private static StartOfRound gameInstance => StartOfRound.Instance;

		private static SelectableLevel currentLevel => gameInstance.currentLevel;

		public static MConfig LCFConfig { get; internal set; }

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			action.performed += delegate
			{
				queueSpawnMine();
			};
			action.Enable();
			Network.RegisterAll();
			LCFConfig = new MConfig(((BaseUnityPlugin)this).Config);
			harmony.PatchAll(typeof(Plugin));
			Logger = Logger.CreateLogSource("LethalComFunny");
			Logger.LogInfo((object)"Plugin LethalComFunny is loaded!");
		}

		[HarmonyPatch(typeof(Landmine), "Detonate")]
		[HarmonyPostfix]
		private static void disableHitboxAfterExplosion(ref Landmine __instance)
		{
			((MonoBehaviour)gameInstance).StartCoroutine(DestroyOnDelay(5f, __instance));
		}

		[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		private static void byebyeMines()
		{
			foreach (Landmine mine in mines)
			{
				Object.Destroy((Object)(object)((Component)((Component)mine).gameObject.transform.parent).gameObject);
			}
			mines = new List<Landmine>();
		}

		[NetworkMessage("LethalCumFunnyMineDespawn", false)]
		public static void SpawnHandler(ulong sender, Landmine mine)
		{
			if (((NetworkBehaviour)gameInstance).IsHost)
			{
				((Component)mine).GetComponent<NetworkObject>().Despawn(true);
			}
		}

		private static IEnumerator DestroyOnDelay(float delay, Landmine mine)
		{
			mines.Remove(mine);
			((Component)mine).gameObject.transform.Find("BlastMark").parent = null;
			yield return (object)new WaitForSeconds(delay);
			if (((NetworkBehaviour)gameInstance).IsHost)
			{
				Object.Destroy((Object)(object)((Component)((Component)mine).gameObject.transform.parent).gameObject);
			}
		}

		private static void queueSpawnMine()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (gameInstance.localPlayerController.isPlayerDead && !allowDeadSpawns)
			{
				return;
			}
			Camera activeCamera = gameInstance.activeCamera;
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)activeCamera).transform.position, ((Component)activeCamera).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 20f, 268437761))
			{
				Vector3 point = ((RaycastHit)(ref val2)).point;
				if (((NetworkBehaviour)gameInstance).IsHost)
				{
					spawnMine(point);
					return;
				}
				Network.Broadcast<Vector3SClass>("LethalCumFunnyMineSpawn", new Vector3SClass
				{
					pos = Vector3S.op_Implicit(point)
				});
			}
		}

		[NetworkMessage("LethalCumFunnyMineSpawn", false)]
		public static void SpawnHandler(ulong sender, Vector3SClass message)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)gameInstance).IsHost)
			{
				Vector3S pos = message.pos;
				spawnMine(((Vector3S)(ref pos)).vector3);
			}
		}

		public static void spawnMine(Vector3 pos)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			SpawnableMapObject[] spawnableMapObjects = currentLevel.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				if (!((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() == (Object)null))
				{
					GameObject val2 = Object.Instantiate<GameObject>(val.prefabToSpawn, pos, Quaternion.identity);
					val2.transform.position = pos;
					val2.transform.forward = new Vector3(1f, 0f, 0f);
					val2.GetComponent<NetworkObject>().Spawn(true);
					mines.Add(val2.GetComponentInChildren<Landmine>());
					break;
				}
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyMemberJoined")]
		[HarmonyPostfix]
		public static void SyncConfig()
		{
			if (((NetworkBehaviour)gameInstance).IsHost)
			{
				((MonoBehaviour)gameInstance).StartCoroutine(SendConfigOnDelay(5f));
			}
		}

		private static IEnumerator SendConfigOnDelay(float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			Logger.LogInfo((object)("Telling clients to set configDeadSpawns to " + MConfig.configDeadSpawns.Value));
			Network.Broadcast<ConfigWrapper>("LethalCumFunnySendConfig", new ConfigWrapper
			{
				Value = MConfig.configDeadSpawns.Value
			});
			allowDeadSpawns = MConfig.configDeadSpawns.Value;
		}

		[NetworkMessage("LethalCumFunnySendConfig", false)]
		public static void ConfigReceiver(ulong sender, ConfigWrapper configDeadSpawns)
		{
			Logger.LogInfo((object)("Setting allowDeadSpawns to " + configDeadSpawns.Value));
			allowDeadSpawns = configDeadSpawns.Value;
		}

		[NetworkMessage("LethalCumFunnyRequestConfig", false)]
		public static void ConfigSender(ulong sender)
		{
			if (((NetworkBehaviour)gameInstance).IsHost)
			{
				Logger.LogInfo((object)("Telling clients to set configDeadSpawns to " + MConfig.configDeadSpawns.Value));
				Network.Broadcast<ConfigEntry<bool>>("LethalCumFunnySendConfig", MConfig.configDeadSpawns);
				allowDeadSpawns = MConfig.configDeadSpawns.Value;
			}
		}
	}
	public class Vector3SClass
	{
		public Vector3S pos { get; set; }
	}
	public class ConfigWrapper
	{
		public bool Value { get; set; }
	}
	public class MConfig
	{
		public static ConfigEntry<bool> configDeadSpawns;

		public MConfig(ConfigFile cfg)
		{
			configDeadSpawns = cfg.Bind<bool>("General.Toggles", "AllowDeadSpawns", false, "Whether or not to allow dead players to spawn mines");
		}
	}
	[Serializable]
	public class SyncedInstance<T>
	{
		[NonSerialized]
		protected static int IntSize = 4;

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		public static T Default { get; private set; }

		public static T Instance { get; private set; }

		public static bool Synced { get; internal set; }

		protected void InitInstance(T instance)
		{
			Default = instance;
			Instance = instance;
			IntSize = 4;
		}

		internal static void SyncInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}

		internal static void RevertSync()
		{
			Instance = Default;
			Synced = false;
		}

		public static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		public static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalComFunny";

		public const string PLUGIN_NAME = "LethalComFunny";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

plugins/MetalRecharging.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
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("MetalRecharging")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Allows you to charge metal objects")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MetalRecharging")]
[assembly: AssemblyTitle("MetalRecharging")]
[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.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MetalRecharging
{
	[BepInPlugin("MetalRecharging", "MetalRecharging", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MetalRecharging is loaded!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MetalRecharging";

		public const string PLUGIN_NAME = "MetalRecharging";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MetalRecharging.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class ChatPatch
	{
		private static bool _justExploded;

		private static SpawnableMapObject? _landmine;

		[HarmonyPatch("AddPlayerChatMessageServerRpc")]
		[HarmonyPatch("AddChatMessage")]
		[HarmonyPostfix]
		private static void OnServerMessageAdded(HUDManager __instance, ref string chatMessage)
		{
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			if (_justExploded || (Object)(object)((NetworkBehaviour)__instance).NetworkManager == (Object)null || !chatMessage.Contains("iexplode"))
			{
				return;
			}
			string[] array = chatMessage.Split('-');
			if (array.Length != 3)
			{
				return;
			}
			ulong playerId = ulong.Parse(array[1]);
			PlayerControllerB val = ((IEnumerable<PlayerControllerB>)__instance.playersManager.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.playerClientId == playerId));
			if (_landmine == null)
			{
				_landmine = __instance.playersManager?.levels?.SelectMany((SelectableLevel x) => x.spawnableMapObjects).FirstOrDefault((Func<SpawnableMapObject, bool>)((SpawnableMapObject x) => ((Object)x.prefabToSpawn).name == "Landmine"));
			}
			if (!((Object)(object)val == (Object)null) && _landmine != null)
			{
				if (!((NetworkBehaviour)__instance).NetworkManager.IsHost && !((NetworkBehaviour)__instance).NetworkManager.IsServer)
				{
					LandminePatch.LastExplosionWasCharger = true;
					return;
				}
				LandminePatch.LastExplosionWasCharger = true;
				Debug.Log((object)"Explisuion time.");
				_justExploded = true;
				Vector3 val2 = ((Component)val).transform.position - new Vector3(0f, 0.25f, 0f);
				GameObject obj = Object.Instantiate<GameObject>(_landmine.prefabToSpawn, val2, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform);
				Landmine componentInChildren = obj.GetComponentInChildren<Landmine>();
				obj.GetComponent<NetworkObject>().Spawn(true);
				componentInChildren.ExplodeMineServerRpc();
				Unexplode();
			}
		}

		private static async Task Unexplode()
		{
			await Task.Delay(200);
			_justExploded = false;
		}

		public static void SendExplosionChat()
		{
			if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				int num = (int)GameNetworkManager.Instance.localPlayerController.playerClientId;
				HUDManager.Instance.AddTextToChatOnServer("<size=0>-" + num + "-iexplode</size>", num);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class InteractPerformedPatch
	{
		private static bool _swappingTwoHandedValue;

		[HarmonyPatch("Interact_performed")]
		[HarmonyPrefix]
		internal static void InteractPerformedPrefix(PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance.hoveringOverTrigger == (Object)null) && __instance.twoHanded)
			{
				Transform parent = ((Component)__instance.hoveringOverTrigger).transform.parent;
				if (!((Object)(object)parent == (Object)null) && !(((Object)((Component)parent).gameObject).name != "ChargeStationTrigger"))
				{
					_swappingTwoHandedValue = true;
					__instance.twoHanded = false;
				}
			}
		}

		[HarmonyPatch("Interact_performed")]
		[HarmonyPostfix]
		internal static void InteractPerformedPostfix(PlayerControllerB __instance)
		{
			if (_swappingTwoHandedValue)
			{
				_swappingTwoHandedValue = false;
				__instance.twoHanded = true;
			}
		}
	}
	[HarmonyPatch(typeof(ItemCharger))]
	internal class ItemChargerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool ItemChargerUpdate(ItemCharger __instance, ref float ___updateInterval, ref InteractTrigger ___triggerScript)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				return false;
			}
			if (___updateInterval > 1f)
			{
				___updateInterval = 0f;
				if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
				{
					GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
					if ((Object)(object)currentlyHeldObjectServer == (Object)null || (!currentlyHeldObjectServer.itemProperties.isConductiveMetal && !currentlyHeldObjectServer.itemProperties.requiresBattery))
					{
						___triggerScript.interactable = false;
						___triggerScript.disabledHoverTip = "(Requires battery-powered or metal item)";
					}
					else
					{
						___triggerScript.interactable = true;
					}
					___triggerScript.twoHandedItemAllowed = true;
					return false;
				}
			}
			___updateInterval += Time.deltaTime;
			return false;
		}

		[HarmonyPatch("ChargeItem")]
		[HarmonyPostfix]
		private static void ItemChargerCharge(ItemCharger __instance)
		{
			GrabbableObject currentlyHeldObjectServer = GameNetworkManager.Instance.localPlayerController.currentlyHeldObjectServer;
			if ((Object)(object)currentlyHeldObjectServer != (Object)null && !currentlyHeldObjectServer.itemProperties.requiresBattery && currentlyHeldObjectServer.itemProperties.isConductiveMetal)
			{
				LandminePatch.LastExplosionWasLocalPlayer = true;
				ChatPatch.SendExplosionChat();
			}
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatch
	{
		public static bool LastExplosionWasLocalPlayer;

		public static bool LastExplosionWasCharger;

		[HarmonyPatch("SpawnExplosion")]
		[HarmonyPrefix]
		private static bool SpawnExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Spawning explosion");
			Debug.Log((object)"Charger:");
			Debug.Log((object)LastExplosionWasCharger);
			Debug.Log((object)LastExplosionWasLocalPlayer);
			if (!LastExplosionWasCharger)
			{
				return true;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			Vector3 val = (((Component)localPlayerController.gameplayCamera).transform.position - explosionPosition) * 80f / Vector3.Distance(((Component)localPlayerController.gameplayCamera).transform.position, explosionPosition);
			if (LastExplosionWasLocalPlayer)
			{
				localPlayerController.KillPlayer(val, true, (CauseOfDeath)3, 0);
			}
			LastExplosionWasCharger = false;
			LastExplosionWasLocalPlayer = false;
			int num = ~LayerMask.GetMask(new string[1] { "Room" });
			num = ~LayerMask.GetMask(new string[1] { "Colliders" });
			Collider[] array = Physics.OverlapSphere(explosionPosition, 10f, num);
			for (int i = 0; i < array.Length; i++)
			{
				Rigidbody component = ((Component)array[i]).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddExplosionForce(70f, explosionPosition, 10f);
				}
			}
			return false;
		}
	}
}

plugins/YippeeScrap/SharedUtils.dll

Decompiled 10 months ago
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx.Logging;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
	private struct MonoScriptData
	{
		public byte[] FilePathsData;

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[85]
		{
			0, 0, 0, 1, 0, 0, 0, 34, 92, 65,
			115, 115, 101, 116, 115, 92, 83, 99, 114, 105,
			112, 116, 115, 92, 83, 104, 97, 114, 101, 100,
			92, 76, 111, 103, 85, 116, 105, 108, 115, 46,
			99, 115, 0, 0, 0, 1, 0, 0, 0, 35,
			92, 65, 115, 115, 101, 116, 115, 92, 83, 99,
			114, 105, 112, 116, 115, 92, 83, 104, 97, 114,
			101, 100, 92, 80, 97, 116, 104, 85, 116, 105,
			108, 115, 46, 99, 115
		};
		result.TypesData = new byte[51]
		{
			0, 0, 0, 0, 20, 83, 104, 97, 114, 101,
			100, 85, 116, 105, 108, 115, 124, 76, 111, 103,
			85, 116, 105, 108, 115, 0, 0, 0, 0, 21,
			83, 104, 97, 114, 101, 100, 85, 116, 105, 108,
			115, 124, 80, 97, 116, 104, 85, 116, 105, 108,
			115
		};
		result.TotalFiles = 2;
		result.TotalTypes = 2;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace SharedUtils;

public static class LogUtils
{
	private static Dictionary<Assembly, ManualLogSource> logSources = new Dictionary<Assembly, ManualLogSource>();

	public static void Init(string pluginGuid)
	{
		Assembly callingAssembly = Assembly.GetCallingAssembly();
		if (!logSources.ContainsKey(callingAssembly))
		{
			logSources.Add(callingAssembly, Logger.CreateLogSource(pluginGuid));
		}
	}

	public static void LogInfo(string message)
	{
		logSources[Assembly.GetCallingAssembly()].LogInfo((object)message);
	}

	public static void LogWarning(string message)
	{
		logSources[Assembly.GetCallingAssembly()].LogWarning((object)message);
	}

	public static void LogError(string message)
	{
		logSources[Assembly.GetCallingAssembly()].LogError((object)message);
	}

	public static void LogFatal(string message)
	{
		logSources[Assembly.GetCallingAssembly()].LogFatal((object)message);
	}
}
public static class PathUtils
{
	public static string PathForResourceInAssembly(string resourceName, Assembly assembly = null)
	{
		return Path.Combine(Path.GetDirectoryName((assembly ?? Assembly.GetCallingAssembly()).Location), resourceName);
	}
}

plugins/YippeeScrap/YippeeScrap.dll

Decompiled 10 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalLib.Modules;
using SharedUtils;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Audio;
using YippeeScrap.Assets.Mods.Yippee;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
	private struct MonoScriptData
	{
		public byte[] FilePathsData;

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[179]
		{
			0, 0, 0, 1, 0, 0, 0, 41, 92, 65,
			115, 115, 101, 116, 115, 92, 77, 111, 100, 115,
			92, 89, 105, 112, 112, 101, 101, 92, 76, 101,
			116, 104, 97, 108, 67, 111, 110, 102, 105, 103,
			67, 111, 109, 112, 97, 116, 46, 99, 115, 0,
			0, 0, 1, 0, 0, 0, 29, 92, 65, 115,
			115, 101, 116, 115, 92, 77, 111, 100, 115, 92,
			89, 105, 112, 112, 101, 101, 92, 80, 108, 117,
			103, 105, 110, 46, 99, 115, 0, 0, 0, 1,
			0, 0, 0, 33, 92, 65, 115, 115, 101, 116,
			115, 92, 77, 111, 100, 115, 92, 89, 105, 112,
			112, 101, 101, 92, 80, 108, 117, 103, 105, 110,
			73, 110, 102, 111, 46, 99, 115, 0, 0, 0,
			1, 0, 0, 0, 44, 92, 65, 115, 115, 101,
			116, 115, 92, 77, 111, 100, 115, 92, 89, 105,
			112, 112, 101, 101, 92, 85, 116, 105, 108, 115,
			92, 65, 117, 100, 105, 111, 77, 105, 120, 101,
			114, 70, 105, 120, 101, 114, 46, 99, 115
		};
		result.TypesData = new byte[136]
		{
			0, 0, 0, 0, 49, 89, 105, 112, 112, 101,
			101, 83, 99, 114, 97, 112, 46, 65, 115, 115,
			101, 116, 115, 46, 77, 111, 100, 115, 46, 89,
			105, 112, 112, 101, 101, 124, 76, 101, 116, 104,
			97, 108, 67, 111, 110, 102, 105, 103, 67, 111,
			109, 112, 97, 116, 0, 0, 0, 0, 18, 89,
			105, 112, 112, 101, 101, 83, 99, 114, 97, 112,
			124, 80, 108, 117, 103, 105, 110, 0, 0, 0,
			0, 22, 89, 105, 112, 112, 101, 101, 83, 99,
			114, 97, 112, 124, 80, 108, 117, 103, 105, 110,
			73, 110, 102, 111, 0, 0, 0, 0, 27, 89,
			105, 112, 112, 101, 101, 83, 99, 114, 97, 112,
			124, 65, 117, 100, 105, 111, 77, 105, 120, 101,
			114, 70, 105, 120, 101, 114
		};
		result.TotalFiles = 4;
		result.TotalTypes = 4;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace YippeeScrap
{
	[BepInPlugin("ainavt.lc.yippee", "YippeeScrap", "1.0.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private static Plugin instance;

		private static AssetBundle assetBundle;

		private static ConfigEntry<int> configRarity;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			LogUtils.Init("ainavt.lc.yippee");
			LoadScrap(PathUtils.PathForResourceInAssembly("ainavt_yippee", (Assembly)null), "Assets/mods/Yippee/Yippee.asset", "Yippee");
			LogUtils.LogInfo("YippeeScrap loaded!");
			harmony = new Harmony("ainavt.lc.yippee");
			harmony.PatchAll(typeof(Plugin));
		}

		private void LoadScrap(string assetBundlePath, string innerAssetPath, string name)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_004a: Expected O, but got Unknown
			configRarity = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("General", name + " Rarity"), 30, new ConfigDescription("How often " + name + " will show up. Higher value means more likely to show up", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			assetBundle = AssetBundle.LoadFromFile(assetBundlePath);
			Item obj = assetBundle.LoadAsset<Item>(innerAssetPath);
			if ((Object)(object)obj == (Object)null)
			{
				LogUtils.LogError("Failed to load " + name + " assets.");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(obj.spawnPrefab);
				Items.RegisterScrap(obj, configRarity.Value, (LevelTypes)(-1));
				LogUtils.LogInfo(name + " scrap loaded!");
			}
			configRarity.SettingChanged += delegate
			{
				ScrapItem val = ((IEnumerable<ScrapItem>)Items.scrapItems).FirstOrDefault((Func<ScrapItem, bool>)((ScrapItem i) => (Object)(object)i.item == (Object)(object)obj));
				if (val != null)
				{
					val.rarity = configRarity.Value;
				}
			};
			if (LethalConfigCompat.IsAvailable)
			{
				LethalConfigCompat.AddIntSlider(configRarity, restartRequired: false);
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void StartOfRoundAwake(ref StartOfRound __instance)
		{
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				foreach (SpawnableItemWithRarity item in val.spawnableScrap.Where((SpawnableItemWithRarity i) => i.spawnableItem.itemName == "Yippee"))
				{
					LogUtils.LogInfo($"Updating yippee rarity on {val.PlanetName} to {configRarity.Value}");
					item.rarity = configRarity.Value;
				}
			}
		}
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	internal struct PluginInfo
	{
		public const string Guid = "ainavt.lc.yippee";

		public const string Name = "YippeeScrap";

		public const string Version = "1.0.5";
	}
	public class AudioMixerFixer : MonoBehaviour
	{
		private static AudioMixerGroup _masterDiageticMixer;

		[SerializeField]
		private List<AudioSource> sourcesToFix;

		public static AudioMixerGroup MasterDiageticMixer
		{
			get
			{
				if ((Object)(object)_masterDiageticMixer == (Object)null)
				{
					AudioSource? obj = (from p in ((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().NetworkConfig.Prefabs.Prefabs
						select p.Prefab.GetComponentInChildren<NoisemakerProp>() into p
						where (Object)(object)p != (Object)null
						select ((Component)p).GetComponentInChildren<AudioSource>() into p
						where (Object)(object)p != (Object)null
						select p).FirstOrDefault();
					if ((Object)(object)obj == (Object)null)
					{
						throw new Exception("Failed to locate a suitable AudioSource output mixer to reference! Could you be calling this method before the GameNetworkManager is initialized?");
					}
					_masterDiageticMixer = obj.outputAudioMixerGroup;
				}
				return _masterDiageticMixer;
			}
		}

		private void Start()
		{
			AudioSource[] componentsInChildren = ((Component)this).GetComponentsInChildren<AudioSource>();
			foreach (AudioSource item in componentsInChildren)
			{
				if (!sourcesToFix.Contains(item))
				{
					sourcesToFix.Add(item);
				}
			}
			foreach (AudioSource item2 in sourcesToFix)
			{
				LogUtils.LogInfo("Replaced source to diagetic mixer.");
				item2.outputAudioMixerGroup = MasterDiageticMixer;
			}
		}
	}
}
namespace YippeeScrap.Assets.Mods.Yippee
{
	internal static class LethalConfigCompat
	{
		public const string GUID = "ainavt.lc.lethalconfig";

		public static bool IsAvailable => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddIntSlider(ConfigEntry<int> entry, bool restartRequired)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry, restartRequired));
		}
	}
}