Decompiled source of QuanDupeLightsources v1.0.0

QuanDupeLightsources.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("QuanDupeLightsources")]
[assembly: AssemblyConfiguration("release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b35ebadc9f5f0283d87053737caed04a0175fb18")]
[assembly: AssemblyProduct("QuanDupeLightsources")]
[assembly: AssemblyTitle("QuanDupeLightsources")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 QuanDupeLightsources
{
	[BepInPlugin("quandru.QuanDupeLightsources", "QuanDupeLightsources", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class QuanDupeLightsourcesPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "quandru.QuanDupeLightsources";

		public const string PluginName = "QuanDupeLightsources";

		public const string PluginVersion = "1.0.0";

		private const string PrefabPrefix = "Quan_";

		private const string NameSuffix = " (Always Lit)";

		private static readonly string[] BasePrefabs = new string[8] { "piece_walltorch", "piece_groundtorch", "piece_groundtorch_wood", "piece_groundtorch_green", "piece_groundtorch_blue", "piece_brazierfloor01", "piece_brazierceiling01", "piece_jackoturnip" };

		private void Awake()
		{
			PrefabManager.OnVanillaPrefabsAvailable += AddClones;
		}

		private void AddClones()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= AddClones;
			string[] basePrefabs = BasePrefabs;
			foreach (string text in basePrefabs)
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab(text);
				Piece val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Piece>() : null);
				if ((Object)(object)val == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Base prefab '" + text + "' not found or has no Piece component; skipped."));
					continue;
				}
				PieceConfig val2 = new PieceConfig
				{
					Name = val.m_name + " (Always Lit)",
					Description = val.m_description,
					PieceTable = PieceTables.Hammer,
					Category = ((object)Unsafe.As<PieceCategory, PieceCategory>(ref val.m_category)/*cast due to .constrained prefix*/).ToString(),
					CraftingStation = (Object.op_Implicit((Object)(object)val.m_craftingStation) ? ((Object)val.m_craftingStation).name : string.Empty),
					Requirements = val.m_resources.Where((Requirement r) => r != null && (Object)(object)r.m_resItem != (Object)null).Select((Func<Requirement, RequirementConfig>)((Requirement r) => new RequirementConfig(((Object)r.m_resItem).name, r.m_amount, r.m_amountPerLevel, r.m_recover))).ToArray()
				};
				PieceManager.Instance.AddPiece(new CustomPiece("Quan_" + text, text, val2));
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Light source duplicates registered. Add to NoSmokeStayLit Custom Items Keep Lit: " + string.Join(",", BasePrefabs.Select((string b) => "Quan_" + b))));
		}
	}
	internal static class PluginInfo
	{
		public const string Version = "1.0.0";
	}
}