Decompiled source of ClothCollider v1.0.1

ClothCollider.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Diagnostics;
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 DM;
using HarmonyLib;
using Landfall.TABS;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ClothCollider")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("ClothCollider")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("ClothCollider")]
[assembly: ComVisible(false)]
[assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace ClothCollider;

public static class UManager
{
	public static void SetClothes(GameObject cloth, CharacterItem ci, LandfallContentDatabase db)
	{
		MeshFilter[] componentsInChildren = cloth.GetComponentsInChildren<MeshFilter>();
		foreach (MeshFilter val in componentsInChildren)
		{
			try
			{
				MeshCollider obj = ((Component)val).gameObject.AddComponent<MeshCollider>();
				obj.convex = true;
				((Collider)obj).contactOffset = 0.01f;
				obj.sharedMesh = val.mesh;
				obj.cookingOptions = (MeshColliderCookingOptions)6;
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex);
				Debug.Log((object)("Failed adding collision to " + ((Object)cloth.gameObject).name));
			}
		}
	}
}
[BepInPlugin("BepInEx.ClothCollider", "ClothCollider", "1.0.1")]
internal class Loader : BaseUnityPlugin
{
	private void Awake()
	{
		((MonoBehaviour)this).StartCoroutine("Call");
	}

	private IEnumerator Call()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
		yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
		LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
		new Harmony("ClothCollider").PatchAll();
		GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
		for (int i = 0; i < array.Length; i++)
		{
			if (Object.op_Implicit((Object)(object)array[i].GetComponent<PropItem>()) && Object.op_Implicit((Object)(object)array[i].GetComponentInChildren<MeshRenderer>()))
			{
				UManager.SetClothes(array[i], array[i].GetComponent<CharacterItem>(), landfallContentDatabase);
			}
		}
		Debug.Log((object)"Loaded ClothCollider Mod Successfully!");
	}
}