using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2.UI;
using R2API.Utils;
using RoR2;
using RoR2.UI;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WizardObliterate")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WizardObliterate")]
[assembly: AssemblyTitle("WizardObliterate")]
[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 WizardObliterate
{
public static class Assets
{
public static AssetBundle mainAssetBundle = null;
internal static string assetBundleName = "wizardobliterate";
internal static string assemblyDir => Path.GetDirectoryName(WizardObliterate.pluginInfo.Location);
public static void PopulateAssets()
{
mainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(assemblyDir, assetBundleName));
}
}
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);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Miyowi.Orbliteration", "Orbliteration", "1.1.3")]
public class WizardObliterate : BaseUnityPlugin
{
public const string PluginGUID = "Miyowi.Orbliteration";
public const string PluginAuthor = "Miyowi";
public const string PluginName = "Orbliteration";
public const string PluginVersion = "1.1.3";
public static PluginInfo pluginInfo;
private static Random rnd = new Random();
private GameObject Whitescreen;
private GameObject Wizardscreen;
private float alpha;
private static Coroutine currentCoroutine;
public static WizardObliterate instance;
private HUD hud;
public void Awake()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
instance = this;
pluginInfo = ((BaseUnityPlugin)this).Info;
Log.Init(((BaseUnityPlugin)this).Logger);
Assets.PopulateAssets();
HUD.Awake += new hook_Awake(GetHud);
HealthComponent.HandleDamageDealt += new Manipulator(BestVoidHook);
}
public void OnDestroy()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
HUD.Awake -= new hook_Awake(GetHud);
HealthComponent.HandleDamageDealt -= new Manipulator(BestVoidHook);
}
public Sprite LoadRandomWizard()
{
int num = rnd.Next(1, 8);
return Assets.mainAssetBundle.LoadAsset<Sprite>($"wizard{num}.png");
}
private void GetHud(orig_Awake orig, HUD self)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_004e: 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_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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)
orig.Invoke(self);
hud = self;
Wizardscreen = new GameObject("Wizardscreen");
Wizardscreen.transform.SetParent(hud.mainContainer.transform);
RectTransform val = Wizardscreen.AddComponent<RectTransform>();
val.anchorMin = Vector2.zero;
val.anchorMax = Vector2.one;
val.sizeDelta = Vector2.zero;
val.anchoredPosition = Vector2.zero;
Wizardscreen.AddComponent<Image>();
Whitescreen = new GameObject("Whitescreen");
Whitescreen.transform.SetParent(hud.mainContainer.transform);
val = Whitescreen.AddComponent<RectTransform>();
val.anchorMin = Vector2.zero;
val.anchorMax = Vector2.one;
val.sizeDelta = Vector2.zero;
val.anchoredPosition = Vector2.zero;
Image val2 = Whitescreen.AddComponent<Image>();
val2.sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 4f, 4f), Vector2.zero);
FlashAlpha(0f);
Wizardscreen.gameObject.SetActive(false);
Whitescreen.gameObject.SetActive(false);
}
private void FlashAlpha(float x)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
((Graphic)Whitescreen.GetComponent<Image>()).color = new Color(1f, 1f, 1f, x);
((Graphic)Wizardscreen.GetComponent<Image>()).color = new Color(1f, 1f, 1f, x);
}
public void WizardbangPlayer()
{
if ((Object)(object)Whitescreen != (Object)null && (Object)(object)Wizardscreen != (Object)null)
{
Wizardscreen.GetComponent<Image>().sprite = LoadRandomWizard();
if (currentCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(currentCoroutine);
}
currentCoroutine = ((MonoBehaviour)this).StartCoroutine(Fade());
}
}
private IEnumerator Fade()
{
Wizardscreen.gameObject.SetActive(true);
Whitescreen.gameObject.SetActive(true);
alpha = 0.4f;
FlashAlpha(alpha);
while (alpha >= 0f)
{
yield return (object)new WaitForSeconds(0.04f);
alpha -= 0.01f * (2f - alpha);
FlashAlpha(alpha);
}
Wizardscreen.gameObject.SetActive(false);
Whitescreen.gameObject.SetActive(false);
}
private void BestVoidHook(ILContext il)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
Action<DamageDealtMessage> action = delegate(DamageDealtMessage damageDealtMessage)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_0057: Unknown result type (might be due to invalid IL or missing references)
CharacterBody component = damageDealtMessage.attacker.GetComponent<CharacterBody>();
bool flag = component.master.networkIdentity.netId == LocalUserManager.GetFirstLocalUser().cachedMaster.networkIdentity.netId;
if (component != null && component.isPlayerControlled && flag && DamageTypeCombo.op_Implicit(damageDealtMessage.damageType) == DamageTypeCombo.op_Implicit(DamageTypeCombo.op_Implicit((DamageType)65536)))
{
WizardbangPlayer();
}
};
ILCursor val = new ILCursor(il);
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0)
}) && val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<NetworkMessage>(x, "ReadMessage")
}) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 0)
}))
{
val.Emit(OpCodes.Ldloc_0);
val.EmitDelegate<Action<DamageDealtMessage>>(action);
}
else
{
Log.Error("ILHook failed. Mod will not work as intended.");
}
}
}
}