Decompiled source of MushroomHatItem v1.0.1

MushroomHatItem.dll

Decompiled 7 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using MelonLoader;
using Microsoft.CodeAnalysis;
using MushroomHatItem;
using S1API.Entities;
using S1API.Items;
using S1API.Rendering;
using S1API.Shops;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "MushroomHatItem", "1.0.0", "Bars", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MushroomHatItem")]
[assembly: AssemblyConfiguration("CrossCompat")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+638c5bdd5d675e61fe05c7eccaefd57918a33a39")]
[assembly: AssemblyProduct("MushroomHatItem")]
[assembly: AssemblyTitle("MushroomHatItem")]
[assembly: NeutralResourcesLanguage("en-US")]
[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.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 MushroomHatItem
{
	public class Core : MelonMod
	{
		private bool _itemsInitialized = false;

		private ClothingItemDefinition? _mushroomHat = null;

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Main" && !_itemsInitialized)
			{
				InitializeCustomClothing();
				_itemsInitialized = true;
			}
		}

		private void InitializeCustomClothing()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			_mushroomHat = ClothingItemCreator.CloneFrom("cap").WithBasicInfo("mushroom_hat", "Mushroom Hat", "A whimsical mushroom hat for nature lovers.").WithClothingAsset("Avatar/Accessories/Head/MushroomHat/MushroomHat")
				.WithColorable(false)
				.WithPricing(100f, 0.5f)
				.WithKeywords(new string[5] { "hat", "cap", "mushroom", "nature", "fungi" })
				.WithLabelColor(Color.red)
				.Build();
			Player.LocalPlayerSpawned += OnLocalPlayerSpawned;
			int num = ShopManager.AddToCompatibleShops((ItemDefinition)(object)_mushroomHat, (float?)null);
			MelonLogger.Msg("Created clothing item: " + ((ItemDefinition)_mushroomHat).Name);
			MelonLogger.Msg($"Added to {num} shop(s)");
		}

		private void OnLocalPlayerSpawned(Player player)
		{
			Player.LocalPlayerSpawned -= OnLocalPlayerSpawned;
			if ((ItemDefinition)(object)_mushroomHat == (ItemDefinition)null)
			{
				MelonLogger.Warning("Mushroom Hat item not initialized, cannot generate icon.");
				return;
			}
			IconFactory.GenerateAccessoryIconSprite("Avatar/Accessories/Head/MushroomHat/MushroomHat", (Action<Sprite>)delegate(Sprite generatedSprite)
			{
				if ((Object)(object)generatedSprite != (Object)null)
				{
					((ItemDefinition)_mushroomHat).Icon = generatedSprite;
					MelonLogger.Msg("Generated custom icon for Mushroom Hat using player's appearance.");
					int num = ShopManager.RefreshItemIcon((ItemDefinition)(object)_mushroomHat);
					if (num > 0)
					{
						MelonLogger.Msg($"Updated icon in {num} shop listing(s)");
					}
				}
				else
				{
					MelonLogger.Warning("Failed to generate icon for Mushroom Hat.");
				}
			}, (Color?)null, 512);
		}
	}
}
namespace MushroomHatItem.Utils
{
	public static class Constants
	{
		public static class Defaults
		{
		}

		public static class Constraints
		{
			public const float MIN_CONSTRAINT = 0f;

			public const float MAX_CONSTRAINT = 100f;
		}

		public static class Game
		{
			public const string GAME_STUDIO = "TVGS";

			public const string GAME_NAME = "Schedule I";
		}

		public const string MOD_NAME = "MushroomHatItem";

		public const string MOD_VERSION = "1.0.0";

		public const string MOD_AUTHOR = "Bars";

		public const string MOD_DESCRIPTION = "Mod description...";

		public const string PREFERENCES_CATEGORY = "MushroomHatItem";
	}
}