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 BlackMagicAPI.Managers;
using BlackMagicAPI.Modules.Spells;
using BlackMagicAPI.Network;
using FishNet;
using FishNet.Broadcast;
using FishNet.Connection;
using FishNet.Object;
using FishNet.Transporting;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Kamehameha")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Kamehameha")]
[assembly: AssemblyTitle("Kamehameha")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Kamehameha;
public class KamehamehaData : SpellData
{
public override string Name => "Kamehameha";
public override float Cooldown => 120f;
public override Color GlowColor => new Color(0.2f, 0.65f, 1f);
public override string[] SubNames => new string[8] { "Kame Hame Ha", "Kame Hame", "Kamehame", "Camera Hama", "Camera Hammer", "Came A Hama", "Come A Hama", "Karma Karma" };
public override bool CanSpawnInTeamChest => false;
public override bool DebugForceSpawn => false;
}
internal struct KamFireDirBroadcast : IBroadcast
{
public float X;
public float Y;
public float Z;
}
public class KamehamehaLogic : SpellLogic
{
[HarmonyPatch(typeof(PlayerMovement), "UpdateGravity")]
private static class PatchUpdateGravity
{
private static bool Prefix(PlayerMovement __instance)
{
if (!((Object)(object)__instance != (Object)null) || !s_levitatingPlayers.Contains(__instance))
{
return true;
}
return false;
}
}
private const float CHARGE_DURATION = 10f;
private const float POST_BLAST_HOLD = 8f;
private const float RISE_TIME = 0.7f;
private const float RISE_SPEED = 12f;
private const float BEAM_RANGE = 80f;
private const float EYE_HEIGHT = 1.5f;
private const float FIREBALL_SPACING = 3.5f;
private const float FIREBALL_DELAY = 0.27f;
internal static readonly HashSet<PlayerMovement> s_levitatingPlayers = new HashSet<PlayerMovement>();
private static readonly FieldInfo s_velocityField = typeof(PlayerMovement).GetField("velocity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private PlayerMovement _activeCaster;
private static GameObject s_darkBlastPrefab = null;
private static Material s_particleMat = null;
private static Vector3 s_pendingFireDir = Vector3.zero;
private static bool s_broadcastSetup = false;
private void OnDestroy()
{
if ((Object)(object)_activeCaster != (Object)null)
{
s_levitatingPlayers.Remove(_activeCaster);
}
_activeCaster = null;
}
public override bool CastSpell(PlayerMovement caster, PageController page, Vector3 spawnPos, Vector3 viewDirectionVector, int castingLevel)
{
((MonoBehaviour)this).StartCoroutine(KamehamehaRoutine(caster));
return true;
}
public override void WriteData(DataWriter writer, PageController page, PlayerMovement caster, Vector3 spawnPos, Vector3 viewDirectionVector, int level)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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)
writer.Write<float>(spawnPos.x);
writer.Write<float>(spawnPos.y);
writer.Write<float>(spawnPos.z);
writer.Write<float>(viewDirectionVector.x);
writer.Write<float>(viewDirectionVector.y);
writer.Write<float>(viewDirectionVector.z);
}
public override void SyncData(object[] values)
{
//IL_004a: 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)
if (((SpellLogic)this).IsPrefab)
{
return;
}
try
{
Vector3 castOrigin = default(Vector3);
((Vector3)(ref castOrigin))..ctor(Convert.ToSingle(values[0]), Convert.ToSingle(values[1]), Convert.ToSingle(values[2]));
Vector3 castDir = default(Vector3);
((Vector3)(ref castDir))..ctor(Convert.ToSingle(values[3]), Convert.ToSingle(values[4]), Convert.ToSingle(values[5]));
((MonoBehaviour)this).StartCoroutine(PlayChargeSequence(castOrigin, castDir));
}
catch (Exception ex)
{
Debug.LogError((object)("[Kamehameha] SyncData error: " + ex.Message));
}
}
private IEnumerator KamehamehaRoutine(PlayerMovement caster)
{
if ((Object)(object)s_darkBlastPrefab == (Object)null)
{
PageController[] array = Resources.FindObjectsOfTypeAll<PageController>();
for (int i = 0; i < array.Length; i++)
{
GameObject spellprefab = array[i].spellprefab;
if ((Object)(object)spellprefab != (Object)null && (Object)(object)spellprefab.GetComponent<DarkBlastController>() != (Object)null)
{
s_darkBlastPrefab = spellprefab;
break;
}
}
}
Debug.Log((object)("[Kamehameha] Charge start | darkBlastPrefab=" + (((Object)(object)s_darkBlastPrefab != (Object)null) ? ((Object)s_darkBlastPrefab).name : "none")));
s_levitatingPlayers.Add(caster);
_activeCaster = caster;
float riseElapsed = 0f;
while (riseElapsed < 0.7f)
{
if ((Object)(object)caster == (Object)null)
{
s_levitatingPlayers.Remove(caster);
_activeCaster = null;
yield break;
}
if (s_velocityField != null)
{
Vector3 val = (Vector3)s_velocityField.GetValue(caster);
val.y = 12f;
s_velocityField.SetValue(caster, val);
}
riseElapsed += Time.deltaTime;
yield return null;
}
float holdElapsed = 0f;
while (holdElapsed < 9.3f)
{
if ((Object)(object)caster == (Object)null)
{
s_levitatingPlayers.Remove(caster);
_activeCaster = null;
yield break;
}
if (s_velocityField != null)
{
Vector3 val2 = (Vector3)s_velocityField.GetValue(caster);
val2.y = 0f;
s_velocityField.SetValue(caster, val2);
}
holdElapsed += Time.deltaTime;
yield return null;
}
float blastHoldElapsed = 0f;
while (blastHoldElapsed < 8f)
{
if ((Object)(object)caster == (Object)null)
{
s_levitatingPlayers.Remove(caster);
_activeCaster = null;
yield break;
}
if (s_velocityField != null)
{
Vector3 val3 = (Vector3)s_velocityField.GetValue(caster);
val3.y = 0f;
s_velocityField.SetValue(caster, val3);
}
blastHoldElapsed += Time.deltaTime;
yield return null;
}
s_levitatingPlayers.Remove(caster);
_activeCaster = null;
if ((Object)(object)caster != (Object)null)
{
s_velocityField?.SetValue(caster, Vector3.zero);
}
}
private IEnumerator PlayChargeSequence(Vector3 castOrigin, Vector3 castDir)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if (((Vector3)(ref castDir)).sqrMagnitude < 0.001f)
{
castDir = Vector3.forward;
}
castDir = ((Vector3)(ref castDir)).normalized;
SetupBroadcast();
Transform casterTf = FindNearestPlayer(castOrigin);
bool isCaster = IsLocalCaster(casterTf);
if ((Object)(object)s_particleMat == (Object)null)
{
ParticleSystemRenderer[] array = Object.FindObjectsOfType<ParticleSystemRenderer>();
foreach (ParticleSystemRenderer val in array)
{
if ((Object)(object)((Renderer)val).sharedMaterial != (Object)null)
{
s_particleMat = ((Renderer)val).sharedMaterial;
break;
}
}
}
string text = Path.Combine(Path.GetDirectoryName(typeof(KamehamehaLogic).Assembly.Location), "Sounds", "Kamehameha.wav");
string text2 = "file:///" + text.Replace('\\', '/');
AudioClip clip = null;
UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(text2, (AudioType)20);
yield return req.SendWebRequest();
if ((int)req.result == 1)
{
clip = DownloadHandlerAudioClip.GetContent(req);
}
req.Dispose();
GameObject audioObj = new GameObject("KamehamehaAudio");
AudioSource val2 = audioObj.AddComponent<AudioSource>();
val2.spatialBlend = 0f;
val2.volume = 1f;
if ((Object)(object)clip != (Object)null)
{
val2.clip = clip;
val2.Play();
}
GameObject chargeObj = new GameObject("KamehamehaChargeGlow");
Light chargeLight = chargeObj.AddComponent<Light>();
chargeLight.type = (LightType)2;
chargeLight.color = new Color(0.2f, 0.65f, 1f);
chargeLight.range = 35f;
GameObject kiBallObj = new GameObject("KamKiBall");
ParticleSystem kiBallPs = kiBallObj.AddComponent<ParticleSystem>();
MainModule main = kiBallPs.main;
((MainModule)(ref main)).loop = true;
((MainModule)(ref main)).duration = 999f;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.3f, 0.55f);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.05f, 0.2f);
((MainModule)(ref main)).startSize = new MinMaxCurve(0.08f, 0.22f);
((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0f, 0.55f, 1f, 1f), new Color(0.6f, 0.92f, 1f, 0.8f));
((MainModule)(ref main)).maxParticles = 300;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
EmissionModule emission = kiBallPs.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(150f);
ShapeModule shape = kiBallPs.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
((ShapeModule)(ref shape)).radius = 0.05f;
((ShapeModule)(ref shape)).radiusThickness = 0f;
if ((Object)(object)s_particleMat != (Object)null)
{
((Renderer)((Component)kiBallPs).GetComponent<ParticleSystemRenderer>()).sharedMaterial = s_particleMat;
}
Light kiBallInner = kiBallObj.AddComponent<Light>();
kiBallInner.type = (LightType)2;
kiBallInner.color = new Color(0.5f, 0.85f, 1f);
kiBallInner.range = 1.5f;
kiBallInner.intensity = 0f;
GameObject val3 = new GameObject("KiBallOuter");
val3.transform.SetParent(kiBallObj.transform, false);
Light kiBallOuter = val3.AddComponent<Light>();
kiBallOuter.type = (LightType)2;
kiBallOuter.color = new Color(0.2f, 0.65f, 1f);
kiBallOuter.range = 5f;
kiBallOuter.intensity = 0f;
float elapsed = 0f;
while (elapsed < 10f)
{
if ((Object)(object)chargeObj == (Object)null)
{
if ((Object)(object)kiBallObj != (Object)null)
{
Object.Destroy((Object)(object)kiBallObj);
}
yield break;
}
Vector3 position = (((Object)(object)casterTf != (Object)null) ? casterTf.position : castOrigin) + Vector3.up;
Vector3 val4 = (((Object)(object)casterTf != (Object)null) ? casterTf.forward : Vector3.forward);
chargeObj.transform.position = position;
float num = elapsed / 10f;
chargeLight.intensity = Mathf.Lerp(0f, 120f, num) + Random.Range(-8f, 8f) * (num * num);
if ((Object)(object)kiBallObj != (Object)null)
{
Vector3 val5 = (((Object)(object)casterTf != (Object)null) ? casterTf.right : Vector3.right);
kiBallObj.transform.position = (((Object)(object)casterTf != (Object)null) ? casterTf.position : castOrigin) + Vector3.up * 0.3f + val4 * 0.5f + val5 * 0.8f;
float num2 = Mathf.Pow(num, 1.8f);
ShapeModule shape2 = kiBallPs.shape;
((ShapeModule)(ref shape2)).radius = Mathf.Lerp(0.05f, 0.5f, num2);
kiBallInner.intensity = Mathf.Lerp(0f, 600f, num2);
kiBallInner.range = Mathf.Lerp(1.5f, 3.5f, num2);
kiBallOuter.intensity = Mathf.Lerp(0f, 60f, num2);
kiBallOuter.range = Mathf.Lerp(5f, 18f, num2);
}
elapsed += Time.deltaTime;
yield return null;
}
if ((Object)(object)kiBallObj != (Object)null)
{
Object.Destroy((Object)(object)kiBallObj);
}
if ((Object)(object)chargeObj != (Object)null)
{
Object.Destroy((Object)(object)chargeObj);
}
s_pendingFireDir = Vector3.zero;
Vector3 fireDir;
Vector3 val6;
if (isCaster && (Object)(object)Camera.main != (Object)null)
{
fireDir = ((Component)Camera.main).transform.forward;
val6 = fireDir;
Debug.Log((object)("[Kamehameha] Caster broadcasting fire dir=" + ((object)(Vector3)(ref val6)).ToString()));
KamFireDirBroadcast kamFireDirBroadcast = default(KamFireDirBroadcast);
kamFireDirBroadcast.X = fireDir.x;
kamFireDirBroadcast.Y = fireDir.y;
kamFireDirBroadcast.Z = fireDir.z;
KamFireDirBroadcast kamFireDirBroadcast2 = kamFireDirBroadcast;
try
{
if (InstanceFinder.IsServerStarted)
{
InstanceFinder.ServerManager.Broadcast<KamFireDirBroadcast>(kamFireDirBroadcast2, true, (Channel)0);
}
else
{
InstanceFinder.ClientManager.Broadcast<KamFireDirBroadcast>(kamFireDirBroadcast2, (Channel)0);
}
}
catch (Exception ex)
{
Debug.LogWarning((object)("[Kamehameha] Fire dir broadcast: " + ex.Message));
}
}
else
{
Debug.Log((object)"[Kamehameha] Observer: waiting for fire dir broadcast...");
float waited = 0f;
while (((Vector3)(ref s_pendingFireDir)).sqrMagnitude < 0.001f && waited < 0.5f)
{
waited += Time.deltaTime;
yield return null;
}
if (((Vector3)(ref s_pendingFireDir)).sqrMagnitude > 0.001f)
{
val6 = s_pendingFireDir;
Debug.Log((object)("[Kamehameha] Observer: received broadcast dir=" + ((object)(Vector3)(ref val6)).ToString()));
fireDir = ((Vector3)(ref s_pendingFireDir)).normalized;
s_pendingFireDir = Vector3.zero;
}
else
{
Vector3 val7 = (((Object)(object)casterTf != (Object)null) ? casterTf.position : castOrigin) + Vector3.up * 1.5f;
Vector3 val8;
if (!((Object)(object)casterTf != (Object)null))
{
val8 = castDir;
}
else
{
val6 = new Vector3(casterTf.forward.x, 0f, casterTf.forward.z);
val8 = ((Vector3)(ref val6)).normalized;
}
Vector3 val9 = val8;
Vector3 val10 = val9;
float num3 = -1f;
PlayerMovement[] array2 = Object.FindObjectsOfType<PlayerMovement>();
Vector3 val13 = default(Vector3);
foreach (PlayerMovement val11 in array2)
{
if ((Object)(object)val11 == (Object)null || (Object)(object)casterTf == (Object)null || (Object)(object)((Component)val11).transform == (Object)(object)casterTf)
{
continue;
}
Vector3 val12 = ((Component)val11).transform.position + Vector3.up * 1f - val7;
float magnitude = ((Vector3)(ref val12)).magnitude;
if (magnitude < 0.5f || magnitude > 80f)
{
continue;
}
((Vector3)(ref val13))..ctor(val12.x, 0f, val12.z);
if (((Vector3)(ref val13)).sqrMagnitude < 0.001f)
{
continue;
}
float num4 = Vector3.Dot(val9, ((Vector3)(ref val13)).normalized);
if (!(num4 < 0.3f))
{
float num5 = num4 / (magnitude + 1f);
if (num5 > num3)
{
num3 = num5;
val10 = ((Vector3)(ref val12)).normalized;
}
}
}
val6 = val10;
Debug.Log((object)("[Kamehameha] Observer: timeout, fallback dir=" + ((object)(Vector3)(ref val6)).ToString()));
fireDir = val10;
}
}
Vector3 eyePos = (((Object)(object)casterTf != (Object)null) ? casterTf.position : castOrigin) + Vector3.up * 1.5f;
float beamRange = GetBeamRange(eyePos, fireDir);
Vector3 val14 = eyePos + fireDir * beamRange;
float dist = Vector3.Distance(eyePos, val14);
int count = Mathf.Max(1, Mathf.FloorToInt(dist / 3.5f));
if ((Object)(object)s_darkBlastPrefab == (Object)null)
{
PageController[] array3 = Resources.FindObjectsOfTypeAll<PageController>();
for (int j = 0; j < array3.Length; j++)
{
GameObject spellprefab = array3[j].spellprefab;
if ((Object)(object)spellprefab != (Object)null && (Object)(object)spellprefab.GetComponent<DarkBlastController>() != (Object)null)
{
s_darkBlastPrefab = spellprefab;
break;
}
}
}
SpawnBlueImpact(eyePos + fireDir * 1f);
for (int i = 0; i < count; i++)
{
float num6 = ((float)i + 1f) / (float)count;
Vector3 val15 = eyePos + fireDir * (dist * num6);
if ((Object)(object)s_darkBlastPrefab != (Object)null)
{
float[] array4 = new float[3] { 0f, 0.55f, -0.55f };
foreach (float num7 in array4)
{
try
{
GameObject val16 = Object.Instantiate<GameObject>(s_darkBlastPrefab, val15 + Vector3.up * num7, Quaternion.identity);
DarkBlastController component = val16.GetComponent<DarkBlastController>();
if ((Object)(object)component != (Object)null)
{
if ((Object)(object)component.asour != (Object)null)
{
component.asour.Stop();
component.asour.volume = 0f;
((Behaviour)component.asour).enabled = false;
}
Light[] componentsInChildren = val16.GetComponentsInChildren<Light>();
for (int k = 0; k < componentsInChildren.Length; k++)
{
componentsInChildren[k].color = new Color(0.2f, 0.65f, 1f);
}
component.CastDarkBlast(fireDir, ((Object)(object)casterTf != (Object)null) ? ((Component)casterTf).gameObject : null);
}
}
catch (Exception ex2)
{
Debug.LogWarning((object)("[Kamehameha] DarkBlast " + i + " error: " + ex2.Message));
}
}
}
else
{
SpawnBlueImpact(val15);
((MonoBehaviour)this).StartCoroutine(SpawnBlueFire(val15));
}
yield return (object)new WaitForSeconds(0.27f);
}
if ((Object)(object)clip != (Object)null)
{
float num8 = clip.length - 10f - (float)count * 0.27f;
if (num8 > 0f)
{
yield return (object)new WaitForSeconds(num8);
}
}
Object.Destroy((Object)(object)audioObj);
}
internal static void SetupBroadcast()
{
if (s_broadcastSetup)
{
return;
}
try
{
if (InstanceFinder.IsServerStarted && (Object)(object)InstanceFinder.ServerManager != (Object)null)
{
InstanceFinder.ServerManager.RegisterBroadcast<KamFireDirBroadcast>((Action<NetworkConnection, KamFireDirBroadcast, Channel>)OnFireDirServer, false);
}
if ((Object)(object)InstanceFinder.ClientManager != (Object)null)
{
InstanceFinder.ClientManager.RegisterBroadcast<KamFireDirBroadcast>((Action<KamFireDirBroadcast, Channel>)OnFireDirClient);
}
s_broadcastSetup = true;
}
catch (Exception ex)
{
Debug.LogWarning((object)("[Kamehameha] Broadcast setup: " + ex.Message));
}
}
private static void OnFireDirServer(NetworkConnection conn, KamFireDirBroadcast msg, Channel ch)
{
try
{
InstanceFinder.ServerManager.Broadcast<KamFireDirBroadcast>(msg, true, (Channel)0);
}
catch
{
}
}
private static void OnFireDirClient(KamFireDirBroadcast msg, Channel ch)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
s_pendingFireDir = new Vector3(msg.X, msg.Y, msg.Z);
}
private static void SpawnBlueImpact(Vector3 pos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: 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)
//IL_0161: 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_0194: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("KamBlueImpact");
val.transform.position = pos;
ParticleSystem val2 = val.AddComponent<ParticleSystem>();
MainModule main = val2.main;
((MainModule)(ref main)).duration = 0.2f;
((MainModule)(ref main)).loop = false;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.25f, 0.65f);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(4f, 10f);
((MainModule)(ref main)).startSize = new MinMaxCurve(0.15f, 0.55f);
((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0f, 0.55f, 1f, 1f), new Color(0.6f, 0.92f, 1f, 0.8f));
((MainModule)(ref main)).gravityModifier = new MinMaxCurve(0.25f);
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).maxParticles = 40;
EmissionModule emission = val2.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
{
new Burst(0f, (short)25, (short)35, 1, 0.01f)
});
ShapeModule shape = val2.shape;
((ShapeModule)(ref shape)).enabled = true;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
((ShapeModule)(ref shape)).radius = 0.3f;
if ((Object)(object)s_particleMat != (Object)null)
{
((Renderer)((Component)val2).GetComponent<ParticleSystemRenderer>()).sharedMaterial = s_particleMat;
}
GameObject val3 = new GameObject("ImpactLight");
val3.transform.SetParent(val.transform, false);
Light obj = val3.AddComponent<Light>();
obj.type = (LightType)2;
obj.color = new Color(0.3f, 0.7f, 1f);
obj.intensity = 18f;
obj.range = 14f;
Object.Destroy((Object)(object)val, 2f);
}
private IEnumerator SpawnBlueFire(Vector3 endpoint)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
yield return null;
Vector3 val = default(Vector3);
RaycastHit val3 = default(RaycastHit);
for (int i = 0; i < 2; i++)
{
((Vector3)(ref val))..ctor(Random.Range(-1.5f, 1.5f), 0f, Random.Range(-1.5f, 1.5f));
Vector3 val2 = endpoint + val + Vector3.up * 2f;
Vector3 pos = endpoint + val;
if (Physics.Raycast(val2, Vector3.down, ref val3, 30f))
{
pos = ((RaycastHit)(ref val3)).point;
}
CreateBlueFirePool(pos);
}
}
private static void CreateBlueFirePool(Vector3 pos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("KamBlueFire");
val.transform.position = pos;
ParticleSystem val2 = val.AddComponent<ParticleSystem>();
MainModule main = val2.main;
((MainModule)(ref main)).duration = 5f;
((MainModule)(ref main)).loop = false;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.2f, 2.5f);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.4f, 2f);
((MainModule)(ref main)).startSize = new MinMaxCurve(0.25f, 0.75f);
((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0f, 0.55f, 1f, 1f), new Color(0.3f, 0.9f, 1f, 0.6f));
((MainModule)(ref main)).gravityModifier = new MinMaxCurve(-0.1f);
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).maxParticles = 60;
EmissionModule emission = val2.emission;
((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(15f);
ShapeModule shape = val2.shape;
((ShapeModule)(ref shape)).enabled = true;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
((ShapeModule)(ref shape)).angle = 15f;
((ShapeModule)(ref shape)).radius = 0.2f;
if ((Object)(object)s_particleMat != (Object)null)
{
((Renderer)((Component)val2).GetComponent<ParticleSystemRenderer>()).sharedMaterial = s_particleMat;
}
GameObject val3 = new GameObject("FlameLight");
val3.transform.SetParent(val.transform, false);
Light obj = val3.AddComponent<Light>();
obj.type = (LightType)2;
obj.color = new Color(0.2f, 0.65f, 1f);
obj.intensity = 5f;
obj.range = 8f;
Object.Destroy((Object)(object)val, 7f);
}
private static float GetBeamRange(Vector3 origin, Vector3 dir)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(origin + dir * 0.5f, dir, ref val, 80f, -5, (QueryTriggerInteraction)1))
{
return Mathf.Min(((RaycastHit)(ref val)).distance + 0.5f, 80f);
}
return 80f;
}
private static Transform FindNearestPlayer(Vector3 pos)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
Transform result = null;
float num = float.MaxValue;
PlayerMovement[] array = Object.FindObjectsOfType<PlayerMovement>();
foreach (PlayerMovement val in array)
{
if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).transform == (Object)null))
{
float num2 = Vector3.Distance(((Component)val).transform.position, pos);
if (num2 < num)
{
num = num2;
result = ((Component)val).transform;
}
}
}
return result;
}
private static bool IsLocalCaster(Transform casterTf)
{
if ((Object)(object)casterTf == (Object)null)
{
return false;
}
NetworkObject component = ((Component)casterTf).GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null)
{
Debug.Log((object)("[Kamehameha] IsLocalCaster (IsOwner)=" + component.IsOwner + " for " + ((Object)casterTf).name));
return component.IsOwner;
}
try
{
NetworkConnection val = InstanceFinder.ClientManager?.Connection;
if (val == (NetworkConnection)null)
{
return false;
}
foreach (NetworkObject @object in val.Objects)
{
PlayerMovement component2 = ((Component)@object).GetComponent<PlayerMovement>();
if ((Object)(object)component2 != (Object)null && (Object)(object)((Component)component2).transform == (Object)(object)casterTf)
{
return true;
}
}
}
catch
{
}
return false;
}
}
[BepInPlugin("com.thewargod_ares.kamehameha", "Kamehameha", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "com.thewargod_ares.kamehameha";
public const string NAME = "Kamehameha";
public const string VERSION = "1.0.0";
public static string modsync = "all";
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("com.thewargod_ares.kamehameha").PatchAll(typeof(Plugin).Assembly);
BlackMagicManager.RegisterSpell((BaseUnityPlugin)(object)this, typeof(KamehamehaData), typeof(KamehamehaLogic));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Kamehameha loaded — say 'Kamehameha' to ascend.");
}
}