using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using loaforcsSoundAPI.Core;
using loaforcsSoundAPI.Core.Data;
using loaforcsSoundAPI.Core.Networking;
using loaforcsSoundAPI.LethalCompany.Conditions;
using loaforcsSoundAPI.LethalCompany.Conditions.Contexts;
using loaforcsSoundAPI.LethalCompany.Conditions.Player;
using loaforcsSoundAPI.Reporting;
using loaforcsSoundAPI.Reporting.Data;
using loaforcsSoundAPI.SoundPacks.Data.Conditions;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("me.loaforc.soundapi.lethalcompany")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1c5da9aa0ecea20002b9c72ce776120988276ecd")]
[assembly: AssemblyProduct("loaforcsSoundAPI-LethalCompany")]
[assembly: AssemblyTitle("me.loaforc.soundapi.lethalcompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 loaforcsSoundAPI.LethalCompany
{
[BepInPlugin("me.loaforc.soundapi.lethalcompany", "loaforcsSoundAPI-LethalCompany", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class loaforcsSoundAPILethalCompany : BaseUnityPlugin
{
internal static readonly List<string> foundDungeonTypes = new List<string>();
internal static readonly List<string> foundMoonNames = new List<string>();
internal static readonly List<ReverbPreset> foundReverbPresets = new List<ReverbPreset>();
internal static readonly List<FootstepSurface> foundFootstepSurfaces = new List<FootstepSurface>();
private void Awake()
{
SoundAPI.RegisterAll(Assembly.GetExecutingAssembly());
SoundReportHandler.AddReportSection("Lethal Company", (Action<StreamWriter, SoundReport>)delegate(StreamWriter stream, SoundReport _)
{
stream.WriteLine("Version: `1.0.0` <br/>");
SoundReportHandler.WriteList("Found Dungeon Types", stream, (ICollection<string>)foundDungeonTypes);
SoundReportHandler.WriteList("Found Moon Names", stream, (ICollection<string>)foundMoonNames);
SoundReportHandler.WriteList("Found Reverb Presets", stream, (ICollection<string>)foundReverbPresets.Select(ReverbPresetToHumanReadable).ToList());
SoundReportHandler.WriteList("Found Footstep Surfaces", stream, (ICollection<string>)foundFootstepSurfaces.Select((FootstepSurface it) => it.surfaceTag).ToList());
SoundReportHandler.WriteEnum<PlayerLocationCondition.LocationType>("Player Location Types", stream);
SoundReportHandler.WriteEnum<ApparatusStateCondition.StateType>("Apparatus State Types", stream);
SoundReportHandler.WriteEnum<DayMode>("Time Of Day Types", stream);
});
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "me.loaforc.soundapi.lethalcompany");
}
private static string ReverbPresetToHumanReadable(ReverbPreset preset)
{
string text = ((Object)preset).name + "<br/>\n";
text += $"hasEcho: {preset.hasEcho} <br/>\n";
text += $"changeRoom: {preset.changeRoom}, room: {preset.room} <br/>\n";
text += $"changeDecayTime: {preset.changeDecayTime}, decayTime: {preset.decayTime} <br/>\n";
text += $"changeDryLevel: {preset.changeDryLevel}, dryLevel: {preset.dryLevel} <br/>\n";
text += $"changeHighFreq: {preset.changeHighFreq}, highFreq: {preset.highFreq} <br/>\n";
return text + $"changeLowFreq: {preset.changeLowFreq}, lowFreq: {preset.lowFreq} <br/>\n";
}
}
public class NGONetworkAdapter : NetworkAdapter
{
public override string Name => "Unity Netcode for GameObjects";
public override void OnRegister()
{
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "me.loaforc.soundapi.lethalcompany";
public const string PLUGIN_NAME = "loaforcsSoundAPI-LethalCompany";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace loaforcsSoundAPI.LethalCompany.Patches
{
[HarmonyPatch(typeof(LungProp))]
internal static class ApparatusPatch
{
[HarmonyPatch("EquipItem")]
[HarmonyPrefix]
[HarmonyWrapSafe]
private static void OnApparatusPull(LungProp __instance)
{
if (__instance.isLungDocked)
{
ApparatusStateCondition.CurrentApparatusPulled = true;
}
}
}
[HarmonyPatch(typeof(AudioReverbTrigger))]
internal static class AudioReverbTriggerPatch
{
[HarmonyPatch("ChangeAudioReverbForPlayer")]
[HarmonyPostfix]
[HarmonyWrapSafe]
private static void LogFoundReverbPreset(AudioReverbTrigger __instance)
{
if (SoundReportHandler.CurrentReport != null && !((Object)(object)__instance.reverbPreset == (Object)null) && !loaforcsSoundAPILethalCompany.foundReverbPresets.Contains(__instance.reverbPreset))
{
loaforcsSoundAPILethalCompany.foundReverbPresets.Add(__instance.reverbPreset);
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal static class PlayerControllerPatch
{
[HarmonyPatch("Start")]
private static void UpdatePlayerContexts(PlayerControllerB __instance)
{
PlayerContext currentContext = new PlayerContext(__instance);
AudioSourceAdditionalData.GetOrCreate(__instance.movementAudio).CurrentContext = (IContext)(object)currentContext;
AudioSourceAdditionalData.GetOrCreate(__instance.statusEffectAudio).CurrentContext = (IContext)(object)currentContext;
AudioSourceAdditionalData.GetOrCreate(__instance.waterBubblesAudio).CurrentContext = (IContext)(object)currentContext;
}
}
[HarmonyPatch(typeof(RoundManager))]
internal static class RoundManagerPatch
{
[HarmonyPatch("GenerateNewFloor")]
[HarmonyPostfix]
[HarmonyWrapSafe]
private static void Reporting()
{
if (SoundReportHandler.CurrentReport != null)
{
string name = ((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name;
string name2 = ((Object)StartOfRound.Instance.currentLevel).name;
if (!loaforcsSoundAPILethalCompany.foundDungeonTypes.Contains(name))
{
loaforcsSoundAPILethalCompany.foundDungeonTypes.Add(name);
}
if (!loaforcsSoundAPILethalCompany.foundMoonNames.Contains(name2))
{
loaforcsSoundAPILethalCompany.foundMoonNames.Add(name2);
}
}
}
[HarmonyPatch("Awake")]
[HarmonyPostfix]
[HarmonyWrapSafe]
private static void ListenForPowerChanges()
{
((UnityEvent<bool>)(object)RoundManager.Instance.onPowerSwitch).AddListener((UnityAction<bool>)delegate(bool power)
{
FacilityPowerStateCondition.CurrentPowerState = power;
});
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRoundPatch
{
[HarmonyPrefix]
[HarmonyPatch("EndOfGame")]
[HarmonyWrapSafe]
private static void ResetApparatusState()
{
ApparatusStateCondition.CurrentApparatusPulled = false;
}
[HarmonyPostfix]
[HarmonyPatch("Awake")]
[HarmonyWrapSafe]
private static void ReportFootstepSurfaces()
{
if (SoundReportHandler.CurrentReport == null)
{
return;
}
FootstepSurface[] footstepSurfaces = StartOfRound.Instance.footstepSurfaces;
foreach (FootstepSurface item in footstepSurfaces)
{
if (!loaforcsSoundAPILethalCompany.foundFootstepSurfaces.Contains(item))
{
loaforcsSoundAPILethalCompany.foundFootstepSurfaces.Add(item);
}
}
}
}
}
namespace loaforcsSoundAPI.LethalCompany.Conditions
{
[SoundAPICondition("LethalCompany:apparatus_state")]
public class ApparatusStateCondition : Condition
{
public enum StateType
{
PULLED,
PLUGGED_IN
}
internal static bool CurrentApparatusPulled;
public StateType? Value { get; internal set; }
public override bool Evaluate(IContext context)
{
StateType stateType = ((!CurrentApparatusPulled) ? StateType.PLUGGED_IN : StateType.PULLED);
return stateType == Value.GetValueOrDefault();
}
}
[SoundAPICondition("LethalCompany:dungeon_name")]
public class DungeonNameCondition : Condition
{
public string Value { get; internal set; }
public override bool Evaluate(IContext context)
{
if (!Object.op_Implicit((Object)(object)RoundManager.Instance))
{
return false;
}
string name = ((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name;
return string.Equals(Value, name, StringComparison.InvariantCultureIgnoreCase);
}
}
[SoundAPICondition("LethalCompany:facility_power_state")]
public class FacilityPowerStateCondition : Condition
{
internal static bool CurrentPowerState;
public bool? Value { get; internal set; }
public override bool Evaluate(IContext context)
{
return CurrentPowerState == Value.GetValueOrDefault(true);
}
}
[SoundAPICondition("LethalCompany:moon_name")]
public class MoonNameCondition : Condition
{
public string Value { get; internal set; }
public override bool Evaluate(IContext context)
{
if (!Object.op_Implicit((Object)(object)StartOfRound.Instance))
{
return false;
}
string name = ((Object)StartOfRound.Instance.currentLevel).name;
return string.Equals(Value, name, StringComparison.InvariantCultureIgnoreCase);
}
}
[SoundAPICondition("LethalCompany:player:standing_on")]
public class PlayerStandingOnCondition : Condition<PlayerContext>
{
public string Value { get; internal set; }
protected override bool EvaluateWithContext(PlayerContext context)
{
if (!Object.op_Implicit((Object)(object)context.Player))
{
return false;
}
return string.Equals(Value, StartOfRound.Instance.footstepSurfaces[context.Player.currentFootstepSurfaceIndex].surfaceTag, StringComparison.InvariantCultureIgnoreCase);
}
protected override bool EvaluateFallback(IContext context)
{
if (!Object.op_Implicit((Object)(object)GameNetworkManager.Instance))
{
return false;
}
return ((Condition<PlayerContext>)this).EvaluateWithContext(new PlayerContext(GameNetworkManager.Instance.localPlayerController));
}
}
[SoundAPICondition("LethalCompany:time_of_day")]
public class TimeOfDayCondition : Condition
{
public string Value { get; internal set; }
public override bool Evaluate(IContext context)
{
if (!Object.op_Implicit((Object)(object)TimeOfDay.Instance))
{
return false;
}
return string.Equals(Value, ((object)(DayMode)(ref TimeOfDay.Instance.dayMode)).ToString(), StringComparison.InvariantCultureIgnoreCase);
}
}
}
namespace loaforcsSoundAPI.LethalCompany.Conditions.Player
{
[SoundAPICondition("LethalCompany:player:audio_reverb")]
public class AudioReverbCondition : Condition
{
public bool? HasEcho { get; private set; }
[CanBeNull]
public string Name { get; private set; }
public override bool Evaluate(IContext context)
{
if (!Object.op_Implicit((Object)(object)GameNetworkManager.Instance))
{
return false;
}
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if (!Object.op_Implicit((Object)(object)localPlayerController))
{
return false;
}
if (!Object.op_Implicit((Object)(object)localPlayerController.reverbPreset))
{
return false;
}
if (HasEcho.HasValue && HasEcho == localPlayerController.reverbPreset.hasEcho)
{
return true;
}
if (Name != null && string.Equals(Name, ((Object)localPlayerController.reverbPreset).name, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
return false;
}
}
[SoundAPICondition("LethalCompany:player:is_alone")]
public class PlayerAloneCondition : Condition<PlayerContext>
{
public bool? Value { get; internal set; }
protected override bool EvaluateWithContext(PlayerContext context)
{
if (!Object.op_Implicit((Object)(object)context.Player))
{
return false;
}
return context.Player.isPlayerAlone == Value.GetValueOrDefault(true);
}
protected override bool EvaluateFallback(IContext context)
{
if (!Object.op_Implicit((Object)(object)GameNetworkManager.Instance))
{
return false;
}
return ((Condition<PlayerContext>)this).EvaluateWithContext(new PlayerContext(GameNetworkManager.Instance.localPlayerController));
}
}
[SoundAPICondition("LethalCompany:player:health")]
public class PlayerHealthCondition : Condition<PlayerContext>
{
public string Value { get; private set; }
protected override bool EvaluateWithContext(PlayerContext context)
{
if (!Object.op_Implicit((Object)(object)context.Player))
{
return false;
}
if (context.Player.isPlayerDead)
{
return false;
}
return ((Condition)this).EvaluateRangeOperator(context.Player.health, Value);
}
protected override bool EvaluateFallback(IContext context)
{
if (!Object.op_Implicit((Object)(object)GameNetworkManager.Instance))
{
return false;
}
return ((Condition<PlayerContext>)this).EvaluateWithContext(new PlayerContext(GameNetworkManager.Instance.localPlayerController));
}
public override List<ValidationResult> Validate()
{
ValidationResult item = default(ValidationResult);
if (!((Condition)this).ValidateRangeOperator(Value, ref item))
{
return new List<ValidationResult>(1) { item };
}
return new List<ValidationResult>();
}
}
[SoundAPICondition("LethalCompany:player:insanity")]
public class PlayerInsanityCondition : Condition<PlayerContext>
{
public string Value { get; internal set; }
protected override bool EvaluateWithContext(PlayerContext context)
{
if (!Object.op_Implicit((Object)(object)context.Player))
{
return false;
}
if (context.Player.isPlayerDead)
{
return false;
}
return ((Condition)this).EvaluateRangeOperator(context.Player.insanityLevel, Value);
}
protected override bool EvaluateFallback(IContext context)
{
if (!Object.op_Implicit((Object)(object)GameNetworkManager.Instance))
{
return false;
}
return ((Condition<PlayerContext>)this).EvaluateWithContext(new PlayerContext(GameNetworkManager.Instance.localPlayerController));
}
public override List<ValidationResult> Validate()
{
ValidationResult item = default(ValidationResult);
if (!((Condition)this).ValidateRangeOperator(Value, ref item))
{
return new List<ValidationResult>(1) { item };
}
return new List<ValidationResult>();
}
}
[SoundAPICondition("LethalCompany:player:location")]
public class PlayerLocationCondition : Condition<PlayerContext>
{
public enum LocationType
{
INSIDE,
ON_SHIP,
OUTSIDE
}
public LocationType Value { get; internal set; }
protected override bool EvaluateWithContext(PlayerContext context)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)context.Player))
{
return false;
}
if (context.Player.isPlayerDead)
{
return false;
}
if (context.Player.isInsideFactory)
{
return Value == LocationType.INSIDE;
}
Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
if (((Bounds)(ref bounds)).Contains(((Component)context.Player).transform.position))
{
return Value == LocationType.ON_SHIP;
}
return Value == LocationType.OUTSIDE;
}
protected override bool EvaluateFallback(IContext context)
{
if (!Object.op_Implicit((Object)(object)GameNetworkManager.Instance))
{
return false;
}
return ((Condition<PlayerContext>)this).EvaluateWithContext(new PlayerContext(GameNetworkManager.Instance.localPlayerController));
}
}
}
namespace loaforcsSoundAPI.LethalCompany.Conditions.Contexts
{
public class PlayerContext : IContext
{
[CompilerGenerated]
private PlayerControllerB <player>P;
public PlayerControllerB Player => <player>P;
public PlayerContext(PlayerControllerB player)
{
<player>P = player;
base..ctor();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}