using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using HarmonyLib; using Il2Cpp; using Il2CppFishNet; using Il2CppFishNet.Broadcast; using Il2CppFishNet.Connection; using Il2CppFishNet.Managing; using Il2CppFishNet.Managing.Client; using Il2CppFishNet.Managing.Object; using Il2CppFishNet.Managing.Server; using Il2CppFishNet.Managing.Transporting; using Il2CppFishNet.Object; using Il2CppFishNet.Serializing; using Il2CppFishNet.Transporting; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.AvatarFramework.Animation; using Il2CppScheduleOne.AvatarFramework.Customization; using Il2CppScheduleOne.AvatarFramework.Equipping; using Il2CppScheduleOne.Building; using Il2CppScheduleOne.Calling; using Il2CppScheduleOne.Cartel; using Il2CppScheduleOne.Casino; using Il2CppScheduleOne.Clothing; using Il2CppScheduleOne.Combat; using Il2CppScheduleOne.Core.Equipping.Framework; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.Cutscenes; using Il2CppScheduleOne.Delivery; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Dialogue; using Il2CppScheduleOne.Doors; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.Effects; using Il2CppScheduleOne.Effects.MixMaps; using Il2CppScheduleOne.Employees; using Il2CppScheduleOne.EntityFramework; using Il2CppScheduleOne.Equipping; using Il2CppScheduleOne.Equipping.Framework; using Il2CppScheduleOne.GameTime; using Il2CppScheduleOne.Graffiti; using Il2CppScheduleOne.Growing; using Il2CppScheduleOne.Interaction; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Law; using Il2CppScheduleOne.Levelling; using Il2CppScheduleOne.Management; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.Messaging; using Il2CppScheduleOne.Misc; using Il2CppScheduleOne.Money; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.Actions; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.NPCs.Framework; using Il2CppScheduleOne.NPCs.Other; using Il2CppScheduleOne.NPCs.Relation; using Il2CppScheduleOne.NPCs.Responses; using Il2CppScheduleOne.NPCs.Schedules; using Il2CppScheduleOne.Noise; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.Persistence.Datas; using Il2CppScheduleOne.Persistence.Loaders; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.PlayerScripts.Health; using Il2CppScheduleOne.Police; using Il2CppScheduleOne.Product; using Il2CppScheduleOne.Product.Packaging; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.ScriptableObjects; using Il2CppScheduleOne.StationFramework; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.TV; using Il2CppScheduleOne.Tiles; using Il2CppScheduleOne.Tools; using Il2CppScheduleOne.Trash; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Items; using Il2CppScheduleOne.UI.MainMenu; using Il2CppScheduleOne.UI.Phone; using Il2CppScheduleOne.UI.Phone.ContactsApp; using Il2CppScheduleOne.UI.Phone.Delivery; using Il2CppScheduleOne.UI.Phone.Map; using Il2CppScheduleOne.UI.Phone.Messages; using Il2CppScheduleOne.UI.Phone.ProductManagerApp; using Il2CppScheduleOne.UI.Relations; using Il2CppScheduleOne.UI.Shop; using Il2CppScheduleOne.UI.Stations; using Il2CppScheduleOne.UI.WorldspacePopup; using Il2CppScheduleOne.Variables; using Il2CppScheduleOne.Vehicles; using Il2CppScheduleOne.Vehicles.Modification; using Il2CppScheduleOne.Vision; using Il2CppScheduleOne.VoiceOver; using Il2CppSystem; using Il2CppSystem.Collections; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using S1API; using S1API.AssetBundles; using S1API.Avatar; using S1API.Building; using S1API.Casino; using S1API.Conditions; using S1API.Console; using S1API.Cutscenes; using S1API.DeadDrops; using S1API.Deliveries; using S1API.Dialogues; using S1API.Economy; using S1API.Entities; using S1API.Entities.Actions; using S1API.Entities.Appearances.AccessoryFields; using S1API.Entities.Appearances.Base; using S1API.Entities.Appearances.BodyLayerFields; using S1API.Entities.Appearances.CustomizationFields; using S1API.Entities.Appearances.FaceLayerFields; using S1API.Entities.Behaviour; using S1API.Entities.Customer; using S1API.Entities.Dealer; using S1API.Entities.Dialogue; using S1API.Entities.Equippables; using S1API.Entities.Impostors; using S1API.Entities.Interfaces; using S1API.Entities.Relation; using S1API.Entities.Schedule; using S1API.Entities.Supplier; using S1API.Entities.Voices; using S1API.GameTime; using S1API.Graffiti; using S1API.Growing; using S1API.Internal; using S1API.Internal.Abstraction; using S1API.Internal.Console; using S1API.Internal.Cutscenes; using S1API.Internal.Deliveries; using S1API.Internal.Diagnostics; using S1API.Internal.Entities; using S1API.Internal.Entities.Suppliers; using S1API.Internal.Items; using S1API.Internal.Lifecycle; using S1API.Internal.Map; using S1API.Internal.NPCWorkbench; using S1API.Internal.Patches; using S1API.Internal.Phone; using S1API.Internal.Products; using S1API.Internal.Properties; using S1API.Internal.Rendering; using S1API.Internal.Shops; using S1API.Internal.Utils; using S1API.Items; using S1API.Items.Additive; using S1API.Items.Buildable; using S1API.Items.Clothing; using S1API.Items.Quality; using S1API.Items.Storable; using S1API.Law; using S1API.Leveling; using S1API.Lifecycle; using S1API.Logging; using S1API.Map; using S1API.Map.Buildings; using S1API.Map.DeliveryLocations; using S1API.Messaging; using S1API.Money; using S1API.PhoneApp; using S1API.PhoneCalls; using S1API.PhoneCalls.Constants; using S1API.Products; using S1API.Products.Packaging; using S1API.Properties; using S1API.Properties.Interfaces; using S1API.Properties.Tokens; using S1API.Property; using S1API.Quests; using S1API.Quests.Constants; using S1API.Quests.Identifiers; using S1API.Rendering; using S1API.Saveables; using S1API.Shops; using S1API.Stations; using S1API.Storage; using S1API.Storages; using S1API.TVApp; using S1API.Trash; using S1API.Utils; using S1API.Vehicles; using UnityEngine; using UnityEngine.AI; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: InternalsVisibleTo("S1API.Tests")] [assembly: InternalsVisibleTo("S1API.CustomProductLifecycleSmoke")] [assembly: MelonInfo(typeof(global::S1API.S1API), "S1API (Forked by Bars)", "3.1.8", "KaBooMa", null)] [assembly: MelonPriority(int.MinValue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ifBars")] [assembly: AssemblyConfiguration("Il2CppMelon")] [assembly: AssemblyDescription("A Schedule One Mono / Il2Cpp Cross Compatibility Layer (Forked from the original S1API by Kabooma)")] [assembly: AssemblyFileVersion("3.1.8.0")] [assembly: AssemblyInformationalVersion("3.1.8+445586c624144aaaaf08ada54621558064b0ab7a")] [assembly: AssemblyProduct("S1API")] [assembly: AssemblyTitle("S1API")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ifBars/S1API")] [assembly: AssemblyVersion("3.1.8.0")] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [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; } } } public class ClickHandler { private readonly UnityAction _callback; public ClickHandler(UnityAction callback) { _callback = callback; } public void OnClick() { _callback.Invoke(); } } namespace S1API { public class S1API : MelonMod { public override void OnInitializeMelon() { S1APIPreferences.Initialize(); MelonPreferences_Entry? enableUnityNullReferenceTraceLogging = S1APIPreferences.EnableUnityNullReferenceTraceLogging; if (enableUnityNullReferenceTraceLogging != null && enableUnityNullReferenceTraceLogging.Value) { MelonLogger.Warning("Exception trace logging is enabled. If you are not a mod developer, you probably do not need this enabled."); UnityExceptionTraceHook.Install(); } } public override void OnDeinitializeMelon() { NPCWorkbenchRuntime.Close(); PresentationWorkbenchRuntime.Close(); ProductPackagingContentRuntime.ResetForSceneChange(); CutsceneManager.Deinitialize(); MapPOIManager.RemoveAll(); UnityExceptionTraceHook.Remove(); } public override void OnUpdate() { PresentationWorkbenchRuntime.Tick(); CutsceneManager.Tick(Time.unscaledDeltaTime); NPCWorkbenchRuntime.Tick(); } public override void OnGUI() { CutsceneManager.DrawPresentation(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (sceneName == "Main") { GameLifecycle.Initialize(); } } public override void OnSceneWasUnloaded(int buildIndex, string sceneName) { NPCWorkbenchRuntime.Close(); PresentationWorkbenchRuntime.Close(); CutsceneManager.CleanupForSceneChange(); SceneStateCleaner.ResetForSceneChange(sceneName, afterUnload: true); if (sceneName == "Main" || sceneName == "Tutorial") { ProductPackagingContentRuntime.ResetForSceneChange(); MapPOIManager.ResetForSceneChange(); } if (sceneName == "Main") { GameLifecycle.Reset(); } } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { NPCNetworkBootstrap.EnsurePrefabsWarmup(); SceneStateCleaner.ResetForSceneChange(sceneName, afterUnload: false); } } } namespace S1API.Vehicles { public class LandVehicle { internal LandVehicle S1LandVehicle = null; internal bool _isDeferredByName = false; internal StorageInstance? _storage; private static readonly Log _logger = new Log("S1API.LandVehicle"); private static readonly FieldInfo? VehiclePriceField = typeof(LandVehicle).GetField("vehiclePrice", BindingFlags.NonPublic); private NetworkConnection? _conn; private string _guid = string.Empty; public float VehiclePrice { get { return S1LandVehicle.VehiclePrice; } set { VehiclePriceField?.SetValue(S1LandVehicle, value); } } public float TopSpeed { get { return S1LandVehicle.TopSpeed; } set { S1LandVehicle.TopSpeed = value; } } public bool IsPlayerOwned { get { return S1LandVehicle.IsPlayerOwned; } set { SetIsPlayerOwned(value); } } public bool IsOccupied { get { return S1LandVehicle.IsOccupied; } set { S1LandVehicle.IsOccupied = value; } } public VehicleColor Color { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected I4, but got Unknown return (VehicleColor)S1LandVehicle.OwnedColor; } set { SetColor(value); } } public string GUID => _guid; public StorageInstance? Storage => _storage; public event Action OnVehicleStart { add { LandVehicle s1LandVehicle = S1LandVehicle; s1LandVehicle.onVehicleStart += Action.op_Implicit(value); } remove { LandVehicle s1LandVehicle = S1LandVehicle; s1LandVehicle.onVehicleStart -= Action.op_Implicit(value); } } public event Action OnVehicleStop { add { LandVehicle s1LandVehicle = S1LandVehicle; s1LandVehicle.onVehicleStop += Action.op_Implicit(value); } remove { LandVehicle s1LandVehicle = S1LandVehicle; s1LandVehicle.onVehicleStop -= Action.op_Implicit(value); } } public event Action OnHandbrakeApplied { add { LandVehicle s1LandVehicle = S1LandVehicle; s1LandVehicle.onHandbrakeApplied += Action.op_Implicit(value); } remove { LandVehicle s1LandVehicle = S1LandVehicle; s1LandVehicle.onHandbrakeApplied -= Action.op_Implicit(value); } } public event Action OnCollision { add { LandVehicle s1LandVehicle = S1LandVehicle; s1LandVehicle.onCollision += Action.op_Implicit(value); } remove { LandVehicle s1LandVehicle = S1LandVehicle; s1LandVehicle.onCollision -= Action.op_Implicit(value); } } public LandVehicle(string vehicleCode) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) LandVehicle vehiclePrefab = NetworkSingleton.Instance.GetVehiclePrefab(vehicleCode); if ((Object)(object)vehiclePrefab == (Object)null) { _logger.Error("SpawnVehicle: '" + vehicleCode + "' is not a valid vehicle code!"); return; } LandVehicle component = Object.Instantiate(((Component)vehiclePrefab).gameObject).GetComponent(); component.SetGUID(GUIDManager.GenerateUniqueGUID()); NetworkSingleton.Instance.AllVehicles.Add(component); S1LandVehicle = component; SetConnection(); UpdateGuidFromGame(); _storage = new StorageInstance(component.Storage); } public void Spawn(Vector3 position, Quaternion rotation) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!InstanceFinder.IsServer) { _logger.Warning("Spawn can only be called on the server!"); return; } if ((Object)(object)S1LandVehicle == (Object)null) { throw new Exception("Unable to spawn vehicle, S1LandVehicle is null!"); } ((Component)S1LandVehicle).transform.position = position; ((Component)S1LandVehicle).transform.rotation = rotation; ((NetworkBehaviour)NetworkSingleton.Instance).Spawn(((Component)S1LandVehicle).gameObject, (NetworkConnection)null, default(Scene)); } public void AlignTo(Transform target, ParkingAlignment type, bool network = false) { if ((Object)(object)S1LandVehicle == (Object)null) { throw new Exception("Unable to align to position, S1LandVehicle is null!"); } S1LandVehicle.AlignTo(target, (EParkingAlignment)type, network); } public void ExitPark(bool moveToExitPoint = true) { S1LandVehicle.ExitPark(moveToExitPoint); } public void SetVisible(bool vis) { S1LandVehicle.SetVisible(vis); } public void DestroyVehichle() { S1LandVehicle.DestroyVehicle(); } public void ApplyColor(VehicleColor col) { S1LandVehicle.ApplyColor((EVehicleColor)col); } public void Park(ParkingData parkData, bool network) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown ParkData val = new ParkData { lotGUID = Guid.Parse(parkData.LotId), spotIndex = parkData.Index, alignment = (EParkingAlignment)parkData.Alignment }; S1LandVehicle.Park(_conn, val, network); } internal LandVehicle(LandVehicle landVehicle) { S1LandVehicle = landVehicle; SetConnection(); UpdateGuidFromGame(); _storage = new StorageInstance(landVehicle.Storage); _isDeferredByName = false; } internal LandVehicle(string vehicleName, bool isDeferred) { _isDeferredByName = isDeferred; } private void SetConnection() { NetworkManager networkManager = InstanceFinder.NetworkManager; if (networkManager.IsClientOnly) { NetworkConnection connection = InstanceFinder.ClientManager.Connection; if (connection != (NetworkConnection)null && connection.IsValid) { _conn = connection; } } else if (networkManager.IsServerOnly || (networkManager.IsServer && !networkManager.IsClient)) { NetworkConnection owner = ((NetworkBehaviour)S1LandVehicle).Owner; if (owner != (NetworkConnection)null && owner.IsValid) { _conn = owner; } } } private void SetIsPlayerOwned(bool isPlayerOwned) { S1LandVehicle.SetIsPlayerOwned(_conn, isPlayerOwned); if (isPlayerOwned) { NetworkSingleton.Instance.PlayerOwnedVehicles.Add(S1LandVehicle); } else { NetworkSingleton.Instance.PlayerOwnedVehicles.Remove(S1LandVehicle); } } private void SetColor(VehicleColor color) { MethodInfo method = typeof(LandVehicle).GetMethod("SetOwnedColor", BindingFlags.Instance | BindingFlags.NonPublic); if (method == null) { _logger.Error("SetOwnedColor method not found!"); return; } method.Invoke(S1LandVehicle, new object[2] { _conn, (object)(EVehicleColor)color }); } private void UpdateGuidFromGame() { //IL_0044: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) try { PropertyInfo property = typeof(LandVehicle).GetProperty("GUID", BindingFlags.Instance | BindingFlags.Public); if (!(property == null)) { _guid = ((object)(Guid)(property.GetValue(S1LandVehicle) ?? ((object)default(Guid)))/*cast due to .constrained prefix*/).ToString(); } } catch { } } } public enum ParkingAlignment { FrontToKerb, RearToKerb } public enum VehicleColor { Black, DarkGrey, LightGrey, White, Yellow, Orange, Red, DullRed, Pink, Purple, Navy, DarkBlue, LightBlue, Cyan, LightGreen, DarkGreen, Custom } public static class VehicleRegistry { private static readonly Dictionary _cache = new Dictionary(); public static LandVehicle[] GetAll() { try { List allVehicles = NetworkSingleton.Instance.AllVehicles; if (allVehicles == null) { return Array.Empty(); } List list = new List(); Enumerator enumerator = allVehicles.GetEnumerator(); while (enumerator.MoveNext()) { LandVehicle current = enumerator.Current; if ((Object)(object)current != (Object)null) { LandVehicle landVehicle = Wrap(current); if (landVehicle != null) { list.Add(landVehicle); } } } return list.ToArray(); } catch { return Array.Empty(); } } public static LandVehicle? GetByGUID(string guid) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(guid)) { return null; } try { Guid val = default(Guid); ((Guid)(ref val))..ctor(guid); LandVehicle val2 = GUIDManager.GetObject(val); if ((Object)(object)val2 == (Object)null) { return null; } return Wrap(val2); } catch { return null; } } public static LandVehicle? GetByName(string gameObjectName) { if (string.IsNullOrEmpty(gameObjectName)) { return null; } try { GameObject val = GameObject.Find(gameObjectName); if ((Object)(object)val != (Object)null) { LandVehicle component = val.GetComponent(); if ((Object)(object)component != (Object)null) { return Wrap(component); } } List allVehicles = NetworkSingleton.Instance.AllVehicles; if (allVehicles != null) { for (int i = 0; i < allVehicles.Count; i++) { LandVehicle val2 = allVehicles[i]; if ((Object)(object)val2 != (Object)null && ((Object)((Component)val2).gameObject).name == gameObjectName) { return Wrap(val2); } } } if (DeferredMapResolver.IsMenuScene()) { LandVehicle deferredVehicle = new LandVehicle(gameObjectName, isDeferred: true); DeferredMapResolver.RegisterDeferredLookup(new DeferredLookup(gameObjectName, delegate(object resolved) { if (resolved is LandVehicle landVehicle && landVehicle != null && (Object)(object)landVehicle.S1LandVehicle != (Object)null) { deferredVehicle.S1LandVehicle = landVehicle.S1LandVehicle; deferredVehicle._isDeferredByName = false; } })); return deferredVehicle; } return null; } catch { return null; } } public static LandVehicle? CreateVehicle(string vehicleCode) { if (!string.IsNullOrEmpty(vehicleCode)) { try { return new LandVehicle(vehicleCode); } catch { return null; } } return null; } public static void RemoveVehicle(string guidString) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(guidString)) { return; } VehicleManager instance = NetworkSingleton.Instance; if ((Object)(object)instance == (Object)null) { return; } Guid val = default(Guid); ((Guid)(ref val))..ctor(guidString); int? num = null; LandVehicle val2 = null; List allVehicles = instance.AllVehicles; Guid gUID; if (allVehicles != null) { for (int i = 0; i < allVehicles.Count; i++) { LandVehicle obj = allVehicles[i]; if (obj != null) { gUID = obj.GUID; if (((Guid)(ref gUID)).Equals(val)) { num = i; val2 = allVehicles[i]; break; } } } } int? num2 = null; List playerOwnedVehicles = instance.PlayerOwnedVehicles; if (playerOwnedVehicles != null) { for (int j = 0; j < playerOwnedVehicles.Count; j++) { LandVehicle obj2 = playerOwnedVehicles[j]; if (obj2 != null) { gUID = obj2.GUID; if (((Guid)(ref gUID)).Equals(val)) { num2 = j; break; } } } } if (num.HasValue) { allVehicles?.RemoveAt(num.Value); } if (num2.HasValue) { playerOwnedVehicles?.RemoveAt(num2.Value); } if ((Object)(object)val2 != (Object)null && _cache.ContainsKey(val2)) { _cache.Remove(val2); } } private static LandVehicle? Wrap(LandVehicle? veh) { if ((Object)(object)veh == (Object)null) { return null; } if (_cache.TryGetValue(veh, out LandVehicle value)) { return value; } LandVehicle landVehicle = new LandVehicle(veh); _cache[veh] = landVehicle; return landVehicle; } } } namespace S1API.Utils { public static class ArrayExtensions { public static T[] AddItemToArray(this T[]? array, T item) { return global::S1API.Internal.Utils.ArrayExtensions.AddItemToArray(array, item); } public static Il2CppReferenceArray AddItemToArray(this Il2CppReferenceArray? array, params T[]? itemsToAdd) where T : Object { return global::S1API.Internal.Utils.ArrayExtensions.AddItemToArray(array, itemsToAdd); } } public static class ButtonUtils { public static void AddListener(Button button, Action action) { global::S1API.Internal.Utils.ButtonUtils.AddListener(button, action); } public static void RemoveListener(Button button, Action action) { global::S1API.Internal.Utils.ButtonUtils.RemoveListener(button, action); } public static void ClearListeners(Button button) { global::S1API.Internal.Utils.ButtonUtils.ClearListeners(button); } public static void Enable(Button button, Text? label = null, string? text = null) { global::S1API.Internal.Utils.ButtonUtils.Enable(button, label, text); } public static void Disable(Button button, Text? label = null, string? text = null) { global::S1API.Internal.Utils.ButtonUtils.Disable(button, label, text); } public static void SetLabel(Text label, string text) { global::S1API.Internal.Utils.ButtonUtils.SetLabel(label, text); } public static void SetStyle(Button button, Text label, string text, Color bg) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) global::S1API.Internal.Utils.ButtonUtils.SetStyle(button, label, text, bg); } } public static class ColorUtils { public static Color ToColor(this uint hexColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return global::S1API.Internal.Utils.ColorUtils.ToColorInternal(hexColor); } } public static class EventHelper { internal static void AddListener(Action listener, Action subscribe) { global::S1API.Internal.Abstraction.EventHelper.AddListener(listener, subscribe); } internal static void RemoveListener(Action listener, Action unsubscribe) { global::S1API.Internal.Abstraction.EventHelper.RemoveListener(listener, unsubscribe); } public static void AddListener(Action listener, UnityEvent unityEvent) { global::S1API.Internal.Abstraction.EventHelper.AddListener(listener, unityEvent); } public static void RemoveListener(Action listener, UnityEvent unityEvent) { global::S1API.Internal.Abstraction.EventHelper.RemoveListener(listener, unityEvent); } public static void AddListener(Action listener, UnityEvent unityEvent) { global::S1API.Internal.Abstraction.EventHelper.AddListener(listener, unityEvent); } public static void RemoveListener(Action listener, UnityEvent unityEvent) { global::S1API.Internal.Abstraction.EventHelper.RemoveListener(listener, unityEvent); } public static void AddEventTrigger(EventTrigger trigger, EventTriggerType eventType, Action listener) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) global::S1API.Internal.Abstraction.EventHelper.AddEventTrigger(trigger, eventType, listener); } public static void AddEventTrigger(EventTrigger trigger, EventTriggerType eventType, Action listener) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) global::S1API.Internal.Abstraction.EventHelper.AddEventTrigger(trigger, eventType, listener); } public static void RemoveEventTrigger(EventTrigger trigger, EventTriggerType eventType, Action listener) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) global::S1API.Internal.Abstraction.EventHelper.RemoveEventTrigger(trigger, eventType, listener); } } public static class ImageUtils { public static Sprite? LoadImage(string fileName) { return global::S1API.Internal.Utils.ImageUtils.LoadImage(fileName); } public static Sprite? LoadImageRaw(byte[] data) { return global::S1API.Internal.Utils.ImageUtils.LoadImageRaw(data); } public static Sprite? TextureToSprite(Texture2D? texture, float pixelsPerUnit = 100f) { return global::S1API.Internal.Utils.ImageUtils.TextureToSprite(texture, pixelsPerUnit); } public static Sprite? LoadImageFromResource(Assembly assembly, string resourceName, float pixelsPerUnit = 100f, FilterMode filterMode = (FilterMode)1) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return global::S1API.Internal.Utils.ImageUtils.LoadImageFromResource(assembly, resourceName, pixelsPerUnit, filterMode); } } public static class RandomUtils { public static T PickOne(this IList list) { return global::S1API.Internal.Utils.RandomUtils.PickOne(list); } public static T PickUnique(this IList list, Func isDuplicate, int maxTries = 10) { return global::S1API.Internal.Utils.RandomUtils.PickUnique(list, isDuplicate, maxTries); } public static List PickMany(this IList list, int count) { return global::S1API.Internal.Utils.RandomUtils.PickMany(list, count); } public static int RangeInt(int minInclusive, int maxExclusive) { return global::S1API.Internal.Utils.RandomUtils.RangeInt(minInclusive, maxExclusive); } } public static class ReflectionUtils { public static MethodInfo? GetMethod(Type? type, string methodName, BindingFlags bindingFlags) { return global::S1API.Internal.Utils.ReflectionUtils.GetMethod(type, methodName, bindingFlags); } public static bool IsValueTuple(this object obj) { return global::S1API.Internal.Utils.ReflectionUtils.IsValueTuple(obj); } public static object?[]? GetValueTupleItems(this object obj) { return global::S1API.Internal.Utils.ReflectionUtils.GetValueTupleItems(obj); } public static bool TrySetFieldOrProperty(object target, string memberName, object? value) { return global::S1API.Internal.Utils.ReflectionUtils.TrySetFieldOrProperty(target, memberName, value); } public static object? TryGetFieldOrProperty(object target, string memberName) { return global::S1API.Internal.Utils.ReflectionUtils.TryGetFieldOrProperty(target, memberName); } } public static class ToggleUtils { public static void AddListener(Toggle toggle, Action listener) { global::S1API.Internal.Utils.ToggleUtils.AddListener(toggle, listener); } public static void RemoveListener(Toggle toggle, Action listener) { global::S1API.Internal.Utils.ToggleUtils.RemoveListener(toggle, listener); } public static void ClearListeners(Toggle toggle) { global::S1API.Internal.Utils.ToggleUtils.ClearListeners(toggle); } public static void SetGraphic(Toggle toggle, Graphic graphic) { global::S1API.Internal.Utils.ToggleUtils.SetGraphic(toggle, graphic); } public static Graphic? GetGraphic(Toggle toggle) { return global::S1API.Internal.Utils.ToggleUtils.GetGraphic(toggle); } } public static class TransformUtils { public static Transform? FindDescendant(Transform root, string name) { return global::S1API.Internal.Utils.TransformUtils.FindDescendant(root, name); } } } namespace S1API.UI { public static class CharacterCreatorManager { private static readonly Log Logger = new Log("CharacterCreatorManager"); private static CharacterCreator? _s1Creator; private static bool _isInitialized; private static bool _eventsRegistered; public static bool IsOpen { get { EnsureInitialized(); CharacterCreator? s1Creator = _s1Creator; return s1Creator != null && s1Creator.IsOpen; } } public static BasicAvatarSettings? ActiveSettings { get { EnsureInitialized(); CharacterCreator? s1Creator = _s1Creator; if ((Object)(object)((s1Creator != null) ? s1Creator.ActiveSettings : null) == (Object)null) { return null; } return new BasicAvatarSettings(_s1Creator.ActiveSettings); } } public static event Action? OnOpened; public static event Action? OnClosed; public static event Action? OnCompleted; public static void Open(BasicAvatarSettings? initialSettings = null, bool showUI = true) { EnsureInitialized(); if ((Object)(object)_s1Creator == (Object)null) { Logger.Error("CharacterCreator singleton is not available"); return; } if (_s1Creator.IsOpen) { Logger.Warning("CharacterCreator is already open"); return; } RegisterEvents(); if (initialSettings == null) { initialSettings = GetPlayerAvatarSettings(); } BasicAvatarSettings val = initialSettings?.S1BasicAvatarSettings; _s1Creator.Open(val); if (!showUI && (Object)(object)_s1Creator.Canvas != (Object)null) { ((Behaviour)_s1Creator.Canvas).enabled = false; } try { CharacterCreatorManager.OnOpened?.Invoke(); } catch (Exception value) { Logger.Error($"Error in OnOpened event handler: {value}"); } } public static void Close() { EnsureInitialized(); if ((Object)(object)_s1Creator == (Object)null) { Logger.Error("CharacterCreator singleton is not available"); return; } if (!_s1Creator.IsOpen) { Logger.Warning("CharacterCreator is not open"); return; } _s1Creator.Close(); MelonCoroutines.Start(RestoreAfterClose()); try { CharacterCreatorManager.OnClosed?.Invoke(); } catch (Exception value) { Logger.Error($"Error in OnClosed event handler: {value}"); } } public static void Complete() { EnsureInitialized(); if ((Object)(object)_s1Creator == (Object)null) { Logger.Error("CharacterCreator singleton is not available"); } else if (!_s1Creator.IsOpen) { Logger.Warning("CharacterCreator is not open"); } else { _s1Creator.Done(); } } public static void SelectPreset(string presetName) { EnsureInitialized(); if ((Object)(object)_s1Creator == (Object)null) { Logger.Error("CharacterCreator singleton is not available"); } else if (!_s1Creator.IsOpen) { Logger.Warning("CharacterCreator must be open to select a preset"); } else if (string.IsNullOrWhiteSpace(presetName)) { Logger.Warning("Preset name cannot be null or empty"); } else { _s1Creator.SelectPreset(presetName); } } public static string[] GetAvailablePresets() { EnsureInitialized(); if ((Object)(object)_s1Creator == (Object)null || _s1Creator.Presets == null) { return Array.Empty(); } List list = new List(); for (int i = 0; i < _s1Creator.Presets.Count; i++) { BasicAvatarSettings val = _s1Creator.Presets[i]; if ((Object)(object)val != (Object)null && !string.IsNullOrWhiteSpace(((Object)val).name)) { list.Add(((Object)val).name); } } return list.ToArray(); } public static void SetRigRotation(float normalizedValue) { EnsureInitialized(); if ((Object)(object)_s1Creator == (Object)null) { Logger.Error("CharacterCreator singleton is not available"); } else if (!_s1Creator.IsOpen) { Logger.Warning("CharacterCreator must be open to set rig rotation"); } else { _s1Creator.SliderChanged(Mathf.Clamp01(normalizedValue)); } } public static void PreRegisterAsActiveUI() { EnsureInitialized(); if ((Object)(object)_s1Creator == (Object)null) { Logger.Warning("CharacterCreator singleton is not available for pre-registration"); } else if (PlayerSingleton.InstanceExists) { PlayerSingleton.Instance.AddActiveUIElement(((Object)_s1Creator).name); } } private static void EnsureInitialized() { if (_isInitialized) { return; } try { _s1Creator = Singleton.Instance; if ((Object)(object)_s1Creator == (Object)null) { Logger.Warning("CharacterCreator singleton not found. Make sure you're in the correct scene."); } _isInitialized = true; } catch (Exception value) { Logger.Error($"Failed to initialize CharacterCreatorManager: {value}"); _isInitialized = true; } } private static void RegisterEvents() { if (_eventsRegistered || (Object)(object)_s1Creator == (Object)null) { return; } try { if (_s1Creator.onComplete != null) { _s1Creator.onComplete.AddListener(UnityAction.op_Implicit((Action)OnCreatorCompleted)); } _eventsRegistered = true; } catch (Exception value) { Logger.Error($"Failed to register CharacterCreator events: {value}"); } } private static void OnCreatorCompleted(BasicAvatarSettings s1Settings) { try { if ((Object)(object)s1Settings == (Object)null) { Logger.Warning("CharacterCreator completed with null settings"); return; } BasicAvatarSettings obj = new BasicAvatarSettings(s1Settings); MelonCoroutines.Start(RestoreGameState()); CharacterCreatorManager.OnCompleted?.Invoke(obj); } catch (Exception value) { Logger.Error($"Error in OnCompleted event handler: {value}"); } } private static IEnumerator RestoreAfterClose() { yield return RestoreGameState(); } private static IEnumerator RestoreGameState() { yield return null; yield return (object)new WaitForSeconds(0.1f); if (PlayerSingleton.InstanceExists) { PlayerCamera camera = PlayerSingleton.Instance; CharacterCreator? s1Creator = _s1Creator; camera.RemoveActiveUIElement(((s1Creator != null) ? ((Object)s1Creator).name : null) ?? "CharacterCreator"); if (GetActiveUIElementCount(camera) == 0) { camera.StopTransformOverride(0f, true, false); camera.StopFOVOverride(0f); camera.SetCanLook(true); camera.LockMouse(true); } } if (PlayerSingleton.InstanceExists) { PlayerSingleton.Instance.CanMove = true; } if (PlayerSingleton.InstanceExists) { PlayerSingleton.Instance.SetInventoryEnabled(true); } if (Singleton.InstanceExists) { ((Behaviour)Singleton.Instance.canvas).enabled = true; } } private static BasicAvatarSettings? GetPlayerAvatarSettings() { try { Player local = Player.Local; if (local == null || (Object)(object)local.S1Player == (Object)null) { Logger.Warning("Local player not available"); return null; } BasicAvatarSettings currentBasicAvatarSettings = local.GetCurrentBasicAvatarSettings(); if (currentBasicAvatarSettings == null) { Logger.Debug("Player has no current avatar settings, using default"); return null; } BasicAvatarSettings settings = Object.Instantiate(currentBasicAvatarSettings.S1BasicAvatarSettings); return new BasicAvatarSettings(settings); } catch (Exception value) { Logger.Error($"Failed to get player avatar settings: {value}"); return null; } } private static int GetActiveUIElementCount(PlayerCamera camera) { if ((Object)(object)camera == (Object)null) { return 0; } if (global::S1API.Internal.Utils.ReflectionUtils.TryGetFieldOrProperty(camera, "ActiveUIElementCount") is int result) { return result; } return 0; } } public sealed class MainMenuRig { internal readonly MainMenuRig S1MainMenuRig; public global::S1API.Avatar.Avatar? Avatar { get { if ((Object)(object)S1MainMenuRig == (Object)null || (Object)(object)S1MainMenuRig.Avatar == (Object)null) { return null; } return new global::S1API.Avatar.Avatar(S1MainMenuRig.Avatar); } } internal MainMenuRig(MainMenuRig mainMenuRig) { S1MainMenuRig = mainMenuRig; } public static MainMenuRig[] FindInScene(bool includeInactive = false) { Il2CppArrayBase val = Object.FindObjectsOfType(includeInactive); if (val == null || val.Length == 0) { return Array.Empty(); } return (from r in (IEnumerable)val where (Object)(object)r != (Object)null select new MainMenuRig(r)).ToArray(); } } public static class UIFactory { private static Sprite? roundedSprite; public static GameObject Panel(string name, Transform parent, Color bgColor, Vector2? anchorMin = null, Vector2? anchorMax = null, bool fullAnchor = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); if (fullAnchor) { val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; } else { val2.anchorMin = (Vector2)(((??)anchorMin) ?? new Vector2(0.5f, 0.5f)); val2.anchorMax = (Vector2)(((??)anchorMax) ?? new Vector2(0.5f, 0.5f)); } Image val3 = val.AddComponent(); ((Graphic)val3).color = bgColor; return val; } public static Text Text(string name, string content, Transform parent, int fontSize = 14, TextAnchor anchor = (TextAnchor)0, FontStyle style = (FontStyle)0) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); Text val3 = val.AddComponent(); val3.text = content; val3.fontSize = fontSize; val3.alignment = anchor; val3.fontStyle = style; val3.font = Resources.GetBuiltinResource("Arial.ttf"); ((Graphic)val3).color = Color.white; val3.horizontalOverflow = (HorizontalWrapMode)0; val3.verticalOverflow = (VerticalWrapMode)1; return val3; } public static RectTransform ScrollableVerticalList(string name, Transform parent, out ScrollRect scrollRect) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0123: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; scrollRect = val.AddComponent(); scrollRect.horizontal = false; GameObject val3 = new GameObject("Viewport"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; ((Graphic)val3.AddComponent()).color = new Color(0f, 0f, 0f, 0.05f); val3.AddComponent().showMaskGraphic = false; scrollRect.viewport = val4; GameObject val5 = new GameObject("Content"); val5.transform.SetParent(val3.transform, false); RectTransform val6 = val5.AddComponent(); val6.anchorMin = new Vector2(0f, 1f); val6.anchorMax = new Vector2(1f, 1f); val6.pivot = new Vector2(0.5f, 1f); VerticalLayoutGroup val7 = val5.AddComponent(); ((HorizontalOrVerticalLayoutGroup)val7).spacing = 10f; ((LayoutGroup)val7).padding = new RectOffset(10, 10, 10, 10); ((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val7).childForceExpandHeight = false; val5.AddComponent().verticalFit = (FitMode)2; scrollRect.content = val6; return val6; } public static void FitContentHeight(RectTransform content) { ContentSizeFitter val = ((Component)content).gameObject.GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)content).gameObject.AddComponent(); } val.verticalFit = (FitMode)2; } public static (GameObject, Button, Text) RoundedButtonWithLabel(string name, string label, Transform parent, Color bgColor, float width, float height, int fontSize, Color textColor) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name + "_RoundedMask"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent(); val2.sizeDelta = new Vector2(width, height); LayoutElement val3 = val.AddComponent(); val3.preferredWidth = width; val3.preferredHeight = height; Image val4 = val.AddComponent(); val4.sprite = GetRoundedSprite(); val4.type = (Type)1; ((Graphic)val4).color = Color.white; Mask val5 = val.AddComponent(); val5.showMaskGraphic = true; GameObject val6 = new GameObject(name); val6.transform.SetParent(val.transform, false); RectTransform val7 = val6.AddComponent(); val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = Vector2.zero; val7.offsetMax = Vector2.zero; Image val8 = val6.AddComponent(); ((Graphic)val8).color = bgColor; val8.sprite = GetRoundedSprite(); val8.type = (Type)1; Button val9 = val6.AddComponent