Decompiled source of InvisibleChipLogRope v1.0.0

plugins/CuerdaMod.dll

Decompiled an hour ago
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 HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CuerdaMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CuerdaMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("007e607f-0e37-448c-b8f5-8a48a461b4dd")]
[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 CuerdaMod;

[BepInPlugin("vikingdmike.invisiblechiplogrope", "VDM Invisible Chip Log Rope", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public const string ID = "vikingdmike.invisiblechiplogrope";

	private ConfigEntry<bool> invisible;

	private float proxima;

	private bool volcado;

	private readonly HashSet<int> vistos = new HashSet<int>();

	private static readonly FieldInfo campoCuerda = AccessTools.Field(typeof(ShipItemChipLog), "rope");

	private static readonly FieldInfo campoMadera = AccessTools.Field(typeof(ShipItemChipLog), "bobberBody");

	private void Awake()
	{
		invisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Rope", "Invisible", true, "Hide the chip log rope");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"VDM Invisible Chip Log Rope cargado");
	}

	private void Update()
	{
		if (Time.time < proxima)
		{
			return;
		}
		proxima = Time.time + 0.5f;
		ShipItemChipLog[] array = Object.FindObjectsOfType<ShipItemChipLog>();
		foreach (ShipItemChipLog val in array)
		{
			if (!volcado)
			{
				volcado = true;
				Volcar(((Component)val).transform.root);
			}
			Esconder(((Component)val).transform);
			Component val2 = (Component)((campoCuerda != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val2 != (Object)null)
			{
				Esconder(val2.transform);
			}
			Rigidbody val3 = (Rigidbody)((campoMadera != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val3 != (Object)null)
			{
				Esconder(((Component)val3).transform);
			}
		}
	}

	private void Esconder(Transform raiz)
	{
		LineRenderer[] componentsInChildren = ((Component)raiz).GetComponentsInChildren<LineRenderer>(true);
		foreach (LineRenderer val in componentsInChildren)
		{
			if (((Renderer)val).enabled == invisible.Value)
			{
				((Renderer)val).enabled = !invisible.Value;
			}
		}
		Component[] componentsInChildren2 = ((Component)raiz).GetComponentsInChildren<Component>(true);
		foreach (Component val2 in componentsInChildren2)
		{
			if ((Object)(object)val2 == (Object)null || ((object)val2).GetType().Name != "ClothRope")
			{
				continue;
			}
			Renderer[] componentsInChildren3 = val2.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val3 in componentsInChildren3)
			{
				if (val3.enabled == invisible.Value)
				{
					val3.enabled = !invisible.Value;
				}
			}
		}
	}

	private void Volcar(Transform raiz)
	{
		ShipItemChipLog[] componentsInChildren = ((Component)raiz).GetComponentsInChildren<ShipItemChipLog>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Transform[] componentsInChildren2 = ((Component)componentsInChildren[i]).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren2)
			{
				string text = "";
				Component[] components = ((Component)val).GetComponents<Component>();
				foreach (Component val2 in components)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						text = text + ((object)val2).GetType().Name + " ";
					}
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)("CUERDA: pieza '" + Ruta(val) + "' activa=" + ((Component)val).gameObject.activeInHierarchy + " [" + text + "]"));
			}
		}
		FieldInfo[] fields = typeof(ShipItemChipLog).GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		foreach (FieldInfo fieldInfo in fields)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("CUERDA: campo ShipItemChipLog." + fieldInfo.Name + " (" + fieldInfo.FieldType.Name + ")"));
		}
	}

	private void Piezas(string que, Transform raiz)
	{
		Transform[] componentsInChildren = ((Component)raiz).GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			string text = "";
			Component[] components = ((Component)val).GetComponents<Component>();
			foreach (Component val2 in components)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					text = text + ((object)val2).GetType().Name + " ";
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("CUERDA: " + que + " '" + Ruta(val) + "' activa=" + ((Component)val).gameObject.activeInHierarchy + " [" + text + "]"));
		}
	}

	private static string Ruta(Transform t)
	{
		string text = ((Object)t).name;
		Transform parent = t.parent;
		while ((Object)(object)parent != (Object)null)
		{
			text = ((Object)parent).name + "/" + text;
			parent = parent.parent;
		}
		return text;
	}
}