Decompiled source of SparkleDoll v0.0.2

SparkleDoll.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
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 Dawn;
using Dusk;
using Dusk.Weights;
using Microsoft.CodeAnalysis;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SparkleDoll")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("SparkleDoll")]
[assembly: AssemblyTitle("SparkleDoll")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 SparkleDoll
{
	internal static class ItemRegistry
	{
		internal static class SparkleDollKeys
		{
			public static readonly NamespacedKey<DawnItemInfo> SparkleDoll = NamespacedKey<DawnItemInfo>.From("sparkledoll", "sparkle_doll");
		}

		internal static int sparkleDollSpawnWeight;

		private static string sparkleBundlePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sparkledoll");

		public static AssetBundle sparkleBundle = AssetBundle.LoadFromFile(sparkleBundlePath);

		public static Item sparkleDollItem = sparkleBundle.LoadAsset<Item>("Assets/SparkleDoll/Prefabs/SparkleDoll.asset");

		private static bool initialised;

		internal static void Init()
		{
			if (initialised)
			{
				return;
			}
			initialised = true;
			DawnLib.RegisterNetworkPrefab(sparkleDollItem.spawnPrefab);
			DawnLib.FixMixerGroups(sparkleDollItem.spawnPrefab);
			DawnLib.DefineItem(SparkleDollKeys.SparkleDoll, sparkleDollItem, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo>>)delegate(WeightTableBuilder<DawnMoonInfo> weightBuilder)
					{
						weightBuilder.SetGlobalWeight((IWeighted)(object)CreateGlobalWeightPreset(sparkleDollSpawnWeight));
					});
				});
			});
		}

		private static SpawnWeightsPreset CreateGlobalWeightPreset(int baseWeight)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			SpawnWeightsPreset val = new SpawnWeightsPreset();
			List<NamespacedConfigWeight> list = new List<NamespacedConfigWeight>();
			List<NamespacedConfigWeight> list2 = new List<NamespacedConfigWeight>();
			List<NamespacedConfigWeight> list3 = new List<NamespacedConfigWeight>();
			val.SetupSpawnWeightsPreset(list, list2, list3, baseWeight);
			return val;
		}
	}
	[BepInPlugin("MrHat.SparkleDoll", "SparkleDoll", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal const string modGUID = "MrHat.SparkleDoll";

		internal const string modName = "SparkleDoll";

		internal const string modVersion = "0.0.1";

		internal static ManualLogSource mls;

		internal static Plugin Instance;

		private void Awake()
		{
			Instance = this;
			mls = Logger.CreateLogSource("MrHat.SparkleDoll");
			mls.LogInfo((object)"[SparkleDoll] Sparkle doll loaded!");
			ItemRegistry.sparkleDollSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Sparkle Doll", "SpawnWeight", 20, "Global scrap spawn weight for Sparkle Doll").Value;
			ItemRegistry.Init();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SparkleDoll";

		public const string PLUGIN_NAME = "SparkleDoll";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}