using 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On.RoR2; using R2API; using RoR2; using ThinkInvisible.Jfork.Yeet; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Yeet")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BalancedYeet")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BalancedYeet")] [assembly: AssemblyTitle("BalancedYeet")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 BalancedYeet { [BepInPlugin("Bloonjitsu7.BalancedYeet", "BalancedYeet", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BalancedYeetPlugin : BaseUnityPlugin { public struct YeetTrackerInfo { public ItemIndex itemIndex; public CostTypeIndex costType; public int count; public YeetTrackerInfo(ItemIndex itemIndex, CostTypeIndex costType, int count) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) this.itemIndex = itemIndex; this.costType = costType; this.count = count; } } public class YeetTracker : MonoBehaviour { public CharacterBody body; public List yeetTrackers = new List(); public string stageName = ""; } public const string PluginGUID = "Bloonjitsu7.BalancedYeet"; public const string PluginAuthor = "Bloonjitsu7"; public const string PluginName = "BalancedYeet"; public const string PluginVersion = "1.0.0"; public static bool dropCooldown = false; public ILHook yeetHook; public static CostTypeIndex[] bannedCosts; public void Awake() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMCOMMON", "{0} cannot spend Common items, as they have yeeted a Common item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMCOMMON_2P", "You cannot spend Common items, as you have yeeted a Common item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMUNCOMMON", "{0} cannot spend Uncommon items, as they have yeeted an Uncommon item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMUNCOMMON_2P", "You cannot spend Uncommon items, as you have yeeted an Uncommon item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMLEGENDARY", "{0} cannot spend Legendary items, as they have yeeted a Legendary item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMLEGENDARY_2P", "You cannot spend Legendary items, as you have yeeted a Legendary item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMBOSS", "{0} cannot spend Boss items, as they have yeeted a Boss item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMBOSS_2P", "You cannot spend Boss items, as you have yeeted a Boss item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMLUNAR", "{0} cannot spend Lunar items, as they have yeeted a Lunar item this stage and not picked it back up."); LanguageAPI.Add("PLAYER_YEET_FAILEDPURCHASEITEMLUNAR_2P", "You cannot spend Lunar items, as you have yeeted a Lunar item this stage and not picked it back up."); PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(OnPurchaseBegin); MethodInfo methodInfo = AccessTools.Method(typeof(YeetPlugin), "ConCmdYeet", (Type[])null, (Type[])null); yeetHook = new ILHook((MethodBase)methodInfo, new Manipulator(IL_YeetCheck)); } public void OnPurchaseBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor interactor) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0031: 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_0056: Expected I4, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected I4, but got Unknown //IL_0059: 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_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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) bool flag = true; if ((Object)(object)((Component)interactor).gameObject != (Object)null) { YeetTracker component = ((Component)interactor).gameObject.GetComponent(); ItemTier val = (ItemTier)5; CostTypeIndex costType = self.costType; CostTypeIndex val2 = costType; switch (val2 - 4) { case 0: val = (ItemTier)0; break; case 1: val = (ItemTier)1; break; case 2: val = (ItemTier)2; break; case 6: val = (ItemTier)4; break; case 5: val = (ItemTier)3; break; } if ((Object)(object)component != (Object)null && (Object)(object)component.body != (Object)null && (Object)(object)component.body.inventory != (Object)null) { int num = 0; ItemDef[] itemDefs = ItemCatalog.itemDefs; foreach (ItemDef val3 in itemDefs) { if (val3.tier == val && (val3.ContainsTag((ItemTag)14) || val3.ContainsTag((ItemTag)10))) { num += component.body.inventory.GetItemCountEffective(val3); } } Log.Message(num); if (num < self.cost) { if (Object.op_Implicit((Object)(object)Stage.instance) && Object.op_Implicit((Object)(object)Stage.instance.sceneDef) && component.stageName != Stage.instance.sceneDef.nameToken) { component.yeetTrackers.Clear(); component.stageName = Stage.instance.sceneDef.nameToken; } foreach (YeetTrackerInfo yeetTracker in component.yeetTrackers) { if (self.costType == yeetTracker.costType) { if (component.body.inventory.GetItemCountPermanent(yeetTracker.itemIndex) < yeetTracker.count) { flag = false; } else { component.yeetTrackers.Remove(yeetTracker); } } } } } } if (flag) { orig.Invoke(self, interactor); return; } Util.PlaySound("Play_GG_StageEvent_AccessCodes_WrongActivation", ((Component)self).gameObject); string baseToken = ""; CostTypeIndex costType2 = self.costType; CostTypeIndex val4 = costType2; switch (val4 - 4) { case 0: baseToken = "PLAYER_YEET_FAILEDPURCHASEITEMCOMMON"; break; case 1: baseToken = "PLAYER_YEET_FAILEDPURCHASEITEMUNCOMMON"; break; case 2: baseToken = "PLAYER_YEET_FAILEDPURCHASEITEMLEGENDARY"; break; case 6: baseToken = "PLAYER_YEET_FAILEDPURCHASEITEMBOSS"; break; case 5: baseToken = "PLAYER_YEET_FAILEDPURCHASEITEMLUNAR"; break; } Chat.SendBroadcastChat((ChatMessageBase)new SubjectChatMessage { subjectAsCharacterBody = ((Component)interactor).GetComponent(), baseToken = baseToken }); } public void IL_YeetCheck(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MoveType val2 = (MoveType)0; MoveType val3 = (MoveType)2; int itemLoc = -1; Func[] array = new Func[1]; if (val.TryGotoNext(val3, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(ItemCatalog), "GetItemDef"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref itemLoc) })) { int num = default(int); CostTypeIndex val4 = default(CostTypeIndex); if (val.TryGotoNext(val2, new Func[6] { (Instruction x) => ILPatternMatchingExt.MatchLdarga(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val4), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, ref val4), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, typeof(Inventory), "RemoveItemPermanent") })) { val.Emit(OpCodes.Ldarg, 0); val.Emit(OpCodes.Ldloc, itemLoc); val.EmitDelegate>((Action)delegate(ConCommandArgs args, ItemDef itemDef) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected I4, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Invalid comparison between Unknown and I4 //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((ConCommandArgs)(ref args)).senderBody != (Object)null && (Object)(object)((ConCommandArgs)(ref args)).senderBody.inventory != (Object)null && (Object)(object)itemDef != (Object)null && itemDef.DoesNotContainTag((ItemTag)14) && itemDef.DoesNotContainTag((ItemTag)10)) { YeetTracker yeetTracker = ((Component)((ConCommandArgs)(ref args)).senderBody).gameObject.GetComponent(); if ((Object)(object)yeetTracker == (Object)null) { yeetTracker = ((Component)((ConCommandArgs)(ref args)).senderBody).gameObject.AddComponent(); } if (Object.op_Implicit((Object)(object)Stage.instance) && Object.op_Implicit((Object)(object)Stage.instance.sceneDef) && yeetTracker.stageName != Stage.instance.sceneDef.nameToken) { yeetTracker.yeetTrackers.Clear(); yeetTracker.stageName = Stage.instance.sceneDef.nameToken; } yeetTracker.body = ((ConCommandArgs)(ref args)).senderBody; ItemIndex itemIndex = itemDef.itemIndex; int itemCountPermanent = ((ConCommandArgs)(ref args)).senderBody.inventory.GetItemCountPermanent(itemIndex); val4 = (CostTypeIndex)0; ItemTier tier = itemDef.tier; ItemTier val5 = tier; ItemTier val6 = val5; switch ((int)val6) { case 0: val4 = (CostTypeIndex)4; break; case 1: val4 = (CostTypeIndex)5; break; case 2: val4 = (CostTypeIndex)6; break; case 4: val4 = (CostTypeIndex)10; break; case 3: val4 = (CostTypeIndex)9; break; } if ((int)val4 > 0) { YeetTrackerInfo item = new YeetTrackerInfo(itemIndex, val4, itemCountPermanent); yeetTracker.yeetTrackers.Add(item); } } }); } else { Log.Error(((MemberReference)il.Method).Name + " Hook 2 failed!"); } } else { Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!"); } } static BalancedYeetPlugin() { CostTypeIndex[] array = new CostTypeIndex[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); bannedCosts = (CostTypeIndex[])(object)array; } } 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 System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }