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 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("JunkDisposal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JunkDisposal")]
[assembly: AssemblyTitle("JunkDisposal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace JunkDisposal
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "JunkDisposal";
public const string PLUGIN_NAME = "JunkDisposal";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace SmootherTraversal
{
internal class JunkDisposalSettings
{
private static ConfigEntry<bool> _removeJunk;
private static ConfigEntry<bool> _removeGroundPoles;
private static ConfigEntry<bool> _lightObstacles;
private static ConfigEntry<bool> _removeCars;
private static ConfigEntry<bool> _removePeople;
public static bool RemoveJunk => _removeJunk.Value;
public static bool RemoveGroundPoles => _removeGroundPoles.Value;
public static bool LightObstacles => _lightObstacles.Value;
public static bool RemoveCars => _removeCars.Value;
public static bool RemovePeople => _removePeople.Value;
public static void Initialize(ConfigFile config)
{
_removeJunk = config.Bind<bool>("General", "RemoveJunk", false, "Removes physics props from levels that can get in the way.");
_removeGroundPoles = config.Bind<bool>("General", "RemoveGroundPoles", true, "Removes static small bits or poles on the ground that can stop you in your tracks if you hit them.");
_lightObstacles = config.Bind<bool>("General", "LightObstacles", true, "Makes it possible to hit props without losing speed.");
_removeCars = config.Bind<bool>("General", "RemoveCars", false, "Removes all cars from levels.");
_removePeople = config.Bind<bool>("General", "RemovePeople", false, "Removes all people walking around in levels.");
}
}
internal class JunkRemover
{
private List<GameObject> _forceDisable = new List<GameObject>();
public JunkRemover()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
StageManager.OnStagePostInitialization += new OnStageInitializedDelegate(StageManager_OnStagePostInitialization);
}
public void OnUpdate()
{
foreach (GameObject item in _forceDisable)
{
if (!((Object)(object)item == (Object)null) && item.activeSelf)
{
item.SetActive(false);
}
}
}
private void StageManager_OnStagePostInitialization()
{
_forceDisable.Clear();
Transform[] array = Object.FindObjectsOfType<Transform>(true);
foreach (Transform val in array)
{
if (JunkDisposalSettings.RemoveGroundPoles && (((Object)((Component)val).gameObject).name.ToLowerInvariant().StartsWith("groundpole") || ((Object)((Component)val).gameObject).name.ToLowerInvariant().StartsWith("firehydrant")))
{
Object.Destroy((Object)(object)((Component)val).gameObject);
continue;
}
if (JunkDisposalSettings.RemoveJunk && ((Component)val).gameObject.layer == 21)
{
_forceDisable.Add(((Component)val).gameObject);
((Component)val).gameObject.SetActive(false);
continue;
}
if (JunkDisposalSettings.RemovePeople)
{
StreetLifeCluster component = ((Component)val).gameObject.GetComponent<StreetLifeCluster>();
if (Object.op_Implicit((Object)(object)component))
{
_forceDisable.Add(((Component)val).gameObject);
((Component)component).gameObject.SetActive(false);
continue;
}
}
if (JunkDisposalSettings.LightObstacles && ((Component)val).gameObject.layer == 21)
{
Rigidbody component2 = ((Component)val).gameObject.GetComponent<Rigidbody>();
if (Object.op_Implicit((Object)(object)component2))
{
component2.isKinematic = false;
}
}
if (JunkDisposalSettings.RemoveCars && Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<Car>()))
{
_forceDisable.Add(((Component)val).gameObject);
((Component)val).gameObject.SetActive(false);
}
}
}
}
[BepInPlugin("com.LazyDuchess.BRC.JunkDisposal", "Junk Disposal", "1.0.0")]
internal class Plugin : BaseUnityPlugin
{
private const string GUID = "com.LazyDuchess.BRC.JunkDisposal";
private const string Name = "Junk Disposal";
private const string Version = "1.0.0";
private JunkRemover _junkRemover;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
JunkDisposalSettings.Initialize(((BaseUnityPlugin)this).Config);
new Harmony("com.LazyDuchess.BRC.JunkDisposal").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Junk Disposal 1.0.0 loaded!");
_junkRemover = new JunkRemover();
}
private void Update()
{
_junkRemover.OnUpdate();
}
}
}
namespace SmootherTraversal.Patches
{
[HarmonyPatch(typeof(BasicEnemy))]
internal static class BasicEnemyPatch
{
[HarmonyPostfix]
[HarmonyPatch("Setup")]
private static void Init(BasicEnemy __instance)
{
if (JunkDisposalSettings.LightObstacles)
{
Rigidbody[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Rigidbody>();
foreach (Rigidbody obj in componentsInChildren)
{
obj.mass *= 2000f;
}
}
}
}
[HarmonyPatch(typeof(JunkBehaviour))]
internal class JunkBehaviourPatch
{
[HarmonyPostfix]
[HarmonyPatch("RestoreSingle")]
private static void RestoreSingle_Postfix(Junk junk)
{
if (JunkDisposalSettings.LightObstacles)
{
Rigidbody component = ((Component)junk).GetComponent<Rigidbody>();
if (Object.op_Implicit((Object)(object)component))
{
component.isKinematic = false;
}
}
}
}
[HarmonyPatch(typeof(Junk))]
internal class JunkPatch
{
[HarmonyPostfix]
[HarmonyPatch("Init")]
private static void Init_Postfix(Junk __instance)
{
if (JunkDisposalSettings.LightObstacles)
{
Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>();
if (Object.op_Implicit((Object)(object)component))
{
component.isKinematic = false;
}
}
}
}
[HarmonyPatch(typeof(Player))]
internal class PlayerPatch
{
[HarmonyPostfix]
[HarmonyPatch("Init")]
private static void Init_Postfix(Player __instance)
{
if (JunkDisposalSettings.LightObstacles)
{
__instance.motor._rigidbody.mass = 2000f;
}
}
[HarmonyPrefix]
[HarmonyPatch("OnCollisionEnter")]
private static void OnCollisionEnter_Prefix(Player __instance, Collision other)
{
if (JunkDisposalSettings.LightObstacles)
{
Junk component = ((Component)other.transform).GetComponent<Junk>();
if (Object.op_Implicit((Object)(object)component))
{
component.FallApart(true);
}
}
}
}
}