using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[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("UgandanKnucklesDoom")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UgandanKnucklesDoom")]
[assembly: AssemblyTitle("UgandanKnucklesDoom")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace UgandanKnucklesDoom
{
[BepInPlugin("com.IBMOTH.MageArena.UgandanKnuckles", "Ugandan Knuckles Doom", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
public GameObject Knuckles;
internal static ManualLogSource Log { get; private set; }
private void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Knuckles = LoadKnucklesFromEmbeddedBundle();
Harmony val = new Harmony("com.IBMOTH.MageArena.UgandanKnuckles");
val.PatchAll();
Log.LogInfo((object)"Plugin Ugandan Knuckles Doom is loaded!");
}
private GameObject LoadKnucklesFromEmbeddedBundle()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string text = "UgandanKnucklesDoom.Assets.knucklesbundle";
using Stream stream = executingAssembly.GetManifestResourceStream(text);
if (stream == null)
{
Log.LogError((object)("Embedded AssetBundle '" + text + "' not found!"));
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
AssetBundle val = AssetBundle.LoadFromMemory(array);
if ((Object)(object)val == (Object)null)
{
Log.LogError((object)"Failed to load AssetBundle from memory!");
return null;
}
return val.LoadAsset<GameObject>("Knuckles");
}
}
public static class BlackHoleTracker
{
public static BlackHole Latest;
}
[HarmonyPatch(typeof(BlackHole), "OnEnable")]
public static class BlackHole_OnEnable_Patch
{
private static void Postfix(BlackHole __instance)
{
BlackHoleTracker.Latest = __instance;
}
}
[HarmonyPatch(typeof(PageController), "RpcLogic___CastSpellObs_3976682022")]
public static class DoomPage_CastSpell_Patch
{
private static void Postfix(PageController __instance, GameObject ownerobj, Vector3 fwdVector, int level, Vector3 spawnpos)
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: 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)
if ((Object)(object)__instance.spellprefab == (Object)null || !((Object)__instance.spellprefab).name.Contains("DoomSpell"))
{
return;
}
BlackHole latest = BlackHoleTracker.Latest;
if ((Object)(object)latest == (Object)null)
{
Plugin.Log.LogError((object)"No BlackHole found in tracker!");
return;
}
GameObject gameObject = ((Component)latest).gameObject;
LookatCamera component = gameObject.GetComponent<LookatCamera>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
Transform val = gameObject.transform.Find("holder");
if ((Object)(object)val == (Object)null)
{
return;
}
Transform val2 = ((Component)val).transform.Find("singleplane");
if ((Object)(object)val2 != (Object)null)
{
MeshRenderer component2 = ((Component)val2).GetComponent<MeshRenderer>();
if ((Object)(object)component2 != (Object)null)
{
((Renderer)component2).enabled = false;
}
}
GameObject val3 = Object.Instantiate<GameObject>(Plugin.Instance.Knuckles, val);
((Object)val3).name = "KnucklesVisual";
val3.transform.localPosition = Vector3.zero;
val3.transform.localRotation = Quaternion.identity;
val3.transform.localScale = Vector3.one * 1.2f;
val3.AddComponent<BlackHoleFollower>().target = val;
}
}
public class BlackHoleFollower : MonoBehaviour
{
public Transform target;
private Vector3 initialScale;
private void Awake()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
initialScale = ((Component)this).transform.localScale;
((Component)this).transform.rotation = Quaternion.identity;
}
private void LateUpdate()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)target == (Object)null))
{
((Component)this).transform.position = target.position;
((Component)this).transform.localScale = initialScale;
}
}
}
[HarmonyPatch(typeof(BlackHole), "SetupRoutine")]
public static class BlackHole_SetupRoutine_Patch
{
[CompilerGenerated]
private sealed class <CustomRoutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public BlackHole bh;
private float <timer>5__1;
private Vector3 <startpos>5__2;
private Transform <knuckles>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CustomRoutine>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<knuckles>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Expected O, but got Unknown
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<timer>5__1 = 0f;
<startpos>5__2 = ((Component)bh).transform.position;
goto IL_0136;
case 1:
<>1__state = -1;
<timer>5__1 += Time.deltaTime;
((Component)bh).transform.position = Vector3.Lerp(<startpos>5__2, <startpos>5__2 + new Vector3(0f, 15f, 0f), <timer>5__1 / 2f);
if ((Object)(object)bh.holder != (Object)null)
{
bh.holder.localScale = Vector3.Lerp(Vector3.one * 0.1f, Vector3.one * 0.1f, <timer>5__1 / 2f);
}
goto IL_0136;
case 2:
<>1__state = -1;
<timer>5__1 = 0f;
goto IL_0244;
case 3:
<>1__state = -1;
<timer>5__1 += Time.deltaTime;
if ((Object)(object)bh.holder != (Object)null)
{
bh.holder.localScale = Vector3.Lerp(Vector3.one * 0.1f, Vector3.one, <timer>5__1 * 5f);
}
goto IL_0244;
case 4:
<>1__state = -1;
<timer>5__1 = 0f;
break;
case 5:
{
<>1__state = -1;
<timer>5__1 += Time.deltaTime;
if ((Object)(object)bh.holder != (Object)null)
{
bh.holder.localScale = Vector3.Lerp(Vector3.one, Vector3.one * 0.1f, <timer>5__1 * 5f);
}
break;
}
IL_0244:
if (<timer>5__1 < 0.2f)
{
<>2__current = null;
<>1__state = 3;
return true;
}
typeof(BlackHole).GetField("inited", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(bh, true);
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 4;
return true;
IL_0136:
if (<timer>5__1 < 2f)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<knuckles>5__3 = ((Component)bh).transform.Find("holder/KnucklesVisual");
if ((Object)(object)<knuckles>5__3 != (Object)null && (Object)(object)((Component)<knuckles>5__3).GetComponent<KnucklesFloatSpin>() == (Object)null)
{
((Component)<knuckles>5__3).gameObject.AddComponent<KnucklesFloatSpin>();
}
<>2__current = (object)new WaitForSeconds(0.3f);
<>1__state = 2;
return true;
}
if (<timer>5__1 < 0.2f)
{
<>2__current = null;
<>1__state = 5;
return true;
}
Object.Destroy((Object)(object)((Component)bh).gameObject);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static bool Prefix(BlackHole __instance, ref IEnumerator __result)
{
__result = CustomRoutine(__instance);
return false;
}
[IteratorStateMachine(typeof(<CustomRoutine>d__1))]
private static IEnumerator CustomRoutine(BlackHole bh)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CustomRoutine>d__1(0)
{
bh = bh
};
}
}
public class KnucklesFloatSpin : MonoBehaviour
{
private Vector3 currentRotationSpeed;
private Vector3 targetRotationSpeed;
private float timer;
private float changeInterval = 1f;
private void Start()
{
NewSpin();
}
private void Update()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
timer += Time.deltaTime;
if (timer >= changeInterval)
{
timer = 0f;
NewSpin();
}
currentRotationSpeed = Vector3.Lerp(currentRotationSpeed, targetRotationSpeed, Time.deltaTime * 0.5f);
((Component)this).transform.Rotate(currentRotationSpeed * Time.deltaTime, (Space)1);
}
private void NewSpin()
{
//IL_002f: 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)
targetRotationSpeed = new Vector3(Random.Range(-720f, 720f), Random.Range(-720f, 720f), Random.Range(-720f, 720f));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.IBMOTH.MageArena.UgandanKnuckles";
public const string PLUGIN_NAME = "Ugandan Knuckles Doom";
public const string PLUGIN_VERSION = "1.0.0";
}
}