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 SupplyChain v1.0.0
SupplyChain.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using On.RoR2; using R2API; using RoR2; using RoR2.ExpansionManagement; using SupplyChain.Artifacts; using SupplyChain.Items; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Rendering; [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("SupplyChain")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e1b54bd2ff98f9266ac533a3e98992d49530fffb")] [assembly: AssemblyProduct("SupplyChain")] [assembly: AssemblyTitle("SupplyChain")] [assembly: AssemblyVersion("1.0.0.0")] [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 SupplyChain { internal static class Assets { private static GameObject prefabHolder; internal static Transform PrefabHolder { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)prefabHolder)) { prefabHolder = new GameObject("SupplyChainPrefabHolder"); Object.DontDestroyOnLoad((Object)(object)prefabHolder); prefabHolder.SetActive(false); } return prefabHolder.transform; } } internal static void SetItemTier(ItemDef def, ItemTier tier) { //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_0038: Unknown result type (might be due to invalid IL or missing references) typeof(ItemDef).GetField("deprecatedTier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(def, tier); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(tier); if (Object.op_Implicit((Object)(object)itemTierDef)) { typeof(ItemDef).GetField("_itemTierDef", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(def, itemTierDef); } }); } internal static ItemDef CreateItemDef(string name, string tokenBase, ItemTier tier, Sprite icon, GameObject model, ItemTag[] tags, bool canRemove = true) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) ItemDef val = ScriptableObject.CreateInstance<ItemDef>(); ((Object)val).name = name; val.nameToken = tokenBase + "_NAME"; val.pickupToken = tokenBase + "_PICKUP"; val.descriptionToken = tokenBase + "_DESC"; val.loreToken = tokenBase + "_LORE"; val.canRemove = canRemove; val.hidden = false; val.tags = tags; val.pickupIconSprite = icon; val.pickupModelPrefab = model; SetItemTier(val, tier); return val; } private static byte[] ReadResource(string resourceName) { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } internal static Texture2D LoadRawTexture(string resourceName, int size) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown try { byte[] array = ReadResource(resourceName); if (array == null || array.Length != size * size * 4) { return null; } Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; val.LoadRawTextureData(array); val.Apply(); return val; } catch (Exception arg) { Log.Error($"Failed to load texture '{resourceName}': {arg}"); return null; } } internal static Sprite LoadSprite(string resourceName, int size) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Texture2D val = LoadRawTexture(resourceName, size); return Object.op_Implicit((Object)(object)val) ? Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f)) : null; } internal static Material CreatePickupMaterial(Color color, Texture2D mainTexture, Color emission) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/LunarCoin/PickupLunarCoin.prefab").WaitForCompletion(); Renderer val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponentInChildren<Renderer>(true) : null); Material val3 = ((Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.sharedMaterial)) ? new Material(val2.sharedMaterial) : new Material(Shader.Find("Standard"))); string[] array = new string[5] { "_MainTex", "_NormalTex", "_BumpMap", "_EmTex", "_EmissionMap" }; foreach (string text in array) { if (val3.HasProperty(text)) { val3.SetTexture(text, (Texture)(object)((!(text == "_MainTex")) ? null : (Object.op_Implicit((Object)(object)mainTexture) ? mainTexture : Texture2D.whiteTexture))); } } if (val3.HasProperty("_Color")) { val3.color = color; } if (val3.HasProperty("_EmColor")) { val3.SetColor("_EmColor", emission); } return val3; } internal static Mesh LoadObjMesh(string resourceName) { //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) byte[] array = ReadResource(resourceName); if (array == null) { return null; } List<Vector3> positions = new List<Vector3>(); List<Vector2> texCoords = new List<Vector2>(); List<Vector3> objNormals = new List<Vector3>(); Dictionary<(int, int, int), int> vertexMap = new Dictionary<(int, int, int), int>(); List<Vector3> vertices = new List<Vector3>(); List<Vector2> uvs = new List<Vector2>(); List<Vector3> normals = new List<Vector3>(); List<int> list = new List<int>(); using (StreamReader streamReader = new StreamReader(new MemoryStream(array))) { string text; while ((text = streamReader.ReadLine()) != null) { string[] array2 = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array2.Length == 0) { continue; } switch (array2[0]) { case "v": positions.Add(new Vector3(0f - float.Parse(array2[1], CultureInfo.InvariantCulture), float.Parse(array2[2], CultureInfo.InvariantCulture), float.Parse(array2[3], CultureInfo.InvariantCulture))); break; case "vt": texCoords.Add(new Vector2(float.Parse(array2[1], CultureInfo.InvariantCulture), float.Parse(array2[2], CultureInfo.InvariantCulture))); break; case "vn": objNormals.Add(new Vector3(0f - float.Parse(array2[1], CultureInfo.InvariantCulture), float.Parse(array2[2], CultureInfo.InvariantCulture), float.Parse(array2[3], CultureInfo.InvariantCulture))); break; case "f": { int item = ResolveVertex(array2[1]); int item2 = ResolveVertex(array2[2]); for (int i = 3; i < array2.Length; i++) { int num = ResolveVertex(array2[i]); list.Add(item); list.Add(num); list.Add(item2); item2 = num; } break; } } } } Mesh val = new Mesh { indexFormat = (IndexFormat)1 }; val.SetVertices(vertices); val.SetUVs(0, uvs); val.SetNormals(normals); val.SetTriangles(list, 0); val.RecalculateBounds(); return val; int ResolveVertex(string token) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_013a: 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) string[] array3 = token.Split('/'); int num2 = int.Parse(array3[0], CultureInfo.InvariantCulture); int num3 = ((array3.Length > 1 && array3[1].Length > 0) ? int.Parse(array3[1], CultureInfo.InvariantCulture) : 0); int num4 = ((array3.Length > 2 && array3[2].Length > 0) ? int.Parse(array3[2], CultureInfo.InvariantCulture) : 0); if (num2 < 0) { num2 += positions.Count + 1; } if (num3 < 0) { num3 += texCoords.Count + 1; } if (num4 < 0) { num4 += objNormals.Count + 1; } (int, int, int) key = (num2, num3, num4); if (vertexMap.TryGetValue(key, out var value)) { return value; } value = vertices.Count; vertices.Add(positions[num2 - 1]); uvs.Add((num3 > 0) ? texCoords[num3 - 1] : Vector2.zero); normals.Add((num4 > 0) ? objNormals[num4 - 1] : Vector3.up); vertexMap[key] = value; return value; } } internal static GameObject CreatePickupModel(string name, string objResource, string textureResource, int textureSize, float targetSize, Func<GameObject> fallback = null) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) try { Mesh val = LoadObjMesh(objResource); if ((Object)(object)val == (Object)null) { Log.Warning("Model resource '" + objResource + "' missing; using fallback model for " + name + "."); return (fallback != null) ? fallback() : MysteryModel(); } Texture2D mainTexture = LoadRawTexture(textureResource, textureSize); GameObject val2 = new GameObject(name); val2.transform.SetParent(PrefabHolder); val2.AddComponent<MeshFilter>().mesh = val; ((Renderer)val2.AddComponent<MeshRenderer>()).material = CreatePickupMaterial(Color.white, mainTexture, Color.black); float[] array = new float[3]; Bounds bounds = val.bounds; array[0] = ((Bounds)(ref bounds)).size.x; bounds = val.bounds; array[1] = ((Bounds)(ref bounds)).size.y; bounds = val.bounds; array[2] = ((Bounds)(ref bounds)).size.z; float num = Mathf.Max(array); if (num > 0f) { val2.transform.localScale = Vector3.one * (targetSize / num); } return val2; } catch (Exception arg) { Log.Error($"Failed to build pickup model {name}: {arg}"); return (fallback != null) ? fallback() : MysteryModel(); } } internal static GameObject MysteryModel() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion(); } } internal static class ChestHooks { private class ChestOpener : MonoBehaviour { internal CharacterMaster master; } [CompilerGenerated] private static class <>O { public static hook_OnInteractionBegin <0>__TrackOpener; public static hook_ItemDrop <1>__OnChestItemDrop; } private static int bonusDropsThisStage; internal static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown object obj = <>O.<0>__TrackOpener; if (obj == null) { hook_OnInteractionBegin val = TrackOpener; <>O.<0>__TrackOpener = val; obj = (object)val; } PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj; object obj2 = <>O.<1>__OnChestItemDrop; if (obj2 == null) { hook_ItemDrop val2 = OnChestItemDrop; <>O.<1>__OnChestItemDrop = val2; obj2 = (object)val2; } ChestBehavior.ItemDrop += (hook_ItemDrop)obj2; Stage.onServerStageBegin += delegate { bonusDropsThisStage = 0; }; } private static void TrackOpener(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 if (NetworkServer.active && (int)self.costType == 1 && Object.op_Implicit((Object)(object)activator)) { ChestBehavior component = ((Component)self).GetComponent<ChestBehavior>(); if (Object.op_Implicit((Object)(object)component)) { CharacterBody component2 = ((Component)activator).GetComponent<CharacterBody>(); CharacterMaster val = (Object.op_Implicit((Object)(object)component2) ? component2.master : null); if (Object.op_Implicit((Object)(object)val)) { ChestOpener chestOpener = ((Component)component).GetComponent<ChestOpener>(); if (!Object.op_Implicit((Object)(object)chestOpener)) { chestOpener = ((Component)component).gameObject.AddComponent<ChestOpener>(); } chestOpener.master = val; } } } orig.Invoke(self, activator); } private static void OnChestItemDrop(orig_ItemDrop orig, ChestBehavior self) { //IL_0075: 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_008a: Invalid comparison between Unknown and I4 //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance)) { orig.Invoke(self); return; } ChestOpener component = ((Component)self).GetComponent<ChestOpener>(); CharacterMaster val = (Object.op_Implicit((Object)(object)component) ? component.master : null); Inventory val2 = (Object.op_Implicit((Object)(object)val) ? val.inventory : null); if (!Object.op_Implicit((Object)(object)val2)) { orig.Invoke(self); return; } PickupDef val3 = PickupCatalog.GetPickupDef(self.dropPickup); if (val3 == null || (int)val3.itemIndex == -1) { orig.Invoke(self); return; } if (ArtifactOfDiversification.Enabled && val2.GetItemCount(val3.itemIndex) >= ArtifactOfDiversification.RerollThreshold.Value) { self.RollItem(); PickupDef pickupDef = PickupCatalog.GetPickupDef(self.dropPickup); Log.Info("Diversification reroll: " + val3.internalName + " -> " + (pickupDef?.internalName ?? "?")); val3 = pickupDef ?? val3; } int itemCount = val2.GetItemCount(LoadedDice.Def); int itemCount2 = val2.GetItemCount(RecallNotice.Def); if (itemCount > 0 || itemCount2 > 0) { int num = itemCount + itemCount2; int num2 = LoadedDice.StageCapBase.Value + (num - 1); if (bonusDropsThisStage < num2) { bool flag = itemCount2 > 0; float num3 = HyperbolicChance(LoadedDice.BonusChanceBase.Value, LoadedDice.BonusChancePerStack.Value, LoadedDice.BonusChanceMax.Value, num); if (flag || Run.instance.treasureRng.nextNormalizedFloat < num3) { List<PickupIndex> list = (flag ? VoidListForTier(val3.itemTier) : TierDownListForTier(val3.itemTier)); PickupIndex val4 = PickFromList(list); if (val4 != PickupIndex.none) { bonusDropsThisStage++; SpawnBonus(self, val4); } } } } int itemCount3 = val2.GetItemCount(BulkOrder.Def); if (itemCount3 > 0) { float num4 = HyperbolicChance(BulkOrder.ExtraChanceBase.Value, BulkOrder.ExtraChancePerStack.Value, BulkOrder.ExtraChanceMax.Value, itemCount3); if (Run.instance.treasureRng.nextNormalizedFloat < num4) { PickupIndex val5 = PickFromList(Run.instance.availableTier1DropList); if (val5 != PickupIndex.none) { SpawnBonus(self, val5); } } } orig.Invoke(self); } internal static float HyperbolicChance(float baseChance, float perStack, float max, int stacks) { if (stacks <= 0) { return 0f; } return baseChance + (max - baseChance) * (1f - 1f / (1f + perStack * (float)(stacks - 1))); } private static List<PickupIndex> TierDownListForTier(ItemTier tier) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0004: 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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown return (tier - 1) switch { 1 => Run.instance.availableTier2DropList, 0 => Run.instance.availableTier1DropList, 3 => Run.instance.availableTier3DropList, _ => Run.instance.availableTier1DropList, }; } private static List<PickupIndex> VoidListForTier(ItemTier tier) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0004: 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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown return (tier - 1) switch { 1 => Run.instance.availableVoidTier3DropList, 0 => Run.instance.availableVoidTier2DropList, 3 => Run.instance.availableVoidBossDropList, _ => Run.instance.availableVoidTier1DropList, }; } private static PickupIndex PickFromList(List<PickupIndex> list) { //IL_0015: 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_006f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0055: Unknown result type (might be due to invalid IL or missing references) if (list == null || list.Count == 0) { return PickupIndex.none; } for (int i = 0; i < 8; i++) { PickupIndex val = list[Run.instance.treasureRng.RangeInt(0, list.Count)]; if (!SupplyChainPlugin.BundlePickups.Contains(val)) { return val; } } return PickupIndex.none; } private static void SpawnBonus(ChestBehavior chest, PickupIndex pickup) { //IL_0022: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0049: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) Transform val = (Object.op_Implicit((Object)(object)chest.dropTransform) ? chest.dropTransform : ((Component)chest).gameObject.transform); PickupDropletController.CreatePickupDroplet(pickup, val.position + Vector3.up * 1.5f, val.forward * chest.dropForwardVelocityStrength + Vector3.up * chest.dropUpVelocityStrength); } } internal static class InventoryCompat { private static Func<Inventory, ItemIndex, int> getPermanent; private static bool resolved; internal static int GetPermanentCount(Inventory inventory, ItemIndex itemIndex) { //IL_008d: 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) if (!resolved) { resolved = true; MethodInfo method = typeof(Inventory).GetMethod("GetItemCountPermanent", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(ItemIndex) }, null); if (method != null) { getPermanent = (Func<Inventory, ItemIndex, int>)method.CreateDelegate(typeof(Func<Inventory, ItemIndex, int>)); } else { Log.Warning("Inventory.GetItemCountPermanent not found; falling back to GetItemCount."); } } return (getPermanent != null) ? getPermanent(inventory, itemIndex) : inventory.GetItemCount(itemIndex); } } 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 Info(object data) { _logSource.LogInfo(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Isaac_Cummings.SupplyChain", "SupplyChain", "1.0.0")] public class SupplyChainPlugin : BaseUnityPlugin { public const string PluginGUID = "Isaac_Cummings.SupplyChain"; public const string PluginAuthor = "Isaac_Cummings"; public const string PluginName = "SupplyChain"; public const string PluginVersion = "1.0.0"; public static ConfigEntry<KeyboardShortcut> DebugSpawnPackKey; internal static readonly HashSet<PickupIndex> BundlePickups = new HashSet<PickupIndex>(); internal static readonly HashSet<ItemIndex> AmplifiableItems = new HashSet<ItemIndex>(); public void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) Log.Init(((BaseUnityPlugin)this).Logger); DebugSpawnPackKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Debug", "SpawnPackKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Drops one of each SupplyChain item for testing (host only). Set to an empty shortcut to disable."); BulkOrder.Init(((BaseUnityPlugin)this).Config); LoadedDice.Init(((BaseUnityPlugin)this).Config); StandingOrder.Init(((BaseUnityPlugin)this).Config); ForceMultiplier.Init(((BaseUnityPlugin)this).Config); PyramidScheme.Init(((BaseUnityPlugin)this).Config); RecallNotice.Init(((BaseUnityPlugin)this).Config); ArtifactOfDiversification.Init(((BaseUnityPlugin)this).Config); ChestHooks.Init(); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(BuildIndexSets)); Log.Info("SupplyChain loaded."); } private static void BuildIndexSets() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0069: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_00d1: Invalid comparison between Unknown and I4 //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Invalid comparison between Unknown and I4 //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Invalid comparison between Unknown and I4 ItemDef[] array = (ItemDef[])(object)new ItemDef[6] { BulkOrder.Def, LoadedDice.Def, StandingOrder.Def, ForceMultiplier.Def, PyramidScheme.Def, RecallNotice.Def }; foreach (ItemDef val in array) { if (Object.op_Implicit((Object)(object)val) && (int)val.itemIndex != -1) { PickupIndex val2 = PickupCatalog.FindPickupIndex(val.itemIndex); if (val2 != PickupIndex.none) { BundlePickups.Add(val2); } } } for (int j = 0; j < ItemCatalog.itemCount; j++) { ItemIndex val3 = (ItemIndex)j; ItemDef itemDef = ItemCatalog.GetItemDef(val3); if (Object.op_Implicit((Object)(object)itemDef) && !itemDef.hidden && ((int)itemDef.tier == 0 || (int)itemDef.tier == 1 || (int)itemDef.tier == 2 || (int)itemDef.tier == 4) && (Object)(object)itemDef != (Object)(object)ForceMultiplier.Def && (Object)(object)itemDef != (Object)(object)StandingOrder.Def) { AmplifiableItems.Add(val3); } } Log.Info($"SupplyChain index sets: {BundlePickups.Count} bundle pickups, {AmplifiableItems.Count} amplifiable items."); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0107: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = DebugSpawnPackKey.Value; if (!((KeyboardShortcut)(ref value)).IsDown() || !NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance)) { return; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null); if (Object.op_Implicit((Object)(object)val)) { Log.Info("Debug: spawning SupplyChain pack"); Vector3 forward = ((Component)val).gameObject.transform.forward; ItemDef[] array = (ItemDef[])(object)new ItemDef[6] { BulkOrder.Def, LoadedDice.Def, StandingOrder.Def, ForceMultiplier.Def, PyramidScheme.Def, RecallNotice.Def }; for (int i = 0; i < array.Length; i++) { Vector3 val2 = Quaternion.AngleAxis(-37.5f + 15f * (float)i, Vector3.up) * forward; PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(array[i].itemIndex), val.corePosition + Vector3.up * 1.5f, val2 * 10f); } } } } } namespace SupplyChain.Items { internal static class BulkOrder { internal static ItemDef Def; internal static ConfigEntry<float> ExtraChanceBase; internal static ConfigEntry<float> ExtraChancePerStack; internal static ConfigEntry<float> ExtraChanceMax; internal static void Init(ConfigFile config) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown ExtraChanceBase = config.Bind<float>("BulkOrder", "ExtraChanceBase", 0.07f, "Chance for a gold chest to contain an extra white item, with one stack."); ExtraChancePerStack = config.Bind<float>("BulkOrder", "ExtraChancePerStack", 0.07f, "Hyperbolic growth rate toward the max chance per additional stack."); ExtraChanceMax = config.Bind<float>("BulkOrder", "ExtraChanceMax", 0.3f, "Maximum chance."); Def = Assets.CreateItemDef("BulkOrder", "BULK_ORDER", (ItemTier)0, Assets.LoadSprite("SupplyChain.icon_bulk_order.rgba", 128), Assets.CreatePickupModel("PickupBulkOrder", "SupplyChain.models.bulk_order.obj", "SupplyChain.models.bulk_order.rgba", 512, 0.6f), (ItemTag[])(object)new ItemTag[2] { (ItemTag)3, (ItemTag)4 }); ItemAPI.Add(new CustomItem(Def, new ItemDisplayRuleDict((ItemDisplayRule[])null))); int num = Mathf.RoundToInt(ExtraChanceBase.Value * 100f); int num2 = Mathf.RoundToInt(ExtraChanceMax.Value * 100f); LanguageAPI.Add("BULK_ORDER_NAME", "Bulk Order"); LanguageAPI.Add("BULK_ORDER_PICKUP", "Chests sometimes ship with a free white item."); LanguageAPI.Add("BULK_ORDER_DESC", $"Gold-cost chests have a <style=cIsUtility>{num}% <style=cStack>(up to {num2}% with more stacks)</style></style> chance " + "to contain an additional <style=cIsUtility>common item</style>."); LanguageAPI.Add("BULK_ORDER_LORE", "Buy nine crates, the tenth crate ships free. Contents of tenth crate not guaranteed, inspected, or in some cases identified."); } } internal static class ForceMultiplier { private delegate int orig_GetItemCountEffective(Inventory self, ItemIndex itemIndex); internal static ItemDef Def; internal static ConfigEntry<float> BoostPerStack; internal static void Init(ConfigFile config) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) BoostPerStack = config.Bind<float>("ForceMultiplier", "BoostPerStack", 0.1f, "Fractional bonus stacks applied to all other standard-tier items, per stack. Rounded down per item."); Def = Assets.CreateItemDef("ForceMultiplier", "FORCE_MULTIPLIER", (ItemTier)2, Assets.LoadSprite("SupplyChain.icon_force_multiplier.rgba", 128), Assets.CreatePickupModel("PickupForceMultiplier", "SupplyChain.models.force_multiplier.obj", "SupplyChain.models.force_multiplier.rgba", 512, 0.7f), (ItemTag[])(object)new ItemTag[2] { (ItemTag)3, (ItemTag)4 }); ItemAPI.Add(new CustomItem(Def, new ItemDisplayRuleDict((ItemDisplayRule[])null))); int num = Mathf.RoundToInt(BoostPerStack.Value * 100f); LanguageAPI.Add("FORCE_MULTIPLIER_NAME", "Force Multiplier"); LanguageAPI.Add("FORCE_MULTIPLIER_PICKUP", "Deep stacks run deeper."); LanguageAPI.Add("FORCE_MULTIPLIER_DESC", $"All other standard items behave as if you had <style=cIsUtility>{num}% <style=cStack>(+{num}% per stack)</style> more stacks</style>, " + "rounded <style=cStack>down</style> per item. Lunar and void items are unaffected."); LanguageAPI.Add("FORCE_MULTIPLIER_LORE", "\"The audit found that the quartermaster had been reporting each pallet as one-point-one pallets. The audit also found that, somehow, the math held up under fire.\""); MethodInfo method = typeof(Inventory).GetMethod("GetItemCountEffective", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(ItemIndex) }, null); new Hook((MethodBase)method, typeof(ForceMultiplier).GetMethod("AmplifyCount", BindingFlags.Static | BindingFlags.NonPublic)); } private static int AmplifyCount(orig_GetItemCountEffective orig, Inventory self, ItemIndex itemIndex) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0049: 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) int num = orig(self, itemIndex); if (num <= 0 || (Object)(object)Def == (Object)null || (int)Def.itemIndex == -1 || !SupplyChainPlugin.AmplifiableItems.Contains(itemIndex)) { return num; } int num2 = orig(self, Def.itemIndex); if (num2 <= 0) { return num; } return num + (int)((float)num * BoostPerStack.Value * (float)num2); } } internal static class LoadedDice { internal static ItemDef Def; internal static ConfigEntry<float> BonusChanceBase; internal static ConfigEntry<float> BonusChancePerStack; internal static ConfigEntry<float> BonusChanceMax; internal static ConfigEntry<int> StageCapBase; internal static void Init(ConfigFile config) { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown BonusChanceBase = config.Bind<float>("LoadedDice", "BonusChanceBase", 0.15f, "Chance for a gold chest to drop a bonus item one tier below its contents, with one stack."); BonusChancePerStack = config.Bind<float>("LoadedDice", "BonusChancePerStack", 0.1f, "Hyperbolic growth rate toward the max chance per additional stack."); BonusChanceMax = config.Bind<float>("LoadedDice", "BonusChanceMax", 0.4f, "Maximum chance."); StageCapBase = config.Bind<int>("LoadedDice", "StageCapBase", 2, "Maximum bonus drops per stage with one stack (+1 per additional stack). Shared with Recall Notice."); Def = Assets.CreateItemDef("LoadedDice", "LOADED_DICE", (ItemTier)1, Assets.LoadSprite("SupplyChain.icon_loaded_dice.rgba", 128), Assets.CreatePickupModel("PickupLoadedDice", "SupplyChain.models.loaded_dice.obj", "SupplyChain.models.loaded_dice.rgba", 512, 0.55f), (ItemTag[])(object)new ItemTag[2] { (ItemTag)3, (ItemTag)4 }); ItemAPI.Add(new CustomItem(Def, new ItemDisplayRuleDict((ItemDisplayRule[])null))); int num = Mathf.RoundToInt(BonusChanceBase.Value * 100f); int num2 = Mathf.RoundToInt(BonusChanceMax.Value * 100f); LanguageAPI.Add("LOADED_DICE_NAME", "Loaded Dice"); LanguageAPI.Add("LOADED_DICE_PICKUP", "Chests sometimes pay out twice... the house set a daily limit."); LanguageAPI.Add("LOADED_DICE_DESC", $"Gold-cost chests have a <style=cIsUtility>{num}% <style=cStack>(up to {num2}% with more stacks)</style></style> chance to drop a " + "<style=cIsUtility>bonus item one tier below their contents</style>. " + $"At most <style=cIsUtility>{StageCapBase.Value} <style=cStack>(+1 per stack)</style></style> bonus drops per stage. " + "<style=cIsVoid>Corruptible</style>."); LanguageAPI.Add("LOADED_DICE_LORE", "Confiscated from the estate of a casino magnate. The pips rearrange themselves when nobody is looking, which the courts ruled was technically not cheating because nobody was looking."); } } internal static class PyramidScheme { private class PyramidTracker : MonoBehaviour { internal int knownStacks; } [CompilerGenerated] private static class <>O { public static hook_OnInventoryChanged <0>__DetectPickup; public static hook_GiveMoney <1>__PayUpline; } internal static ItemDef Def; internal static ConfigEntry<float> TithePerStack; private static bool granting; internal static void Init(ConfigFile config) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown TithePerStack = config.Bind<float>("PyramidScheme", "TithePerStack", 0.2f, "Fraction of gold income paid upline (lost) per stack, multiplicative."); Def = Assets.CreateItemDef("PyramidScheme", "PYRAMID_SCHEME", (ItemTier)3, Assets.LoadSprite("SupplyChain.icon_pyramid_scheme.rgba", 128), Assets.CreatePickupModel("PickupPyramidScheme", "SupplyChain.models.pyramid_scheme.obj", "SupplyChain.models.pyramid_scheme.rgba", 512, 0.65f), (ItemTag[])(object)new ItemTag[2] { (ItemTag)3, (ItemTag)4 }); ItemAPI.Add(new CustomItem(Def, new ItemDisplayRuleDict((ItemDisplayRule[])null))); int num = Mathf.RoundToInt(TithePerStack.Value * 100f); LanguageAPI.Add("PYRAMID_SCHEME_NAME", "Pyramid Scheme"); LanguageAPI.Add("PYRAMID_SCHEME_PICKUP", "Gain +1 stack of everything you own... <style=cDeath>but your income pays the upline, forever.</style>"); LanguageAPI.Add("PYRAMID_SCHEME_DESC", "On pickup, gain <style=cIsUtility>+1 stack of every item you own</style>. " + $"Afterwards, <style=cDeath>{num}% of your gold income <style=cStack>(stacks multiplicatively)</style> is paid upline</style>. " + "The upline does not pay back."); LanguageAPI.Add("PYRAMID_SCHEME_LORE", "It's not what you think. It's a reverse funnel system. The structure is more of a triangle, really. Your downline practically builds itself once you stop being so negative. Anyway — about your buy-in."); object obj = <>O.<0>__DetectPickup; if (obj == null) { hook_OnInventoryChanged val = DetectPickup; <>O.<0>__DetectPickup = val; obj = (object)val; } CharacterMaster.OnInventoryChanged += (hook_OnInventoryChanged)obj; object obj2 = <>O.<1>__PayUpline; if (obj2 == null) { hook_GiveMoney val2 = PayUpline; <>O.<1>__PayUpline = val2; obj2 = (object)val2; } CharacterMaster.GiveMoney += (hook_GiveMoney)obj2; } private static void DetectPickup(orig_OnInventoryChanged orig, CharacterMaster self) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_010d: 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) orig.Invoke(self); if (!NetworkServer.active || granting || !Object.op_Implicit((Object)(object)self.inventory) || (Object)(object)Def == (Object)null || (int)Def.itemIndex == -1) { return; } PyramidTracker pyramidTracker = ((Component)self).GetComponent<PyramidTracker>(); if (!Object.op_Implicit((Object)(object)pyramidTracker)) { pyramidTracker = ((Component)self).gameObject.AddComponent<PyramidTracker>(); } int permanentCount = InventoryCompat.GetPermanentCount(self.inventory, Def.itemIndex); int num = permanentCount - pyramidTracker.knownStacks; pyramidTracker.knownStacks = permanentCount; if (num <= 0) { return; } granting = true; try { int num2 = 0; for (int i = 0; i < ItemCatalog.itemCount; i++) { ItemIndex val = (ItemIndex)i; if (val != Def.itemIndex) { ItemDef itemDef = ItemCatalog.GetItemDef(val); if (Object.op_Implicit((Object)(object)itemDef) && !itemDef.hidden && (int)itemDef.tier != 5 && InventoryCompat.GetPermanentCount(self.inventory, val) > 0) { self.inventory.GiveItem(val, num); num2++; } } } Log.Info($"Pyramid Scheme paid out +{num} stack(s) of {num2} item(s) for {Util.GetBestMasterName(self)}"); Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = $"<color=#79c7ec>{Util.GetBestMasterName(self)} joined a pyramid scheme: +{num} stack(s) of {num2} item(s). The upline thanks them.</color>" }); } finally { granting = false; } } private static void PayUpline(orig_GiveMoney orig, CharacterMaster self, uint amount) { //IL_0049: 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_0031: Invalid comparison between Unknown and I4 if (NetworkServer.active && amount != 0 && Object.op_Implicit((Object)(object)self.inventory) && (Object)(object)Def != (Object)null && (int)Def.itemIndex != -1) { int permanentCount = InventoryCompat.GetPermanentCount(self.inventory, Def.itemIndex); if (permanentCount > 0) { amount = (uint)Math.Round((double)amount * Math.Pow(1.0 - (double)Mathf.Clamp01(TithePerStack.Value), permanentCount)); } } orig.Invoke(self, amount); } } internal static class RecallNotice { internal static ItemDef Def; internal static void Init(ConfigFile config) { //IL_005d: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) Def = Assets.CreateItemDef("RecallNotice", "RECALL_NOTICE", (ItemTier)7, Assets.LoadSprite("SupplyChain.icon_recall_notice.rgba", 128), Assets.CreatePickupModel("PickupRecallNotice", "SupplyChain.models.recall_notice.obj", "SupplyChain.models.recall_notice.rgba", 512, 0.6f), (ItemTag[])(object)new ItemTag[2] { (ItemTag)3, (ItemTag)4 }); Def.requiredExpansion = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion(); ItemAPI.Add(new CustomItem(Def, new ItemDisplayRuleDict((ItemDisplayRule[])null))); ItemRelationshipProvider val = ScriptableObject.CreateInstance<ItemRelationshipProvider>(); ((Object)val).name = "SupplyChainContagiousItems"; val.relationshipType = Addressables.LoadAssetAsync<ItemRelationshipType>((object)"RoR2/DLC1/Common/ContagiousItem.asset").WaitForCompletion(); val.relationships = (Pair[])(object)new Pair[1] { new Pair { itemDef1 = LoadedDice.Def, itemDef2 = Def } }; ContentAddition.AddItemRelationshipProvider(val); LanguageAPI.Add("RECALL_NOTICE_NAME", "Recall Notice"); LanguageAPI.Add("RECALL_NOTICE_PICKUP", "Chests always ship a bonus item — direct from the manufacturer in the void. <style=cIsVoid>Corrupts all Loaded Dice</style>."); LanguageAPI.Add("RECALL_NOTICE_DESC", "Gold-cost chests <style=cIsUtility>always</style> drop a bonus item, but the bonus is a <style=cIsVoid>void item</style> of the chest's tier. Shares Loaded Dice's per-stage bonus cap. <style=cIsVoid>Corrupts all Loaded Dice</style>."); LanguageAPI.Add("RECALL_NOTICE_LORE", "URGENT PRODUCT RECALL\nAffected units: all\nDefect: contents replaced during shipping\nRemedy: none. Replacement parts have already been delivered. Please do not attempt to return them."); } } internal static class StandingOrder { internal static ItemDef Def; internal static ConfigEntry<int> ItemsPerStack; internal static void Init(ConfigFile config) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown ItemsPerStack = config.Bind<int>("StandingOrder", "ItemsPerStack", 1, "Number of lowest-count items topped up by +1 stack each stage, per stack of this item."); Def = Assets.CreateItemDef("StandingOrder", "STANDING_ORDER", (ItemTier)2, Assets.LoadSprite("SupplyChain.icon_standing_order.rgba", 128), Assets.CreatePickupModel("PickupStandingOrder", "SupplyChain.models.standing_order.obj", "SupplyChain.models.standing_order.rgba", 512, 0.7f), (ItemTag[])(object)new ItemTag[2] { (ItemTag)3, (ItemTag)4 }); ItemAPI.Add(new CustomItem(Def, new ItemDisplayRuleDict((ItemDisplayRule[])null))); LanguageAPI.Add("STANDING_ORDER_NAME", "Standing Order"); LanguageAPI.Add("STANDING_ORDER_PICKUP", "Automatically restock your scarcest items each stage."); LanguageAPI.Add("STANDING_ORDER_DESC", "At the start of each stage, gain <style=cIsUtility>+1 stack</style> of your " + $"<style=cIsUtility>{ItemsPerStack.Value} <style=cStack>(+{ItemsPerStack.Value} per stack)</style> lowest-count item(s)</style>. " + "Lunar, void, and hidden items are not restocked."); LanguageAPI.Add("STANDING_ORDER_LORE", "PROCUREMENT DIRECTIVE 7-C: Inventory levels shall be maintained. Shortfalls shall be remedied. Questions about where the materiel comes from shall be directed to the office of not asking that."); Stage.onServerStageBegin += OnStageBegin; } private static void OnStageBegin(Stage stage) { //IL_00a5: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterMaster master = instance.master; Inventory val = (Object.op_Implicit((Object)(object)master) ? master.inventory : null); if (!Object.op_Implicit((Object)(object)val)) { continue; } int itemCount = val.GetItemCount(Def); if (itemCount <= 0) { continue; } int count = itemCount * ItemsPerStack.Value; List<(ItemIndex, int)> list = new List<(ItemIndex, int)>(); foreach (ItemIndex amplifiableItem in SupplyChainPlugin.AmplifiableItems) { int permanentCount = InventoryCompat.GetPermanentCount(val, amplifiableItem); if (permanentCount > 0) { list.Add((amplifiableItem, permanentCount)); } } foreach (var item in (from e in list orderby e.count, (int)e.index select e).Take(count)) { val.GiveItem(item.Item1, 1); ItemDef itemDef = ItemCatalog.GetItemDef(item.Item1); Log.Info("Standing Order restocked " + (((itemDef != null) ? ((Object)itemDef).name : null) ?? "?") + " for " + Util.GetBestMasterName(master)); } } } } } namespace SupplyChain.Artifacts { internal static class ArtifactOfDiversification { internal static ArtifactDef Def; internal static ConfigEntry<int> RerollThreshold; internal static bool Enabled => Object.op_Implicit((Object)(object)Def) && Object.op_Implicit((Object)(object)RunArtifactManager.instance) && RunArtifactManager.instance.IsArtifactEnabled(Def); internal static void Init(ConfigFile config) { RerollThreshold = config.Bind<int>("ArtifactOfDiversification", "RerollThreshold", 5, "Chest drops reroll once if the opener already owns at least this many stacks of the rolled item."); Def = ScriptableObject.CreateInstance<ArtifactDef>(); Def.cachedName = "ArtifactOfDiversification"; Def.nameToken = "ARTIFACT_DIVERSIFICATION_NAME"; Def.descriptionToken = "ARTIFACT_DIVERSIFICATION_DESC"; Def.smallIconSelectedSprite = Assets.LoadSprite("SupplyChain.icon_artifact_diversification_enabled.rgba", 128); Def.smallIconDeselectedSprite = Assets.LoadSprite("SupplyChain.icon_artifact_diversification_disabled.rgba", 128); ContentAddition.AddArtifactDef(Def); LanguageAPI.Add("ARTIFACT_DIVERSIFICATION_NAME", "Artifact of Diversification"); LanguageAPI.Add("ARTIFACT_DIVERSIFICATION_DESC", $"Chests reroll their contents once when they would drop an item you already own {RerollThreshold.Value}+ stacks of."); } } }