Decompiled source of Rainbrew v3.0.0

GreenStormMod.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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("GreenStormMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GreenStormMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e11132f3-73eb-40cb-a241-76a6da26ae2a")]
[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")]
[HarmonyPatch(typeof(StartOfRound))]
internal class PlushieModelReplacement
{
	[HarmonyPatch("Awake")]
	[HarmonyPrefix]
	public static void ReplaceModel(AllItemsList ___allItemsList)
	{
		RainbrewMod.ReplaceBottles(___allItemsList.itemsList.ToArray());
	}
}
[BepInPlugin("GreenStorm.Rainbrew", "Rainbrew", "0.0.1")]
public class RainbrewMod : BaseUnityPlugin
{
	private const string modGUID = "GreenStorm.Rainbrew";

	private const string modName = "Rainbrew";

	private const string modVersion = "0.0.1";

	private readonly Harmony harmony = new Harmony("GreenStorm.Rainbrew");

	public static ManualLogSource mls;

	private static RainbrewMod instance;

	public static AssetBundle assets;

	public static string assetName = "rain.brew";

	public static string meshName = "rainbrew_crate.mesh";

	public static string capMat = "rainbrew_bottle_cap.mat";

	public static string bottleMat = "rainbrew_bottle.mat";

	public static string crateMat = "rainbrew_crate.mat";

	public static string BottleName = "Bottles";

	public static Mesh BottleMesh;

	public static Material[] BottleMaterials;

	public static float size = 8f;

	private void Awake()
	{
		if ((Object)(object)instance == (Object)null)
		{
			instance = this;
		}
		mls = Logger.CreateLogSource("GreenStorm.Rainbrew");
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string text = Path.Combine(directoryName, assetName).Replace("\\", "/");
		assets = AssetBundle.LoadFromFile(text);
		harmony.PatchAll();
		mls.LogInfo((object)"Rainbrew has loaded");
	}

	public static void ReplaceBottles(Item[] items)
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Expected O, but got Unknown
		Item val = null;
		mls.LogMessage((object)items.Length);
		foreach (Item val2 in items)
		{
			mls.LogMessage((object)val2.itemName);
			if (val2.itemName == BottleName)
			{
				val = val2;
				break;
			}
		}
		if ((Object)(object)val != (Object)null)
		{
			val.itemName = "Rainbrew";
			val.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = val.itemName;
			val.restingRotation = Vector3.zero;
			val.rotationOffset = new Vector3(95.3f, 111.9f, 10.25f);
			val.positionOffset = new Vector3(-0.15f, 0.2f, -0.35f);
			val.floorYOffset = 90;
			Mesh val3 = Object.Instantiate<Mesh>(assets.LoadAsset<Mesh>(meshName));
			Vector3[] vertices = val3.vertices;
			Bounds bounds = val3.bounds;
			Vector3 center = ((Bounds)(ref bounds)).center;
			for (int j = 0; j < vertices.Length; j++)
			{
				vertices[j] = center + (vertices[j] - center) * size;
			}
			val3.vertices = vertices;
			val3.RecalculateBounds();
			((Renderer)val.spawnPrefab.GetComponent<MeshRenderer>()).materials = (Material[])(object)new Material[3]
			{
				assets.LoadAsset<Material>(capMat),
				assets.LoadAsset<Material>(bottleMat),
				assets.LoadAsset<Material>(crateMat)
			};
			val.spawnPrefab.GetComponent<MeshFilter>().mesh = val3;
			foreach (Transform item in val.spawnPrefab.transform)
			{
				Transform val4 = item;
				if (((Object)val4).name != "ScanNode")
				{
					Object.Destroy((Object)(object)((Component)val4).gameObject);
				}
			}
			Object.Destroy((Object)(object)val.spawnPrefab.GetComponent<LODGroup>());
		}
		else
		{
			mls.LogMessage((object)"Bottles could not be found.");
		}
	}
}