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 AncientScepter; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using R2API; using RoR2; using RoR2.ContentManagement; using RoR2.ExpansionManagement; using RoR2.Navigation; using RoR2BepInExPack.GameAssetPaths.Version_1_39_0; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.Networking; [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("ReliableAncientScepter")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ReliableAncientScepter")] [assembly: AssemblyTitle("ReliableAncientScepter")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } namespace ReliableAncientScepter { public class ContentProvider : IContentPackProvider { private readonly ContentPack _contentPack = new ContentPack(); public static InteractableSpawnCard iscScepterGem; public static ItemDef BrokenScepterShaft; public static ItemDef BrokenScepterGem; public static GameObject voidCampGemInteractable; public static readonly Dictionary ShaderLookup = new Dictionary { { "stubbedror2/base/shaders/hgstandard", "RoR2/Base/Shaders/HGStandard.shader" } }; private Material[] materialCache; public string identifier => "viliger.ReliableAncientScepterPlugin.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; string path = Path.Combine(Path.GetDirectoryName(typeof(ContentProvider).Assembly.Location), "AssetBundles"); AssetBundle assetbundle = null; yield return LoadAssetBundle(Path.Combine(path, "reliablescepter"), args.progressReceiver, delegate(AssetBundle resultAssetBundle) { assetbundle = resultAssetBundle; }); BrokenScepterShaft = CreateItem("ViligerBrokenScepterShaft", assetbundle.LoadAsset("Assets/Scepter/PickupScepterShaft.prefab"), assetbundle.LoadAsset("Assets/Scepter/texScepterShaftIcon.png")); BrokenScepterGem = CreateItem("ViligerBrokenScepterGem", assetbundle.LoadAsset("Assets/Scepter/PickupScepterGem.prefab"), assetbundle.LoadAsset("Assets/Scepter/texScepterGemIcon.png")); _contentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[2] { BrokenScepterGem, BrokenScepterShaft }); CraftableDef val = CreateRecipe(ItemBase.myDef, BrokenScepterShaft, BrokenScepterGem); _contentPack.craftableDefs.Add((CraftableDef[])(object)new CraftableDef[1] { val }); voidCampGemInteractable = CreateVoidCampGemInteractable(assetbundle.LoadAsset("Assets/Scepter/ScepterGemInteractable.prefab"), BrokenScepterGem); _contentPack.networkedObjectPrefabs.Add((GameObject[])(object)new GameObject[1] { voidCampGemInteractable }); iscScepterGem = CreateInteractableSpawnCard(voidCampGemInteractable); materialCache = assetbundle.LoadAllAssets(); SwapMaterials(materialCache); Transform val2 = Addressables.LoadAssetAsync((object)RoR2_DLC1_VoidCamp.VoidCamp_prefab).WaitForCompletion().transform.Find("Camp 1 - Void Monsters & Interactables"); if (Object.op_Implicit((Object)(object)val2)) { ((Component)val2).gameObject.AddComponent().iscScepterGem = iscScepterGem; } } private InteractableSpawnCard CreateInteractableSpawnCard(GameObject prefab) { //IL_0015: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) InteractableSpawnCard obj = ScriptableObject.CreateInstance(); ((SpawnCard)obj).prefab = prefab; ((SpawnCard)obj).sendOverNetwork = true; ((SpawnCard)obj).hullSize = (HullClassification)0; ((SpawnCard)obj).nodeGraphType = (GraphType)0; ((SpawnCard)obj).requiredFlags = (NodeFlags)0; ((SpawnCard)obj).forbiddenFlags = (NodeFlags)8; ((SpawnCard)obj).directorCreditCost = ReliableAncientScepterPlugin.ScepterGemVoidCampCost.Value; ((SpawnCard)obj).occupyPosition = true; ((SpawnCard)obj).eliteRules = (EliteRules)0; obj.orientToFloor = true; obj.maxSpawnsPerStage = 1; return obj; } private CraftableDef CreateRecipe(ItemDef target, ItemDef reg1, ItemDef reg2) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_004f: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown CraftableDef val = ScriptableObject.CreateInstance(); ((Object)val).name = "viligerReliableScepter" + ((Object)target).name; val.pickup = (Object)(object)target; Recipe[] array = new Recipe[1]; Recipe val2 = new Recipe(); val2.ingredients = (RecipeIngredient[])(object)new RecipeIngredient[2] { new RecipeIngredient { pickup = (Object)(object)reg1, type = (IngredientTypeIndex)0 }, new RecipeIngredient { pickup = (Object)(object)reg2, type = (IngredientTypeIndex)0 } }; array[0] = val2; val.recipes = (Recipe[])(object)array; return val; } private GameObject CreateVoidCampGemInteractable(GameObject prefab, ItemDef itemDefToDrop) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown Transform val = prefab.transform.Find("ModelBase/Gem"); prefab.AddComponent(); Highlight obj = prefab.AddComponent(); obj.strength = 1f; obj.targetRenderer = ((Component)val).GetComponent(); obj.highlightColor = (HighlightColor)0; ModelLocator obj2 = prefab.AddComponent(); obj2.modelTransform = val; obj2.modelBaseTransform = prefab.transform.Find("ModelBase"); obj2.dontDetatchFromParent = true; obj2.modelScaleCompensation = val.localScale.x; prefab.AddComponent().requiredExpansion = Addressables.LoadAssetAsync((object)RoR2_DLC1_Common.DLC1_asset).WaitForCompletion(); DropItem dropItem = prefab.AddComponent(); dropItem.itemToDrop = itemDefToDrop; dropItem.dropletOrigin = prefab.transform.Find("ModelBase/DropletOrigin"); PurchaseInteraction obj3 = prefab.AddComponent(); obj3.displayNameToken = "VILIGER_RELIABLE_SCEPTER_INTERACABLE_GEM_NAME"; obj3.contextToken = "VILIGER_RELIABLE_SCEPTER_INTERACABLE_GEM_CONTEXT"; obj3.costType = (CostTypeIndex)0; obj3.setUnavailableOnTeleporterActivated = false; obj3.isShrine = false; obj3.shouldProximityHighlight = true; obj3.onPurchase = new PurchaseEvent(); ((UnityEvent)(object)obj3.onPurchase).AddPersistentListener(dropItem.DropAndDestroySelf); ((Component)val).gameObject.AddComponent().entity = prefab; PrefabAPI.RegisterNetworkPrefab(prefab); return prefab; } private ItemDef CreateItem(string name, GameObject pickupModel, Sprite icon) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ItemDef val = ScriptableObject.CreateInstance(); ((Object)val).name = name; val.tier = (ItemTier)5; val.deprecatedTier = (ItemTier)5; ((Object)val).name = name; val.nameToken = "VILIGER_RELIABLE_SCEPTER_ITEM_" + name.ToUpper() + "_NAME"; val.pickupToken = "VILIGER_RELIABLE_SCEPTER_ITEM_" + name.ToUpper() + "_PICKUP"; val.descriptionToken = "VILIGER_RELIABLE_SCEPTER_ITEM_" + name.ToUpper() + "_DESC"; val.loreToken = "VILIGER_RELIABLE_SCEPTER_ITEM_" + name.ToUpper() + "_LORE"; val.pickupModelPrefab = pickupModel; val.pickupIconSprite = icon; val.canRemove = false; val.isConsumed = true; val.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)30 }; return val; } private void SwapMaterials(Material[] assets) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (assets == null) { return; } Material[] array = assets; foreach (Material val in array) { if (!ShaderLookup.TryGetValue(((Object)val.shader).name.ToLower(), out string value)) { Log.Info("Couldn't find replacement shader for " + ((Object)val.shader).name.ToLower() + " in dictionary for material " + ((Object)val).name + "."); } else { Shader val2 = Addressables.LoadAssetAsync((object)value).WaitForCompletion(); if (Object.op_Implicit((Object)(object)val2)) { int renderQueue = val.renderQueue; val.shader = val2; val.renderQueue = renderQueue; } else { Log.Info("Couldn't find replacement shader for " + ((Object)val.shader).name.ToLower()); } } } } private IEnumerator LoadAssetBundle(string assetBundleFullPath, IProgress progress, Action onAssetBundleLoaded) { AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(assetBundleFullPath); while (!((AsyncOperation)assetBundleCreateRequest).isDone) { progress.Report(((AsyncOperation)assetBundleCreateRequest).progress); yield return null; } onAssetBundleLoaded(assetBundleCreateRequest.assetBundle); } } public class DropItem : MonoBehaviour { public ItemDef itemToDrop; public Transform dropletOrigin; public void DropAndDestroySelf(Interactor interactor) { //IL_002c: 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_0041: 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_0050: 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) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0071: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && Object.op_Implicit((Object)(object)itemToDrop)) { Transform transform = dropletOrigin; if (!Object.op_Implicit((Object)(object)transform)) { transform = ((Component)this).transform; } Vector3 val = Vector3.up * 20f + ((Component)this).transform.forward * 2f; PickupDropletController.CreatePickupDroplet(new UniquePickup(PickupCatalog.FindPickupIndex(itemToDrop.itemIndex)), transform.position, val, false); NetworkServer.Destroy(((Component)this).gameObject); } } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [BepInPlugin("viliger.ReliableAncientScepterPlugin", "ReliableAncientScepterPlugin", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ReliableAncientScepterPlugin : BaseUnityPlugin { public const string Author = "viliger"; public const string Name = "ReliableAncientScepterPlugin"; public const string Version = "1.0.0"; public const string GUID = "viliger.ReliableAncientScepterPlugin"; public static ConfigEntry HalcyoniteRewardChance; public static ConfigEntry ScepterGemVoidCampCost; public static ConfigEntry VoidCampGemSpawnChance; public void Awake() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); HalcyoniteRewardChance = ((BaseUnityPlugin)this).Config.Bind("Reliable Ancient Scepter", "Halcyonite Reward Spawn Chance", 50f, "Percent chance that Scepter Shaft will replace one of the items from Halcyonite Shrine rewards (and the one you get at meridian but shhhh)"); ScepterGemVoidCampCost = ((BaseUnityPlugin)this).Config.Bind("Reliable Ancient Scepter", "Void Camp Spawn Cost", 30, "How much, in credits, it costs Void Camp to spawn Scepter Gem interactable."); VoidCampGemSpawnChance = ((BaseUnityPlugin)this).Config.Bind("Reliable Ancient Scepter", "Void Camp Spawn Chance", 50f, "Percent chance that Scepter Gem will spawn in Void Camp."); ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders); Language.collectLanguageRootFolders += Language_collectLanguageRootFolders; PickupPickerController.GenerateOptionsFromDropTablePlusForcedStorm += new hook_GenerateOptionsFromDropTablePlusForcedStorm(PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm); } private Option[] PickupPickerController_GenerateOptionsFromDropTablePlusForcedStorm(orig_GenerateOptionsFromDropTablePlusForcedStorm orig, int numOptions, PickupDropTable dropTable, PickupDropTable stormDropTable, Xoroshiro128Plus rng) { //IL_004a: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) Option[] array = orig.Invoke(numOptions, dropTable, stormDropTable, rng); if (rng.RangeFloat(0f, 100f) > HalcyoniteRewardChance.Value && Object.op_Implicit((Object)(object)ContentProvider.BrokenScepterShaft) && array.Length != 0) { int num = rng.RangeInt(0, array.Length); array[num] = new Option { available = true, pickup = new UniquePickup(PickupCatalog.FindPickupIndex(ContentProvider.BrokenScepterShaft.itemIndex)) }; } return array; } 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()); } } [RequireComponent(typeof(CampDirector))] public class ScepterVoidCampSpawner : MonoBehaviour { public InteractableSpawnCard iscScepterGem; private CampDirector campDirector; private Xoroshiro128Plus rng; private bool spawn; public static float scepterGemSpawnChance => ReliableAncientScepterPlugin.VoidCampGemSpawnChance.Value; private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if (NetworkServer.active && Object.op_Implicit((Object)(object)iscScepterGem)) { campDirector = ((Component)this).GetComponent(); rng = new Xoroshiro128Plus((ulong)Run.instance.stageRng.nextUint); if (rng.RangeFloat(0f, 100f) > scepterGemSpawnChance) { spawn = true; CampDirector obj = campDirector; obj.baseInteractableCredit -= ((SpawnCard)iscScepterGem).directorCreditCost; } } } private void Start() { if (NetworkServer.active) { SpawnScepterGem(); } } private void SpawnScepterGem() { //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_002b: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)campDirector) || !Object.op_Implicit((Object)(object)iscScepterGem) || !spawn) { return; } DirectorPlacementRule val = new DirectorPlacementRule { placementMode = (PlacementMode)1, minDistance = campDirector.campMinimumRadius, maxDistance = campDirector.campMaximumRadius, position = campDirector.campCenterTransform.position, spawnOnTarget = campDirector.campCenterTransform }; GameObject val2 = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)iscScepterGem, val, rng)); if (Object.op_Implicit((Object)(object)val2)) { PurchaseInteraction component = val2.GetComponent(); if (Object.op_Implicit((Object)(object)component) && (int)component.costType == 1) { component.Networkcost = Run.instance.GetDifficultyScaledCost(component.cost); } } } } public static class Utils { public static void AddPersistentListener(this UnityEvent unityEvent, UnityAction action) { //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_001c: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown ((UnityEventBase)unityEvent).m_PersistentCalls.AddListener(new PersistentCall { m_Target = (Object)/*isinst with value type is only supported in some contexts*/, m_TargetAssemblyTypeName = UnityEventTools.TidyAssemblyTypeName(((Delegate)(object)action).Method.DeclaringType.AssemblyQualifiedName), m_MethodName = ((Delegate)(object)action).Method.Name, m_CallState = (UnityEventCallState)2, m_Mode = (PersistentListenerMode)0 }); } public static void AddPersistentListener(this UnityEvent unityEvent, UnityAction action) { //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_001c: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown ((UnityEventBase)unityEvent).m_PersistentCalls.AddListener(new PersistentCall { m_Target = (Object)/*isinst with value type is only supported in some contexts*/, m_TargetAssemblyTypeName = UnityEventTools.TidyAssemblyTypeName(((Delegate)(object)action).Method.DeclaringType.AssemblyQualifiedName), m_MethodName = ((Delegate)(object)action).Method.Name, m_CallState = (UnityEventCallState)2, m_Mode = (PersistentListenerMode)0 }); } } }