Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of Command Essence v0.3.0
ExamplePlugin.dll
Decompiled 6 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using R2API.Utils; using RoR2; using UnityEngine; using UnityEngine.Networking; [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("ExamplePlugin")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ExamplePlugin")] [assembly: AssemblyTitle("ExamplePlugin")] [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 ExamplePlugin { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } } namespace CommandEssenceMod { public class CommandEssenceTier : MonoBehaviour { public ItemTier tier; } [BepInPlugin("com.yourname.commandessence", "Command Essence Replacer", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [R2APISubmoduleDependency(new string[] { "ItemAPI" })] public class CommandEssencePlugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Start <>9__9_0; internal void <Awake>b__9_0(orig_Start orig, Run self) { orig.Invoke(self); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterMaster master = instance.master; if ((Object)(object)master != (Object)null) { master.money = 25u; } } } } public const string PluginGUID = "com.yourname.commandessence"; public const string PluginName = "Command Essence Replacer"; public const string PluginVersion = "1.0.0"; private ConfigEntry<bool> enableMod; private ConfigEntry<float> whiteItemChance; private ConfigEntry<float> greenItemChance; private ConfigEntry<float> redItemChance; private ConfigEntry<float> lunarItemChance; private ConfigEntry<float> equipmentChance; private bool showGUI = false; private Rect windowRect = new Rect(20f, 20f, 380f, 350f); private string whiteItemText = ""; private string greenItemText = ""; private string redItemText = ""; private string lunarItemText = ""; private string equipmentText = ""; private void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Mod", true, "Enable/disable the mod"); whiteItemChance = ((BaseUnityPlugin)this).Config.Bind<float>("Item Chances", "White Item Chance", 50f, new ConfigDescription("Percentage chance to replace white items with command essences (0-100)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); greenItemChance = ((BaseUnityPlugin)this).Config.Bind<float>("Item Chances", "Green Item Chance", 50f, new ConfigDescription("Percentage chance to replace green items with command essences (0-100)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); redItemChance = ((BaseUnityPlugin)this).Config.Bind<float>("Item Chances", "Red Item Chance", 50f, new ConfigDescription("Percentage chance to replace red items with command essences (0-100)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); lunarItemChance = ((BaseUnityPlugin)this).Config.Bind<float>("Item Chances", "Lunar Item Chance", 0f, new ConfigDescription("Percentage chance to replace lunar items with command essences (0-100)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); equipmentChance = ((BaseUnityPlugin)this).Config.Bind<float>("Item Chances", "Equipment Chance", 50f, new ConfigDescription("Percentage chance to replace equipment with command essences (0-100)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnGameLoad)); object obj = <>c.<>9__9_0; if (obj == null) { hook_Start val = delegate(orig_Start orig, Run self) { orig.Invoke(self); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterMaster master = instance.master; if ((Object)(object)master != (Object)null) { master.money = 25u; } } }; <>c.<>9__9_0 = val; obj = (object)val; } Run.Start += (hook_Start)obj; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Command Essence Replacer loaded!"); } private void OnGameLoad() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GenericPickupController.Start += new hook_Start(OnPickupControllerStart); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Command essence hooks initialized!"); } private void OnPickupControllerStart(orig_Start orig, GenericPickupController self) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Invalid comparison between Unknown and I4 //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (!enableMod.Value || !NetworkServer.active || !(self.pickupIndex != PickupIndex.none)) { return; } PickupDef pickupDef = PickupCatalog.GetPickupDef(self.pickupIndex); if (pickupDef == null) { return; } if ((int)pickupDef.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if ((Object)(object)itemDef != (Object)null && ShouldReplaceItem(itemDef.tier)) { CreateItemCommandCube(self, itemDef.tier); } } else if ((int)pickupDef.equipmentIndex != -1 && ShouldReplaceEquipment()) { CreateEquipmentCommandCube(self); } } private void CreateItemCommandCube(GenericPickupController originalPickup, ItemTier tier) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> availableItemsOfTier = GetAvailableItemsOfTier(tier); if (availableItemsOfTier.Count > 0) { GameObject commandCube = CreateCommandCube(originalPickup, availableItemsOfTier); SetCommandCubeColor(commandCube, tier); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Replaced item with {tier} command essence"); } } private void CreateEquipmentCommandCube(GenericPickupController originalPickup) { List<PickupIndex> availableEquipment = GetAvailableEquipment(); if (availableEquipment.Count > 0) { GameObject commandCubeColorEquipment = CreateCommandCube(originalPickup, availableEquipment); SetCommandCubeColorEquipment(commandCubeColorEquipment); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Replaced equipment with command essence"); } } private GameObject CreateCommandCube(GenericPickupController originalPickup, List<PickupIndex> availablePickups) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/CommandCube"); if ((Object)(object)val != (Object)null) { GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)originalPickup).transform.position, Quaternion.identity); PickupPickerController component = val2.GetComponent<PickupPickerController>(); if ((Object)(object)component != (Object)null) { Option[] array = (Option[])(object)new Option[availablePickups.Count]; for (int i = 0; i < availablePickups.Count; i++) { array[i] = new Option { pickupIndex = availablePickups[i], available = true }; } component.options = array; CommandEssencePickerBehavior commandEssencePickerBehavior = val2.AddComponent<CommandEssencePickerBehavior>(); commandEssencePickerBehavior.plugin = this; } NetworkServer.Spawn(val2); Object.Destroy((Object)(object)((Component)originalPickup).gameObject); return val2; } return null; } private void SetCommandCubeColor(GameObject commandCube, ItemTier tier) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) Renderer componentInChildren = commandCube.GetComponentInChildren<Renderer>(); if ((Object)(object)componentInChildren != (Object)null) { Material material = componentInChildren.material; if ((Object)(object)material != (Object)null) { material.color = GetTierColor(tier); } } Highlight component = commandCube.GetComponent<Highlight>(); if (!((Object)(object)component != (Object)null)) { return; } Type type = ((object)component).GetType(); FieldInfo field = type.GetField("color"); if (field != null) { field.SetValue(component, GetTierColor(tier)); } else { FieldInfo field2 = type.GetField("highlightColor"); if (field2 != null && field2.FieldType == typeof(Color)) { field2.SetValue(component, GetTierColor(tier)); } } component.isOn = true; } private void SetCommandCubeColorEquipment(GameObject commandCube) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Color equipmentColor = GetEquipmentColor(); Renderer componentInChildren = commandCube.GetComponentInChildren<Renderer>(); if ((Object)(object)componentInChildren != (Object)null) { Material material = componentInChildren.material; if ((Object)(object)material != (Object)null) { material.color = equipmentColor; } } Highlight component = commandCube.GetComponent<Highlight>(); if (!((Object)(object)component != (Object)null)) { return; } Type type = ((object)component).GetType(); FieldInfo field = type.GetField("color"); if (field != null) { field.SetValue(component, equipmentColor); } else { FieldInfo field2 = type.GetField("highlightColor"); if (field2 != null && field2.FieldType == typeof(Color)) { field2.SetValue(component, equipmentColor); } } component.isOn = true; } private Color GetTierColor(ItemTier tier) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected I4, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color32 val = (Color32)((int)tier switch { 0 => ColorCatalog.GetColor((ColorIndex)1), 1 => ColorCatalog.GetColor((ColorIndex)2), 2 => ColorCatalog.GetColor((ColorIndex)3), 3 => ColorCatalog.GetColor((ColorIndex)4), _ => ColorCatalog.GetColor((ColorIndex)1), }); if (1 == 0) { } Color32 val2 = val; return new Color((float)(int)val2.r / 255f, (float)(int)val2.g / 255f, (float)(int)val2.b / 255f, (float)(int)val2.a / 255f); } private Color GetEquipmentColor() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Color32 color = ColorCatalog.GetColor((ColorIndex)5); return new Color((float)(int)color.r / 255f, (float)(int)color.g / 255f, (float)(int)color.b / 255f, (float)(int)color.a / 255f); } private List<PickupIndex> GetAvailableItemsOfTier(ItemTier tier) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) List<PickupIndex> list = new List<PickupIndex>(); for (ItemIndex val = (ItemIndex)0; (int)val < ItemCatalog.itemCount; val = (ItemIndex)(val + 1)) { ItemDef itemDef = ItemCatalog.GetItemDef(val); if ((Object)(object)itemDef != (Object)null && itemDef.tier == tier && !itemDef.hidden && itemDef.canRemove) { PickupIndex val2 = PickupCatalog.FindPickupIndex(val); if (val2 != PickupIndex.none) { list.Add(val2); } } } return list; } private List<PickupIndex> GetAvailableEquipment() { //IL_0008: 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) //IL_006c: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = new List<PickupIndex>(); for (EquipmentIndex val = (EquipmentIndex)0; (int)val < EquipmentCatalog.equipmentCount; val = (EquipmentIndex)(val + 1)) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(val); if ((Object)(object)equipmentDef != (Object)null && equipmentDef.canDrop && !equipmentDef.isBoss && !equipmentDef.isLunar) { PickupIndex val2 = PickupCatalog.FindPickupIndex(val); if (val2 != PickupIndex.none) { list.Add(val2); } } } return list; } private bool ShouldReplaceItem(ItemTier tier) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected I4, but got Unknown if (1 == 0) { } float num = (int)tier switch { 0 => whiteItemChance.Value, 1 => greenItemChance.Value, 2 => redItemChance.Value, 3 => lunarItemChance.Value, _ => 0f, }; if (1 == 0) { } float num2 = num; return num2 > 0f && Random.Range(0f, 100f) < num2; } private bool ShouldReplaceEquipment() { return equipmentChance.Value > 0f && Random.Range(0f, 100f) < equipmentChance.Value; } private void Update() { if (Input.GetKeyDown((KeyCode)289)) { showGUI = !showGUI; if (showGUI) { whiteItemText = whiteItemChance.Value.ToString("F1"); greenItemText = greenItemChance.Value.ToString("F1"); redItemText = redItemChance.Value.ToString("F1"); lunarItemText = lunarItemChance.Value.ToString("F1"); equipmentText = equipmentChance.Value.ToString("F1"); } } } private void OnGUI() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0025: 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) if (showGUI) { windowRect = GUI.Window(0, windowRect, new WindowFunction(DoGUI), "Command Essence Settings"); } } private void DoGUI(int windowID) { GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); bool flag = GUILayout.Toggle(enableMod.Value, "Enable Mod", Array.Empty<GUILayoutOption>()); if (flag != enableMod.Value) { enableMod.Value = flag; } GUILayout.Space(10f); GUILayout.Label("Item Replacement Chances:", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"White Items: {whiteItemChance.Value:F1}%", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); string text = GUILayout.TextField(whiteItemText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (text != whiteItemText) { whiteItemText = text; if (float.TryParse(whiteItemText, out var result)) { whiteItemChance.Value = Mathf.Clamp(result, 0f, 100f); } } GUILayout.EndHorizontal(); float num = GUILayout.HorizontalSlider(whiteItemChance.Value, 0f, 100f, Array.Empty<GUILayoutOption>()); if (Mathf.Abs(num - whiteItemChance.Value) > 0.1f) { whiteItemChance.Value = num; whiteItemText = whiteItemChance.Value.ToString("F1"); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Green Items: {greenItemChance.Value:F1}%", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); string text2 = GUILayout.TextField(greenItemText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (text2 != greenItemText) { greenItemText = text2; if (float.TryParse(greenItemText, out var result2)) { greenItemChance.Value = Mathf.Clamp(result2, 0f, 100f); } } GUILayout.EndHorizontal(); float num2 = GUILayout.HorizontalSlider(greenItemChance.Value, 0f, 100f, Array.Empty<GUILayoutOption>()); if (Mathf.Abs(num2 - greenItemChance.Value) > 0.1f) { greenItemChance.Value = num2; greenItemText = greenItemChance.Value.ToString("F1"); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Red Items: {redItemChance.Value:F1}%", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); string text3 = GUILayout.TextField(redItemText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (text3 != redItemText) { redItemText = text3; if (float.TryParse(redItemText, out var result3)) { redItemChance.Value = Mathf.Clamp(result3, 0f, 100f); } } GUILayout.EndHorizontal(); float num3 = GUILayout.HorizontalSlider(redItemChance.Value, 0f, 100f, Array.Empty<GUILayoutOption>()); if (Mathf.Abs(num3 - redItemChance.Value) > 0.1f) { redItemChance.Value = num3; redItemText = redItemChance.Value.ToString("F1"); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Lunar Items: {lunarItemChance.Value:F1}%", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); string text4 = GUILayout.TextField(lunarItemText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (text4 != lunarItemText) { lunarItemText = text4; if (float.TryParse(lunarItemText, out var result4)) { lunarItemChance.Value = Mathf.Clamp(result4, 0f, 100f); } } GUILayout.EndHorizontal(); float num4 = GUILayout.HorizontalSlider(lunarItemChance.Value, 0f, 100f, Array.Empty<GUILayoutOption>()); if (Mathf.Abs(num4 - lunarItemChance.Value) > 0.1f) { lunarItemChance.Value = num4; lunarItemText = lunarItemChance.Value.ToString("F1"); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Equipment: {equipmentChance.Value:F1}%", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); string text5 = GUILayout.TextField(equipmentText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (text5 != equipmentText) { equipmentText = text5; if (float.TryParse(equipmentText, out var result5)) { equipmentChance.Value = Mathf.Clamp(result5, 0f, 100f); } } GUILayout.EndHorizontal(); float num5 = GUILayout.HorizontalSlider(equipmentChance.Value, 0f, 100f, Array.Empty<GUILayoutOption>()); if (Mathf.Abs(num5 - equipmentChance.Value) > 0.1f) { equipmentChance.Value = num5; equipmentText = equipmentChance.Value.ToString("F1"); } if (GUILayout.Button("Close", Array.Empty<GUILayoutOption>())) { showGUI = false; } GUILayout.EndVertical(); GUI.DragWindow(); } internal void GiveItemToBody(CharacterBody body, PickupIndex pickupIndex) { //IL_0001: 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_001b: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (pickupDef != null) { if ((int)pickupDef.itemIndex != -1) { body.inventory.GiveItem(pickupDef.itemIndex, 1); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Gave selected item: " + pickupDef.nameToken)); } else if ((int)pickupDef.equipmentIndex != -1) { body.inventory.SetEquipmentIndex(pickupDef.equipmentIndex); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Gave selected equipment: " + pickupDef.nameToken)); } } } private void OnDestroy() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GenericPickupController.Start -= new hook_Start(OnPickupControllerStart); } } public class CommandEssencePickerBehavior : MonoBehaviour { public CommandEssencePlugin plugin; private void Start() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown PickupPickerController component = ((Component)this).GetComponent<PickupPickerController>(); if ((Object)(object)component != (Object)null) { PickupPickerController.SubmitChoice += new hook_SubmitChoice(OnSubmitChoice); } } private void OnSubmitChoice(orig_SubmitChoice orig, PickupPickerController self, int choiceIndex) { //IL_005c: 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_0069: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)self).gameObject == (Object)(object)((Component)this).gameObject && (Object)(object)plugin != (Object)null) { CharacterBody val = FindInteractingPlayer(self); if ((Object)(object)val != (Object)null && choiceIndex >= 0 && choiceIndex < self.options.Length) { PickupIndex pickupIndex = self.options[choiceIndex].pickupIndex; plugin.GiveItemToBody(val, pickupIndex); if (NetworkServer.active) { Object.Destroy((Object)(object)((Component)self).gameObject); } return; } } orig.Invoke(self, choiceIndex); } private CharacterBody FindInteractingPlayer(PickupPickerController picker) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) CharacterBody result = null; float num = float.MaxValue; foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { if (Object.op_Implicit((Object)(object)readOnlyInstances) && Object.op_Implicit((Object)(object)readOnlyInstances.teamComponent) && (int)readOnlyInstances.teamComponent.teamIndex == 1) { float num2 = Vector3.Distance(((Component)picker).transform.position, readOnlyInstances.transform.position); if (num2 < num && num2 < 10f) { num = num2; result = readOnlyInstances; } } } return result; } private void OnDestroy() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown PickupPickerController.SubmitChoice -= new hook_SubmitChoice(OnSubmitChoice); } } }