Decompiled source of LethalClips v0.0.4

LethalClips.dll

Decompiled a week ago
using System;
using System.Collections;
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.Configuration;
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.4.0")]
[assembly: AssemblyInformationalVersion("0.0.4+a4de4cc3b2a7822f66b037f0a0e55d4ba420337c")]
[assembly: AssemblyProduct("Lethal Clips")]
[assembly: AssemblyTitle("LethalClips")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.4.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
{
	public static class Config
	{
		public class ConfigGroup
		{
			[CompilerGenerated]
			private ConfigFile <config>P;

			[CompilerGenerated]
			private string <group>P;

			public ConfigGroup(ConfigFile config, string group)
			{
				<config>P = config;
				<group>P = group;
				base..ctor();
			}

			public ConfigEntry<T> Bind<T>(string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, params object[] tags)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				return <config>P.Bind<T>(<group>P, key, defaultValue, new ConfigDescription(description, acceptableValues, tags));
			}
		}

		public static class General
		{
			public static ConfigEntry<bool> Enabled { get; private set; }

			public static void Initialize(ConfigGroup config)
			{
				Enabled = config.Bind("Enabled", true, "Whether the mod should be loaded on game startup", null);
			}
		}

		public static class Clips
		{
			public static ConfigEntry<bool> Deaths { get; private set; }

			public static ConfigEntry<bool> Apparatus { get; private set; }

			public static ConfigEntry<bool> Teleporter { get; private set; }

			public static ConfigEntry<bool> Rounds { get; private set; }

			public static void Initialize(ConfigGroup config)
			{
				Deaths = config.Bind("Clip Deaths", true, "Create clip markers for player deaths", null);
				Apparatus = config.Bind("Clip Apparatus", true, "Create clip markers when someone takes the apparatus", null);
				Teleporter = config.Bind("Clip Teleporter", true, "Create clips markers when you are teleported by one of the teleporters", null);
				Rounds = config.Bind("Clip Round", true, "Create clip markers when the round begins and ends", null);
			}
		}

		public static void Initialize(ConfigFile config)
		{
			General.Initialize(new ConfigGroup(config, "General"));
			Clips.Initialize(new ConfigGroup(config, "Clips"));
		}
	}
	public enum ExtendedCauseOfDeath
	{
		Killed,
		Bludgeoned,
		SPLAT,
		Exploded,
		Strangled,
		Suffocated,
		Mauled,
		Shot,
		Crushed,
		Drowned,
		Abandoned,
		Electrocuted,
		Kicked,
		Incinerated,
		Stabbed,
		Sliced,
		Crashed,
		Snipped,
		Devoured,
		Springed,
		Died,
		Disintegrated,
		Infected,
		Embarrassing
	}
	public static class Player
	{
		public static PlayerControllerB Local => GameNetworkManager.Instance.localPlayerController;

		public static PlayerControllerB FromID(int id)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			if (0 > id || id >= allPlayerScripts.Length)
			{
				return null;
			}
			return allPlayerScripts[id];
		}

		public static bool IsLocal(int playerId)
		{
			return IsLocal(FromID(playerId));
		}

		public static bool IsLocal(PlayerControllerB player)
		{
			return (Object)(object)player == (Object)(object)Local;
		}
	}
	[BepInPlugin("com.lalabuff.lethal.lethalclips", "LethalClips", "0.0.4")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "com.lalabuff.lethal.lethalclips";

		private const string NAME = "LethalClips";

		private const string VERSION = "0.0.4";

		internal static ManualLogSource Log;

		internal void Awake()
		{
			//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)
			Log = ((BaseUnityPlugin)this).Logger;
			Config.Initialize(((BaseUnityPlugin)this).Config);
			if (!Config.General.Enabled.Value)
			{
				Log.LogWarning((object)"Mod is disabled. No patching will occur. To enable the mod, edit the configuration file and restart the game.");
				return;
			}
			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.4!");
		}
	}
	public abstract class State<K, V> where V : State<K, V>, new()
	{
		private static readonly Dictionary<K, V> states = new Dictionary<K, V>();

		public K Instance { get; private set; }

		public static V Of(K obj)
		{
			if (!states.TryGetValue(obj, out var value))
			{
				V val2 = (states[obj] = new V());
				value = val2;
				value.Instance = obj;
			}
			return value;
		}

		public static IEnumerable<(K, V)> All()
		{
			foreach (KeyValuePair<K, V> state in states)
			{
				yield return (state.Key, state.Value);
			}
		}
	}
	public static class StateExtensions
	{
		public static V GetState<K, V>(this GameObject obj) where K : Component where V : State<K, V>, new()
		{
			return State<K, V>.Of(obj.GetComponent<K>());
		}

		public static bool TryGetState<K, V>(this GameObject obj, out V state) where K : Component where V : State<K, V>, new()
		{
			K obj2 = default(K);
			if (obj.TryGetComponent<K>(ref obj2))
			{
				state = State<K, V>.Of(obj2);
				return true;
			}
			state = null;
			return false;
		}

		public static V GetState<K, V>(this Component obj) where K : Component where V : State<K, V>, new()
		{
			return obj.gameObject.GetState<K, V>();
		}

		public static bool TryGetState<K, V>(this Component obj, out V state) where K : Component where V : State<K, V>, new()
		{
			return obj.gameObject.TryGetState<K, V>(out state);
		}
	}
	public static class Steam
	{
		public enum Icon
		{
			Death,
			Caution,
			Transfer,
			Flag,
			Completed
		}

		public static string IconToString(Icon icon)
		{
			return icon switch
			{
				Icon.Death => "steam_death", 
				Icon.Caution => "steam_caution", 
				Icon.Transfer => "steam_transfer", 
				Icon.Flag => "steam_flag", 
				Icon.Completed => "steam_completed", 
				_ => "steam_marker", 
			};
		}

		public static TimelineEventHandle? AddEvent(string title, string description, Icon icon, uint priority = 0u, float offset = 0f, TimelineEventClipPriority possibleClip = 2)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				TimelineEventHandle val = SteamTimeline.AddInstantaneousTimelineEvent(title, description, IconToString(icon), priority, offset, possibleClip);
				Plugin.Log.LogInfo((object)$"Added timeline event {val}.");
				return val;
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Failed to add timeline event '{title}': {arg}");
				return null;
			}
		}
	}
}
namespace LethalClips.Patches
{
	[HarmonyPatch]
	public static class AnimationPatch
	{
		[HarmonyPatch(typeof(FlowermanAI), "killAnimation")]
		[HarmonyPrefix]
		public static void Bracken(FlowermanAI __instance)
		{
			State<PlayerControllerB, PlayerState>.Of(((EnemyAI)__instance).inSpecialAnimationWithPlayer).Kill(ExtendedCauseOfDeath.Strangled, "Bracken", -1f);
		}

		[HarmonyPatch(typeof(MouthDogAI), "KillPlayer")]
		[HarmonyPrefix]
		public static void EyelessDog(int playerId)
		{
			State<PlayerControllerB, PlayerState>.Of(Player.FromID(playerId)).Kill(ExtendedCauseOfDeath.Mauled, "Eyeless Dog", -1f);
		}

		[HarmonyPatch(typeof(ForestGiantAI), "EatPlayerAnimation")]
		[HarmonyPrefix]
		public static void ForestKeeper(PlayerControllerB playerBeingEaten)
		{
			State<PlayerControllerB, PlayerState>.Of(playerBeingEaten).Kill(ExtendedCauseOfDeath.Devoured, "Forest Keeper", 6f);
		}

		[HarmonyPatch(typeof(JesterAI), "killPlayerAnimation")]
		[HarmonyPrefix]
		public static void Jester(int playerId)
		{
			State<PlayerControllerB, PlayerState>.Of(Player.FromID(playerId)).Kill(ExtendedCauseOfDeath.Mauled, "Jester", -1f);
		}

		[HarmonyPatch(typeof(MaskedPlayerEnemy), "killAnimation")]
		[HarmonyPrefix]
		public static void Masked(MaskedPlayerEnemy __instance)
		{
			State<PlayerControllerB, PlayerState>.Of(((EnemyAI)__instance).inSpecialAnimationWithPlayer).Kill(ExtendedCauseOfDeath.Infected, __instance.mimickingPlayer?.playerUsername ?? "Masked", 5f);
		}

		[HarmonyPatch(typeof(RadMechAI), "TorchPlayerAnimation")]
		[HarmonyPrefix]
		public static void OldBird(RadMechAI __instance)
		{
			State<PlayerControllerB, PlayerState>.Of(((EnemyAI)__instance).inSpecialAnimationWithPlayer).Kill(ExtendedCauseOfDeath.Incinerated, "Old Bird", 7f);
		}
	}
	[HarmonyPatch(typeof(LungProp))]
	public class ApparatusPatch
	{
		[HarmonyPatch("DisconnectFromMachinery")]
		[HarmonyPostfix]
		public static void DisconnectFromMachinery()
		{
			if (Config.Clips.Apparatus.Value)
			{
				Steam.AddEvent("WARNING!", "Someone took the apparatus", Steam.Icon.Caution, 0u, 0f, (TimelineEventClipPriority)2);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	public static class DamagePatch
	{
		[HarmonyPatch("OnCollideWithPlayer")]
		[HarmonyPrefix]
		public static void OnCollideWithPlayer(EnemyAI __instance, Collider other)
		{
			bool flag = __instance is DressGirlAI;
			if (Object.op_Implicit((Object)(object)__instance.MeetsStandardPlayerCollisionConditions(other, false, flag)))
			{
				(ExtendedCauseOfDeath, string, int) tuple = ((__instance is ClaySurgeonAI) ? (ExtendedCauseOfDeath.Snipped, "Barber", -1) : ((__instance is RedLocustBees) ? (ExtendedCauseOfDeath.Electrocuted, "Circuit Bees", 10) : ((__instance is ButlerEnemyAI) ? (ExtendedCauseOfDeath.Stabbed, "Butler", 10) : ((__instance is SpringManAI) ? (ExtendedCauseOfDeath.Springed, "Coil-Head", 90) : ((__instance is BushWolfEnemy) ? (ExtendedCauseOfDeath.Mauled, "Kidnapper Fox", -1) : ((__instance is DressGirlAI) ? (ExtendedCauseOfDeath.Died, "", -1) : ((__instance is BaboonBirdAI) ? (ExtendedCauseOfDeath.Stabbed, "Baboon Hawk", 20) : ((__instance is ButlerBeesEnemyAI) ? (ExtendedCauseOfDeath.Stabbed, "Mask Hornets", 10) : ((__instance is PufferAI) ? (ExtendedCauseOfDeath.Embarrassing, "", 20) : ((__instance is HoarderBugAI) ? (ExtendedCauseOfDeath.Mauled, "Hoarding Bug", 30) : ((__instance is CaveDwellerAI) ? (ExtendedCauseOfDeath.Mauled, "Maneater", -1) : ((__instance is NutcrackerEnemyAI) ? (ExtendedCauseOfDeath.Kicked, "Nutcracker", -1) : ((__instance is BlobAI) ? (ExtendedCauseOfDeath.Disintegrated, "Hydrogere", 35) : ((__instance is SandSpiderAI) ? (ExtendedCauseOfDeath.Mauled, "Bunker Spider", 90) : ((__instance is CrawlerAI) ? (ExtendedCauseOfDeath.Mauled, "Thumper", 40) : ((!(__instance is SandWormAI)) ? default((ExtendedCauseOfDeath, string, int)) : (ExtendedCauseOfDeath.Devoured, "Earth Leviathan", -1)))))))))))))))));
				(ExtendedCauseOfDeath, string, int) tuple2 = tuple;
				ExtendedCauseOfDeath item = tuple2.Item1;
				string item2 = tuple2.Item2;
				int item3 = tuple2.Item3;
				PlayerState local = PlayerState.Local;
				if (item3 == -1)
				{
					local.Kill(item, item2);
				}
				else
				{
					local.Damage(item, item2, item3);
				}
			}
		}
	}
	[HarmonyPatch(typeof(CentipedeAI))]
	public class FleaPatch
	{
		[HarmonyPatch("DamagePlayerOnIntervals")]
		[HarmonyPrefix]
		public static void DamagePlayerOnIntervals(CentipedeAI __instance)
		{
			if (__instance.damagePlayerInterval <= 0f && !__instance.inDroppingOffPlayerAnim && ((EnemyAI)__instance).stunNormalizedTimer <= 0f && (StartOfRound.Instance.connectedPlayersAmount > 0 || Player.Local.health > 15 || __instance.singlePlayerSecondChanceGiven))
			{
				PlayerState.Local.Damage(ExtendedCauseOfDeath.Suffocated, "Snare Flea", 10f);
			}
		}
	}
	[HarmonyPatch(typeof(ForestGiantAI))]
	public class GiantPatch
	{
		[HarmonyPatch("AnimationEventA")]
		[HarmonyPrefix]
		public static void AnimationEventA(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++)
			{
				((Component)(object)((RaycastHit)(ref array[i])).transform).GetState<PlayerControllerB, PlayerState>().Damage(ExtendedCauseOfDeath.Crushed, "Forest Keeper", 30f);
			}
		}
	}
	public class LandmineState : State<Landmine, LandmineState>
	{
		public PlayerControllerB Detonator { get; set; }

		public string DetonatorName
		{
			get
			{
				if (Object.op_Implicit((Object)(object)Detonator) && !((Object)(object)Detonator == (Object)(object)Player.Local))
				{
					return Detonator.playerUsername;
				}
				return "Landmine";
			}
		}

		public static void SpawnExplosion(Vector3 explosionPosition, float killRange, float damageRange, int nonLethalDamage, string source)
		{
			//IL_000f: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005a: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogWarning((object)"kabooming");
			Collider[] array = Physics.OverlapSphere(explosionPosition, damageRange, 2621448, (QueryTriggerInteraction)2);
			RaycastHit val = default(RaycastHit);
			for (int i = 0; i < array.Length; i++)
			{
				Plugin.Log.LogWarning((object)"hit");
				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)
				{
					Plugin.Log.LogWarning((object)$"found object {gameObject}");
					PlayerState state = gameObject.GetState<PlayerControllerB, PlayerState>();
					Plugin.Log.LogWarning((object)$"player {state}");
					if (num < killRange)
					{
						state.Kill(ExtendedCauseOfDeath.Exploded, source);
					}
					else if (num < damageRange)
					{
						state.Damage(ExtendedCauseOfDeath.Exploded, source, nonLethalDamage);
					}
					break;
				}
			}
		}

		public void SpawnExplosion(Vector3 explosionPosition, float killRange, float damageRange, int nonLethalDamage)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			SpawnExplosion(explosionPosition, killRange, damageRange, nonLethalDamage, DetonatorName);
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	public class LandminePatch
	{
		[HarmonyPatch("OnTriggerExit")]
		[HarmonyPrefix]
		public static void OnTriggerExit(Landmine __instance, Collider other)
		{
			if (__instance.hasExploded || !__instance.mineActivated)
			{
				return;
			}
			Transform val = ((Component)other).transform;
			PlayerControllerB detonator = default(PlayerControllerB);
			while (Object.op_Implicit((Object)(object)val))
			{
				if (((Component)val).TryGetComponent<PlayerControllerB>(ref detonator))
				{
					State<Landmine, LandmineState>.Of(__instance).Detonator = detonator;
					break;
				}
				val = val.parent;
			}
		}

		[HarmonyPatch("Detonate")]
		[HarmonyPrefix]
		public static void Detonate(Landmine __instance)
		{
			//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)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			State<Landmine, LandmineState>.Of(__instance).SpawnExplosion(((Component)__instance).transform.position + Vector3.up, 5.7f, 6f, 50);
		}
	}
	[HarmonyPatch(typeof(RadMechAI))]
	public class MechPatch
	{
		[HarmonyPatch("Stomp")]
		[HarmonyPrefix]
		public 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)Player.Local).transform.position, stompTransform.position);
			if (num < (double)radius)
			{
				if (num < (double)radius * 0.175)
				{
					PlayerState.Local.Damage(ExtendedCauseOfDeath.Crushed, "Old Bird", 70f);
				}
				else if (num < (double)(radius * 0.5f))
				{
					PlayerState.Local.Damage(ExtendedCauseOfDeath.Crushed, "Old Bird", 30f);
				}
			}
		}

		[HarmonyPatch("SetExplosion")]
		[HarmonyPrefix]
		public 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)
			LandmineState.SpawnExplosion(explosionPosition - forwardRotation * 0.1f, 1f, 7f, 30, "Old Bird");
		}
	}
	public class PlayerState : State<PlayerControllerB, PlayerState>
	{
		public static PlayerState Local => State<PlayerControllerB, PlayerState>.Of(Player.Local);

		public ExtendedCauseOfDeath CauseOfDeath { get; private set; }

		public string SourceOfDeath { get; private set; }

		public float DeathTimeout { get; private set; }

		public string Message
		{
			get
			{
				string text = Enum.GetName(typeof(ExtendedCauseOfDeath), CauseOfDeath) ?? "Killed";
				if (!string.IsNullOrEmpty(SourceOfDeath))
				{
					text = text + " by " + SourceOfDeath;
				}
				return text;
			}
		}

		public void Kill(ExtendedCauseOfDeath cause, string source, float timeout = 0.1f)
		{
			if (!(DeathTimeout < 0f))
			{
				CauseOfDeath = cause;
				SourceOfDeath = source;
				if (timeout >= 0f)
				{
					DeathTimeout = Time.time + timeout;
				}
				else
				{
					DeathTimeout = -1f;
				}
			}
		}

		public void Damage(ExtendedCauseOfDeath cause, string source, float damage)
		{
			if ((float)base.Instance.health <= damage && (damage >= 50f || base.Instance.criticallyInjured))
			{
				Kill(cause, source);
			}
		}

		public void TriggerDeathEvent(CauseOfDeath causeOfDeath)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected I4, but got Unknown
			if (0f <= DeathTimeout && DeathTimeout < Time.time)
			{
				CauseOfDeath = (ExtendedCauseOfDeath)causeOfDeath;
				SourceOfDeath = "";
			}
			DeathTimeout = 0f;
			if (Config.Clips.Deaths.Value)
			{
				Steam.AddEvent("You died!", Message, Steam.Icon.Death, 96u, 0f, (TimelineEventClipPriority)2);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public static class PlayerPatch
	{
		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		public static void KillPlayer(PlayerControllerB __instance, CauseOfDeath causeOfDeath)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsOwner && !__instance.isPlayerDead && __instance.AllowPlayerDeath())
			{
				State<PlayerControllerB, PlayerState>.Of(__instance).TriggerDeathEvent(causeOfDeath);
			}
		}
	}
	[HarmonyPatch(typeof(ShotgunItem))]
	public class ShotgunPatch
	{
		[HarmonyPatch("ShootGun")]
		[HarmonyPrefix]
		public static void ShootGun(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)Player.Local;
			float num2 = Vector3.Distance(((Component)Player.Local).transform.position, ((Component)__instance.shotgunRayPoint).transform.position);
			Vector3 val = Player.Local.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)
			{
				PlayerState.Local.Damage(ExtendedCauseOfDeath.Shot, source, num4);
			}
		}
	}
	[HarmonyPatch(typeof(SpikeRoofTrap))]
	public static class SpikePatch
	{
		[HarmonyPatch("OnTriggerStay")]
		[HarmonyPrefix]
		public static void OnTriggerStay(SpikeRoofTrap __instance, Collider other)
		{
			if (__instance.trapActive && __instance.slammingDown && !(Time.realtimeSinceStartup - __instance.timeSinceMovingUp < 0.75f) && ((Component)(object)other).TryGetState<PlayerControllerB, PlayerState>(out PlayerState state) && !state.Instance.isPlayerDead)
			{
				state.Kill(ExtendedCauseOfDeath.Crushed, "Spike Trap");
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatch
	{
		[HarmonyPatch("openingDoorsSequence")]
		[HarmonyPrefix]
		public static void OpeningDoorsSequence()
		{
			if (Config.Clips.Rounds.Value)
			{
				Steam.AddEvent("Round start", "The ship has landed", Steam.Icon.Flag, 0u, 0f, (TimelineEventClipPriority)2);
			}
		}

		[HarmonyPatch("ShipHasLeft")]
		[HarmonyPrefix]
		public static void ShipHasLeft()
		{
			if (Config.Clips.Rounds.Value)
			{
				Steam.AddEvent("Round end", "The ship has left", Steam.Icon.Completed, 0u, 0f, (TimelineEventClipPriority)2);
			}
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	public class TeleporterPatch
	{
		[HarmonyPatch("beamUpPlayer")]
		[HarmonyPostfix]
		public static void BeamUpPlayer(ref IEnumerator __result)
		{
			IEnumerator original = __result;
			__result = Wrapper();
			IEnumerator Wrapper()
			{
				PlayerControllerB player = StartOfRound.Instance.mapScreen.targetedPlayer;
				yield return original;
				if (Config.Clips.Teleporter.Value && (Object)(object)player == (Object)(object)Player.Local)
				{
					string description = (player.isPlayerDead ? "Yoink" : "Sav") + "ed by the teleporter";
					Steam.AddEvent("Teleported", description, Steam.Icon.Transfer, 0u, 0f, (TimelineEventClipPriority)2);
				}
			}
		}

		[HarmonyPatch("TeleportPlayerOutWithInverseTeleporter")]
		[HarmonyPostfix]
		public static void TeleportPlayerOutWithInverseTeleporter(int playerObj)
		{
			if (Config.Clips.Teleporter.Value && (Object)(object)Player.FromID(playerObj) == (Object)(object)Player.Local)
			{
				Steam.AddEvent("Teleported", "Inverse teleported into the facility", Steam.Icon.Transfer, 0u, 0f, (TimelineEventClipPriority)2);
			}
		}
	}
	[HarmonyPatch(typeof(Turret))]
	public static class TurretPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void Update(Turret __instance)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			if (__instance.turretActive && ((int)__instance.turretMode == 2 || ((int)__instance.turretMode == 3 && !__instance.enteringBerserkMode)) && __instance.turretInterval >= 0.21f && (Object)(object)__instance.CheckForPlayersInLineOfSight(3f, false) == (Object)(object)Player.Local)
			{
				PlayerState.Local.Damage(ExtendedCauseOfDeath.Shot, "Turret", 50f);
			}
		}
	}
}