Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of S1API v1.6.2
Mods/S1API.Mono.BepInEx.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using BepInEx.Unity.Mono; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using S1API.Conditions; using S1API.Dialogues; using S1API.Entities; using S1API.Entities.Interfaces; using S1API.GameTime; using S1API.Internal.Abstraction; using S1API.Internal.Patches; using S1API.Internal.Utils; using S1API.Items; using S1API.Logging; using S1API.Map; using S1API.Messaging; using S1API.Money; using S1API.PhoneApp; using S1API.PhoneCalls.Constants; using S1API.Products; using S1API.Quests; using S1API.Quests.Constants; using S1API.Saveables; using S1API.Storages; using ScheduleOne; using ScheduleOne.AvatarFramework; using ScheduleOne.Calling; using ScheduleOne.DevUtilities; using ScheduleOne.Dialogue; using ScheduleOne.Economy; using ScheduleOne.GameTime; using ScheduleOne.Interaction; using ScheduleOne.ItemFramework; using ScheduleOne.Levelling; using ScheduleOne.Map; using ScheduleOne.Messaging; using ScheduleOne.Money; using ScheduleOne.NPCs; using ScheduleOne.NPCs.Behaviour; using ScheduleOne.NPCs.Relation; using ScheduleOne.NPCs.Responses; using ScheduleOne.NPCs.Schedules; using ScheduleOne.Noise; using ScheduleOne.Persistence.Datas; using ScheduleOne.Persistence.Loaders; using ScheduleOne.PlayerScripts; using ScheduleOne.PlayerScripts.Health; using ScheduleOne.Product; using ScheduleOne.Product.Packaging; using ScheduleOne.Property; using ScheduleOne.Quests; using ScheduleOne.ScriptableObjects; using ScheduleOne.Storage; using ScheduleOne.UI; using ScheduleOne.UI.Phone; using ScheduleOne.UI.Phone.ContactsApp; using ScheduleOne.UI.WorldspacePopup; using ScheduleOne.Variables; using ScheduleOne.Vehicles; using ScheduleOne.Vision; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KaBooMa")] [assembly: AssemblyConfiguration("MonoBepInEx")] [assembly: AssemblyDescription("A Schedule One Mono / Il2Cpp Cross Compatibility Layer")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d9665e9bd95b76b033fb53d5c1698afa82fe53ac")] [assembly: AssemblyProduct("S1API")] [assembly: AssemblyTitle("S1API")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/KaBooMa/S1API")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } public class DialogueInjection { public string NpcName; public string ContainerName; public string FromNodeGuid; public string ToNodeGuid; public string ChoiceLabel; public string ChoiceText; public Action OnConfirmed; public DialogueInjection(string npc, string container, string from, string to, string label, string text, Action onConfirmed) { NpcName = npc; ContainerName = container; FromNodeGuid = from; ToNodeGuid = to; ChoiceLabel = label; ChoiceText = text; OnConfirmed = onConfirmed; } } public static class DialogueInjector { private static List<DialogueInjection> pendingInjections = new List<DialogueInjection>(); private static bool isHooked = false; public static void Register(DialogueInjection injection) { pendingInjections.Add(injection); HookUpdateLoop(); } private static void HookUpdateLoop() { if (!isHooked) { isHooked = true; } } private static IEnumerator WaitForNPCsAndInject() { while (pendingInjections.Count > 0) { for (int i = pendingInjections.Count - 1; i >= 0; i--) { DialogueInjection injection = pendingInjections[i]; NPC[] npcs = Object.FindObjectsOfType<NPC>(); NPC target = null; for (int j = 0; j < npcs.Length; j++) { if ((Object)(object)npcs[j] != (Object)null && ((Object)npcs[j]).name.Contains(injection.NpcName)) { target = npcs[j]; break; } } if ((Object)(object)target != (Object)null) { TryInject(injection, target); pendingInjections.RemoveAt(i); } } yield return null; } } private static void TryInject(DialogueInjection injection, NPC npc) { //IL_00d7: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown DialogueHandler component = ((Component)npc).GetComponent<DialogueHandler>(); NPCEvent_LocationDialogue componentInChildren = ((Component)npc).GetComponentInChildren<NPCEvent_LocationDialogue>(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.DialogueOverride == (Object)null || ((Object)componentInChildren.DialogueOverride).name != injection.ContainerName) { return; } DialogueContainer dialogueOverride = componentInChildren.DialogueOverride; if (dialogueOverride.DialogueNodeData == null) { return; } DialogueNodeData val = null; for (int i = 0; i < dialogueOverride.DialogueNodeData.Count; i++) { DialogueNodeData val2 = dialogueOverride.DialogueNodeData.ToArray()[i]; if (val2 != null && val2.Guid == injection.FromNodeGuid) { val = val2; break; } } if (val != null) { DialogueChoiceData val3 = new DialogueChoiceData { Guid = Guid.NewGuid().ToString(), ChoiceLabel = injection.ChoiceLabel, ChoiceText = injection.ChoiceText }; List<DialogueChoiceData> list = new List<DialogueChoiceData>(); if (val.choices != null) { list.AddRange(val.choices); } list.Add(val3); val.choices = list.ToArray(); NodeLinkData item = new NodeLinkData { BaseDialogueOrBranchNodeGuid = injection.FromNodeGuid, BaseChoiceOrOptionGUID = val3.Guid, TargetNodeGuid = injection.ToNodeGuid }; if (dialogueOverride.NodeLinks == null) { dialogueOverride.NodeLinks = new List<NodeLinkData>(); } dialogueOverride.NodeLinks.Add(item); DialogueChoiceListener.Register(component, injection.ChoiceLabel, injection.OnConfirmed); } } } public class ClickHandler { private readonly UnityAction _callback; public ClickHandler(UnityAction callback) { _callback = callback; } public void OnClick() { _callback.Invoke(); } } namespace S1API { [BepInPlugin("S1API", "S1API", "1.0.0")] public class S1API : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) new Harmony("com.S1API").PatchAll(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "S1API"; public const string PLUGIN_NAME = "S1API"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace S1API.UI { 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<RectTransform>(); 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<Image>(); ((Graphic)val3).color = bgColor; return val; } public static Text Text(string name, string content, Transform parent, int fontSize = 14, TextAnchor anchor = 0, FontStyle style = 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<RectTransform>(); Text val3 = val.AddComponent<Text>(); val3.text = content; val3.fontSize = fontSize; val3.alignment = anchor; val3.fontStyle = style; val3.font = Resources.GetBuiltinResource<Font>("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<RectTransform>(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; scrollRect = val.AddComponent<ScrollRect>(); scrollRect.horizontal = false; GameObject val3 = new GameObject("Viewport"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent<RectTransform>(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; ((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.05f); val3.AddComponent<Mask>().showMaskGraphic = false; scrollRect.viewport = val4; GameObject val5 = new GameObject("Content"); val5.transform.SetParent(val3.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = new Vector2(0f, 1f); val6.anchorMax = new Vector2(1f, 1f); val6.pivot = new Vector2(0.5f, 1f); VerticalLayoutGroup val7 = val5.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val7).spacing = 10f; ((LayoutGroup)val7).padding = new RectOffset(10, 10, 10, 10); ((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val7).childForceExpandHeight = false; val5.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; scrollRect.content = val6; return val6; } public static void FitContentHeight(RectTransform content) { ContentSizeFitter val = ((Component)content).gameObject.GetComponent<ContentSizeFitter>(); if ((Object)(object)val == (Object)null) { val = ((Component)content).gameObject.AddComponent<ContentSizeFitter>(); } 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<RectTransform>(); val2.sizeDelta = new Vector2(width, height); LayoutElement val3 = val.AddComponent<LayoutElement>(); val3.preferredWidth = width; val3.preferredHeight = height; Image val4 = val.AddComponent<Image>(); val4.sprite = GetRoundedSprite(); val4.type = (Type)1; ((Graphic)val4).color = Color.white; Mask val5 = val.AddComponent<Mask>(); val5.showMaskGraphic = true; GameObject val6 = new GameObject(name); val6.transform.SetParent(val.transform, false); RectTransform val7 = val6.AddComponent<RectTransform>(); val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = Vector2.zero; val7.offsetMax = Vector2.zero; Image val8 = val6.AddComponent<Image>(); ((Graphic)val8).color = bgColor; val8.sprite = GetRoundedSprite(); val8.type = (Type)1; Button val9 = val6.AddComponent<Button>(); ((Selectable)val9).targetGraphic = (Graphic)(object)val8; GameObject val10 = new GameObject("Label"); val10.transform.SetParent(val6.transform, false); RectTransform val11 = val10.AddComponent<RectTransform>(); val11.anchorMin = Vector2.zero; val11.anchorMax = Vector2.one; val11.offsetMin = Vector2.zero; val11.offsetMax = Vector2.zero; Text val12 = val10.AddComponent<Text>(); val12.text = label; val12.alignment = (TextAnchor)4; val12.fontSize = fontSize; val12.fontStyle = (FontStyle)1; ((Graphic)val12).color = textColor; val12.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); return (val, val9, val12); } private static Sprite GetRoundedSprite() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)roundedSprite != (Object)null) { return roundedSprite; } int num = 32; Texture2D val = new Texture2D(num, num, (TextureFormat)5, false); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); float num2 = 6f; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { bool flag = ((float)j < num2 && (float)i < num2 && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) > num2) || ((float)j > (float)num - num2 - 1f && (float)i < num2 && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)num - num2 - 1f, num2)) > num2) || ((float)j < num2 && (float)i > (float)num - num2 - 1f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, (float)num - num2 - 1f)) > num2) || ((float)j > (float)num - num2 - 1f && (float)i > (float)num - num2 - 1f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)num - num2 - 1f, (float)num - num2 - 1f)) > num2); val.SetPixel(j, i, Color32.op_Implicit(flag ? val2 : val3)); } } val.Apply(); Vector4 val4 = default(Vector4); ((Vector4)(ref val4))..ctor(8f, 8f, 8f, 8f); roundedSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, val4); return roundedSprite; } public static GameObject ButtonRow(string name, Transform parent, float spacing = 12f, TextAnchor alignment = 4) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002d: 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<RectTransform>(); HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).spacing = spacing; ((LayoutGroup)val3).childAlignment = alignment; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false; return val; } public static (GameObject, Button, Text) ButtonWithLabel(string name, string label, Transform parent, Color bgColor, float Width, float Height) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_008f: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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<RectTransform>(); val2.sizeDelta = new Vector2(Height, Width); Image val3 = val.AddComponent<Image>(); ((Graphic)val3).color = bgColor; val3.sprite = Resources.GetBuiltinResource<Sprite>("UI/Skin/UISprite.psd"); val3.type = (Type)1; Button val4 = val.AddComponent<Button>(); ((Selectable)val4).targetGraphic = (Graphic)(object)val3; GameObject val5 = new GameObject("Label"); val5.transform.SetParent(val.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = Vector2.zero; val6.offsetMax = Vector2.zero; Text val7 = val5.AddComponent<Text>(); val7.text = label; val7.alignment = (TextAnchor)4; val7.fontSize = 16; val7.fontStyle = (FontStyle)1; ((Graphic)val7).color = Color.white; val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); return (val, val4, val7); } public static void SetIcon(Sprite sprite, Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Icon"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; Image val3 = val.AddComponent<Image>(); val3.sprite = sprite; val3.preserveAspect = true; } public static void CreateTextBlock(Transform parent, string title, string subtitle, bool isCompleted) { Text(((Object)parent).name + "Title", title, parent, 16, (TextAnchor)3, (FontStyle)1); Text(((Object)parent).name + "Subtitle", subtitle, parent, 14, (TextAnchor)0, (FontStyle)0); if (isCompleted) { Text("CompletedLabel", "<color=#888888><i>Already Delivered</i></color>", parent, 12, (TextAnchor)0, (FontStyle)0); } } public static void CreateRowButton(GameObject go, UnityAction clickHandler, bool enabled) { Button val = go.AddComponent<Button>(); Image component = go.GetComponent<Image>(); ((Selectable)val).targetGraphic = (Graphic)(object)component; ((Selectable)val).interactable = enabled; ((UnityEvent)val.onClick).AddListener(clickHandler); } public static void ClearChildren(Transform parent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in parent) { Transform val = item; Object.Destroy((Object)(object)((Component)val).gameObject); } } public static void VerticalLayoutOnGO(GameObject go, int spacing = 10, RectOffset? padding = null) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) VerticalLayoutGroup val = go.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val).spacing = spacing; ((LayoutGroup)val).padding = (RectOffset)(((object)padding) ?? ((object)new RectOffset(10, 10, 10, 10))); } public static GameObject CreateQuestRow(string name, Transform parent, out GameObject iconPanel, out GameObject textPanel) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Row_" + name); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = new Vector2(0f, 90f); val.AddComponent<LayoutElement>().minHeight = 50f; ((Shadow)val.AddComponent<Outline>()).effectColor = new Color(0f, 0f, 0f, 0.2f); GameObject val3 = Panel("Separator", val.transform, new Color(1f, 1f, 1f, 0.05f)); val3.GetComponent<RectTransform>().sizeDelta = new Vector2(300f, 1f); Image val4 = val.AddComponent<Image>(); ((Graphic)val4).color = new Color(0.12f, 0.12f, 0.12f); Button val5 = val.AddComponent<Button>(); ((Selectable)val5).targetGraphic = (Graphic)(object)val4; HorizontalLayoutGroup val6 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val6).spacing = 20f; ((LayoutGroup)val6).padding = new RectOffset(75, 10, 10, 10); ((LayoutGroup)val6).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)val6).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val6).childForceExpandHeight = false; LayoutElement val7 = val.AddComponent<LayoutElement>(); val7.minHeight = 90f; val7.flexibleWidth = 1f; iconPanel = Panel("IconPanel", val.transform, new Color(0.12f, 0.12f, 0.12f)); RectTransform component = iconPanel.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(80f, 80f); LayoutElement val8 = iconPanel.AddComponent<LayoutElement>(); val8.preferredWidth = 80f; val8.preferredHeight = 80f; textPanel = Panel("TextPanel", val.transform, Color.clear); VerticalLayoutOnGO(textPanel, 2); LayoutElement val9 = textPanel.AddComponent<LayoutElement>(); val9.minWidth = 200f; val9.flexibleWidth = 1f; return val; } public static GameObject TopBar(string name, Transform parent, string title, float topbarSize, int paddingLeft, int paddingRight, int paddingTop, int paddingBottom) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown GameObject val = Panel(name, parent, new Color(0.15f, 0.15f, 0.15f), (Vector2?)new Vector2(0f, topbarSize), (Vector2?)new Vector2(1f, 1f), fullAnchor: false); HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>(); ((LayoutGroup)val2).padding = new RectOffset(paddingLeft, paddingRight, paddingTop, paddingBottom); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 20f; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = true; Text val3 = Text("TopBarTitle", title, val.transform, 26, (TextAnchor)3, (FontStyle)1); LayoutElement val4 = ((Component)val3).gameObject.AddComponent<LayoutElement>(); val4.minWidth = 300f; val4.flexibleWidth = 1f; return val; } public static void HorizontalLayoutOnGO(GameObject go, int spacing = 10, int padLeft = 0, int padRight = 0, int padTop = 0, int padBottom = 0, TextAnchor alignment = 4) { //IL_0012: 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_003b: Expected O, but got Unknown HorizontalLayoutGroup val = go.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val).spacing = spacing; ((LayoutGroup)val).childAlignment = alignment; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false; ((LayoutGroup)val).padding = new RectOffset(padLeft, padRight, padTop, padBottom); } public static void SetLayoutGroupPadding(LayoutGroup layoutGroup, int left, int right, int top, int bottom) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown layoutGroup.padding = new RectOffset(left, right, top, bottom); } public static void BindAcceptButton(Button btn, Text label, string text, UnityAction callback) { label.text = text; ((UnityEventBase)btn.onClick).RemoveAllListeners(); ((UnityEvent)btn.onClick).AddListener(callback); } } } namespace S1API.Storages { public class StorageInstance { internal readonly StorageEntity S1Storage; public ItemSlotInstance[] Slots => (from itemSlot in S1Storage.ItemSlots.ToArray() select new ItemSlotInstance(itemSlot)).ToArray(); public event Action OnOpened { add { EventHelper.AddListener(value, S1Storage.onOpened); } remove { EventHelper.RemoveListener(value, S1Storage.onOpened); } } public event Action OnClosed { add { EventHelper.AddListener(value, S1Storage.onClosed); } remove { EventHelper.RemoveListener(value, S1Storage.onClosed); } } internal StorageInstance(StorageEntity storage) { S1Storage = storage; } public bool CanItemFit(ItemInstance itemInstance, int quantity = 1) { return S1Storage.CanItemFit(itemInstance.S1ItemInstance, quantity); } public void AddItem(ItemInstance itemInstance) { S1Storage.InsertItem(itemInstance.S1ItemInstance, true); } } } namespace S1API.Saveables { [AttributeUsage(AttributeTargets.Field)] public class SaveableField : Attribute { internal string SaveName { get; } public SaveableField(string saveName) { SaveName = saveName; } } } namespace S1API.Quests { public abstract class Quest : Saveable { protected readonly List<QuestEntry> QuestEntries = new List<QuestEntry>(); [SaveableField("QuestData")] private readonly QuestData _questData; internal readonly Quest S1Quest; private readonly GameObject _gameObject; protected abstract string Title { get; } protected abstract string Description { get; } protected virtual bool AutoBegin => true; protected QuestState QuestState => (QuestState)S1Quest.QuestState; internal string? SaveFolder => S1Quest.SaveFolderName; protected virtual Sprite? QuestIcon => null; public Quest() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown _questData = new QuestData(GetType().Name); _gameObject = new GameObject("Quest"); S1Quest = _gameObject.AddComponent<Quest>(); S1Quest.StaticGUID = string.Empty; FieldInfo fieldInfo = AccessTools.Field(typeof(Quest), "title"); fieldInfo.SetValue(S1Quest, Title); S1Quest.onActiveState = new UnityEvent(); S1Quest.onComplete = new UnityEvent(); S1Quest.onInitialComplete = new UnityEvent(); S1Quest.onQuestBegin = new UnityEvent(); S1Quest.onQuestEnd = new UnityEvent<EQuestState>(); S1Quest.onTrackChange = new UnityEvent<bool>(); S1Quest.TrackOnBegin = true; S1Quest.AutoCompleteOnAllEntriesComplete = true; FieldInfo fieldInfo2 = AccessTools.Field(typeof(Quest), "autoInitialize"); fieldInfo2.SetValue(S1Quest, false); GameObject val = new GameObject("IconPrefab", new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Image>() }); val.transform.SetParent(_gameObject.transform); Image component = val.GetComponent<Image>(); component.sprite = QuestIcon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; S1Quest.IconPrefab = val.GetComponent<RectTransform>(); GameObject val2 = new GameObject("PoIUIPrefab", new Type[4] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<EventTrigger>(), CrossType.Of<Button>() }); val2.transform.SetParent(_gameObject.transform); GameObject val3 = new GameObject("MainLabel", new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Text>() }); val3.transform.SetParent(val2.transform); GameObject val4 = new GameObject("IconContainer", new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Image>() }); val4.transform.SetParent(val2.transform); Image component2 = val4.GetComponent<Image>(); component2.sprite = QuestIcon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; RectTransform component3 = ((Component)component2).GetComponent<RectTransform>(); component3.sizeDelta = new Vector2(20f, 20f); GameObject val5 = new GameObject("POIPrefab"); val5.SetActive(false); val5.transform.SetParent(_gameObject.transform); POI val6 = val5.AddComponent<POI>(); val6.DefaultMainText = "Did it work?"; FieldInfo fieldInfo3 = AccessTools.Field(typeof(POI), "UIPrefab"); fieldInfo3.SetValue(val6, val2); S1Quest.PoIPrefab = val5; S1Quest.onQuestEnd.AddListener((UnityAction<EQuestState>)OnQuestEnded); } internal override void CreateInternal() { base.CreateInternal(); S1Quest.InitializeQuest(Title, Description, Array.Empty<QuestEntryData>(), S1Quest?.StaticGUID); if (AutoBegin) { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Begin(true); } } } internal override void SaveInternal(string folderPath, ref List<string> extraSaveables) { string text = Path.Combine(folderPath, S1Quest.SaveFolderName); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } base.SaveInternal(text, ref extraSaveables); } internal void OnQuestEnded(EQuestState questState) { Quest.Quests.Remove(S1Quest); QuestManager.Quests.Remove(this); } protected QuestEntry AddEntry(string title, Vector3? poiPosition = null) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("QuestEntry"); Transform transform = val.transform; GameObject gameObject = _gameObject; transform.SetParent((gameObject != null) ? gameObject.transform : null); QuestEntry val2 = val.AddComponent<QuestEntry>(); val2.PoILocation = val.transform; S1Quest.Entries.Add(val2); QuestEntry questEntry = new QuestEntry(val2) { Title = title, POIPosition = (Vector3)(((??)poiPosition) ?? Vector3.zero) }; QuestEntries.Add(questEntry); return questEntry; } public void Begin() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Begin(true); } } public void Cancel() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Cancel(true); } } public void Expire() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Expire(true); } } public void Fail() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Fail(true); } } public void Complete() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Complete(true); } } public void End() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.End(); } } } public class QuestData { public readonly string ClassName; public QuestData(string className) { ClassName = className; } } public class QuestEntry { internal readonly QuestEntry S1QuestEntry; public QuestState State => (QuestState)S1QuestEntry.State; public string Title { get { return S1QuestEntry.Title; } set { S1QuestEntry.SetEntryTitle(value); } } public Vector3 POIPosition { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return S1QuestEntry.PoILocation.position; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1QuestEntry.PoILocation.position = value; } } public event Action OnComplete { add { EventHelper.AddListener(value, S1QuestEntry.onComplete); } remove { EventHelper.RemoveListener(value, S1QuestEntry.onComplete); } } internal QuestEntry(QuestEntry questEntry) { S1QuestEntry = questEntry; } public void Begin() { S1QuestEntry.Begin(); } public void Complete() { S1QuestEntry.Complete(); } public void SetState(QuestState questState) { S1QuestEntry.SetState((EQuestState)questState, true); } } public static class QuestManager { internal static readonly List<Quest> Quests = new List<Quest>(); public static Quest CreateQuest<T>(string? guid = null) where T : Quest { return CreateQuest(typeof(T), guid); } public static Quest CreateQuest(Type questType, string? guid = null) { Quest quest = (Quest)Activator.CreateInstance(questType); if (quest == null) { throw new Exception("Unable to create quest instance of " + questType.FullName + "!"); } Quests.Add(quest); return quest; } public static Quest? GetQuestByGuid(string guid) { string guid2 = guid; return Quests.FirstOrDefault((Quest x) => x.S1Quest.StaticGUID == guid2); } public static Quest? GetQuestByName(string questName) { string questName2 = questName; return Quests.FirstOrDefault((Quest x) => x.S1Quest.Title == questName2); } } } namespace S1API.Quests.Constants { public enum QuestAction { Begin, Success, Fail, Expire, Cancel } public enum QuestState { Inactive, Active, Completed, Failed, Expired, Cancelled } } namespace S1API.Property { public abstract class BaseProperty { public abstract string PropertyName { get; } public abstract string PropertyCode { get; } public abstract float Price { get; } public abstract bool IsOwned { get; } public abstract int EmployeeCapacity { get; set; } public abstract void SetOwned(); public abstract bool IsPointInside(Vector3 point); } public static class PropertyManager { public static List<PropertyWrapper> GetAllProperties() { List<PropertyWrapper> list = new List<PropertyWrapper>(); foreach (Property property in Property.Properties) { list.Add(new PropertyWrapper(property)); } return list; } public static List<PropertyWrapper> GetOwnedProperties() { List<PropertyWrapper> list = new List<PropertyWrapper>(); foreach (Property ownedProperty in Property.OwnedProperties) { list.Add(new PropertyWrapper(ownedProperty)); } return list; } public static PropertyWrapper FindPropertyByName(string name) { foreach (Property property in Property.Properties) { if (property.PropertyName == name) { return new PropertyWrapper(property); } } return null; } } public class PropertyWrapper : BaseProperty { internal readonly Property InnerProperty; public override string PropertyName => InnerProperty.PropertyName; public override string PropertyCode => InnerProperty.PropertyCode; public override float Price => InnerProperty.Price; public override bool IsOwned => InnerProperty.IsOwned; public override int EmployeeCapacity { get { return InnerProperty.EmployeeCapacity; } set { InnerProperty.EmployeeCapacity = value; } } public PropertyWrapper(Property property) { InnerProperty = property; } public override void SetOwned() { InnerProperty.SetOwned(); } public override bool IsPointInside(Vector3 point) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return InnerProperty.DoBoundsContainPoint(point); } } } namespace S1API.Products { public class CocaineDefinition : ProductDefinition { internal CocaineDefinition S1CocaineDefinition => CrossType.As<CocaineDefinition>(S1ItemDefinition); internal CocaineDefinition(CocaineDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>(((ItemDefinition)S1CocaineDefinition).GetDefaultInstance(quantity))); } } public class MethDefinition : ProductDefinition { internal MethDefinition S1MethDefinition => CrossType.As<MethDefinition>(S1ItemDefinition); internal MethDefinition(MethDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>(((ItemDefinition)S1MethDefinition).GetDefaultInstance(quantity))); } } public class PackagingDefinition : ItemDefinition { internal PackagingDefinition S1PackagingDefinition => CrossType.As<PackagingDefinition>(S1ItemDefinition); public int Quantity => S1PackagingDefinition.Quantity; internal PackagingDefinition(ItemDefinition s1ItemDefinition) : base(s1ItemDefinition) { } } public class ProductDefinition : ItemDefinition { internal ProductDefinition S1ProductDefinition => CrossType.As<ProductDefinition>(S1ItemDefinition); public float Price => S1ProductDefinition.Price; public Sprite Icon => ((ItemDefinition)S1ProductDefinition).Icon; internal ProductDefinition(ProductDefinition productDefinition) : base((ItemDefinition)(object)productDefinition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>(((ItemDefinition)S1ProductDefinition).GetDefaultInstance(quantity))); } } internal static class ProductDefinitionWrapper { internal static ProductDefinition Wrap(ProductDefinition def) { ItemDefinition s1ItemDefinition = def.S1ItemDefinition; if (CrossType.Is<WeedDefinition>(s1ItemDefinition, out var result)) { return new WeedDefinition(result); } if (CrossType.Is<MethDefinition>(s1ItemDefinition, out var result2)) { return new MethDefinition(result2); } if (CrossType.Is<CocaineDefinition>(s1ItemDefinition, out var result3)) { return new CocaineDefinition(result3); } return def; } } public class ProductInstance : ItemInstance { internal ProductItemInstance S1ProductInstance => CrossType.As<ProductItemInstance>(S1ItemInstance); public bool IsPackaged => Object.op_Implicit((Object)(object)S1ProductInstance.AppliedPackaging); public PackagingDefinition AppliedPackaging => new PackagingDefinition((ItemDefinition)(object)S1ProductInstance.AppliedPackaging); internal ProductInstance(ProductItemInstance productInstance) : base((ItemInstance)(object)productInstance) { } } public static class ProductManager { public static ProductDefinition[] DiscoveredProducts => (from productDefinition in ProductManager.DiscoveredProducts.ToArray() select ProductDefinitionWrapper.Wrap(new ProductDefinition(productDefinition))).ToArray(); } public class WeedDefinition : ProductDefinition { internal WeedDefinition S1WeedDefinition => CrossType.As<WeedDefinition>(S1ItemDefinition); internal WeedDefinition(WeedDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>(((ItemDefinition)S1WeedDefinition).GetDefaultInstance(quantity))); } } } namespace S1API.PhoneCalls { public class CallerDefinition { internal readonly CallerID S1CallerIDEntry; public string Name { get { return S1CallerIDEntry.Name; } set { S1CallerIDEntry.Name = value; } } public Sprite? ProfilePicture { get { return S1CallerIDEntry.ProfilePicture; } set { S1CallerIDEntry.ProfilePicture = value; } } internal CallerDefinition(CallerID s1CallerID) { S1CallerIDEntry = s1CallerID; } } public static class CallManager { public static void QueueCall(PhoneCallDefinition phoneCallDefinition) { Singleton<CallManager>.Instance.QueueCall(phoneCallDefinition.S1PhoneCallData); } } public class CallStageEntry { internal readonly Stage S1Stage; protected readonly List<SystemTriggerEntry> StartTriggerEntries = new List<SystemTriggerEntry>(); protected readonly List<SystemTriggerEntry> DoneTriggerEntries = new List<SystemTriggerEntry>(); public string Text { get { return S1Stage.Text; } set { S1Stage.Text = value; } } internal CallStageEntry(Stage stage) { S1Stage = stage; } public SystemTriggerEntry AddSystemTrigger(SystemTriggerType triggerType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown SystemTrigger val = new SystemTrigger(); SystemTriggerEntry systemTriggerEntry = new SystemTriggerEntry(val); switch (triggerType) { case SystemTriggerType.StartTrigger: S1Stage.OnStartTriggers = S1Stage.OnStartTriggers.AddItemToArray(val); StartTriggerEntries.Add(systemTriggerEntry); break; case SystemTriggerType.DoneTrigger: S1Stage.OnDoneTriggers = S1Stage.OnDoneTriggers.AddItemToArray(val); DoneTriggerEntries.Add(systemTriggerEntry); break; } return systemTriggerEntry; } } public abstract class PhoneCallDefinition { public CallerDefinition? Caller; public readonly PhoneCallData S1PhoneCallData; protected readonly List<CallStageEntry> StageEntries = new List<CallStageEntry>(); protected PhoneCallDefinition(string name, Sprite? profilePicture = null) { S1PhoneCallData = ScriptableObject.CreateInstance<PhoneCallData>(); PhoneCallData s1PhoneCallData = S1PhoneCallData; if (s1PhoneCallData.Stages == null) { s1PhoneCallData.Stages = Array.Empty<Stage>(); } AddCallerID(name, profilePicture); } protected PhoneCallDefinition(NPC? npcCallerID) { S1PhoneCallData = ScriptableObject.CreateInstance<PhoneCallData>(); PhoneCallData s1PhoneCallData = S1PhoneCallData; if (s1PhoneCallData.Stages == null) { s1PhoneCallData.Stages = Array.Empty<Stage>(); } AddCallerID(npcCallerID); } protected CallerDefinition AddCallerID(string name, Sprite? profilePicture = null) { CallerID val = ScriptableObject.CreateInstance<CallerID>(); val.Name = name; val.ProfilePicture = profilePicture; S1PhoneCallData.CallerID = val; Caller = new CallerDefinition(val) { Name = name, ProfilePicture = profilePicture }; return Caller; } protected CallerDefinition AddCallerID(NPC? npc) { CallerID val = ScriptableObject.CreateInstance<CallerID>(); val.Name = npc?.FullName ?? "Unknown Caller"; val.ProfilePicture = npc?.Icon; S1PhoneCallData.CallerID = val; Caller = new CallerDefinition(val) { Name = (npc?.FullName ?? "Unknown Caller"), ProfilePicture = npc?.Icon }; return Caller; } protected CallStageEntry AddStage(string text) { //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_000e: Expected O, but got Unknown Stage val = new Stage { Text = text }; S1PhoneCallData.Stages = S1PhoneCallData.Stages.AddItemToArray(val); CallStageEntry callStageEntry = new CallStageEntry(val) { Text = text }; StageEntries.Add(callStageEntry); return callStageEntry; } public void Completed() { S1PhoneCallData.Completed(); } } } namespace S1API.PhoneCalls.Constants { public enum EvaluationType { PassOnTrue, PassOnFalse } public enum SystemTriggerType { StartTrigger, DoneTrigger } } namespace S1API.PhoneApp { public abstract class PhoneApp : Registerable { protected static readonly Log Logger = new Log("PhoneApp"); private GameObject? _appPanel; private bool _appCreated; private bool _iconModified; protected abstract string AppName { get; } protected abstract string AppTitle { get; } protected abstract string IconLabel { get; } protected abstract string IconFileName { get; } protected abstract void OnCreatedUI(GameObject container); protected override void OnCreated() { PhoneAppRegistry.Register(this); } protected override void OnDestroyed() { if ((Object)(object)_appPanel != (Object)null) { Object.Destroy((Object)(object)_appPanel); _appPanel = null; } _appCreated = false; _iconModified = false; } internal void SpawnUI(HomeScreen homeScreenInstance) { Transform obj = ((Component)homeScreenInstance).transform.parent.Find("AppsCanvas"); GameObject val = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val == (Object)null) { Logger.Error("AppsCanvas not found."); return; } Transform val2 = val.transform.Find(AppName); if ((Object)(object)val2 != (Object)null) { _appPanel = ((Component)val2).gameObject; SetupExistingAppPanel(_appPanel); } else { Transform val3 = val.transform.Find("ProductManagerApp"); if ((Object)(object)val3 == (Object)null) { Logger.Error("Template ProductManagerApp not found."); return; } _appPanel = Object.Instantiate<GameObject>(((Component)val3).gameObject, val.transform); ((Object)_appPanel).name = AppName; Transform val4 = _appPanel.transform.Find("Container"); if ((Object)(object)val4 != (Object)null) { GameObject gameObject = ((Component)val4).gameObject; ClearContainer(gameObject); OnCreatedUI(gameObject); } _appCreated = true; } _appPanel.SetActive(true); } internal void SpawnIcon(HomeScreen homeScreenInstance) { if (_iconModified) { return; } Transform obj = ((Component)homeScreenInstance).transform.Find("AppIcons"); GameObject val = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val == (Object)null) { Logger.Error("AppIcons not found under HomeScreen."); return; } Transform val2 = ((val.transform.childCount > 0) ? val.transform.GetChild(val.transform.childCount - 1) : null); if ((Object)(object)val2 == (Object)null) { Logger.Error("No icons found in AppIcons."); return; } GameObject gameObject = ((Component)val2).gameObject; ((Object)gameObject).name = AppName; Transform val3 = gameObject.transform.Find("Label"); Text val4 = ((val3 != null) ? ((Component)val3).GetComponent<Text>() : null); if ((Object)(object)val4 != (Object)null) { val4.text = IconLabel; } _iconModified = ChangeAppIconImage(gameObject, IconFileName); } private void SetupExistingAppPanel(GameObject panel) { Transform val = panel.transform.Find("Container"); if ((Object)(object)val != (Object)null) { GameObject gameObject = ((Component)val).gameObject; if (gameObject.transform.childCount < 2) { ClearContainer(gameObject); OnCreatedUI(gameObject); } } _appCreated = true; } private void ClearContainer(GameObject container) { for (int num = container.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)container.transform.GetChild(num)).gameObject); } } private bool ChangeAppIconImage(GameObject iconObj, string filename) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) Transform val = iconObj.transform.Find("Mask/Image"); Image val2 = ((val != null) ? ((Component)val).GetComponent<Image>() : null); if ((Object)(object)val2 == (Object)null) { Logger.Error("Image component not found in icon."); return false; } string text = Path.Combine(Paths.PluginPath, filename); if (!File.Exists(text)) { Logger.Error("Icon file not found: " + text); return false; } try { byte[] array = File.ReadAllBytes(text); Texture2D val3 = new Texture2D(2, 2); if (ImageConversion.LoadImage(val3, array)) { val2.sprite = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f)); return true; } Object.Destroy((Object)(object)val3); } catch (Exception ex) { Logger.Error("Failed to load image: " + ex.Message); } return false; } } } namespace S1API.Money { public class CashDefinition : ItemDefinition { internal CashDefinition S1CashDefinition => CrossType.As<CashDefinition>(S1ItemDefinition); internal CashDefinition(CashDefinition s1ItemDefinition) : base((ItemDefinition)(object)s1ItemDefinition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new CashInstance(((ItemDefinition)S1CashDefinition).GetDefaultInstance(quantity)); } } public class CashInstance : ItemInstance { internal CashInstance S1CashInstance => CrossType.As<CashInstance>(S1ItemInstance); internal CashInstance(ItemInstance itemInstance) : base(itemInstance) { } public void AddQuantity(float amount) { S1CashInstance.SetBalance(Mathf.Clamp(S1CashInstance.Balance + amount, 0f, float.MaxValue), false); } public void SetQuantity(float newQuantity) { S1CashInstance.SetBalance(newQuantity, false); } } public static class Money { private static MoneyManager Internal => NetworkSingleton<MoneyManager>.Instance; public static event Action? OnBalanceChanged; public static void ChangeCashBalance(float amount, bool visualizeChange = true, bool playCashSound = false) { MoneyManager @internal = Internal; if (@internal != null) { @internal.ChangeCashBalance(amount, visualizeChange, playCashSound); } Money.OnBalanceChanged?.Invoke(); } public static void CreateOnlineTransaction(string transactionName, float unitAmount, float quantity, string transactionNote) { MoneyManager @internal = Internal; if (@internal != null) { @internal.CreateOnlineTransaction(transactionName, unitAmount, quantity, transactionNote); } Money.OnBalanceChanged?.Invoke(); } public static float GetNetWorth() { return ((Object)(object)Internal != (Object)null) ? Internal.GetNetWorth() : 0f; } public static float GetCashBalance() { return ((Object)(object)Internal != (Object)null) ? Internal.cashBalance : 0f; } public static float GetOnlineBalance() { return ((Object)(object)Internal != (Object)null) ? Internal.sync___get_value_onlineBalance() : 0f; } public static void AddNetworthCalculation(Action<object> callback) { if ((Object)(object)Internal != (Object)null) { MoneyManager @internal = Internal; @internal.onNetworthCalculation = (Action<FloatContainer>)Delegate.Combine(@internal.onNetworthCalculation, callback); } } public static void RemoveNetworthCalculation(Action<object> callback) { if ((Object)(object)Internal != (Object)null) { MoneyManager @internal = Internal; @internal.onNetworthCalculation = (Action<FloatContainer>)Delegate.Remove(@internal.onNetworthCalculation, callback); } } public static CashInstance CreateCashInstance(float amount) { CashDefinition item = Registry.GetItem<CashDefinition>("cash"); ItemInstance itemInstance = CrossType.As<ItemInstance>(((ItemDefinition)item).GetDefaultInstance(1)); CashInstance cashInstance = new CashInstance(itemInstance); cashInstance.SetQuantity(amount); return cashInstance; } } } namespace S1API.Messaging { public class Response { internal readonly Response S1Response; public Action? OnTriggered { get { return (S1Response.callback == null) ? null : ((Action)delegate { S1Response.callback(); }); } set { S1Response.callback = value; } } public string Label { get { return S1Response.label; } set { S1Response.label = value; } } public string Text { get { return S1Response.text; } set { S1Response.text = value; } } public Response() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown S1Response = new Response(); } internal Response(Response response) { S1Response = response; } } } namespace S1API.Map { public enum Region { Northtown, Westville, Downtown, Docks, Suburbia, Uptown } } namespace S1API.Logging { public class Log { private readonly ManualLogSource _loggerInstance; public Log(string sourceName) { _loggerInstance = Logger.CreateLogSource(sourceName); } public Log(ManualLogSource loggerInstance) { _loggerInstance = loggerInstance; } public void Msg(string message) { _loggerInstance.LogInfo((object)message); } public void Warning(string message) { _loggerInstance.LogWarning((object)message); } public void Error(string message) { _loggerInstance.LogError((object)message); } public void BigError(string message) { _loggerInstance.LogFatal((object)message); } } } namespace S1API.Leveling { public static class LevelManager { public static Rank Rank = (Rank)NetworkSingleton<LevelManager>.Instance.Rank; } public enum Rank { StreetRat, Hoodlum, Peddler, Hustler, Bagman, Enforcer, ShotCaller, BlockBoss, Underlord, Baron, Kingpin } } namespace S1API.Items { public enum ItemCategory { Product, Packaging, Growing, Tools, Furniture, Lighting, Cash, Consumable, Equipment, Ingredient, Decoration, Clothing } public class ItemDefinition : IGUIDReference { internal readonly ItemDefinition S1ItemDefinition; public virtual string GUID => S1ItemDefinition.ID; public string ID => S1ItemDefinition.ID; public string Name => S1ItemDefinition.Name; public string Description => S1ItemDefinition.Description; public ItemCategory Category => (ItemCategory)S1ItemDefinition.Category; public int StackLimit => S1ItemDefinition.StackLimit; internal ItemDefinition(ItemDefinition s1ItemDefinition) { S1ItemDefinition = s1ItemDefinition; } internal static ItemDefinition GetFromGUID(string guid) { return ItemManager.GetItemDefinition(guid); } public override bool Equals(object? obj) { return obj is ItemDefinition itemDefinition && (Object)(object)S1ItemDefinition == (Object)(object)itemDefinition.S1ItemDefinition; } public override int GetHashCode() { return ((object)S1ItemDefinition)?.GetHashCode() ?? 0; } public static bool operator ==(ItemDefinition? left, ItemDefinition? right) { if ((object)left == right) { return true; } return (Object)(object)left?.S1ItemDefinition == (Object)(object)right?.S1ItemDefinition; } public static bool operator !=(ItemDefinition left, ItemDefinition right) { return !(left == right); } public virtual ItemInstance CreateInstance(int quantity = 1) { return new ItemInstance(S1ItemDefinition.GetDefaultInstance(quantity)); } } public class ItemInstance { internal readonly ItemInstance S1ItemInstance; public ItemDefinition Definition => new ItemDefinition(S1ItemInstance.Definition); internal ItemInstance(ItemInstance itemInstance) { S1ItemInstance = itemInstance; } } public static class ItemManager { public static ItemDefinition GetItemDefinition(string itemID) { ItemDefinition item = Registry.GetItem(itemID); if (CrossType.Is<ProductDefinition>(item, out var result)) { return new ProductDefinition(result); } if (CrossType.Is<CashDefinition>(item, out var result2)) { return new CashDefinition(result2); } return new ItemDefinition(item); } } public class ItemSlotInstance { internal readonly ItemSlot S1ItemSlot; public int Quantity => S1ItemSlot.Quantity; public ItemInstance? ItemInstance { get { if (CrossType.Is<ProductItemInstance>(S1ItemSlot.ItemInstance, out var result)) { return new ProductInstance(result); } if (CrossType.Is<CashInstance>(S1ItemSlot.ItemInstance, out var result2)) { return new CashInstance((ItemInstance)(object)result2); } if (CrossType.Is<ItemInstance>(S1ItemSlot.ItemInstance, out var result3)) { return new ItemInstance(result3); } return null; } } internal ItemSlotInstance(ItemSlot itemSlot) { S1ItemSlot = itemSlot; } public void AddQuantity(int amount) { S1ItemSlot.ChangeQuantity(amount, false); } } } namespace S1API.Internal.Utils { public static class ArrayExtensions { public static T[] AddItemToArray<T>(this T[]? array, T item) { if (array == null) { array = Array.Empty<T>(); } Array.Resize(ref array, array.Length + 1); array[^1] = item; return array; } } public static class ButtonUtils { public static void AddListener(Button button, Action action) { if (!((Object)(object)button == (Object)null) && action != null) { EventHelper.AddListener(action, (UnityEvent)(object)button.onClick); } } public static void RemoveListener(Button button, Action action) { if (!((Object)(object)button == (Object)null) && action != null) { EventHelper.RemoveListener(action, (UnityEvent)(object)button.onClick); } } public static void ClearListeners(Button button) { if (!((Object)(object)button == (Object)null)) { ((UnityEventBase)button.onClick).RemoveAllListeners(); } } public static void Enable(Button button, Text? label = null, string? text = null) { if ((Object)(object)button != (Object)null) { ((Selectable)button).interactable = true; } if ((Object)(object)label != (Object)null && !string.IsNullOrEmpty(text)) { label.text = text; } } public static void Disable(Button button, Text? label = null, string? text = null) { if ((Object)(object)button != (Object)null) { ((Selectable)button).interactable = false; } if ((Object)(object)label != (Object)null && !string.IsNullOrEmpty(text)) { label.text = text; } } public static void SetLabel(Text label, string text) { if ((Object)(object)label != (Object)null) { label.text = text; } } public static void SetStyle(Button button, Text label, string text, Color bg) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)button == (Object)null) && !((Object)(object)label == (Object)null)) { label.text = text; ((Graphic)((Selectable)button).image).color = bg; } } } internal static class CrossType { internal static Type Of<T>() { return typeof(T); } internal static bool Is<T>(object obj, out T result) where T : class { if (obj is T val) { result = val; return true; } result = null; return false; } internal static T As<T>(object obj) where T : class { return (T)obj; } } public static class ImageUtils { private static readonly Log _loggerInstance = new Log("ImageUtils"); public static Sprite? LoadImage(string fileName) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, fileName); if (!File.Exists(text)) { _loggerInstance.Error("❌ Icon file not found: " + text); return null; } try { byte[] array = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2); if (ImageConversion.LoadImage(val, array)) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } catch (Exception ex) { _loggerInstance.Error("❌ Failed to load sprite: " + ex); } return null; } } public static class RandomUtils { private static readonly Random SystemRng = new Random(); public static T PickOne<T>(this IList<T> list) { if (list == null || list.Count == 0) { return default(T); } return list[Random.Range(0, list.Count)]; } public static T PickUnique<T>(this IList<T> list, Func<T, bool> isDuplicate, int maxTries = 10) { if (list.Count == 0) { return default(T); } for (int i = 0; i < maxTries; i++) { T val = list.PickOne(); if (!isDuplicate(val)) { return val; } } return default(T); } public static List<T> PickMany<T>(this IList<T> list, int count) { if (list.Count == 0) { return new List<T>(); } List<T> list2 = new List<T>(list); List<T> list3 = new List<T>(); for (int i = 0; i < count; i++) { if (list2.Count <= 0) { break; } int index = Random.Range(0, list2.Count); list3.Add(list2[index]); list2.RemoveAt(index); } return list3; } public static int RangeInt(int minInclusive, int maxExclusive) { return SystemRng.Next(minInclusive, maxExclusive); } } internal static class ReflectionUtils { internal static List<Type> GetDerivedClasses<TBaseClass>() { List<Type> list = new List<Type>(); Assembly[] array = (from assembly in AppDomain.CurrentDomain.GetAssemblies() where !assembly.FullName.StartsWith("System") && !assembly.FullName.StartsWith("Unity") && !assembly.FullName.StartsWith("Il2Cpp") && !assembly.FullName.StartsWith("mscorlib") && !assembly.FullName.StartsWith("Mono.") && !assembly.FullName.StartsWith("netstandard") && !assembly.FullName.StartsWith("com.rlabrecque") && !assembly.FullName.StartsWith("__Generated") select assembly).ToArray(); Assembly[] array2 = array; foreach (Assembly assembly2 in array2) { list.AddRange(from type in assembly2.GetTypes() where typeof(TBaseClass).IsAssignableFrom(type) && type != typeof(TBaseClass) && !type.IsAbstract select type); } return list; } internal static Type? GetTypeByName(string typeName) { string typeName2 = typeName; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array = assemblies; foreach (Assembly assembly in array) { Type type2 = assembly.GetTypes().FirstOrDefault((Type type) => type.Name == typeName2); if (!(type2 == null)) { return type2; } } return null; } internal static FieldInfo[] GetAllFields(Type? type, BindingFlags bindingFlags) { List<FieldInfo> list = new List<FieldInfo>(); while (type != null && type != typeof(object)) { list.AddRange(type.GetFields(bindingFlags)); type = type.BaseType; } return list.ToArray(); } public static MethodInfo? GetMethod(Type? type, string methodName, BindingFlags bindingFlags) { while (type != null && type != typeof(object)) { MethodInfo method = type.GetMethod(methodName, bindingFlags); if (method != null) { return method; } type = type.BaseType; } return null; } } } namespace S1API.Internal.Patches { [HarmonyPatch(typeof(HomeScreen), "Start")] internal static class HomeScreen_Start_Patch { private static readonly Log Logger = new Log("PhoneApp"); private static void Postfix(HomeScreen __instance) { if ((Object)(object)__instance == (Object)null) { return; } List<Type> derivedClasses = ReflectionUtils.GetDerivedClasses<global::S1API.PhoneApp.PhoneApp>(); foreach (Type item in derivedClasses) { Logger.Msg("Found phone app: " + item.FullName); if (!(item.GetConstructor(Type.EmptyTypes) == null)) { try { global::S1API.PhoneApp.PhoneApp phoneApp = (global::S1API.PhoneApp.PhoneApp)Activator.CreateInstance(item); ((IRegisterable)phoneApp).CreateInternal(); phoneApp.SpawnUI(__instance); phoneApp.SpawnIcon(__instance); } catch (Exception ex) { Logger.Warning("[PhoneApp] Failed to register " + item.FullName + ": " + ex.Message); } } } } } [HarmonyPatch] internal class NPCPatches { [HarmonyPatch(typeof(NPCsLoader), "Load")] [HarmonyPrefix] private static void NPCsLoadersLoad(NPCsLoader __instance, string mainPath) { foreach (Type derivedClass in ReflectionUtils.GetDerivedClasses<NPC>()) { NPC nPC = (NPC)Activator.CreateInstance(derivedClass, nonPublic: true); if (nPC == null) { throw new Exception("Unable to create instance of " + derivedClass.FullName + "!"); } if (!(derivedClass.Assembly == Assembly.GetExecutingAssembly())) { string folderPath = Path.Combine(mainPath, nPC.S1NPC.SaveFolderName); nPC.LoadInternal(folderPath); } } } [HarmonyPatch(typeof(NPC), "Start")] [HarmonyPostfix] private static void NPCStart(NPC __instance) { NPC __instance2 = __instance; NPC.All.FirstOrDefault((NPC npc) => npc.IsCustomNPC && (Object)(object)npc.S1NPC == (Object)(object)__instance2)?.CreateInternal(); } [HarmonyPatch(typeof(NPC), "WriteData")] [HarmonyPostfix] private static void NPCWriteData(NPC __instance, string parentFolderPath, ref List<string> __result) { NPC __instance2 = __instance; NPC.All.FirstOrDefault((NPC npc) => npc.IsCustomNPC && (Object)(object)npc.S1NPC == (Object)(object)__instance2)?.SaveInternal(parentFolderPath, ref __result); } [HarmonyPatch(typeof(NPC), "OnDestroy")] [HarmonyPostfix] private static void NPCOnDestroy(NPC __instance) { NPC __instance2 = __instance; NPC.All.Remove(NPC.All.First((NPC npc) => (Object)(object)npc.S1NPC == (Object)(object)__instance2)); } } internal static class PhoneAppRegistry { public static readonly List<global::S1API.PhoneApp.PhoneApp> RegisteredApps = new List<global::S1API.PhoneApp.PhoneApp>(); public static void Register(global::S1API.PhoneApp.PhoneApp app) { RegisteredApps.Add(app); } } [HarmonyPatch] internal class PlayerPatches { [HarmonyPatch(typeof(Player), "Awake")] [HarmonyPostfix] private static void PlayerAwake(Player __instance) { new Player(__instance); } [HarmonyPatch(typeof(Player), "OnDestroy")] [HarmonyPostfix] private static void PlayerOnDestroy(Player __instance) { Player __instance2 = __instance; Player.All.Remove(Player.All.First((Player player) => (Object)(object)player.S1Player == (Object)(object)__instance2)); } } [HarmonyPatch] internal class QuestPatches { [HarmonyPatch(typeof(QuestManager), "WriteData")] [HarmonyPostfix] private static void QuestManagerWriteData(QuestManager __instance, string parentFolderPath, ref List<string> __result) { string folderPath = Path.Combine(parentFolderPath, "Quests"); foreach (Quest quest in QuestManager.Quests) { quest.SaveInternal(folderPath, ref __result); } } [HarmonyPatch(typeof(QuestsLoader), "Load")] [HarmonyPostfix] private static void QuestsLoaderLoad(QuestsLoader __instance, string mainPath) { if (!Directory.Exists(mainPath)) { return; } string[] array = (from directory in Directory.GetDirectories(mainPath).Select(Path.GetFileName) where directory?.StartsWith("Quest_") ?? false select directory).ToArray(); string[] array2 = array; string text2 = default(string); string text5 = default(string); foreach (string path in array2) { string text = Path.Combine(mainPath, path); ((Loader)__instance).TryLoadFile(text, ref text2, true); if (text2 == null) { continue; } QuestData val = JsonUtility.FromJson<QuestData>(text2); string text3 = Path.Combine(mainPath, path); string text4 = Path.Combine(text3, "QuestData"); if (!((Loader)__instance).TryLoadFile(text4, ref text5, true)) { continue; } QuestData questData = JsonConvert.DeserializeObject<QuestData>(text5, ISaveable.SerializerSettings); if (questData?.ClassName != null) { Type typeByName = ReflectionUtils.GetTypeByName(questData.ClassName); if (!(typeByName == null) && typeof(Quest).IsAssignableFrom(typeByName)) { Quest quest = QuestManager.CreateQuest(typeByName, val?.GUID); quest.LoadInternal(text3); } } } } [HarmonyPatch(typeof(QuestManager), "DeleteUnapprovedFiles")] [HarmonyPostfix] private static void QuestManagerDeleteUnapprovedFiles(QuestManager __instance, string parentFolderPath) { string path = Path.Combine(parentFolderPath, "Quests"); string?[] existingQuests = QuestManager.Quests.Select((Quest quest) => quest.SaveFolder).ToArray(); string[] array = (from directory in Directory.GetDirectories(path) where directory.StartsWith("Quest_") && !existingQuests.Contains<string>(directory) select directory).ToArray(); string[] array2 = array; foreach (string path2 in array2) { Directory.Delete(path2, recursive: true); } } [HarmonyPatch(typeof(Quest), "Start")] [HarmonyPrefix] private static void QuestStart(Quest __instance) { Quest __instance2 = __instance; QuestManager.Quests.FirstOrDefault((Quest quest) => (Object)(object)quest.S1Quest == (Object)(object)__instance2)?.CreateInternal(); } } [HarmonyPatch] internal class TimePatches { [HarmonyPatch(typeof(TimeManager), "Awake")] [HarmonyPostfix] private static void TimeManagerAwake(TimeManager __instance) { __instance.onDayPass = (Action)Delegate.Combine(__instance.onDayPass, new Action(DayPass)); static void DayPass() { TimeManager.OnDayPass(); } } } } namespace S1API.Internal.Abstraction { internal static class EventHelper { internal static readonly Dictionary<Action, UnityAction> SubscribedActions = new Dictionary<Action, UnityAction>(); internal static void AddListener(Action listener, UnityEvent unityEvent) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (!SubscribedActions.ContainsKey(listener)) { UnityAction val = new UnityAction(listener.Invoke); unityEvent.AddListener(val); SubscribedActions.Add(listener, val); } } internal static void RemoveListener(Action listener, UnityEvent unityEvent) { SubscribedActions.TryGetValue(listener, out UnityAction value); SubscribedActions.Remove(listener); unityEvent.RemoveListener(value); } } internal class GUIDReferenceConverter : JsonConverter { public override bool CanRead => true; public override bool CanConvert(Type objectType) { return typeof(IGUIDReference).IsAssignableFrom(objectType); } public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (value is IGUIDReference iGUIDReference) { writer.WriteValue(iGUIDReference.GUID); } else { writer.WriteNull(); } } public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { string text = reader.Value?.ToString(); if (string.IsNullOrEmpty(text)) { return null; } MethodInfo method = ReflectionUtils.GetMethod(objectType, "GetFromGUID", BindingFlags.Static | BindingFlags.NonPublic); if (method == null) { throw new Exception("The type " + objectType.Name + " does not have a valid implementation of the GetFromGUID(string guid) method!"); } return method.Invoke(null, new object[1] { text }); } } internal interface IGUIDReference { string GUID { get; } } internal interface IRegisterable { void CreateInternal(); void DestroyInternal(); void OnCreated(); void OnDestroyed(); } internal interface ISaveable : IRegisterable { internal static JsonSerializerSettings SerializerSettings => new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1, Converters = new List<JsonConverter> { (JsonConverter)(object)new GUIDReferenceConverter() } }; void SaveInternal(string path, ref List<string> extraSaveables); void LoadInternal(string folderPath); void OnSaved(); void OnLoaded(); } public abstract class Registerable : IRegisterable { void IRegisterable.CreateInternal() { CreateInternal(); } internal virtual void CreateInternal() { OnCreated(); } void IRegisterable.DestroyInternal() { DestroyInternal(); } internal virtual void DestroyInternal() { OnDestroyed(); } void IRegisterable.OnCreated() { OnCreated(); } protected virtual void OnCreated() { } void IRegisterable.OnDestroyed() { OnDestroyed(); } protected virtual void OnDestroyed() { } } public abstract class Saveable : Registerable, ISaveable, IRegisterable { void ISaveable.LoadInternal(string folderPath) { LoadInternal(folderPath); } internal virtual void LoadInternal(string folderPath) { FieldInfo[] fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { SaveableField customAttribute = fieldInfo.GetCustomAttribute<SaveableField>(); if (customAttribute != null) { string path = (customAttribute.SaveName.EndsWith(".json") ? customAttribute.SaveName : (customAttribute.SaveName + ".json")); string path2 = Path.Combine(folderPath, path); if (File.Exists(path2)) { string text = File.ReadAllText(path2); Type fieldType = fieldInfo.FieldType; object value = JsonConvert.DeserializeObject(text, fieldType, ISaveable.SerializerSettings); fieldInfo.SetValue(this, value); } } } OnLoaded(); } void ISaveable.SaveInternal(string folderPath, ref List<string> extraSaveables) { SaveInternal(folderPath, ref extraSaveables); } internal virtual void SaveInternal(string folderPath, ref List<string> extraSaveables) { FieldInfo[] allFields = ReflectionUtils.GetAllFields(GetType(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = allFields; foreach (FieldInfo fieldInfo in array) { SaveableField customAttribute = fieldInfo.GetCustomAttribute<SaveableField>(); if (customAttribute != null) { string text = (customAttribute.SaveName.EndsWith(".json") ? customAttribute.SaveName : (customAttribute.SaveName + ".json")); string path = Path.Combine(folderPath, text); object value = fieldInfo.GetValue(this); if (value == null) { File.Delete(path); continue; } extraSaveables.Add(text); string contents = JsonConvert.SerializeObject(value, (Formatting)1, ISaveable.SerializerSettings); File.WriteAllText(path, contents); } } OnSaved(); } void ISaveable.OnLoaded() { OnLoaded(); } protected virtual void OnLoaded() { } void ISaveable.OnSaved() { OnSaved(); } protected virtual void OnSaved() { } } } namespace S1API.GameTime { public enum Day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } public struct GameDateTime { public int ElapsedDays; public int Time; public GameDateTime(int elapsedDays, int time) { ElapsedDays = elapsedDays; Time = time; } public GameDateTime(int minSum) { ElapsedDays = minSum / 1440; int num = minSum % 1440; if (minSum < 0) { num = -minSum % 1440; } Time = TimeManager.Get24HourTimeFromMinSum(num); } public GameDateTime(GameDateTimeData data) { ElapsedDays = data.ElapsedDays; Time = data.Time; } public GameDateTime(GameDateTime gameDateTime) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) ElapsedDays = gameDateTime.elapsedDays; Time = gameDateTime.time; } public int GetMinSum() { return ElapsedDays * 1440 + TimeManager.GetMinSumFrom24HourTime(Time); } public GameDateTime AddMinutes(int minutes) { return new GameDateTime(GetMinSum() + minutes); } public GameDateTime ToS1() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return new GameDateTime(ElapsedDays, Time); } public string GetFormattedTime() { return TimeManager.Get12HourTime((float)Time, true); } public bool IsNightTime() { return Time < 600 || Time >= 1800; } public bool IsSameDay(GameDateTime other) { return ElapsedDays == other.ElapsedDays; } public bool IsSameTime(GameDateTime other) { return ElapsedDays == other.ElapsedDays && Time == other.Time; } public override string ToString() { return $"Day {ElapsedDays}, {GetFormattedTime()}"; } public static GameDateTime operator +(GameDateTime a, GameDateTime b) { return new GameDateTime(a.GetMinSum() + b.GetMinSum()); } public static GameDateTime operator -(GameDateTime a, GameDateTime b) { return new GameDateTime(a.GetMinSum() - b.GetMinSum()); } public static bool operator >(GameDateTime a, GameDateTime b) { return a.GetMinSum() > b.GetMinSum(); } public static bool operator <(GameDateTime a, GameDateTime b) { return a.GetMinSum() < b.GetMinSum(); } } public static class TimeManager { public static Action OnDayPass; public static Action OnWeekPass; public static Action OnSleepStart; public static Action<int> OnSleepEnd; public static Day CurrentDay => (Day)NetworkSingleton<TimeManager>.Instance.CurrentDay; public static int ElapsedDays => NetworkSingleton<TimeManager>.Instance.ElapsedDays; public static int CurrentTime => NetworkSingleton<TimeManager>.Instance.CurrentTime; public static bool IsNight => NetworkSingleton<TimeManager>.Instance.IsNight; public static bool IsEndOfDay => NetworkSingleton<TimeManager>.Instance.IsEndOfDay; public static bool SleepInProgress => NetworkSingleton<TimeManager>.Instance.SleepInProgress; public static bool TimeOverridden => NetworkSingleton<TimeManager>.Instance.TimeOverridden; public static float NormalizedTime => NetworkSingleton<TimeManager>.Instance.NormalizedTime; public static float Playtime => NetworkSingleton<TimeManager>.Instance.Playtime; static TimeManager() { OnDayPass = delegate { }; OnWeekPass = delegate { }; OnSleepStart = delegate { }; OnSleepEnd = delegate { }; if ((Object)(object)NetworkSingleton<TimeManager>.Instance != (Object)null) { TimeManager instance = NetworkSingleton<TimeManager>.Instance; instance.onDayPass = (Action)Delegate.Combine(instance.onDayPass, (Action)delegate { OnDayPass(); }); TimeManager instance2 = NetworkSingleton<TimeManager>.Instance; instance2.onWeekPass = (Action)Delegate.Combine(instance2.onWeekPass, (Action)delegate { OnWeekPass(); }); } TimeManager.onSleepStart = (Action)Delegate.Combine(TimeManager.onSleepStart, (Action)delegate { OnSleepStart(); }); TimeManager.onSleepEnd = (Action<int>)Delegate.Combine(TimeManager.onSleepEnd, (Action<int>)delegate(int minutes) { OnSleepEnd(minutes); }); } public static void FastForwardToWakeTime() { NetworkSingleton<TimeManager>.Instance.FastForwardToWakeTime(); } public static void SetTime(int time24h, bool local = false) { NetworkSingleton<TimeManager>.Instance.SetTime(time24h, local); } public static void SetElapsedDays(int days) { NetworkSingleton<TimeManager>.Instance.SetElapsedDays(days); } public static string GetFormatted12HourTime() { return TimeManager.Get12HourTime((float)CurrentTime, true); } public static bool IsCurrentTimeWithinRange(int startTime24h, int endTime24h) { return NetworkSingleton<TimeManager>.Instance.IsCurrentTimeWithinRange(startTime24h, endTime24h); } public static int GetMinutesFrom24HourTime(int time24h) { return TimeManager.GetMinSumFrom24HourTime(time24h); } public static int Get24HourTimeFromMinutes(int minutes) { return TimeManager.Get24HourTimeFromMinSum(minutes); } } } namespace S1API.Entities { public abstract class NPC : Saveable, IEntity, IHealth { protected readonly List<Response> Responses = new List<Response>(); public static readonly List<NPC> All = new List<NPC>(); internal readonly NPC S1NPC; internal readonly bool IsCustomNPC; private readonly FieldInfo _panicField = AccessTools.Field(typeof(NPC), "PANIC_DURATION"); private readonly FieldInfo _requiresRegionUnlockedField = AccessTools.Field(typeof(NPC), "RequiresRegionUnlocked"); private readonly MethodInfo _unsettleMethod = AccessTools.Method(typeof(NPC), "SetUnsettled", (Type[])null, (Type[])null); private readonly MethodInfo _removePanicMethod = AccessTools.Method(typeof(NPC), "RemovePanicked", (Type[])null, (Type[])null); public GameObject gameObject { get; } public Vector3 Position { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return gameObject.transform.position; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1NPC.Movement.Warp(value); } } public Transform Transform => gameObject.transform; public string FirstName { get { return S1NPC.FirstName; } set { S1NPC.FirstName = value; } } public string LastName { get { return S1NPC.LastName; } set { S1NPC.LastName = value; } } public string FullName => S1NPC.fullName; public string ID { get { return S1NPC.ID; } protected set { S1NPC.ID = value; } } public Sprite Icon { get { return S1NPC.MugshotSprite; } set { S1NPC.MugshotSprite = value; } } public bool IsConscious => S1NPC.IsConscious; public bool IsInBuilding => S1NPC.isInBuilding; public bool IsInVehicle => S1NPC.IsInVehicle; public bool IsPanicking => S1NPC.IsPanicked; public bool IsUnsettled => S1NPC.isUnsettled; public bool IsVisible => S1NPC.isVisible; public float Aggressiveness { get { return S1NPC.Aggression; } set { S1NPC.Aggression = value; } } public Region Region => (Region)S1NPC.Region; public float PanicDuration { get { return (float)_panicField.GetValue(S1NPC); } set { _panicField.SetValue(S1NPC, value); } } public float Scale { get { return S1NPC.Scale; } set { S1NPC.SetScale(value); } } public bool IsKnockedOut => S1NPC.Health.IsKnockedOut; public bool RequiresRegionUnlocked { get { return (bool)_requiresRegionUnlockedField.GetValue(S1NPC); } set { _panicField.SetValue(S1NPC, value); } } public float CurrentHealth => S1NPC.Health.Health; public float MaxHealth { get { return S1NPC.Health.MaxHealth; } set { S1NPC.Health.MaxHealth = value; } } public bool IsDead => S1NPC.Health.IsDead; public bool IsInvincible { get { return S1NPC.Health.Invincible; } set { S1NPC.Health.Invincible = value; } } public event Action OnDeath { add { EventHelper.AddListener(value, S1NPC.Health.onDie); } remove { EventHelper.RemoveListener(value, S1NPC.Health.onDie); } } public event Action OnInventoryChanged { add { EventHelper.AddListener(value, S1NPC.Inventory.onContentsChanged); } remove { EventHelper.RemoveListener(value, S1NPC.Inventory.onContentsChanged); } } protected NPC(string id, string? firstName, string? lastName, Sprite? icon = null) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Expected O, but got Unknown //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Expected O, but got Unknown //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Expected O, but got Unknown //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Expected O, but got Unknown //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Expected O, but got Unknown //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Expected O, but got Unknown IsCustomNPC = true; gameObject = new GameObject(); gameObject.SetActive(false); S1NPC = gameObject.AddComponent<NPC>(); S1NPC.FirstName = firstName; S1NPC.LastName = lastName; S1NPC.ID = id; S1NPC.MugshotSprite = icon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; S1NPC.BakedGUID = Guid.NewGuid().ToString(); S1NPC.ConversationCategories = new List<EConversationCategory>(); S1NPC.ConversationCategories.Add((EConversationCategory)0); MethodInfo methodInfo = AccessTools.Method(typeof(NPC), "CreateMessageConversation", (Type[])null, (Type[])null); methodInfo.Invoke(S1NPC, null); S1NPC.Health = gameObject.GetComponent<NPCHealth>(); S1NPC.Health.onDie = new UnityEvent(); S1NPC.Health.onKnockedOut = new UnityEvent(); S1NPC.Health.Invincible = true; S1NPC.Health.MaxHealth = 100f; GameObject val = new GameObject("NPCAwareness"); val.transform.SetParent(gameObject.transform); S1NPC.awareness = val.AddComponent<NPCAwareness>(); S1NPC.awareness.onExplosionHeard = new UnityEvent<NoiseEvent>(); S1NPC.awareness.onGunshotHeard = new UnityEvent<NoiseEvent>(); S1NPC.awareness.onHitByCar = new UnityEvent<LandVehicle>(); S1NPC.awareness.onNoticedDrugDealing = new UnityEvent<Player>(); S1NPC.awareness.onNoticedGeneralCrime = new UnityEvent<Player>(); S1NPC.awareness.onNoticedPettyCrime = new UnityEvent<Player>(); S1NPC.awareness.onNoticedPlayerViolatingCurfew = new UnityEvent<Player>(); S1NPC.awareness.onNoticedSuspiciousPlayer = new UnityEvent<Player>(); S1NPC.awareness.Listener = gameObject.AddComponent<Listener>(); GameObject val2 = new GameObject("NPCBehaviour"); val2.transform.SetParent(gameObject.transform); NPCBehaviour val3 = val2.AddComponent<NPCBehaviour>(); GameObject val4 = new GameObject("CowingBehaviour"); val4.transform.SetParent(val2.transform); CoweringBehaviour coweringBehaviour = val4.AddComponent<CoweringBehaviour>(); GameObject val5 = new GameObject("FleeBehaviour"); val5.transform.SetParent(val2.transform); FleeBehaviour fleeBehaviour = val5.AddComponent<FleeBehaviour>(); val3.CoweringBehaviour = coweringBehaviour; val3.FleeBehaviour = fleeBehaviour; S1NPC.behaviour = val3; GameObject val6 = new GameObject("NPCResponses"); val6.transform.SetParent(gameObject.transform); S1NPC.awareness.Responses = (NPCResponses)(object)val6.AddComponent<NPCResponses_Civilian>(); GameObject val7 = new GameObject("VisionCone"); val7.transform.SetParent(gameObject.transform); VisionCone val8 = val7.AddComponent<VisionCone>(); val8.StatesOfInterest.Add(new StateContainer { state = (EVisualState)4, RequiredNoticeTime = 0.1f }); S1NPC.awareness.VisionCone = val8; S1NPC.awareness.VisionCone.QuestionMarkPopup = gameObject.AddComponent<WorldspacePopup>(); FieldInfo fieldInfo = AccessTools.Field(typeof(NPC), "intObj"); fieldInfo.SetValue(S1NPC, gameObject.AddComponent<InteractableObject>()); S1NPC.RelationData = new NPCRelationData(); NPCInventory val9 = gameObject.AddComponent<NPCInventory>(); val9.PickpocketIntObj = gameObject.AddComponent<InteractableObject>(); S1NPC.Avatar = Singleton<MugshotGenerator>.Instance.MugshotRig; gameObject.SetActive(true); All.Add(this); } protected virtual void OnResponseLoaded(Response response) { } public void Revive() { S1NPC.Health.Revive(); } public void Damage(int amount) { if (amount > 0) { S1NPC.Health.TakeDamage((float)amount, true); } } public void Heal(int amount) { if (amount > 0) { float num = Mathf.Min((float)amount, S1NPC.Health.MaxHealth - S1NPC.Health.Health); S1NPC.Health.TakeDamage(0f - num, false); } } public void Kill() { S1NPC.Health.TakeDamage(S1NPC.Health.MaxHealth, true); } public void Unsettle(float duration) { _unsettleMethod.Invoke(S1NPC, new object[1] { duration }); } public void LerpScale(float scale, float lerpTime) { S1NPC.SetScale(scale, lerpTime); } public void Panic() { S1NPC.SetPanicked(); } public void StopPanicking() { _removePanicMethod.Invoke(S1NPC, new object[0]); } public void KnockOut() { S1NPC.Health.KnockOut(); } public void Goto(Vector3 position) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1NPC.Movement.SetDestination(position); } public void SendTextMessage(string message, Response[]? responses = null, float responseDelay = 1f, bool network = true) { S1NPC.SendTextMessage(message); S1NPC.MSGConversation.ClearResponses(false); if (responses != null && responses.Length != 0) { Responses.Clear(); List<Response> list = new List<Response>(); foreach (Response response in responses) { Responses.Add(response); list.Add(response.S1Response); } S1NPC.MSGConversation.ShowResponses(list, responseDelay, network); } } public static NPC? Get<T>() { return All.FirstOrDefault((NPC npc) => npc.GetType() == typeof(T)); } internal NPC(NPC npc) { S1NPC = npc; gameObject = ((Component)npc).gameObject; IsCustomNPC = false; All.Add(this); } internal override void CreateInternal() { foreach (Response currentResponse in S1NPC.MSGConversation.currentResponses) { Response response = new Response(currentResponse) { Label = currentResponse.label, Text = currentResponse.text }; Responses.Add(response); OnResponseLoaded(response); } base.CreateInternal(); } internal override void SaveInternal(string folderPath, ref List<string> extraSaveables) { string folderPath2 = Path.Combine(folderPath, S1NPC.SaveFolderName); base.SaveInternal(folderPath2, ref extraSaveables); } } public class Player : IEntity, IHealth { private const float InvincibleHealth = 1E+09f; private const float MortalHealth = 100f; public static readonly List<Player> All = new List<Player>(); internal Player S1Player; private readonly FieldInfo _maxHealthField = AccessTools.Field(typeof(PlayerHealth), "MAX_HEALTH"); public static Player Local => All.FirstOrDefault((Player player) => player.IsLocal); public bool IsLocal => S1Player.IsLocalPlayer; public string Name => S1Player.PlayerName; GameObject IEntity.gameObject => ((Component)S1Player).gameObject; public Vector3 Position { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return ((IEntity)this).gameObject.transform.position; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) ((IEntity)this).gameObject.transform.position = value; } } public Transform Transform => ((IEntity)this).gameObject.transform; public float Scale { get { return S1Player.Scale; } set { S1Player.SetScale(value); } } public float CurrentHealth => S1Player.Health.CurrentHealth; public float MaxHealth { get { return (float)_maxHealthField.GetValue(S1Player.Health); } set { _maxHealthField.SetValue(S1Player.
Mods/S1API.Mono.MelonLoader.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using HarmonyLib; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using S1API; using S1API.Conditions; using S1API.Dialogues; using S1API.Entities; using S1API.Entities.Interfaces; using S1API.GameTime; using S1API.Internal.Abstraction; using S1API.Internal.Patches; using S1API.Internal.Utils; using S1API.Items; using S1API.Logging; using S1API.Map; using S1API.Messaging; using S1API.Money; using S1API.PhoneApp; using S1API.PhoneCalls.Constants; using S1API.Products; using S1API.Quests; using S1API.Quests.Constants; using S1API.Saveables; using S1API.Storages; using ScheduleOne; using ScheduleOne.AvatarFramework; using ScheduleOne.Calling; using ScheduleOne.DevUtilities; using ScheduleOne.Dialogue; using ScheduleOne.Economy; using ScheduleOne.GameTime; using ScheduleOne.Interaction; using ScheduleOne.ItemFramework; using ScheduleOne.Levelling; using ScheduleOne.Map; using ScheduleOne.Messaging; using ScheduleOne.Money; using ScheduleOne.NPCs; using ScheduleOne.NPCs.Behaviour; using ScheduleOne.NPCs.Relation; using ScheduleOne.NPCs.Responses; using ScheduleOne.NPCs.Schedules; using ScheduleOne.Noise; using ScheduleOne.Persistence.Datas; using ScheduleOne.Persistence.Loaders; using ScheduleOne.PlayerScripts; using ScheduleOne.PlayerScripts.Health; using ScheduleOne.Product; using ScheduleOne.Product.Packaging; using ScheduleOne.Property; using ScheduleOne.Quests; using ScheduleOne.ScriptableObjects; using ScheduleOne.Storage; using ScheduleOne.UI; using ScheduleOne.UI.Phone; using ScheduleOne.UI.Phone.ContactsApp; using ScheduleOne.UI.WorldspacePopup; using ScheduleOne.Variables; using ScheduleOne.Vehicles; using ScheduleOne.Vision; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; 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: MelonInfo(typeof(global::S1API.S1API), "S1API", "1.6.2", "KaBooMa", null)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KaBooMa")] [assembly: AssemblyConfiguration("MonoMelon")] [assembly: AssemblyDescription("A Schedule One Mono / Il2Cpp Cross Compatibility Layer")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d9665e9bd95b76b033fb53d5c1698afa82fe53ac")] [assembly: AssemblyProduct("S1API")] [assembly: AssemblyTitle("S1API")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/KaBooMa/S1API")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } public class DialogueInjection { public string NpcName; public string ContainerName; public string FromNodeGuid; public string ToNodeGuid; public string ChoiceLabel; public string ChoiceText; public Action OnConfirmed; public DialogueInjection(string npc, string container, string from, string to, string label, string text, Action onConfirmed) { NpcName = npc; ContainerName = container; FromNodeGuid = from; ToNodeGuid = to; ChoiceLabel = label; ChoiceText = text; OnConfirmed = onConfirmed; } } public static class DialogueInjector { private static List<DialogueInjection> pendingInjections = new List<DialogueInjection>(); private static bool isHooked = false; public static void Register(DialogueInjection injection) { pendingInjections.Add(injection); HookUpdateLoop(); } private static void HookUpdateLoop() { if (!isHooked) { isHooked = true; MelonCoroutines.Start(WaitForNPCsAndInject()); } } private static IEnumerator WaitForNPCsAndInject() { while (pendingInjections.Count > 0) { for (int i = pendingInjections.Count - 1; i >= 0; i--) { DialogueInjection injection = pendingInjections[i]; NPC[] npcs = Object.FindObjectsOfType<NPC>(); NPC target = null; for (int j = 0; j < npcs.Length; j++) { if ((Object)(object)npcs[j] != (Object)null && ((Object)npcs[j]).name.Contains(injection.NpcName)) { target = npcs[j]; break; } } if ((Object)(object)target != (Object)null) { TryInject(injection, target); pendingInjections.RemoveAt(i); } } yield return null; } } private static void TryInject(DialogueInjection injection, NPC npc) { //IL_00d7: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown DialogueHandler component = ((Component)npc).GetComponent<DialogueHandler>(); NPCEvent_LocationDialogue componentInChildren = ((Component)npc).GetComponentInChildren<NPCEvent_LocationDialogue>(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.DialogueOverride == (Object)null || ((Object)componentInChildren.DialogueOverride).name != injection.ContainerName) { return; } DialogueContainer dialogueOverride = componentInChildren.DialogueOverride; if (dialogueOverride.DialogueNodeData == null) { return; } DialogueNodeData val = null; for (int i = 0; i < dialogueOverride.DialogueNodeData.Count; i++) { DialogueNodeData val2 = dialogueOverride.DialogueNodeData.ToArray()[i]; if (val2 != null && val2.Guid == injection.FromNodeGuid) { val = val2; break; } } if (val != null) { DialogueChoiceData val3 = new DialogueChoiceData { Guid = Guid.NewGuid().ToString(), ChoiceLabel = injection.ChoiceLabel, ChoiceText = injection.ChoiceText }; List<DialogueChoiceData> list = new List<DialogueChoiceData>(); if (val.choices != null) { list.AddRange(val.choices); } list.Add(val3); val.choices = list.ToArray(); NodeLinkData item = new NodeLinkData { BaseDialogueOrBranchNodeGuid = injection.FromNodeGuid, BaseChoiceOrOptionGUID = val3.Guid, TargetNodeGuid = injection.ToNodeGuid }; if (dialogueOverride.NodeLinks == null) { dialogueOverride.NodeLinks = new List<NodeLinkData>(); } dialogueOverride.NodeLinks.Add(item); DialogueChoiceListener.Register(component, injection.ChoiceLabel, injection.OnConfirmed); } } } public class ClickHandler { private readonly UnityAction _callback; public ClickHandler(UnityAction callback) { _callback = callback; } public void OnClick() { _callback.Invoke(); } } namespace S1API { public class S1API : MelonMod { } } namespace S1API.UI { 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<RectTransform>(); 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<Image>(); ((Graphic)val3).color = bgColor; return val; } public static Text Text(string name, string content, Transform parent, int fontSize = 14, TextAnchor anchor = 0, FontStyle style = 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<RectTransform>(); Text val3 = val.AddComponent<Text>(); val3.text = content; val3.fontSize = fontSize; val3.alignment = anchor; val3.fontStyle = style; val3.font = Resources.GetBuiltinResource<Font>("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<RectTransform>(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; scrollRect = val.AddComponent<ScrollRect>(); scrollRect.horizontal = false; GameObject val3 = new GameObject("Viewport"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent<RectTransform>(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; ((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.05f); val3.AddComponent<Mask>().showMaskGraphic = false; scrollRect.viewport = val4; GameObject val5 = new GameObject("Content"); val5.transform.SetParent(val3.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = new Vector2(0f, 1f); val6.anchorMax = new Vector2(1f, 1f); val6.pivot = new Vector2(0.5f, 1f); VerticalLayoutGroup val7 = val5.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val7).spacing = 10f; ((LayoutGroup)val7).padding = new RectOffset(10, 10, 10, 10); ((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val7).childForceExpandHeight = false; val5.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; scrollRect.content = val6; return val6; } public static void FitContentHeight(RectTransform content) { ContentSizeFitter val = ((Component)content).gameObject.GetComponent<ContentSizeFitter>(); if ((Object)(object)val == (Object)null) { val = ((Component)content).gameObject.AddComponent<ContentSizeFitter>(); } 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<RectTransform>(); val2.sizeDelta = new Vector2(width, height); LayoutElement val3 = val.AddComponent<LayoutElement>(); val3.preferredWidth = width; val3.preferredHeight = height; Image val4 = val.AddComponent<Image>(); val4.sprite = GetRoundedSprite(); val4.type = (Type)1; ((Graphic)val4).color = Color.white; Mask val5 = val.AddComponent<Mask>(); val5.showMaskGraphic = true; GameObject val6 = new GameObject(name); val6.transform.SetParent(val.transform, false); RectTransform val7 = val6.AddComponent<RectTransform>(); val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = Vector2.zero; val7.offsetMax = Vector2.zero; Image val8 = val6.AddComponent<Image>(); ((Graphic)val8).color = bgColor; val8.sprite = GetRoundedSprite(); val8.type = (Type)1; Button val9 = val6.AddComponent<Button>(); ((Selectable)val9).targetGraphic = (Graphic)(object)val8; GameObject val10 = new GameObject("Label"); val10.transform.SetParent(val6.transform, false); RectTransform val11 = val10.AddComponent<RectTransform>(); val11.anchorMin = Vector2.zero; val11.anchorMax = Vector2.one; val11.offsetMin = Vector2.zero; val11.offsetMax = Vector2.zero; Text val12 = val10.AddComponent<Text>(); val12.text = label; val12.alignment = (TextAnchor)4; val12.fontSize = fontSize; val12.fontStyle = (FontStyle)1; ((Graphic)val12).color = textColor; val12.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); return (val, val9, val12); } private static Sprite GetRoundedSprite() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)roundedSprite != (Object)null) { return roundedSprite; } int num = 32; Texture2D val = new Texture2D(num, num, (TextureFormat)5, false); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); float num2 = 6f; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { bool flag = ((float)j < num2 && (float)i < num2 && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) > num2) || ((float)j > (float)num - num2 - 1f && (float)i < num2 && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)num - num2 - 1f, num2)) > num2) || ((float)j < num2 && (float)i > (float)num - num2 - 1f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, (float)num - num2 - 1f)) > num2) || ((float)j > (float)num - num2 - 1f && (float)i > (float)num - num2 - 1f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)num - num2 - 1f, (float)num - num2 - 1f)) > num2); val.SetPixel(j, i, Color32.op_Implicit(flag ? val2 : val3)); } } val.Apply(); Vector4 val4 = default(Vector4); ((Vector4)(ref val4))..ctor(8f, 8f, 8f, 8f); roundedSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, val4); return roundedSprite; } public static GameObject ButtonRow(string name, Transform parent, float spacing = 12f, TextAnchor alignment = 4) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002d: 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<RectTransform>(); HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).spacing = spacing; ((LayoutGroup)val3).childAlignment = alignment; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false; return val; } public static (GameObject, Button, Text) ButtonWithLabel(string name, string label, Transform parent, Color bgColor, float Width, float Height) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_008f: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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<RectTransform>(); val2.sizeDelta = new Vector2(Height, Width); Image val3 = val.AddComponent<Image>(); ((Graphic)val3).color = bgColor; val3.sprite = Resources.GetBuiltinResource<Sprite>("UI/Skin/UISprite.psd"); val3.type = (Type)1; Button val4 = val.AddComponent<Button>(); ((Selectable)val4).targetGraphic = (Graphic)(object)val3; GameObject val5 = new GameObject("Label"); val5.transform.SetParent(val.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = Vector2.zero; val6.offsetMax = Vector2.zero; Text val7 = val5.AddComponent<Text>(); val7.text = label; val7.alignment = (TextAnchor)4; val7.fontSize = 16; val7.fontStyle = (FontStyle)1; ((Graphic)val7).color = Color.white; val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); return (val, val4, val7); } public static void SetIcon(Sprite sprite, Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Icon"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; Image val3 = val.AddComponent<Image>(); val3.sprite = sprite; val3.preserveAspect = true; } public static void CreateTextBlock(Transform parent, string title, string subtitle, bool isCompleted) { Text(((Object)parent).name + "Title", title, parent, 16, (TextAnchor)3, (FontStyle)1); Text(((Object)parent).name + "Subtitle", subtitle, parent, 14, (TextAnchor)0, (FontStyle)0); if (isCompleted) { Text("CompletedLabel", "<color=#888888><i>Already Delivered</i></color>", parent, 12, (TextAnchor)0, (FontStyle)0); } } public static void CreateRowButton(GameObject go, UnityAction clickHandler, bool enabled) { Button val = go.AddComponent<Button>(); Image component = go.GetComponent<Image>(); ((Selectable)val).targetGraphic = (Graphic)(object)component; ((Selectable)val).interactable = enabled; ((UnityEvent)val.onClick).AddListener(clickHandler); } public static void ClearChildren(Transform parent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in parent) { Transform val = item; Object.Destroy((Object)(object)((Component)val).gameObject); } } public static void VerticalLayoutOnGO(GameObject go, int spacing = 10, RectOffset? padding = null) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) VerticalLayoutGroup val = go.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val).spacing = spacing; ((LayoutGroup)val).padding = (RectOffset)(((object)padding) ?? ((object)new RectOffset(10, 10, 10, 10))); } public static GameObject CreateQuestRow(string name, Transform parent, out GameObject iconPanel, out GameObject textPanel) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Row_" + name); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = new Vector2(0f, 90f); val.AddComponent<LayoutElement>().minHeight = 50f; ((Shadow)val.AddComponent<Outline>()).effectColor = new Color(0f, 0f, 0f, 0.2f); GameObject val3 = Panel("Separator", val.transform, new Color(1f, 1f, 1f, 0.05f)); val3.GetComponent<RectTransform>().sizeDelta = new Vector2(300f, 1f); Image val4 = val.AddComponent<Image>(); ((Graphic)val4).color = new Color(0.12f, 0.12f, 0.12f); Button val5 = val.AddComponent<Button>(); ((Selectable)val5).targetGraphic = (Graphic)(object)val4; HorizontalLayoutGroup val6 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val6).spacing = 20f; ((LayoutGroup)val6).padding = new RectOffset(75, 10, 10, 10); ((LayoutGroup)val6).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)val6).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val6).childForceExpandHeight = false; LayoutElement val7 = val.AddComponent<LayoutElement>(); val7.minHeight = 90f; val7.flexibleWidth = 1f; iconPanel = Panel("IconPanel", val.transform, new Color(0.12f, 0.12f, 0.12f)); RectTransform component = iconPanel.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(80f, 80f); LayoutElement val8 = iconPanel.AddComponent<LayoutElement>(); val8.preferredWidth = 80f; val8.preferredHeight = 80f; textPanel = Panel("TextPanel", val.transform, Color.clear); VerticalLayoutOnGO(textPanel, 2); LayoutElement val9 = textPanel.AddComponent<LayoutElement>(); val9.minWidth = 200f; val9.flexibleWidth = 1f; return val; } public static GameObject TopBar(string name, Transform parent, string title, float topbarSize, int paddingLeft, int paddingRight, int paddingTop, int paddingBottom) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown GameObject val = Panel(name, parent, new Color(0.15f, 0.15f, 0.15f), (Vector2?)new Vector2(0f, topbarSize), (Vector2?)new Vector2(1f, 1f), fullAnchor: false); HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>(); ((LayoutGroup)val2).padding = new RectOffset(paddingLeft, paddingRight, paddingTop, paddingBottom); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 20f; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = true; Text val3 = Text("TopBarTitle", title, val.transform, 26, (TextAnchor)3, (FontStyle)1); LayoutElement val4 = ((Component)val3).gameObject.AddComponent<LayoutElement>(); val4.minWidth = 300f; val4.flexibleWidth = 1f; return val; } public static void HorizontalLayoutOnGO(GameObject go, int spacing = 10, int padLeft = 0, int padRight = 0, int padTop = 0, int padBottom = 0, TextAnchor alignment = 4) { //IL_0012: 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_003b: Expected O, but got Unknown HorizontalLayoutGroup val = go.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val).spacing = spacing; ((LayoutGroup)val).childAlignment = alignment; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false; ((LayoutGroup)val).padding = new RectOffset(padLeft, padRight, padTop, padBottom); } public static void SetLayoutGroupPadding(LayoutGroup layoutGroup, int left, int right, int top, int bottom) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown layoutGroup.padding = new RectOffset(left, right, top, bottom); } public static void BindAcceptButton(Button btn, Text label, string text, UnityAction callback) { label.text = text; ((UnityEventBase)btn.onClick).RemoveAllListeners(); ((UnityEvent)btn.onClick).AddListener(callback); } } } namespace S1API.Storages { public class StorageInstance { internal readonly StorageEntity S1Storage; public ItemSlotInstance[] Slots => (from itemSlot in S1Storage.ItemSlots.ToArray() select new ItemSlotInstance(itemSlot)).ToArray(); public event Action OnOpened { add { EventHelper.AddListener(value, S1Storage.onOpened); } remove { EventHelper.RemoveListener(value, S1Storage.onOpened); } } public event Action OnClosed { add { EventHelper.AddListener(value, S1Storage.onClosed); } remove { EventHelper.RemoveListener(value, S1Storage.onClosed); } } internal StorageInstance(StorageEntity storage) { S1Storage = storage; } public bool CanItemFit(ItemInstance itemInstance, int quantity = 1) { return S1Storage.CanItemFit(itemInstance.S1ItemInstance, quantity); } public void AddItem(ItemInstance itemInstance) { S1Storage.InsertItem(itemInstance.S1ItemInstance, true); } } } namespace S1API.Saveables { [AttributeUsage(AttributeTargets.Field)] public class SaveableField : Attribute { internal string SaveName { get; } public SaveableField(string saveName) { SaveName = saveName; } } } namespace S1API.Quests { public abstract class Quest : Saveable { protected readonly List<QuestEntry> QuestEntries = new List<QuestEntry>(); [SaveableField("QuestData")] private readonly QuestData _questData; internal readonly Quest S1Quest; private readonly GameObject _gameObject; protected abstract string Title { get; } protected abstract string Description { get; } protected virtual bool AutoBegin => true; protected QuestState QuestState => (QuestState)S1Quest.QuestState; internal string? SaveFolder => S1Quest.SaveFolderName; protected virtual Sprite? QuestIcon => null; public Quest() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown _questData = new QuestData(GetType().Name); _gameObject = new GameObject("Quest"); S1Quest = _gameObject.AddComponent<Quest>(); S1Quest.StaticGUID = string.Empty; FieldInfo fieldInfo = AccessTools.Field(typeof(Quest), "title"); fieldInfo.SetValue(S1Quest, Title); S1Quest.onActiveState = new UnityEvent(); S1Quest.onComplete = new UnityEvent(); S1Quest.onInitialComplete = new UnityEvent(); S1Quest.onQuestBegin = new UnityEvent(); S1Quest.onQuestEnd = new UnityEvent<EQuestState>(); S1Quest.onTrackChange = new UnityEvent<bool>(); S1Quest.TrackOnBegin = true; S1Quest.AutoCompleteOnAllEntriesComplete = true; FieldInfo fieldInfo2 = AccessTools.Field(typeof(Quest), "autoInitialize"); fieldInfo2.SetValue(S1Quest, false); GameObject val = new GameObject("IconPrefab", new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Image>() }); val.transform.SetParent(_gameObject.transform); Image component = val.GetComponent<Image>(); component.sprite = QuestIcon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; S1Quest.IconPrefab = val.GetComponent<RectTransform>(); GameObject val2 = new GameObject("PoIUIPrefab", new Type[4] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<EventTrigger>(), CrossType.Of<Button>() }); val2.transform.SetParent(_gameObject.transform); GameObject val3 = new GameObject("MainLabel", new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Text>() }); val3.transform.SetParent(val2.transform); GameObject val4 = new GameObject("IconContainer", new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Image>() }); val4.transform.SetParent(val2.transform); Image component2 = val4.GetComponent<Image>(); component2.sprite = QuestIcon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; RectTransform component3 = ((Component)component2).GetComponent<RectTransform>(); component3.sizeDelta = new Vector2(20f, 20f); GameObject val5 = new GameObject("POIPrefab"); val5.SetActive(false); val5.transform.SetParent(_gameObject.transform); POI val6 = val5.AddComponent<POI>(); val6.DefaultMainText = "Did it work?"; FieldInfo fieldInfo3 = AccessTools.Field(typeof(POI), "UIPrefab"); fieldInfo3.SetValue(val6, val2); S1Quest.PoIPrefab = val5; S1Quest.onQuestEnd.AddListener((UnityAction<EQuestState>)OnQuestEnded); } internal override void CreateInternal() { base.CreateInternal(); S1Quest.InitializeQuest(Title, Description, Array.Empty<QuestEntryData>(), S1Quest?.StaticGUID); if (AutoBegin) { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Begin(true); } } } internal override void SaveInternal(string folderPath, ref List<string> extraSaveables) { string text = Path.Combine(folderPath, S1Quest.SaveFolderName); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } base.SaveInternal(text, ref extraSaveables); } internal void OnQuestEnded(EQuestState questState) { Quest.Quests.Remove(S1Quest); QuestManager.Quests.Remove(this); } protected QuestEntry AddEntry(string title, Vector3? poiPosition = null) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("QuestEntry"); Transform transform = val.transform; GameObject gameObject = _gameObject; transform.SetParent((gameObject != null) ? gameObject.transform : null); QuestEntry val2 = val.AddComponent<QuestEntry>(); val2.PoILocation = val.transform; S1Quest.Entries.Add(val2); QuestEntry questEntry = new QuestEntry(val2) { Title = title, POIPosition = (Vector3)(((??)poiPosition) ?? Vector3.zero) }; QuestEntries.Add(questEntry); return questEntry; } public void Begin() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Begin(true); } } public void Cancel() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Cancel(true); } } public void Expire() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Expire(true); } } public void Fail() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Fail(true); } } public void Complete() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Complete(true); } } public void End() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.End(); } } } public class QuestData { public readonly string ClassName; public QuestData(string className) { ClassName = className; } } public class QuestEntry { internal readonly QuestEntry S1QuestEntry; public QuestState State => (QuestState)S1QuestEntry.State; public string Title { get { return S1QuestEntry.Title; } set { S1QuestEntry.SetEntryTitle(value); } } public Vector3 POIPosition { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return S1QuestEntry.PoILocation.position; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1QuestEntry.PoILocation.position = value; } } public event Action OnComplete { add { EventHelper.AddListener(value, S1QuestEntry.onComplete); } remove { EventHelper.RemoveListener(value, S1QuestEntry.onComplete); } } internal QuestEntry(QuestEntry questEntry) { S1QuestEntry = questEntry; } public void Begin() { S1QuestEntry.Begin(); } public void Complete() { S1QuestEntry.Complete(); } public void SetState(QuestState questState) { S1QuestEntry.SetState((EQuestState)questState, true); } } public static class QuestManager { internal static readonly List<Quest> Quests = new List<Quest>(); public static Quest CreateQuest<T>(string? guid = null) where T : Quest { return CreateQuest(typeof(T), guid); } public static Quest CreateQuest(Type questType, string? guid = null) { Quest quest = (Quest)Activator.CreateInstance(questType); if (quest == null) { throw new Exception("Unable to create quest instance of " + questType.FullName + "!"); } Quests.Add(quest); return quest; } public static Quest? GetQuestByGuid(string guid) { string guid2 = guid; return Quests.FirstOrDefault((Quest x) => x.S1Quest.StaticGUID == guid2); } public static Quest? GetQuestByName(string questName) { string questName2 = questName; return Quests.FirstOrDefault((Quest x) => x.S1Quest.Title == questName2); } } } namespace S1API.Quests.Constants { public enum QuestAction { Begin, Success, Fail, Expire, Cancel } public enum QuestState { Inactive, Active, Completed, Failed, Expired, Cancelled } } namespace S1API.Property { public abstract class BaseProperty { public abstract string PropertyName { get; } public abstract string PropertyCode { get; } public abstract float Price { get; } public abstract bool IsOwned { get; } public abstract int EmployeeCapacity { get; set; } public abstract void SetOwned(); public abstract bool IsPointInside(Vector3 point); } public static class PropertyManager { public static List<PropertyWrapper> GetAllProperties() { List<PropertyWrapper> list = new List<PropertyWrapper>(); foreach (Property property in Property.Properties) { list.Add(new PropertyWrapper(property)); } return list; } public static List<PropertyWrapper> GetOwnedProperties() { List<PropertyWrapper> list = new List<PropertyWrapper>(); foreach (Property ownedProperty in Property.OwnedProperties) { list.Add(new PropertyWrapper(ownedProperty)); } return list; } public static PropertyWrapper FindPropertyByName(string name) { foreach (Property property in Property.Properties) { if (property.PropertyName == name) { return new PropertyWrapper(property); } } return null; } } public class PropertyWrapper : BaseProperty { internal readonly Property InnerProperty; public override string PropertyName => InnerProperty.PropertyName; public override string PropertyCode => InnerProperty.PropertyCode; public override float Price => InnerProperty.Price; public override bool IsOwned => InnerProperty.IsOwned; public override int EmployeeCapacity { get { return InnerProperty.EmployeeCapacity; } set { InnerProperty.EmployeeCapacity = value; } } public PropertyWrapper(Property property) { InnerProperty = property; } public override void SetOwned() { InnerProperty.SetOwned(); } public override bool IsPointInside(Vector3 point) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return InnerProperty.DoBoundsContainPoint(point); } } } namespace S1API.Products { public class CocaineDefinition : ProductDefinition { internal CocaineDefinition S1CocaineDefinition => CrossType.As<CocaineDefinition>(S1ItemDefinition); internal CocaineDefinition(CocaineDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>(((ItemDefinition)S1CocaineDefinition).GetDefaultInstance(quantity))); } } public class MethDefinition : ProductDefinition { internal MethDefinition S1MethDefinition => CrossType.As<MethDefinition>(S1ItemDefinition); internal MethDefinition(MethDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>(((ItemDefinition)S1MethDefinition).GetDefaultInstance(quantity))); } } public class PackagingDefinition : ItemDefinition { internal PackagingDefinition S1PackagingDefinition => CrossType.As<PackagingDefinition>(S1ItemDefinition); public int Quantity => S1PackagingDefinition.Quantity; internal PackagingDefinition(ItemDefinition s1ItemDefinition) : base(s1ItemDefinition) { } } public class ProductDefinition : ItemDefinition { internal ProductDefinition S1ProductDefinition => CrossType.As<ProductDefinition>(S1ItemDefinition); public float Price => S1ProductDefinition.Price; public Sprite Icon => ((ItemDefinition)S1ProductDefinition).Icon; internal ProductDefinition(ProductDefinition productDefinition) : base((ItemDefinition)(object)productDefinition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>(((ItemDefinition)S1ProductDefinition).GetDefaultInstance(quantity))); } } internal static class ProductDefinitionWrapper { internal static ProductDefinition Wrap(ProductDefinition def) { ItemDefinition s1ItemDefinition = def.S1ItemDefinition; if (CrossType.Is<WeedDefinition>(s1ItemDefinition, out var result)) { return new WeedDefinition(result); } if (CrossType.Is<MethDefinition>(s1ItemDefinition, out var result2)) { return new MethDefinition(result2); } if (CrossType.Is<CocaineDefinition>(s1ItemDefinition, out var result3)) { return new CocaineDefinition(result3); } return def; } } public class ProductInstance : ItemInstance { internal ProductItemInstance S1ProductInstance => CrossType.As<ProductItemInstance>(S1ItemInstance); public bool IsPackaged => Object.op_Implicit((Object)(object)S1ProductInstance.AppliedPackaging); public PackagingDefinition AppliedPackaging => new PackagingDefinition((ItemDefinition)(object)S1ProductInstance.AppliedPackaging); internal ProductInstance(ProductItemInstance productInstance) : base((ItemInstance)(object)productInstance) { } } public static class ProductManager { public static ProductDefinition[] DiscoveredProducts => (from productDefinition in ProductManager.DiscoveredProducts.ToArray() select ProductDefinitionWrapper.Wrap(new ProductDefinition(productDefinition))).ToArray(); } public class WeedDefinition : ProductDefinition { internal WeedDefinition S1WeedDefinition => CrossType.As<WeedDefinition>(S1ItemDefinition); internal WeedDefinition(WeedDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>(((ItemDefinition)S1WeedDefinition).GetDefaultInstance(quantity))); } } } namespace S1API.PhoneCalls { public class CallerDefinition { internal readonly CallerID S1CallerIDEntry; public string Name { get { return S1CallerIDEntry.Name; } set { S1CallerIDEntry.Name = value; } } public Sprite? ProfilePicture { get { return S1CallerIDEntry.ProfilePicture; } set { S1CallerIDEntry.ProfilePicture = value; } } internal CallerDefinition(CallerID s1CallerID) { S1CallerIDEntry = s1CallerID; } } public static class CallManager { public static void QueueCall(PhoneCallDefinition phoneCallDefinition) { Singleton<CallManager>.Instance.QueueCall(phoneCallDefinition.S1PhoneCallData); } } public class CallStageEntry { internal readonly Stage S1Stage; protected readonly List<SystemTriggerEntry> StartTriggerEntries = new List<SystemTriggerEntry>(); protected readonly List<SystemTriggerEntry> DoneTriggerEntries = new List<SystemTriggerEntry>(); public string Text { get { return S1Stage.Text; } set { S1Stage.Text = value; } } internal CallStageEntry(Stage stage) { S1Stage = stage; } public SystemTriggerEntry AddSystemTrigger(SystemTriggerType triggerType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown SystemTrigger val = new SystemTrigger(); SystemTriggerEntry systemTriggerEntry = new SystemTriggerEntry(val); switch (triggerType) { case SystemTriggerType.StartTrigger: S1Stage.OnStartTriggers = S1Stage.OnStartTriggers.AddItemToArray(val); StartTriggerEntries.Add(systemTriggerEntry); break; case SystemTriggerType.DoneTrigger: S1Stage.OnDoneTriggers = S1Stage.OnDoneTriggers.AddItemToArray(val); DoneTriggerEntries.Add(systemTriggerEntry); break; } return systemTriggerEntry; } } public abstract class PhoneCallDefinition { public CallerDefinition? Caller; public readonly PhoneCallData S1PhoneCallData; protected readonly List<CallStageEntry> StageEntries = new List<CallStageEntry>(); protected PhoneCallDefinition(string name, Sprite? profilePicture = null) { S1PhoneCallData = ScriptableObject.CreateInstance<PhoneCallData>(); PhoneCallData s1PhoneCallData = S1PhoneCallData; if (s1PhoneCallData.Stages == null) { s1PhoneCallData.Stages = Array.Empty<Stage>(); } AddCallerID(name, profilePicture); } protected PhoneCallDefinition(NPC? npcCallerID) { S1PhoneCallData = ScriptableObject.CreateInstance<PhoneCallData>(); PhoneCallData s1PhoneCallData = S1PhoneCallData; if (s1PhoneCallData.Stages == null) { s1PhoneCallData.Stages = Array.Empty<Stage>(); } AddCallerID(npcCallerID); } protected CallerDefinition AddCallerID(string name, Sprite? profilePicture = null) { CallerID val = ScriptableObject.CreateInstance<CallerID>(); val.Name = name; val.ProfilePicture = profilePicture; S1PhoneCallData.CallerID = val; Caller = new CallerDefinition(val) { Name = name, ProfilePicture = profilePicture }; return Caller; } protected CallerDefinition AddCallerID(NPC? npc) { CallerID val = ScriptableObject.CreateInstance<CallerID>(); val.Name = npc?.FullName ?? "Unknown Caller"; val.ProfilePicture = npc?.Icon; S1PhoneCallData.CallerID = val; Caller = new CallerDefinition(val) { Name = (npc?.FullName ?? "Unknown Caller"), ProfilePicture = npc?.Icon }; return Caller; } protected CallStageEntry AddStage(string text) { //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_000e: Expected O, but got Unknown Stage val = new Stage { Text = text }; S1PhoneCallData.Stages = S1PhoneCallData.Stages.AddItemToArray(val); CallStageEntry callStageEntry = new CallStageEntry(val) { Text = text }; StageEntries.Add(callStageEntry); return callStageEntry; } public void Completed() { S1PhoneCallData.Completed(); } } } namespace S1API.PhoneCalls.Constants { public enum EvaluationType { PassOnTrue, PassOnFalse } public enum SystemTriggerType { StartTrigger, DoneTrigger } } namespace S1API.PhoneApp { public abstract class PhoneApp : Registerable { protected static readonly Log Logger = new Log("PhoneApp"); private GameObject? _appPanel; private bool _appCreated; private bool _iconModified; protected abstract string AppName { get; } protected abstract string AppTitle { get; } protected abstract string IconLabel { get; } protected abstract string IconFileName { get; } protected abstract void OnCreatedUI(GameObject container); protected override void OnCreated() { PhoneAppRegistry.Register(this); } protected override void OnDestroyed() { if ((Object)(object)_appPanel != (Object)null) { Object.Destroy((Object)(object)_appPanel); _appPanel = null; } _appCreated = false; _iconModified = false; } internal void SpawnUI(HomeScreen homeScreenInstance) { Transform obj = ((Component)homeScreenInstance).transform.parent.Find("AppsCanvas"); GameObject val = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val == (Object)null) { Logger.Error("AppsCanvas not found."); return; } Transform val2 = val.transform.Find(AppName); if ((Object)(object)val2 != (Object)null) { _appPanel = ((Component)val2).gameObject; SetupExistingAppPanel(_appPanel); } else { Transform val3 = val.transform.Find("ProductManagerApp"); if ((Object)(object)val3 == (Object)null) { Logger.Error("Template ProductManagerApp not found."); return; } _appPanel = Object.Instantiate<GameObject>(((Component)val3).gameObject, val.transform); ((Object)_appPanel).name = AppName; Transform val4 = _appPanel.transform.Find("Container"); if ((Object)(object)val4 != (Object)null) { GameObject gameObject = ((Component)val4).gameObject; ClearContainer(gameObject); OnCreatedUI(gameObject); } _appCreated = true; } _appPanel.SetActive(true); } internal void SpawnIcon(HomeScreen homeScreenInstance) { if (_iconModified) { return; } Transform obj = ((Component)homeScreenInstance).transform.Find("AppIcons"); GameObject val = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val == (Object)null) { Logger.Error("AppIcons not found under HomeScreen."); return; } Transform val2 = ((val.transform.childCount > 0) ? val.transform.GetChild(val.transform.childCount - 1) : null); if ((Object)(object)val2 == (Object)null) { Logger.Error("No icons found in AppIcons."); return; } GameObject gameObject = ((Component)val2).gameObject; ((Object)gameObject).name = AppName; Transform val3 = gameObject.transform.Find("Label"); Text val4 = ((val3 != null) ? ((Component)val3).GetComponent<Text>() : null); if ((Object)(object)val4 != (Object)null) { val4.text = IconLabel; } _iconModified = ChangeAppIconImage(gameObject, IconFileName); } private void SetupExistingAppPanel(GameObject panel) { Transform val = panel.transform.Find("Container"); if ((Object)(object)val != (Object)null) { GameObject gameObject = ((Component)val).gameObject; if (gameObject.transform.childCount < 2) { ClearContainer(gameObject); OnCreatedUI(gameObject); } } _appCreated = true; } private void ClearContainer(GameObject container) { for (int num = container.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)container.transform.GetChild(num)).gameObject); } } private bool ChangeAppIconImage(GameObject iconObj, string filename) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) Transform val = iconObj.transform.Find("Mask/Image"); Image val2 = ((val != null) ? ((Component)val).GetComponent<Image>() : null); if ((Object)(object)val2 == (Object)null) { Logger.Error("Image component not found in icon."); return false; } string text = Path.Combine(MelonEnvironment.ModsDirectory, filename); if (!File.Exists(text)) { Logger.Error("Icon file not found: " + text); return false; } try { byte[] array = File.ReadAllBytes(text); Texture2D val3 = new Texture2D(2, 2); if (ImageConversion.LoadImage(val3, array)) { val2.sprite = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f)); return true; } Object.Destroy((Object)(object)val3); } catch (Exception ex) { Logger.Error("Failed to load image: " + ex.Message); } return false; } } } namespace S1API.Money { public class CashDefinition : ItemDefinition { internal CashDefinition S1CashDefinition => CrossType.As<CashDefinition>(S1ItemDefinition); internal CashDefinition(CashDefinition s1ItemDefinition) : base((ItemDefinition)(object)s1ItemDefinition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new CashInstance(((ItemDefinition)S1CashDefinition).GetDefaultInstance(quantity)); } } public class CashInstance : ItemInstance { internal CashInstance S1CashInstance => CrossType.As<CashInstance>(S1ItemInstance); internal CashInstance(ItemInstance itemInstance) : base(itemInstance) { } public void AddQuantity(float amount) { S1CashInstance.SetBalance(Mathf.Clamp(S1CashInstance.Balance + amount, 0f, float.MaxValue), false); } public void SetQuantity(float newQuantity) { S1CashInstance.SetBalance(newQuantity, false); } } public static class Money { private static MoneyManager Internal => NetworkSingleton<MoneyManager>.Instance; public static event Action? OnBalanceChanged; public static void ChangeCashBalance(float amount, bool visualizeChange = true, bool playCashSound = false) { MoneyManager @internal = Internal; if (@internal != null) { @internal.ChangeCashBalance(amount, visualizeChange, playCashSound); } Money.OnBalanceChanged?.Invoke(); } public static void CreateOnlineTransaction(string transactionName, float unitAmount, float quantity, string transactionNote) { MoneyManager @internal = Internal; if (@internal != null) { @internal.CreateOnlineTransaction(transactionName, unitAmount, quantity, transactionNote); } Money.OnBalanceChanged?.Invoke(); } public static float GetNetWorth() { return ((Object)(object)Internal != (Object)null) ? Internal.GetNetWorth() : 0f; } public static float GetCashBalance() { return ((Object)(object)Internal != (Object)null) ? Internal.cashBalance : 0f; } public static float GetOnlineBalance() { return ((Object)(object)Internal != (Object)null) ? Internal.sync___get_value_onlineBalance() : 0f; } public static void AddNetworthCalculation(Action<object> callback) { if ((Object)(object)Internal != (Object)null) { MoneyManager @internal = Internal; @internal.onNetworthCalculation = (Action<FloatContainer>)Delegate.Combine(@internal.onNetworthCalculation, callback); } } public static void RemoveNetworthCalculation(Action<object> callback) { if ((Object)(object)Internal != (Object)null) { MoneyManager @internal = Internal; @internal.onNetworthCalculation = (Action<FloatContainer>)Delegate.Remove(@internal.onNetworthCalculation, callback); } } public static CashInstance CreateCashInstance(float amount) { CashDefinition item = Registry.GetItem<CashDefinition>("cash"); ItemInstance itemInstance = CrossType.As<ItemInstance>(((ItemDefinition)item).GetDefaultInstance(1)); CashInstance cashInstance = new CashInstance(itemInstance); cashInstance.SetQuantity(amount); return cashInstance; } } } namespace S1API.Messaging { public class Response { internal readonly Response S1Response; public Action? OnTriggered { get { return (S1Response.callback == null) ? null : ((Action)delegate { S1Response.callback(); }); } set { S1Response.callback = value; } } public string Label { get { return S1Response.label; } set { S1Response.label = value; } } public string Text { get { return S1Response.text; } set { S1Response.text = value; } } public Response() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown S1Response = new Response(); } internal Response(Response response) { S1Response = response; } } } namespace S1API.Map { public enum Region { Northtown, Westville, Downtown, Docks, Suburbia, Uptown } } namespace S1API.Logging { public class Log { private readonly Instance _loggerInstance; public Log(string sourceName) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown _loggerInstance = new Instance(sourceName); } public void Msg(string message) { _loggerInstance.Msg(message); } public void Warning(string message) { _loggerInstance.Warning(message); } public void Error(string message) { _loggerInstance.Error(message); } public void BigError(string message) { _loggerInstance.BigError(message); } } } namespace S1API.Leveling { public static class LevelManager { public static Rank Rank = (Rank)NetworkSingleton<LevelManager>.Instance.Rank; } public enum Rank { StreetRat, Hoodlum, Peddler, Hustler, Bagman, Enforcer, ShotCaller, BlockBoss, Underlord, Baron, Kingpin } } namespace S1API.Items { public enum ItemCategory { Product, Packaging, Growing, Tools, Furniture, Lighting, Cash, Consumable, Equipment, Ingredient, Decoration, Clothing } public class ItemDefinition : IGUIDReference { internal readonly ItemDefinition S1ItemDefinition; public virtual string GUID => S1ItemDefinition.ID; public string ID => S1ItemDefinition.ID; public string Name => S1ItemDefinition.Name; public string Description => S1ItemDefinition.Description; public ItemCategory Category => (ItemCategory)S1ItemDefinition.Category; public int StackLimit => S1ItemDefinition.StackLimit; internal ItemDefinition(ItemDefinition s1ItemDefinition) { S1ItemDefinition = s1ItemDefinition; } internal static ItemDefinition GetFromGUID(string guid) { return ItemManager.GetItemDefinition(guid); } public override bool Equals(object? obj) { return obj is ItemDefinition itemDefinition && (Object)(object)S1ItemDefinition == (Object)(object)itemDefinition.S1ItemDefinition; } public override int GetHashCode() { return ((object)S1ItemDefinition)?.GetHashCode() ?? 0; } public static bool operator ==(ItemDefinition? left, ItemDefinition? right) { if ((object)left == right) { return true; } return (Object)(object)left?.S1ItemDefinition == (Object)(object)right?.S1ItemDefinition; } public static bool operator !=(ItemDefinition left, ItemDefinition right) { return !(left == right); } public virtual ItemInstance CreateInstance(int quantity = 1) { return new ItemInstance(S1ItemDefinition.GetDefaultInstance(quantity)); } } public class ItemInstance { internal readonly ItemInstance S1ItemInstance; public ItemDefinition Definition => new ItemDefinition(S1ItemInstance.Definition); internal ItemInstance(ItemInstance itemInstance) { S1ItemInstance = itemInstance; } } public static class ItemManager { public static ItemDefinition GetItemDefinition(string itemID) { ItemDefinition item = Registry.GetItem(itemID); if (CrossType.Is<ProductDefinition>(item, out var result)) { return new ProductDefinition(result); } if (CrossType.Is<CashDefinition>(item, out var result2)) { return new CashDefinition(result2); } return new ItemDefinition(item); } } public class ItemSlotInstance { internal readonly ItemSlot S1ItemSlot; public int Quantity => S1ItemSlot.Quantity; public ItemInstance? ItemInstance { get { if (CrossType.Is<ProductItemInstance>(S1ItemSlot.ItemInstance, out var result)) { return new ProductInstance(result); } if (CrossType.Is<CashInstance>(S1ItemSlot.ItemInstance, out var result2)) { return new CashInstance((ItemInstance)(object)result2); } if (CrossType.Is<ItemInstance>(S1ItemSlot.ItemInstance, out var result3)) { return new ItemInstance(result3); } return null; } } internal ItemSlotInstance(ItemSlot itemSlot) { S1ItemSlot = itemSlot; } public void AddQuantity(int amount) { S1ItemSlot.ChangeQuantity(amount, false); } } } namespace S1API.Internal.Utils { public static class ArrayExtensions { public static T[] AddItemToArray<T>(this T[]? array, T item) { if (array == null) { array = Array.Empty<T>(); } Array.Resize(ref array, array.Length + 1); array[^1] = item; return array; } } public static class ButtonUtils { public static void AddListener(Button button, Action action) { if (!((Object)(object)button == (Object)null) && action != null) { EventHelper.AddListener(action, (UnityEvent)(object)button.onClick); } } public static void RemoveListener(Button button, Action action) { if (!((Object)(object)button == (Object)null) && action != null) { EventHelper.RemoveListener(action, (UnityEvent)(object)button.onClick); } } public static void ClearListeners(Button button) { if (!((Object)(object)button == (Object)null)) { ((UnityEventBase)button.onClick).RemoveAllListeners(); } } public static void Enable(Button button, Text? label = null, string? text = null) { if ((Object)(object)button != (Object)null) { ((Selectable)button).interactable = true; } if ((Object)(object)label != (Object)null && !string.IsNullOrEmpty(text)) { label.text = text; } } public static void Disable(Button button, Text? label = null, string? text = null) { if ((Object)(object)button != (Object)null) { ((Selectable)button).interactable = false; } if ((Object)(object)label != (Object)null && !string.IsNullOrEmpty(text)) { label.text = text; } } public static void SetLabel(Text label, string text) { if ((Object)(object)label != (Object)null) { label.text = text; } } public static void SetStyle(Button button, Text label, string text, Color bg) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)button == (Object)null) && !((Object)(object)label == (Object)null)) { label.text = text; ((Graphic)((Selectable)button).image).color = bg; } } } internal static class CrossType { internal static Type Of<T>() { return typeof(T); } internal static bool Is<T>(object obj, out T result) where T : class { if (obj is T val) { result = val; return true; } result = null; return false; } internal static T As<T>(object obj) where T : class { return (T)obj; } } public static class ImageUtils { private static readonly Log _loggerInstance = new Log("ImageUtils"); public static Sprite? LoadImage(string fileName) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, fileName); if (!File.Exists(text)) { _loggerInstance.Error("❌ Icon file not found: " + text); return null; } try { byte[] array = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2); if (ImageConversion.LoadImage(val, array)) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } catch (Exception ex) { _loggerInstance.Error("❌ Failed to load sprite: " + ex); } return null; } } public static class RandomUtils { private static readonly Random SystemRng = new Random(); public static T PickOne<T>(this IList<T> list) { if (list == null || list.Count == 0) { return default(T); } return list[Random.Range(0, list.Count)]; } public static T PickUnique<T>(this IList<T> list, Func<T, bool> isDuplicate, int maxTries = 10) { if (list.Count == 0) { return default(T); } for (int i = 0; i < maxTries; i++) { T val = list.PickOne(); if (!isDuplicate(val)) { return val; } } return default(T); } public static List<T> PickMany<T>(this IList<T> list, int count) { if (list.Count == 0) { return new List<T>(); } List<T> list2 = new List<T>(list); List<T> list3 = new List<T>(); for (int i = 0; i < count; i++) { if (list2.Count <= 0) { break; } int index = Random.Range(0, list2.Count); list3.Add(list2[index]); list2.RemoveAt(index); } return list3; } public static int RangeInt(int minInclusive, int maxExclusive) { return SystemRng.Next(minInclusive, maxExclusive); } } internal static class ReflectionUtils { internal static List<Type> GetDerivedClasses<TBaseClass>() { List<Type> list = new List<Type>(); Assembly[] array = (from assembly in AppDomain.CurrentDomain.GetAssemblies() where !assembly.FullName.StartsWith("System") && !assembly.FullName.StartsWith("Unity") && !assembly.FullName.StartsWith("Il2Cpp") && !assembly.FullName.StartsWith("mscorlib") && !assembly.FullName.StartsWith("Mono.") && !assembly.FullName.StartsWith("netstandard") && !assembly.FullName.StartsWith("com.rlabrecque") && !assembly.FullName.StartsWith("__Generated") select assembly).ToArray(); Assembly[] array2 = array; foreach (Assembly assembly2 in array2) { list.AddRange(from type in assembly2.GetTypes() where typeof(TBaseClass).IsAssignableFrom(type) && type != typeof(TBaseClass) && !type.IsAbstract select type); } return list; } internal static Type? GetTypeByName(string typeName) { string typeName2 = typeName; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array = assemblies; foreach (Assembly assembly in array) { Type type2 = assembly.GetTypes().FirstOrDefault((Type type) => type.Name == typeName2); if (!(type2 == null)) { return type2; } } return null; } internal static FieldInfo[] GetAllFields(Type? type, BindingFlags bindingFlags) { List<FieldInfo> list = new List<FieldInfo>(); while (type != null && type != typeof(object)) { list.AddRange(type.GetFields(bindingFlags)); type = type.BaseType; } return list.ToArray(); } public static MethodInfo? GetMethod(Type? type, string methodName, BindingFlags bindingFlags) { while (type != null && type != typeof(object)) { MethodInfo method = type.GetMethod(methodName, bindingFlags); if (method != null) { return method; } type = type.BaseType; } return null; } } } namespace S1API.Internal.Patches { [HarmonyPatch(typeof(HomeScreen), "Start")] internal static class HomeScreen_Start_Patch { private static readonly Log Logger = new Log("PhoneApp"); private static void Postfix(HomeScreen __instance) { if ((Object)(object)__instance == (Object)null) { return; } List<Type> derivedClasses = ReflectionUtils.GetDerivedClasses<global::S1API.PhoneApp.PhoneApp>(); foreach (Type item in derivedClasses) { Logger.Msg("Found phone app: " + item.FullName); if (!(item.GetConstructor(Type.EmptyTypes) == null)) { try { global::S1API.PhoneApp.PhoneApp phoneApp = (global::S1API.PhoneApp.PhoneApp)Activator.CreateInstance(item); ((IRegisterable)phoneApp).CreateInternal(); phoneApp.SpawnUI(__instance); phoneApp.SpawnIcon(__instance); } catch (Exception ex) { Logger.Warning("[PhoneApp] Failed to register " + item.FullName + ": " + ex.Message); } } } } } [HarmonyPatch] internal class NPCPatches { [HarmonyPatch(typeof(NPCsLoader), "Load")] [HarmonyPrefix] private static void NPCsLoadersLoad(NPCsLoader __instance, string mainPath) { foreach (Type derivedClass in ReflectionUtils.GetDerivedClasses<NPC>()) { NPC nPC = (NPC)Activator.CreateInstance(derivedClass, nonPublic: true); if (nPC == null) { throw new Exception("Unable to create instance of " + derivedClass.FullName + "!"); } if (!(derivedClass.Assembly == Assembly.GetExecutingAssembly())) { string folderPath = Path.Combine(mainPath, nPC.S1NPC.SaveFolderName); nPC.LoadInternal(folderPath); } } } [HarmonyPatch(typeof(NPC), "Start")] [HarmonyPostfix] private static void NPCStart(NPC __instance) { NPC __instance2 = __instance; NPC.All.FirstOrDefault((NPC npc) => npc.IsCustomNPC && (Object)(object)npc.S1NPC == (Object)(object)__instance2)?.CreateInternal(); } [HarmonyPatch(typeof(NPC), "WriteData")] [HarmonyPostfix] private static void NPCWriteData(NPC __instance, string parentFolderPath, ref List<string> __result) { NPC __instance2 = __instance; NPC.All.FirstOrDefault((NPC npc) => npc.IsCustomNPC && (Object)(object)npc.S1NPC == (Object)(object)__instance2)?.SaveInternal(parentFolderPath, ref __result); } [HarmonyPatch(typeof(NPC), "OnDestroy")] [HarmonyPostfix] private static void NPCOnDestroy(NPC __instance) { NPC __instance2 = __instance; NPC.All.Remove(NPC.All.First((NPC npc) => (Object)(object)npc.S1NPC == (Object)(object)__instance2)); } } internal static class PhoneAppRegistry { public static readonly List<global::S1API.PhoneApp.PhoneApp> RegisteredApps = new List<global::S1API.PhoneApp.PhoneApp>(); public static void Register(global::S1API.PhoneApp.PhoneApp app) { RegisteredApps.Add(app); } } [HarmonyPatch] internal class PlayerPatches { [HarmonyPatch(typeof(Player), "Awake")] [HarmonyPostfix] private static void PlayerAwake(Player __instance) { new Player(__instance); } [HarmonyPatch(typeof(Player), "OnDestroy")] [HarmonyPostfix] private static void PlayerOnDestroy(Player __instance) { Player __instance2 = __instance; Player.All.Remove(Player.All.First((Player player) => (Object)(object)player.S1Player == (Object)(object)__instance2)); } } [HarmonyPatch] internal class QuestPatches { [HarmonyPatch(typeof(QuestManager), "WriteData")] [HarmonyPostfix] private static void QuestManagerWriteData(QuestManager __instance, string parentFolderPath, ref List<string> __result) { string folderPath = Path.Combine(parentFolderPath, "Quests"); foreach (Quest quest in QuestManager.Quests) { quest.SaveInternal(folderPath, ref __result); } } [HarmonyPatch(typeof(QuestsLoader), "Load")] [HarmonyPostfix] private static void QuestsLoaderLoad(QuestsLoader __instance, string mainPath) { if (!Directory.Exists(mainPath)) { return; } string[] array = (from directory in Directory.GetDirectories(mainPath).Select(Path.GetFileName) where directory?.StartsWith("Quest_") ?? false select directory).ToArray(); string[] array2 = array; string text2 = default(string); string text5 = default(string); foreach (string path in array2) { string text = Path.Combine(mainPath, path); ((Loader)__instance).TryLoadFile(text, ref text2, true); if (text2 == null) { continue; } QuestData val = JsonUtility.FromJson<QuestData>(text2); string text3 = Path.Combine(mainPath, path); string text4 = Path.Combine(text3, "QuestData"); if (!((Loader)__instance).TryLoadFile(text4, ref text5, true)) { continue; } QuestData questData = JsonConvert.DeserializeObject<QuestData>(text5, ISaveable.SerializerSettings); if (questData?.ClassName != null) { Type typeByName = ReflectionUtils.GetTypeByName(questData.ClassName); if (!(typeByName == null) && typeof(Quest).IsAssignableFrom(typeByName)) { Quest quest = QuestManager.CreateQuest(typeByName, val?.GUID); quest.LoadInternal(text3); } } } } [HarmonyPatch(typeof(QuestManager), "DeleteUnapprovedFiles")] [HarmonyPostfix] private static void QuestManagerDeleteUnapprovedFiles(QuestManager __instance, string parentFolderPath) { string path = Path.Combine(parentFolderPath, "Quests"); string?[] existingQuests = QuestManager.Quests.Select((Quest quest) => quest.SaveFolder).ToArray(); string[] array = (from directory in Directory.GetDirectories(path) where directory.StartsWith("Quest_") && !existingQuests.Contains<string>(directory) select directory).ToArray(); string[] array2 = array; foreach (string path2 in array2) { Directory.Delete(path2, recursive: true); } } [HarmonyPatch(typeof(Quest), "Start")] [HarmonyPrefix] private static void QuestStart(Quest __instance) { Quest __instance2 = __instance; QuestManager.Quests.FirstOrDefault((Quest quest) => (Object)(object)quest.S1Quest == (Object)(object)__instance2)?.CreateInternal(); } } [HarmonyPatch] internal class TimePatches { [HarmonyPatch(typeof(TimeManager), "Awake")] [HarmonyPostfix] private static void TimeManagerAwake(TimeManager __instance) { __instance.onDayPass = (Action)Delegate.Combine(__instance.onDayPass, new Action(DayPass)); static void DayPass() { TimeManager.OnDayPass(); } } } } namespace S1API.Internal.Abstraction { internal static class EventHelper { internal static readonly Dictionary<Action, UnityAction> SubscribedActions = new Dictionary<Action, UnityAction>(); internal static void AddListener(Action listener, UnityEvent unityEvent) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (!SubscribedActions.ContainsKey(listener)) { UnityAction val = new UnityAction(listener.Invoke); unityEvent.AddListener(val); SubscribedActions.Add(listener, val); } } internal static void RemoveListener(Action listener, UnityEvent unityEvent) { SubscribedActions.TryGetValue(listener, out UnityAction value); SubscribedActions.Remove(listener); unityEvent.RemoveListener(value); } } internal class GUIDReferenceConverter : JsonConverter { public override bool CanRead => true; public override bool CanConvert(Type objectType) { return typeof(IGUIDReference).IsAssignableFrom(objectType); } public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (value is IGUIDReference iGUIDReference) { writer.WriteValue(iGUIDReference.GUID); } else { writer.WriteNull(); } } public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { string text = reader.Value?.ToString(); if (string.IsNullOrEmpty(text)) { return null; } MethodInfo method = ReflectionUtils.GetMethod(objectType, "GetFromGUID", BindingFlags.Static | BindingFlags.NonPublic); if (method == null) { throw new Exception("The type " + objectType.Name + " does not have a valid implementation of the GetFromGUID(string guid) method!"); } return method.Invoke(null, new object[1] { text }); } } internal interface IGUIDReference { string GUID { get; } } internal interface IRegisterable { void CreateInternal(); void DestroyInternal(); void OnCreated(); void OnDestroyed(); } internal interface ISaveable : IRegisterable { internal static JsonSerializerSettings SerializerSettings => new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1, Converters = new List<JsonConverter> { (JsonConverter)(object)new GUIDReferenceConverter() } }; void SaveInternal(string path, ref List<string> extraSaveables); void LoadInternal(string folderPath); void OnSaved(); void OnLoaded(); } public abstract class Registerable : IRegisterable { void IRegisterable.CreateInternal() { CreateInternal(); } internal virtual void CreateInternal() { OnCreated(); } void IRegisterable.DestroyInternal() { DestroyInternal(); } internal virtual void DestroyInternal() { OnDestroyed(); } void IRegisterable.OnCreated() { OnCreated(); } protected virtual void OnCreated() { } void IRegisterable.OnDestroyed() { OnDestroyed(); } protected virtual void OnDestroyed() { } } public abstract class Saveable : Registerable, ISaveable, IRegisterable { void ISaveable.LoadInternal(string folderPath) { LoadInternal(folderPath); } internal virtual void LoadInternal(string folderPath) { FieldInfo[] fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { SaveableField customAttribute = fieldInfo.GetCustomAttribute<SaveableField>(); if (customAttribute != null) { string path = (customAttribute.SaveName.EndsWith(".json") ? customAttribute.SaveName : (customAttribute.SaveName + ".json")); string path2 = Path.Combine(folderPath, path); if (File.Exists(path2)) { string text = File.ReadAllText(path2); Type fieldType = fieldInfo.FieldType; object value = JsonConvert.DeserializeObject(text, fieldType, ISaveable.SerializerSettings); fieldInfo.SetValue(this, value); } } } OnLoaded(); } void ISaveable.SaveInternal(string folderPath, ref List<string> extraSaveables) { SaveInternal(folderPath, ref extraSaveables); } internal virtual void SaveInternal(string folderPath, ref List<string> extraSaveables) { FieldInfo[] allFields = ReflectionUtils.GetAllFields(GetType(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = allFields; foreach (FieldInfo fieldInfo in array) { SaveableField customAttribute = fieldInfo.GetCustomAttribute<SaveableField>(); if (customAttribute != null) { string text = (customAttribute.SaveName.EndsWith(".json") ? customAttribute.SaveName : (customAttribute.SaveName + ".json")); string path = Path.Combine(folderPath, text); object value = fieldInfo.GetValue(this); if (value == null) { File.Delete(path); continue; } extraSaveables.Add(text); string contents = JsonConvert.SerializeObject(value, (Formatting)1, ISaveable.SerializerSettings); File.WriteAllText(path, contents); } } OnSaved(); } void ISaveable.OnLoaded() { OnLoaded(); } protected virtual void OnLoaded() { } void ISaveable.OnSaved() { OnSaved(); } protected virtual void OnSaved() { } } } namespace S1API.GameTime { public enum Day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } public struct GameDateTime { public int ElapsedDays; public int Time; public GameDateTime(int elapsedDays, int time) { ElapsedDays = elapsedDays; Time = time; } public GameDateTime(int minSum) { ElapsedDays = minSum / 1440; int num = minSum % 1440; if (minSum < 0) { num = -minSum % 1440; } Time = TimeManager.Get24HourTimeFromMinSum(num); } public GameDateTime(GameDateTimeData data) { ElapsedDays = data.ElapsedDays; Time = data.Time; } public GameDateTime(GameDateTime gameDateTime) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) ElapsedDays = gameDateTime.elapsedDays; Time = gameDateTime.time; } public int GetMinSum() { return ElapsedDays * 1440 + TimeManager.GetMinSumFrom24HourTime(Time); } public GameDateTime AddMinutes(int minutes) { return new GameDateTime(GetMinSum() + minutes); } public GameDateTime ToS1() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return new GameDateTime(ElapsedDays, Time); } public string GetFormattedTime() { return TimeManager.Get12HourTime((float)Time, true); } public bool IsNightTime() { return Time < 600 || Time >= 1800; } public bool IsSameDay(GameDateTime other) { return ElapsedDays == other.ElapsedDays; } public bool IsSameTime(GameDateTime other) { return ElapsedDays == other.ElapsedDays && Time == other.Time; } public override string ToString() { return $"Day {ElapsedDays}, {GetFormattedTime()}"; } public static GameDateTime operator +(GameDateTime a, GameDateTime b) { return new GameDateTime(a.GetMinSum() + b.GetMinSum()); } public static GameDateTime operator -(GameDateTime a, GameDateTime b) { return new GameDateTime(a.GetMinSum() - b.GetMinSum()); } public static bool operator >(GameDateTime a, GameDateTime b) { return a.GetMinSum() > b.GetMinSum(); } public static bool operator <(GameDateTime a, GameDateTime b) { return a.GetMinSum() < b.GetMinSum(); } } public static class TimeManager { public static Action OnDayPass; public static Action OnWeekPass; public static Action OnSleepStart; public static Action<int> OnSleepEnd; public static Day CurrentDay => (Day)NetworkSingleton<TimeManager>.Instance.CurrentDay; public static int ElapsedDays => NetworkSingleton<TimeManager>.Instance.ElapsedDays; public static int CurrentTime => NetworkSingleton<TimeManager>.Instance.CurrentTime; public static bool IsNight => NetworkSingleton<TimeManager>.Instance.IsNight; public static bool IsEndOfDay => NetworkSingleton<TimeManager>.Instance.IsEndOfDay; public static bool SleepInProgress => NetworkSingleton<TimeManager>.Instance.SleepInProgress; public static bool TimeOverridden => NetworkSingleton<TimeManager>.Instance.TimeOverridden; public static float NormalizedTime => NetworkSingleton<TimeManager>.Instance.NormalizedTime; public static float Playtime => NetworkSingleton<TimeManager>.Instance.Playtime; static TimeManager() { OnDayPass = delegate { }; OnWeekPass = delegate { }; OnSleepStart = delegate { }; OnSleepEnd = delegate { }; if ((Object)(object)NetworkSingleton<TimeManager>.Instance != (Object)null) { TimeManager instance = NetworkSingleton<TimeManager>.Instance; instance.onDayPass = (Action)Delegate.Combine(instance.onDayPass, (Action)delegate { OnDayPass(); }); TimeManager instance2 = NetworkSingleton<TimeManager>.Instance; instance2.onWeekPass = (Action)Delegate.Combine(instance2.onWeekPass, (Action)delegate { OnWeekPass(); }); } TimeManager.onSleepStart = (Action)Delegate.Combine(TimeManager.onSleepStart, (Action)delegate { OnSleepStart(); }); TimeManager.onSleepEnd = (Action<int>)Delegate.Combine(TimeManager.onSleepEnd, (Action<int>)delegate(int minutes) { OnSleepEnd(minutes); }); } public static void FastForwardToWakeTime() { NetworkSingleton<TimeManager>.Instance.FastForwardToWakeTime(); } public static void SetTime(int time24h, bool local = false) { NetworkSingleton<TimeManager>.Instance.SetTime(time24h, local); } public static void SetElapsedDays(int days) { NetworkSingleton<TimeManager>.Instance.SetElapsedDays(days); } public static string GetFormatted12HourTime() { return TimeManager.Get12HourTime((float)CurrentTime, true); } public static bool IsCurrentTimeWithinRange(int startTime24h, int endTime24h) { return NetworkSingleton<TimeManager>.Instance.IsCurrentTimeWithinRange(startTime24h, endTime24h); } public static int GetMinutesFrom24HourTime(int time24h) { return TimeManager.GetMinSumFrom24HourTime(time24h); } public static int Get24HourTimeFromMinutes(int minutes) { return TimeManager.Get24HourTimeFromMinSum(minutes); } } } namespace S1API.Entities { public abstract class NPC : Saveable, IEntity, IHealth { protected readonly List<Response> Responses = new List<Response>(); public static readonly List<NPC> All = new List<NPC>(); internal readonly NPC S1NPC; internal readonly bool IsCustomNPC; private readonly FieldInfo _panicField = AccessTools.Field(typeof(NPC), "PANIC_DURATION"); private readonly FieldInfo _requiresRegionUnlockedField = AccessTools.Field(typeof(NPC), "RequiresRegionUnlocked"); private readonly MethodInfo _unsettleMethod = AccessTools.Method(typeof(NPC), "SetUnsettled", (Type[])null, (Type[])null); private readonly MethodInfo _removePanicMethod = AccessTools.Method(typeof(NPC), "RemovePanicked", (Type[])null, (Type[])null); public GameObject gameObject { get; } public Vector3 Position { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return gameObject.transform.position; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1NPC.Movement.Warp(value); } } public Transform Transform => gameObject.transform; public string FirstName { get { return S1NPC.FirstName; } set { S1NPC.FirstName = value; } } public string LastName { get { return S1NPC.LastName; } set { S1NPC.LastName = value; } } public string FullName => S1NPC.fullName; public string ID { get { return S1NPC.ID; } protected set { S1NPC.ID = value; } } public Sprite Icon { get { return S1NPC.MugshotSprite; } set { S1NPC.MugshotSprite = value; } } public bool IsConscious => S1NPC.IsConscious; public bool IsInBuilding => S1NPC.isInBuilding; public bool IsInVehicle => S1NPC.IsInVehicle; public bool IsPanicking => S1NPC.IsPanicked; public bool IsUnsettled => S1NPC.isUnsettled; public bool IsVisible => S1NPC.isVisible; public float Aggressiveness { get { return S1NPC.Aggression; } set { S1NPC.Aggression = value; } } public Region Region => (Region)S1NPC.Region; public float PanicDuration { get { return (float)_panicField.GetValue(S1NPC); } set { _panicField.SetValue(S1NPC, value); } } public float Scale { get { return S1NPC.Scale; } set { S1NPC.SetScale(value); } } public bool IsKnockedOut => S1NPC.Health.IsKnockedOut; public bool RequiresRegionUnlocked { get { return (bool)_requiresRegionUnlockedField.GetValue(S1NPC); } set { _panicField.SetValue(S1NPC, value); } } public float CurrentHealth => S1NPC.Health.Health; public float MaxHealth { get { return S1NPC.Health.MaxHealth; } set { S1NPC.Health.MaxHealth = value; } } public bool IsDead => S1NPC.Health.IsDead; public bool IsInvincible { get { return S1NPC.Health.Invincible; } set { S1NPC.Health.Invincible = value; } } public event Action OnDeath { add { EventHelper.AddListener(value, S1NPC.Health.onDie); } remove { EventHelper.RemoveListener(value, S1NPC.Health.onDie); } } public event Action OnInventoryChanged { add { EventHelper.AddListener(value, S1NPC.Inventory.onContentsChanged); } remove { EventHelper.RemoveListener(value, S1NPC.Inventory.onContentsChanged); } } protected NPC(string id, string? firstName, string? lastName, Sprite? icon = null) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Expected O, but got Unknown //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Expected O, but got Unknown //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Expected O, but got Unknown //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Expected O, but got Unknown //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Expected O, but got Unknown //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Expected O, but got Unknown IsCustomNPC = true; gameObject = new GameObject(); gameObject.SetActive(false); S1NPC = gameObject.AddComponent<NPC>(); S1NPC.FirstName = firstName; S1NPC.LastName = lastName; S1NPC.ID = id; S1NPC.MugshotSprite = icon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; S1NPC.BakedGUID = Guid.NewGuid().ToString(); S1NPC.ConversationCategories = new List<EConversationCategory>(); S1NPC.ConversationCategories.Add((EConversationCategory)0); MethodInfo methodInfo = AccessTools.Method(typeof(NPC), "CreateMessageConversation", (Type[])null, (Type[])null); methodInfo.Invoke(S1NPC, null); S1NPC.Health = gameObject.GetComponent<NPCHealth>(); S1NPC.Health.onDie = new UnityEvent(); S1NPC.Health.onKnockedOut = new UnityEvent(); S1NPC.Health.Invincible = true; S1NPC.Health.MaxHealth = 100f; GameObject val = new GameObject("NPCAwareness"); val.transform.SetParent(gameObject.transform); S1NPC.awareness = val.AddComponent<NPCAwareness>(); S1NPC.awareness.onExplosionHeard = new UnityEvent<NoiseEvent>(); S1NPC.awareness.onGunshotHeard = new UnityEvent<NoiseEvent>(); S1NPC.awareness.onHitByCar = new UnityEvent<LandVehicle>(); S1NPC.awareness.onNoticedDrugDealing = new UnityEvent<Player>(); S1NPC.awareness.onNoticedGeneralCrime = new UnityEvent<Player>(); S1NPC.awareness.onNoticedPettyCrime = new UnityEvent<Player>(); S1NPC.awareness.onNoticedPlayerViolatingCurfew = new UnityEvent<Player>(); S1NPC.awareness.onNoticedSuspiciousPlayer = new UnityEvent<Player>(); S1NPC.awareness.Listener = gameObject.AddComponent<Listener>(); GameObject val2 = new GameObject("NPCBehaviour"); val2.transform.SetParent(gameObject.transform); NPCBehaviour val3 = val2.AddComponent<NPCBehaviour>(); GameObject val4 = new GameObject("CowingBehaviour"); val4.transform.SetParent(val2.transform); CoweringBehaviour coweringBehaviour = val4.AddComponent<CoweringBehaviour>(); GameObject val5 = new GameObject("FleeBehaviour"); val5.transform.SetParent(val2.transform); FleeBehaviour fleeBehaviour = val5.AddComponent<FleeBehaviour>(); val3.CoweringBehaviour = coweringBehaviour; val3.FleeBehaviour = fleeBehaviour; S1NPC.behaviour = val3; GameObject val6 = new GameObject("NPCResponses"); val6.transform.SetParent(gameObject.transform); S1NPC.awareness.Responses = (NPCResponses)(object)val6.AddComponent<NPCResponses_Civilian>(); GameObject val7 = new GameObject("VisionCone"); val7.transform.SetParent(gameObject.transform); VisionCone val8 = val7.AddComponent<VisionCone>(); val8.StatesOfInterest.Add(new StateContainer { state = (EVisualState)4, RequiredNoticeTime = 0.1f }); S1NPC.awareness.VisionCone = val8; S1NPC.awareness.VisionCone.QuestionMarkPopup = gameObject.AddComponent<WorldspacePopup>(); FieldInfo fieldInfo = AccessTools.Field(typeof(NPC), "intObj"); fieldInfo.SetValue(S1NPC, gameObject.AddComponent<InteractableObject>()); S1NPC.RelationData = new NPCRelationData(); NPCInventory val9 = gameObject.AddComponent<NPCInventory>(); val9.PickpocketIntObj = gameObject.AddComponent<InteractableObject>(); S1NPC.Avatar = Singleton<MugshotGenerator>.Instance.MugshotRig; gameObject.SetActive(true); All.Add(this); } protected virtual void OnResponseLoaded(Response response) { } public void Revive() { S1NPC.Health.Revive(); } public void Damage(int amount) { if (amount > 0) { S1NPC.Health.TakeDamage((float)amount, true); } } public void Heal(int amount) { if (amount > 0) { float num = Mathf.Min((float)amount, S1NPC.Health.MaxHealth - S1NPC.Health.Health); S1NPC.Health.TakeDamage(0f - num, false); } } public void Kill() { S1NPC.Health.TakeDamage(S1NPC.Health.MaxHealth, true); } public void Unsettle(float duration) { _unsettleMethod.Invoke(S1NPC, new object[1] { duration }); } public void LerpScale(float scale, float lerpTime) { S1NPC.SetScale(scale, lerpTime); } public void Panic() { S1NPC.SetPanicked(); } public void StopPanicking() { _removePanicMethod.Invoke(S1NPC, new object[0]); } public void KnockOut() { S1NPC.Health.KnockOut(); } public void Goto(Vector3 position) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1NPC.Movement.SetDestination(position); } public void SendTextMessage(string message, Response[]? responses = null, float responseDelay = 1f, bool network = true) { S1NPC.SendTextMessage(message); S1NPC.MSGConversation.ClearResponses(false); if (responses != null && responses.Length != 0) { Responses.Clear(); List<Response> list = new List<Response>(); foreach (Response response in responses) { Responses.Add(response); list.Add(response.S1Response); } S1NPC.MSGConversation.ShowResponses(list, responseDelay, network); } } public static NPC? Get<T>() { return All.FirstOrDefault((NPC npc) => npc.GetType() == typeof(T)); } internal NPC(NPC npc) { S1NPC = npc; gameObject = ((Component)npc).gameObject; IsCustomNPC = false; All.Add(this); } internal override void CreateInternal() { foreach (Response currentResponse in S1NPC.MSGConversation.currentResponses) { Response response = new Response(currentResponse) { Label = currentResponse.label, Text = currentResponse.text }; Responses.Add(response); OnResponseLoaded(response); } base.CreateInternal(); } internal override void SaveInternal(string folderPath, ref List<string> extraSaveables) { string folderPath2 = Path.Combine(folderPath, S1NPC.SaveFolderName); base.SaveInternal(folderPath2, ref extraSaveables); } } public class Player : IEntity, IHealth { private const float InvincibleHealth = 1E+09f; private const float MortalHealth = 100f; public static readonly List<Player> All = new List<Player>(); internal Player S1Player; private readonly FieldInfo _maxHealthField = AccessTools.Field(typeof(PlayerHealth), "MAX_HEALTH"); public static Player Local => All.FirstOrDefault((Player player) => player.IsLocal); public bool IsLocal => S1Player.IsLocalPlayer; public string Name => S1Player.PlayerName; GameObject IEntity.gameObject => ((Component)S1Player).gameObject; public Vector3 Position { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return ((IEntity)this).gameObject.transform.position; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) ((IEntity)this).gameObject.transform.position = value; } } public Transform Transform => ((IEntity)this).gameObject.transform; public float Scale { get { return S1Player.Scale; } set { S1Player.SetScale(value); } } public float CurrentHealth => S1Player.Health.CurrentHealth; public float MaxHealth { get { return (float)_maxHealthField.GetValue(S1Player.Health); } set { _maxHealthField.SetValue(S1Player.Health, value); } } public bool IsDead => !S1Player.Health.IsAlive; public bool IsInvincible { get { return MaxHealth == 1E+09f; } set { MaxHealth = (value ? 1E+09f : 100f); S1Player.Health.SetHealth(MaxHealth); } } pub
Mods/S1API.Il2Cpp.MelonLoader.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.AvatarFramework; using Il2CppScheduleOne.Calling; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Dialogue; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.GameTime; using Il2CppScheduleOne.Interaction; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Levelling; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.Messaging; using Il2CppScheduleOne.Money; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.NPCs.Relation; using Il2CppScheduleOne.NPCs.Responses; using Il2CppScheduleOne.NPCs.Schedules; using Il2CppScheduleOne.Noise; using Il2CppScheduleOne.Persistence.Datas; using Il2CppScheduleOne.Persistence.Loaders; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.PlayerScripts.Health; using Il2CppScheduleOne.Product; using Il2CppScheduleOne.Product.Packaging; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.ScriptableObjects; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Phone; using Il2CppScheduleOne.UI.Phone.ContactsApp; using Il2CppScheduleOne.UI.WorldspacePopup; using Il2CppScheduleOne.Variables; using Il2CppScheduleOne.Vehicles; using Il2CppScheduleOne.Vision; using Il2CppSystem; using Il2CppSystem.Collections; using Il2CppSystem.Collections.Generic; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using S1API; using S1API.Conditions; using S1API.Dialogues; using S1API.Entities; using S1API.Entities.Interfaces; using S1API.GameTime; using S1API.Internal.Abstraction; using S1API.Internal.Patches; using S1API.Internal.Utils; using S1API.Items; using S1API.Logging; using S1API.Map; using S1API.Messaging; using S1API.Money; using S1API.PhoneApp; using S1API.PhoneCalls.Constants; using S1API.Products; using S1API.Quests; using S1API.Quests.Constants; using S1API.Saveables; using S1API.Storages; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; 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: MelonInfo(typeof(global::S1API.S1API), "S1API", "1.6.2", "KaBooMa", null)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("KaBooMa")] [assembly: AssemblyConfiguration("Il2CppMelon")] [assembly: AssemblyDescription("A Schedule One Mono / Il2Cpp Cross Compatibility Layer")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d9665e9bd95b76b033fb53d5c1698afa82fe53ac")] [assembly: AssemblyProduct("S1API")] [assembly: AssemblyTitle("S1API")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/KaBooMa/S1API")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } public class DialogueInjection { public string NpcName; public string ContainerName; public string FromNodeGuid; public string ToNodeGuid; public string ChoiceLabel; public string ChoiceText; public Action OnConfirmed; public DialogueInjection(string npc, string container, string from, string to, string label, string text, Action onConfirmed) { NpcName = npc; ContainerName = container; FromNodeGuid = from; ToNodeGuid = to; ChoiceLabel = label; ChoiceText = text; OnConfirmed = onConfirmed; } } public static class DialogueInjector { private static List<DialogueInjection> pendingInjections = new List<DialogueInjection>(); private static bool isHooked = false; public static void Register(DialogueInjection injection) { pendingInjections.Add(injection); HookUpdateLoop(); } private static void HookUpdateLoop() { if (!isHooked) { isHooked = true; MelonCoroutines.Start(WaitForNPCsAndInject()); } } private static IEnumerator WaitForNPCsAndInject() { while (pendingInjections.Count > 0) { for (int i = pendingInjections.Count - 1; i >= 0; i--) { DialogueInjection injection = pendingInjections[i]; Il2CppArrayBase<NPC> npcs = Object.FindObjectsOfType<NPC>(); NPC target = null; for (int j = 0; j < npcs.Length; j++) { if ((Object)(object)npcs[j] != (Object)null && ((Object)npcs[j]).name.Contains(injection.NpcName)) { target = npcs[j]; break; } } if ((Object)(object)target != (Object)null) { TryInject(injection, target); pendingInjections.RemoveAt(i); } } yield return null; } } private static void TryInject(DialogueInjection injection, NPC npc) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown DialogueHandler component = ((Component)npc).GetComponent<DialogueHandler>(); NPCEvent_LocationDialogue componentInChildren = ((Component)npc).GetComponentInChildren<NPCEvent_LocationDialogue>(true); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.DialogueOverride == (Object)null || ((Object)componentInChildren.DialogueOverride).name != injection.ContainerName) { return; } DialogueContainer dialogueOverride = componentInChildren.DialogueOverride; if (dialogueOverride.DialogueNodeData == null) { return; } DialogueNodeData val = null; for (int i = 0; i < dialogueOverride.DialogueNodeData.Count; i++) { DialogueNodeData val2 = dialogueOverride.DialogueNodeData.ToArray()[i]; if (val2 != null && val2.Guid == injection.FromNodeGuid) { val = val2; break; } } if (val != null) { DialogueChoiceData val3 = new DialogueChoiceData { Guid = Guid.NewGuid().ToString(), ChoiceLabel = injection.ChoiceLabel, ChoiceText = injection.ChoiceText }; List<DialogueChoiceData> list = new List<DialogueChoiceData>(); if (val.choices != null) { list.AddRange((IEnumerable<DialogueChoiceData>)val.choices); } list.Add(val3); val.choices = Il2CppReferenceArray<DialogueChoiceData>.op_Implicit(list.ToArray()); NodeLinkData val4 = new NodeLinkData { BaseDialogueOrBranchNodeGuid = injection.FromNodeGuid, BaseChoiceOrOptionGUID = val3.Guid, TargetNodeGuid = injection.ToNodeGuid }; if (dialogueOverride.NodeLinks == null) { dialogueOverride.NodeLinks = new List<NodeLinkData>(); } dialogueOverride.NodeLinks.Add(val4); DialogueChoiceListener.Register(component, injection.ChoiceLabel, injection.OnConfirmed); } } } public class ClickHandler { private readonly UnityAction _callback; public ClickHandler(UnityAction callback) { _callback = callback; } public void OnClick() { _callback.Invoke(); } } namespace S1API { public class S1API : MelonMod { } } namespace S1API.UI { 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<RectTransform>(); 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<Image>(); ((Graphic)val3).color = bgColor; return val; } public static Text Text(string name, string content, Transform parent, int fontSize = 14, TextAnchor anchor = 0, FontStyle style = 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<RectTransform>(); Text val3 = val.AddComponent<Text>(); val3.text = content; val3.fontSize = fontSize; val3.alignment = anchor; val3.fontStyle = style; val3.font = Resources.GetBuiltinResource<Font>("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<RectTransform>(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; scrollRect = val.AddComponent<ScrollRect>(); scrollRect.horizontal = false; GameObject val3 = new GameObject("Viewport"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent<RectTransform>(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; ((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.05f); val3.AddComponent<Mask>().showMaskGraphic = false; scrollRect.viewport = val4; GameObject val5 = new GameObject("Content"); val5.transform.SetParent(val3.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = new Vector2(0f, 1f); val6.anchorMax = new Vector2(1f, 1f); val6.pivot = new Vector2(0.5f, 1f); VerticalLayoutGroup val7 = val5.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val7).spacing = 10f; ((LayoutGroup)val7).padding = new RectOffset(10, 10, 10, 10); ((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val7).childForceExpandHeight = false; val5.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; scrollRect.content = val6; return val6; } public static void FitContentHeight(RectTransform content) { ContentSizeFitter val = ((Component)content).gameObject.GetComponent<ContentSizeFitter>(); if ((Object)(object)val == (Object)null) { val = ((Component)content).gameObject.AddComponent<ContentSizeFitter>(); } 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<RectTransform>(); val2.sizeDelta = new Vector2(width, height); LayoutElement val3 = val.AddComponent<LayoutElement>(); val3.preferredWidth = width; val3.preferredHeight = height; Image val4 = val.AddComponent<Image>(); val4.sprite = GetRoundedSprite(); val4.type = (Type)1; ((Graphic)val4).color = Color.white; Mask val5 = val.AddComponent<Mask>(); val5.showMaskGraphic = true; GameObject val6 = new GameObject(name); val6.transform.SetParent(val.transform, false); RectTransform val7 = val6.AddComponent<RectTransform>(); val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = Vector2.zero; val7.offsetMax = Vector2.zero; Image val8 = val6.AddComponent<Image>(); ((Graphic)val8).color = bgColor; val8.sprite = GetRoundedSprite(); val8.type = (Type)1; Button val9 = val6.AddComponent<Button>(); ((Selectable)val9).targetGraphic = (Graphic)(object)val8; GameObject val10 = new GameObject("Label"); val10.transform.SetParent(val6.transform, false); RectTransform val11 = val10.AddComponent<RectTransform>(); val11.anchorMin = Vector2.zero; val11.anchorMax = Vector2.one; val11.offsetMin = Vector2.zero; val11.offsetMax = Vector2.zero; Text val12 = val10.AddComponent<Text>(); val12.text = label; val12.alignment = (TextAnchor)4; val12.fontSize = fontSize; val12.fontStyle = (FontStyle)1; ((Graphic)val12).color = textColor; val12.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); return (val, val9, val12); } private static Sprite GetRoundedSprite() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)roundedSprite != (Object)null) { return roundedSprite; } int num = 32; Texture2D val = new Texture2D(num, num, (TextureFormat)5, false); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0); Color32 val3 = default(Color32); ((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); float num2 = 6f; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { bool flag = ((float)j < num2 && (float)i < num2 && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) > num2) || ((float)j > (float)num - num2 - 1f && (float)i < num2 && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)num - num2 - 1f, num2)) > num2) || ((float)j < num2 && (float)i > (float)num - num2 - 1f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, (float)num - num2 - 1f)) > num2) || ((float)j > (float)num - num2 - 1f && (float)i > (float)num - num2 - 1f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)num - num2 - 1f, (float)num - num2 - 1f)) > num2); val.SetPixel(j, i, Color32.op_Implicit(flag ? val2 : val3)); } } val.Apply(); Vector4 val4 = default(Vector4); ((Vector4)(ref val4))..ctor(8f, 8f, 8f, 8f); roundedSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, val4); return roundedSprite; } public static GameObject ButtonRow(string name, Transform parent, float spacing = 12f, TextAnchor alignment = 4) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002d: 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<RectTransform>(); HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).spacing = spacing; ((LayoutGroup)val3).childAlignment = alignment; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false; return val; } public static (GameObject, Button, Text) ButtonWithLabel(string name, string label, Transform parent, Color bgColor, float Width, float Height) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_008f: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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<RectTransform>(); val2.sizeDelta = new Vector2(Height, Width); Image val3 = val.AddComponent<Image>(); ((Graphic)val3).color = bgColor; val3.sprite = Resources.GetBuiltinResource<Sprite>("UI/Skin/UISprite.psd"); val3.type = (Type)1; Button val4 = val.AddComponent<Button>(); ((Selectable)val4).targetGraphic = (Graphic)(object)val3; GameObject val5 = new GameObject("Label"); val5.transform.SetParent(val.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = Vector2.zero; val6.offsetMax = Vector2.zero; Text val7 = val5.AddComponent<Text>(); val7.text = label; val7.alignment = (TextAnchor)4; val7.fontSize = 16; val7.fontStyle = (FontStyle)1; ((Graphic)val7).color = Color.white; val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); return (val, val4, val7); } public static void SetIcon(Sprite sprite, Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Icon"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; Image val3 = val.AddComponent<Image>(); val3.sprite = sprite; val3.preserveAspect = true; } public static void CreateTextBlock(Transform parent, string title, string subtitle, bool isCompleted) { Text(((Object)parent).name + "Title", title, parent, 16, (TextAnchor)3, (FontStyle)1); Text(((Object)parent).name + "Subtitle", subtitle, parent, 14, (TextAnchor)0, (FontStyle)0); if (isCompleted) { Text("CompletedLabel", "<color=#888888><i>Already Delivered</i></color>", parent, 12, (TextAnchor)0, (FontStyle)0); } } public static void CreateRowButton(GameObject go, UnityAction clickHandler, bool enabled) { Button val = go.AddComponent<Button>(); Image component = go.GetComponent<Image>(); ((Selectable)val).targetGraphic = (Graphic)(object)component; ((Selectable)val).interactable = enabled; ((UnityEvent)val.onClick).AddListener(clickHandler); } public static void ClearChildren(Transform parent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown IEnumerator enumerator = parent.GetEnumerator(); try { while (enumerator.MoveNext()) { Transform val = (Transform)enumerator.Current; Object.Destroy((Object)(object)((Component)val).gameObject); } } finally { if (enumerator is IDisposable disposable) { disposable.Dispose(); } } } public static void VerticalLayoutOnGO(GameObject go, int spacing = 10, RectOffset? padding = null) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) VerticalLayoutGroup val = go.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val).spacing = spacing; ((LayoutGroup)val).padding = (RectOffset)(((object)padding) ?? ((object)new RectOffset(10, 10, 10, 10))); } public static GameObject CreateQuestRow(string name, Transform parent, out GameObject iconPanel, out GameObject textPanel) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Row_" + name); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = new Vector2(0f, 90f); val.AddComponent<LayoutElement>().minHeight = 50f; ((Shadow)val.AddComponent<Outline>()).effectColor = new Color(0f, 0f, 0f, 0.2f); GameObject val3 = Panel("Separator", val.transform, new Color(1f, 1f, 1f, 0.05f)); val3.GetComponent<RectTransform>().sizeDelta = new Vector2(300f, 1f); Image val4 = val.AddComponent<Image>(); ((Graphic)val4).color = new Color(0.12f, 0.12f, 0.12f); Button val5 = val.AddComponent<Button>(); ((Selectable)val5).targetGraphic = (Graphic)(object)val4; HorizontalLayoutGroup val6 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val6).spacing = 20f; ((LayoutGroup)val6).padding = new RectOffset(75, 10, 10, 10); ((LayoutGroup)val6).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)val6).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val6).childForceExpandHeight = false; LayoutElement val7 = val.AddComponent<LayoutElement>(); val7.minHeight = 90f; val7.flexibleWidth = 1f; iconPanel = Panel("IconPanel", val.transform, new Color(0.12f, 0.12f, 0.12f)); RectTransform component = iconPanel.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(80f, 80f); LayoutElement val8 = iconPanel.AddComponent<LayoutElement>(); val8.preferredWidth = 80f; val8.preferredHeight = 80f; textPanel = Panel("TextPanel", val.transform, Color.clear); VerticalLayoutOnGO(textPanel, 2); LayoutElement val9 = textPanel.AddComponent<LayoutElement>(); val9.minWidth = 200f; val9.flexibleWidth = 1f; return val; } public static GameObject TopBar(string name, Transform parent, string title, float topbarSize, int paddingLeft, int paddingRight, int paddingTop, int paddingBottom) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown GameObject val = Panel(name, parent, new Color(0.15f, 0.15f, 0.15f), (Vector2?)new Vector2(0f, topbarSize), (Vector2?)new Vector2(1f, 1f), fullAnchor: false); HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>(); ((LayoutGroup)val2).padding = new RectOffset(paddingLeft, paddingRight, paddingTop, paddingBottom); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 20f; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = true; Text val3 = Text("TopBarTitle", title, val.transform, 26, (TextAnchor)3, (FontStyle)1); LayoutElement val4 = ((Component)val3).gameObject.AddComponent<LayoutElement>(); val4.minWidth = 300f; val4.flexibleWidth = 1f; return val; } public static void HorizontalLayoutOnGO(GameObject go, int spacing = 10, int padLeft = 0, int padRight = 0, int padTop = 0, int padBottom = 0, TextAnchor alignment = 4) { //IL_0012: 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_003b: Expected O, but got Unknown HorizontalLayoutGroup val = go.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val).spacing = spacing; ((LayoutGroup)val).childAlignment = alignment; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false; ((LayoutGroup)val).padding = new RectOffset(padLeft, padRight, padTop, padBottom); } public static void SetLayoutGroupPadding(LayoutGroup layoutGroup, int left, int right, int top, int bottom) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown layoutGroup.padding = new RectOffset(left, right, top, bottom); } public static void BindAcceptButton(Button btn, Text label, string text, UnityAction callback) { label.text = text; ((UnityEventBase)btn.onClick).RemoveAllListeners(); ((UnityEvent)btn.onClick).AddListener(callback); } } } namespace S1API.Storages { public class StorageInstance { internal readonly StorageEntity S1Storage; public ItemSlotInstance[] Slots => ((IEnumerable<ItemSlot>)S1Storage.ItemSlots.ToArray()).Select((ItemSlot itemSlot) => new ItemSlotInstance(itemSlot)).ToArray(); public event Action OnOpened { add { EventHelper.AddListener(value, S1Storage.onOpened); } remove { EventHelper.RemoveListener(value, S1Storage.onOpened); } } public event Action OnClosed { add { EventHelper.AddListener(value, S1Storage.onClosed); } remove { EventHelper.RemoveListener(value, S1Storage.onClosed); } } internal StorageInstance(StorageEntity storage) { S1Storage = storage; } public bool CanItemFit(ItemInstance itemInstance, int quantity = 1) { return S1Storage.CanItemFit(itemInstance.S1ItemInstance, quantity); } public void AddItem(ItemInstance itemInstance) { S1Storage.InsertItem(itemInstance.S1ItemInstance, true); } } } namespace S1API.Saveables { [AttributeUsage(AttributeTargets.Field)] public class SaveableField : Attribute { internal string SaveName { get; } public SaveableField(string saveName) { SaveName = saveName; } } } namespace S1API.Quests { public abstract class Quest : Saveable { protected readonly List<QuestEntry> QuestEntries = new List<QuestEntry>(); [SaveableField("QuestData")] private readonly QuestData _questData; internal readonly Quest S1Quest; private readonly GameObject _gameObject; protected abstract string Title { get; } protected abstract string Description { get; } protected virtual bool AutoBegin => true; protected QuestState QuestState => (QuestState)S1Quest.QuestState; internal string? SaveFolder => S1Quest.SaveFolderName; protected virtual Sprite? QuestIcon => null; public Quest() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Expected O, but got Unknown _questData = new QuestData(GetType().Name); _gameObject = new GameObject("Quest"); S1Quest = _gameObject.AddComponent<Quest>(); S1Quest.StaticGUID = string.Empty; S1Quest.title = Title; S1Quest.onActiveState = new UnityEvent(); S1Quest.onComplete = new UnityEvent(); S1Quest.onInitialComplete = new UnityEvent(); S1Quest.onQuestBegin = new UnityEvent(); S1Quest.onQuestEnd = new UnityEvent<EQuestState>(); S1Quest.onTrackChange = new UnityEvent<bool>(); S1Quest.TrackOnBegin = true; S1Quest.AutoCompleteOnAllEntriesComplete = true; S1Quest.autoInitialize = false; GameObject val = new GameObject("IconPrefab", (Type[])(object)new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Image>() }); val.transform.SetParent(_gameObject.transform); Image component = val.GetComponent<Image>(); component.sprite = QuestIcon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; S1Quest.IconPrefab = val.GetComponent<RectTransform>(); GameObject val2 = new GameObject("PoIUIPrefab", (Type[])(object)new Type[4] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<EventTrigger>(), CrossType.Of<Button>() }); val2.transform.SetParent(_gameObject.transform); GameObject val3 = new GameObject("MainLabel", (Type[])(object)new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Text>() }); val3.transform.SetParent(val2.transform); GameObject val4 = new GameObject("IconContainer", (Type[])(object)new Type[3] { CrossType.Of<RectTransform>(), CrossType.Of<CanvasRenderer>(), CrossType.Of<Image>() }); val4.transform.SetParent(val2.transform); Image component2 = val4.GetComponent<Image>(); component2.sprite = QuestIcon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; RectTransform component3 = ((Component)component2).GetComponent<RectTransform>(); component3.sizeDelta = new Vector2(20f, 20f); GameObject val5 = new GameObject("POIPrefab"); val5.SetActive(false); val5.transform.SetParent(_gameObject.transform); POI val6 = val5.AddComponent<POI>(); val6.DefaultMainText = "Did it work?"; val6.UIPrefab = val2; S1Quest.PoIPrefab = val5; S1Quest.onQuestEnd.AddListener(UnityAction<EQuestState>.op_Implicit((Action<EQuestState>)OnQuestEnded)); } internal override void CreateInternal() { base.CreateInternal(); Quest s1Quest = S1Quest; string title = Title; string description = Description; Il2CppReferenceArray<QuestEntryData> obj = Il2CppReferenceArray<QuestEntryData>.op_Implicit(Array.Empty<QuestEntryData>()); Quest s1Quest2 = S1Quest; s1Quest.InitializeQuest(title, description, obj, (s1Quest2 != null) ? s1Quest2.StaticGUID : null); if (AutoBegin) { Quest s1Quest3 = S1Quest; if (s1Quest3 != null) { s1Quest3.Begin(true); } } } internal override void SaveInternal(string folderPath, ref List<string> extraSaveables) { string text = Path.Combine(folderPath, S1Quest.SaveFolderName); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } base.SaveInternal(text, ref extraSaveables); } internal void OnQuestEnded(EQuestState questState) { Quest.Quests.Remove(S1Quest); QuestManager.Quests.Remove(this); } protected QuestEntry AddEntry(string title, Vector3? poiPosition = null) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("QuestEntry"); Transform transform = val.transform; GameObject gameObject = _gameObject; transform.SetParent((gameObject != null) ? gameObject.transform : null); QuestEntry val2 = val.AddComponent<QuestEntry>(); val2.PoILocation = val.transform; S1Quest.Entries.Add(val2); QuestEntry questEntry = new QuestEntry(val2) { Title = title, POIPosition = (Vector3)(((??)poiPosition) ?? Vector3.zero) }; QuestEntries.Add(questEntry); return questEntry; } public void Begin() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Begin(true); } } public void Cancel() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Cancel(true); } } public void Expire() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Expire(true); } } public void Fail() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Fail(true); } } public void Complete() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.Complete(true); } } public void End() { Quest s1Quest = S1Quest; if (s1Quest != null) { s1Quest.End(); } } } public class QuestData { public readonly string ClassName; public QuestData(string className) { ClassName = className; } } public class QuestEntry { internal readonly QuestEntry S1QuestEntry; public QuestState State => (QuestState)S1QuestEntry.State; public string Title { get { return S1QuestEntry.Title; } set { S1QuestEntry.SetEntryTitle(value); } } public Vector3 POIPosition { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return S1QuestEntry.PoILocation.position; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1QuestEntry.PoILocation.position = value; } } public event Action OnComplete { add { EventHelper.AddListener(value, S1QuestEntry.onComplete); } remove { EventHelper.RemoveListener(value, S1QuestEntry.onComplete); } } internal QuestEntry(QuestEntry questEntry) { S1QuestEntry = questEntry; } public void Begin() { S1QuestEntry.Begin(); } public void Complete() { S1QuestEntry.Complete(); } public void SetState(QuestState questState) { S1QuestEntry.SetState((EQuestState)questState, true); } } public static class QuestManager { internal static readonly List<Quest> Quests = new List<Quest>(); public static Quest CreateQuest<T>(string? guid = null) where T : Quest { return CreateQuest(typeof(T), guid); } public static Quest CreateQuest(Type questType, string? guid = null) { Quest quest = (Quest)Activator.CreateInstance(questType); if (quest == null) { throw new Exception("Unable to create quest instance of " + questType.FullName + "!"); } Quests.Add(quest); return quest; } public static Quest? GetQuestByGuid(string guid) { string guid2 = guid; return Quests.FirstOrDefault((Quest x) => x.S1Quest.StaticGUID == guid2); } public static Quest? GetQuestByName(string questName) { string questName2 = questName; return Quests.FirstOrDefault((Quest x) => x.S1Quest.Title == questName2); } } } namespace S1API.Quests.Constants { public enum QuestAction { Begin, Success, Fail, Expire, Cancel } public enum QuestState { Inactive, Active, Completed, Failed, Expired, Cancelled } } namespace S1API.Property { public abstract class BaseProperty { public abstract string PropertyName { get; } public abstract string PropertyCode { get; } public abstract float Price { get; } public abstract bool IsOwned { get; } public abstract int EmployeeCapacity { get; set; } public abstract void SetOwned(); public abstract bool IsPointInside(Vector3 point); } public static class PropertyManager { public static List<PropertyWrapper> GetAllProperties() { List<PropertyWrapper> list = new List<PropertyWrapper>(); Enumerator<Property> enumerator = Property.Properties.GetEnumerator(); while (enumerator.MoveNext()) { Property current = enumerator.Current; list.Add(new PropertyWrapper(current)); } return list; } public static List<PropertyWrapper> GetOwnedProperties() { List<PropertyWrapper> list = new List<PropertyWrapper>(); Enumerator<Property> enumerator = Property.OwnedProperties.GetEnumerator(); while (enumerator.MoveNext()) { Property current = enumerator.Current; list.Add(new PropertyWrapper(current)); } return list; } public static PropertyWrapper FindPropertyByName(string name) { Enumerator<Property> enumerator = Property.Properties.GetEnumerator(); while (enumerator.MoveNext()) { Property current = enumerator.Current; if (current.PropertyName == name) { return new PropertyWrapper(current); } } return null; } } public class PropertyWrapper : BaseProperty { internal readonly Property InnerProperty; public override string PropertyName => InnerProperty.PropertyName; public override string PropertyCode => InnerProperty.PropertyCode; public override float Price => InnerProperty.Price; public override bool IsOwned => InnerProperty.IsOwned; public override int EmployeeCapacity { get { return InnerProperty.EmployeeCapacity; } set { InnerProperty.EmployeeCapacity = value; } } public PropertyWrapper(Property property) { InnerProperty = property; } public override void SetOwned() { InnerProperty.SetOwned(); } public override bool IsPointInside(Vector3 point) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return InnerProperty.DoBoundsContainPoint(point); } } } namespace S1API.Products { public class CocaineDefinition : ProductDefinition { internal CocaineDefinition S1CocaineDefinition => CrossType.As<CocaineDefinition>((object)S1ItemDefinition); internal CocaineDefinition(CocaineDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>((object)((ItemDefinition)S1CocaineDefinition).GetDefaultInstance(quantity))); } } public class MethDefinition : ProductDefinition { internal MethDefinition S1MethDefinition => CrossType.As<MethDefinition>((object)S1ItemDefinition); internal MethDefinition(MethDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>((object)((ItemDefinition)S1MethDefinition).GetDefaultInstance(quantity))); } } public class PackagingDefinition : ItemDefinition { internal PackagingDefinition S1PackagingDefinition => CrossType.As<PackagingDefinition>((object)S1ItemDefinition); public int Quantity => S1PackagingDefinition.Quantity; internal PackagingDefinition(ItemDefinition s1ItemDefinition) : base(s1ItemDefinition) { } } public class ProductDefinition : ItemDefinition { internal ProductDefinition S1ProductDefinition => CrossType.As<ProductDefinition>((object)S1ItemDefinition); public float Price => S1ProductDefinition.Price; public Sprite Icon => ((ItemDefinition)S1ProductDefinition).Icon; internal ProductDefinition(ProductDefinition productDefinition) : base((ItemDefinition)(object)productDefinition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>((object)((ItemDefinition)S1ProductDefinition).GetDefaultInstance(quantity))); } } internal static class ProductDefinitionWrapper { internal static ProductDefinition Wrap(ProductDefinition def) { ItemDefinition s1ItemDefinition = def.S1ItemDefinition; if (CrossType.Is<WeedDefinition>((object)s1ItemDefinition, out WeedDefinition result)) { return new WeedDefinition(result); } if (CrossType.Is<MethDefinition>((object)s1ItemDefinition, out MethDefinition result2)) { return new MethDefinition(result2); } if (CrossType.Is<CocaineDefinition>((object)s1ItemDefinition, out CocaineDefinition result3)) { return new CocaineDefinition(result3); } return def; } } public class ProductInstance : ItemInstance { internal ProductItemInstance S1ProductInstance => CrossType.As<ProductItemInstance>((object)S1ItemInstance); public bool IsPackaged => Object.op_Implicit((Object)(object)S1ProductInstance.AppliedPackaging); public PackagingDefinition AppliedPackaging => new PackagingDefinition((ItemDefinition)(object)S1ProductInstance.AppliedPackaging); internal ProductInstance(ProductItemInstance productInstance) : base((ItemInstance)(object)productInstance) { } } public static class ProductManager { public static ProductDefinition[] DiscoveredProducts => ((IEnumerable<ProductDefinition>)ProductManager.DiscoveredProducts.ToArray()).Select((ProductDefinition productDefinition) => ProductDefinitionWrapper.Wrap(new ProductDefinition(productDefinition))).ToArray(); } public class WeedDefinition : ProductDefinition { internal WeedDefinition S1WeedDefinition => CrossType.As<WeedDefinition>((object)S1ItemDefinition); internal WeedDefinition(WeedDefinition definition) : base((ProductDefinition)(object)definition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new ProductInstance(CrossType.As<ProductItemInstance>((object)((ItemDefinition)S1WeedDefinition).GetDefaultInstance(quantity))); } } } namespace S1API.PhoneCalls { public class CallerDefinition { internal readonly CallerID S1CallerIDEntry; public string Name { get { return S1CallerIDEntry.Name; } set { S1CallerIDEntry.Name = value; } } public Sprite? ProfilePicture { get { return S1CallerIDEntry.ProfilePicture; } set { S1CallerIDEntry.ProfilePicture = value; } } internal CallerDefinition(CallerID s1CallerID) { S1CallerIDEntry = s1CallerID; } } public static class CallManager { public static void QueueCall(PhoneCallDefinition phoneCallDefinition) { Singleton<CallManager>.Instance.QueueCall(phoneCallDefinition.S1PhoneCallData); } } public class CallStageEntry { internal readonly Stage S1Stage; protected readonly List<SystemTriggerEntry> StartTriggerEntries = new List<SystemTriggerEntry>(); protected readonly List<SystemTriggerEntry> DoneTriggerEntries = new List<SystemTriggerEntry>(); public string Text { get { return S1Stage.Text; } set { S1Stage.Text = value; } } internal CallStageEntry(Stage stage) { S1Stage = stage; } public SystemTriggerEntry AddSystemTrigger(SystemTriggerType triggerType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown SystemTrigger val = new SystemTrigger(); SystemTriggerEntry systemTriggerEntry = new SystemTriggerEntry(val); switch (triggerType) { case SystemTriggerType.StartTrigger: S1Stage.OnStartTriggers = S1Stage.OnStartTriggers.AddItemToArray<SystemTrigger>((SystemTrigger[]?)(object)new SystemTrigger[1] { val }); StartTriggerEntries.Add(systemTriggerEntry); break; case SystemTriggerType.DoneTrigger: S1Stage.OnDoneTriggers = S1Stage.OnDoneTriggers.AddItemToArray<SystemTrigger>((SystemTrigger[]?)(object)new SystemTrigger[1] { val }); DoneTriggerEntries.Add(systemTriggerEntry); break; } return systemTriggerEntry; } } public abstract class PhoneCallDefinition { public CallerDefinition? Caller; public readonly PhoneCallData S1PhoneCallData; protected readonly List<CallStageEntry> StageEntries = new List<CallStageEntry>(); protected PhoneCallDefinition(string name, Sprite? profilePicture = null) { S1PhoneCallData = ScriptableObject.CreateInstance<PhoneCallData>(); PhoneCallData s1PhoneCallData = S1PhoneCallData; if (s1PhoneCallData.Stages == null) { Il2CppReferenceArray<Stage> val2 = (s1PhoneCallData.Stages = Il2CppReferenceArray<Stage>.op_Implicit(Array.Empty<Stage>())); } AddCallerID(name, profilePicture); } protected PhoneCallDefinition(NPC? npcCallerID) { S1PhoneCallData = ScriptableObject.CreateInstance<PhoneCallData>(); PhoneCallData s1PhoneCallData = S1PhoneCallData; if (s1PhoneCallData.Stages == null) { Il2CppReferenceArray<Stage> val2 = (s1PhoneCallData.Stages = Il2CppReferenceArray<Stage>.op_Implicit(Array.Empty<Stage>())); } AddCallerID(npcCallerID); } protected CallerDefinition AddCallerID(string name, Sprite? profilePicture = null) { CallerID val = ScriptableObject.CreateInstance<CallerID>(); val.Name = name; val.ProfilePicture = profilePicture; S1PhoneCallData.CallerID = val; Caller = new CallerDefinition(val) { Name = name, ProfilePicture = profilePicture }; return Caller; } protected CallerDefinition AddCallerID(NPC? npc) { CallerID val = ScriptableObject.CreateInstance<CallerID>(); val.Name = npc?.FullName ?? "Unknown Caller"; val.ProfilePicture = npc?.Icon; S1PhoneCallData.CallerID = val; Caller = new CallerDefinition(val) { Name = (npc?.FullName ?? "Unknown Caller"), ProfilePicture = npc?.Icon }; return Caller; } protected CallStageEntry AddStage(string text) { //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_000f: Expected O, but got Unknown Stage val = new Stage { Text = text }; S1PhoneCallData.Stages = S1PhoneCallData.Stages.AddItemToArray<Stage>((Stage[]?)(object)new Stage[1] { val }); CallStageEntry callStageEntry = new CallStageEntry(val) { Text = text }; StageEntries.Add(callStageEntry); return callStageEntry; } public void Completed() { S1PhoneCallData.Completed(); } } } namespace S1API.PhoneCalls.Constants { public enum EvaluationType { PassOnTrue, PassOnFalse } public enum SystemTriggerType { StartTrigger, DoneTrigger } } namespace S1API.PhoneApp { public abstract class PhoneApp : Registerable { protected static readonly Log Logger = new Log("PhoneApp"); private GameObject? _appPanel; private bool _appCreated; private bool _iconModified; protected abstract string AppName { get; } protected abstract string AppTitle { get; } protected abstract string IconLabel { get; } protected abstract string IconFileName { get; } protected abstract void OnCreatedUI(GameObject container); protected override void OnCreated() { PhoneAppRegistry.Register(this); } protected override void OnDestroyed() { if ((Object)(object)_appPanel != (Object)null) { Object.Destroy((Object)(object)_appPanel); _appPanel = null; } _appCreated = false; _iconModified = false; } internal void SpawnUI(HomeScreen homeScreenInstance) { Transform obj = ((Component)homeScreenInstance).transform.parent.Find("AppsCanvas"); GameObject val = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val == (Object)null) { Logger.Error("AppsCanvas not found."); return; } Transform val2 = val.transform.Find(AppName); if ((Object)(object)val2 != (Object)null) { _appPanel = ((Component)val2).gameObject; SetupExistingAppPanel(_appPanel); } else { Transform val3 = val.transform.Find("ProductManagerApp"); if ((Object)(object)val3 == (Object)null) { Logger.Error("Template ProductManagerApp not found."); return; } _appPanel = Object.Instantiate<GameObject>(((Component)val3).gameObject, val.transform); ((Object)_appPanel).name = AppName; Transform val4 = _appPanel.transform.Find("Container"); if ((Object)(object)val4 != (Object)null) { GameObject gameObject = ((Component)val4).gameObject; ClearContainer(gameObject); OnCreatedUI(gameObject); } _appCreated = true; } _appPanel.SetActive(true); } internal void SpawnIcon(HomeScreen homeScreenInstance) { if (_iconModified) { return; } Transform obj = ((Component)homeScreenInstance).transform.Find("AppIcons"); GameObject val = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val == (Object)null) { Logger.Error("AppIcons not found under HomeScreen."); return; } Transform val2 = ((val.transform.childCount > 0) ? val.transform.GetChild(val.transform.childCount - 1) : null); if ((Object)(object)val2 == (Object)null) { Logger.Error("No icons found in AppIcons."); return; } GameObject gameObject = ((Component)val2).gameObject; ((Object)gameObject).name = AppName; Transform val3 = gameObject.transform.Find("Label"); Text val4 = ((val3 != null) ? ((Component)val3).GetComponent<Text>() : null); if ((Object)(object)val4 != (Object)null) { val4.text = IconLabel; } _iconModified = ChangeAppIconImage(gameObject, IconFileName); } private void SetupExistingAppPanel(GameObject panel) { Transform val = panel.transform.Find("Container"); if ((Object)(object)val != (Object)null) { GameObject gameObject = ((Component)val).gameObject; if (gameObject.transform.childCount < 2) { ClearContainer(gameObject); OnCreatedUI(gameObject); } } _appCreated = true; } private void ClearContainer(GameObject container) { for (int num = container.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)container.transform.GetChild(num)).gameObject); } } private bool ChangeAppIconImage(GameObject iconObj, string filename) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) Transform val = iconObj.transform.Find("Mask/Image"); Image val2 = ((val != null) ? ((Component)val).GetComponent<Image>() : null); if ((Object)(object)val2 == (Object)null) { Logger.Error("Image component not found in icon."); return false; } string text = Path.Combine(MelonEnvironment.ModsDirectory, filename); if (!File.Exists(text)) { Logger.Error("Icon file not found: " + text); return false; } try { byte[] array = File.ReadAllBytes(text); Texture2D val3 = new Texture2D(2, 2); if (ImageConversion.LoadImage(val3, Il2CppStructArray<byte>.op_Implicit(array))) { val2.sprite = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f)); return true; } Object.Destroy((Object)(object)val3); } catch (Exception ex) { Logger.Error("Failed to load image: " + ex.Message); } return false; } } } namespace S1API.Money { public class CashDefinition : ItemDefinition { internal CashDefinition S1CashDefinition => CrossType.As<CashDefinition>((object)S1ItemDefinition); internal CashDefinition(CashDefinition s1ItemDefinition) : base((ItemDefinition)(object)s1ItemDefinition) { } public override ItemInstance CreateInstance(int quantity = 1) { return new CashInstance(((ItemDefinition)S1CashDefinition).GetDefaultInstance(quantity)); } } public class CashInstance : ItemInstance { internal CashInstance S1CashInstance => CrossType.As<CashInstance>((object)S1ItemInstance); internal CashInstance(ItemInstance itemInstance) : base(itemInstance) { } public void AddQuantity(float amount) { S1CashInstance.SetBalance(Mathf.Clamp(S1CashInstance.Balance + amount, 0f, float.MaxValue), false); } public void SetQuantity(float newQuantity) { S1CashInstance.SetBalance(newQuantity, false); } } public static class Money { private static MoneyManager Internal => NetworkSingleton<MoneyManager>.Instance; public static event Action? OnBalanceChanged; public static void ChangeCashBalance(float amount, bool visualizeChange = true, bool playCashSound = false) { MoneyManager @internal = Internal; if (@internal != null) { @internal.ChangeCashBalance(amount, visualizeChange, playCashSound); } Money.OnBalanceChanged?.Invoke(); } public static void CreateOnlineTransaction(string transactionName, float unitAmount, float quantity, string transactionNote) { MoneyManager @internal = Internal; if (@internal != null) { @internal.CreateOnlineTransaction(transactionName, unitAmount, quantity, transactionNote); } Money.OnBalanceChanged?.Invoke(); } public static float GetNetWorth() { return ((Object)(object)Internal != (Object)null) ? Internal.GetNetWorth() : 0f; } public static float GetCashBalance() { return ((Object)(object)Internal != (Object)null) ? Internal.cashBalance : 0f; } public static float GetOnlineBalance() { return ((Object)(object)Internal != (Object)null) ? Internal.sync___get_value_onlineBalance() : 0f; } public static void AddNetworthCalculation(Action<object> callback) { if ((Object)(object)Internal != (Object)null) { MoneyManager @internal = Internal; @internal.onNetworthCalculation += Action<FloatContainer>.op_Implicit((Action<FloatContainer>)callback); } } public static void RemoveNetworthCalculation(Action<object> callback) { if ((Object)(object)Internal != (Object)null) { MoneyManager @internal = Internal; @internal.onNetworthCalculation -= Action<FloatContainer>.op_Implicit((Action<FloatContainer>)callback); } } public static CashInstance CreateCashInstance(float amount) { CashDefinition item = Registry.GetItem<CashDefinition>("cash"); ItemInstance itemInstance = CrossType.As<ItemInstance>((object)((ItemDefinition)item).GetDefaultInstance(1)); CashInstance cashInstance = new CashInstance(itemInstance); cashInstance.SetQuantity(amount); return cashInstance; } } } namespace S1API.Messaging { public class Response { internal readonly Response S1Response; public Action? OnTriggered { get { return ((Delegate)(object)S1Response.callback == (Delegate)null) ? null : ((Action)delegate { S1Response.callback.Invoke(); }); } set { S1Response.callback = Action.op_Implicit(value); } } public string Label { get { return S1Response.label; } set { S1Response.label = value; } } public string Text { get { return S1Response.text; } set { S1Response.text = value; } } public Response() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown S1Response = new Response(); } internal Response(Response response) { S1Response = response; } } } namespace S1API.Map { public enum Region { Northtown, Westville, Downtown, Docks, Suburbia, Uptown } } namespace S1API.Logging { public class Log { private readonly Instance _loggerInstance; public Log(string sourceName) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown _loggerInstance = new Instance(sourceName); } public void Msg(string message) { _loggerInstance.Msg(message); } public void Warning(string message) { _loggerInstance.Warning(message); } public void Error(string message) { _loggerInstance.Error(message); } public void BigError(string message) { _loggerInstance.BigError(message); } } } namespace S1API.Leveling { public static class LevelManager { public static Rank Rank = (Rank)NetworkSingleton<LevelManager>.Instance.Rank; } public enum Rank { StreetRat, Hoodlum, Peddler, Hustler, Bagman, Enforcer, ShotCaller, BlockBoss, Underlord, Baron, Kingpin } } namespace S1API.Items { public enum ItemCategory { Product, Packaging, Growing, Tools, Furniture, Lighting, Cash, Consumable, Equipment, Ingredient, Decoration, Clothing } public class ItemDefinition : IGUIDReference { internal readonly ItemDefinition S1ItemDefinition; public virtual string GUID => S1ItemDefinition.ID; public string ID => S1ItemDefinition.ID; public string Name => S1ItemDefinition.Name; public string Description => S1ItemDefinition.Description; public ItemCategory Category => (ItemCategory)S1ItemDefinition.Category; public int StackLimit => S1ItemDefinition.StackLimit; internal ItemDefinition(ItemDefinition s1ItemDefinition) { S1ItemDefinition = s1ItemDefinition; } internal static ItemDefinition GetFromGUID(string guid) { return ItemManager.GetItemDefinition(guid); } public override bool Equals(object? obj) { return obj is ItemDefinition itemDefinition && (Object)(object)S1ItemDefinition == (Object)(object)itemDefinition.S1ItemDefinition; } public override int GetHashCode() { ItemDefinition s1ItemDefinition = S1ItemDefinition; return (s1ItemDefinition != null) ? ((Object)s1ItemDefinition).GetHashCode() : 0; } public static bool operator ==(ItemDefinition? left, ItemDefinition? right) { if ((object)left == right) { return true; } return (Object)(object)left?.S1ItemDefinition == (Object)(object)right?.S1ItemDefinition; } public static bool operator !=(ItemDefinition left, ItemDefinition right) { return !(left == right); } public virtual ItemInstance CreateInstance(int quantity = 1) { return new ItemInstance(S1ItemDefinition.GetDefaultInstance(quantity)); } } public class ItemInstance { internal readonly ItemInstance S1ItemInstance; public ItemDefinition Definition => new ItemDefinition(S1ItemInstance.Definition); internal ItemInstance(ItemInstance itemInstance) { S1ItemInstance = itemInstance; } } public static class ItemManager { public static ItemDefinition GetItemDefinition(string itemID) { ItemDefinition item = Registry.GetItem(itemID); if (CrossType.Is<ProductDefinition>((object)item, out ProductDefinition result)) { return new ProductDefinition(result); } if (CrossType.Is<CashDefinition>((object)item, out CashDefinition result2)) { return new CashDefinition(result2); } return new ItemDefinition(item); } } public class ItemSlotInstance { internal readonly ItemSlot S1ItemSlot; public int Quantity => S1ItemSlot.Quantity; public ItemInstance? ItemInstance { get { if (CrossType.Is<ProductItemInstance>((object)S1ItemSlot.ItemInstance, out ProductItemInstance result)) { return new ProductInstance(result); } if (CrossType.Is<CashInstance>((object)S1ItemSlot.ItemInstance, out CashInstance result2)) { return new CashInstance((ItemInstance)(object)result2); } if (CrossType.Is<ItemInstance>((object)S1ItemSlot.ItemInstance, out ItemInstance result3)) { return new ItemInstance(result3); } return null; } } internal ItemSlotInstance(ItemSlot itemSlot) { S1ItemSlot = itemSlot; } public void AddQuantity(int amount) { S1ItemSlot.ChangeQuantity(amount, false); } } } namespace S1API.Internal.Utils { public static class ArrayExtensions { public static T[] AddItemToArray<T>(this T[]? array, T item) { if (array == null) { array = Array.Empty<T>(); } Array.Resize(ref array, array.Length + 1); array[^1] = item; return array; } public static Il2CppReferenceArray<T> AddItemToArray<T>(this Il2CppReferenceArray<T>? array, params T[]? itemsToAdd) where T : Object { int num = ((Il2CppArrayBase<T>)(object)array)?.Length ?? 0; int num2 = ((itemsToAdd != null) ? itemsToAdd.Length : 0); int num3 = num + num2; Il2CppReferenceArray<T> val = new Il2CppReferenceArray<T>((long)num3); for (int i = 0; i < num; i++) { ((Il2CppArrayBase<T>)(object)val)[i] = ((Il2CppArrayBase<T>)(object)array)[i]; } for (int j = 0; j < num2; j++) { ((Il2CppArrayBase<T>)(object)val)[num + j] = itemsToAdd[j]; } return val; } } public static class ButtonUtils { public static void AddListener(Button button, Action action) { if (!((Object)(object)button == (Object)null) && action != null) { EventHelper.AddListener(action, (UnityEvent)(object)button.onClick); } } public static void RemoveListener(Button button, Action action) { if (!((Object)(object)button == (Object)null) && action != null) { EventHelper.RemoveListener(action, (UnityEvent)(object)button.onClick); } } public static void ClearListeners(Button button) { if (!((Object)(object)button == (Object)null)) { ((UnityEventBase)button.onClick).RemoveAllListeners(); } } public static void Enable(Button button, Text? label = null, string? text = null) { if ((Object)(object)button != (Object)null) { ((Selectable)button).interactable = true; } if ((Object)(object)label != (Object)null && !string.IsNullOrEmpty(text)) { label.text = text; } } public static void Disable(Button button, Text? label = null, string? text = null) { if ((Object)(object)button != (Object)null) { ((Selectable)button).interactable = false; } if ((Object)(object)label != (Object)null && !string.IsNullOrEmpty(text)) { label.text = text; } } public static void SetLabel(Text label, string text) { if ((Object)(object)label != (Object)null) { label.text = text; } } public static void SetStyle(Button button, Text label, string text, Color bg) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)button == (Object)null) && !((Object)(object)label == (Object)null)) { label.text = text; ((Graphic)((Selectable)button).image).color = bg; } } } internal static class CrossType { internal static Type Of<T>() { return Il2CppType.Of<T>(); } internal static bool Is<T>(object obj, out T result) where T : Il2CppObjectBase { Object val = (Object)((obj is Object) ? obj : null); if (val != null) { Type val2 = Il2CppType.Of<T>(); if (val2.IsAssignableFrom(val.GetIl2CppType())) { result = ((Il2CppObjectBase)val).TryCast<T>(); return true; } } result = default(T); return false; } internal static T As<T>(object obj) where T : Il2CppObjectBase { Object val = (Object)((obj is Object) ? obj : null); return (val != null) ? ((Il2CppObjectBase)val).Cast<T>() : default(T); } } public static class ImageUtils { private static readonly Log _loggerInstance = new Log("ImageUtils"); public static Sprite? LoadImage(string fileName) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_008d: 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) string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, fileName); if (!File.Exists(text)) { _loggerInstance.Error("❌ Icon file not found: " + text); return null; } try { byte[] array = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2); if (ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array))) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } catch (Exception ex) { _loggerInstance.Error("❌ Failed to load sprite: " + ex); } return null; } } public static class RandomUtils { private static readonly Random SystemRng = new Random(); public static T PickOne<T>(this IList<T> list) { if (list == null || list.Count == 0) { return default(T); } return list[Random.Range(0, list.Count)]; } public static T PickUnique<T>(this IList<T> list, Func<T, bool> isDuplicate, int maxTries = 10) { if (list.Count == 0) { return default(T); } for (int i = 0; i < maxTries; i++) { T val = list.PickOne(); if (!isDuplicate(val)) { return val; } } return default(T); } public static List<T> PickMany<T>(this IList<T> list, int count) { if (list.Count == 0) { return new List<T>(); } List<T> list2 = new List<T>(list); List<T> list3 = new List<T>(); for (int i = 0; i < count; i++) { if (list2.Count <= 0) { break; } int index = Random.Range(0, list2.Count); list3.Add(list2[index]); list2.RemoveAt(index); } return list3; } public static int RangeInt(int minInclusive, int maxExclusive) { return SystemRng.Next(minInclusive, maxExclusive); } } internal static class ReflectionUtils { internal static List<Type> GetDerivedClasses<TBaseClass>() { List<Type> list = new List<Type>(); Assembly[] array = (from assembly in AppDomain.CurrentDomain.GetAssemblies() where !assembly.FullName.StartsWith("System") && !assembly.FullName.StartsWith("Unity") && !assembly.FullName.StartsWith("Il2Cpp") && !assembly.FullName.StartsWith("mscorlib") && !assembly.FullName.StartsWith("Mono.") && !assembly.FullName.StartsWith("netstandard") && !assembly.FullName.StartsWith("com.rlabrecque") && !assembly.FullName.StartsWith("__Generated") select assembly).ToArray(); Assembly[] array2 = array; foreach (Assembly assembly2 in array2) { list.AddRange(from type in assembly2.GetTypes() where typeof(TBaseClass).IsAssignableFrom(type) && type != typeof(TBaseClass) && !type.IsAbstract select type); } return list; } internal static Type? GetTypeByName(string typeName) { string typeName2 = typeName; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array = assemblies; foreach (Assembly assembly in array) { Type type2 = assembly.GetTypes().FirstOrDefault((Type type) => type.Name == typeName2); if (!(type2 == null)) { return type2; } } return null; } internal static FieldInfo[] GetAllFields(Type? type, BindingFlags bindingFlags) { List<FieldInfo> list = new List<FieldInfo>(); while (type != null && type != typeof(object)) { list.AddRange(type.GetFields(bindingFlags)); type = type.BaseType; } return list.ToArray(); } public static MethodInfo? GetMethod(Type? type, string methodName, BindingFlags bindingFlags) { while (type != null && type != typeof(object)) { MethodInfo method = type.GetMethod(methodName, bindingFlags); if (method != null) { return method; } type = type.BaseType; } return null; } } } namespace S1API.Internal.Patches { [HarmonyPatch(typeof(HomeScreen), "Start")] internal static class HomeScreen_Start_Patch { private static readonly Log Logger = new Log("PhoneApp"); private static void Postfix(HomeScreen __instance) { if ((Object)(object)__instance == (Object)null) { return; } List<Type> derivedClasses = ReflectionUtils.GetDerivedClasses<global::S1API.PhoneApp.PhoneApp>(); foreach (Type item in derivedClasses) { Logger.Msg("Found phone app: " + item.FullName); if (!(item.GetConstructor(Type.EmptyTypes) == null)) { try { global::S1API.PhoneApp.PhoneApp phoneApp = (global::S1API.PhoneApp.PhoneApp)Activator.CreateInstance(item); ((IRegisterable)phoneApp).CreateInternal(); phoneApp.SpawnUI(__instance); phoneApp.SpawnIcon(__instance); } catch (Exception ex) { Logger.Warning("[PhoneApp] Failed to register " + item.FullName + ": " + ex.Message); } } } } } [HarmonyPatch] internal class NPCPatches { [HarmonyPatch(typeof(NPCsLoader), "Load")] [HarmonyPrefix] private static void NPCsLoadersLoad(NPCsLoader __instance, string mainPath) { foreach (Type derivedClass in ReflectionUtils.GetDerivedClasses<NPC>()) { NPC nPC = (NPC)Activator.CreateInstance(derivedClass, nonPublic: true); if (nPC == null) { throw new Exception("Unable to create instance of " + derivedClass.FullName + "!"); } if (!(derivedClass.Assembly == Assembly.GetExecutingAssembly())) { string folderPath = Path.Combine(mainPath, nPC.S1NPC.SaveFolderName); nPC.LoadInternal(folderPath); } } } [HarmonyPatch(typeof(NPC), "Start")] [HarmonyPostfix] private static void NPCStart(NPC __instance) { NPC __instance2 = __instance; NPC.All.FirstOrDefault((NPC npc) => npc.IsCustomNPC && (Object)(object)npc.S1NPC == (Object)(object)__instance2)?.CreateInternal(); } [HarmonyPatch(typeof(NPC), "WriteData")] [HarmonyPostfix] private static void NPCWriteData(NPC __instance, string parentFolderPath, ref List<string> __result) { NPC __instance2 = __instance; NPC.All.FirstOrDefault((NPC npc) => npc.IsCustomNPC && (Object)(object)npc.S1NPC == (Object)(object)__instance2)?.SaveInternal(parentFolderPath, ref __result); } [HarmonyPatch(typeof(NPC), "OnDestroy")] [HarmonyPostfix] private static void NPCOnDestroy(NPC __instance) { NPC __instance2 = __instance; NPC.All.Remove(NPC.All.First((NPC npc) => (Object)(object)npc.S1NPC == (Object)(object)__instance2)); } } internal static class PhoneAppRegistry { public static readonly List<global::S1API.PhoneApp.PhoneApp> RegisteredApps = new List<global::S1API.PhoneApp.PhoneApp>(); public static void Register(global::S1API.PhoneApp.PhoneApp app) { RegisteredApps.Add(app); } } [HarmonyPatch] internal class PlayerPatches { [HarmonyPatch(typeof(Player), "Awake")] [HarmonyPostfix] private static void PlayerAwake(Player __instance) { new Player(__instance); } [HarmonyPatch(typeof(Player), "OnDestroy")] [HarmonyPostfix] private static void PlayerOnDestroy(Player __instance) { Player __instance2 = __instance; Player.All.Remove(Player.All.First((Player player) => (Object)(object)player.S1Player == (Object)(object)__instance2)); } } [HarmonyPatch] internal class QuestPatches { [HarmonyPatch(typeof(QuestManager), "WriteData")] [HarmonyPostfix] private static void QuestManagerWriteData(QuestManager __instance, string parentFolderPath, ref List<string> __result) { string folderPath = Path.Combine(parentFolderPath, "Quests"); foreach (Quest quest in QuestManager.Quests) { quest.SaveInternal(folderPath, ref __result); } } [HarmonyPatch(typeof(QuestsLoader), "Load")] [HarmonyPostfix] private static void QuestsLoaderLoad(QuestsLoader __instance, string mainPath) { if (!Directory.Exists(mainPath)) { return; } string[] array = (from directory in Directory.GetDirectories(mainPath).Select(Path.GetFileName) where directory?.StartsWith("Quest_") ?? false select directory).ToArray(); string[] array2 = array; string text2 = default(string); string text5 = default(string); foreach (string path in array2) { string text = Path.Combine(mainPath, path); ((Loader)__instance).TryLoadFile(text, ref text2, true); if (text2 == null) { continue; } QuestData val = JsonUtility.FromJson<QuestData>(text2); string text3 = Path.Combine(mainPath, path); string text4 = Path.Combine(text3, "QuestData"); if (!((Loader)__instance).TryLoadFile(text4, ref text5, true)) { continue; } QuestData questData = JsonConvert.DeserializeObject<QuestData>(text5, ISaveable.SerializerSettings); if (questData?.ClassName != null) { Type typeByName = ReflectionUtils.GetTypeByName(questData.ClassName); if (!(typeByName == null) && typeof(Quest).IsAssignableFrom(typeByName)) { Quest quest = QuestManager.CreateQuest(typeByName, (val != null) ? val.GUID : null); quest.LoadInternal(text3); } } } } [HarmonyPatch(typeof(QuestManager), "DeleteUnapprovedFiles")] [HarmonyPostfix] private static void QuestManagerDeleteUnapprovedFiles(QuestManager __instance, string parentFolderPath) { string path = Path.Combine(parentFolderPath, "Quests"); string?[] existingQuests = QuestManager.Quests.Select((Quest quest) => quest.SaveFolder).ToArray(); string[] array = (from directory in Directory.GetDirectories(path) where directory.StartsWith("Quest_") && !existingQuests.Contains<string>(directory) select directory).ToArray(); string[] array2 = array; foreach (string path2 in array2) { Directory.Delete(path2, recursive: true); } } [HarmonyPatch(typeof(Quest), "Start")] [HarmonyPrefix] private static void QuestStart(Quest __instance) { Quest __instance2 = __instance; QuestManager.Quests.FirstOrDefault((Quest quest) => (Object)(object)quest.S1Quest == (Object)(object)__instance2)?.CreateInternal(); } } [HarmonyPatch] internal class TimePatches { [HarmonyPatch(typeof(TimeManager), "Awake")] [HarmonyPostfix] private static void TimeManagerAwake(TimeManager __instance) { __instance.onDayPass += Action.op_Implicit((Action)DayPass); static void DayPass() { TimeManager.OnDayPass(); } } } } namespace S1API.Internal.Abstraction { internal static class EventHelper { internal static readonly Dictionary<Action, UnityAction> SubscribedActions = new Dictionary<Action, UnityAction>(); internal static void AddListener(Action listener, UnityEvent unityEvent) { if (!SubscribedActions.ContainsKey(listener)) { UnityAction val = UnityAction.op_Implicit((Action)listener.Invoke); unityEvent.AddListener(val); SubscribedActions.Add(listener, val); } } internal static void RemoveListener(Action listener, UnityEvent unityEvent) { SubscribedActions.TryGetValue(listener, out UnityAction value); SubscribedActions.Remove(listener); unityEvent.RemoveListener(value); } } internal class GUIDReferenceConverter : JsonConverter { public override bool CanRead => true; public override bool CanConvert(Type objectType) { return typeof(IGUIDReference).IsAssignableFrom(objectType); } public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (value is IGUIDReference iGUIDReference) { writer.WriteValue(iGUIDReference.GUID); } else { writer.WriteNull(); } } public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { string text = reader.Value?.ToString(); if (string.IsNullOrEmpty(text)) { return null; } MethodInfo method = ReflectionUtils.GetMethod(objectType, "GetFromGUID", BindingFlags.Static | BindingFlags.NonPublic); if (method == null) { throw new Exception("The type " + objectType.Name + " does not have a valid implementation of the GetFromGUID(string guid) method!"); } return method.Invoke(null, new object[1] { text }); } } internal interface IGUIDReference { string GUID { get; } } internal interface IRegisterable { void CreateInternal(); void DestroyInternal(); void OnCreated(); void OnDestroyed(); } internal interface ISaveable : IRegisterable { internal static JsonSerializerSettings SerializerSettings => new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1, Converters = new List<JsonConverter> { (JsonConverter)(object)new GUIDReferenceConverter() } }; void SaveInternal(string path, ref List<string> extraSaveables); void LoadInternal(string folderPath); void OnSaved(); void OnLoaded(); } public abstract class Registerable : IRegisterable { void IRegisterable.CreateInternal() { CreateInternal(); } internal virtual void CreateInternal() { OnCreated(); } void IRegisterable.DestroyInternal() { DestroyInternal(); } internal virtual void DestroyInternal() { OnDestroyed(); } void IRegisterable.OnCreated() { OnCreated(); } protected virtual void OnCreated() { } void IRegisterable.OnDestroyed() { OnDestroyed(); } protected virtual void OnDestroyed() { } } public abstract class Saveable : Registerable, ISaveable, IRegisterable { void ISaveable.LoadInternal(string folderPath) { LoadInternal(folderPath); } internal virtual void LoadInternal(string folderPath) { FieldInfo[] fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { SaveableField customAttribute = fieldInfo.GetCustomAttribute<SaveableField>(); if (customAttribute != null) { string path = (customAttribute.SaveName.EndsWith(".json") ? customAttribute.SaveName : (customAttribute.SaveName + ".json")); string path2 = Path.Combine(folderPath, path); if (File.Exists(path2)) { string text = File.ReadAllText(path2); Type fieldType = fieldInfo.FieldType; object value = JsonConvert.DeserializeObject(text, fieldType, ISaveable.SerializerSettings); fieldInfo.SetValue(this, value); } } } OnLoaded(); } void ISaveable.SaveInternal(string folderPath, ref List<string> extraSaveables) { SaveInternal(folderPath, ref extraSaveables); } internal virtual void SaveInternal(string folderPath, ref List<string> extraSaveables) { FieldInfo[] allFields = ReflectionUtils.GetAllFields(GetType(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = allFields; foreach (FieldInfo fieldInfo in array) { SaveableField customAttribute = fieldInfo.GetCustomAttribute<SaveableField>(); if (customAttribute != null) { string text = (customAttribute.SaveName.EndsWith(".json") ? customAttribute.SaveName : (customAttribute.SaveName + ".json")); string path = Path.Combine(folderPath, text); object value = fieldInfo.GetValue(this); if (value == null) { File.Delete(path); continue; } extraSaveables.Add(text); string contents = JsonConvert.SerializeObject(value, (Formatting)1, ISaveable.SerializerSettings); File.WriteAllText(path, contents); } } OnSaved(); } void ISaveable.OnLoaded() { OnLoaded(); } protected virtual void OnLoaded() { } void ISaveable.OnSaved() { OnSaved(); } protected virtual void OnSaved() { } } } namespace S1API.GameTime { public enum Day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } public struct GameDateTime { public int ElapsedDays; public int Time; public GameDateTime(int elapsedDays, int time) { ElapsedDays = elapsedDays; Time = time; } public GameDateTime(int minSum) { ElapsedDays = minSum / 1440; int num = minSum % 1440; if (minSum < 0) { num = -minSum % 1440; } Time = TimeManager.Get24HourTimeFromMinSum(num); } public GameDateTime(GameDateTimeData data) { ElapsedDays = data.ElapsedDays; Time = data.Time; } public GameDateTime(GameDateTime gameDateTime) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) ElapsedDays = gameDateTime.elapsedDays; Time = gameDateTime.time; } public int GetMinSum() { return ElapsedDays * 1440 + TimeManager.GetMinSumFrom24HourTime(Time); } public GameDateTime AddMinutes(int minutes) { return new GameDateTime(GetMinSum() + minutes); } public GameDateTime ToS1() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return new GameDateTime(ElapsedDays, Time); } public string GetFormattedTime() { return TimeManager.Get12HourTime((float)Time, true); } public bool IsNightTime() { return Time < 600 || Time >= 1800; } public bool IsSameDay(GameDateTime other) { return ElapsedDays == other.ElapsedDays; } public bool IsSameTime(GameDateTime other) { return ElapsedDays == other.ElapsedDays && Time == other.Time; } public override string ToString() { return $"Day {ElapsedDays}, {GetFormattedTime()}"; } public static GameDateTime operator +(GameDateTime a, GameDateTime b) { return new GameDateTime(a.GetMinSum() + b.GetMinSum()); } public static GameDateTime operator -(GameDateTime a, GameDateTime b) { return new GameDateTime(a.GetMinSum() - b.GetMinSum()); } public static bool operator >(GameDateTime a, GameDateTime b) { return a.GetMinSum() > b.GetMinSum(); } public static bool operator <(GameDateTime a, GameDateTime b) { return a.GetMinSum() < b.GetMinSum(); } } public static class TimeManager { public static Action OnDayPass; public static Action OnWeekPass; public static Action OnSleepStart; public static Action<int> OnSleepEnd; public static Day CurrentDay => (Day)NetworkSingleton<TimeManager>.Instance.CurrentDay; public static int ElapsedDays => NetworkSingleton<TimeManager>.Instance.ElapsedDays; public static int CurrentTime => NetworkSingleton<TimeManager>.Instance.CurrentTime; public static bool IsNight => NetworkSingleton<TimeManager>.Instance.IsNight; public static bool IsEndOfDay => NetworkSingleton<TimeManager>.Instance.IsEndOfDay; public static bool SleepInProgress => NetworkSingleton<TimeManager>.Instance.SleepInProgress; public static bool TimeOverridden => NetworkSingleton<TimeManager>.Instance.TimeOverridden; public static float NormalizedTime => NetworkSingleton<TimeManager>.Instance.NormalizedTime; public static float Playtime => NetworkSingleton<TimeManager>.Instance.Playtime; static TimeManager() { OnDayPass = delegate { }; OnWeekPass = delegate { }; OnSleepStart = delegate { }; OnSleepEnd = delegate { }; if ((Object)(object)NetworkSingleton<TimeManager>.Instance != (Object)null) { TimeManager instance = NetworkSingleton<TimeManager>.Instance; instance.onDayPass += Action.op_Implicit((Action)delegate { OnDayPass(); }); TimeManager instance2 = NetworkSingleton<TimeManager>.Instance; instance2.onWeekPass += Action.op_Implicit((Action)delegate { OnWeekPass(); }); } TimeManager.onSleepStart += Action.op_Implicit((Action)delegate { OnSleepStart(); }); TimeManager.onSleepEnd += Action<int>.op_Implicit((Action<int>)delegate(int minutes) { OnSleepEnd(minutes); }); } public static void FastForwardToWakeTime() { NetworkSingleton<TimeManager>.Instance.FastForwardToWakeTime(); } public static void SetTime(int time24h, bool local = false) { NetworkSingleton<TimeManager>.Instance.SetTime(time24h, local); } public static void SetElapsedDays(int days) { NetworkSingleton<TimeManager>.Instance.SetElapsedDays(days); } public static string GetFormatted12HourTime() { return TimeManager.Get12HourTime((float)CurrentTime, true); } public static bool IsCurrentTimeWithinRange(int startTime24h, int endTime24h) { return NetworkSingleton<TimeManager>.Instance.IsCurrentTimeWithinRange(startTime24h, endTime24h); } public static int GetMinutesFrom24HourTime(int time24h) { return TimeManager.GetMinSumFrom24HourTime(time24h); } public static int Get24HourTimeFromMinutes(int minutes) { return TimeManager.Get24HourTimeFromMinSum(minutes); } } } namespace S1API.Entities { public abstract class NPC : Saveable, IEntity, IHealth { protected readonly List<Response> Responses = new List<Response>(); public static readonly List<NPC> All = new List<NPC>(); internal readonly NPC S1NPC; internal readonly bool IsCustomNPC; private readonly FieldInfo _panicField = AccessTools.Field(typeof(NPC), "PANIC_DURATION"); private readonly FieldInfo _requiresRegionUnlockedField = AccessTools.Field(typeof(NPC), "RequiresRegionUnlocked"); private readonly MethodInfo _unsettleMethod = AccessTools.Method(typeof(NPC), "SetUnsettled", (Type[])null, (Type[])null); private readonly MethodInfo _removePanicMethod = AccessTools.Method(typeof(NPC), "RemovePanicked", (Type[])null, (Type[])null); public GameObject gameObject { get; } public Vector3 Position { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return gameObject.transform.position; } set { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1NPC.Movement.Warp(value); } } public Transform Transform => gameObject.transform; public string FirstName { get { return S1NPC.FirstName; } set { S1NPC.FirstName = value; } } public string LastName { get { return S1NPC.LastName; } set { S1NPC.LastName = value; } } public string FullName => S1NPC.fullName; public string ID { get { return S1NPC.ID; } protected set { S1NPC.ID = value; } } public Sprite Icon { get { return S1NPC.MugshotSprite; } set { S1NPC.MugshotSprite = value; } } public bool IsConscious => S1NPC.IsConscious; public bool IsInBuilding => S1NPC.isInBuilding; public bool IsInVehicle => S1NPC.IsInVehicle; public bool IsPanicking => S1NPC.IsPanicked; public bool IsUnsettled => S1NPC.isUnsettled; public bool IsVisible => S1NPC.isVisible; public float Aggressiveness { get { return S1NPC.Aggression; } set { S1NPC.Aggression = value; } } public Region Region => (Region)S1NPC.Region; public float PanicDuration { get { return (float)_panicField.GetValue(S1NPC); } set { _panicField.SetValue(S1NPC, value); } } public float Scale { get { return S1NPC.Scale; } set { S1NPC.SetScale(value); } } public bool IsKnockedOut => S1NPC.Health.IsKnockedOut; public bool RequiresRegionUnlocked { get { return (bool)_requiresRegionUnlockedField.GetValue(S1NPC); } set { _panicField.SetValue(S1NPC, value); } } public float CurrentHealth => S1NPC.Health.Health; public float MaxHealth { get { return S1NPC.Health.MaxHealth; } set { S1NPC.Health.MaxHealth = value; } } public bool IsDead => S1NPC.Health.IsDead; public bool IsInvincible { get { return S1NPC.Health.Invincible; } set { S1NPC.Health.Invincible = value; } } public event Action OnDeath { add { EventHelper.AddListener(value, S1NPC.Health.onDie); } remove { EventHelper.RemoveListener(value, S1NPC.Health.onDie); } } public event Action OnInventoryChanged { add { EventHelper.AddListener(value, S1NPC.Inventory.onContentsChanged); } remove { EventHelper.RemoveListener(value, S1NPC.Inventory.onContentsChanged); } } protected NPC(string id, string? firstName, string? lastName, Sprite? icon = null) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Expected O, but got Unknown //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Expected O, but got Unknown //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Expected O, but got Unknown //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Expected O, but got Unknown //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Expected O, but got Unknown //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Expected O, but got Unknown //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Expected O, but got Unknown IsCustomNPC = true; gameObject = new GameObject(); gameObject.SetActive(false); S1NPC = gameObject.AddComponent<NPC>(); S1NPC.FirstName = firstName; S1NPC.LastName = lastName; S1NPC.ID = id; S1NPC.MugshotSprite = icon ?? ((App<ContactsApp>)(object)PlayerSingleton<ContactsApp>.Instance).AppIcon; S1NPC.BakedGUID = Guid.NewGuid().ToString(); S1NPC.ConversationCategories = new List<EConversationCategory>(); S1NPC.ConversationCategories.Add((EConversationCategory)0); S1NPC.CreateMessageConversation(); S1NPC.Health = gameObject.GetComponent<NPCHealth>(); S1NPC.Health.onDie = new UnityEvent(); S1NPC.Health.onKnockedOut = new UnityEvent(); S1NPC.Health.Invincible = true; S1NPC.Health.MaxHealth = 100f; GameObject val = new GameObject("NPCAwareness"); val.transform.SetParent(gameObject.transform); S1NPC.awareness = val.AddComponent<NPCAwareness>(); S1NPC.awareness.onExplosionHeard = new UnityEvent<NoiseEvent>(); S1NPC.awareness.onGunshotHeard = new UnityEvent<NoiseEvent>(); S1NPC.awareness.onHitByCar = new UnityEvent<LandVehicle>(); S1NPC.awareness.onNoticedDrugDealing = new UnityEvent<Player>(); S1NPC.awareness.onNoticedGeneralCrime = new UnityEvent<Player>(); S1NPC.awareness.onNoticedPettyCrime = new UnityEvent<Player>(); S1NPC.awareness.onNoticedPlayerViolatingCurfew = new UnityEvent<Player>(); S1NPC.awareness.onNoticedSuspiciousPlayer = new UnityEvent<Player>(); S1NPC.awareness.Listener = gameObject.AddComponent<Listener>(); GameObject val2 = new GameObject("NPCBehaviour"); val2.transform.SetParent(gameObject.transform); NPCBehaviour val3 = val2.AddComponent<NPCBehaviour>(); GameObject val4 = new GameObject("CowingBehaviour"); val4.transform.SetParent(val2.transform); CoweringBehaviour coweringBehaviour = val4.AddComponent<CoweringBehaviour>(); GameObject val5 = new GameObject("FleeBehaviour"); val5.transform.SetParent(val2.transform); FleeBehaviour fleeBehaviour = val5.AddComponent<FleeBehaviour>(); val3.CoweringBehaviour = coweringBehaviour; val3.FleeBehaviour = fleeBehaviour; S1NPC.behaviour = val3; GameObject val6 = new GameObject("NPCResponses"); val6.transform.SetParent(gameObject.transform); S1NPC.awareness.Responses = (NPCResponses)(object)val6.AddComponent<NPCResponses_Civilian>(); GameObject val7 = new GameObject("VisionCone"); val7.transform.SetParent(gameObject.transform); VisionCone val8 = val7.AddComponent<VisionCone>(); val8.StatesOfInterest.Add(new StateContainer { state = (EVisualState)4, RequiredNoticeTime = 0.1f }); S1NPC.awareness.VisionCone = val8; S1NPC.awareness.VisionCone.QuestionMarkPopup = gameObject.AddComponent<WorldspacePopup>(); S1NPC.intObj = gameObject.AddComponent<InteractableObject>(); S1NPC.RelationData = new NPCRelationData(); NPCInventory val9 = gameObject.AddComponent<NPCInventory>(); val9.PickpocketIntObj = gameObject.AddComponent<InteractableObject>(); S1NPC.Avatar = Singleton<MugshotGenerator>.Instance.MugshotRig; gameObject.SetActive(true); All.Add(this); } protected virtual void OnResponseLoaded(Response response) { } public void Revive() { S1NPC.Health.Revive(); } public void Damage(int amount) { if (amount > 0) { S1NPC.Health.TakeDamage((float)amount, true); } } public void Heal(int amount) { if (amount > 0) { float num = Mathf.Min((float)amount, S1NPC.Health.MaxHealth - S1NPC.Health.Health); S1NPC.Health.TakeDamage(0f - num, false); } } public void Kill() { S1NPC.Health.TakeDamage(S1NPC.Health.MaxHealth, true); } public void Unsettle(float duration) { _unsettleMethod.Invoke(S1NPC, new object[1] { duration }); } public void LerpScale(float scale, float lerpTime) { S1NPC.SetScale(scale, lerpTime); } public void Panic() { S1NPC.SetPanicked(); } public void StopPanicking() { _removePanicMethod.Invoke(S1NPC, new object[0]); } public void KnockOut() { S1NPC.Health.KnockOut(); } public void Goto(Vector3 position) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) S1NPC.Movement.SetDestination(position); } public void SendTextMessage(string message, Response[]? responses = null, float responseDelay = 1f, bool network = true) { S1NPC.SendTextMessage(message); S1NPC.MSGConversation.ClearResponses(false); if (responses != null && responses.Length != 0) { Responses.Clear(); List<Response> val = new List<Response>(); foreach (Response response in responses) { Responses.Add(response); val.Add(response.S1Response); } S1NPC.MSGConversation.ShowResponses(val, responseDelay, network); } } public static NPC? Get<T>() { return All.FirstOrDefault((NPC npc
Plugins/S1APILoader.BepInEx.dll
Decompiled 2 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using MelonLoader; using Microsoft.CodeAnalysis; using S1APILoader; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(global::S1APILoader.S1APILoader), "S1APILoader", "1.6.2", "KaBooMa", null)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("S1APILoader")] [assembly: AssemblyConfiguration("MonoBepInEx")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d9665e9bd95b76b033fb53d5c1698afa82fe53ac")] [assembly: AssemblyProduct("S1APILoader")] [assembly: AssemblyTitle("S1APILoader")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } namespace S1APILoader { public class S1APILoader : MelonPlugin { private const string BuildFolderName = "S1API"; public override void OnPreModsLoaded() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (directoryName == null) { throw new Exception("Failed to identify plugins folder."); } string path = Path.Combine(directoryName, "../Mods"); string text = (MelonUtils.IsGameIl2Cpp() ? "Il2Cpp" : "Mono"); string text2 = ((!MelonUtils.IsGameIl2Cpp()) ? "Il2Cpp" : "Mono"); MelonLogger.Msg("Loading S1API for " + text + "..."); string text3 = Path.Combine(path, "S1API." + text + ".MelonLoader.dll"); string text4 = Path.Combine(path, "S1API." + text2 + ".MelonLoader.dll"); string path2 = text3 + ".disabled"; if (File.Exists(path2)) { File.Move(text3 + ".disabled", text3); } if (File.Exists(text4)) { File.Move(text4, text4 + ".disabled"); } MelonLogger.Msg("Successfully loaded S1API for " + text + "!"); } } }
Plugins/S1APILoader.MelonLoader.dll
Decompiled 2 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using MelonLoader; using Microsoft.CodeAnalysis; using S1APILoader; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(global::S1APILoader.S1APILoader), "S1APILoader", "1.6.2", "KaBooMa", null)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("S1APILoader")] [assembly: AssemblyConfiguration("MonoMelon")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d9665e9bd95b76b033fb53d5c1698afa82fe53ac")] [assembly: AssemblyProduct("S1APILoader")] [assembly: AssemblyTitle("S1APILoader")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } namespace S1APILoader { public class S1APILoader : MelonPlugin { private const string BuildFolderName = "S1API"; public override void OnPreModsLoaded() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (directoryName == null) { throw new Exception("Failed to identify plugins folder."); } string path = Path.Combine(directoryName, "../Mods"); string text = (MelonUtils.IsGameIl2Cpp() ? "Il2Cpp" : "Mono"); string text2 = ((!MelonUtils.IsGameIl2Cpp()) ? "Il2Cpp" : "Mono"); MelonLogger.Msg("Loading S1API for " + text + "..."); string text3 = Path.Combine(path, "S1API." + text + ".MelonLoader.dll"); string text4 = Path.Combine(path, "S1API." + text2 + ".MelonLoader.dll"); string path2 = text3 + ".disabled"; if (File.Exists(path2)) { File.Move(text3 + ".disabled", text3); } if (File.Exists(text4)) { File.Move(text4, text4 + ".disabled"); } MelonLogger.Msg("Successfully loaded S1API for " + text + "!"); } } }