Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ShardTierForClassicItemsReturns v1.0.0
plugins/ShardTierClassicItems.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ClassicItemsReturns; using HG.Reflection; using HarmonyLib; using Microsoft.CodeAnalysis; using On.RoR2; using RoR2; using RoR2.ContentManagement; using SS2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ShardTierClassicItems")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9503324fbccd2ee3658a916083b92ad3f14056e8")] [assembly: AssemblyProduct("ShardTierClassicItems")] [assembly: AssemblyTitle("ShardTierClassicItems")] [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 ShardTierClassicItems { public static class ConfigOptions { internal static ConfigEntry<bool> LogExtraInfo; internal static List<ConfigEntry<string>> TradesConfigEntriesList = new List<ConfigEntry<string>>(); internal static List<ConfigEntry<bool>> TierChangeConfigEntriesList = new List<ConfigEntry<bool>>(); internal static void BindConfigOptions(ConfigFile config) { LogExtraInfo = config.Bind<bool>("Other", "Enable logging extra info", false, "If you wanna see stuff like all valid trades, the mod changing item tiers and adding items to trades, enable this."); string text = "Set what shard trades this item should be added to.\nValid options:\n"; foreach (string validTradeName in Main.ValidTradeNames) { text = ((!(validTradeName == "None")) ? (text + validTradeName + ", ") : (text + validTradeName)); } text += "\nSeparate each one with a COMMA ( , ) and NO SPACES, except for `All` or `None` which must be alone."; text += "\n\nNOTE: Setting to `All` means it may add itself to other modded trades!"; ItemDef[] itemDefs = ContentManager.itemDefs; foreach (ItemDef val in itemDefs) { if (Main.IsItemDefNormalClassicItem(val.nameToken)) { string @string = Language.GetString(val.nameToken, "en"); TradesConfigEntriesList.Add(config.Bind<string>("Add to shard trades", @string, "All", text)); TierChangeConfigEntriesList.Add(config.Bind<bool>("Change to shard tier", @string, true, "Should this item be changed to shard tier? The item icon's outline does not yet change color to match this.")); } } } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object 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) { if (ConfigOptions.LogExtraInfo != null && ConfigOptions.LogExtraInfo.Value) { _logSource.LogInfo(data); } } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } internal static class Main { internal static Color CurioColor; internal static TradeController tradeController = null; internal static List<string> ValidTradeNames = new List<string>(); internal static void SetupTradeController() { tradeController = SS2Assets.LoadAsset<GameObject>("TradeTeleporter", (SS2Bundle)15).GetComponent<TradeController>(); Log.Info("ALl valid trades:"); TradeDef[] trades = tradeController.trades; foreach (TradeDef val in trades) { Log.Info(((Object)val).name + " (requires " + ((Object)val.desiredItem).name + ")"); ValidTradeNames.Add(((Object)val).name); } ValidTradeNames.Add("All"); ValidTradeNames.Add("None"); } internal static void EditClassicItems() { ItemDef[] itemDefs = ContentManager.itemDefs; foreach (ItemDef val in itemDefs) { if (IsItemDefNormalClassicItem(val.nameToken)) { ConfigEntry<string> tradesConfigEntryForItemDef = GetTradesConfigEntryForItemDef(val); if (ShouldItemBeAddedToTrades(tradesConfigEntryForItemDef)) { AddItemDefToConfiguredTrades(val, tradesConfigEntryForItemDef); } ConfigEntry<bool> tierChangeConfigEntryForItemDef = GetTierChangeConfigEntryForItemDef(val); if (tierChangeConfigEntryForItemDef.Value) { MakeItemDefCurioTier(val, tierChangeConfigEntryForItemDef); } } } } private static void AddItemDefToConfiguredTrades(ItemDef itemDef, ConfigEntry<string> itemConfigEntry) { string[] array = itemConfigEntry.Value.Split(','); TradeDef[] trades; if (array[0].ToLower() == "all") { Log.Info("Adding \"" + ((ConfigEntryBase)itemConfigEntry).Definition.Key + "\" to ALL trades!"); trades = tradeController.trades; foreach (TradeDef val in trades) { val.options = CollectionExtensions.AddToArray<TradeOption>(val.options, CreateTradeOptionFromItemDef(itemDef)); Log.Debug($"tradeDef.options.Length is {val.options.Length}"); } return; } trades = tradeController.trades; foreach (TradeDef val2 in trades) { if (array.Contains(((Object)val2).name)) { Log.Info("Adding \"" + ((ConfigEntryBase)itemConfigEntry).Definition.Key + "\" to trade \"" + ((Object)val2).name + "\""); val2.options = CollectionExtensions.AddToArray<TradeOption>(val2.options, CreateTradeOptionFromItemDef(itemDef)); } } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void MakeItemDefCurioTier(ItemDef itemDef, ConfigEntry<bool> itemTierChangeConfigEntry) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) Log.Info("Changing \"" + ((ConfigEntryBase)itemTierChangeConfigEntry).Definition.Key + "\" item tier to shard tier!"); Log.Debug(((Object)itemDef).name); itemDef._itemTierDef = ItemTierDefs.Curio; itemDef.tier = ItemTierDefs.Curio.tier; ModSupport.SoftDependencies.SetItemDefSpriteToCurioSprite(itemDef); } internal static TradeOption CreateTradeOptionFromItemDef(ItemDef itemDef) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0018: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown return new TradeOption { pickupName = itemDef.nameToken, pickupDef = (Object)(object)itemDef, pickupIndex = PickupCatalog.FindPickupIndex(itemDef.itemIndex) }; } internal static bool ShouldItemBeAddedToTrades(ConfigEntry<string> itemConfigEntry) { if (itemConfigEntry.Value == "None") { Log.Info("\"" + ((ConfigEntryBase)itemConfigEntry).Definition.Key + "\" will not be added to any trades due to being set to \"None\"."); return false; } if (Utility.IsNullOrWhiteSpace(itemConfigEntry.Value)) { Log.Info("\"" + ((ConfigEntryBase)itemConfigEntry).Definition.Key + "\" will not be added to any trades due to being set to blank."); return false; } return true; } internal static ConfigEntry<string> GetTradesConfigEntryForItemDef(ItemDef itemDef) { foreach (ConfigEntry<string> tradesConfigEntries in ConfigOptions.TradesConfigEntriesList) { if (((ConfigEntryBase)tradesConfigEntries).Definition.Key == Language.GetString(itemDef.nameToken, "en")) { return tradesConfigEntries; } } return null; } internal static ConfigEntry<bool> GetTierChangeConfigEntryForItemDef(ItemDef itemDef) { foreach (ConfigEntry<bool> tierChangeConfigEntries in ConfigOptions.TierChangeConfigEntriesList) { if (((ConfigEntryBase)tierChangeConfigEntries).Definition.Key == Language.GetString(itemDef.nameToken, "en")) { return tierChangeConfigEntries; } } return null; } internal static bool IsItemDefNormalClassicItem(string nameToken) { if (nameToken.StartsWith("CLASSICITEMSRETURNS") || nameToken == "ITEM_ANCIENT_SCEPTER_NAME") { return !nameToken.Contains("DRONEITEM"); } return false; } } internal static class ModSupport { internal static class ClassicItemsReturnsMod { private static bool? _modexists; internal static bool ModIsRunning { get { if (!_modexists.HasValue) { _modexists = Chainloader.PluginInfos.ContainsKey("com.RiskySleeps.ClassicItemsReturns"); } return _modexists.Value; } } internal static bool Use3DModels { get { if (ModIsRunning) { return ClassicItemsReturnsPlugin.use3dModels; } return false; } } internal static bool UseClassicSprites { get { if (ModIsRunning) { return ClassicItemsReturnsPlugin.useClassicSprites; } return false; } } } internal static class SoftDependencies { [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void SetItemDefSpriteToCurioSprite(ItemDef itemDef) { string text = ((Object)itemDef).name + ".png"; Sprite val = null; bool flag = ((Object)itemDef).name == "ITEM_ANCIENT_SCEPTER"; bool flag2 = false; bool flag3 = false; if (flag || ClassicItemsReturnsMod.Use3DModels) { val = MyAssets.R2IconsBundle.LoadAsset<Sprite>(text); if ((Object)(object)val == (Object)null) { if (flag) { Log.Warning("Shard-tier item sprite for \"Ancient Scepter\" could not be found!"); Log.Error("All possible sprite options not found. The item's sprite will not be changed."); return; } Log.Warning("Shard-tier 3D item sprite for \"" + ((Object)itemDef).name + "\" could not be found!"); Log.Warning("Falling back to the Returns sprite."); flag3 = true; } else { flag2 = true; } } if (flag3) { val = MyAssets.RRIconsBundle.LoadAsset<Sprite>(text); if ((Object)(object)val == (Object)null) { Log.Warning("Shard-tier returns item sprite for \"" + ((Object)itemDef).name + "\" could not be found!"); Log.Warning("Falling back to the Classic sprite."); } else { flag2 = true; } } if ((!flag2 && ClassicItemsReturnsMod.UseClassicSprites) || (!flag2 && flag3)) { val = MyAssets.R1IconsBundle.LoadAsset<Sprite>(text); if ((Object)(object)val == (Object)null) { if (flag3) { Log.Warning("Shard-tier classic item sprite for item \"" + ((Object)itemDef).name + "\" could not be found!"); Log.Error("All possible sprite options not found. The item's sprite will not be changed."); return; } Log.Warning("Shard-tier classic item sprite for \"" + ((Object)itemDef).name + "\" could not be found!"); Log.Warning("Falling back to the Returns sprite."); } else { flag2 = true; } } if (!flag2) { val = MyAssets.RRIconsBundle.LoadAsset<Sprite>(text); if ((Object)(object)val == (Object)null) { Log.Warning("Shard-tier returns item sprite for \"" + ((Object)itemDef).name + "\" could not be found!"); Log.Error("All possible sprite options not found. The item's sprite will not be changed."); return; } } itemDef.pickupIconSprite = val; } } } public static class MyAssets { public static AssetBundle R2IconsBundle; public const string R2IconsBundleName = "recolored_ror2_icons"; public static AssetBundle R1IconsBundle; public const string R1IconsBundleName = "recolored_ror1_icons"; public static AssetBundle RRIconsBundle; public const string RRIconsBundleName = "recolored_rorr_icons"; public static string R2IconsBundlePath => Path.Combine(Path.GetDirectoryName(Plugin.PluginInfo.Location), "recolored_ror2_icons"); public static string R1IconsBundlePath => Path.Combine(Path.GetDirectoryName(Plugin.PluginInfo.Location), "recolored_ror1_icons"); public static string RRIconsBundlePath => Path.Combine(Path.GetDirectoryName(Plugin.PluginInfo.Location), "recolored_rorr_icons"); public static void Init() { R2IconsBundle = AssetBundle.LoadFromFile(R2IconsBundlePath); R1IconsBundle = AssetBundle.LoadFromFile(R1IconsBundlePath); RRIconsBundle = AssetBundle.LoadFromFile(RRIconsBundlePath); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("LordVGames.ShardTierClassicItems", "ShardTierClassicItems", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "LordVGames.ShardTierClassicItems"; public const string PluginAuthor = "LordVGames"; public const string PluginName = "ShardTierClassicItems"; public const string PluginVersion = "1.0.0"; public static PluginInfo PluginInfo { get; private set; } public void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown PluginInfo = ((BaseUnityPlugin)this).Info; Log.Init(((BaseUnityPlugin)this).Logger); MyAssets.Init(); ItemCatalog.SetItemDefs += (hook_SetItemDefs)delegate(orig_SetItemDefs orig, ItemDef[] itemDefs) { orig.Invoke(itemDefs); Guh(((BaseUnityPlugin)this).Config); }; } private static void Guh(ConfigFile Config) { //IL_0005: 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Main.CurioColor = Color32.op_Implicit(ColorCatalog.GetColor(ItemTierDefs.Curio.colorIndex)); Main.SetupTradeController(); ConfigOptions.BindConfigOptions(Config); Main.EditClassicItems(); } } }