Decompiled source of REPO Enemy Drops v2.0.0

REPO_Enemy_Drops.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using MelonLoader;
using MelonLoader.Utils;
using Newtonsoft.Json;
using REPO_Enemy_Drops;
using Repo_Library;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Mod), "R.E.P.O Enemy Drops", "2.0.0", "ImVertro", null)]
[assembly: MelonGame("semiwork", "REPO")]
[assembly: AssemblyTitle("REPO_Enemy_Drops")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO_Enemy_Drops")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("18cb529d-6807-40d7-8b22-fe6311610c03")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public class Config
{
	public Dictionary<string, Dictionary<string, Dictionary<string, Dictionary<string, float>>>> Entities { get; set; } = new Dictionary<string, Dictionary<string, Dictionary<string, Dictionary<string, float>>>>();

}
namespace REPO_Enemy_Drops;

public class Mod : MelonMod
{
	private readonly Library Repo_Lib = new Library();

	private readonly string configPath = Path.Combine(MelonEnvironment.UserDataDirectory, "repo_enemy_drops_config.json");

	[Obsolete]
	public override void OnApplicationStart()
	{
		Config config = ReadConfigFile(configPath);
		Library.OnEnemyDeath += delegate(GameObject enemy)
		{
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			string text = ((Object)enemy).name.Replace("Enemy -", "").Replace("(Clone)", "").Trim();
			object obj;
			if (enemy == null)
			{
				obj = null;
			}
			else
			{
				Transform obj2 = enemy.transform.Find("Enable");
				obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
			}
			GameObject val = (GameObject)obj;
			object obj3;
			if (val == null)
			{
				obj3 = null;
			}
			else
			{
				Transform obj4 = val.transform.Find("Controller");
				obj3 = ((obj4 != null) ? ((Component)obj4).gameObject : null);
			}
			GameObject val2 = (GameObject)obj3;
			Dictionary<string, Dictionary<string, Dictionary<string, float>>> value;
			Dictionary<string, Dictionary<string, float>> value2;
			if ((Object)(object)val2 == (Object)null)
			{
				MelonLogger.Error("Controller not found in enemy hierarchy.");
			}
			else if (config.Entities.TryGetValue(text, out value) && value.TryGetValue("Items", out value2))
			{
				string key = value2.ElementAt(Random.Range(0, value2.Count)).Key;
				if (value2[key].TryGetValue("Chance", out var value3) && Random.Range(0f, 1f) < value3)
				{
					Repo_Lib.SpawnItem(key, val2.transform.position + val2.transform.up * 2f);
				}
			}
			else
			{
				MelonLogger.Error("No config found for enemy: " + text);
			}
		};
	}

	public override void OnApplicationQuit()
	{
	}

	private void WriteConfigFile(string path, Config config)
	{
		try
		{
			string contents = JsonConvert.SerializeObject((object)RemoveDuplicates(config), (Formatting)1);
			File.WriteAllText(path, contents);
		}
		catch (Exception ex)
		{
			throw new Exception("Failed to write config file: " + ex.Message, ex);
		}
	}

	private Config RemoveDuplicates(Config config)
	{
		config.Entities = config.Entities.Distinct().ToDictionary((KeyValuePair<string, Dictionary<string, Dictionary<string, Dictionary<string, float>>>> x) => x.Key, (KeyValuePair<string, Dictionary<string, Dictionary<string, Dictionary<string, float>>>> x) => x.Value);
		return config;
	}

	private Config ReadConfigFile(string path)
	{
		if (File.Exists(path))
		{
			string text = File.ReadAllText(path);
			Config config = JsonConvert.DeserializeObject<Config>(text);
			MelonLogger.Msg("Config file loaded from " + path + ".");
			WriteConfigFile(path, config);
			return config;
		}
		MelonLogger.Msg("Config file not found at " + path + ". Creating a new one.");
		Config config2 = CreateDefaultConfig(path);
		WriteConfigFile(path, config2);
		return config2;
	}

	private Config CreateDefaultConfig(string path)
	{
		return new Config
		{
			Entities = new Dictionary<string, Dictionary<string, Dictionary<string, Dictionary<string, float>>>>
			{
				{
					"Gnome",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							}
						}
					} }
				},
				{
					"Bang",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 0.1f } }
							}
						}
					} }
				},
				{
					"Head",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Slow Walker",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Robe",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Duck",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Runner",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Slow Mouth",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Floater",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Thin Man",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Hunter",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Bowtie",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Beamer",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Valuable Thrower",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Upscream",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Tumbler",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Animal",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				},
				{
					"Hidden",
					new Dictionary<string, Dictionary<string, Dictionary<string, float>>> { 
					{
						"Items",
						new Dictionary<string, Dictionary<string, float>>
						{
							{
								"Item Upgrade Player Extra Jump",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Range",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Energy",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Grab Strength",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Health",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Sprint Speed",
								new Dictionary<string, float> { { "Chance", 1f } }
							},
							{
								"Item Upgrade Player Tumble Launch",
								new Dictionary<string, float> { { "Chance", 1f } }
							}
						}
					} }
				}
			}
		};
	}
}