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 FortnitificationScanner v0.0.7
FortnitificationScanner.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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.Configuration; using BepInEx.Logging; using Dawn; using Dawn.Utils; using HarmonyLib; using ItemRarities.Patches; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FortnitificationScanner")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.0.7.0")] [assembly: AssemblyInformationalVersion("0.0.7")] [assembly: AssemblyProduct("FortnitificationScanner")] [assembly: AssemblyTitle("FortnitificationScanner")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } [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 ItemRarities { internal static class ConfigManager { internal static ConfigEntry<bool> DebugLogsEnabled { get; private set; } internal static ConfigEntry<bool> OverrideExistingDawnScanNodeColours { get; private set; } internal static ConfigEntry<string> CommonItems { get; private set; } internal static ConfigEntry<string> UncommonItems { get; private set; } internal static ConfigEntry<string> RareItems { get; private set; } internal static ConfigEntry<string> ExceptionalItems { get; private set; } internal static ConfigEntry<string> LegendaryItems { get; private set; } internal static ConfigEntry<float> CommonPercentage { get; private set; } internal static ConfigEntry<float> UncommonPercentage { get; private set; } internal static ConfigEntry<float> RarePercentage { get; private set; } internal static ConfigEntry<float> ExceptionalPercentage { get; private set; } internal static ConfigEntry<float> LegendaryPercentage { get; private set; } internal static ConfigEntry<string> CommonName { get; private set; } internal static ConfigEntry<string> UncommonName { get; private set; } internal static ConfigEntry<string> RareName { get; private set; } internal static ConfigEntry<string> ExceptionalName { get; private set; } internal static ConfigEntry<string> LegendaryName { get; private set; } internal static void Bind(ConfigFile config) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown DebugLogsEnabled = config.Bind<bool>("Internal", "Enable Debug Logging", false, "If true, enables debug logging"); OverrideExistingDawnScanNodeColours = config.Bind<bool>("General", "Override Existing Dawn Scan Node Colours", false, "If true, overrides items already using DawnLib scan node colours"); CommonItems = config.Bind<string>("Item overrides", "Common items", string.Empty, "Namespaced keys for the Common rarity, e.g. 'lethal_company:big_bolt,lethal_company:apparatus'"); UncommonItems = config.Bind<string>("Item overrides", "Uncommon items", string.Empty, "Namespaced keys for the Uncommon rarity, e.g. 'lethal_company:big_bolt,lethal_company:apparatus'"); RareItems = config.Bind<string>("Item overrides", "Rare items", string.Empty, "Namespaced keys for the Rare rarity, e.g. 'lethal_company:big_bolt,lethal_company:apparatus'"); ExceptionalItems = config.Bind<string>("Item overrides", "Exceptional items", "lethal_company:apparatus, lethal_company:hive, lethal_company:kitchen_knife", "Namespaced keys for the Exceptional rarity, e.g. 'lethal_company:big_bolt,lethal_company:apparatus'"); LegendaryItems = config.Bind<string>("Item overrides", "Legendary items", string.Empty, "Namespaced keys for the Legendary rarity, e.g. 'lethal_company:big_bolt,lethal_company:apparatus'"); CommonPercentage = config.Bind<float>("Rarity groups", "Common percentage", 39f, new ConfigDescription("Percentage of scrap to be Common. If all rarity percentages do not total 100, they will scale automatically", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); UncommonPercentage = config.Bind<float>("Rarity groups", "Uncommon percentage", 28f, new ConfigDescription("Percentage of scrap to be Uncommon. If all rarity percentages do not total 100, they will scale automatically", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); RarePercentage = config.Bind<float>("Rarity groups", "Rare percentage", 16f, new ConfigDescription("Percentage of scrap to be Rare. If all rarity percentages do not total 100, they will scale automatically", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); ExceptionalPercentage = config.Bind<float>("Rarity groups", "Exceptional percentage", 11f, new ConfigDescription("Percentage of scrap to be Exceptional. If all rarity percentages do not total 100, they will scale automatically", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); LegendaryPercentage = config.Bind<float>("Rarity groups", "Legendary percentage", 6f, new ConfigDescription("Percentage of scrap to be Legendary. If all rarity percentages do not total 100, they will scale automatically", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); CommonName = config.Bind<string>("Rarity groups", "Common name", "Common", "Rarity name shown on the scanner for Common scrap"); UncommonName = config.Bind<string>("Rarity groups", "Uncommon name", "Uncommon", "Rarity name shown on the scanner for Uncommon scrap"); RareName = config.Bind<string>("Rarity groups", "Rare name", "Rare", "Rarity name shown on the scanner for Rare scrap"); ExceptionalName = config.Bind<string>("Rarity groups", "Exceptional name", "Exceptional", "Rarity name shown on the scanner for Exceptional scrap"); LegendaryName = config.Bind<string>("Rarity groups", "Legendary name", "Legendary", "Rarity name shown on the scanner for Legendary scrap"); } } internal static class Log { internal static void Debug(string message) { if (ConfigManager.DebugLogsEnabled.Value) { Write((LogLevel)32, message); } } internal static void Info(string message) { Write((LogLevel)16, message); } internal static void Warn(string message) { Write((LogLevel)4, message); } internal static void Error(string message) { Write((LogLevel)2, message); } internal static void Fatal(string message) { Write((LogLevel)1, message); } private static void Write(LogLevel logLevel, string message) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Plugin.mls.Log(logLevel, (object)message); } } [BepInPlugin("MrHat.FortnitificationScanner", "FortnitificationScanner", "0.0.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string modGUID = "MrHat.FortnitificationScanner"; public const string modName = "FortnitificationScanner"; public const string modVersion = "0.0.7"; private readonly Harmony _harmony = new Harmony("MrHat.FortnitificationScanner"); internal static ManualLogSource mls; private void Awake() { mls = ((BaseUnityPlugin)this).Logger; ConfigManager.Bind(((BaseUnityPlugin)this).Config); RarityGroups.Enable(); _harmony.PatchAll(typeof(GrabbableObjectPatches)); _harmony.PatchAll(typeof(LungPropPatches)); Log.Info("FortnitificationScanner loaded"); } } internal static class RarityGroups { private static readonly Dictionary<Item, RarityGroup> AssignedItems = new Dictionary<Item, RarityGroup>(); private static readonly List<RarityGroup> Groups = new List<RarityGroup>(); private static readonly HashSet<Item> RarityScanItems = new HashSet<Item>(); internal static void Enable() { //IL_0036: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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) //IL_0159: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) Groups.AddRange(new <>z__ReadOnlyArray<RarityGroup>(new RarityGroup[5] { new RarityGroup(ConfigManager.CommonName.Value, ConfigManager.CommonPercentage.Value, ConfigManager.CommonItems.Value, Color32.op_Implicit(new Color32((byte)74, (byte)74, (byte)74, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)226, (byte)226, (byte)226, byte.MaxValue))), new RarityGroup(ConfigManager.UncommonName.Value, ConfigManager.UncommonPercentage.Value, ConfigManager.UncommonItems.Value, Color32.op_Implicit(new Color32((byte)28, (byte)90, (byte)49, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)118, (byte)242, (byte)154, byte.MaxValue))), new RarityGroup(ConfigManager.RareName.Value, ConfigManager.RarePercentage.Value, ConfigManager.RareItems.Value, Color32.op_Implicit(new Color32((byte)36, (byte)74, (byte)122, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)127, (byte)199, byte.MaxValue, byte.MaxValue))), new RarityGroup(ConfigManager.ExceptionalName.Value, ConfigManager.ExceptionalPercentage.Value, ConfigManager.ExceptionalItems.Value, Color32.op_Implicit(new Color32((byte)85, (byte)48, (byte)112, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)215, (byte)156, byte.MaxValue, byte.MaxValue))), new RarityGroup(ConfigManager.LegendaryName.Value, ConfigManager.LegendaryPercentage.Value, ConfigManager.LegendaryItems.Value, Color32.op_Implicit(new Color32((byte)111, (byte)91, (byte)16, byte.MaxValue)), Color32.op_Implicit(new Color32(byte.MaxValue, (byte)230, (byte)109, byte.MaxValue))) })); ((Registry<DawnItemInfo>)(object)LethalContent.Items).OnFreeze += SortItems; } internal static bool Find(Item item, out RarityGroup rarity) { return AssignedItems.TryGetValue(item, out rarity); } internal static bool UsesRarityScan(Item item) { return RarityScanItems.Contains(item); } private static void SortItems() { //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) List<string>[] array = new List<string>[5] { new List<string>(), new List<string>(), new List<string>(), new List<string>(), new List<string>() }; AssignedItems.Clear(); NamespacedKey val = default(NamespacedKey); DawnItemInfo val3 = default(DawnItemInfo); for (int i = 0; i < Groups.Count; i++) { string[] array2 = Groups[i].OverrideText.Split(new char[4] { ',', ';', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); string[] array3 = array2; foreach (string text in array3) { string text2 = text.Trim(); if (!NamespacedKey.TryParse(text2, ref val)) { Log.Error("Item override key is invalid: " + text2); continue; } NamespacedKey<DawnItemInfo> val2 = NamespacedKey<DawnItemInfo>.From(val.Namespace, val.Key); if (!((Registry<DawnItemInfo>)(object)LethalContent.Items).TryGetValue(val2, ref val3)) { Log.Error("Item override was not loaded: " + text2); } else if (!val3.Item.isScrap) { Log.Warn("Item override is not scrap: " + text2); } else if (!AssignedItems.TryAdd(val3.Item, Groups[i])) { Log.Error("Item override appears in more than one rarity: " + text2); } else { array[i].Add(text2); } } } int count = AssignedItems.Count; List<DawnItemInfo> list = (from itemInfo in ((Registry<DawnItemInfo>)(object)LethalContent.Items).Values where itemInfo.Item.isScrap && !AssignedItems.ContainsKey(itemInfo.Item) orderby (float)(itemInfo.Item.minValue + itemInfo.Item.maxValue) / 2f select itemInfo).ToList(); float num = Groups.Sum((RarityGroup rarityGroup) => rarityGroup.Percentage); if (list.Count > 0 && num <= 0f) { AssignedItems.Clear(); Log.Error("Rarity percentages must total more than zero"); return; } if (list.Count > 0) { int num2 = 0; float num3 = Groups[0].Percentage / num; for (int num4 = 0; num4 < list.Count; num4++) { float num5 = ((float)num4 + 0.5f) / (float)list.Count; while (num2 < Groups.Count - 1 && num5 >= num3) { num2++; num3 += Groups[num2].Percentage / num; } AssignedItems[list[num4].Item] = Groups[num2]; } } GrabbableObject[] array4 = Resources.FindObjectsOfTypeAll<GrabbableObject>(); HashSet<Item> hashSet = new HashSet<Item>(); RarityScanItems.Clear(); if (!ConfigManager.OverrideExistingDawnScanNodeColours.Value) { GrabbableObject[] array5 = array4; foreach (GrabbableObject val4 in array5) { if ((Object)(object)val4.itemProperties != (Object)null && val4.itemProperties.isScrap && ((Component)val4).GetComponentsInChildren<ForceScanColorOnItem>(true).Length != 0) { hashSet.Add(val4.itemProperties); } } } int num7 = 0; GrabbableObject[] array6 = array4; foreach (GrabbableObject val5 in array6) { if ((Object)(object)val5.itemProperties == (Object)null || !val5.itemProperties.isScrap || !AssignedItems.TryGetValue(val5.itemProperties, out RarityGroup value)) { continue; } if (hashSet.Contains(val5.itemProperties)) { Log.Debug("Existing scan node colours kept for " + val5.itemProperties.itemName); continue; } ScanNodeProperties componentInChildren = ((Component)val5).GetComponentInChildren<ScanNodeProperties>(true); if ((Object)(object)componentInChildren == (Object)null) { Log.Error("Setup failed for " + val5.itemProperties.itemName + " because it's missing a scan node"); continue; } componentInChildren.subText = $"{value.Name} - ${val5.scrapValue}"; ForceScanColorOnItem[] array7 = ((Component)val5).GetComponentsInChildren<ForceScanColorOnItem>(true); if (array7.Length == 0) { array7 = (ForceScanColorOnItem[])(object)new ForceScanColorOnItem[1] { ((Component)val5).gameObject.AddComponent<ForceScanColorOnItem>() }; } ForceScanColorOnItem[] array8 = array7; foreach (ForceScanColorOnItem val6 in array8) { val6.grabbableObject = val5; val6.borderColor = value.ScanColor; val6.textColor = value.TextColor; } RarityScanItems.Add(val5.itemProperties); num7++; } Log.Debug($"{num7} scrap prefabs setup"); foreach (RarityGroup rarity in Groups) { Log.Info($"{rarity.Name} scrap amount: {AssignedItems.Count<KeyValuePair<Item, RarityGroup>>((KeyValuePair<Item, RarityGroup> item) => item.Value == rarity)}"); } for (int num10 = 0; num10 < Groups.Count; num10++) { if (array[num10].Count > 0) { Log.Info(Groups[num10].Name + " item overrides: " + string.Join(", ", array[num10])); } } Log.Info($"{list.Count} scrap items sorted by mean value from lowest to highest with {count} overrides"); } } internal class RarityGroup(string name, float percentage, string overrideText, Color scanColor, Color textColor) { internal string Name { get; } = name; internal float Percentage { get; } = percentage; internal string OverrideText { get; } = overrideText; internal Color ScanColor { get; } = scanColor; internal Color TextColor { get; } = textColor; } public static class MyPluginInfo { public const string PLUGIN_GUID = "FortnitificationScanner"; public const string PLUGIN_NAME = "FortnitificationScanner"; public const string PLUGIN_VERSION = "0.0.7"; } } namespace ItemRarities.Patches { [HarmonyPatch(typeof(GrabbableObject))] internal static class GrabbableObjectPatches { [HarmonyPatch("SetScrapValue")] [HarmonyPostfix] private static void SetScrapValuePostfix(GrabbableObject __instance) { if (!((Object)(object)__instance.itemProperties == (Object)null) && __instance.itemProperties.isScrap && RarityGroups.UsesRarityScan(__instance.itemProperties) && RarityGroups.Find(__instance.itemProperties, out RarityGroup rarity)) { ScanNodeProperties componentInChildren = ((Component)__instance).GetComponentInChildren<ScanNodeProperties>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.subText = $"{rarity.Name} - ${__instance.scrapValue}"; Log.Debug(__instance.itemProperties.itemName + " rarity scan text set to " + componentInChildren.subText); } } } } [HarmonyPatch(typeof(LungProp))] internal static class LungPropPatches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostfix(LungProp __instance) { if (!((Object)(object)((GrabbableObject)__instance).itemProperties == (Object)null) && ((GrabbableObject)__instance).itemProperties.isScrap && RarityGroups.UsesRarityScan(((GrabbableObject)__instance).itemProperties) && RarityGroups.Find(((GrabbableObject)__instance).itemProperties, out RarityGroup rarity)) { ScanNodeProperties componentInChildren = ((Component)__instance).GetComponentInChildren<ScanNodeProperties>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.subText = rarity.Name + " - $???"; Log.Debug(((GrabbableObject)__instance).itemProperties.itemName + " rarity scan text set to " + componentInChildren.subText); } } } } } [CompilerGenerated] internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }