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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GabrielJester.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GabrielJester")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Gabriel Jester mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GabrielJester")]
[assembly: AssemblyTitle("GabrielJester")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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 GabrielJester
{
public class GabrielConfig
{
public static void Load()
{
}
}
internal class GabrielControl : MonoBehaviour
{
public List<AudioClip> VoiceLines = new List<AudioClip>();
private List<AudioClip> voiceLinesShuffled = new List<AudioClip>();
public AudioClip MonologueA;
public AudioClip MonologueB;
public AudioClip SwordSwingA;
public AudioClip SwordSwingB;
public AudioClip Music;
public AudioClip Silence;
private JesterAI ai;
private Animator anim;
private AudioSource audioSource;
private Coroutine swordSwingCoroutine;
private bool startedA;
private Coroutine monologueACoroutine;
private bool startedB;
private Coroutine monologueBCoroutine;
private int voiceLineIndex = 0;
public bool inKillAnimation;
public void Awake()
{
anim = ((Component)this).GetComponent<Animator>();
ai = ((Component)((Component)this).transform.parent).GetComponent<JesterAI>();
ai.popGoesTheWeaselTheme = Silence;
ai.popUpSFX = Silence;
ai.screamingSFX = Silence;
ai.killPlayerSFX = Silence;
audioSource = ((Component)this).GetComponent<AudioSource>();
}
public void Reset()
{
if (swordSwingCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(swordSwingCoroutine);
swordSwingCoroutine = null;
}
if (monologueACoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(monologueACoroutine);
monologueACoroutine = null;
}
if (monologueBCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(monologueBCoroutine);
monologueBCoroutine = null;
}
startedA = false;
startedB = false;
audioSource.Stop();
ShuffleVoiceLines();
anim.SetBool("Triggered", false);
anim.SetTrigger("Reset");
}
public void ShuffleVoiceLines()
{
voiceLinesShuffled = new List<AudioClip>(VoiceLines);
int count = voiceLinesShuffled.Count;
int num = count - 1;
for (int i = 0; i < num; i++)
{
int index = Random.Range(i, count);
AudioClip value = voiceLinesShuffled[i];
voiceLinesShuffled[i] = voiceLinesShuffled[index];
voiceLinesShuffled[index] = value;
}
}
public void Update()
{
if (swordSwingCoroutine == null && inKillAnimation)
{
swordSwingCoroutine = ((MonoBehaviour)this).StartCoroutine(Attack());
}
if (((EnemyAI)ai).currentBehaviourStateIndex == 0 && (Object)(object)((EnemyAI)ai).targetPlayer != (Object)null && !startedA && GameNetworkManager.Instance.isHostingGame)
{
GabrielNetworkManager.Instance.GabrielSayMonologueAClientRpc(((Component)((Component)this).transform.parent).GetComponent<NetworkObject>().NetworkObjectId);
startedA = true;
ai.beginCrankingTimer = 40.546f;
}
if (((EnemyAI)ai).currentBehaviourStateIndex == 1 && !startedB)
{
startedB = true;
monologueBCoroutine = ((MonoBehaviour)this).StartCoroutine(SayMonologueB());
ai.popUpTimer = 41.608f;
}
}
public void MonologueAClientRpc()
{
monologueACoroutine = ((MonoBehaviour)this).StartCoroutine(SayMonologueA());
startedA = true;
ai.beginCrankingTimer = 40.546f;
}
private IEnumerator SayMonologueA()
{
audioSource.PlayOneShot(MonologueA);
monologueACoroutine = null;
yield break;
}
private IEnumerator SayMonologueB()
{
audioSource.PlayOneShot(MonologueB);
yield return (object)new WaitForSeconds(39.167f);
anim.SetTrigger("Cutscene");
yield return (object)new WaitForSeconds(1.787f);
yield return (object)new WaitForSeconds(0.654f);
yield return (object)new WaitForSeconds(0.792f);
CreateExplosion(((Component)this).transform.position + Vector3.up, spawnExplosionEffect: true, 0, 5.7f, 6.4f, 6, (CauseOfDeath)3);
audioSource.loop = true;
audioSource.clip = Music;
audioSource.Play();
anim.SetBool("Triggered", true);
while (true)
{
yield return (object)new WaitForSeconds(8f);
Debug.Log((object)"Playing voice line");
if (voiceLineIndex >= 0 && voiceLineIndex < voiceLinesShuffled.Count)
{
audioSource.PlayOneShot(voiceLinesShuffled[voiceLineIndex]);
}
voiceLineIndex = (voiceLineIndex + 1) % voiceLinesShuffled.Count;
}
}
private IEnumerator Attack()
{
anim.SetTrigger("Attack");
yield return (object)new WaitForSeconds(0.43f);
audioSource.PlayOneShot(SwordSwingA);
yield return (object)new WaitForSeconds(1.06f);
audioSource.PlayOneShot(SwordSwingB);
yield return (object)new WaitForSeconds(1f);
swordSwingCoroutine = null;
}
public static void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 1f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null, AudioClip playSound = null)
{
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: 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_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"Spawning explosion at pos: {explosionPosition}");
Transform val = null;
if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
{
val = RoundManager.Instance.mapPropsContainer.transform;
}
if (spawnExplosionEffect)
{
GameObject val2 = Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val);
if ((Object)(object)playSound != (Object)null)
{
AudioSource componentInChildren = val2.GetComponentInChildren<AudioSource>();
componentInChildren.clip = playSound;
componentInChildren.Play();
}
val2.SetActive(true);
}
float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition);
if (num < 14f)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
}
else if (num < 25f)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
}
Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
PlayerControllerB val3 = null;
for (int i = 0; i < array.Length; i++)
{
float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
{
continue;
}
if (((Component)array[i]).gameObject.layer == 3)
{
val3 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)val3 != (Object)null && ((NetworkBehaviour)val3).IsOwner)
{
float num3 = 0f;
if (damage > 0)
{
num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
}
val3.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, default(Vector3));
}
}
else if (((Component)array[i]).gameObject.layer == 19)
{
EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
{
componentInChildren2.mainScript.HitEnemyOnLocalClient(enemyHitForce, default(Vector3), attacker, false);
}
}
}
int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
array = Physics.OverlapSphere(explosionPosition, 10f, num4);
for (int j = 0; j < array.Length; j++)
{
Rigidbody component = ((Component)array[j]).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.AddExplosionForce(70f, explosionPosition, 10f);
}
}
}
}
internal class GabrielNetworkManager : NetworkBehaviour
{
public static GabrielNetworkManager Instance;
private void Awake()
{
Instance = this;
}
[ClientRpc]
public void GabrielSayMonologueAClientRpc(ulong id)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_0071: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(927349973u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, id);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 927349973u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
GabrielControl[] array = Object.FindObjectsByType<GabrielControl>((FindObjectsSortMode)0);
foreach (GabrielControl gabrielControl in array)
{
object obj;
if (gabrielControl == null)
{
obj = null;
}
else
{
Transform transform = ((Component)gabrielControl).transform;
if (transform == null)
{
obj = null;
}
else
{
Transform parent = transform.parent;
obj = ((parent != null) ? ((Component)parent).GetComponent<NetworkObject>() : null);
}
}
NetworkObject val3 = (NetworkObject)obj;
if ((Object)(object)val3 != (Object)null && val3.NetworkObjectId == id)
{
gabrielControl.MonologueAClientRpc();
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_GabrielNetworkManager()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(927349973u, new RpcReceiveHandler(__rpc_handler_927349973));
}
private static void __rpc_handler_927349973(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong id = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref id);
target.__rpc_exec_stage = (__RpcExecStage)2;
((GabrielNetworkManager)(object)target).GabrielSayMonologueAClientRpc(id);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "GabrielNetworkManager";
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManagerPatcher
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void AddToPrefabs(ref GameNetworkManager __instance)
{
((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.Instance.NetworkManagerPrefab);
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatcher
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void SpawnGabrielNetworkManager(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsHost)
{
Object.Instantiate<GameObject>(Plugin.Instance.NetworkManagerPrefab).GetComponent<NetworkObject>().Spawn(false);
}
}
}
[HarmonyPatch(typeof(JesterAI))]
internal class JesterPatcher
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start(JesterAI __instance)
{
if (!(((object)__instance).GetType() != typeof(JesterAI)))
{
((Behaviour)((Component)__instance).GetComponentInChildren<Animator>()).enabled = false;
Renderer[] componentsInChildren = ((Component)((Component)__instance).transform.Find("MeshContainer")).GetComponentsInChildren<Renderer>();
foreach (Renderer val in componentsInChildren)
{
val.enabled = false;
}
GameObject val2 = Object.Instantiate<GameObject>(Plugin.Instance.GabrielPrefab, ((Component)__instance).transform);
}
}
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void SendData(JesterAI __instance, ref bool ___inKillAnimation)
{
GabrielControl componentInChildren = ((Component)__instance).GetComponentInChildren<GabrielControl>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.inKillAnimation = ___inKillAnimation;
}
}
[HarmonyPostfix]
[HarmonyPatch("SetJesterInitialValues")]
private static void Reset(JesterAI __instance)
{
GabrielControl componentInChildren = ((Component)__instance).GetComponentInChildren<GabrielControl>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.Reset();
}
}
}
[BepInPlugin("56a5eedc-db9b-48b8-983d-d0b1f4a82c7e", "GabrielJester", "0.1")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "56a5eedc-db9b-48b8-983d-d0b1f4a82c7e";
private const string PLUGIN_NAME = "GabrielJester";
private const string PLUGIN_VERSION = "0.1";
public static Plugin Instance;
public GameObject GabrielPrefab;
public GameObject NetworkManagerPrefab;
public static ConfigFile config;
private void Awake()
{
config = ((BaseUnityPlugin)this).Config;
GabrielConfig.Load();
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
Instance = this;
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "gabriel");
AssetBundle val = AssetBundle.LoadFromFile(text);
NetworkManagerPrefab = val.LoadAsset<GameObject>("Assets/Gabriel/GabrielNetworkManager.prefab");
NetworkManagerPrefab.AddComponent<GabrielNetworkManager>();
List<AudioClip> voiceLines = new List<AudioClip>
{
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_phaseChange2.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntAngry1.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntAngry2.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntAngry3.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntAngry4.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntAngry5.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntAngry6.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntAngry7.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic1.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic2.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic3.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic4.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic5.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic6.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic7.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic8.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic9.wav"),
val.LoadAsset<AudioClip>("Assets/Gabriel/gab2nd_TauntEcstatic10.wav")
};
AudioClip monologueA = val.LoadAsset<AudioClip>("Assets/Gabriel/monologue0.ogg");
AudioClip monologueB = val.LoadAsset<AudioClip>("Assets/Gabriel/monologue1.ogg");
AudioClip swordSwingA = val.LoadAsset<AudioClip>("Assets/Gabriel/GabrielSwing2.wav");
AudioClip swordSwingB = val.LoadAsset<AudioClip>("Assets/Gabriel/GabrielSwing.wav");
AudioClip music = val.LoadAsset<AudioClip>("Assets/Gabriel/music.ogg");
EnemyType val2 = val.LoadAsset<EnemyType>("Assets/Gabriel/Gabriel.asset");
GabrielControl gabrielControl = val2.enemyPrefab.AddComponent<GabrielControl>();
gabrielControl.VoiceLines = voiceLines;
gabrielControl.MonologueA = monologueA;
gabrielControl.MonologueB = monologueB;
gabrielControl.SwordSwingA = swordSwingA;
gabrielControl.SwordSwingB = swordSwingB;
gabrielControl.Music = music;
GabrielPrefab = val2.enemyPrefab;
Utilities.FixMixerGroups(val2.enemyPrefab);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "56a5eedc-db9b-48b8-983d-d0b1f4a82c7e");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 56a5eedc-db9b-48b8-983d-d0b1f4a82c7e is loaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "GabrielJester";
public const string PLUGIN_NAME = "GabrielJester";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace GabrielJester.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}