Decompiled source of BundleFix v1.0.1

plugins/LLB-BundleFix/BundleFix.dll

Decompiled 8 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameplayEntities;
using HarmonyLib;
using LLBML.Utils;
using LLHandlers;
using StageBackground;
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: AssemblyTitle("BundleFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BundleFix")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a8395581-4eea-4793-bb1c-ea718aa90e0f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BundleFix;

[HarmonyPatch(typeof(BG), "StartUp")]
public class StartPatch
{
	public static void Postfix()
	{
		if (!Object.op_Implicit((Object)(object)((Component)BG.instance).gameObject.GetComponent<NitroFix>()))
		{
			((Component)BG.instance).gameObject.AddComponent<NitroFix>();
		}
	}
}
[BepInPlugin("fr.github.andylobjois.llb-bundlefix", "BundleFix", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BundleFixPlugin : BaseUnityPlugin
{
	public static BundleFixPlugin instance;

	public static DirectoryInfo PluginDir => ModdingFolder.GetModSubFolder(((BaseUnityPlugin)instance).Info);

	internal static ManualLogSource Log { get; private set; }

	private void Awake()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		Harmony val = new Harmony("BundleFix");
		val.PatchAll();
		Log.LogInfo((object)PluginDir);
		log("BundleFix is loaded");
	}

	public static void log(string message)
	{
		Debug.Log((object)("<color=cyan>[BundleFix] " + message + "</color>"));
	}

	public static void SetLayerAllChildren(Transform root, int layer)
	{
		Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
		Transform[] array = componentsInChildren;
		foreach (Transform val in array)
		{
			((Component)val).gameObject.layer = layer;
		}
	}
}
public static class BundleFixInfos
{
	public const string PLUGIN_ID = "fr.github.andylobjois.llb-bundlefix";

	public const string PLUGIN_NAME = "BundleFix";

	public const string PLUGIN_VERSION = "1.0.1";
}
public class NitroFix : MonoBehaviour
{
	private GameObject cuffHolder;

	private GameObject cuffReference;

	private Transform holderPlayer;

	private Transform holderBalls;

	private int playerSpot;

	public void Start()
	{
		//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)
		Scene activeScene = SceneManager.GetActiveScene();
		if (!(((Scene)(ref activeScene)).name == "title"))
		{
			Check();
		}
	}

	private void Check()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected O, but got Unknown
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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)
		//IL_007a: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Invalid comparison between Unknown and I4
		//IL_0087: 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_008d: Invalid comparison between Unknown and I4
		holderPlayer = GameObject.Find("holderPlayers").transform;
		holderBalls = GameObject.Find("holderBalls").transform;
		foreach (Transform item in holderPlayer)
		{
			Transform val = item;
			if (!(((Object)val).name == "copPlayer"))
			{
				continue;
			}
			playerSpot = val.GetSiblingIndex();
			CharacterVariant aIINAIDBHJI = ((AbilityEntity)((Component)val).GetComponent<CopPlayerModel>()).player.AIINAIDBHJI;
			CharacterVariant val2 = aIINAIDBHJI;
			CharacterVariant val3 = val2;
			if ((int)val3 > 7)
			{
				if (val3 - 9 <= 1)
				{
					CuffFix("cuffDetectiveVisual", "cuffDetective");
				}
			}
			else
			{
				CuffFix("cuffVisual", "cuff");
			}
		}
	}

	private void CuffFix(string target, string value)
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		for (int i = 0; i < 2; i++)
		{
			cuffHolder = ((Component)holderBalls.GetChild(i).Find(target)).gameObject;
			for (int j = 0; j < BundleHandler.assetReferences["characters/cop"].Length; j++)
			{
				if (BundleHandler.assetReferences["characters/cop"][j].name == value)
				{
					foreach (Transform item in cuffHolder.transform)
					{
						Transform val = item;
						((Component)val).gameObject.SetActive(false);
					}
					ref GameObject reference = ref cuffReference;
					Object obj = BundleHandler.assetReferences["characters/cop"][j];
					reference = (GameObject)(object)((obj is GameObject) ? obj : null);
					GameObject val2 = Object.Instantiate<GameObject>(cuffReference, cuffHolder.transform);
					BundleFixPlugin.SetLayerAllChildren(val2.transform, 8);
					Material material = ((Renderer)GameObject.Find("holderPlayers/copPlayer/main/buntEffect").GetComponent<SkinnedMeshRenderer>()).materials[0];
					((Renderer)((Component)val2.transform.GetChild(0)).GetComponent<SkinnedMeshRenderer>()).material = material;
					BundleFixPlugin.log($"Nitro {((Object)cuffHolder).name}.{target} have been replaced for Player {playerSpot}");
					break;
				}
				if (j == BundleHandler.assetReferences["characters/cop"].Length - 1)
				{
				}
			}
		}
	}
}