using System;
using System.Collections;
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 BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;
[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("Oopsies")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("You made a sound")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Oopsies")]
[assembly: AssemblyTitle("Oopsies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 OopsiesAudio
{
[Serializable]
public struct WebAudioIndex
{
public string version;
public List<string> files;
}
public struct CoolAudioClip
{
public string filename;
public AudioClip clip;
}
[Serializable]
public class Config
{
[CompilerGenerated]
private static class <>O
{
public static CanModifyDelegate <0>__AudioIndexCanModifyCallback;
public static CanModifyDelegate <1>__RequireHostCanModifyCallback;
}
public static ConfigEntry<string> audioIndexURL;
public static ConfigEntry<float> audioLevel;
public static ConfigEntry<int> initialDelayMin;
public static ConfigEntry<int> initialDelayMax;
public static ConfigEntry<int> moreDelayMin;
public static ConfigEntry<int> moreDelayMax;
public static ConfigEntry<bool> triggerUntilDone;
public Config(ConfigFile cfg)
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Expected O, but got Unknown
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Expected O, but got Unknown
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Expected O, but got Unknown
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Expected O, but got Unknown
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Expected O, but got Unknown
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
audioIndexURL = cfg.Bind<string>("General", "AudioIndexURL", "https://cdn.sc07.group/audio.json", "URL of a raw JSON file which includes an array of mp3 file URLs with the key of 'files'");
audioLevel = cfg.Bind<float>("General", "AudioLevel", 1f, "Loudness of the audio clip (synced to other clients from host)");
initialDelayMin = cfg.Bind<int>("Delays", "InitialDelayMin", 180, "Initial random delay minimum (seconds)");
initialDelayMax = cfg.Bind<int>("Delays", "InitialDelayMax", 360, "Initial random delay maximum (seconds)");
moreDelayMin = cfg.Bind<int>("Delays", "MoreDelayMin", 60, "Additional random delay minimum (seconds)");
moreDelayMax = cfg.Bind<int>("Delays", "MoreDelayMax", 120, "Additional random delay maximum (seconds)");
triggerUntilDone = cfg.Bind<bool>("Experimental", "TriggerUntilDone", true, "Constantly trigger enemies until audio is finished playing");
ConfigEntry<string> obj = audioIndexURL;
TextInputFieldOptions val = new TextInputFieldOptions();
object obj2 = <>O.<0>__AudioIndexCanModifyCallback;
if (obj2 == null)
{
CanModifyDelegate val2 = AudioIndexCanModifyCallback;
<>O.<0>__AudioIndexCanModifyCallback = val2;
obj2 = (object)val2;
}
((BaseOptions)val).CanModifyCallback = (CanModifyDelegate)obj2;
((BaseOptions)val).RequiresRestart = false;
TextInputFieldConfigItem val3 = new TextInputFieldConfigItem(obj, val);
ConfigEntry<float> obj3 = audioLevel;
FloatSliderOptions val4 = new FloatSliderOptions();
((BaseRangeOptions<float>)val4).Min = 0.5f;
((BaseRangeOptions<float>)val4).Max = 2f;
object obj4 = <>O.<1>__RequireHostCanModifyCallback;
if (obj4 == null)
{
CanModifyDelegate val5 = RequireHostCanModifyCallback;
<>O.<1>__RequireHostCanModifyCallback = val5;
obj4 = (object)val5;
}
((BaseOptions)val4).CanModifyCallback = (CanModifyDelegate)obj4;
((BaseOptions)val4).RequiresRestart = false;
FloatSliderConfigItem val6 = new FloatSliderConfigItem(obj3, val4);
ConfigEntry<bool> obj5 = triggerUntilDone;
BoolCheckBoxOptions val7 = new BoolCheckBoxOptions();
object obj6 = <>O.<1>__RequireHostCanModifyCallback;
if (obj6 == null)
{
CanModifyDelegate val8 = RequireHostCanModifyCallback;
<>O.<1>__RequireHostCanModifyCallback = val8;
obj6 = (object)val8;
}
((BaseOptions)val7).CanModifyCallback = (CanModifyDelegate)obj6;
((BaseOptions)val7).RequiresRestart = false;
new BoolCheckBoxConfigItem(obj5, val7);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
LethalConfigManager.AddConfigItem((BaseConfigItem)val6);
}
public static CanModifyResult AudioIndexCanModifyCallback()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkManager.Singleton.IsHost && NetworkManager.Singleton.IsConnectedClient)
{
return CanModifyResult.op_Implicit((false, "Must be host"));
}
OopsiesAudioNetworking instance = OopsiesAudioNetworking.Instance;
if ((Object)(object)((instance != null) ? ((Component)instance).gameObject : null) == (Object)null)
{
return CanModifyResult.True();
}
return CanModifyResult.False("This can only be modified while not in game");
}
public static CanModifyResult RequireHostCanModifyCallback()
{
//IL_0037: 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)
if ((Object)(object)NetworkManager.Singleton != (Object)null && !NetworkManager.Singleton.IsHost && NetworkManager.Singleton.IsConnectedClient)
{
return CanModifyResult.op_Implicit((false, "Must be host"));
}
return CanModifyResult.op_Implicit(true);
}
public static void RequestResync()
{
if (NetworkManager.Singleton.IsHost)
{
OopsiesAudioNetworking.AnnounceConfig();
}
}
}
[BepInPlugin("Oopsies", "Oopsies", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class OopsiesAudioLoader : BaseUnityPlugin
{
public static Harmony harmony;
public static ManualLogSource Logger;
public static string path;
public static AssetBundle assetBundle;
public static Config Config { get; internal set; }
private void Awake()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_006c: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Oopsies is loading...");
Config = new Config(((BaseUnityPlugin)this).Config);
Logger = ((BaseUnityPlugin)this).Logger;
assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sc07assets"));
harmony = new Harmony("group.sc07.oopsies");
harmony.PatchAll();
GameObject val = new GameObject("OopsiesAudio");
val.AddComponent<OopsiesAudioPersistent>();
((Object)val).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)val);
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
for (int i = 0; i < types.Length; i++)
{
MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Oopsies is loaded!");
}
public static void chat(string str)
{
typeof(HUDManager).GetMethod("AddChatMessage", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(HUDManager.Instance, new object[2] { str, "sc07" });
}
}
public class OopsiesAudioNetworking : NetworkBehaviour
{
public static OopsiesAudioNetworking Instance { get; private set; }
public static event Action<ulong, int> LevelEvent;
public override void OnNetworkSpawn()
{
OopsiesAudioNetworking.LevelEvent = null;
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
OopsiesAudioNetworking instance = Instance;
if (instance != null)
{
((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
}
}
Instance = this;
((NetworkBehaviour)this).OnNetworkSpawn();
}
[ClientRpc]
public void MakeSoundClientRpc(ulong player, int audio)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1902901973u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, player);
BytePacker.WriteValueBitPacked(val2, audio);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1902901973u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
OopsiesAudioLoader.Logger.LogWarning((object)"Received client RPC, invoking listeners");
OopsiesAudioNetworking.LevelEvent?.Invoke(player, audio);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void MakeSoundServerRpc(ulong player, int audio)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2714643482u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, player);
BytePacker.WriteValueBitPacked(val2, audio);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2714643482u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
OopsiesAudioLoader.Logger.LogWarning((object)"Received server RPC, exec client rpc");
MakeSoundClientRpc(player, audio);
}
}
}
public static void AnnounceConfig()
{
Instance.LoadConfigClientRpc(Config.audioIndexURL.Value, Config.audioLevel.Value, Config.initialDelayMin.Value, Config.initialDelayMax.Value, Config.moreDelayMin.Value, Config.moreDelayMax.Value, Config.triggerUntilDone.Value);
}
[ServerRpc(RequireOwnership = false)]
public void RequestConfigServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(953863663u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 953863663u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
OopsiesAudioLoader.Logger.LogWarning((object)"A client is requesting config, sending...");
AnnounceConfig();
}
}
}
[ClientRpc]
public void LoadConfigClientRpc(string audioIndexURL, float audioLevel, int initialDelayMin, int initialDelayMax, int moreDelayMin, int moreDelayMax, bool triggerUntilDone)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: 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(941150640u, val, (RpcDelivery)0);
bool flag = audioIndexURL != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe(audioIndexURL, false);
}
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref audioLevel, default(ForPrimitives));
BytePacker.WriteValueBitPacked(val2, initialDelayMin);
BytePacker.WriteValueBitPacked(val2, initialDelayMax);
BytePacker.WriteValueBitPacked(val2, moreDelayMin);
BytePacker.WriteValueBitPacked(val2, moreDelayMax);
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref triggerUntilDone, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 941150640u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
Config.audioIndexURL.Value = audioIndexURL;
Config.audioLevel.Value = audioLevel;
Config.initialDelayMin.Value = initialDelayMin;
Config.initialDelayMax.Value = initialDelayMax;
Config.moreDelayMin.Value = moreDelayMin;
Config.moreDelayMax.Value = moreDelayMax;
Config.triggerUntilDone.Value = triggerUntilDone;
OopsiesAudioLoader.Logger.LogWarning((object)"Server sent config, loaded");
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_OopsiesAudioNetworking()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(1902901973u, new RpcReceiveHandler(__rpc_handler_1902901973));
NetworkManager.__rpc_func_table.Add(2714643482u, new RpcReceiveHandler(__rpc_handler_2714643482));
NetworkManager.__rpc_func_table.Add(953863663u, new RpcReceiveHandler(__rpc_handler_953863663));
NetworkManager.__rpc_func_table.Add(941150640u, new RpcReceiveHandler(__rpc_handler_941150640));
}
private static void __rpc_handler_1902901973(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong player = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref player);
int audio = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref audio);
target.__rpc_exec_stage = (__RpcExecStage)2;
((OopsiesAudioNetworking)(object)target).MakeSoundClientRpc(player, audio);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2714643482(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong player = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref player);
int audio = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref audio);
target.__rpc_exec_stage = (__RpcExecStage)1;
((OopsiesAudioNetworking)(object)target).MakeSoundServerRpc(player, audio);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_953863663(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((OopsiesAudioNetworking)(object)target).RequestConfigServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_941150640(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string audioIndexURL = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref audioIndexURL, false);
}
float audioLevel = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref audioLevel, default(ForPrimitives));
int initialDelayMin = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref initialDelayMin);
int initialDelayMax = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref initialDelayMax);
int moreDelayMin = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref moreDelayMin);
int moreDelayMax = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref moreDelayMax);
bool triggerUntilDone = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref triggerUntilDone, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((OopsiesAudioNetworking)(object)target).LoadConfigClientRpc(audioIndexURL, audioLevel, initialDelayMin, initialDelayMax, moreDelayMin, moreDelayMax, triggerUntilDone);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "OopsiesAudioNetworking";
}
}
public class OopsiesAudioPersistent : MonoBehaviour
{
public string loadedAudioIndexURL;
public List<CoolAudioClip> clips = new List<CoolAudioClip>();
public static Dictionary<ulong, AudioSource> audioSources = new Dictionary<ulong, AudioSource>();
private int plays;
private DateTime? playUntil;
public static OopsiesAudioPersistent Instance { get; private set; }
private void Awake()
{
Instance = this;
((MonoBehaviour)this).StartCoroutine(LoadSoundClips());
Config.audioIndexURL.SettingChanged += delegate
{
if (NetworkManager.Singleton.IsHost)
{
OopsiesAudioLoader.Logger.LogWarning((object)$"[host] audioIndexURL changed {Config.audioLevel.Value}");
Config.RequestResync();
}
else
{
OopsiesAudioLoader.Logger.LogWarning((object)$"[client] audioIndexURL changed {Config.audioLevel.Value}");
}
if (Config.audioIndexURL.Value != loadedAudioIndexURL)
{
OopsiesAudioLoader.Logger.LogWarning((object)"AudioIndexURL was changed and new URL is not currently loaded, downloading...");
((MonoBehaviour)this).StartCoroutine(LoadSoundClips());
}
};
Config.audioLevel.SettingChanged += delegate
{
if (NetworkManager.Singleton.IsHost)
{
OopsiesAudioLoader.Logger.LogWarning((object)$"[host] audioLevel changed {Config.audioLevel.Value}");
Config.RequestResync();
}
else
{
OopsiesAudioLoader.Logger.LogWarning((object)$"[client] audioLevel changed {Config.audioLevel.Value}");
}
};
Config.triggerUntilDone.SettingChanged += delegate
{
if (NetworkManager.Singleton.IsHost)
{
OopsiesAudioLoader.Logger.LogWarning((object)$"[host] audioLevel changed {Config.triggerUntilDone.Value}");
Config.RequestResync();
}
else
{
OopsiesAudioLoader.Logger.LogWarning((object)$"[client] audioLevel changed {Config.triggerUntilDone.Value}");
}
};
}
private static GameObject GetGameObjectForClientId(ulong clientId)
{
return StartOfRound.Instance.allPlayerObjects.Where((GameObject o) => o.GetComponent<PlayerControllerB>().actualClientId == clientId).First();
}
private static AudioSource GetAudioSourceForClientId(ulong clientId)
{
if (audioSources.ContainsKey(clientId))
{
return audioSources[clientId];
}
AudioSource movementAudio = GetGameObjectForClientId(clientId).GetComponent<PlayerControllerB>().movementAudio;
audioSources[clientId] = movementAudio;
return movementAudio;
}
private static void MakeSoundRecieve(ulong player, int audio)
{
CoolAudioClip coolAudioClip = Instance.clips[audio];
GetAudioSourceForClientId(player).PlayOneShot(coolAudioClip.clip, Config.audioLevel.Value);
}
public void OnRoundStart()
{
OopsiesAudioNetworking.LevelEvent += MakeSoundRecieve;
plays = 0;
int num = Random.Range(Config.initialDelayMin.Value, Config.initialDelayMax.Value);
OopsiesAudioLoader.Logger.LogWarning((object)("Next audio in " + num));
((MonoBehaviour)this).Invoke("MakeSound", (float)num);
}
public void OnRoundEnd()
{
OopsiesAudioNetworking.LevelEvent -= MakeSoundRecieve;
((MonoBehaviour)this).CancelInvoke("MakeSound");
}
public int GetRandomDelayBetweenPlays()
{
return Random.Range(Config.moreDelayMin.Value, Config.moreDelayMax.Value);
}
public void Update()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if (playUntil > DateTime.Now)
{
OopsiesAudioLoader.Logger.LogWarning((object)"playing audio");
RoundManager.Instance.PlayAudibleNoise(((Component)StartOfRound.Instance.localPlayerController).transform.position, 16f, 0.9f, plays, false, 5);
}
}
public void MakeSound()
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead)
{
int num = Random.Range(0, clips.Count() - 1);
if (Config.triggerUntilDone.Value)
{
plays++;
playUntil = DateTime.Now.AddSeconds(clips[num].clip.length);
}
else
{
RoundManager.Instance.PlayAudibleNoise(((Component)StartOfRound.Instance.localPlayerController).transform.position, 16f, 0.9f, plays++, false, 5);
}
OopsiesAudioNetworking.Instance.MakeSoundServerRpc(StartOfRound.Instance.localPlayerController.actualClientId, num);
HUDManager.Instance.DisplayTip("oopsie", "you made a sound", false, false, "LC_Tip1");
}
int randomDelayBetweenPlays = GetRandomDelayBetweenPlays();
OopsiesAudioLoader.Logger.LogWarning((object)("Next audio in " + randomDelayBetweenPlays));
((MonoBehaviour)this).Invoke("MakeSound", (float)randomDelayBetweenPlays);
}
private IEnumerator LoadSoundClips()
{
loadedAudioIndexURL = Config.audioIndexURL.Value;
OopsiesAudioLoader.Logger.LogInfo((object)("Loading audio from " + Config.audioIndexURL.Value + "... [set in config file]"));
UnityWebRequest req2 = UnityWebRequest.Get(Config.audioIndexURL.Value);
WebAudioIndex index;
try
{
yield return req2.SendWebRequest();
if ((int)req2.result != 1)
{
OopsiesAudioLoader.Logger.LogError((object)("audio.json error " + req2.error));
yield break;
}
string text = req2.downloadHandler.GetText();
index = JsonUtility.FromJson<WebAudioIndex>(text);
}
finally
{
((IDisposable)req2)?.Dispose();
}
OopsiesAudioLoader.Logger.LogInfo((object)$"Loading {index.files.Count} audio files...");
foreach (string file in index.files)
{
string filename = file.Split('/').Last();
OopsiesAudioLoader.Logger.LogInfo((object)("Downloading " + filename + "..."));
req2 = UnityWebRequestMultimedia.GetAudioClip(file, (AudioType)13);
try
{
yield return req2.SendWebRequest();
Result result = req2.result;
if ((int)result != 1)
{
if (result - 2 <= 2)
{
OopsiesAudioLoader.Logger.LogError((object)(filename + " error " + req2.error));
}
}
else
{
clips.Add(new CoolAudioClip
{
filename = filename,
clip = DownloadHandlerAudioClip.GetContent(req2)
});
OopsiesAudioLoader.Logger.LogInfo((object)("Loaded " + filename));
}
}
finally
{
((IDisposable)req2)?.Dispose();
}
}
OopsiesAudioLoader.Logger.LogInfo((object)$"Loaded {index.files.Count} audio files!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "Oopsies";
public const string PLUGIN_NAME = "Oopsies";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace OopsiesAudio.Patches
{
[HarmonyPatch]
public class PlayerPatcher
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
public static void InitializeLocalPlayer()
{
OopsiesAudioNetworking.Instance.RequestConfigServerRpc();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
public static void PlayerLeave()
{
}
}
[HarmonyPatch]
public class NetworkObjectManager
{
private static GameObject networkPrefab;
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "Start")]
public static void Init()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
if (!((Object)(object)networkPrefab != (Object)null))
{
networkPrefab = (GameObject)OopsiesAudioLoader.assetBundle.LoadAsset("PluginNetworkHandler");
networkPrefab.AddComponent<OopsiesAudioNetworking>();
NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Awake")]
private static void SpawnNetworkHandler()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity).GetComponent<NetworkObject>().Spawn(false);
}
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RMPatches
{
[HarmonyPostfix]
[HarmonyPatch("GenerateNewFloor")]
private static void detectNewLevel()
{
OopsiesAudioPersistent.Instance.OnRoundStart();
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class SORPatches
{
[HarmonyPostfix]
[HarmonyPatch("DespawnPropsAtEndOfRound")]
private static void shipLeave()
{
OopsiesAudioPersistent.Instance.OnRoundEnd();
}
}
}