Decompiled source of YippeeScrap v1.0.7

plugins/YippeeScrap/SharedUtils.dll

Decompiled 8 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 8 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 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.7")]
	[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 void Awake()
		{
			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!");
		}

		private void LoadScrap(string assetBundlePath, string innerAssetPath, string name)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0044: 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 val = assetBundle.LoadAsset<Item>(innerAssetPath);
			if ((Object)(object)val == (Object)null)
			{
				LogUtils.LogError("Failed to load " + name + " assets.");
			}
			else
			{
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, configRarity.Value, (LevelTypes)(-1));
				LogUtils.LogInfo(name + " scrap loaded!");
			}
			if (LethalConfigCompat.IsAvailable)
			{
				LethalConfigCompat.AddIntSlider(configRarity, restartRequired: true);
			}
		}
	}
	[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.7";
	}
	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));
		}
	}
}