Decompiled source of OneShotSunApparatice v1.0.2

plugins/OneshotSunApparatice/OneshotSunApparatice.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OneshotSunApparatice.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("OneshotSunApparatice")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OneshotSunApparatice")]
[assembly: AssemblyTitle("OneshotSunApparatice")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 OneshotSunApparatice
{
	[BepInPlugin("OneshotSunApparatice", "OneshotSunApparatice", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("OneshotSunApparatice");

		public static Plugin Instance;

		internal ManualLogSource mls = Logger.CreateLogSource("OneshotSunApparatice");

		internal static AssetBundle assetBundle;

		public static string PathForResourceInAssembly(string resourceName, Assembly assembly = null)
		{
			return Path.Combine(Path.GetDirectoryName((assembly ?? Assembly.GetCallingAssembly()).Location), resourceName);
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				harmony.PatchAll();
			}
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			assetBundle = AssetBundle.LoadFromFile(PathForResourceInAssembly("bulb"));
			if ((Object)(object)assetBundle == (Object)null)
			{
				mls.LogInfo((object)"Failed to load AssetBundle!");
				return;
			}
			mls.LogInfo((object)"AssetBundle loaded!");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(LungPropPatch));
			mls.LogInfo((object)"Plugin OneshotSunApparatice is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "OneshotSunApparatice";

		public const string PLUGIN_NAME = "OneshotSunApparatice";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace OneshotSunApparatice.Patches
{
	[HarmonyPatch(typeof(LungProp))]
	internal class LungPropPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void ReplaceModel(LungProp __instance)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Instance.mls.LogInfo((object)"LungPropPatch.Start");
			ScanNodeProperties componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<ScanNodeProperties>();
			componentInChildren.headerText = "The Sun";
			((GrabbableObject)__instance).itemProperties.itemName = "The Sun";
			Object.Destroy((Object)(object)((Component)((Component)__instance).gameObject.transform.Find("Mesh")).gameObject);
			GameObject val = Object.Instantiate<GameObject>(Plugin.assetBundle.LoadAsset<GameObject>("assets/bulb.prefab"), ((Component)__instance).gameObject.transform);
			val.transform.localRotation = Quaternion.Euler(0f, 180f, 180f);
			val.transform.localScale = new Vector3(4f, 4f, 4f);
		}
	}
}