Decompiled source of MoreClothing v1.0.2

Mods/MoreClothing_IL2Cpp.dll

Decompiled 9 hours 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 Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using MoreClothing;
using S1API.Items;
using S1API.Shops;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "MoreClothing", "1.0.2", "j0ckinjz", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MoreClothing_IL2Cpp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreClothing_IL2Cpp")]
[assembly: AssemblyTitle("MoreClothing_IL2Cpp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
}
namespace MoreClothing
{
	public sealed class Core : MelonMod
	{
		private readonly record struct ItemSpec(string Id, string Name, string Description, float Price, string AssetPath, ClothingSlot Slot, bool Colorable, ClothingColor DefaultColor)
		{
			public void Deconstruct(out string Id, out string Name, out string Description, out float Price, out string AssetPath, out ClothingSlot Slot, out bool Colorable, out ClothingColor DefaultColor)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected I4, but got Unknown
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected I4, but got Unknown
				Id = this.Id;
				Name = this.Name;
				Description = this.Description;
				Price = this.Price;
				AssetPath = this.AssetPath;
				Slot = (ClothingSlot)(int)this.Slot;
				Colorable = this.Colorable;
				DefaultColor = (ClothingColor)(int)this.DefaultColor;
			}
		}

		private bool _ready;

		private readonly List<ItemSpec> _items = new List<ItemSpec>
		{
			new ItemSpec("bulletproofvest_police", "Police Tactical Vest", "Very tough looking vest. It doesn't actually block bullets, though. Police issued.", 200f, "Avatar/Accessories/Chest/BulletproofVest/BulletproofVest_Police", (ClothingSlot)4, Colorable: false, (ClothingColor)0),
			new ItemSpec("policecap", "Police Cap", "Standard-issue police cap. Offers no protection, but a strong sense of authority.", 100f, "Avatar/Accessories/Head/PoliceCap/PoliceCap", (ClothingSlot)8, Colorable: false, (ClothingColor)0),
			new ItemSpec("respirator", "Respirator", "Blocks out the bad stuff. Or at least makes you feel like it does.", 100f, "Avatar/Accessories/Head/Respirator/Respirator", (ClothingSlot)8, Colorable: false, (ClothingColor)0),
			new ItemSpec("hazmatsuit", "Hazmat Suit", "Complete body coverage for those 'don't ask what I'm doing' days.", 200f, "Avatar/Accessories/Waist/HazmatSuit/HazmatSuit", (ClothingSlot)4, Colorable: true, (ClothingColor)13),
			new ItemSpec("policebelt", "Police Belt", "Comes with holsters and zero responsibility. For decorative law enforcement.", 100f, "Avatar/Accessories/Waist/PoliceBelt/PoliceBelt", (ClothingSlot)2, Colorable: false, (ClothingColor)0),
			new ItemSpec("fastfoodtshirt", "Fast Food T-Shirt", "Grease-stained uniform of the flavor elite. Smells like tacos, permanently.", 75f, "Avatar/Layers/Top/FastFood T-Shirt", (ClothingSlot)3, Colorable: false, (ClothingColor)0),
			new ItemSpec("fastfoodcap", "Taco Ticklers Cap", "Grease-stained uniform of the flavor elite. Smells like tacos, permanently.", 50f, "Avatar/Accessories/Head/Cap/Cap_FastFood", (ClothingSlot)8, Colorable: false, (ClothingColor)0),
			new ItemSpec("gasstationtshirt", "Gas Station T-Shirt", "Proudly repping petroleum. Includes complimentary sweat.", 75f, "Avatar/Layers/Top/GasStation T-Shirt", (ClothingSlot)3, Colorable: false, (ClothingColor)0),
			new ItemSpec("tuckedtshirt", "Tucked T-Shirt", "For when you want to look like you care... but not that much.", 50f, "Avatar/Layers/Top/Tucked T-Shirt", (ClothingSlot)3, Colorable: true, (ClothingColor)0),
			new ItemSpec("priestgown", "Priest Gown", "God is good. We're not.", 100f, "Avatar/Accessories/Waist/PriestGown/PriestGown", (ClothingSlot)4, Colorable: false, (ClothingColor)0)
		};

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName != "Main" || _ready)
			{
				return;
			}
			try
			{
				InjectAll();
				_ready = true;
			}
			catch (Exception value)
			{
				((MelonBase)this).LoggerInstance.Error($"MoreClothing inject failed: {value}");
			}
		}

		private void InjectAll()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			foreach (ItemSpec item in _items)
			{
				ClothingItemDefinitionBuilder val = ClothingItemCreator.CreateBuilder().WithBasicInfo(item.Id, item.Name, item.Description).WithSlot(item.Slot)
					.WithClothingAsset(item.AssetPath)
					.WithColorable(item.Colorable)
					.WithDefaultColor(item.DefaultColor)
					.WithPricing(item.Price, 0.5f);
				Sprite val2 = LoadIcon(item.Id);
				if ((Object)(object)val2 != (Object)null)
				{
					val = val.WithIcon(val2);
				}
				ClothingItemDefinition val3 = val.Build();
				if ((ItemDefinition)(object)val3 == (ItemDefinition)null)
				{
					((MelonBase)this).LoggerInstance.Warning("Failed to build " + item.Name);
					continue;
				}
				if (string.IsNullOrEmpty(val3.ClothingAssetPath))
				{
					((MelonBase)this).LoggerInstance.Warning("Avatar object missing for " + item.Name + " path=" + item.AssetPath);
				}
				num2 += ShopManager.AddToCompatibleShops((ItemDefinition)(object)val3, (float?)item.Price);
				num++;
				((MelonBase)this).LoggerInstance.Msg("Created " + item.Name);
			}
			((MelonBase)this).LoggerInstance.Msg($"MoreClothing 1.0.2 ready: {num} items, shop listings touched={num2}");
		}

		private static Sprite? LoadIcon(string id)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			string name = "MoreClothing.Icons." + id + ".png";
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
			if (stream == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			byte[] array = memoryStream.ToArray();
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, new Il2CppStructArray<byte>(array));
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
}