using System;
using System.Collections.Generic;
using System.Diagnostics;
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 HarmonyLib;
using Reptile;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("BetterToilet")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterToilet")]
[assembly: AssemblyTitle("BetterToilet")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BetterToilet;
[BepInPlugin("org.lazyduchess.plugins.brc.bettertoilet", "Better Toilet", "1.0.1.0")]
[BepInProcess("Bomb Rush Cyberfunk.exe")]
public class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
public ConfigEntry<bool> OpenToiletsUsedWhileWanted;
private ToiletController _toiletController;
public ManualLogSource GetLogger()
{
return ((BaseUnityPlugin)this).Logger;
}
private void Awake()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
OpenToiletsUsedWhileWanted = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OpenToiletsUsedWhileWanted", false, "Whether to also keep toilets that were used with a heat level open.");
Instance = this;
try
{
new Harmony("org.lazyduchess.plugins.brc.bettertoilet").PatchAll();
_toiletController = new ToiletController();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Better Toilet plugin.");
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Problem loading Better Toilet plugin: {arg}");
}
}
private void Update()
{
_toiletController.Update();
}
}
public class ToiletController
{
public static ToiletController Instance;
private const float HorizontalDistanceToOpenToilets = 2f;
private const float VerticalDistanceToOpenToilets = 5f;
private HashSet<PublicToilet> _toiletsToOpenOncePlayerIsFarAwayEnough = new HashSet<PublicToilet>();
public ToiletController()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
if (Instance == null)
{
Instance = this;
StageManager.OnStageInitialized += new OnStageInitializedDelegate(StageManager_OnStageInitialized);
}
}
private void StageManager_OnStageInitialized()
{
_toiletsToOpenOncePlayerIsFarAwayEnough.Clear();
}
private void OpenToilet(PublicToilet toilet)
{
MethodInfo method = typeof(PublicToilet).GetMethod("OpenDoor", BindingFlags.Instance | BindingFlags.NonPublic);
object[] parameters = new object[1] { false };
method.Invoke(toilet, parameters);
}
public void Update()
{
//IL_0060: 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)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
WorldHandler instance = WorldHandler.instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
Player currentPlayer = instance.GetCurrentPlayer();
if ((Object)(object)currentPlayer == (Object)null)
{
return;
}
foreach (PublicToilet item in new HashSet<PublicToilet>(_toiletsToOpenOncePlayerIsFarAwayEnough))
{
if ((Object)(object)item == (Object)null)
{
_toiletsToOpenOncePlayerIsFarAwayEnough.Remove(item);
continue;
}
float num = Mathf.Abs(((Component)item).transform.position.y - ((Component)currentPlayer).transform.position.y);
if (Vector3.Distance(new Vector3(((Component)item).transform.position.x, ((Component)currentPlayer).transform.position.y, ((Component)item).transform.position.z), ((Component)currentPlayer).transform.position) >= 2f || num >= 5f)
{
OpenToilet(item);
_toiletsToOpenOncePlayerIsFarAwayEnough.Remove(item);
}
}
}
public void OpenToiletOncePlayerIsFarAwayEnough(PublicToilet toilet)
{
if (!_toiletsToOpenOncePlayerIsFarAwayEnough.Contains(toilet))
{
_toiletsToOpenOncePlayerIsFarAwayEnough.Add(toilet);
}
}
}
[HarmonyPatch(typeof(PublicToilet))]
public class ToiletPatch
{
[HarmonyPostfix]
[HarmonyPatch("DoSequence")]
public static void DoSequence_Postfix(PublicToilet __instance)
{
if (Plugin.Instance.OpenToiletsUsedWhileWanted.Value)
{
ToiletController.Instance.OpenToiletOncePlayerIsFarAwayEnough(__instance);
}
else if (!WantedManager.instance.Wanted)
{
ToiletController.Instance.OpenToiletOncePlayerIsFarAwayEnough(__instance);
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BetterToilet";
public const string PLUGIN_NAME = "BetterToilet";
public const string PLUGIN_VERSION = "1.0.0";
}