using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using FishNet;
using FixedForBetter;
using HarmonyLib;
using HeathenEngineering.SteamworksIntegration;
using HeathenEngineering.SteamworksIntegration.UI;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FixedForBetter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FixedForBetter")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("77f1e5fe-3fd4-4573-9423-ee9467b6884f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Combined
{
public class Text
{
}
}
namespace Server
{
[HarmonyPatch]
public class Text
{
}
}
namespace Client
{
[HarmonyPatch]
public class InteractionPatch
{
private static string currentMap = "";
[HarmonyPatch(typeof(PlayerPickup), "PlayerGrab")]
[HarmonyPostfix]
private static void BodyGrabbing(object __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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)
Scene activeScene = SceneManager.GetActiveScene();
currentMap = ((Scene)(ref activeScene)).name;
if (global::FixedForBetter.FixedForBetter.BodyGrabbing.Value && !(currentMap == "VictoryScene"))
{
Traverse.Create(__instance).Field("ragdollInteractionLayer").SetValue((object)LayerMask.op_Implicit(0));
global::FixedForBetter.FixedForBetter.Log("BodyGrabbing: Value set");
}
}
}
[HarmonyPatch]
public class ProximityMinePatch
{
[HarmonyPatch(typeof(ProximityMine), "OnTriggerStay")]
[HarmonyPostfix]
private static void NearbyPlayerDetected(ProximityMine __instance)
{
Traverse val = Traverse.Create((object)__instance);
float value = val.Field("bipTimer").GetValue<float>();
AudioClip value2 = val.Field("bipClip").GetValue<AudioClip>();
if (value < 0.1f)
{
Traverse.Create((object)__instance).Field("bipTimer").SetValue((object)(global::FixedForBetter.FixedForBetter.ProximityMineDelay.Value + 0.1f));
SoundManager.Instance._effectsSource.PlayOneShot(value2, global::FixedForBetter.FixedForBetter.ProximityMineVolume.Value);
global::FixedForBetter.FixedForBetter.Log($"NearbyPlayerDetected: Audio delayed (At: '{value}')");
}
}
}
[HarmonyPatch]
public class FriendsListPatch
{
[HarmonyPatch(typeof(FriendList), "HandleStateChange")]
[HarmonyPrefix]
private static bool HideSelf(PersonaStateChange arg0)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
if (((PersonaStateChange)(ref arg0)).SubjectId == UserData.Me && global::FixedForBetter.FixedForBetter.FriendsListHideSelf.Value)
{
global::FixedForBetter.FixedForBetter.Log("HideSelf: Triggered");
return false;
}
return true;
}
}
[HarmonyPatch]
public class MainMenuUIPatch
{
private static readonly List<(TextMeshProUGUI textMesh, Func<string> text, ButtonSizeTween buttonScript, Func<string> hoverText, Func<bool> hide)> clonedDisplayUIs = new List<(TextMeshProUGUI, Func<string>, ButtonSizeTween, Func<string>, Func<bool>)>();
[HarmonyPatch(typeof(FirstToWinsText), "Update")]
[HarmonyPostfix]
private static void DisplayHostSettings(FirstToWinsText __instance)
{
bool flag = (bool)AccessTools.Field(typeof(FirstToWinsText), "onEndRoundScreen").GetValue(__instance);
bool flag2 = clonedDisplayUIs.Count <= 0;
if ((Object)(object)SceneMotor.Instance == (Object)null || (Object)(object)GameManager.Instance == (Object)null || (Object)(object)SpawnerManager.Instance == (Object)null || flag || !global::FixedForBetter.FixedForBetter.DisplayHostSettings.Value)
{
return;
}
if (InstanceFinder.NetworkManager.IsServer)
{
foreach (var clonedDisplayUI in clonedDisplayUIs)
{
if (((UIBehaviour)clonedDisplayUI.textMesh).IsActive())
{
((Component)((TMP_Text)clonedDisplayUI.textMesh).transform.parent).gameObject.SetActive(false);
global::FixedForBetter.FixedForBetter.Log($"DisplayHostSettings: Disabled {clonedDisplayUI.text}");
}
}
return;
}
if (flag2)
{
DisplayUIs(__instance);
global::FixedForBetter.FixedForBetter.Log("DisplayHostSettings: Called rebuild");
}
foreach (var clonedDisplayUI2 in clonedDisplayUIs)
{
((TMP_Text)clonedDisplayUI2.textMesh).text = clonedDisplayUI2.text();
AccessTools.Field(typeof(ButtonSizeTween), "customText").SetValue(clonedDisplayUI2.buttonScript, clonedDisplayUI2.hoverText());
bool flag3 = clonedDisplayUI2.hide();
((Component)((TMP_Text)clonedDisplayUI2.textMesh).transform.parent).gameObject.SetActive(!flag3);
}
}
private static void DisplayUIs(FirstToWinsText originalDisplayUI)
{
CloneUI(originalDisplayUI, 1, () => "Team Damage " + (GameManager.Instance.FriendlyFireEnabled ? "On" : "Off"), () => (GameManager.Instance.FriendlyFireEnabled ? "Killing your own team is possible but not reccomended" : "Most types of damage or interaction with your team are disabled") ?? "");
CloneUI(originalDisplayUI, 2, () => "Outlines " + (GameManager.Instance.EnemyOutlinesEnabled ? "On" : "Off"), () => (GameManager.Instance.EnemyOutlinesEnabled ? "Players on the opposing team will have a visble outline" : "Only teammates will have an outline") ?? "");
CloneUI(originalDisplayUI, 3, () => "Random Weapons " + (SpawnerManager.Instance.randomiseWeapons ? "On" : "Off"), () => (SpawnerManager.Instance.randomiseWeapons ? "Each map will have randomized spawners based on the host's preferences" : "Every map will have a single value for the spawners") ?? "", delegate
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
CSteamID val = default(CSteamID);
((CSteamID)(ref val))..ctor(SteamLobby.Instance.CurrentLobbyID);
string lobbyData = SteamMatchmaking.GetLobbyData(val, "ownDlc0");
return !string.IsNullOrEmpty(lobbyData) && lobbyData == "False";
});
}
private static void CloneUI(FirstToWinsText originalDisplayUI, int slot, Func<string> text, Func<string> hoverText, Func<bool> hide = null)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(((Component)originalDisplayUI).gameObject, ((Component)originalDisplayUI).transform.parent);
Object.Destroy((Object)(object)val.GetComponent<FirstToWinsText>());
val.transform.localPosition = ((Component)originalDisplayUI).transform.localPosition + new Vector3(0f, 70f * (float)slot, 0f);
TextMeshProUGUI componentInChildren = val.GetComponentInChildren<TextMeshProUGUI>();
((TMP_Text)componentInChildren).text = text();
ButtonSizeTween component = val.GetComponent<ButtonSizeTween>();
AccessTools.Field(typeof(ButtonSizeTween), "customText").SetValue(component, hoverText());
AccessTools.Field(typeof(ButtonSizeTween), "targetScale").SetValue(component, Vector3.one);
clonedDisplayUIs.Add((componentInChildren, text, component, hoverText, hide ?? ((Func<bool>)(() => false))));
}
}
}
namespace FixedForBetter
{
[BepInPlugin("bubba.fixedforbetter", "FixedForBetter", "1.1.0")]
public class FixedForBetter : BaseUnityPlugin
{
public static FixedForBetter Instance;
public static ConfigEntry<bool> Logging;
public static ConfigEntry<bool> BodyGrabbing;
public static ConfigEntry<float> ProximityMineDelay;
public static ConfigEntry<float> ProximityMineVolume;
public static ConfigEntry<bool> FriendsListHideSelf;
public static ConfigEntry<bool> DisplayHostSettings;
private void Awake()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Expected O, but got Unknown
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
Logging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Logging", false, new ConfigDescription("Should logging be enabled?", (AcceptableValueBase)null, Array.Empty<object>()));
BodyGrabbing = ((BaseUnityPlugin)this).Config.Bind<bool>("Client - Toggle", "Body Grabbing", true, new ConfigDescription("Should body grabbing be disabled?", (AcceptableValueBase)null, Array.Empty<object>()));
FriendsListHideSelf = ((BaseUnityPlugin)this).Config.Bind<bool>("Client - Toggle", "Friends List Hide Self", true, new ConfigDescription("Should you be hidden on the friends list? (This bug occurs when leaving a server after a match)", (AcceptableValueBase)null, Array.Empty<object>()));
DisplayHostSettings = ((BaseUnityPlugin)this).Config.Bind<bool>("Client - Toggle", "Display Host Settings", true, new ConfigDescription("Should the host's settings be displayed while on the main menu?", (AcceptableValueBase)null, Array.Empty<object>()));
ProximityMineDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Client - Proximity Mine", "Proximity Mine Delay", 0.2f, new ConfigDescription("How long until proximity mines can play another audio clip when a player is detected? (Vanilla: '0.006f')", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
ProximityMineVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Client - Proximity Mine", "Proximity Mine Volume", 0.5f, new ConfigDescription("How loud should proximity mines be when a player is detected?", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
Log($"Using configs: (Logging {Logging.Value}) (BodyGrabbing {BodyGrabbing.Value}) (ProximityMineDelay {ProximityMineDelay.Value}) (ProximityMineVolume {ProximityMineVolume.Value}) (FriendsListHideSelf {FriendsListHideSelf.Value}) (DisplayHostSettings {DisplayHostSettings.Value})");
new Harmony("bubba.fixedforbetter").PatchAll();
}
public static void Log(string message)
{
if (Logging.Value)
{
Debug.Log((object)("[FFB] " + message));
}
}
}
}