using System;
using System.Collections.Generic;
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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using Unity.Netcode;
using UnityEngine;
[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("LethalClips")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2+31a1ccb8af15a554e5a8f912185e56971fff6ea6")]
[assembly: AssemblyProduct("Lethal Clips")]
[assembly: AssemblyTitle("LethalClips")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 LethalClips
{
[BepInPlugin("com.lalabuff.lethal.lethalclips", "LethalClips", "0.0.2")]
public class Plugin : BaseUnityPlugin
{
private const string GUID = "com.lalabuff.lethal.lethalclips";
private const string NAME = "LethalClips";
private const string VERSION = "0.0.2";
internal static ManualLogSource Log;
internal void Awake()
{
//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)
Log = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("com.lalabuff.lethal.lethalclips");
val.PatchAll();
foreach (MethodBase patchedMethod in val.GetPatchedMethods())
{
Log.LogInfo((object)$"Patched method {patchedMethod}.");
}
Log.LogInfo((object)"Successfully loaded LethalClips (com.lalabuff.lethal.lethalclips) v0.0.2!");
}
}
internal static class State<T> where T : new()
{
private static readonly Dictionary<object, T> states = new Dictionary<object, T>();
internal static T Of(object obj)
{
if (!states.TryGetValue(obj, out var value))
{
return states[obj] = new T();
}
return value;
}
}
}
namespace LethalClips.Patches
{
[HarmonyPatch]
internal class AnimationPatch
{
[HarmonyPatch(typeof(FlowermanAI), "killAnimation")]
[HarmonyPrefix]
private static void Bracken()
{
KillPatch.Kill(TranslatedCauseOfDeath.Strangled, "Bracken", -1f);
}
[HarmonyPatch(typeof(MouthDogAI), "KillPlayer")]
[HarmonyPrefix]
private static void EyelessDog()
{
KillPatch.Kill(TranslatedCauseOfDeath.Mauled, "Eyeless Dog", -1f);
}
[HarmonyPatch(typeof(ForestGiantAI), "EatPlayerAnimation")]
[HarmonyPrefix]
private static void ForestKeeper()
{
KillPatch.Kill(TranslatedCauseOfDeath.Devoured, "ForestKeeper", 6f);
}
[HarmonyPatch(typeof(JesterAI), "killPlayerAnimation")]
[HarmonyPrefix]
private static void Jester()
{
KillPatch.Kill(TranslatedCauseOfDeath.Mauled, "Jester", -1f);
}
[HarmonyPatch(typeof(MaskedPlayerEnemy), "killAnimation")]
[HarmonyPrefix]
private static void Masked(MaskedPlayerEnemy __instance)
{
KillPatch.Kill(TranslatedCauseOfDeath.Infected, __instance.mimickingPlayer?.playerUsername ?? "Masked", 5f);
}
[HarmonyPatch(typeof(RadMechAI), "TorchPlayerAnimation")]
[HarmonyPrefix]
private static void OldBird()
{
KillPatch.Kill(TranslatedCauseOfDeath.Incinerated, "Old Bird", 7f);
}
}
[HarmonyPatch(typeof(EnemyAI), "OnCollideWithPlayer")]
internal class DamagePatch
{
private static void Prefix(EnemyAI __instance, Collider other)
{
bool flag = __instance is DressGirlAI;
bool flag2 = flag;
if (Object.op_Implicit((Object)(object)__instance.MeetsStandardPlayerCollisionConditions(other, false, flag2)))
{
var (cause, source, num) = ((__instance is ClaySurgeonAI) ? (TranslatedCauseOfDeath.Snipped, "Barber", -1) : ((__instance is RedLocustBees) ? (TranslatedCauseOfDeath.Electrocuted, "Circuit Bees", 10) : ((__instance is ButlerEnemyAI) ? (TranslatedCauseOfDeath.Stabbed, "Butler", 10) : ((__instance is SpringManAI) ? (TranslatedCauseOfDeath.Springed, "Coil-Head", 90) : ((__instance is BushWolfEnemy) ? (TranslatedCauseOfDeath.Mauled, "Kidnapper Fox", -1) : ((__instance is DressGirlAI) ? (TranslatedCauseOfDeath.Died, "", -1) : ((__instance is BaboonBirdAI) ? (TranslatedCauseOfDeath.Stabbed, "Baboon Hawk", 20) : ((__instance is ButlerBeesEnemyAI) ? (TranslatedCauseOfDeath.Stabbed, "Mask Hornets", 10) : ((__instance is PufferAI) ? (TranslatedCauseOfDeath.Embarrassing, "", 20) : ((__instance is HoarderBugAI) ? (TranslatedCauseOfDeath.Mauled, "Hoarding Bug", 30) : ((__instance is CaveDwellerAI) ? (TranslatedCauseOfDeath.Mauled, "Maneater", -1) : ((__instance is NutcrackerEnemyAI) ? (TranslatedCauseOfDeath.Kicked, "Nutcracker", -1) : ((__instance is BlobAI) ? (TranslatedCauseOfDeath.Disintegrated, "Hydrogere", 35) : ((__instance is SandSpiderAI) ? (TranslatedCauseOfDeath.Mauled, "Bunker Spider", 90) : ((__instance is CrawlerAI) ? (TranslatedCauseOfDeath.Mauled, "Thumper", 40) : ((!(__instance is SandWormAI)) ? default((TranslatedCauseOfDeath, string, int)) : (TranslatedCauseOfDeath.Devoured, "Earth Leviathan", -1)))))))))))))))));
if (num == -1)
{
KillPatch.Kill(cause, source);
}
else
{
KillPatch.Damage(cause, source, num);
}
}
}
}
[HarmonyPatch(typeof(CentipedeAI), "DamagePlayerOnIntervals")]
internal class FleaPatch
{
private static void Prefix(CentipedeAI __instance, float ___damagePlayerInterval, bool ___inDroppingOffPlayerAnim, bool ___singlePlayerSecondChanceGiven)
{
if (___damagePlayerInterval <= 0f && !___inDroppingOffPlayerAnim && (((EnemyAI)__instance).stunNormalizedTimer > 0f || (StartOfRound.Instance.connectedPlayersAmount <= 0 && KillPatch.Player.health <= 15 && !___singlePlayerSecondChanceGiven)))
{
KillPatch.Damage(TranslatedCauseOfDeath.Suffocated, "Snare Flea", 10f);
}
}
}
[HarmonyPatch(typeof(ForestGiantAI), "AnimationEventA")]
internal class GiantPatch
{
private static void Prefix(ForestGiantAI __instance)
{
//IL_0006: 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)
RaycastHit[] array = Physics.SphereCastAll(__instance.deathFallPosition.position, 2.7f, __instance.deathFallPosition.forward, 3.9f, StartOfRound.Instance.playersMask, (QueryTriggerInteraction)1);
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)((Component)((RaycastHit)(ref array[i])).transform).GetComponent<PlayerControllerB>() == (Object)(object)KillPatch.Player)
{
KillPatch.Kill(TranslatedCauseOfDeath.Crushed, "Forest Keeper");
}
}
}
}
internal enum TranslatedCauseOfDeath
{
Killed,
Bludgeoned,
SPLAT,
Exploded,
Strangled,
Suffocated,
Mauled,
Shot,
Crushed,
Drowned,
Abandoned,
Electrocuted,
Kicked,
Incinerated,
Stabbed,
Sliced,
Crashed,
Snipped,
Devoured,
Springed,
Died,
Disintegrated,
Infected,
Embarrassing
}
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
internal static class KillPatch
{
private static TranslatedCauseOfDeath cause;
private static string source;
private static float time;
internal static string Message
{
get
{
string text = Enum.GetName(typeof(TranslatedCauseOfDeath), cause) ?? "Killed";
if (!string.IsNullOrEmpty(source))
{
text = text + " by " + source;
}
return text;
}
}
internal static PlayerControllerB Player => GameNetworkManager.Instance.localPlayerController;
internal static void Damage(TranslatedCauseOfDeath cause, string source, float damage)
{
if ((float)Player.health <= damage && (damage > 50f || Player.criticallyInjured))
{
Kill(cause, source);
}
}
internal static void Kill(TranslatedCauseOfDeath cause, string source, float timeout = 0.1f)
{
if (!(time < 0f))
{
KillPatch.cause = cause;
KillPatch.source = source;
if (timeout >= 0f)
{
time = Time.time + timeout;
}
else
{
time = -1f;
}
}
}
private static void Prefix(PlayerControllerB __instance, ref bool __state)
{
__state = ((NetworkBehaviour)__instance).IsOwner && !__instance.isPlayerDead && __instance.AllowPlayerDeath();
}
private static void Postfix(bool __state, CauseOfDeath causeOfDeath)
{
//IL_005d: 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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected I4, but got Unknown
if (__state)
{
if (0f <= time && time < Time.time)
{
cause = (TranslatedCauseOfDeath)causeOfDeath;
source = "";
}
Plugin.Log.LogInfo((object)("Player died! Cause of death: " + Message));
TimelineEventHandle val = SteamTimeline.AddInstantaneousTimelineEvent(Message, "git gud lol", "steam_death", 0u, 0f, (TimelineEventClipPriority)2);
Plugin.Log.LogInfo((object)$"Added timeline event {val}.");
time = 0f;
}
}
}
internal class Player
{
internal PlayerControllerB player;
}
[HarmonyPatch(typeof(Landmine), "OnTriggerExit")]
internal class LandminePatch_OnTriggerExit
{
private static void Prefix(Landmine __instance, Collider other, bool ___mineActivated)
{
if (__instance.hasExploded || !___mineActivated)
{
return;
}
Transform val = ((Component)other).transform;
PlayerControllerB player = default(PlayerControllerB);
while (Object.op_Implicit((Object)(object)val))
{
if (((Component)val).TryGetComponent<PlayerControllerB>(ref player))
{
State<Player>.Of(__instance).player = player;
break;
}
val = val.parent;
}
}
}
[HarmonyPatch(typeof(Landmine), "Detonate")]
internal class LandminePatch_Detonate
{
internal static void SpawnExplosion(Vector3 explosionPosition, float killRange, float damageRange, int nonLethalDamage, string source)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//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)
//IL_0046: 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)
Collider[] array = Physics.OverlapSphere(explosionPosition, damageRange, 2621448, (QueryTriggerInteraction)2);
RaycastHit val = default(RaycastHit);
for (int i = 0; i < array.Length; i++)
{
GameObject gameObject = ((Component)array[i]).gameObject;
float num = Vector3.Distance(explosionPosition, gameObject.transform.position);
if ((!Physics.Linecast(explosionPosition, gameObject.transform.position + Vector3.up * 0.3f, ref val, 1073742080, (QueryTriggerInteraction)1) || (((Component)((RaycastHit)(ref val)).collider).gameObject.layer != 30 && !(num > 4f))) && gameObject.layer == 3 && (Object)(object)gameObject.GetComponent<PlayerControllerB>() == (Object)(object)KillPatch.Player)
{
if (num < killRange)
{
KillPatch.Kill(TranslatedCauseOfDeath.Exploded, source);
}
else if (num < damageRange)
{
KillPatch.Damage(TranslatedCauseOfDeath.Exploded, source, nonLethalDamage);
}
break;
}
}
}
private static void Prefix(Landmine __instance)
{
//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)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
SpawnExplosion(((Component)__instance).transform.position + Vector3.up, 5.7f, 6f, 50, Blame(__instance));
}
private static string Blame(Landmine __instance)
{
PlayerControllerB player = State<Player>.Of(__instance).player;
if (!((Object)(object)player == (Object)null) && !((Object)(object)player == (Object)(object)KillPatch.Player))
{
return player.playerUsername;
}
return "Landmine";
}
}
[HarmonyPatch(typeof(RadMechAI))]
internal class OldPatch
{
[HarmonyPatch("Stomp")]
[HarmonyPrefix]
private static void Stomp(Transform stompTransform, float radius)
{
//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)
double num = Vector3.Distance(((Component)KillPatch.Player).transform.position, stompTransform.position);
if (num < (double)radius)
{
if (num < (double)radius * 0.175)
{
KillPatch.Damage(TranslatedCauseOfDeath.Crushed, "Old Bird", 70f);
}
else if (num < (double)(radius * 0.5f))
{
KillPatch.Damage(TranslatedCauseOfDeath.Crushed, "Old Bird", 30f);
}
}
}
[HarmonyPatch("SetExplosion")]
[HarmonyPrefix]
private static void SetExplosion(Vector3 explosionPosition, Vector3 forwardRotation)
{
//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)
LandminePatch_Detonate.SpawnExplosion(explosionPosition - forwardRotation * 0.1f, 1f, 7f, 30, "Old Bird");
}
}
[HarmonyPatch(typeof(ShotgunItem), "ShootGun")]
internal class ShotgunPatch
{
private static void Prefix(ShotgunItem __instance, Vector3 shotgunPosition, Vector3 shotgunForward)
{
//IL_0061: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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_0090: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
string source = (((GrabbableObject)__instance).isHeldByEnemy ? "Nutcracker" : ((!((GrabbableObject)__instance).isHeld) ? "Accident" : (((GrabbableObject)__instance).playerHeldBy?.playerUsername ?? "Player")));
bool num = ((GrabbableObject)__instance).isHeld && (Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)KillPatch.Player;
float num2 = Vector3.Distance(((Component)KillPatch.Player).transform.position, ((Component)__instance.shotgunRayPoint).transform.position);
Vector3 val = KillPatch.Player.playerCollider.ClosestPoint(shotgunPosition);
bool num3 = !num & !Physics.Linecast(shotgunPosition, val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) & (Vector3.Angle(shotgunForward, val - shotgunPosition) < 30f);
int num4 = 0;
if (num2 < 15f)
{
num4 = 100;
}
else if (num2 < 23f)
{
num4 = 40;
}
else if (num2 < 30f)
{
num4 = 20;
}
if (num3)
{
KillPatch.Damage(TranslatedCauseOfDeath.Shot, source, num4);
}
}
}
}