using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using RoR2; using RoR2.ContentManagement; using RoR2.Navigation; using RoR2BepInExPack.GameAssetPaths.Version_1_39_0; using UnityEngine; using UnityEngine.AddressableAssets; [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("BasicChest")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BasicChest")] [assembly: AssemblyTitle("BasicChest")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace BasicChest { [BepInPlugin("com.viliger.BasicChest", "BasicChest", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BasicChestPlugin : BaseUnityPlugin { public const string Author = "viliger"; public const string ModName = "BasicChest"; public const string Version = "1.0.1"; public const string GUID = "com.viliger.BasicChest"; public static ConfigEntry DropList; public static ConfigEntry GoldCost; public static ConfigEntry DirectorCost; public static ConfigEntry Tier1Weight; public static ConfigEntry Tier2Weight; public static ConfigEntry Tier3Weight; public static ConfigEntry EverythingElseWeight; public void Awake() { //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown DropList = ((BaseUnityPlugin)this).Config.Bind("Basic Chest", "Drop Table", string.Join(",", "CritGlasses", "Hoof", "Feather", "SprintBonus", "Syringe", "BossDamageBonus", "StickyBomb", "SecondarySkillMagazine", "Missile", "ChainLightning", "ExplodeOnDeath", "FireRing", "IceRing", "Behemoth", "AlienHead", "UtilitySkillMagazine", "Dagger"), "Drop table, separated by coma (,). You can get internal item names by using DebugToolkit's list_item command."); GoldCost = ((BaseUnityPlugin)this).Config.Bind("Basic Chest", "Gold Cost", 40, "Cost of Basic Chest."); DirectorCost = ((BaseUnityPlugin)this).Config.Bind("Basic Chest", "Director Cost", 30, "Director cost of Basic Chest."); Tier1Weight = ((BaseUnityPlugin)this).Config.Bind("Basic Chest", "Tier 1 Weight", 79.2f, "Weight of Tier 1 items. Weights are relative to each other."); Tier2Weight = ((BaseUnityPlugin)this).Config.Bind("Basic Chest", "Tier 2 Weight", 19.8f, "Weight of Tier 2 items. Weights are relative to each other."); Tier3Weight = ((BaseUnityPlugin)this).Config.Bind("Basic Chest", "Tier 3 Weight", 1f, "Weight of Tier 3 items. Weights are relative to each other."); EverythingElseWeight = ((BaseUnityPlugin)this).Config.Bind("Basic Chest", "Everything Else Weight", 1f, "Weight of item of everyother tier. Weights are relative to each other."); ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders); Language.collectLanguageRootFolders += Language_collectLanguageRootFolders; SceneDirector.GenerateInteractableCardSelection += new hook_GenerateInteractableCardSelection(SceneDirector_GenerateInteractableCardSelection); } private WeightedSelection SceneDirector_GenerateInteractableCardSelection(orig_GenerateInteractableCardSelection orig, SceneDirector self) { //IL_0027: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) WeightedSelection val = orig.Invoke(self); if (val == null) { return val; } if (Object.op_Implicit((Object)(object)ContentProvider.iscBasicChest)) { for (int i = 0; i < val.Count; i++) { if ((Object)(object)val.choices[i].value.spawnCard == (Object)(object)ContentProvider.iscBasicChest) { return val; } } for (int j = 0; j < val.Count; j++) { ChoiceInfo val2 = val.choices[j]; if (((Object)val2.value.spawnCard).name == "iscChest2") { DirectorCard val3 = new DirectorCard { spawnCard = (SpawnCard)(object)ContentProvider.iscBasicChest, selectionWeight = val2.value.selectionWeight, spawnDistance = val2.value.spawnDistance, minimumStageCompletions = val2.value.minimumStageCompletions }; val.AddChoice(val3, val2.weight); break; } } } return val; } private void Language_collectLanguageRootFolders(List folders) { folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Language")); } private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentProvider()); } } public class ContentProvider : IContentPackProvider { public static GameObject basicChestPrefab; public static InteractableSpawnCard iscBasicChest; private readonly ContentPack _contentPack = new ContentPack(); public string identifier => "com.viliger.BasicChest.ContentPack"; public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(_contentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { _contentPack.identifier = identifier; basicChestPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync((object)RoR2_Base_Chest2.Chest2_prefab).WaitForCompletion(), "viliger_BasicChest", true); PurchaseInteraction component = basicChestPrefab.GetComponent(); component.displayNameToken = "VILIGER_BASIC_CHEST_NAME"; component.cost = BasicChestPlugin.GoldCost.Value; InspectDef val = Object.Instantiate(Addressables.LoadAssetAsync((object)RoR2_Base_Chest2.Chest2InspectDef_asset).WaitForCompletion()); ((Object)val).name = "idBasicChest"; val.Info.TitleToken = "VILIGER_BASIC_CHEST_NAME"; val.Info.DescriptionToken = "VILIGER_BASIC_CHEST_DESC"; val.Info.FlavorToken = "VILIGER_BASIC_CHEST_LORE"; basicChestPrefab.GetComponent().InspectInfo = val; basicChestPrefab.GetComponent().displayToken = "VILIGER_BASIC_CHEST_NAME"; CustomExplicitDropTable customExplicitDropTable = new CustomExplicitDropTable(); customExplicitDropTable.entries = BasicChestPlugin.DropList.Value.Split(','); customExplicitDropTable.tier1Weight = BasicChestPlugin.Tier1Weight.Value; customExplicitDropTable.tier2Weight = BasicChestPlugin.Tier2Weight.Value; customExplicitDropTable.tier3Weight = BasicChestPlugin.Tier3Weight.Value; customExplicitDropTable.everythingElseWeight = BasicChestPlugin.EverythingElseWeight.Value; basicChestPrefab.GetComponent().dropTable = (PickupDropTable)(object)customExplicitDropTable; ((Renderer)basicChestPrefab.GetComponentInChildren()).material = CreateBasicChestMaterial(); _contentPack.networkedObjectPrefabs.Add((GameObject[])(object)new GameObject[1] { basicChestPrefab }); iscBasicChest = ScriptableObject.CreateInstance(); ((Object)iscBasicChest).name = "iscBasicChest"; ((SpawnCard)iscBasicChest).prefab = basicChestPrefab; ((SpawnCard)iscBasicChest).sendOverNetwork = true; ((SpawnCard)iscBasicChest).hullSize = (HullClassification)0; ((SpawnCard)iscBasicChest).nodeGraphType = (GraphType)0; ((SpawnCard)iscBasicChest).requiredFlags = (NodeFlags)0; ((SpawnCard)iscBasicChest).forbiddenFlags = (NodeFlags)8; ((SpawnCard)iscBasicChest).directorCreditCost = BasicChestPlugin.DirectorCost.Value; ((SpawnCard)iscBasicChest).occupyPosition = true; ((SpawnCard)iscBasicChest).eliteRules = (EliteRules)0; iscBasicChest.orientToFloor = true; iscBasicChest.slightlyRandomizeOrientation = true; iscBasicChest.skipSpawnWhenSacrificeArtifactEnabled = true; iscBasicChest.weightScalarWhenSacrificeArtifactEnabled = 1f; iscBasicChest.skipSpawnWhenDevotionArtifactEnabled = false; iscBasicChest.maxSpawnsPerStage = -1; iscBasicChest.prismaticTrialSpawnChance = 1f; yield break; } private Material CreateBasicChestMaterial() { //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_002d: 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) Material obj = Object.Instantiate(Addressables.LoadAssetAsync((object)RoR2_Base_Chest1.matChest1_mat).WaitForCompletion()); ((Object)obj).name = "matBasicChest"; obj.SetTexture("_MainTex", (Texture)(object)Addressables.LoadAssetAsync((object)RoR2_Base_Common_TrimSheets.texTrimSheetMedical_png).WaitForCompletion()); return obj; } } public class CustomExplicitDropTable : PickupDropTable { public string[] entries = Array.Empty(); public float tier1Weight = 0.8f; public float tier2Weight = 0.2f; public float tier3Weight = 0.01f; public float everythingElseWeight = 0.01f; private readonly WeightedSelection weightedSelection = new WeightedSelection(8); public override void Regenerate(Run run) { GenerateWeightedSelection(run); } private void GenerateWeightedSelection(Run run) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_002e: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) weightedSelection.Clear(); for (int i = 0; i < entries.Length; i++) { ItemIndex val = ItemCatalog.FindItemIndex(entries[i]); if ((int)val != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(val); PickupIndex val2 = PickupCatalog.FindPickupIndex(val); if (val2 != PickupIndex.none && run.IsPickupAvailable(val2)) { weightedSelection.AddChoice(new UniquePickup(val2), GetTierWeight(itemDef.tier)); } } } } private float GetTierWeight(ItemTier tier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown return (int)tier switch { 0 => tier1Weight, 1 => tier2Weight, 2 => tier3Weight, _ => everythingElseWeight, }; } public override UniquePickup GeneratePickupPreReplacement(Xoroshiro128Plus rng) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return PickupDropTable.GeneratePickupFromWeightedSelection(rng, weightedSelection); } public override void GenerateDistinctPickupsPreReplacement(List dest, int desiredCount, Xoroshiro128Plus rng) { PickupDropTable.GenerateDistinctFromWeightedSelection(dest, desiredCount, rng, weightedSelection); } public override int GetPickupCount() { return weightedSelection.Count; } } }