using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Adaptation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Adaptation")]
[assembly: AssemblyTitle("Adaptation")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Adaptation;
[BepInPlugin("com.example.adaptation", "Adaptation", "1.0.1")]
public class AdaptationPlugin : BaseUnityPlugin
{
private class WheelRotator : MonoBehaviour
{
private Quaternion currentRot = Quaternion.identity;
private void Update()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
Quaternion val = Quaternion.Euler(0f, 0f, targetRotation);
float num = ((RotationSmoothing.Value > 0f) ? RotationSmoothing.Value : 5f);
currentRot = Quaternion.Lerp(currentRot, val, Time.deltaTime * num);
((Component)this).transform.localRotation = currentRot;
}
}
public const string pluginGuid = "com.example.adaptation";
public const string pluginName = "Adaptation";
public const string pluginVersion = "1.0.1";
public static ConfigEntry<float> ResistancePerHit;
public static ConfigEntry<float> DamageBoostPerHit;
public static ConfigEntry<float> RotationSmoothing;
public static int hitCount;
public static float targetRotation;
public const float ROTATION_PER_HIT = 45f;
private static Sprite wheelSprite;
private void Awake()
{
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Expected O, but got Unknown
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Expected O, but got Unknown
ResistancePerHit = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ResistancePerHit", 0.95f, "Multiplier for incoming damage per hit");
DamageBoostPerHit = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DamageBoostPerHit", 1.05f, "Multiplier for outgoing weapon damage per hit");
RotationSmoothing = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RotationSmoothing", 5f, "Wheel animation smoothness");
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string r) => r.IndexOf("wheel", StringComparison.OrdinalIgnoreCase) >= 0);
if (!string.IsNullOrEmpty(text))
{
Texture2D val = LoadTextureFromResource(executingAssembly, text);
wheelSprite = (((Object)(object)val != (Object)null) ? Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)) : CreateWhiteSprite());
}
else
{
wheelSprite = CreateWhiteSprite();
}
SceneManager.sceneLoaded += OnSceneLoaded;
Harmony val2 = new Harmony("com.example.adaptation");
Type type = AccessTools.TypeByName("NewMovement");
if (type != null)
{
MethodInfo methodInfo = AccessTools.Method(type, "GetHurt", (Type[])null, (Type[])null);
if (methodInfo != null)
{
val2.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(AdaptationPlugin), "OnGetHurt", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
MethodInfo methodInfo2 = AccessTools.Method(type, "Start", (Type[])null, (Type[])null);
if (methodInfo2 != null)
{
val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(AdaptationPlugin), "ResetHits", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
Type type2 = AccessTools.TypeByName("EnemyIdentifier");
if (type2 != null)
{
MethodInfo methodInfo3 = AccessTools.Method(type2, "DeliverDamage", new Type[9]
{
typeof(GameObject),
typeof(Vector3),
typeof(Vector3),
typeof(float),
typeof(bool),
typeof(float),
typeof(GameObject),
typeof(bool),
typeof(bool)
}, (Type[])null);
if (methodInfo3 != null)
{
val2.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(AdaptationPlugin), "OnDeliverDamage", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Adaptation loaded (weapons + resistance + wheel, 45° per turn)");
}
public static void OnGetHurt(ref int damage)
{
float num = Mathf.Pow(ResistancePerHit.Value, (float)hitCount);
damage = Mathf.RoundToInt((float)damage * num);
hitCount++;
targetRotation += 45f;
}
public static void OnDeliverDamage(GameObject target, Vector3 force, Vector3 hitPoint, ref float multiplier, bool tryForExplode, ref float critMultiplier, GameObject sourceWeapon, bool ignoreTotalDamageTakenMultiplier, bool fromExplosion)
{
if ((Object)(object)sourceWeapon != (Object)null && (sourceWeapon.CompareTag("Player") || ((Object)(object)sourceWeapon.transform.root != (Object)null && ((Component)sourceWeapon.transform.root).CompareTag("Player"))))
{
float num = Mathf.Pow(DamageBoostPerHit.Value, (float)hitCount);
multiplier *= num;
critMultiplier *= num;
}
}
public static void ResetHits()
{
hitCount = 0;
targetRotation = 0f;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//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_006b: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
SceneManager.sceneLoaded -= OnSceneLoaded;
GameObject val = new GameObject("MahoragaWheelCanvas");
((Object)val).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)val);
Canvas obj = val.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 32767;
val.AddComponent<CanvasScaler>();
val.AddComponent<GraphicRaycaster>();
GameObject val2 = new GameObject("WheelImage");
val2.transform.SetParent(val.transform, false);
Image obj2 = val2.AddComponent<Image>();
obj2.sprite = wheelSprite;
((Graphic)obj2).color = Color.white;
((Graphic)obj2).SetNativeSize();
RectTransform component = val2.GetComponent<RectTransform>();
component.anchorMin = new Vector2(1f, 1f);
component.anchorMax = new Vector2(1f, 1f);
component.pivot = new Vector2(0.5f, 0.5f);
component.anchoredPosition = new Vector2(-230f, -230f);
component.sizeDelta = new Vector2(420f, 420f);
val2.AddComponent<WheelRotator>();
}
private static Sprite CreateWhiteSprite()
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(64, 64);
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 64; j++)
{
val.SetPixel(j, i, Color.white);
}
}
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f));
}
private static Texture2D LoadTextureFromResource(Assembly asm, string name)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
using Stream stream = asm.GetManifestResourceStream(name);
if (stream == null)
{
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Texture2D val = new Texture2D(2, 2);
if (!ImageConversion.LoadImage(val, array))
{
return null;
}
return val;
}
}