Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of TeleporterDropToInventory v1.1.0
TeleporterDropToInventory.dll
Decompiled 11 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 System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using RoR2; using UnityEngine; [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("TeleporterDropToInventory")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a897b231b6d6ca5be9cf94c9d8d421184bf7d240")] [assembly: AssemblyProduct("TeleporterDropToInventory")] [assembly: AssemblyTitle("TeleporterDropToInventory")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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.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 TeleporterDropToInventory { [BepInIncompatibility("shbones.MoreMountains")] [BepInPlugin("com.Moffein.TeleporterDropToInventory", "TeleporterDropToInventory", "1.1.0")] public class TeleporterDropToInventoryPlugin : BaseUnityPlugin { public static ConfigEntry<bool> printToChat; public static ConfigEntry<bool> requireAlive; public static ConfigEntry<bool> randomizeOrder; public static bool blacklistCommand; public static string blacklistedArtifactsString; public static HashSet<ArtifactDef> blacklistedArtifacts = new HashSet<ArtifactDef>(); private void Awake() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown printToChat = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Print to Chat", false, "Print drops to chat."); requireAlive = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Require Alive", false, "Only drop items to living players."); blacklistCommand = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Blacklist Command", true, "This mod does not take effect if Command is enabled.").Value; blacklistedArtifactsString = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "Blacklisted Artifacts", "", "Disable this mod when any of these artifacts are enabled. Comma separated list (ex. Sacrifice, Command, Vengeance).").Value; randomizeOrder = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Randomize Order", true, "Randomize drop order so it doesn't always start with the host."); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); BossGroup.DropRewards += new hook_DropRewards(BossGroup_DropRewards); } private void OnLoad() { if (blacklistCommand) { blacklistedArtifacts.Add(Artifacts.Command); } if (blacklistedArtifactsString.Trim().Length <= 0) { return; } string[] array = blacklistedArtifactsString.Split(","); string[] array2 = array; foreach (string text in array2) { string text2 = text.Trim(); ArtifactDef val = ArtifactCatalog.FindArtifactDef(text2); if (!Object.op_Implicit((Object)(object)val)) { val = GetArtifactDefFromString(text2); } if (Object.op_Implicit((Object)(object)val)) { blacklistedArtifacts.Add(val); } } } private static bool BlacklistedArtifactEnabled() { if (Object.op_Implicit((Object)(object)RunArtifactManager.instance)) { foreach (ArtifactDef blacklistedArtifact in blacklistedArtifacts) { if (RunArtifactManager.instance.IsArtifactEnabled(blacklistedArtifact)) { return true; } } } return false; } private static void BossGroup_DropRewards(orig_DropRewards orig, BossGroup self) { if (!BlacklistedArtifactEnabled()) { DropRewardsToInventory(self); } else { orig.Invoke(self); } } private static void DropRewardsToInventory(BossGroup self) { //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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Invalid comparison between Unknown and I4 //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Invalid comparison between Unknown and I4 //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Run.instance)) { Debug.LogError((object)"No valid run instance!"); return; } if (self.rng == null) { Debug.LogError((object)"RNG is null!"); return; } if (!Object.op_Implicit((Object)(object)self.dropPosition)) { Debug.LogWarning((object)"dropPosition not set for BossGroup! No item will be spawned."); return; } int participatingPlayerCount = Run.instance.participatingPlayerCount; if (participatingPlayerCount == 0) { return; } PickupIndex none = PickupIndex.none; if (Object.op_Implicit((Object)(object)self.dropTable)) { none = self.dropTable.GenerateDrop(self.rng); } else { List<PickupIndex> list = Run.instance.availableTier2DropList; if (self.forceTier3Reward) { list = Run.instance.availableTier3DropList; } none = self.rng.NextElementUniform<PickupIndex>(list); } ItemIndex val = (ItemIndex)(-1); PickupDef pickupDef = PickupCatalog.GetPickupDef(none); if (pickupDef != null && (int)pickupDef.itemIndex != -1) { val = pickupDef.itemIndex; } int num = 1 + self.bonusRewardCount; if (self.scaleRewardsByPlayerCount) { num *= participatingPlayerCount; } Queue<ItemIndex> queue = new Queue<ItemIndex>(); bool flag = self.bossDrops != null && self.bossDrops.Count > 0; bool flag2 = self.bossDropTables != null && self.bossDropTables.Count > 0; if (self.bossDrops != null && (flag || flag2)) { for (int i = 0; i < num; i++) { PickupIndex val2 = PickupIndex.none; if (self.rng.nextNormalizedFloat <= self.bossDropChance) { if (flag2) { PickupDropTable val3 = self.rng.NextElementUniform<PickupDropTable>(self.bossDropTables); if ((Object)(object)val3 != (Object)null) { val2 = val3.GenerateDrop(self.rng); } } else { val2 = self.rng.NextElementUniform<PickupIndex>(self.bossDrops); } } if (val2 != PickupIndex.none) { PickupDef pickupDef2 = PickupCatalog.GetPickupDef(val2); if (pickupDef2 != null && (int)pickupDef2.itemIndex != -1) { queue.Enqueue(pickupDef2.itemIndex); } } } } int num2 = 0; int count = PlayerCharacterMasterController.instances.Count; int num3 = 0; int num4 = 0; bool flag3 = true; if (randomizeOrder.Value) { num3 = Random.Range(0, count); } while (num2 < num) { int num5 = num2; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (num4 < num3) { num4++; } else { if (!Object.op_Implicit((Object)(object)instance.master) || !Object.op_Implicit((Object)(object)instance.master.inventory) || (requireAlive.Value && instance.master.IsDeadAndOutOfLivesServer())) { continue; } PickupDef val4 = pickupDef; ItemIndex val5 = val; if (queue.Count > 0) { val5 = queue.Dequeue(); PickupIndex val6 = PickupCatalog.FindPickupIndex(val5); val4 = PickupCatalog.GetPickupDef(val6); } if (printToChat.Value) { CharacterBody body = instance.master.GetBody(); if (Object.op_Implicit((Object)(object)body)) { Chat.AddPickupMessage(body, val4?.nameToken ?? PickupCatalog.invalidPickupToken, Color32.op_Implicit(val4?.baseColor ?? Color.black), 1u); } } instance.master.inventory.GiveItem(val5, 1); num2++; } } if (num2 == num5 && !flag3) { break; } flag3 = false; } } private static ArtifactDef GetArtifactDefFromString(string partialName) { ArtifactDef val = ArtifactCatalog.FindArtifactDef(partialName); if (Object.op_Implicit((Object)(object)val)) { return val; } ArtifactDef[] artifactDefs = ArtifactCatalog.artifactDefs; foreach (ArtifactDef val2 in artifactDefs) { if (GetArgNameForAtrifact(val2).ToLower().Contains(partialName.ToLower())) { return val2; } } return null; } private static string GetArgNameForAtrifact(ArtifactDef artifactDef) { return Regex.Replace(Language.GetString(artifactDef.nameToken), "[ '-]", string.Empty); } } } namespace R2API.Utils { [AttributeUsage(AttributeTargets.Assembly)] public class ManualNetworkRegistrationAttribute : Attribute { } }