using System;
using System.Collections;
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 Microsoft.CodeAnalysis;
using Reptile;
using UnityEngine;
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: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("BillboardTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Billboard Tweaker")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: AssemblyInformationalVersion("0.0.3")]
[assembly: AssemblyProduct("BillboardTweaks")]
[assembly: AssemblyTitle("BillboardTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 billboardtweaks
{
[BepInPlugin("info.mariobluegloves.tweakbillboardp", "Tweak Billboard", "0.2.0")]
[BepInProcess("Bomb Rush Cyberfunk.exe")]
public class BillboardTweakerPlugin : BaseUnityPlugin
{
public static ConfigEntry<bool> fixWallrides;
public static ConfigEntry<bool> enableHidden;
public static ConfigEntry<bool> showWallrides;
public static ConfigEntry<bool> holdToEnable;
private WallrunLine[] wallrunLines;
private bool wallrunsCached;
public static readonly HashSet<WallrunLine> RevealedWallruns = new HashSet<WallrunLine>();
private Harmony harmony;
private static readonly HashSet<Renderer> PluginEnabledRenderers = new HashSet<Renderer>();
private void Awake()
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
fixWallrides = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "Fix Wallrides storage (requires restart)", true, "Detach wallrides from parents (requires restart)");
enableHidden = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "Enable hidden wallrides (requires restart)", false, "Enable wallrides that are disabled in the hierarchy (requires restart)");
showWallrides = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "Show wallride triggers", false, "Always show all wallride triggers");
holdToEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "Hold trick3 to reveal wallride triggers", true, "Reveal wallride triggers by holding trick3 while wallrunning");
harmony = new Harmony("info.mariobluegloves.tweakbillboardp.harmony");
harmony.PatchAll();
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
RevealedWallruns.Clear();
wallrunsCached = false;
((MonoBehaviour)this).StartCoroutine(CacheWallrunsDelayed());
}
private IEnumerator CacheWallrunsDelayed()
{
yield return null;
yield return null;
yield return null;
wallrunLines = Resources.FindObjectsOfTypeAll<WallrunLine>();
wallrunsCached = true;
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Cached {wallrunLines.Length} WallrunLines");
Scene scene;
if (fixWallrides.Value)
{
WallrunLine[] array = wallrunLines;
foreach (WallrunLine line2 in array)
{
int num;
if (Object.op_Implicit((Object)(object)line2))
{
scene = ((Component)line2).gameObject.scene;
num = ((!((Scene)(ref scene)).IsValid()) ? 1 : 0);
}
else
{
num = 1;
}
if (num == 0)
{
UnparentWallrunLine(line2);
}
}
}
if (!enableHidden.Value)
{
yield break;
}
WallrunLine[] array2 = wallrunLines;
foreach (WallrunLine line in array2)
{
int num2;
if (Object.op_Implicit((Object)(object)line))
{
scene = ((Component)line).gameObject.scene;
num2 = ((!((Scene)(ref scene)).IsValid()) ? 1 : 0);
}
else
{
num2 = 1;
}
if (num2 == 0)
{
EnsureWallrunEnabled(line);
}
}
}
private void Update()
{
//IL_003a: 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)
if (!wallrunsCached || wallrunLines == null)
{
return;
}
WallrunLine[] array = wallrunLines;
foreach (WallrunLine val in array)
{
if (Object.op_Implicit((Object)(object)val))
{
Scene scene = ((Component)val).gameObject.scene;
if (((Scene)(ref scene)).IsValid())
{
bool shouldReveal = showWallrides.Value || RevealedWallruns.Contains(val);
SetWallrunRenderers(val, shouldReveal);
}
}
}
}
private bool HasDynamicParent(Transform t)
{
Transform parent = t.parent;
while ((Object)(object)parent != (Object)null)
{
if ((Object)(object)((Component)parent).GetComponent<Rigidbody>() != (Object)null || (Object)(object)((Component)parent).GetComponent<Animator>() != (Object)null || (Object)(object)((Component)parent).GetComponent<Animation>() != (Object)null)
{
return true;
}
parent = parent.parent;
}
return false;
}
private void UnparentWallrunLine(WallrunLine line)
{
if (!HasDynamicParent(((Component)line).transform) && (Object)(object)((Component)line).transform.parent != (Object)null)
{
((Component)line).transform.SetParent((Transform)null, true);
}
}
private void EnsureWallrunEnabled(WallrunLine line)
{
if (!((Component)line).gameObject.activeSelf)
{
((Component)line).gameObject.SetActive(true);
}
if (!((Behaviour)line).enabled)
{
((Behaviour)line).enabled = true;
}
}
private static void SetWallrunRenderers(WallrunLine line, bool shouldReveal)
{
if (!shouldReveal)
{
return;
}
Renderer[] componentsInChildren = ((Component)line).GetComponentsInChildren<Renderer>(true);
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
if (!val.enabled)
{
val.enabled = true;
PluginEnabledRenderers.Add(val);
}
}
}
}
[HarmonyPatch(typeof(WallrunLineAbility), "FixedUpdateAbility")]
internal class WallrunLineAbility_FixedUpdateAbility_Patch
{
private static void Postfix(WallrunLineAbility __instance)
{
if (!BillboardTweakerPlugin.holdToEnable.Value)
{
return;
}
Player p = ((Ability)__instance).p;
if (!((Object)(object)p == (Object)null) && p.trick3ButtonHeld)
{
WallrunLine wallrunLine = __instance.wallrunLine;
if (!((Object)(object)wallrunLine == (Object)null))
{
BillboardTweakerPlugin.RevealedWallruns.Add(wallrunLine);
}
}
}
}
[BepInPlugin("info.mariobluegloves.tweakbillboard", "Tweak Billboard", "0.0.3")]
[BepInProcess("Bomb Rush Cyberfunk.exe")]
public class BillboardTweaker : BaseUnityPlugin
{
private Harmony harmony;
private void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"goo goo ga ga");
harmony = new Harmony("info.mariobluegloves.tweakbillboardp.harmony");
harmony.PatchAll();
}
}
}