using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoyalMod.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RoyalMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RoyalMod")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("BBC1740C-0796-4CE9-B350-F504DCC9C8B9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 RoyalMod
{
[BepInPlugin("Alarox.RoyalMod", "Lethal Company RoyalMod", "1.0.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string ModGUID = "Alarox.RoyalMod";
private const string ModName = "Lethal Company RoyalMod";
private const string ModVersion = "1.0.0.0";
private readonly Harmony _harmony = new Harmony("Alarox.RoyalMod");
private static Plugin Instance;
public static readonly ManualLogSource AlaroxLogger = Logger.CreateLogSource("Lethal Company RoyalMod");
public static AssetBundle mainAssetBundle;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
string location = ((BaseUnityPlugin)Instance).Info.Location;
string text = "RoyalAssets";
string text2 = location.TrimEnd("RoyalMod.dll".ToCharArray());
string text3 = text2 + text + "\\alaroxmod";
mainAssetBundle = AssetBundle.LoadFromFile(text3);
if ((Object)(object)mainAssetBundle == (Object)null)
{
AlaroxLogger.LogError((object)"RoyalMod - Failed to load audio assets mainBundle!");
return;
}
_harmony.PatchAll(typeof(Plugin));
_harmony.PatchAll(typeof(RoundManagerPatch));
_harmony.PatchAll(typeof(NoisemakerPropPatch));
_harmony.PatchAll(typeof(AirhornCooldownPatch));
_harmony.PatchAll(typeof(HoarderBugPatch));
_harmony.PatchAll(typeof(FlowermanPatch));
_harmony.PatchAll(typeof(ItemDropshipPatch));
}
}
}
namespace RoyalMod.Patches
{
[HarmonyPatch(typeof(GrabbableObject))]
public class AirhornCooldownPatch
{
[HarmonyPrefix]
[HarmonyPatch("RequireCooldown")]
public static bool Prefix(GrabbableObject __instance, ref bool __result)
{
NoisemakerProp val = (NoisemakerProp)(object)((__instance is NoisemakerProp) ? __instance : null);
if (val == null || ((GrabbableObject)val).itemProperties.itemName.ToLower() != "airhorn")
{
return true;
}
if (val.noiseAudio.isPlaying || val.noiseAudioFar.isPlaying)
{
__result = true;
}
else
{
__result = false;
}
return false;
}
}
[HarmonyPatch(typeof(FlowermanAI))]
internal class FlowermanPatch
{
private static AudioClip crackNeckSFX = Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/sam_ntm.mp3");
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void overrideFlowermanAudio(ref AudioClip ___crackNeckSFX)
{
___crackNeckSFX = crackNeckSFX;
}
}
[HarmonyPatch(typeof(HoarderBugAI))]
internal class HoarderBugPatch
{
private static AudioClip[] chitterSFX = (AudioClip[])(object)new AudioClip[1] { Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/toulouzzzzz.mp3") };
private static AudioClip[] chitterSFXTlzBlbl = (AudioClip[])(object)new AudioClip[1] { Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/tlz_blblblblb.mp3") };
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void overrideHoarderBugAudio(ref AudioClip[] ___chitterSFX)
{
___chitterSFX = chitterSFX;
}
[HarmonyPatch("DetectAndLookAtPlayers")]
[HarmonyPrefix]
private static void DetectAndLookAtPlayersPatch(ref PlayerControllerB ___watchingPlayer, ref EnemyAI __instance)
{
if ((Object)(object)___watchingPlayer != (Object)null)
{
Random random = new Random();
int num = random.Next(1, 10);
if (num == 1)
{
RoundManager.PlayRandomClip(__instance.creatureVoice, chitterSFXTlzBlbl, true, 1f, 0, 1000);
}
}
}
}
[HarmonyPatch(typeof(ItemDropship))]
internal class ItemDropshipPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void replaceDropshipMusic(ItemDropship __instance)
{
AudioSource component = ((Component)((Component)__instance).transform.Find("Music")).GetComponent<AudioSource>();
AudioSource component2 = ((Component)((Component)__instance).transform.Find("Music").GetChild(0)).GetComponent<AudioSource>();
component.clip = Plugin.mainAssetBundle.LoadAsset<AudioClip>("tlz_sing.mp3");
component2.clip = Plugin.mainAssetBundle.LoadAsset<AudioClip>("tlz_sing.mp3");
}
}
[HarmonyPatch(typeof(NoisemakerProp))]
internal class NoisemakerPropPatch
{
internal static AudioClip[] airhornSFX = (AudioClip[])(object)new AudioClip[13]
{
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/carglass.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/gang_gang.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/imposter.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/jabawockez.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/korea_kpop.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/manipulator.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/orange.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/pastore.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/poetic_lover.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/pokimane.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/spiderman_engine.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/stupid_voice_recorder.mp3"),
Plugin.mainAssetBundle.LoadAsset<AudioClip>("assets/weeb.mp3")
};
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void OverrideAirHornAudio(NoisemakerProp __instance)
{
if (((GrabbableObject)__instance).itemProperties.itemName.ToLower() == "airhorn")
{
__instance.noiseSFX = airhornSFX;
__instance.noiseSFXFar = airhornSFX;
}
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
public static Random Rand = new Random();
[HarmonyPatch(typeof(StartOfRound), "Start")]
[HarmonyPostfix]
private static void StartPatch()
{
UpdateMaterials(0);
}
[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
[HarmonyPostfix]
private static void GenerateNewLevelClientRpcPatch(int randomSeed)
{
UpdateMaterials(randomSeed);
}
private static void UpdateMaterials(int seed)
{
Rand = new Random(seed);
Material[] materials = ((Renderer)GameObject.Find("HangarShip/Plane.001").GetComponent<MeshRenderer>()).materials;
materials[0].mainTexture = (Texture)(object)Plugin.mainAssetBundle.LoadAsset<Texture2D>("assets/posters.jpg");
materials[1].mainTexture = (Texture)(object)Plugin.mainAssetBundle.LoadAsset<Texture2D>("assets/tip.jpg");
}
}
[HarmonyPatch(typeof(StartOfRound))]
public class StartOfRoundPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
public static void InitializeAllLevelsAndSpawnableScrap(StartOfRound __instance)
{
Plugin.AlaroxLogger.LogInfo((object)"InitializeAllLevelsAndSpawnableScrap");
if (__instance == null)
{
Plugin.AlaroxLogger.LogWarning((object)"__instance is null in 'InitializeAllLevelsAndSpawnableScrap'. Aborting.");
}
else
{
InitializeAllItems(__instance);
}
}
private static void InitializeAllItems(StartOfRound startOfRoundInstance)
{
Plugin.AlaroxLogger.LogInfo((object)"InitializeAllItems");
Plugin.AlaroxLogger.LogInfo((object)$"Found {startOfRoundInstance.allItemsList.itemsList.Count} items in allItemsList.");
foreach (Item item in startOfRoundInstance.allItemsList.itemsList.OrderBy((Item i) => i.itemName))
{
if (((Object)item).name == "Key")
{
item.isScrap = true;
}
}
}
}
}