using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; 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: AssemblyVersion("0.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace MoreScraps { [BepInPlugin("lonewolf.morescraps", "MoreScraps", "0.3.0")] public class Plugin : BaseUnityPlugin { private const string GUID = "lonewolf.morescraps"; private const string NAME = "MoreScraps"; private const string VERSION = "0.3.0"; private static AssetBundle MoreScrapsBundle; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Thanks for using MoreScraps-0.3.0 by JusteLoneWolf!"); try { LoadScraps(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "lonewolf.morescraps"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony integrated, MoreScraps loaded!"); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("{0} failed to load:\n{1}", "MoreScraps", arg)); } } private void LoadScraps() { //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MoreScrapsBundle != (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"MoreScraps AssetBundle is already loaded."); return; } string? directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (string.IsNullOrEmpty(directoryName)) { throw new DirectoryNotFoundException("Unable to locate the plugin folder."); } string text = Path.Combine(directoryName, "morescraps"); if (!File.Exists(text)) { throw new FileNotFoundException("Unable to find the AssetBundle 'morescraps'.", text); } MoreScrapsBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)MoreScrapsBundle == (Object)null) { throw new InvalidOperationException("Unable to load AssetBundle: " + text); } ScrapsDataManager scrapsDataManager = new ScrapsDataManager(); int num = 0; foreach (ScrapData asset in scrapsDataManager.Assets) { try { ((BaseUnityPlugin)this).Logger.LogDebug((object)("Loading: " + asset.AssetPath)); Item val = MoreScrapsBundle.LoadAsset(asset.AssetPath); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Unable to load Item: " + asset.AssetPath)); continue; } if ((Object)(object)val.spawnPrefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Missing spawnPrefab for '" + val.itemName + "'.")); continue; } NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(val.spawnPrefab); foreach (KeyValuePair spawnMoonsDatum in asset.SpawnMoonsData) { Items.RegisterScrap(val, spawnMoonsDatum.Value, spawnMoonsDatum.Key); ((BaseUnityPlugin)this).Logger.LogDebug((object)(val.itemName + " | " + $"Moon: {spawnMoonsDatum.Key} | " + $"Rarity: {spawnMoonsDatum.Value}")); } num++; ((BaseUnityPlugin)this).Logger.LogDebug((object)("Loaded: " + val.itemName)); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to load '{asset.AssetPath}':\n{arg}"); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Successfully loaded {num}/{scrapsDataManager.Assets.Count} scraps."); } } public class ScrapData { public string AssetPath { get; } public Dictionary SpawnMoonsData { get; } public ScrapData(string assetPath, Dictionary spawnMoonsData) { AssetPath = assetPath; SpawnMoonsData = spawnMoonsData; } } public class ScrapsDataManager { public List Assets { get; } public ScrapsDataManager() { Assets = new List(); InitializeAssets(); } private void InitializeAssets() { Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Battery/JusteLoneWolf_MoreScraps_Battery.asset", GetSpawnValues(30, 30, 30, 30, 30, 30, 20, 20, 24, 24, 25))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Battery/JusteLoneWolf_MoreScraps_PowerCell.asset", GetSpawnValues(2, 2, 2, 3, 3, 3, 1, 2, 2, 2, 2))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Ammo/JusteLoneWolf_MoreScraps_Ammo.asset", GetSpawnValues(15, 15, 15, 10, 10, 10, 10, 10, 10, 10, 10))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Bottle/JusteLoneWolf_MoreScraps_Bottle.asset", GetSpawnValues(50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Bucket/JusteLoneWolf_MoreScraps_Bucket.asset", GetSpawnValues(35, 35, 35, 35, 35, 35, 20, 20, 40, 40, 30))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Camera/JusteLoneWolf_MoreScraps_Camera.asset", GetSpawnValues(30, 30, 30, 40, 40, 40, 40, 50, 50, 40, 35))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Coffee/JusteLoneWolf_MoreScraps_Pot.asset", GetSpawnValues(30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Coffee/JusteLoneWolf_MoreScraps_Machine.asset", GetSpawnValues(2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/CopperWire/JusteLoneWolf_MoreScraps_CopperWire.asset", GetSpawnValues(40, 40, 40, 40, 40, 40, 10, 10, 35, 45, 35))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/GameBoy/JusteLoneWolf_MoreScraps_Gameboy.asset", GetSpawnValues(20, 20, 20, 25, 25, 25, 45, 45, 30, 25, 25))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/GPU/JusteLoneWolf_MoreScraps_GPU.asset", GetSpawnValues(4, 4, 4, 4, 5, 5, 3, 3, 4, 4, 4))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Gears/JusteLoneWolf_MoreScraps_Gears.asset", GetSpawnValues(40, 40, 40, 40, 10, 10, 30, 30, 35, 30, 30))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Hammer/JusteLoneWolf_MoreScraps_Hammer.asset", GetSpawnValues(40, 40, 40, 40, 20, 20, 40, 40, 40, 40, 35))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Jerrican/JusteLoneWolf_MoreScraps_Jerrican.asset", GetSpawnValues(20, 20, 20, 25, 10, 10, 20, 20, 20, 20, 20))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/MetalBeam/JusteLoneWolf_MoreScraps_MetalBeam.asset", GetSpawnValues(30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/HDD/JusteLoneWolf_MoreScraps_HDD.asset", GetSpawnValues(30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Monitor/JusteLoneWolf_MoreScraps_Monitor.asset", GetSpawnValues(1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Laptop/JusteLoneWolf_MoreScraps_Laptop.asset", GetSpawnValues(2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Microwave/JusteLoneWolf_MoreScraps_Microwave.asset", GetSpawnValues(2, 2, 2, 2, 3, 3, 1, 1, 2, 2, 2))); Assets.Add(new ScrapData("Assets/MoreScraps/Items/Scraps/Phone/JusteLoneWolf_MoreScraps_Phone.asset", GetSpawnValues(35, 35, 35, 35, 15, 15, 35, 35, 35, 35, 30))); } private Dictionary GetSpawnValues(params int[] values) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if (values == null || values.Length != 11) { throw new ArgumentException("GetSpawnValues doit recevoir exactement 11 valeurs : Experimentation, Assurance, Vow, Offense, March, Adamance, Rend, Dine, Titan, Embrion et Modded."); } string[][] array = new string[10][] { new string[1] { "ExperimentationLevel" }, new string[1] { "AssuranceLevel" }, new string[1] { "VowLevel" }, new string[2] { "OffenseLevel", "OffenceLevel" }, new string[1] { "MarchLevel" }, new string[1] { "AdamanceLevel" }, new string[1] { "RendLevel" }, new string[1] { "DineLevel" }, new string[1] { "TitanLevel" }, new string[1] { "EmbrionLevel" } }; Dictionary dictionary = new Dictionary(); for (int i = 0; i < array.Length; i++) { LevelTypes key = ParseLevel(array[i]); dictionary[key] = values[i]; } dictionary[(LevelTypes)1024] = values[10]; return dictionary; } private static LevelTypes ParseLevel(IEnumerable candidateNames) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) foreach (string candidateName in candidateNames) { if (Enum.TryParse(candidateName, ignoreCase: true, out LevelTypes result)) { return result; } } throw new InvalidOperationException("Impossible de trouver un niveau LethalLib attendu : " + string.Join(" ou ", candidateNames) + ". Vérifie que la DLL LethalLib utilisée correspond à la version du jeu."); } } }