Decompiled source of GophxrMod v1.0.0

GophxrMod.dll

Decompiled 9 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
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 GophxrMod;
using GophxrMod.Items;
using GophxrMod.Utils;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using S1API.Console;
using S1API.Economy;
using S1API.Entities;
using S1API.Entities.Customer;
using S1API.Entities.Dialogue;
using S1API.Entities.NPCs.Northtown;
using S1API.Entities.Relation;
using S1API.Entities.Schedule;
using S1API.GameTime;
using S1API.Items;
using S1API.Lifecycle;
using S1API.Map;
using S1API.Map.Buildings;
using S1API.Products;
using S1API.Rendering;
using S1API.Shops;
using S1API.Utils;
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), "GophxrMod", "1.0.0", "HazDS", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GophxrMod")]
[assembly: AssemblyConfiguration("CrossCompat")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ae2faad2d39777aa6ee4cb445f4335ee68ed14f9")]
[assembly: AssemblyProduct("GophxrMod")]
[assembly: AssemblyTitle("GophxrMod")]
[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 GophxrMod
{
	public class Core : MelonMod
	{
		[CompilerGenerated]
		private sealed class <AddToShopsDelayed>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Core <>4__this;

			object? IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object? IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <AddToShopsDelayed>d__15(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!<>4__this._shopsInitialized)
					{
						GophxrCapCreator.AddToShops();
						GophxrTShirtCreator.AddToShops();
						<>4__this._shopsInitialized = true;
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private bool _itemsInitialized = false;

		private bool _shopsInitialized = false;

		private bool _mainSceneLoaded = false;

		private static MelonPreferences_Category? _preferencesCategory;

		private static MelonPreferences_Entry<bool>? _debugLogsEntry;

		public static Core? Instance { get; private set; }

		public static bool DebugLogsEnabled => _debugLogsEntry?.Value ?? false;

		public override void OnLateInitializeMelon()
		{
			Instance = this;
			_preferencesCategory = MelonPreferences.CreateCategory("GophxrMod");
			_debugLogsEntry = _preferencesCategory.CreateEntry<bool>("DebugLogs", false, "Enable Debug Logs", "Show detailed debug messages in the console", false, false, (ValueValidator)null, (string)null);
			_preferencesCategory.SaveToFile(false);
			GameLifecycle.OnPreLoad += OnPreLoad;
			((MelonBase)this).LoggerInstance.Msg("GophxrMod v1.0.0 initialized");
		}

		public override void OnApplicationQuit()
		{
			Instance = null;
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Main")
			{
				_mainSceneLoaded = true;
				if (_itemsInitialized && !_shopsInitialized)
				{
					MelonCoroutines.Start(AddToShopsDelayed());
				}
			}
			else if (sceneName == "Menu")
			{
				_itemsInitialized = false;
				_shopsInitialized = false;
				_mainSceneLoaded = false;
			}
		}

		private void OnPreLoad()
		{
			if (!_itemsInitialized)
			{
				GophxrCapCreator.Initialize();
				GophxrTShirtCreator.Initialize();
				_itemsInitialized = true;
				((MelonBase)this).LoggerInstance.Msg("Gophxr items loaded!");
				if (_mainSceneLoaded && !_shopsInitialized)
				{
					MelonCoroutines.Start(AddToShopsDelayed());
				}
			}
		}

		[IteratorStateMachine(typeof(<AddToShopsDelayed>d__15))]
		private IEnumerator AddToShopsDelayed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AddToShopsDelayed>d__15(0)
			{
				<>4__this = this
			};
		}
	}
}
namespace GophxrMod.NPCs
{
	public sealed class GophxrNPC : NPC
	{
		public override bool IsPhysical => true;

		protected override void ConfigurePrefab(NPCPrefabBuilder builder)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			Building budsBar = Building.Get<BudsBar>();
			Building mollyHouse = Building.Get<GeorgeAndMollysHouse>();
			builder.WithIdentity("gophxr", "Gophxr", "").WithAppearanceDefaults((Action<AvatarDefaultsBuilder>)delegate(AvatarDefaultsBuilder av)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017a: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
				av.Gender = 0f;
				av.Weight = 0.15161291f;
				av.SkinColor = new Color32((byte)223, (byte)189, (byte)161, byte.MaxValue);
				av.LeftEyeLidColor = new Color(0.8745098f, 63f / 85f, 0.6313726f);
				av.RightEyeLidColor = new Color(0.8745098f, 63f / 85f, 0.6313726f);
				av.EyeBallTint = new Color(1f, 0.8254717f, 0.8254717f);
				av.EyeballMaterialIdentifier = "Default";
				av.HairPath = "Avatar/Hair/Peaked/Peaked";
				av.HairColor = new Color(0.31132078f, 0.22077194f, 0.1541919f);
				av.PupilDilation = 0.43387097f;
				av.EyebrowScale = 0.9616129f;
				av.EyebrowThickness = 1.167742f;
				av.EyebrowRestingHeight = -0.07741934f;
				av.EyebrowRestingAngle = -7.096774f;
				av.LeftEye = (34f / 155f, 0.4935484f);
				av.RightEye = (34f / 155f, 0.4935484f);
				av.WithFaceLayer("Avatar/Layers/Face/Face_SmugPout", new Color(0f, 0f, 0f));
				av.WithFaceLayer("Avatar/Layers/Face/FacialHair_Goatee", new Color(0.31132078f, 0.22077194f, 0.1541919f));
				av.WithFaceLayer("Avatar/Layers/Tattoos/Face/Face_Tribal", new Color(0f, 0f, 0f));
				av.WithBodyLayer("GophxrMod/Clothing/GophxrTShirt", Color.white);
				av.WithBodyLayer("Avatar/Layers/Bottom/Jeans", new Color(0.17795478f, 0.21686769f, 43f / 106f));
				av.WithAccessoryLayer("GophxrMod/Accessories/GophxrCap", Color.white);
				av.WithAccessoryLayer("Avatar/Accessories/Feet/Sneakers/Sneakers", new Color(0.7169812f, 0.7169812f, 0.7169812f));
			}).WithSpawnPosition(new Vector3(18.83f, 2.64f, 92.65f))
				.EnsureCustomer()
				.WithCustomerDefaults((Action<CustomerDataBuilder>)delegate(CustomerDataBuilder cd)
				{
					cd.WithSpending(200f, 600f).WithOrdersPerWeek(1, 2).WithPreferredOrderDay((Day)4)
						.WithOrderTime(1200)
						.WithStandards((CustomerStandard)2)
						.AllowDirectApproach(true)
						.WithMutualRelationRequirement(2f, 3.5f)
						.WithCallPoliceChance(0.05f)
						.WithDependence(0.05f, 1f)
						.WithAffinities((IEnumerable<ValueTuple<DrugType, float>>)new(DrugType, float)[2]
						{
							((DrugType)0, 0.6f),
							((DrugType)2, -0.4f)
						});
				})
				.WithRelationshipDefaults((Action<NPCRelationshipDataBuilder>)delegate(NPCRelationshipDataBuilder r)
				{
					r.WithDelta(1.5f).SetUnlocked(false).SetUnlockType((UnlockType)1)
						.WithConnections<JessiWaters, MickLubbin>();
				})
				.WithSchedule((Action<PrefabScheduleBuilder>)delegate(PrefabScheduleBuilder plan)
				{
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_004e: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
					plan.EnsureDealSignal().LocationBased(new Vector3(18.83f, 2.64f, 92.65f), 700, 5).OnArriveNone()
						.SitAtSeatSet((string)null, 705, 25, false, (string)null, "Map/Hyland Point/Region_Downtown/Casino/Interior/Double Sofa (1)")
						.LocationBased(new Vector3(-30.64f, 1.84f, 72.67f), 730, 90)
						.OnArriveNone()
						.SitAtSeatSet("Fast Food Booth", 900, 60, false, (string)null, (string)null)
						.LocationBased(new Vector3(-40.44f, 1.74f, 77.94f), 1000, 30)
						.OnArriveNone()
						.SitAtSeatSet("outdoorbench", 1030, 180, false, (string)null, (string)null)
						.LocationBased(new Vector3(-73.83f, -2.16f, 140.64f), 1300, 120)
						.OnArriveNone()
						.LocationBased(new Vector3(-33.46f, -0.76f, -18.44f), 1500, 110)
						.OnArriveNone()
						.SitAtSeatSet((string)null, 1650, 130, false, (string)null, "Map/Hyland Point/Region_Docks/WaterFront/OutdoorBench (1)")
						.StayInBuilding(budsBar, 1900, 270, (int?)null, (string)null)
						.StayInBuilding(mollyHouse, 2330, 270, (int?)null, (string)null);
				})
				.WithInventoryDefaults((Action<RandomInventoryItemsBuilder>)delegate(RandomInventoryItemsBuilder inv)
				{
					inv.WithRandomCash(100, 500).WithClearInventoryEachNight(false);
				});
		}

		protected override void OnCreated()
		{
			try
			{
				((NPC)this).OnCreated();
				((NPC)this).Appearance.Build();
				((NPC)this).Region = (Region)0;
				((NPC)this).Schedule.Enable();
				SetupDialogue();
				DebugLog.Msg("[GophxrNPC] Gophxr NPC created and schedule enabled.");
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[GophxrNPC] OnCreated failed: " + ex.Message);
				MelonLogger.Error("[GophxrNPC] Stack trace: " + ex.StackTrace);
			}
		}

		private void SetupDialogue()
		{
			((NPC)this).Dialogue.BuildAndRegisterContainer("GophxrDialogue", (Action<DialogueContainerBuilder>)delegate(DialogueContainerBuilder c)
			{
				c.AddNode("ENTRY", "Hey my dude! Have you seen my merch over at Thrifty Threads?", (Action<ChoiceList>)delegate(ChoiceList ch)
				{
					ch.Add("MERCH_INFO", "What merch?", "MERCH_DETAILS");
					ch.Add("ALREADY_KNOW", "Yeah, I've seen it!", "ALREADY_KNOW_RESPONSE");
					ch.Add("LEAVE", "Catch you later.", "EXIT");
				});
				c.AddNode("MERCH_DETAILS", "I've got caps and t-shirts at Thrifty Threads! Go check 'em out, you won't regret it.", (Action<ChoiceList>)delegate(ChoiceList ch)
				{
					ch.Add("THANKS", "I'll check it out!", "EXIT");
					ch.Add("MAYBE_LATER", "Maybe later.", "EXIT");
				});
				c.AddNode("ALREADY_KNOW_RESPONSE", "Positive vibes, my dude!", (Action<ChoiceList>)delegate(ChoiceList ch)
				{
					ch.Add("FRIDAY", "Friday vibes! It's pizza night!", "EXIT");
				});
				c.AddNode("EXIT", "Stay positive, dude!", (Action<ChoiceList>)null);
			});
			((NPC)this).Dialogue.UseContainerOnInteractOnce("GophxrDialogue");
		}
	}
}
namespace GophxrMod.Items
{
	public static class GophxrCapCreator
	{
		private const string ITEM_ID = "gophxr_cap";

		private const string ITEM_NAME = "Gophxr Cap";

		private const string ITEM_DESCRIPTION = "Gophxr's very own cap!";

		private const string SOURCE_CAP_PATH = "avatar/accessories/head/cap/Cap";

		private const string CUSTOM_CAP_RESOURCE_PATH = "GophxrMod/Accessories/GophxrCap";

		public static void Initialize()
		{
			try
			{
				if (!CreateCustomAccessory())
				{
					MelonLogger.Error("[GophxrCap] Failed to create custom accessory");
				}
				else if (!CreateClothingItem())
				{
					MelonLogger.Error("[GophxrCap] Failed to create clothing item");
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[GophxrCap] Initialization failed: " + ex.Message);
				MelonLogger.Error("[GophxrCap] Stack trace: " + ex.StackTrace);
			}
		}

		public static void AddToShops()
		{
			try
			{
				ItemDefinition itemDefinition = ItemManager.GetItemDefinition("gophxr_cap");
				if (itemDefinition == (ItemDefinition)null)
				{
					MelonLogger.Error("[GophxrCap] Item 'gophxr_cap' not found in registry");
					return;
				}
				ShopManager.AddToShops(itemDefinition, new string[1] { "Thrifty Threads" });
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[GophxrCap] Failed to add to shops: " + ex.Message);
			}
		}

		private static bool CreateCustomAccessory()
		{
			try
			{
				if (RuntimeResourceRegistry.IsRegistered("GophxrMod/Accessories/GophxrCap"))
				{
					DebugLog.Msg("[GophxrCap] Custom accessory already registered, skipping creation");
					return true;
				}
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				Texture2D val = TextureUtils.LoadTextureFromResource(executingAssembly, "GophxrMod.Resources.GophxrCap.gophxr_cap_texture.png", (FilterMode)1, (TextureWrapMode)1);
				if ((Object)(object)val == (Object)null)
				{
					MelonLogger.Error("[GophxrCap] Failed to load custom texture from resources");
					return false;
				}
				Dictionary<string, Texture2D> dictionary = new Dictionary<string, Texture2D>
				{
					{ "_MainTex", val },
					{ "_BaseMap", val },
					{ "_Albedo", val }
				};
				return AccessoryFactory.CreateAndRegisterAccessory("avatar/accessories/head/cap/Cap", "GophxrMod/Accessories/GophxrCap", "GophxrCap", dictionary, (Color?)null);
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[GophxrCap] Failed to create accessory: " + ex.Message);
				MelonLogger.Error("[GophxrCap] Stack trace: " + ex.StackTrace);
				return false;
			}
		}

		private static bool CreateClothingItem()
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ClothingItemDefinitionBuilder val = ClothingItemCreator.CloneFrom("cap");
				if (val == null)
				{
					MelonLogger.Error("[GophxrCap] Failed to clone base cap - 'cap' item not found");
					return false;
				}
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				Sprite val2 = ImageUtils.LoadImageFromResource(executingAssembly, "GophxrMod.Resources.GophxrCap.icon.png", 100f, (FilterMode)1);
				if (!RuntimeResourceRegistry.IsRegistered("GophxrMod/Accessories/GophxrCap"))
				{
					MelonLogger.Warning("[GophxrCap] Custom accessory not registered at 'GophxrMod/Accessories/GophxrCap'. Model may not load correctly.");
				}
				ClothingItemDefinition val3 = val.WithBasicInfo("gophxr_cap", "Gophxr Cap", "Gophxr's very own cap!").WithClothingAsset("GophxrMod/Accessories/GophxrCap").WithColorable(false)
					.WithDefaultColor((ClothingColor)0)
					.WithPricing(200f, 0.5f)
					.WithKeywords(new string[5] { "cap", "hat", "gophxr", "custom", "youtuber" })
					.WithLabelColor(new Color(0.2f, 0.6f, 1f))
					.Build();
				if ((ItemDefinition)(object)val3 == (ItemDefinition)null)
				{
					MelonLogger.Error("[GophxrCap] Failed to build clothing item");
					return false;
				}
				if ((Object)(object)val2 != (Object)null)
				{
					((ItemDefinition)val3).Icon = val2;
				}
				return true;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[GophxrCap] Failed to create clothing item: " + ex.Message);
				MelonLogger.Error("[GophxrCap] Stack trace: " + ex.StackTrace);
				return false;
			}
		}
	}
	public static class GophxrTShirtCreator
	{
		private const string ITEM_ID = "gophxr_tshirt";

		private const string ITEM_NAME = "Gophxr T-Shirt";

		private const string ITEM_DESCRIPTION = "A custom t-shirt featuring the Gophxr brand. Represent your favorite YouTuber!";

		private const string TEXTURE_RESOURCE_PATH = "GophxrMod.Resources.GophxrTShirt.gophxr_tshirt_texture.png";

		private const string ICON_RESOURCE_PATH = "GophxrMod.Resources.GophxrTShirt.icon.png";

		private const string CUSTOM_TSHIRT_RESOURCE_PATH = "GophxrMod/Clothing/GophxrTShirt";

		private const string SOURCE_TSHIRT_LAYER_PATH = "Avatar/Layers/Top/T-Shirt";

		public static void Initialize()
		{
			try
			{
				if (!RegisterCustomLayer())
				{
					MelonLogger.Error("[GophxrTShirt] Failed to register custom layer");
				}
				else if (!CreateClothingItem())
				{
					MelonLogger.Error("[GophxrTShirt] Failed to create clothing item");
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[GophxrTShirt] Initialization failed: " + ex.Message);
				MelonLogger.Error("[GophxrTShirt] Stack trace: " + ex.StackTrace);
			}
		}

		public static void AddToShops()
		{
			try
			{
				ItemDefinition itemDefinition = ItemManager.GetItemDefinition("gophxr_tshirt");
				if (itemDefinition == (ItemDefinition)null)
				{
					MelonLogger.Error("[GophxrTShirt] Item 'gophxr_tshirt' not found in registry");
					return;
				}
				ShopManager.AddToShops(itemDefinition, new string[1] { "Thrifty Threads" });
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[GophxrTShirt] Failed to add to shops: " + ex.Message);
			}
		}

		private static bool RegisterCustomLayer()
		{
			if (RuntimeResourceRegistry.IsRegistered("GophxrMod/Clothing/GophxrTShirt"))
			{
				DebugLog.Msg("[GophxrTShirt] Custom layer already registered, skipping");
				return true;
			}
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Texture2D val = TextureUtils.LoadTextureFromResource(executingAssembly, "GophxrMod.Resources.GophxrTShirt.gophxr_tshirt_texture.png", (FilterMode)1, (TextureWrapMode)1);
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("[GophxrTShirt] Failed to load custom texture from resources");
				return false;
			}
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)32;
			Type type = null;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				type = assembly.GetType("ScheduleOne.AvatarFramework.AvatarLayer") ?? assembly.GetType("Il2CppScheduleOne.AvatarFramework.AvatarLayer");
				if (type != null)
				{
					break;
				}
			}
			if (type == null)
			{
				MelonLogger.Error("[GophxrTShirt] Could not find AvatarLayer type");
				return false;
			}
			Object val2 = Resources.Load("Avatar/Layers/Top/T-Shirt");
			if (val2 == (Object)null)
			{
				MelonLogger.Error("[GophxrTShirt] Failed to load source layer at 'Avatar/Layers/Top/T-Shirt'");
				return false;
			}
			DebugLog.Msg("[GophxrTShirt] Source layer: type=" + ((object)val2).GetType().FullName);
			Object val3 = Object.Instantiate(val2);
			if (val3 == (Object)null)
			{
				MelonLogger.Error("[GophxrTShirt] Failed to clone source layer");
				return false;
			}
			Object.DontDestroyOnLoad(val3);
			val3.hideFlags = (HideFlags)32;
			DebugLog.Msg("[GophxrTShirt] Clone: type=" + ((object)val3).GetType().FullName);
			object obj = val3;
			if (!type.IsAssignableFrom(((object)val3).GetType()))
			{
				DebugLog.Msg("[GophxrTShirt] IL2CPP: creating typed wrapper (managed=" + ((object)val3).GetType().Name + ")");
				obj = CreateIl2CppTypedWrapper(val3, type);
				if (obj == null)
				{
					MelonLogger.Error("[GophxrTShirt] Failed to create IL2CPP typed wrapper");
					return false;
				}
			}
			bool flag = TrySetMember(type, obj, "Name", "GophxrTShirt", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			bool flag2 = TrySetMember(type, obj, "AssetPath", "GophxrMod/Clothing/GophxrTShirt", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			bool flag3 = TrySetMember(type, obj, "Texture", val, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			DebugLog.Msg($"[GophxrTShirt] Field set - Name: {flag}, AssetPath: {flag2}, Texture: {flag3}");
			Object val4 = (Object)(((obj is Object) ? obj : null) ?? val3);
			DebugLog.Msg("[GophxrTShirt] Registering: " + ((object)val4).GetType().FullName);
			RuntimeResourceRegistry.RegisterAsset("GophxrMod/Clothing/GophxrTShirt", val4);
			RuntimeResourceRegistry.RegisterAssetForType("GophxrMod/Clothing/GophxrTShirt", val4, type);
			return true;
		}

		private static object? CreateIl2CppTypedWrapper(Object sourceObject, Type targetType)
		{
			try
			{
				PropertyInfo propertyInfo = null;
				Type type = ((object)sourceObject).GetType();
				while (type != null)
				{
					propertyInfo = type.GetProperty("Pointer", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (propertyInfo != null)
					{
						break;
					}
					type = type.BaseType;
				}
				if (propertyInfo == null)
				{
					MelonLogger.Error("[GophxrTShirt] Could not find Pointer property on object hierarchy");
					return null;
				}
				object value = propertyInfo.GetValue(sourceObject);
				if (value == null)
				{
					MelonLogger.Error("[GophxrTShirt] Pointer value is null");
					return null;
				}
				ConstructorInfo constructor = targetType.GetConstructor(new Type[1] { typeof(IntPtr) });
				if (constructor == null)
				{
					MelonLogger.Error("[GophxrTShirt] No IntPtr constructor found on " + targetType.FullName);
					return null;
				}
				object obj = constructor.Invoke(new object[1] { value });
				DebugLog.Msg("[GophxrTShirt] Created typed wrapper: " + obj?.GetType().FullName);
				return obj;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("[GophxrTShirt] CreateIl2CppTypedWrapper failed: " + ex.Message);
				MelonLogger.Error("[GophxrTShirt] Stack trace: " + ex.StackTrace);
				return null;
			}
		}

		private static bool TrySetMember(Type type, object target, string memberName, object value, BindingFlags flags)
		{
			PropertyInfo property = type.GetProperty(memberName, flags);
			if (property != null && property.CanWrite)
			{
				try
				{
					property.SetValue(target, value);
					return true;
				}
				catch (Exception ex)
				{
					MelonLogger.Warning("[GophxrTShirt] Property '" + memberName + "' set failed: " + ex.Message);
				}
			}
			FieldInfo field = type.GetField(memberName, flags);
			if (field != null)
			{
				try
				{
					field.SetValue(target, value);
					return true;
				}
				catch (Exception ex2)
				{
					MelonLogger.Warning("[GophxrTShirt] Field '" + memberName + "' set failed: " + ex2.Message);
				}
			}
			return false;
		}

		private static bool CreateClothingItem()
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			ClothingItemDefinitionBuilder val = ClothingItemCreator.CloneFrom("tshirt");
			if (val == null)
			{
				MelonLogger.Error("[GophxrTShirt] Failed to clone base t-shirt - 'tshirt' item not found");
				return false;
			}
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Sprite val2 = ImageUtils.LoadImageFromResource(executingAssembly, "GophxrMod.Resources.GophxrTShirt.icon.png", 100f, (FilterMode)1);
			ClothingItemDefinition val3 = val.WithBasicInfo("gophxr_tshirt", "Gophxr T-Shirt", "A custom t-shirt featuring the Gophxr brand. Represent your favorite YouTuber!").WithClothingAsset("GophxrMod/Clothing/GophxrTShirt").WithColorable(false)
				.WithDefaultColor((ClothingColor)0)
				.WithPricing(500f, 0.5f)
				.WithKeywords(new string[5] { "tshirt", "shirt", "gophxr", "custom", "youtuber" })
				.WithLabelColor(new Color(0.2f, 0.6f, 1f))
				.Build();
			if ((ItemDefinition)(object)val3 == (ItemDefinition)null)
			{
				MelonLogger.Error("[GophxrTShirt] Failed to build clothing item");
				return false;
			}
			if ((Object)(object)val2 != (Object)null)
			{
				((ItemDefinition)val3).Icon = val2;
			}
			return true;
		}
	}
}
namespace GophxrMod.Utils
{
	public static class Constants
	{
		public static class Game
		{
			public const string GAME_STUDIO = "TVGS";

			public const string GAME_NAME = "Schedule I";
		}

		public const string MOD_NAME = "GophxrMod";

		public const string MOD_VERSION = "1.0.0";

		public const string MOD_AUTHOR = "HazDS";

		public const string PREFERENCES_CATEGORY = "GophxrMod";
	}
	public static class DebugLog
	{
		public static void Msg(string message)
		{
			if (Core.DebugLogsEnabled)
			{
				MelonLogger.Msg(message);
			}
		}

		public static void Warning(string message)
		{
			MelonLogger.Warning(message);
		}

		public static void Error(string message)
		{
			MelonLogger.Error(message);
		}
	}
	public class PositionLogger : BaseConsoleCommand
	{
		public override string CommandWord => "pos";

		public override string CommandDescription => "Logs the player's current world position.";

		public override string ExampleUsage => "pos";

		public override void ExecuteCommand(List<string> args)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Player_Local");
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Warning("[PositionLogger] Player not found.");
				return;
			}
			Vector3 position = val.transform.position;
			MelonLogger.Msg($"[PositionLogger] Position: new Vector3({position.x:F4}f, {position.y:F4}f, {position.z:F4}f)");
		}
	}
}