using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HG;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.Hologram;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Suppression")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Suppression")]
[assembly: AssemblyTitle("Suppression")]
[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 Suppression
{
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("Acanthi.Suppression", "Suppression", "0.0.1")]
public class Suppression : BaseUnityPlugin
{
public class VoidSuppressorBehaviorFixer : MonoBehaviour
{
private VoidSuppressorBehavior voidSuppressor;
private PurchaseInteraction purchaseInteraction;
private HologramProjector hologramProjector;
private int stage;
public void Awake()
{
voidSuppressor = ((Component)this).gameObject.GetComponent<VoidSuppressorBehavior>();
purchaseInteraction = ((Component)this).gameObject.GetComponent<PurchaseInteraction>();
hologramProjector = ((Component)this).gameObject.GetComponent<HologramProjector>();
}
public void Start()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0029: 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_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: 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)
int childCount = ((Component)((Component)this).gameObject.transform.GetChild(0)).transform.childCount;
GameObject val = new GameObject();
val.transform.localPosition = hologramLocalPosOriginal;
val.transform.localRotation = new Quaternion(0f, 180f, 0f, 0f);
Object.Instantiate<GameObject>(val, ((Component)((Component)this).gameObject.transform.GetChild(0)).gameObject.transform);
Object.Destroy((Object)(object)val);
hologramProjector.hologramPivot = ((Component)((Component)this).gameObject.transform.GetChild(0)).gameObject.transform.GetChild(childCount);
if (!NetworkServer.active)
{
GameObject val2 = Object.Instantiate<GameObject>(lunarInfectionLarge, ((Component)this).gameObject.transform);
Renderer[] array = (from thing in val2.GetComponentsInChildren<Renderer>()
where ((Object)thing.material).name == "matLunarInfection (Instance)"
select thing).ToArray();
Renderer[] array2 = array;
foreach (Renderer val3 in array2)
{
((Component)val3).gameObject.SetActive(true);
((Component)val3).gameObject.transform.localScale = new Vector3(0.3f, 0.4f, 0.4f);
((Component)val3).gameObject.transform.localPosition = new Vector3(0.15f, -0.65f, 0.4f);
val3.material = Object.Instantiate<Material>(brotherInfectionWhite);
val3.material.SetColor("_EmColor", Color32.op_Implicit(ColorCatalog.GetColor(ItemTierCatalog.GetItemTierDef((ItemTier)6).colorIndex)));
}
}
if (!Object.op_Implicit((Object)(object)purchaseInteraction))
{
return;
}
((UnityEvent<Interactor>)(object)purchaseInteraction.onPurchase).AddListener((UnityAction<Interactor>)delegate
{
//IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: 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_00c7: 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_00dc: 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)
if (voidSuppressor.purchaseCount <= 0)
{
purchaseInteraction.cost = 0;
}
else if (voidSuppressor.purchaseCount == 1)
{
purchaseInteraction.cost = (int)(1f * voidSuppressor.costMultiplierPerPurchase);
if (dropScrapOnSuppress)
{
PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(Items.ScrapWhiteSuppressed.itemIndex), ((Component)this).gameObject.transform.position, Vector3.up * 10f);
}
}
else if (voidSuppressor.purchaseCount == 2)
{
if (dropScrapOnSuppress)
{
PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(Items.ScrapGreenSuppressed.itemIndex), ((Component)this).gameObject.transform.position, Vector3.up * 10f);
}
}
else if (dropScrapOnSuppress)
{
PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(Items.ScrapRedSuppressed.itemIndex), ((Component)this).gameObject.transform.position, Vector3.up * 10f);
}
});
}
public void Update()
{
//IL_011f: 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)
//IL_012e: 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_00dc: 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)
if (!Object.op_Implicit((Object)(object)voidSuppressor))
{
return;
}
if (currency == 2)
{
((Component)hologramProjector.hologramPivot).gameObject.SetActive(false);
}
else if (voidSuppressor.hasRevealed)
{
if (voidSuppressor.purchaseCount <= 0)
{
((Component)hologramProjector.hologramPivot).gameObject.SetActive(false);
}
else if (voidSuppressor.purchaseCount == 1)
{
((Component)hologramProjector.hologramPivot).gameObject.SetActive(true);
}
((Component)hologramProjector.hologramPivot).gameObject.transform.localPosition = Vector3.MoveTowards(((Component)hologramProjector.hologramPivot).gameObject.transform.localPosition, hologramLocalPosOpen, Time.fixedDeltaTime);
}
else
{
((Component)hologramProjector.hologramPivot).gameObject.transform.localPosition = Vector3.MoveTowards(((Component)hologramProjector.hologramPivot).gameObject.transform.localPosition, hologramLocalPosOriginal, Time.fixedDeltaTime);
}
}
}
public const string PluginGUID = "Acanthi.Suppression";
public const string PluginAuthor = "Acanthi";
public const string PluginName = "Suppression";
public const string PluginVersion = "0.0.1";
public static InteractableSpawnCard voidSupressorSpawnCard;
public static GameObject lunarInfectionLarge;
public static Material brotherInfectionWhite;
public static Vector3 hologramLocalPosOriginal = new Vector3(0.2f, 0.8f, 1f);
public static Vector3 hologramLocalPosOpen = new Vector3(0.2f, 0.8f, 1.4f);
public static bool dropScrapOnSuppress;
public static bool singleItemOnly;
public static int alwaysReveal;
public static int currency;
[SystemInitializer(new Type[] { typeof(SceneCatalog) })]
public static void Init()
{
Log.Warning("Suppression!");
FixStrangeScrap();
SetupVoidSuppressorPrefab();
Stage.onServerStageBegin += onServerStageBegin;
}
private static void FixStrangeScrap()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
Items.ScrapWhiteSuppressed.tier = (ItemTier)0;
if (Items.ScrapWhiteSuppressed.DoesNotContainTag((ItemTag)10))
{
ref ItemTag[] tags = ref Items.ScrapWhiteSuppressed.tags;
ItemTag val = (ItemTag)10;
ArrayUtils.ArrayAppend<ItemTag>(ref tags, ref val);
}
Items.ScrapGreenSuppressed.tier = (ItemTier)1;
if (Items.ScrapGreenSuppressed.DoesNotContainTag((ItemTag)10))
{
ref ItemTag[] tags2 = ref Items.ScrapGreenSuppressed.tags;
ItemTag val = (ItemTag)10;
ArrayUtils.ArrayAppend<ItemTag>(ref tags2, ref val);
}
Items.ScrapRedSuppressed.tier = (ItemTier)2;
if (Items.ScrapRedSuppressed.DoesNotContainTag((ItemTag)10))
{
ref ItemTag[] tags3 = ref Items.ScrapRedSuppressed.tags;
ItemTag val = (ItemTag)10;
ArrayUtils.ArrayAppend<ItemTag>(ref tags3, ref val);
}
}
private static void SetupVoidSuppressorPrefab()
{
//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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
lunarInfectionLarge = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/bazaar/LunarInfectionLargeMesh.prefab").WaitForCompletion();
brotherInfectionWhite = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Brother/matBrotherInfectionWhite.mat").WaitForCompletion();
voidSupressorSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC1/VoidSuppressor/iscVoidSuppressor.asset").WaitForCompletion();
((SpawnCard)voidSupressorSpawnCard).prefab.transform.position = new Vector3(0f, 0f, 0f);
Vector3 localPosition = ((Component)((SpawnCard)voidSupressorSpawnCard).prefab.gameObject.transform.GetChild(0)).gameObject.transform.localPosition;
((Component)((SpawnCard)voidSupressorSpawnCard).prefab.gameObject.transform.GetChild(0)).gameObject.transform.localPosition = new Vector3(localPosition.x, localPosition.y - 1.45f, localPosition.z);
if (currency != 2)
{
((SpawnCard)voidSupressorSpawnCard).prefab.GetComponent<PurchaseInteraction>().cost = 1;
((SpawnCard)voidSupressorSpawnCard).prefab.GetComponent<PurchaseInteraction>().costType = (CostTypeIndex)((currency == 0) ? 14 : 3);
((SpawnCard)voidSupressorSpawnCard).prefab.GetComponent<VoidSuppressorBehavior>().costMultiplierPerPurchase = 2f;
}
((SpawnCard)voidSupressorSpawnCard).prefab.GetComponent<Highlight>().targetRenderer = (Renderer)(object)((Component)((Component)((SpawnCard)voidSupressorSpawnCard).prefab.gameObject.transform.GetChild(0)).gameObject.transform.GetChild(5)).GetComponent<SkinnedMeshRenderer>();
((SpawnCard)voidSupressorSpawnCard).prefab.AddComponent<VoidSuppressorBehaviorFixer>();
((SpawnCard)voidSupressorSpawnCard).prefab.AddComponent<HologramProjector>().disableHologramRotation = true;
}
private static void onServerStageBegin(Stage obj)
{
bool flag = true;
bool flag2 = true;
Log.Warning("Spawned a supressor!");
FindAltarsInScene();
}
public static void FindAltarsInScene()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: 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_010b: 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_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
PortalStatueBehavior[] array = Resources.FindObjectsOfTypeAll(typeof(PortalStatueBehavior)) as PortalStatueBehavior[];
foreach (PortalStatueBehavior val in array)
{
if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null || (int)val.portalType != 0 || ((Component)val).gameObject.activeSelf)
{
continue;
}
InteractableSpawnCard val2 = Object.Instantiate<InteractableSpawnCard>(voidSupressorSpawnCard);
((SpawnCard)val2).prefab.transform.rotation = ((Component)val).gameObject.transform.rotation;
((Component)((SpawnCard)val2).prefab.GetComponent<Highlight>().targetRenderer).gameObject.transform.localPosition = ((Component)((Component)val).GetComponent<Highlight>().targetRenderer).gameObject.transform.localPosition;
((Component)((SpawnCard)val2).prefab.GetComponent<Highlight>().targetRenderer).gameObject.transform.localRotation = ((Component)((Component)val).GetComponent<Highlight>().targetRenderer).gameObject.transform.localRotation;
DirectorPlacementRule val3 = new DirectorPlacementRule
{
placementMode = (PlacementMode)0,
spawnOnTarget = ((Component)val).gameObject.transform,
position = ((Component)val).gameObject.transform.position
};
DirectorSpawnRequest val4 = new DirectorSpawnRequest((SpawnCard)(object)val2, val3, Run.instance.stageRng);
GameObject val5 = DirectorCore.instance.TrySpawnObject(val4);
VoidSuppressorBehavior component = val5.GetComponent<VoidSuppressorBehavior>();
component.numItemsToReveal = 0;
component.itemsSuppressedPerPurchase = 0;
if (alwaysReveal == 1)
{
component.numItemsToReveal = 3;
}
else if (alwaysReveal == 2)
{
component.numItemsToReveal = 0;
}
else
{
for (int j = 0; j < 3; j++)
{
float num = Random.Range(0f, 100f);
if (num <= (float)(75 / (j + 1)))
{
component.numItemsToReveal++;
}
}
}
if (singleItemOnly)
{
component.itemsSuppressedPerPurchase = 1;
}
else
{
float num2 = Random.Range(0f, 100f);
if (num2 <= 50f)
{
component.itemsSuppressedPerPurchase = 1;
}
else
{
component.itemsSuppressedPerPurchase = 3;
}
}
Renderer[] array2 = (from thing in ((Component)val).GetComponentsInChildren<Renderer>()
where ((Object)thing.material).name == "matLunarInfection (Instance)"
select thing).ToArray();
Renderer[] array3 = array2;
foreach (Renderer val6 in array3)
{
((Component)val6).gameObject.SetActive(true);
val6.material = Object.Instantiate<Material>(brotherInfectionWhite);
val6.material.SetColor("_EmColor", Color32.op_Implicit(ColorCatalog.GetColor(ItemTierCatalog.GetItemTierDef((ItemTier)6).colorIndex)));
GameObject val7 = Object.Instantiate<GameObject>(((Component)val6).gameObject, val5.transform);
}
break;
}
}
public void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
InitConfig();
}
public void InitConfig()
{
dropScrapOnSuppress = ((BaseUnityPlugin)this).Config.Bind<bool>("Tweaks", "Drop Scrap on Suppress", false, "Drops Strange Scrap after removing an item from the universe.").Value;
singleItemOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Tweaks", "Single Item Only", false, "Removes the ability to suppress multiple items.").Value;
alwaysReveal = ((BaseUnityPlugin)this).Config.Bind<int>("Tweaks", "Always Reveal Item", 0, "(0 = 75% Chance, 1 = Always Show, 2 = Never Show)").Value;
currency = ((BaseUnityPlugin)this).Config.Bind<int>("Tweaks", "Use Currency", 0, "(0 = Void Coins, 1 = Lunar Coins, 2 = Disable Cost)").Value;
}
}
}