Decompiled source of UpdatedPlushies v0.1.1

Mayberry.UpdatedPlushies.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using CSync.Extensions;
using CSync.Lib;
using LethalLib.Modules;
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("Mayberry.UpdatedPlushies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0+f8a7966ba1ab2b305e27572acfe3378e4e94f7f9")]
[assembly: AssemblyProduct("UpdatedPlushies")]
[assembly: AssemblyTitle("Mayberry.UpdatedPlushies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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.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 UpdatedPlushies
{
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	internal struct DefaultPlushieConfig
	{
	}
	internal class PlushieConfig : SyncedConfig2<PlushieConfig>
	{
		private static readonly (string, LevelTypes)[] moons = new(string, LevelTypes)[11]
		{
			("Experimentation", (LevelTypes)4),
			("Assurance", (LevelTypes)8),
			("Vow", (LevelTypes)16),
			("Offense", (LevelTypes)32),
			("March", (LevelTypes)64),
			("Adamance", (LevelTypes)2048),
			("Rend", (LevelTypes)128),
			("Dine", (LevelTypes)256),
			("Titan", (LevelTypes)512),
			("Artifice", (LevelTypes)4096),
			("Embrion", (LevelTypes)8192)
		};

		private readonly Dictionary<string, (int, int, bool, float, bool, Dictionary<LevelTypes, int>)> defaultConfigs = new Dictionary<string, (int, int, bool, float, bool, Dictionary<LevelTypes, int>)>
		{
			{
				"Bracken Plushie",
				(20, 70, false, 5f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)4,
						3
					},
					{
						(LevelTypes)8,
						2
					},
					{
						(LevelTypes)16,
						12
					},
					{
						(LevelTypes)32,
						1
					},
					{
						(LevelTypes)64,
						9
					},
					{
						(LevelTypes)2048,
						4
					},
					{
						(LevelTypes)128,
						6
					},
					{
						(LevelTypes)256,
						4
					},
					{
						(LevelTypes)512,
						5
					},
					{
						(LevelTypes)4096,
						4
					},
					{
						(LevelTypes)8192,
						1
					}
				})
			},
			{
				"Bunker Spider Plushie",
				(30, 50, false, 7f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)4,
						12
					},
					{
						(LevelTypes)8,
						11
					},
					{
						(LevelTypes)16,
						7
					},
					{
						(LevelTypes)32,
						10
					},
					{
						(LevelTypes)64,
						10
					},
					{
						(LevelTypes)2048,
						8
					},
					{
						(LevelTypes)128,
						5
					},
					{
						(LevelTypes)256,
						3
					},
					{
						(LevelTypes)512,
						5
					},
					{
						(LevelTypes)4096,
						4
					},
					{
						(LevelTypes)8192,
						4
					}
				})
			},
			{
				"Coil-Head Plushie",
				(50, 70, false, 8f, true, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)16,
						1
					},
					{
						(LevelTypes)32,
						6
					},
					{
						(LevelTypes)64,
						2
					},
					{
						(LevelTypes)2048,
						2
					},
					{
						(LevelTypes)128,
						5
					},
					{
						(LevelTypes)256,
						3
					},
					{
						(LevelTypes)512,
						5
					},
					{
						(LevelTypes)4096,
						4
					},
					{
						(LevelTypes)8192,
						4
					}
				})
			},
			{
				"Eyeless Dog Plushie",
				(30, 60, false, 7f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)4,
						12
					},
					{
						(LevelTypes)8,
						9
					},
					{
						(LevelTypes)16,
						1
					},
					{
						(LevelTypes)32,
						10
					},
					{
						(LevelTypes)64,
						5
					},
					{
						(LevelTypes)2048,
						5
					},
					{
						(LevelTypes)128,
						11
					},
					{
						(LevelTypes)256,
						9
					},
					{
						(LevelTypes)512,
						12
					},
					{
						(LevelTypes)4096,
						5
					},
					{
						(LevelTypes)8192,
						1
					}
				})
			},
			{
				"Forest Keeper Plushie",
				(50, 80, true, 12f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)4,
						1
					},
					{
						(LevelTypes)8,
						1
					},
					{
						(LevelTypes)16,
						12
					},
					{
						(LevelTypes)32,
						2
					},
					{
						(LevelTypes)64,
						8
					},
					{
						(LevelTypes)2048,
						4
					},
					{
						(LevelTypes)128,
						9
					},
					{
						(LevelTypes)256,
						11
					},
					{
						(LevelTypes)512,
						6
					},
					{
						(LevelTypes)4096,
						6
					},
					{
						(LevelTypes)8192,
						1
					}
				})
			},
			{
				"Jester Plushie",
				(50, 90, false, 9f, true, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)64,
						1
					},
					{
						(LevelTypes)2048,
						1
					},
					{
						(LevelTypes)128,
						7
					},
					{
						(LevelTypes)256,
						3
					},
					{
						(LevelTypes)512,
						6
					},
					{
						(LevelTypes)4096,
						4
					}
				})
			},
			{
				"Hoarding Bug Plushie",
				(10, 30, false, 4f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)4,
						6
					},
					{
						(LevelTypes)8,
						12
					},
					{
						(LevelTypes)16,
						10
					},
					{
						(LevelTypes)32,
						4
					},
					{
						(LevelTypes)64,
						6
					},
					{
						(LevelTypes)2048,
						8
					},
					{
						(LevelTypes)256,
						4
					},
					{
						(LevelTypes)512,
						3
					},
					{
						(LevelTypes)4096,
						4
					},
					{
						(LevelTypes)8192,
						15
					}
				})
			},
			{
				"Comedy Masked Plushie",
				(30, 60, false, 5f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)8,
						1
					},
					{
						(LevelTypes)2048,
						1
					},
					{
						(LevelTypes)128,
						5
					},
					{
						(LevelTypes)256,
						1
					},
					{
						(LevelTypes)512,
						4
					},
					{
						(LevelTypes)4096,
						4
					}
				})
			},
			{
				"Tragedy Masked Plushie",
				(40, 50, false, 5f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)8,
						1
					},
					{
						(LevelTypes)2048,
						1
					},
					{
						(LevelTypes)128,
						3
					},
					{
						(LevelTypes)256,
						3
					},
					{
						(LevelTypes)512,
						4
					},
					{
						(LevelTypes)4096,
						4
					}
				})
			},
			{
				"Nutcracker Plushie",
				(30, 80, false, 8f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)4,
						1
					},
					{
						(LevelTypes)8,
						1
					},
					{
						(LevelTypes)32,
						1
					},
					{
						(LevelTypes)64,
						1
					},
					{
						(LevelTypes)2048,
						1
					},
					{
						(LevelTypes)128,
						12
					},
					{
						(LevelTypes)256,
						3
					},
					{
						(LevelTypes)512,
						6
					},
					{
						(LevelTypes)4096,
						4
					},
					{
						(LevelTypes)8192,
						4
					}
				})
			},
			{
				"Thumper Plushie",
				(30, 60, true, 10f, false, new Dictionary<LevelTypes, int>
				{
					{
						(LevelTypes)4,
						3
					},
					{
						(LevelTypes)8,
						4
					},
					{
						(LevelTypes)16,
						2
					},
					{
						(LevelTypes)32,
						13
					},
					{
						(LevelTypes)64,
						12
					},
					{
						(LevelTypes)2048,
						10
					},
					{
						(LevelTypes)256,
						2
					},
					{
						(LevelTypes)512,
						5
					},
					{
						(LevelTypes)4096,
						4
					},
					{
						(LevelTypes)8192,
						5
					}
				})
			}
		};

		[DataMember]
		public SyncedEntry<int> MinValue { get; private set; }

		[DataMember]
		public SyncedEntry<int> MaxValue { get; private set; }

		[DataMember]
		public SyncedEntry<bool> IsTwoHanded { get; private set; }

		[DataMember]
		public SyncedEntry<float> CarryWeight { get; private set; }

		[DataMember]
		public SyncedEntry<bool> IsConductive { get; private set; }

		[DataMember]
		public Dictionary<LevelTypes, SyncedEntry<int>> SpawnWeights { get; private set; } = new Dictionary<LevelTypes, SyncedEntry<int>>();


		public PlushieConfig(ConfigFile configFile, string name)
			: base("Mayberry.UpdatedPlushies")
		{
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0780: Unknown result type (might be due to invalid IL or missing references)
			//IL_0790: Unknown result type (might be due to invalid IL or missing references)
			string text = name + " Settings";
			(int, int, bool, float, bool, Dictionary<LevelTypes, int>) tuple = defaultConfigs[name];
			int item = tuple.Item1;
			int item2 = tuple.Item2;
			bool item3 = tuple.Item3;
			float item4 = tuple.Item4;
			bool item5 = tuple.Item5;
			Dictionary<LevelTypes, int> item6 = tuple.Item6;
			MinValue = SyncedBindingExtensions.BindSyncedEntry<int>(configFile, text, name + " Minimum Value", item, "The lowest sell value the " + name + " can appear with, in $.");
			MaxValue = SyncedBindingExtensions.BindSyncedEntry<int>(configFile, text, name + " Maximum Value", item2, "The highest sell value the " + name + " can appear with, in $.");
			IsTwoHanded = SyncedBindingExtensions.BindSyncedEntry<bool>(configFile, text, name + " Is Two-Handed", item3, "If true, " + name + " will require two hands to carry.");
			CarryWeight = SyncedBindingExtensions.BindSyncedEntry<float>(configFile, text, name + " Carry Weight", item4, "The carry weight of " + name + ", in lb.");
			IsConductive = SyncedBindingExtensions.BindSyncedEntry<bool>(configFile, text, name + " Is Conductive", item5, "If true, " + name + " will attract lightning.");
			(string, LevelTypes)[] array = moons;
			for (int i = 0; i < array.Length; i++)
			{
				var (text2, key) = array[i];
				item6.TryGetValue(key, out var value);
				SpawnWeights.Add(key, SyncedBindingExtensions.BindSyncedEntry<int>(configFile, text, name + " " + text2 + " Spawn Weight", value, "The weight for a " + name + " to spawn on " + text2 + ". The higher this value is, the more often the item will appear. Set to 0 to make the item never appear on " + text2 + "."));
			}
		}
	}
	[BepInPlugin("Mayberry.UpdatedPlushies", "UpdatedPlushies", "0.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class UpdatedPlushies : BaseUnityPlugin
	{
		public void Awake()
		{
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Begin loading Mayberry.UpdatedPlushies");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading monster plushie asset bundle");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "monsterplushies");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			(string, Item)[] array = new(string, Item)[11]
			{
				("Bracken Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Bracken Plush/BrackenPlush.asset")),
				("Bunker Spider Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Bunkspid/BunkspidItem.asset")),
				("Coil-Head Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Coil head/CoilHeadPlush.asset")),
				("Eyeless Dog Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Eyeless dog/EyelessDog.asset")),
				("Forest Keeper Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Giant/Forest keeper plushie.asset")),
				("Jester Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Jester/jesterplushie.asset")),
				("Hoarding Bug Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Lootbug/lootbugPlush.asset")),
				("Comedy Masked Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Masked/comedyplushitem.asset")),
				("Tragedy Masked Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Masked/Tragedyplushitem.asset")),
				("Nutcracker Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Nutcracker/Nutcracker.asset")),
				("Thumper Plushie", val.LoadAsset<Item>("Assets/MY STUFF/Thumper/Thumper.asset"))
			};
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Finished loading monster plushie asset bundle");
			(string, Item)[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				var (text2, val2) = array2[i];
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Registering " + text2));
				PlushieConfig plushieConfig = new PlushieConfig(((BaseUnityPlugin)this).Config, text2);
				NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
				Utilities.FixMixerGroups(val2.spawnPrefab);
				val2.minValue = (int)((double)SyncedEntry<int>.op_Implicit(plushieConfig.MinValue) / 0.4);
				val2.maxValue = (int)((double)SyncedEntry<int>.op_Implicit(plushieConfig.MaxValue) / 0.4);
				val2.twoHanded = SyncedEntry<bool>.op_Implicit(plushieConfig.IsTwoHanded);
				val2.twoHandedAnimation = SyncedEntry<bool>.op_Implicit(plushieConfig.IsTwoHanded);
				val2.weight = SyncedEntry<float>.op_Implicit(plushieConfig.CarryWeight) / 105f + 1f;
				val2.isConductiveMetal = SyncedEntry<bool>.op_Implicit(plushieConfig.IsConductive);
				foreach (var (val5, val6) in plushieConfig.SpawnWeights)
				{
					if (SyncedEntry<int>.op_Implicit(val6) > 0)
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)$"Registering {text2} on {val5} with a spawn weight of {val6.Value}");
						Items.RegisterScrap(val2, val6.Value, val5);
					}
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Finished registering " + text2));
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Mayberry.UpdatedPlushies v0.0.0 has loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Mayberry.UpdatedPlushies";

		public const string PLUGIN_NAME = "UpdatedPlushies";

		public const string PLUGIN_VERSION = "0.0.0";
	}
}