using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FishNet.Object;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("DinamiteExplosionLaunch")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Airborn trickshots? Gotcha, now you can explode your feet to hit that clip")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("DinamiteExplosionLaunch")]
[assembly: AssemblyTitle("DinamiteExplosionLaunch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ExplosionLaunchMod
{
internal static class LaunchValues
{
public const float HorizontalMultiplier = 18f;
public const float MinHorizontalForce = 10f;
public const float VerticalMultiplier = 10f;
public const float MinUpwardForce = 12f;
public const float LaunchDecayPerTick = 0.985f;
public const float MaxHorizontalSpeed = 45f;
public const float MaxVerticalSpeed = 46f;
}
internal static class ExplosionSettings
{
public const int MinDamageReduction = 10;
public const int MaxDamageReduction = 99;
public const int DefaultDamageReduction = 75;
private static ConfigEntry<int> _damageReduction;
private static ConfigEntry<bool> _invulnerable;
public static int DamageReduction => Mathf.Clamp(_damageReduction.Value, 10, 99);
public static bool Invulnerable => _invulnerable.Value;
public static void Bind(ConfigFile config)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
_damageReduction = config.Bind<int>("Explosion Damage", "Damage Reduction Percent", 75, new ConfigDescription("Percentage of player damage prevented by explosions.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 99), Array.Empty<object>()));
_invulnerable = config.Bind<bool>("Explosion Damage", "Invulnerable", false, "Ignore all damage caused by explosions.");
config.Save();
}
public static int ApplyToDamage(int damage)
{
if (Invulnerable)
{
return 0;
}
return Mathf.Max(0, Mathf.RoundToInt((float)damage * (1f - (float)DamageReduction / 100f)));
}
}
internal static class LaunchState
{
private class Holder
{
public Vector3 Velocity;
}
private static readonly ConditionalWeakTable<PlayerMovement, Holder> _table = new ConditionalWeakTable<PlayerMovement, Holder>();
private static Holder Get(PlayerMovement pm)
{
return _table.GetOrCreateValue(pm);
}
public static void Add(PlayerMovement pm, Vector3 horizontalVelocity)
{
//IL_000a: 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_0010: 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_0055: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
Holder holder = Get(pm);
holder.Velocity += horizontalVelocity;
float num = 45f;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(holder.Velocity.x, 0f, holder.Velocity.z);
if (((Vector3)(ref val)).sqrMagnitude > num * num)
{
val = ((Vector3)(ref val)).normalized * num;
holder.Velocity = new Vector3(val.x, 0f, val.z);
}
}
public static Vector3 Peek(PlayerMovement pm)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Get(pm).Velocity;
}
public static void Decay(PlayerMovement pm, float factor)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
Holder holder = Get(pm);
holder.Velocity *= factor;
if (((Vector3)(ref holder.Velocity)).sqrMagnitude < 0.0025f)
{
holder.Velocity = Vector3.zero;
}
}
public static void Clear(PlayerMovement pm)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Get(pm).Velocity = Vector3.zero;
}
}
[HarmonyPatch(typeof(Server), "RpcLogic___HitPlayer___2449261505")]
internal static class ExplosionHitPatch
{
private static void Postfix(Server __instance, Player __0, int __1, Vector3 __2, Vector3 __3, byte __4, Player __5)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: 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_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
byte b = __4;
if (b == 0 && Object.op_Implicit((Object)(object)__0) && !((NetworkBehaviour)__0).IsDeinitializing && __0.Vitals.Health > 0 && !(__2 == Vector3.zero) && !((Object)(object)__0.Movement == (Object)null))
{
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(__2.x, 0f, __2.z);
float magnitude = ((Vector3)(ref val)).magnitude;
if (magnitude > 0.001f)
{
val /= magnitude;
magnitude = Mathf.Clamp(Mathf.Max(magnitude * 18f, 10f), 0f, 45f);
val *= magnitude;
}
else
{
val = Vector3.zero;
}
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(val.x, __2.y * 10f, val.z);
if (val2.y < 12f)
{
val2.y = 12f;
}
val2.y = Mathf.Clamp(val2.y, -46f, 46f);
__0.Movement.RPCKnockback(((NetworkBehaviour)__0).Owner, val2);
}
}
}
[HarmonyPatch(typeof(Server), "RpcLogic___HitPlayer___2449261505")]
internal static class ExplosionDamagePatch
{
private static void Prefix(ref int __1, byte __4)
{
if (__4 == 0)
{
__1 = ExplosionSettings.ApplyToDamage(__1);
}
}
}
[HarmonyPatch(typeof(PlayerMovement), "Knockback")]
internal static class KnockbackSplitPatch
{
private static readonly FieldInfo RigField = AccessTools.Field(typeof(PlayerMovement), "_rig");
internal static bool ExplosionKnockbackActive;
private static bool Prefix(PlayerMovement __instance, Vector3 force)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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)
if (!ExplosionKnockbackActive)
{
return true;
}
Rigidbody val = (Rigidbody)RigField.GetValue(__instance);
if ((Object)(object)val == (Object)null)
{
return true;
}
Vector3 linearVelocity = val.linearVelocity;
linearVelocity.y += force.y;
val.linearVelocity = linearVelocity;
LaunchState.Add(__instance, new Vector3(force.x, 0f, force.z));
return false;
}
}
[HarmonyPatch(typeof(PlayerMovement), "RpcLogic___RPCKnockback___4285073289")]
internal static class ExplosionKnockbackRpcPatch
{
private static void Prefix()
{
KnockbackSplitPatch.ExplosionKnockbackActive = true;
}
private static void Postfix()
{
KnockbackSplitPatch.ExplosionKnockbackActive = false;
}
}
[HarmonyPatch(typeof(PlayerMovement), "Move")]
internal static class ApplyLaunchPatch
{
private static readonly FieldInfo RigField = AccessTools.Field(typeof(PlayerMovement), "_rig");
private static void Postfix(PlayerMovement __instance)
{
//IL_0002: 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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = LaunchState.Peek(__instance);
if (val == Vector3.zero)
{
return;
}
Rigidbody val2 = (Rigidbody)RigField.GetValue(__instance);
if (!((Object)(object)val2 == (Object)null))
{
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(val2.linearVelocity.x, 0f, val2.linearVelocity.z);
Vector3 val4 = val3 + val;
if (((Vector3)(ref val4)).sqrMagnitude > 2025f)
{
val4 = ((Vector3)(ref val4)).normalized * 45f;
}
Vector3 linearVelocity = val2.linearVelocity;
linearVelocity.x = val4.x;
linearVelocity.z = val4.z;
val2.linearVelocity = linearVelocity;
LaunchState.Decay(__instance, 0.985f);
}
}
}
public static class ExplosionLaunchModule
{
public static void Init(Harmony harmony)
{
harmony.PatchAll(typeof(ExplosionHitPatch));
harmony.PatchAll(typeof(ExplosionDamagePatch));
harmony.PatchAll(typeof(KnockbackSplitPatch));
harmony.PatchAll(typeof(ExplosionKnockbackRpcPatch));
harmony.PatchAll(typeof(ApplyLaunchPatch));
}
}
[BepInPlugin("com.KingIDFK.explosionlaunch", "Explosion Launch Mod", "1.2.0")]
public class Project : BaseUnityPlugin
{
public const string PluginGUID = "com.KingIDFK.explosionlaunch";
public const string PluginName = "Explosion Launch Mod";
public const string PluginVersion = "1.2.0";
internal static ManualLogSource Log;
private Harmony _harmony;
private void Awake()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"[Explosion Launch Mod] Cargando v1.2.0...");
ExplosionSettings.Bind(((BaseUnityPlugin)this).Config);
_harmony = new Harmony("com.KingIDFK.explosionlaunch");
ExplosionLaunchModule.Init(_harmony);
Log.LogInfo((object)"[Explosion Launch Mod] Patches aplicados correctamente.");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Log.LogInfo((object)"[Explosion Launch Mod] Descargado y patches removidos.");
}
}
}