using System;
using System.Collections;
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.2.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.2")]
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);
}
}
[CompilerGenerated]
private sealed class <OnHitEnemy>d__4 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> IL;
public IEnumerable<CodeInstruction> <>3__IL;
private CodeInstruction <branch>5__2;
private CodeInstruction <previous>5__3;
private MethodInfo <method>5__4;
private FieldInfo <field>5__5;
private IEnumerator<CodeInstruction> <>7__wrap5;
private CodeInstruction <instruction>5__7;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OnHitEnemy>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 5u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<branch>5__2 = null;
<previous>5__3 = null;
<method>5__4 = null;
<field>5__5 = null;
<>7__wrap5 = null;
<instruction>5__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Expected O, but got Unknown
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Expected O, but got Unknown
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Expected O, but got Unknown
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<branch>5__2 = null;
<previous>5__3 = null;
<method>5__4 = null;
<field>5__5 = typeof(Buffs).GetField("ElementalRingVoidReady", AccessTools.all);
<>7__wrap5 = IL.GetEnumerator();
<>1__state = -3;
goto IL_0287;
case 1:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Ldfld, (object)typeof(DamageInfo).GetField("damage"));
<>1__state = 2;
return true;
case 2:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Ldc_R4, (object)0.5f);
<>1__state = 3;
return true;
case 3:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Mul, (object)null);
<>1__state = 4;
return true;
case 4:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Sub, (object)null);
<>1__state = 5;
return true;
case 5:
<>1__state = -3;
<method>5__4 = null;
goto IL_0255;
case 6:
{
<>1__state = -3;
<instruction>5__7 = null;
goto IL_0287;
}
IL_0287:
if (<>7__wrap5.MoveNext())
{
<instruction>5__7 = <>7__wrap5.Current;
if (<instruction>5__7.opcode == OpCodes.Br)
{
<branch>5__2 = <instruction>5__7;
}
else if (CodeInstructionExtensions.LoadsField(<instruction>5__7, <field>5__5, false))
{
<branch>5__2.opcode = OpCodes.Nop;
<method>5__4 = typeof(Util).GetMethod("OnHitProcDamage", AccessTools.all);
}
else if ((object)<method>5__4 != null)
{
if (CodeInstructionExtensions.Calls(<previous>5__3, <method>5__4))
{
<>2__current = new CodeInstruction(OpCodes.Ldarg_1, (object)null);
<>1__state = 1;
return true;
}
if (<instruction>5__7.opcode == OpCodes.Ble && CodeInstructionExtensions.LoadsConstant(<previous>5__3, 20.0))
{
<previous>5__3.operand = 10f;
}
}
goto IL_0255;
}
<>m__Finally1();
<>7__wrap5 = null;
return false;
IL_0255:
<previous>5__3 = <instruction>5__7;
<>2__current = <instruction>5__7;
<>1__state = 6;
return true;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>7__wrap5 != null)
{
<>7__wrap5.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<OnHitEnemy>d__4 <OnHitEnemy>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<OnHitEnemy>d__ = this;
}
else
{
<OnHitEnemy>d__ = new <OnHitEnemy>d__4(0);
}
<OnHitEnemy>d__.IL = <>3__IL;
return <OnHitEnemy>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
public const string version = "0.1.2";
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("100%</style>", "50%</style>");
oldValue = oldValue.Replace("5</style> seconds", "2.5</style> seconds");
english.SetStringByToken(elementalRingVoid.descriptionToken, oldValue);
}
[IteratorStateMachine(typeof(<OnHitEnemy>d__4))]
[HarmonyPatch(typeof(GlobalEventManager), "OnHitEnemy")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> OnHitEnemy(IEnumerable<CodeInstruction> IL)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OnHitEnemy>d__4(-2)
{
<>3__IL = IL
};
}
}
}