using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API.Utils;
using RoR2;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("GuaranteedScrapper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GuaranteedScrapper")]
[assembly: AssemblyTitle("GuaranteedScrapper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace GuaranteedScraper
{
[BepInPlugin("cavemoss.GuaranteedScraper", "GuaranteedScraper", "1.0.0")]
public class GuaranteedScrapper : BaseUnityPlugin
{
public bool canSpawn;
public static ConfigEntry<int> ScrapperAmount { get; set; }
public void Awake()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
ScrapperAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "Scrapper Amount", 3, new ConfigDescription("Amount of scrappers to be spawned on each stage. (0 for vanilla spawn rate).", (AcceptableValueBase)null, Array.Empty<object>()));
PurchaseInteraction.CanBeAffordedByInteractor += new hook_CanBeAffordedByInteractor(PurchaseInteraction_CanBeAffordedByInteractor);
PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(PurchaseInteraction_OnInteractionBegin);
ShopTerminalBehavior.DropPickup += new hook_DropPickup(ShopTerminalBehavior_DropPickup);
PurchaseInteraction.GetContextString += new hook_GetContextString(PurchaseInteraction_GetContextString);
CostHologramContent.FixedUpdate += new hook_FixedUpdate(CostHologramContent_FixedUpdate);
BazaarController.Awake += (hook_Awake)delegate(orig_Awake orig, BazaarController self)
{
SpawnCauldron();
orig.Invoke(self);
};
SceneDirector.GenerateInteractableCardSelection += new hook_GenerateInteractableCardSelection(SceneDirector_GenerateInteractableCardSelection);
SceneDirector.PlaceTeleporter += (hook_PlaceTeleporter)delegate(orig_PlaceTeleporter orig, SceneDirector self)
{
orig.Invoke(self);
if (((ScrapperAmount.Value > 0 && ScrapperAmount.Value != 0) ? 1 : 0) > (false ? 1 : 0) && canSpawn)
{
for (int i = 0; i < ScrapperAmount.Value; i++)
{
SpawnScrapper(self);
}
}
};
SceneCatalog.onMostRecentSceneDefChanged += OnMostRecentSceneDefChanged;
}
private bool PurchaseInteraction_CanBeAffordedByInteractor(orig_CanBeAffordedByInteractor orig, PurchaseInteraction self, Interactor activator)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
return ((int)self.costType == 6 && self.cost == 1 && ((Component)activator).GetComponent<CharacterBody>().inventory.GetTotalItemCountOfTier((ItemTier)4) > 0) || orig.Invoke(self, activator);
}
private async void PurchaseInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
{
if (((Object)self).name.StartsWith("LunarCauldron, RedToWhite Variant"))
{
Random rng = new Random();
List<CostTypeIndex> types = new List<CostTypeIndex>
{
(CostTypeIndex)6,
(CostTypeIndex)10
};
if (((Component)activator).GetComponent<CharacterBody>().inventory.GetTotalItemCountOfTier((ItemTier)4) > 0 && ((Component)activator).GetComponent<CharacterBody>().inventory.GetItemCount(Items.ScrapRed) > 0)
{
if (((Component)activator).GetComponent<CharacterBody>().inventory.GetItemCount(Items.ScrapYellow) > 0)
{
self.costType = types[rng.Next(types.Count)];
self.cost = 1;
}
else
{
self.costType = (CostTypeIndex)6;
self.cost = 1;
}
}
else if (((Component)activator).GetComponent<CharacterBody>().inventory.GetTotalItemCountOfTier((ItemTier)4) > 0 && ((Component)activator).GetComponent<CharacterBody>().inventory.GetItemCount(Items.ScrapYellow) <= 0 && ((Component)activator).GetComponent<CharacterBody>().inventory.GetTotalItemCountOfTier((ItemTier)2) > 0)
{
self.costType = types[rng.Next(types.Count)];
self.cost = 1;
}
else if (((Component)activator).GetComponent<CharacterBody>().inventory.GetTotalItemCountOfTier((ItemTier)2) > 0 && ((Component)activator).GetComponent<CharacterBody>().inventory.GetItemCount(Items.ScrapYellow) > 0)
{
if (((Component)activator).GetComponent<CharacterBody>().inventory.GetItemCount(Items.ScrapRed) > 0)
{
self.costType = types[rng.Next(types.Count)];
self.cost = 1;
}
else
{
self.costType = (CostTypeIndex)10;
self.cost = 1;
}
}
else if (((Component)activator).GetComponent<CharacterBody>().inventory.GetTotalItemCountOfTier((ItemTier)4) > 0)
{
self.costType = (CostTypeIndex)10;
self.cost = 1;
}
orig.Invoke(self, activator);
ShopTerminalBehavior component = ((Component)self).GetComponent<ShopTerminalBehavior>();
await Task.Delay(1550);
for (int i = 0; i < 3; i++)
{
PickupDropletController.CreatePickupDroplet(component.pickupIndex, (Object.op_Implicit((Object)(object)component.dropTransform) ? component.dropTransform : ((Component)component).transform).position, ((Component)component).transform.TransformVector(component.dropVelocity));
await Task.Delay(200);
}
self.costType = (CostTypeIndex)6;
self.cost = 1;
}
else
{
orig.Invoke(self, activator);
}
}
private void ShopTerminalBehavior_DropPickup(orig_DropPickup orig, ShopTerminalBehavior self)
{
if (!((Object)self).name.StartsWith("LunarCauldron, RedToWhite Variant"))
{
orig.Invoke(self);
}
}
private string PurchaseInteraction_GetContextString(orig_GetContextString orig, PurchaseInteraction self, Interactor activator)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Invalid comparison between Unknown and I4
if (((Object)self).name.StartsWith("LunarCauldron, RedToWhite Variant"))
{
PurchaseInteraction.sharedStringBuilder.Clear();
PurchaseInteraction.sharedStringBuilder.Append(Language.GetString(self.contextToken));
if ((int)self.costType > 0)
{
PurchaseInteraction.sharedStringBuilder.Append(" <nobr>(<color=#e7543a>1 Item(s)</color></nobr> / <nobr><color=yellow>1 Item(s)</color>)</nobr>");
}
return PurchaseInteraction.sharedStringBuilder.ToString();
}
return orig.Invoke(self, activator);
}
private void CostHologramContent_FixedUpdate(orig_FixedUpdate orig, CostHologramContent self)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if (!canSpawn)
{
if ((self.displayValue == 1 && (int)self.costType == 6) || (self.displayValue == 1 && (int)self.costType == 10))
{
CostHologramContent.sharedStringBuilder.Clear();
((Graphic)self.targetTextMesh).color = Color.white;
((TMP_Text)self.targetTextMesh).SetText("<nobr><color=#d91111>1 Item(s)</color></nobr><br>OR<br><nobr><color=#736100>1 Item(s)</color></nobr>", true);
}
else
{
orig.Invoke(self);
}
}
else
{
orig.Invoke(self);
}
}
private WeightedSelection<DirectorCard> SceneDirector_GenerateInteractableCardSelection(orig_GenerateInteractableCardSelection orig, SceneDirector self)
{
WeightedSelection<DirectorCard> val = orig.Invoke(self);
if (((ScrapperAmount.Value > 0 && ScrapperAmount.Value != 0) ? 1 : 0) > (false ? 1 : 0))
{
for (int i = 0; i < val.Count; i++)
{
ChoiceInfo<DirectorCard>[] choices = val.choices;
string name = ((Object)val.choices[i].value.spawnCard).name;
if (name.Replace("Sandy", "").Replace("Snowy", "") == "iscScrapper")
{
ChoiceInfo<DirectorCard>[] choices2 = val.choices;
choices2[i].weight = choices2[i].weight * 0f;
}
}
}
return val;
}
public void SpawnScrapper(SceneDirector self)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
Xoroshiro128Plus val = new Xoroshiro128Plus(Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "rng").nextUlong);
if (SceneInfo.instance.countsAsStage)
{
SpawnCard val2 = Resources.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscScrapper");
DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(val2, new DirectorPlacementRule
{
placementMode = (PlacementMode)4
}, val));
}
}
public void SpawnCauldron()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/LunarCauldron, RedToWhite Variant"), new Vector3(-122.6f, -23.65f, -5.7f), Quaternion.identity);
val.transform.eulerAngles = new Vector3(0f, 86f, 0f);
NetworkServer.Spawn(val);
}
public void OnMostRecentSceneDefChanged(SceneDef scene)
{
if (scene.cachedName == "moon2" || scene.cachedName == "bazaar")
{
canSpawn = false;
}
else
{
canSpawn = true;
}
}
}
}