using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Steamworks;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using com.github.zehsteam.MilkButton.Dependencies.LethalConfigMod;
using com.github.zehsteam.MilkButton.Extensions;
using com.github.zehsteam.MilkButton.Helpers;
using com.github.zehsteam.MilkButton.Managers;
using com.github.zehsteam.MilkButton.MonoBehaviours;
using com.github.zehsteam.MilkButton.NetcodePatcher;
using com.github.zehsteam.MilkButton.Objects;
using com.github.zehsteam.MilkButton.Patches;
[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("Zehs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2026 Zehs")]
[assembly: AssemblyDescription("Adds the milk button from Insym's dream.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d033e691eb7af52fb51a646888802e90380aa897")]
[assembly: AssemblyProduct("MilkButton")]
[assembly: AssemblyTitle("com.github.zehsteam.MilkButton")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 com.github.zehsteam.MilkButton
{
internal static class Assets
{
public static readonly string AssetBundleFileName = "milkbutton_assets";
public static AssetBundle AssetBundle { get; private set; }
public static GameObject PluginNetworkHandlerPrefab { get; private set; }
public static GameObject VoiceControllerPrefab { get; private set; }
public static GameObject PluginCanvasPrefab { get; private set; }
public static void Load()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, AssetBundleFileName);
if (!File.Exists(text))
{
Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text + "\". Make sure the \"" + AssetBundleFileName + "\" file is in the same folder as the mod's DLL file.");
}
else
{
AssetBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)AssetBundle == (Object)null)
{
Logger.LogFatal("Failed to load assets. AssetBundle is null.");
}
else
{
OnAssetBundleLoaded(AssetBundle);
}
}
}
private static void OnAssetBundleLoaded(AssetBundle assetBundle)
{
PluginNetworkHandlerPrefab = LoadAsset<GameObject>("PluginNetworkHandler", assetBundle);
VoiceControllerPrefab = LoadAsset<GameObject>("VoiceController", assetBundle);
PluginCanvasPrefab = LoadAsset<GameObject>("PluginCanvas", assetBundle);
}
private static T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object
{
if (string.IsNullOrWhiteSpace(name))
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace.");
return default(T);
}
if ((Object)(object)assetBundle == (Object)null)
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null.");
return default(T);
}
T val = assetBundle.LoadAsset<T>(name);
if ((Object)(object)val == (Object)null)
{
Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name.");
return default(T);
}
return val;
}
private static bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object
{
asset = LoadAsset<T>(name, assetBundle);
return (Object)(object)asset != (Object)null;
}
}
internal static class Logger
{
public static ManualLogSource ManualLogSource { get; private set; }
public static bool IsExtendedLoggingEnabled => ConfigManager.Misc_ExtendedLogging?.Value ?? false;
public static void Initialize(ManualLogSource manualLogSource)
{
ManualLogSource = manualLogSource;
}
public static void LogDebug(object data)
{
Log((LogLevel)32, data);
}
public static void LogInfo(object data, bool extended = false)
{
Log((LogLevel)16, data, extended);
}
public static void LogMessage(object data, bool extended = false)
{
Log((LogLevel)8, data, extended);
}
public static void LogWarning(object data, bool extended = false)
{
Log((LogLevel)4, data, extended);
}
public static void LogError(object data, bool extended = false)
{
Log((LogLevel)2, data, extended);
}
public static void LogFatal(object data, bool extended = false)
{
Log((LogLevel)1, data, extended);
}
public static void Log(LogLevel logLevel, object data, bool extended = false)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (!extended || IsExtendedLoggingEnabled)
{
ManualLogSource manualLogSource = ManualLogSource;
if (manualLogSource != null)
{
manualLogSource.Log(logLevel, data);
}
}
}
}
[BepInPlugin("com.github.zehsteam.MilkButton", "MilkButton", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("com.github.zehsteam.MilkButton");
internal static Plugin Instance { get; private set; }
private void Awake()
{
Instance = this;
Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.MilkButton"));
Logger.LogInfo("MilkButton has awoken!");
_harmony.PatchAll(typeof(GameNetworkManager_Patches));
_harmony.PatchAll(typeof(StartOfRound_Patches));
_harmony.PatchAll(typeof(HUDManager_Patches));
_harmony.PatchAll(typeof(PlayerControllerB_Patches));
Assets.Load();
ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
NetworkUtils.NetcodePatcherAwake();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.github.zehsteam.MilkButton";
public const string PLUGIN_NAME = "MilkButton";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace com.github.zehsteam.MilkButton.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal static class GameNetworkManager_Patches
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start_Patch()
{
AddNetworkPrefabs();
}
private static void AddNetworkPrefabs()
{
NetworkUtils.AddNetworkPrefab(Assets.PluginNetworkHandlerPrefab);
NetworkUtils.AddNetworkPrefab(Assets.VoiceControllerPrefab);
}
}
[HarmonyPatch(typeof(HUDManager))]
internal static class HUDManager_Patches
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start_Patch()
{
PluginCanvas.Spawn();
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal static class PlayerControllerB_Patches
{
private static bool _wasLocalPlayerDead;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start_Patch(PlayerControllerB __instance)
{
if (NetworkUtils.IsServer)
{
VoiceController.Spawn_Server(__instance);
}
}
[HarmonyPatch("OnDestroy")]
[HarmonyPrefix]
private static void OnDestroy_Patch(PlayerControllerB __instance)
{
if (NetworkUtils.IsServer)
{
VoiceController.Despawn_Server(__instance);
}
}
[HarmonyPatch("KillPlayer")]
[HarmonyPrefix]
private static void KillPlayer_Prefix_Patch(PlayerControllerB __instance)
{
if (PlayerUtils.IsLocalPlayer(__instance))
{
_wasLocalPlayerDead = __instance.isPlayerDead;
}
}
[HarmonyPatch("KillPlayer")]
[HarmonyPostfix]
private static void KillPlayer_Postfix_Patch(PlayerControllerB __instance)
{
if (PlayerUtils.IsLocalPlayer(__instance) && !_wasLocalPlayerDead && __instance.isPlayerDead)
{
OnLocalPlayerDeath();
}
}
private static void OnLocalPlayerDeath()
{
if (ConfigManager.Button_Enabled.Value && CanActivateButton())
{
float value = ConfigManager.Button_ActivateChance.Value;
if (Utils.RollPercentChance(value))
{
PluginNetworkHandler.Instance?.ShowPanel_ServerRpc();
}
}
}
private static bool CanActivateButton()
{
if (NetworkUtils.IsServer && ConfigManager.Button_ActivateFromHost.Value)
{
return true;
}
if (ConfigManager.Button_ActivateFromEveryone.Value)
{
return true;
}
string name = SteamClient.Name;
if (ConfigManager.Button_ActivateFromPlayers_Collection.Contains(name.ToLower()))
{
return true;
}
return false;
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRound_Patches
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake_Patch()
{
if (NetworkUtils.IsServer)
{
PluginNetworkHandler.Spawn_Server();
}
}
[HarmonyPatch("OnClientConnect")]
[HarmonyPostfix]
private static void OnClientConnect_Patch(ulong clientId)
{
if (NetworkUtils.IsServer)
{
VoiceController.OnClientConnect_Server(clientId);
}
}
[HarmonyPatch("ShipHasLeft")]
[HarmonyPostfix]
private static void ShipHasLeft_Patch()
{
if (NetworkUtils.IsServer)
{
PluginNetworkHandler.Instance?.HidePanel_ServerRpc();
}
}
}
}
namespace com.github.zehsteam.MilkButton.Objects
{
public class PlayerAudioGroup
{
public AudioSource VoiceAudio { get; private set; }
public AudioSource DeadAudio { get; private set; }
public bool IsPlaying => VoiceAudio.isPlaying;
public float Volume01
{
get
{
return VoiceAudio.volume;
}
set
{
VoiceAudio.volume = value;
DeadAudio.volume = value;
}
}
public float Pitch
{
get
{
return VoiceAudio.pitch;
}
set
{
VoiceAudio.pitch = value;
DeadAudio.pitch = value;
}
}
public float MaxDistance
{
get
{
return VoiceAudio.maxDistance;
}
set
{
VoiceAudio.maxDistance = value;
DeadAudio.maxDistance = value;
}
}
public AudioClip Clip
{
get
{
return VoiceAudio.clip;
}
set
{
VoiceAudio.clip = value;
DeadAudio.clip = value;
}
}
public bool Mute
{
get
{
if (VoiceAudio.mute)
{
return DeadAudio.mute;
}
return false;
}
set
{
VoiceAudio.mute = value;
DeadAudio.mute = value;
}
}
public PlayerAudioGroup(AudioSource voiceAudio, AudioSource deadAudio)
{
VoiceAudio = voiceAudio;
DeadAudio = deadAudio;
}
public void Play()
{
AudioSource voiceAudio = VoiceAudio;
if (voiceAudio != null)
{
voiceAudio.Play();
}
AudioSource deadAudio = DeadAudio;
if (deadAudio != null)
{
deadAudio.Play();
}
}
public void Pause()
{
AudioSource voiceAudio = VoiceAudio;
if (voiceAudio != null)
{
voiceAudio.Pause();
}
AudioSource deadAudio = DeadAudio;
if (deadAudio != null)
{
deadAudio.Pause();
}
}
public void Stop()
{
AudioSource voiceAudio = VoiceAudio;
if (voiceAudio != null)
{
voiceAudio.Stop();
}
AudioSource deadAudio = DeadAudio;
if (deadAudio != null)
{
deadAudio.Stop();
}
}
public void PlayOneShot(AudioClip clip)
{
AudioSource voiceAudio = VoiceAudio;
if (voiceAudio != null)
{
AudioSource voiceAudio2 = VoiceAudio;
voiceAudio.PlayOneShot(clip, (voiceAudio2 != null) ? voiceAudio2.volume : 1f);
}
AudioSource deadAudio = DeadAudio;
if (deadAudio != null)
{
AudioSource deadAudio2 = DeadAudio;
deadAudio.PlayOneShot(clip, (deadAudio2 != null) ? deadAudio2.volume : 1f);
}
}
public void PlayOneShot(AudioClip clip, float volumeScale)
{
AudioSource voiceAudio = VoiceAudio;
if (voiceAudio != null)
{
voiceAudio.PlayOneShot(clip, volumeScale);
}
AudioSource deadAudio = DeadAudio;
if (deadAudio != null)
{
deadAudio.PlayOneShot(clip, volumeScale);
}
}
}
}
namespace com.github.zehsteam.MilkButton.MonoBehaviours
{
public class ButtonController : MonoBehaviour
{
[CompilerGenerated]
private sealed class <PressAnimation>d__9 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ButtonController <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PressAnimation>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
ButtonController buttonController = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
((Component)buttonController).transform.localScale = buttonController._originalScale;
<>2__current = buttonController.ScaleTo(buttonController._originalScale * buttonController._pressedScale, buttonController._animationDuration);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = buttonController.ScaleTo(buttonController._originalScale, buttonController._animationDuration);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ScaleTo>d__10 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ButtonController <>4__this;
public float duration;
public Vector3 targetScale;
private Vector3 <startScale>5__2;
private float <elapsed>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ScaleTo>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0028: 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)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
ButtonController buttonController = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<startScale>5__2 = ((Component)buttonController).transform.localScale;
<elapsed>5__3 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<elapsed>5__3 < duration)
{
<elapsed>5__3 += Time.deltaTime;
float num2 = Mathf.SmoothStep(0f, 1f, <elapsed>5__3 / duration);
((Component)buttonController).transform.localScale = Vector3.Lerp(<startScale>5__2, targetScale, num2);
<>2__current = null;
<>1__state = 1;
return true;
}
((Component)buttonController).transform.localScale = targetScale;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private Vector3 _originalScale;
private float _pressedScale = 0.9f;
private float _animationDuration = 0.1f;
private InputAction _keyAction;
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
_keyAction = new InputAction((string)null, (InputActionType)0, "<Keyboard>/f", (string)null, (string)null, (string)null);
_keyAction.performed += delegate
{
OnClick();
};
_originalScale = ((Component)this).transform.localScale;
}
private void OnEnable()
{
_keyAction.Enable();
}
private void OnDisable()
{
_keyAction.Disable();
}
private void OnDestroy()
{
_keyAction.Disable();
_keyAction.Dispose();
}
private void OnClick()
{
VoiceController.LocalInstance?.PlaySound();
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(PressAnimation());
}
[IteratorStateMachine(typeof(<PressAnimation>d__9))]
private IEnumerator PressAnimation()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PressAnimation>d__9(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<ScaleTo>d__10))]
private IEnumerator ScaleTo(Vector3 targetScale, float duration)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ScaleTo>d__10(0)
{
<>4__this = this,
targetScale = targetScale,
duration = duration
};
}
}
public class PluginCanvas : MonoBehaviour
{
[SerializeField]
private GameObject _panelObject;
public static PluginCanvas Instance { get; private set; }
public static void Spawn()
{
if (!((Object)(object)Instance != (Object)null))
{
Object.Instantiate<GameObject>(Assets.PluginCanvasPrefab);
}
}
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
((Object)((Component)this).gameObject).name = "MilkButton PluginCanvas";
Logger.LogInfo("Instantiated \"" + ((Object)((Component)this).gameObject).name + "\"", extended: true);
HidePanel();
}
public void ShowPanel()
{
if (ConfigManager.Button_Enabled.Value)
{
GameObject panelObject = _panelObject;
if (panelObject != null)
{
panelObject.SetActive(true);
}
}
}
public void HidePanel()
{
GameObject panelObject = _panelObject;
if (panelObject != null)
{
panelObject.SetActive(false);
}
}
public static void OnConfigSettingsChanged()
{
if (!ConfigManager.Button_Enabled.Value)
{
Instance?.HidePanel();
}
}
}
public class PluginNetworkHandler : NetworkBehaviour
{
public static PluginNetworkHandler Instance { get; private set; }
public static void Spawn_Server()
{
if (!((Object)(object)Instance != (Object)null))
{
GameObject val = Object.Instantiate<GameObject>(Assets.PluginNetworkHandlerPrefab);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
((Object)((Component)this).gameObject).name = "MilkButton PluginNetworkHandler";
Logger.LogInfo("Instantiated \"" + ((Object)((Component)this).gameObject).name + "\"", extended: true);
}
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
if (((NetworkBehaviour)this).IsServer)
{
((NetworkBehaviour)this).NetworkObject.Despawn(true);
}
}
else
{
Instance = this;
}
}
[ServerRpc(RequireOwnership = false)]
public void ShowPanel_ServerRpc()
{
//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)
//IL_00c1: 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(4070705722u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4070705722u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
ShowPanel_ClientRpc();
}
}
}
[ClientRpc]
private void ShowPanel_ClientRpc()
{
//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)
//IL_00c1: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(685052383u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 685052383u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
PluginCanvas.Instance?.ShowPanel();
}
}
}
[ServerRpc(RequireOwnership = false)]
public void HidePanel_ServerRpc()
{
//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)
//IL_00c1: 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(2874192403u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2874192403u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
HidePanel_ClientRpc();
}
}
}
[ClientRpc]
private void HidePanel_ClientRpc()
{
//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)
//IL_00c1: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1854803255u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1854803255u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
PluginCanvas.Instance?.HidePanel();
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(4070705722u, new RpcReceiveHandler(__rpc_handler_4070705722), "ShowPanel_ServerRpc");
((NetworkBehaviour)this).__registerRpc(685052383u, new RpcReceiveHandler(__rpc_handler_685052383), "ShowPanel_ClientRpc");
((NetworkBehaviour)this).__registerRpc(2874192403u, new RpcReceiveHandler(__rpc_handler_2874192403), "HidePanel_ServerRpc");
((NetworkBehaviour)this).__registerRpc(1854803255u, new RpcReceiveHandler(__rpc_handler_1854803255), "HidePanel_ClientRpc");
((NetworkBehaviour)this).__initializeRpcs();
}
private static void __rpc_handler_4070705722(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;
((PluginNetworkHandler)(object)target).ShowPanel_ServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_685052383(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;
((PluginNetworkHandler)(object)target).ShowPanel_ClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2874192403(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;
((PluginNetworkHandler)(object)target).HidePanel_ServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1854803255(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;
((PluginNetworkHandler)(object)target).HidePanel_ClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "PluginNetworkHandler";
}
}
public class VoiceController : NetworkBehaviour
{
private static readonly List<VoiceController> _instances = new List<VoiceController>();
[SerializeField]
private AudioSource _voiceAudio;
[SerializeField]
private AudioSource _deadAudio;
[SerializeField]
private AudioClip _sound;
private static bool _generatedPitch;
private static float _localPitch = 1f;
public static IReadOnlyList<VoiceController> Instances => _instances;
public static VoiceController LocalInstance => Instances.FirstOrDefault((VoiceController x) => x.IsLocal);
public PlayerAudioGroup PlayerAudioGroup { get; private set; }
public PlayerControllerB PlayerScript { get; private set; }
public bool IsLocal => PlayerUtils.IsLocalPlayer(PlayerScript);
public static void Spawn_Server(PlayerControllerB playerScript)
{
GameObject val = Object.Instantiate<GameObject>(Assets.VoiceControllerPrefab, ((Component)playerScript).transform);
NetworkObject val2 = default(NetworkObject);
if (val.TryGetComponent<NetworkObject>(ref val2))
{
val2.DontDestroyWithOwner = true;
val2.SpawnWithOwnership(playerScript.actualClientId, false);
val2.TrySetParent(((Component)playerScript).transform, true);
}
}
public static void Despawn_Server(PlayerControllerB playerScript)
{
VoiceController componentInChildren = ((Component)playerScript).GetComponentInChildren<VoiceController>();
NetworkObject val = default(NetworkObject);
if (!((Object)(object)componentInChildren == (Object)null) && ((Component)componentInChildren).TryGetComponent<NetworkObject>(ref val) && val.IsSpawned)
{
val.Despawn(true);
}
}
public static void OnClientConnect_Server(ulong clientId)
{
PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(clientId);
if (!((Object)(object)playerScriptByClientId == (Object)null))
{
VoiceController componentInChildren = ((Component)playerScriptByClientId).GetComponentInChildren<VoiceController>();
NetworkObject val = default(NetworkObject);
if (!((Object)(object)componentInChildren == (Object)null) && ((Component)componentInChildren).TryGetComponent<NetworkObject>(ref val) && val.IsSpawned)
{
val.ChangeOwnership(playerScriptByClientId.actualClientId);
}
}
}
private void OnEnable()
{
if (!_instances.Contains(this))
{
_instances.Add(this);
}
}
private void OnDisable()
{
_instances.Remove(this);
}
private void Awake()
{
if (!_generatedPitch)
{
_generatedPitch = true;
GenerateLocalPitch();
}
}
private void Start()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB playerScript = default(PlayerControllerB);
if ((Object)(object)((Component)this).transform.parent == (Object)null)
{
LogError("Failed to initialize. Transform parent is null.");
if (NetworkUtils.IsServer)
{
((Component)this).GetComponent<NetworkObject>().Despawn(true);
}
}
else if (!((Component)((Component)this).transform.parent).TryGetComponent<PlayerControllerB>(ref playerScript))
{
LogError("Failed to initialize. PlayerControllerB is null.");
if (NetworkUtils.IsServer)
{
((Component)this).GetComponent<NetworkObject>().Despawn(true);
}
}
else
{
PlayerScript = playerScript;
((Component)this).transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
PlayerAudioGroup = new PlayerAudioGroup(_voiceAudio, _deadAudio);
PlayerAudioGroup.Volume01 = 1f;
ApplySettings();
LogInfo("Initialized.", extended: true);
}
}
public void PlaySound()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
PlaySound_ServerRpc(_localPitch);
PlaySound_Local(_localPitch);
}
[ServerRpc]
private void PlaySound_ServerRpc(float pitch, ServerRpcParams serverRpcParams = default(ServerRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Invalid comparison between Unknown and I4
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
return;
}
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3947782144u, serverRpcParams, (RpcDelivery)0);
((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref pitch, default(ForPrimitives));
((NetworkBehaviour)this).__endSendServerRpc(ref val, 3947782144u, serverRpcParams, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
ulong senderClientId = serverRpcParams.Receive.SenderClientId;
if (((NetworkBehaviour)this).NetworkManager.ConnectedClients.ContainsKey(senderClientId))
{
PlaySound_ClientRpc(senderClientId, pitch);
}
}
}
[ClientRpc]
private void PlaySound_ClientRpc(ulong senderClientId, float pitch)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_008a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2296604842u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, senderClientId);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref pitch, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2296604842u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
if (!NetworkUtils.IsLocalClientId(senderClientId))
{
PlaySound_Local(pitch);
}
}
}
private void PlaySound_Local(float pitch)
{
if (PlayerAudioGroup != null && !((Object)(object)_sound == (Object)null))
{
UpdateVoiceMute();
PlayerAudioGroup.Pitch = pitch;
PlayerAudioGroup.PlayOneShot(_sound);
MakeNoiseForEnemies();
}
}
private void UpdateVoiceMute()
{
if ((Object)(object)PlayerScript == (Object)null || PlayerAudioGroup == null)
{
return;
}
if (IsLocal)
{
PlayerAudioGroup.VoiceAudio.mute = PlayerScript.isPlayerDead;
PlayerAudioGroup.DeadAudio.mute = !PlayerScript.isPlayerDead;
return;
}
PlayerAudioGroup.VoiceAudio.mute = PlayerScript.isPlayerDead;
PlayerControllerB localPlayerScript = PlayerUtils.LocalPlayerScript;
if ((Object)(object)localPlayerScript == (Object)null || !localPlayerScript.isPlayerDead)
{
PlayerAudioGroup.DeadAudio.mute = true;
}
else
{
PlayerAudioGroup.DeadAudio.mute = !PlayerScript.isPlayerDead;
}
}
private void MakeNoiseForEnemies()
{
//IL_000b: 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)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)PlayerScript).transform.position;
float num = 30f;
float num2 = 0.7f;
RoundManager.Instance.PlayAudibleNoise(position, num, num2, 0, PlayerScript.isInHangarShipRoom && StartOfRound.Instance.hangarDoorsClosed, 75);
}
private void ApplySettings()
{
if (PlayerAudioGroup != null)
{
UpdateVoiceMute();
PlayerAudioGroup.Volume01 = (float)ConfigManager.Voice_Volume.Value * 0.01f;
}
}
public static void GenerateLocalPitch()
{
if (ConfigManager.Voice_RandomizePitch.Value)
{
float value = ConfigManager.Voice_PitchMin.Value;
float value2 = ConfigManager.Voice_PitchMax.Value;
_localPitch = Random.Range(value, value2);
LocalInstance?.LogInfo($"Set voice pitch to {_localPitch}");
}
}
public static void OnConfigSettingsChanged()
{
foreach (VoiceController instance in _instances)
{
instance.ApplySettings();
}
}
private void LogInfo(object data, bool extended = false)
{
Log((LogLevel)16, data, extended);
}
private void LogWarning(object data, bool extended = false)
{
Log((LogLevel)4, data, extended);
}
private void LogError(object data, bool extended = false)
{
Log((LogLevel)2, data, extended);
}
private void Log(LogLevel logLevel, object data, bool extended = false)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
string arg = (((Object)(object)PlayerScript == (Object)null) ? ("[" + ((object)this).GetType().Name + "]") : ("[" + ((object)this).GetType().Name + " : " + PlayerScript.playerUsername + "]"));
Logger.Log(logLevel, $"{arg} {data}", extended);
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(3947782144u, new RpcReceiveHandler(__rpc_handler_3947782144), "PlaySound_ServerRpc");
((NetworkBehaviour)this).__registerRpc(2296604842u, new RpcReceiveHandler(__rpc_handler_2296604842), "PlaySound_ClientRpc");
((NetworkBehaviour)this).__initializeRpcs();
}
private static void __rpc_handler_3947782144(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
NetworkManager networkManager = target.NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
}
else
{
float pitch = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref pitch, default(ForPrimitives));
ServerRpcParams server = rpcParams.Server;
target.__rpc_exec_stage = (__RpcExecStage)1;
((VoiceController)(object)target).PlaySound_ServerRpc(pitch, server);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2296604842(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong senderClientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref senderClientId);
float pitch = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref pitch, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)1;
((VoiceController)(object)target).PlaySound_ClientRpc(senderClientId, pitch);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "VoiceController";
}
}
}
namespace com.github.zehsteam.MilkButton.Managers
{
internal static class ConfigManager
{
public static ConfigFile ConfigFile { get; private set; }
public static ConfigEntry<bool> Button_Enabled { get; private set; }
public static ConfigEntry<float> Button_ActivateChance { get; private set; }
public static ConfigEntry<bool> Button_ActivateFromHost { get; private set; }
public static ConfigEntry<bool> Button_ActivateFromEveryone { get; private set; }
public static ConfigEntry<string> Button_ActivateFromPlayers { get; private set; }
public static IEnumerable<string> Button_ActivateFromPlayers_Collection => Button_ActivateFromPlayers.Value.ToLower().StringToCollection<string>();
public static ConfigEntry<int> Voice_Volume { get; private set; }
public static ConfigEntry<bool> Voice_RandomizePitch { get; private set; }
public static ConfigEntry<float> Voice_PitchMin { get; private set; }
public static ConfigEntry<float> Voice_PitchMax { get; private set; }
public static ConfigEntry<bool> Misc_ExtendedLogging { get; private set; }
public static void Initialize(ConfigFile configFile)
{
ConfigFile = configFile;
BindConfigs();
}
private static void BindConfigs()
{
ConfigHelper.SkipAutoGen();
Button_Enabled = ConfigHelper.Bind("Button", "Enabled", defaultValue: true, "If enabled, the milk button will be able to appear and activate from you if allowed.");
Button_ActivateChance = ConfigHelper.Bind("Button", "ActivateChance", 30f, "The chance for the milk button to appear after you die if activation is allowed from you.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f));
Button_ActivateFromHost = ConfigHelper.Bind("Button", "ActivateFromHost", defaultValue: true, "If enabled, will allow the host to make the milk button appear after they die.");
Button_ActivateFromEveryone = ConfigHelper.Bind("Button", "ActivateFromEveryone", defaultValue: false, "If enabled, will allow anyone to make the milk button appear after they die.");
Button_ActivateFromPlayers = ConfigHelper.Bind("Button", "ActivateFromPlayers", "Insym, CritHaxXoG", "List of player Steam names separated by a comma.\nWill allow anyone on the list to make the milk button appear after they die.");
Button_Enabled.SettingChanged += delegate
{
PluginCanvas.OnConfigSettingsChanged();
};
ConfigHelper.AddButton("Button", "Show Button For You", "Show", "Will show the milk button for only you.", delegate
{
PluginCanvas.Instance?.ShowPanel();
});
ConfigHelper.AddButton("Button", "Hide Button For You", "Hide", "Will hide the milk button for only you.", delegate
{
PluginCanvas.Instance?.HidePanel();
});
ConfigHelper.AddButton("Button", "Show Button For Everyone", "Show", "Will show the milk button for everyone.", delegate
{
PluginNetworkHandler.Instance?.ShowPanel_ServerRpc();
});
ConfigHelper.AddButton("Button", "Hide Button For Everyone", "Hide", "Will hide the milk button for everyone.", delegate
{
PluginNetworkHandler.Instance?.HidePanel_ServerRpc();
});
Voice_Volume = ConfigHelper.Bind("Voice", "Volume", 100, "The volume of your voice from pressing the milk button.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
Voice_RandomizePitch = ConfigHelper.Bind("Voice", "RandomizePitch", defaultValue: true, "If enabled, will set a random pitch to your voice based on the min/max pitch values.");
Voice_PitchMin = ConfigHelper.Bind("Voice", "PitchMin", 0.9f, "The minimum value your voice pitch can be.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.7f, 1.3f));
Voice_PitchMax = ConfigHelper.Bind("Voice", "PitchMax", 1.1f, "The maximum value your voice pitch can be.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.7f, 1.3f));
Voice_Volume.SettingChanged += delegate
{
VoiceController.OnConfigSettingsChanged();
};
ConfigHelper.AddButton("Voice", "Regenerate Voice Pitch", "Regenerate", "Will regenerate your voice's pitch.", delegate
{
VoiceController.GenerateLocalPitch();
});
Misc_ExtendedLogging = ConfigHelper.Bind("Misc", "ExtendedLogging", defaultValue: false, "Enable extended logging.");
}
}
}
namespace com.github.zehsteam.MilkButton.Helpers
{
internal static class ConfigHelper
{
public static void SkipAutoGen()
{
if (LethalConfigProxy.IsInstalled)
{
LethalConfigProxy.SkipAutoGen();
}
}
public static void AddButton(string section, string name, string buttonText, string description, Action callback)
{
if (LethalConfigProxy.IsInstalled)
{
LethalConfigProxy.AddButton(section, name, buttonText, description, callback);
}
}
public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description, bool requiresRestart = false, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null)
{
if (configFile == null)
{
configFile = ConfigManager.ConfigFile;
}
ConfigEntry<T> configEntry = configFile.Bind(section, key, defaultValue, description, acceptableValues);
if (settingChanged != null)
{
configEntry.SettingChanged += delegate
{
settingChanged?.Invoke(configEntry.Value);
};
}
if (LethalConfigProxy.IsInstalled)
{
LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart);
}
return configEntry;
}
}
internal static class NetworkUtils
{
public static bool IsConnected
{
get
{
NetworkManager singleton = NetworkManager.Singleton;
if (singleton == null)
{
return false;
}
return singleton.IsConnectedClient;
}
}
public static bool IsServer
{
get
{
NetworkManager singleton = NetworkManager.Singleton;
if (singleton == null)
{
return false;
}
return singleton.IsServer;
}
}
public static ulong LocalClientId
{
get
{
NetworkManager singleton = NetworkManager.Singleton;
if (singleton == null)
{
return 0uL;
}
return singleton.LocalClientId;
}
}
public static int ConnectedPlayerCount => GameNetworkManager.Instance?.connectedPlayers ?? 0;
public static bool IsLocalClientId(ulong clientId)
{
return clientId == LocalClientId;
}
public static bool IsNetworkPrefab(GameObject prefab)
{
IReadOnlyList<NetworkPrefab> prefabs = NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs;
return prefabs.Any((NetworkPrefab x) => (Object)(object)x.Prefab == (Object)(object)prefab);
}
public static bool AddNetworkPrefab(GameObject prefab)
{
if ((Object)(object)prefab == (Object)null)
{
Logger.LogError("Failed to register network prefab. GameObject is null.");
return false;
}
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
Logger.LogError("Failed to register network prefab. NetworkManager Singleton is null.");
return false;
}
NetworkManager.Singleton.AddNetworkPrefab(prefab);
Logger.LogInfo("Registered \"" + ((Object)prefab).name + "\" network prefab.");
return true;
}
public static void NetcodePatcherAwake()
{
try
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Type[] types = executingAssembly.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)
{
try
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
try
{
methodInfo.Invoke(null, null);
}
catch (TargetInvocationException ex)
{
Logger.LogWarning("Failed to invoke method " + methodInfo.Name + ": " + ex.Message);
}
}
}
catch (Exception ex2)
{
Logger.LogWarning("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message);
}
}
}
}
catch (Exception ex3)
{
Logger.LogError("An error occurred in NetcodePatcherAwake: " + ex3.Message);
}
}
}
internal static class PlayerIdentityUtils
{
public static PlayerIdentity InsymIdentity = new PlayerIdentity("Insym", 76561198008109303uL);
public static bool IsPlayer(PlayerControllerB playerScript, PlayerIdentity identity)
{
if ((Object)(object)playerScript == (Object)null)
{
return false;
}
if (playerScript.playerUsername.Equals(identity.Username, StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (playerScript.playerSteamId == identity.SteamId)
{
return true;
}
return false;
}
public static bool IsLocalPlayer(PlayerIdentity identity)
{
return IsPlayer(PlayerUtils.LocalPlayerScript, identity);
}
public static bool TryGetPlayer(PlayerIdentity identity, out PlayerControllerB playerScript)
{
playerScript = ((IEnumerable<PlayerControllerB>)PlayerUtils.PlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => IsPlayer(x, identity)));
return (Object)(object)playerScript != (Object)null;
}
public static bool HasPlayer(PlayerIdentity identity)
{
PlayerControllerB playerScript;
return TryGetPlayer(identity, out playerScript);
}
}
public struct PlayerIdentity
{
public string Username { get; set; }
public ulong SteamId { get; set; }
public PlayerIdentity(string username, ulong steamId)
{
Username = username;
SteamId = steamId;
}
}
internal static class PlayerUtils
{
public static PlayerControllerB LocalPlayerScript => GameNetworkManager.Instance?.localPlayerController ?? null;
public static PlayerControllerB[] PlayerScripts => StartOfRound.Instance?.allPlayerScripts ?? Array.Empty<PlayerControllerB>();
public static bool IsLocalPlayer(PlayerControllerB playerScript)
{
return (Object)(object)playerScript == (Object)(object)LocalPlayerScript;
}
public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId)
{
return ((IEnumerable<PlayerControllerB>)PlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB playerScript) => playerScript.actualClientId == clientId));
}
public static PlayerControllerB GetPlayerScriptByPlayerId(int playerId)
{
if (playerId < 0 || playerId > PlayerScripts.Length - 1)
{
return null;
}
return PlayerScripts[playerId];
}
}
internal static class Utils
{
public static bool RollPercentChance(float percent)
{
if (percent <= 0f)
{
return false;
}
if (percent >= 100f)
{
return true;
}
return Random.value * 100f <= percent;
}
}
}
namespace com.github.zehsteam.MilkButton.Extensions
{
internal static class CollectionExtensions
{
public static IEnumerable<T> StringToCollection<T>(this string s, string separator = ",")
{
if (string.IsNullOrEmpty(s))
{
return Array.Empty<T>();
}
T result;
return from x in s.Split(separator, StringSplitOptions.RemoveEmptyEntries)
where !string.IsNullOrWhiteSpace(x)
select x.Trim() into x
select (!x.TryConvertTo<T>(out result)) ? default(T) : result into x
where x != null
select x;
}
public static string CollectionToString<T>(this IEnumerable<T> value, string separator = ", ")
{
if (value == null || !value.Any())
{
return string.Empty;
}
return string.Join(separator, from x in value
where x != null && !string.IsNullOrWhiteSpace(x.ToString())
select x.ToString().Trim());
}
}
internal static class ConfigFileExtensions
{
public static ConfigEntry<T> Bind<T>(this ConfigFile configFile, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
if (acceptableValues == null)
{
return configFile.Bind<T>(section, key, defaultValue, description);
}
return configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>()));
}
}
internal static class StringExtensions
{
public static T ConvertTo<T>(this string s)
{
Type typeFromHandle = typeof(T);
if ((object)typeFromHandle != null)
{
Type type = typeFromHandle;
object obj;
if (type == typeof(int) && int.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
{
obj = result;
}
else
{
Type type2 = typeFromHandle;
if (type2 == typeof(float) && float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2))
{
obj = result2;
}
else
{
Type type3 = typeFromHandle;
if (type3 == typeof(double) && double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
{
obj = result3;
}
else
{
Type type4 = typeFromHandle;
if (type4 == typeof(bool) && bool.TryParse(s, out var result4))
{
obj = result4;
}
else
{
Type type5 = typeFromHandle;
if (type5 == typeof(string))
{
obj = s;
}
else
{
Type type6 = typeFromHandle;
if (!type6.IsEnum || !Enum.TryParse(type6, s, ignoreCase: true, out object result5))
{
goto IL_0121;
}
obj = result5;
}
}
}
}
}
object obj2 = obj;
return (T)obj2;
}
goto IL_0121;
IL_0121:
throw new NotSupportedException($"Unsupported value type: {typeof(T)}");
}
public static bool TryConvertTo<T>(this string s, out T result)
{
try
{
result = s.ConvertTo<T>();
return true;
}
catch
{
result = default(T);
return false;
}
}
public static bool IsHexColor(this string value)
{
return Regex.IsMatch(value, "^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$");
}
}
}
namespace com.github.zehsteam.MilkButton.Dependencies.LethalConfigMod
{
internal static class LethalConfigProxy
{
public const string PLUGIN_GUID = "ainavt.lc.lethalconfig";
public static bool IsInstalled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void SkipAutoGen()
{
LethalConfigManager.SkipAutoGen();
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static BaseConfigItem AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
if (typeof(T).IsEnum)
{
MethodInfo methodInfo = AccessTools.Method(typeof(LethalConfigProxy), "AddEnumDropdown", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = methodInfo.MakeGenericMethod(typeof(T));
object? obj = methodInfo2.Invoke(null, new object[2] { configEntry, requiresRestart });
return (BaseConfigItem)((obj is BaseConfigItem) ? obj : null);
}
AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
if (acceptableValues != null)
{
if (acceptableValues is AcceptableValueRange<float> || acceptableValues is AcceptableValueRange<int>)
{
return AddConfigSlider<T>(configEntry, requiresRestart);
}
if (acceptableValues is AcceptableValueList<string>)
{
return AddConfigDropdown<T>(configEntry, requiresRestart);
}
}
if (configEntry is ConfigEntry<string> val && IsConfigEntryForHexColor(val))
{
return AddConfigItem((BaseConfigItem)new HexColorInputFieldConfigItem(val, requiresRestart));
}
if (!(configEntry is ConfigEntry<int> val2))
{
if (!(configEntry is ConfigEntry<float> val3))
{
if (!(configEntry is ConfigEntry<bool> val4))
{
if (configEntry is ConfigEntry<string> val5)
{
return AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val5, requiresRestart));
}
throw new NotSupportedException($"Unsupported type: {typeof(T)}");
}
return AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val4, requiresRestart));
}
return AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart));
}
return AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val2, requiresRestart));
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static BaseConfigItem AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
if (!(configEntry is ConfigEntry<float> val))
{
if (configEntry is ConfigEntry<int> val2)
{
return AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart));
}
throw new NotSupportedException($"Slider not supported for type: {typeof(T)}");
}
return AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart));
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static BaseConfigItem AddConfigDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
if (configEntry is ConfigEntry<string> val)
{
return AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart));
}
throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}");
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static BaseConfigItem AddEnumDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) where T : Enum
{
return AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<T>(configEntry, requiresRestart));
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static BaseConfigItem AddButton(string section, string name, string buttonText, string description, Action callback)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
BaseConfigItem configItem = (BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate
{
callback?.Invoke();
});
return AddConfigItem(configItem);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static bool IsConfigEntryForHexColor(ConfigEntry<string> configEntry)
{
if (!(((ConfigEntryBase)configEntry).DefaultValue is string value))
{
return false;
}
return value.IsHexColor();
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static BaseConfigItem AddConfigItem(BaseConfigItem configItem)
{
LethalConfigManager.AddConfigItem(configItem);
return configItem;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace __GEN
{
internal class NetworkVariableSerializationHelper
{
[RuntimeInitializeOnLoadMethod]
internal static void InitializeSerialization()
{
}
}
}
namespace com.github.zehsteam.MilkButton.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}