using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BlackMagicAPI.Enums;
using BlackMagicAPI.Helpers;
using BlackMagicAPI.Managers;
using BlackMagicAPI.Modules.Spells;
using Steamworks;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("VampiricTouch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VampiricTouch")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("11eec473-b926-410f-84d3-7a119daeb155")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VampiricTouch;
[BepInPlugin("com.owls8.vampirictouch", "vampirictouch", "1.0.0")]
public class VampiricTouch : BaseUnityPlugin
{
private static AssetBundle vampiricTouchBundle;
public static AudioClip vampireSound;
public static GameObject vampireVFX;
private void Awake()
{
LoadVampiricTouchAssets();
BlackMagicManager.RegisterSpell((BaseUnityPlugin)(object)this, typeof(VampiricTouchData), typeof(VampiricTouchLogic));
}
private void LoadVampiricTouchAssets()
{
try
{
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
string text = Path.Combine(directoryName, "vampire");
if (File.Exists(text))
{
vampiricTouchBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)vampiricTouchBundle != (Object)null)
{
vampireSound = vampiricTouchBundle.LoadAsset<AudioClip>("vampireSFX");
if ((Object)(object)vampireSound == (Object)null)
{
Debug.LogWarning((object)"[VampiricTouch] Could not find 'vampireSFX' audio clip in AssetBundle");
}
vampireVFX = vampiricTouchBundle.LoadAsset<GameObject>("VampireVFX");
if ((Object)(object)vampireVFX == (Object)null)
{
Debug.LogWarning((object)"[VampiricTouch] Could not find 'Vampire' prefab in AssetBundle");
}
}
else
{
Debug.LogError((object)"[VampiricTouch] Failed to load AssetBundle");
}
}
else
{
Debug.LogError((object)("[VampiricTouch] AssetBundle file does not exist at path: " + text));
}
}
catch (Exception ex)
{
Debug.LogError((object)("[VampiricTouch] Error loading AssetBundle: " + ex.Message));
}
}
}
internal class VampiricTouchData : SpellData
{
public override SpellType SpellType => (SpellType)0;
public override string Name => "Vampiric Touch";
public override float Cooldown => 12f;
public override Color GlowColor => Color.green;
public override Texture2D GetMainTexture()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, "VampiricTouch_Main.png");
if (File.Exists(text))
{
return Utils.LoadTextureFromDisk(text);
}
return Utils.LoadTextureFromResources(Assembly.GetExecutingAssembly(), "BlackMagicAPI.Resources.Items.Item_Main.png");
}
public override Texture2D GetEmissionTexture()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, "VampiricTouch_Emission.png");
if (File.Exists(text))
{
return Utils.LoadTextureFromDisk(text);
}
return Utils.LoadTextureFromResources(Assembly.GetExecutingAssembly(), "BlackMagicAPI.Resources.Items.Item_Emission.png");
}
}
internal class VampiricTouchLogic : SpellLogic
{
public override void CastSpell(GameObject playerObj, PageController page, Vector3 spawnPos, Vector3 viewDirectionVector, int castingLevel)
{
//IL_002c: 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)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
PlayerMovement component = playerObj.GetComponent<PlayerMovement>();
if ((Object)(object)component == (Object)null)
{
return;
}
GameObject[] array = GameObject.FindGameObjectsWithTag("Player");
Vector3 position = playerObj.transform.position;
Vector3 forward = playerObj.transform.forward;
string personaName = SteamFriends.GetPersonaName();
PlayerMovement val = null;
PlayerMovement[] array2 = Object.FindObjectsByType<PlayerMovement>((FindObjectsSortMode)0);
PlayerMovement[] array3 = array2;
foreach (PlayerMovement val2 in array3)
{
if (val2.playername == personaName)
{
val = val2;
break;
}
}
GameObject val3 = null;
float num = float.MaxValue;
PlayerMovement val4 = null;
GameObject[] array4 = array;
foreach (GameObject val5 in array4)
{
if ((Object)(object)val5 == (Object)(object)playerObj)
{
continue;
}
Vector3 val6 = val5.transform.position - position;
Vector3 normalized = ((Vector3)(ref val6)).normalized;
float num2 = Vector3.Distance(position, val5.transform.position);
if (!(num2 <= 3f))
{
continue;
}
float num3 = Vector3.Angle(forward, normalized);
if (!(num3 <= 45f))
{
continue;
}
PlayerMovement component2 = val5.GetComponent<PlayerMovement>();
if ((Object)(object)component2 != (Object)null && component.playerTeam == component2.playerTeam)
{
continue;
}
Vector3 val7 = position + Vector3.up * 1.5f;
Vector3 val8 = val5.transform.position + Vector3.up * 1.5f;
val6 = val8 - val7;
Vector3 normalized2 = ((Vector3)(ref val6)).normalized;
if ((Object)(object)component2 != (Object)null)
{
if (!((Object)(object)val != (Object)null) || (Object)(object)component2 == (Object)(object)val)
{
}
float num4 = Vector3.Angle(forward, normalized);
float num5 = num4 * 2f + num2;
if (num5 < num)
{
val3 = val5;
num = num5;
val4 = component2;
}
}
}
if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null)
{
val4.NonRpcDamagePlayer(15f + (float)(castingLevel * 5), (GameObject)null, "vampirictouch");
playerObj.GetComponent<PlayerMovement>().nonnetworkedheal(25f + (float)(castingLevel * 5));
PlayVampiricTouchVFX(val4);
PlayVampiricTouchSFX(val3.transform.position);
}
}
private static void PlayVampiricTouchVFX(PlayerMovement victim)
{
//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_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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)
if ((Object)(object)VampiricTouch.vampireVFX == (Object)null)
{
Debug.LogWarning((object)"Vampire VFX prefab is null.");
return;
}
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(0f, 0f, 1.5f);
Vector3 val2 = ((Component)victim).transform.position + val;
GameObject val3 = Object.Instantiate<GameObject>(VampiricTouch.vampireVFX, val2, Quaternion.identity);
val3.SetActive(true);
Object.Destroy((Object)(object)val3, 2f);
}
private static void PlayVampiricTouchSFX(Vector3 position)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)VampiricTouch.vampireSound != (Object)null)
{
GameObject val = new GameObject("VampiricTouchAudio");
val.transform.position = position;
AudioSource val2 = val.AddComponent<AudioSource>();
val2.clip = VampiricTouch.vampireSound;
val2.volume = 0.8f;
val2.spatialBlend = 1f;
val2.rolloffMode = (AudioRolloffMode)1;
val2.minDistance = 5f;
val2.maxDistance = 50f;
val2.Play();
float num = VampiricTouch.vampireSound.length + 0.1f;
Object.Destroy((Object)(object)val, num);
}
}
catch (Exception ex)
{
Debug.LogError((object)("[VampiricTouch] Error playing sound: " + ex.Message));
}
}
}