using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.Projectile;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[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 Prototype
{
[BepInPlugin("prototype.item.singularity", "SingularityBand", "0.1.1")]
public class SingularityBand : BaseUnityPlugin
{
private static class Update
{
internal static void Apply()
{
if (!Version.TryParse(RoR2Application.GetBuildId(), out Version result) || !(result < new Version(1, 3)))
{
Harmony.CreateAndPatchAll(typeof(Update), (string)null);
}
}
[HarmonyPatch(typeof(GlobalEventManager), "ProcessHitEnemy")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> ProcessHitEnemy(IEnumerable<CodeInstruction> IL)
{
return OnHitEnemy(IL);
}
}
public const string version = "0.1.1";
public const string identifier = "prototype.item.singularity";
protected async void Awake()
{
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Update.Apply));
Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
ProjectileFuse component = (await Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/ElementalRingVoid/ElementalRingVoidBlackHole.prefab").Task).GetComponent<ProjectileFuse>();
component.fuse *= 0.5f;
}
[HarmonyPatch(typeof(ItemCatalog), "SetItemRelationships")]
[HarmonyPostfix]
private static void SetItemRelationships()
{
Pair[] array = ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem];
ItemDef elementalRingVoid = Items.ElementalRingVoid;
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i].itemDef2 == (Object)(object)elementalRingVoid)
{
array[i].itemDef1 = Items.IceRing;
}
}
Language english = Language.english;
string oldValue = " and " + english.GetLocalizedStringByToken(Items.FireRing.nameToken).Split().First();
string[] array2 = new string[2] { elementalRingVoid.pickupToken, elementalRingVoid.descriptionToken };
foreach (string text in array2)
{
english.SetStringByToken(text, english.GetLocalizedStringByToken(text).Replace(oldValue, ""));
}
oldValue = english.GetLocalizedStringByToken(elementalRingVoid.descriptionToken);
oldValue = oldValue.Replace("20</style> seconds", "10</style> seconds");
oldValue = oldValue.Replace("5</style> seconds", "2.5</style> seconds");
english.SetStringByToken(elementalRingVoid.descriptionToken, oldValue);
}
[HarmonyPatch(typeof(GlobalEventManager), "OnHitEnemy")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> OnHitEnemy(IEnumerable<CodeInstruction> IL)
{
CodeInstruction branch = null;
CodeInstruction previous = null;
foreach (CodeInstruction item in IL)
{
if (item.opcode == OpCodes.Br)
{
branch = item;
}
else if (CodeInstructionExtensions.LoadsField(item, typeof(Buffs).GetField("ElementalRingVoidReady", BindingFlags.Static | BindingFlags.Public), false))
{
branch.opcode = OpCodes.Nop;
}
else if (item.opcode == OpCodes.Ble && CodeInstructionExtensions.LoadsConstant(previous, 20.0))
{
previous.operand = 10f;
}
previous = item;
yield return item;
}
}
}
}