using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using RailgunEffect;
using RumbleModdingAPI;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Class1), "The Railgun Effect", "1.0.1", "SpooderCode", null)]
[assembly: MelonGame("", "")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RailgunEffect")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RailgunEffect")]
[assembly: AssemblyTitle("RailgunEffect")]
[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 RailgunEffect
{
public class Class1 : MelonMod
{
private MelonPreferences_Category? ourFirstCategory;
private MelonPreferences_Entry<bool>? sound;
private MelonPreferences_Entry<bool>? vfx;
public float RailgunThreshold = 21f;
public GameObject? explosion;
public Rigidbody[] walls;
public List<float> wallSpeeds = new List<float>(0);
public List<Rigidbody> hitstopped = new List<Rigidbody>(0);
public override void OnInitializeMelon()
{
ourFirstCategory = MelonPreferences.CreateCategory("Config");
sound = ourFirstCategory.CreateEntry<bool>("Play Ding Sound", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
vfx = ourFirstCategory.CreateEntry<bool>("Show VFX", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
ourFirstCategory.SetFilePath("UserData/Railgun.cfg");
ourFirstCategory.SaveToFile(true);
}
public GameObject LoadAsset()
{
using Stream stream = ((MelonBase)this).MelonAssembly.Assembly.GetManifestResourceStream("RailgunEffect.Resources.railgun");
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Il2CppAssetBundle val = Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(array));
GameObject result = val.LoadAsset<GameObject>("Explosion");
val.Unload(false);
return result;
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
if (wallSpeeds.Count > 0)
{
wallSpeeds.Clear();
hitstopped.Clear();
}
}
public override void OnFixedUpdate()
{
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
if (!(Scene.GetSceneName() == "Gym") && !(Scene.GetSceneName() == "Park") && !(Scene.GetSceneName() == "Map0") && !(Scene.GetSceneName() == "Map1"))
{
return;
}
if ((Object)(object)explosion == (Object)null)
{
explosion = LoadAsset();
explosion.GetComponent<AudioSource>().playOnAwake = sound.Value;
Object.DontDestroyOnLoad((Object)(object)explosion);
}
Rigidbody[] first = Il2CppArrayBase<Rigidbody>.op_Implicit(Structures.GetPoolWall().GetComponentsInChildren<Rigidbody>());
Rigidbody[] second = Il2CppArrayBase<Rigidbody>.op_Implicit(Structures.GetPoolCube().GetComponentsInChildren<Rigidbody>());
Rigidbody[] second2 = Il2CppArrayBase<Rigidbody>.op_Implicit(Structures.GetPoolLargeRock().GetComponentsInChildren<Rigidbody>());
Rigidbody[] second3 = Il2CppArrayBase<Rigidbody>.op_Implicit(Structures.GetPoolPillar().GetComponentsInChildren<Rigidbody>());
walls = first.Concat(second).ToArray();
walls = walls.Concat(second2).ToArray();
walls = walls.Concat(second3).ToArray();
if (walls.Length > wallSpeeds.Count())
{
for (int i = 0; i < walls.Length - wallSpeeds.Count(); i++)
{
wallSpeeds.Add(0f);
}
}
Rigidbody[] array = walls;
foreach (Rigidbody val in array)
{
Vector3 velocity = val.velocity;
float num = ((Vector3)(ref velocity)).magnitude - wallSpeeds[Array.IndexOf(walls, val)] * 2f;
bool flag = false;
if ((double)num < 0.1 && (double)num > -0.1)
{
flag = true;
}
if (flag && hitstopped.Contains(val))
{
velocity = val.velocity;
if (((Vector3)(ref velocity)).magnitude > 18f && vfx.Value)
{
GameObject val2 = Object.Instantiate<GameObject>(explosion);
val2.transform.SetParent(((Component)val).transform.parent);
val2.transform.position = val.position;
Object.Destroy((Object)(object)val2, 2f);
}
}
velocity = val.velocity;
if (((Vector3)(ref velocity)).magnitude != 0f)
{
List<float> list = wallSpeeds;
int index = Array.IndexOf(walls, val);
velocity = val.velocity;
list[index] = ((Vector3)(ref velocity)).magnitude;
if (hitstopped.Contains(val))
{
hitstopped.Remove(val);
}
}
else if (!hitstopped.Contains(val))
{
hitstopped.Add(val);
}
}
}
}
}