Decompiled source of ScarletMarket v1.0.0
ScarletMarket.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; 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 System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppSystem; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Gameplay; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.Scripting; using ProjectM.Shared; using ProjectM.Tiles; using ScarletCore; using ScarletCore.Data; using ScarletCore.Events; using ScarletCore.Services; using ScarletCore.Systems; using ScarletCore.Utils; using ScarletMarket.Models; using ScarletMarket.Services; using Stunlock.Core; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; using UnityEngine; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ScarletMarket")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Scarlet Template")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+948c741fe810609343c0160600b99238ba540f2f")] [assembly: AssemblyProduct("ScarletMarket")] [assembly: AssemblyTitle("ScarletMarket")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ScarletMarket { internal static class Constants { public const int COFFIN_HEIGHT = 223; public const float PLOT_RADIUS = 2f; public static readonly PrefabGUID NEUTRAL_FACTION = new PrefabGUID(-1430861195); public static readonly PrefabGUID BLOCK_SLOT_ITEM = new PrefabGUID(1488205677); public static readonly PrefabGUID SCT_PREFAB = new PrefabGUID(-1404311249); public static readonly PrefabGUID INTERACT_INSPECT = new PrefabGUID(222103866); public static readonly string CLOSED_TEXT = Plugin.Settings.Get<string>("ClosedText"); } internal static class GameData { public static NativeParallelHashMap<PrefabGUID, Entity> PrefabGuidToEntityMap => GameSystems.PrefabCollectionSystem._PrefabGuidToEntityMap; } internal static class SCTMessages { public const string Disabled = "3bf7e066-4e49-4ae4-b7a3-6703b7a15dc1"; public const string Enabled = "f0c8d1b2-3e4a-4c5b-8f6d-7e8f9a0b1c2d"; public const string Done = "54d48cbf-6817-42e5-a23f-354ca531c514"; public const string CannotDo = "45e3238f-36c1-427c-b21c-7d50cfbd77bc"; public const string CannotMove = "298b546b-1686-414b-a952-09836842bedc"; public const string ReadyToChange = "57b699b7-482c-4ad1-9ce3-867cd5cca3fb"; public const string AlreadyAssigned = "d5e62c6c-751f-4629-bfc5-459fd79ea41a"; public const string Private = "80e97474-e56f-4356-bc7d-698a807ac714"; public const string Free = "fc3179c1-3f18-4044-b207-c1c148fb1cd4"; public const string Open = "4ab8d098-2c0c-4719-bf0f-852522d2b424"; public const string Close = "9b97e97d-7d95-4900-af81-1f8457c25182"; } internal static class Ids { public const string Trader = "__ScarletMarket.Trader__"; public const string Stand = "__ScarletMarket.Stand__"; public const string Storage = "__ScarletMarket.Storage__"; public const string Coffin = "__ScarletMarket.Coffin__"; public const string Plot = "__ScarletMarket.Plot__"; public const string GhostTrader = "__ScarletMarket.GTrader__"; public const string GhostStand = "__ScarletMarket.GStand__"; public const string GhostStorage = "__ScarletMarket.GStorage__"; public const string GhostCoffin = "__ScarletMarket.GCoffin__"; public const string GhostPlot = "__ScarletMarket.GPlot__"; public const string Inspect = "__ScarletMarket.Inspect__"; } internal static class Spawnable { public static readonly PrefabGUID StandChest = new PrefabGUID(279811010); public static readonly PrefabGUID StorageChest = new PrefabGUID(-220201461); public static readonly PrefabGUID Coffin = new PrefabGUID(723455393); public static readonly PrefabGUID Trader = ((Plugin.Settings.Get<int>("TraderPrefab") == 0) ? new PrefabGUID(40217214) : new PrefabGUID(Plugin.Settings.Get<int>("TraderPrefab"))); public static readonly PrefabGUID DuelCircle = new PrefabGUID(-893175652); public static readonly PrefabGUID Inspect = new PrefabGUID(1727016613); } internal static class Buffs { public static readonly PrefabGUID Invulnerable = new PrefabGUID(-480024072); public static readonly PrefabGUID DisableAggro = new PrefabGUID(1934061152); public static readonly PrefabGUID Immaterial = new PrefabGUID(1360141727); public static readonly PrefabGUID Invisibility = new PrefabGUID(1880224358); public static readonly PrefabGUID ClosedVisualClue1 = new PrefabGUID(647429443); public static readonly PrefabGUID ClosedVisualClue2 = new PrefabGUID(-883762685); public static readonly PrefabGUID Ghost = new PrefabGUID(-259674366); } internal static class Animations { public static readonly Dictionary<PrefabGUID, float> All = new Dictionary<PrefabGUID, float> { { new PrefabGUID(-235311655), 10f }, { new PrefabGUID(579955887), 15f }, { new PrefabGUID(-124884505), 5f }, { new PrefabGUID(-2014797575), 4f }, { new PrefabGUID(-1006286854), 15f }, { new PrefabGUID(192984794), 15f }, { new PrefabGUID(-1060344019), 5f } }; public static KeyValuePair<PrefabGUID, float> GetRandomAnimation() { Random random = new Random(); int num = random.Next(All.Count); foreach (KeyValuePair<PrefabGUID, float> item in All) { if (num-- == 0) { return item; } } return default(KeyValuePair<PrefabGUID, float>); } public static void RemoveAnimations(Entity trader) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) foreach (PrefabGUID key in All.Keys) { if (BuffService.HasBuff(trader, key)) { BuffService.TryRemoveBuff(trader, key); } } } } internal static class TraderState { public static readonly PrefabGUID WaitingForItem = new PrefabGUID(1237316881); public static readonly PrefabGUID WaitingForCost = new PrefabGUID(1118893557); public static readonly PrefabGUID ReceivedCost = new PrefabGUID(363438545); public static readonly PrefabGUID Ready = new PrefabGUID(-301760618); public static bool IsValid(PrefabGUID state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) return state == WaitingForItem || state == WaitingForCost || state == ReceivedCost || state == Ready; } } internal static class IdHelper { public static string GetId(this Entity entity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (entity == Entity.Null || !ECSExtensions.Has<NameableInteractable>(entity)) { return null; } NameableInteractable val = ECSExtensions.Read<NameableInteractable>(entity); return ((FixedString64Bytes)(ref val.Name)).Value; } public static void SetId(this Entity entity, string id) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!(entity == Entity.Null)) { ECSExtensions.AddWith<NameableInteractable>(entity, (WithRefHandler<NameableInteractable>)delegate(ref NameableInteractable nameable) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) nameable.Name = new FixedString64Bytes(id); }); } } public static bool IdEquals(this Entity entity, string id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (entity == Entity.Null || !ECSExtensions.Has<NameableInteractable>(entity)) { return false; } NameableInteractable val = ECSExtensions.Read<NameableInteractable>(entity); return ((FixedString64Bytes)(ref val.Name)).Value == id; } } [BepInPlugin("ScarletMarket", "ScarletMarket", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private static Harmony _harmony; public static Harmony Harmony => _harmony; public static Plugin Instance { get; private set; } public static ManualLogSource LogInstance { get; private set; } public static Settings Settings { get; private set; } public static Database Database { get; private set; } public override void Load() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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 Instance = this; LogInstance = ((BasePlugin)this).Log; ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ScarletMarket"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } log.LogInfo(val); _harmony = new Harmony("ScarletMarket"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); Settings = new Settings("ScarletMarket", (BasePlugin)(object)Instance); Database = new Database("ScarletMarket"); PrefabService.Initialize(); LoadSettings(); CommandRegistry.RegisterAll(); if (GameSystems.Initialized) { TraderService.Initialize(); } else { EventManager.OnInitialize += OnInitialize; } } public static void OnInitialize(object _, InitializeEventArgs args) { TraderService.Initialize(); EventManager.OnInitialize -= OnInitialize; } public override bool Unload() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } CommandRegistry.UnregisterAssembly(); ActionScheduler.UnregisterAssembly(Assembly.GetExecutingAssembly()); return true; } public static void ReloadSettings() { Settings.Dispose(); LoadSettings(); } public static void LoadSettings() { Settings.Section("General").Add<string>("EmptyPlotName", "Empty Plot", "Default name for empty trader plots.\nThis will be used when a player has not set a custom name for their shop.").Add<bool>("AllowCustomShopNames", true, "Allow players to set custom shop names.\nIf disabled, shops will use the default name based on the trader's name.") .Add<string>("ClosedText", "Closed", "Text to append when a trader shop is closed.\nThis text will be added to the end of the shop name when it is not ready for trading."); Settings.Section("Trader").Add<int>("TraderPrefab", 40217214, "Trader prefab GUID. \nIMPORTANT: Only use characters whose prefab name ends with _Servant (e.g., CHAR_Bandit_Bomber_Servant). Using any other will revert to the default trader prefab."); if (Settings.Get<int>("TraderPrefab") == 0 || !PrefabService.IsValidServant(Settings.Get<int>("TraderPrefab"))) { Settings.Set<int>("TraderPrefab", 40217214); LogInstance.LogError((object)"Trader prefab GUID is invalid or not a servant! Reverting to default."); } Settings.Section("Plot Purchase").Add<int>("PrefabGUID", 0, "Item GUID required to claim a plot. Set to 0 to make plots free.\nUse item GUIDs from the game or community databases.").Add<int>("Amount", 0, "Number of items required to claim a plot.\nIf set to 0, plots can be claimed without any cost."); Settings.Section("Trader Timeout").Add<bool>("TraderTimeoutEnabled", false, "Enable/disable the trader timeout system entirely.\nWhen disabled, trader shops will never be automatically removed.").Add<int>("MaxInactiveDays", 15, "Maximum days a player can be offline before their trader shop is automatically removed.\nWarning: All items in the shop and storage will be permanently lost!") .Add<bool>("RemoveEmptyTradersOnStartup", true, "Clean up empty trader shops when the server starts.\nOnly removes shops with no items in both display and storage areas."); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "ScarletMarket"; public const string PLUGIN_NAME = "ScarletMarket"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ScarletMarket.Services { internal static class ItemSearchService { public static List<ItemSearchResult> SearchAllByName(string searchTerm, int maxResults = 20) { return SearchByNameInternal(PrefabService.AllItemPrefabNames, searchTerm, maxResults); } public static List<ItemSearchResult> SearchByName(string searchTerm, int maxResults = 20) { return SearchByNameInternal(PrefabService.ItemPrefabNames, searchTerm, maxResults); } private static List<ItemSearchResult> SearchByNameInternal(Dictionary<int, string> itemDictionary, string searchTerm, int maxResults = 20) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(searchTerm)) { return new List<ItemSearchResult>(); } List<ItemSearchResult> list = new List<ItemSearchResult>(); HashSet<string> hashSet = new HashSet<string>(); string searchTermLower = searchTerm.ToLowerInvariant().Replace("'", ""); string searchTermNoSpaces = searchTermLower.Replace(" ", ""); foreach (KeyValuePair<int, string> item in itemDictionary) { string value = item.Value; if (ItemMatches(value, searchTermLower, searchTermNoSpaces) && !hashSet.Contains(item.Value)) { hashSet.Add(item.Value); list.Add(new ItemSearchResult { PrefabGUID = new PrefabGUID(item.Key), Name = value, PrefabId = item.Key }); if (list.Count >= maxResults) { break; } } } List<ItemSearchResult> list2 = new List<ItemSearchResult>(); list2.AddRange(list.OrderBy(delegate(ItemSearchResult r) { string text = r.Name.ToLowerInvariant(); string text2 = text.Replace(" ", ""); return (!text.StartsWith(searchTermLower) && !text2.StartsWith(searchTermNoSpaces)) ? 1 : 0; }).ThenBy((ItemSearchResult r) => r.Name.Length).ThenBy((ItemSearchResult r) => r.Name)); return list2; } private static bool ItemMatches(string itemName, string searchTermLower, string searchTermNoSpaces) { (string Name, string Category, string Tier) tuple = ParseItemName(itemName); string item = tuple.Name; string item2 = tuple.Category; string item3 = tuple.Tier; string text = Regex.Replace(itemName, "\\s*\\([^)]*\\)", ""); string text2 = text.ToLowerInvariant().Replace(" ", "").Replace("'", ""); if (text2.Contains(searchTermLower)) { return true; } List<string> list = GenerateSearchVariations(item, item2, item3); foreach (string item4 in list) { if (DoesVariationMatch(item4, searchTermNoSpaces)) { return true; } } return false; } private static bool DoesVariationMatch(string variation, string searchTerm) { if (variation.Equals(searchTerm, StringComparison.OrdinalIgnoreCase)) { return true; } if (searchTerm.StartsWith("t") && searchTerm.Length <= 3) { return false; } return variation.Contains(searchTerm); } private static (string Name, string Category, string Tier) ParseItemName(string itemName) { string item = itemName; string item2 = ""; string item3 = ""; Match match = Regex.Match(itemName, "^(.+?)\\s*\\(([^)]+)\\)$"); if (match.Success) { item = match.Groups[1].Value.Trim(); string text = match.Groups[2].Value.Trim(); Match match2 = Regex.Match(text, "T(\\d{1,2})"); if (match2.Success) { item3 = match2.Groups[1].Value; item2 = Regex.Replace(text, "\\s*T\\d{1,2}\\s*", "").Trim(); } else { item2 = text; } } return (item, item2, item3); } private static List<string> GenerateSearchVariations(string name, string category, string tier) { List<string> list = new List<string>(); string text = name.ToLowerInvariant().Replace(" ", "").Replace("'", ""); string text2 = category.ToLowerInvariant().Replace(" ", "").Replace("'", ""); if (!string.IsNullOrEmpty(category)) { list.Add(text + text2); } if (!string.IsNullOrEmpty(tier)) { int num = int.Parse(tier); list.Add(text + "t" + num); list.Add(text + "t" + num.ToString("D2")); list.Add("t" + num); list.Add("t" + num.ToString("D2")); } if (!string.IsNullOrEmpty(category) && !string.IsNullOrEmpty(tier)) { int num2 = int.Parse(tier); list.Add(text + text2 + "t" + num2); list.Add(text + text2 + "t" + num2.ToString("D2")); } return list; } public static ItemSearchResult FindAllByExactName(string exactName) { return FindByExactNameInternal(PrefabService.AllItemPrefabNames, exactName); } public static ItemSearchResult FindByExactName(string exactName) { return FindByExactNameInternal(PrefabService.ItemPrefabNames, exactName); } private static ItemSearchResult FindByExactNameInternal(Dictionary<int, string> itemDictionary, string exactName) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(exactName)) { return default(ItemSearchResult); } string text = exactName.ToLowerInvariant().Replace("'", ""); string text2 = text.Replace(" ", ""); foreach (KeyValuePair<int, string> item in itemDictionary) { string value = item.Value; string text3 = value.ToLowerInvariant().Replace("(", "").Replace(")", "") .Replace(" ", "") .Replace("'", ""); if (text3.Equals(text2, StringComparison.OrdinalIgnoreCase)) { ItemSearchResult result = default(ItemSearchResult); result.PrefabGUID = new PrefabGUID(item.Key); result.Name = value; result.PrefabId = item.Key; return result; } if (ItemMatchesExact(value, text2)) { ItemSearchResult result = default(ItemSearchResult); result.PrefabGUID = new PrefabGUID(item.Key); result.Name = value; result.PrefabId = item.Key; return result; } } return default(ItemSearchResult); } private static bool ItemMatchesExact(string itemName, string exactNameNoSpaces) { (string Name, string Category, string Tier) tuple = ParseItemName(itemName); string item = tuple.Name; string item2 = tuple.Category; string item3 = tuple.Tier; List<string> list = GenerateSearchVariations(item, item2, item3); foreach (string item4 in list) { if (item4.Equals(exactNameNoSpaces, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } public static ItemSearchResult? FindAllByPrefabGUID(PrefabGUID prefabGUID) { return FindAllByPrefabId(((PrefabGUID)(ref prefabGUID)).GuidHash); } public static ItemSearchResult? FindAllByPrefabId(int prefabId) { return FindByPrefabIdInternal(PrefabService.AllItemPrefabNames, prefabId); } public static ItemSearchResult? FindByPrefabGUID(PrefabGUID prefabGUID) { return FindByPrefabId(((PrefabGUID)(ref prefabGUID)).GuidHash); } public static ItemSearchResult? FindByPrefabId(int prefabId) { return FindByPrefabIdInternal(PrefabService.ItemPrefabNames, prefabId); } private static ItemSearchResult? FindByPrefabIdInternal(Dictionary<int, string> itemDictionary, int prefabId) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (itemDictionary.TryGetValue(prefabId, out var value)) { ItemSearchResult value2 = default(ItemSearchResult); value2.PrefabGUID = new PrefabGUID(prefabId); value2.Name = value; value2.PrefabId = prefabId; return value2; } return null; } public static List<ItemSearchResult> GetAllItems() { return GetItemsInternal(PrefabService.AllItemPrefabNames); } public static List<ItemSearchResult> GetCurrencyItems() { return GetItemsInternal(PrefabService.ItemPrefabNames); } private static List<ItemSearchResult> GetItemsInternal(Dictionary<int, string> itemDictionary) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) List<ItemSearchResult> list = new List<ItemSearchResult>(); foreach (KeyValuePair<int, string> item in itemDictionary) { list.Add(new ItemSearchResult { PrefabGUID = new PrefabGUID(item.Key), Name = item.Value, PrefabId = item.Key }); } return list.OrderBy((ItemSearchResult r) => r.Name).ToList(); } } public struct ItemSearchResult { public PrefabGUID PrefabGUID { get; set; } public string Name { get; set; } public int PrefabId { get; set; } public override string ToString() { return $"{Name} (ID: {PrefabId})"; } } internal static class PrefabService { public static string FileName = "ItemPrefabNames"; public static Dictionary<int, string> AllItemPrefabNames { get; private set; } = new Dictionary<int, string>(); public static Dictionary<int, string> ItemPrefabNames { get; private set; } = new Dictionary<int, string>(); public static List<int> ServantPrefabs { get; private set; } = new List<int>(); public static void Initialize() { LoadAllItemPrefabNames(); LoadItemPrefabNames(); } public static void LoadServantPrefabs() { string resourceName = "ScarletMarket.Localization.ServantPrefabs.json"; string json = LoadResource(resourceName); ServantPrefabs = JsonSerializer.Deserialize<List<int>>(json); } public static void LoadAllItemPrefabNames() { string resourceName = "ScarletMarket.Localization.ItemPrefabNames.json"; string json = LoadResource(resourceName); AllItemPrefabNames = JsonSerializer.Deserialize<Dictionary<int, string>>(json); } public static void LoadItemPrefabNames() { if (Plugin.Database.Has(FileName)) { ItemPrefabNames = Plugin.Database.Get<Dictionary<int, string>>(FileName); return; } string resourceName = "ScarletMarket.Localization.ItemPrefabNames.json"; string json = LoadResource(resourceName); ItemPrefabNames = JsonSerializer.Deserialize<Dictionary<int, string>>(json); Plugin.Database.Save<Dictionary<int, string>>(FileName, ItemPrefabNames); } public static string LoadResource(string resourceName) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(resourceName); string result = null; if (manifestResourceStream != null) { using StreamReader streamReader = new StreamReader(manifestResourceStream); result = streamReader.ReadToEnd(); } else { Log.Error((object)$"Resource '{resourceName}' not found in assembly '{executingAssembly.FullName}'"); } return result; } public static string GetItem(int prefabId) { if (ItemPrefabNames.TryGetValue(prefabId, out var value)) { return value; } return $"Unknown Prefab {prefabId}"; } public static string GetItem(PrefabGUID prefabId) { return GetItem(((PrefabGUID)(ref prefabId)).GuidHash); } public static string GetAllItem(int prefabId) { if (AllItemPrefabNames.TryGetValue(prefabId, out var value)) { return value; } return $"Unknown Prefab {prefabId}"; } public static string GetAllItem(PrefabGUID prefabId) { return GetAllItem(((PrefabGUID)(ref prefabId)).GuidHash); } public static bool IsValidServant(PrefabGUID prefabGUID) { return IsValidServant(((PrefabGUID)(ref prefabGUID)).GuidHash); } public static bool IsValidServant(int prefabGUID) { if (ServantPrefabs.Count == 0) { LoadServantPrefabs(); } return ServantPrefabs.Contains(prefabGUID); } } internal static class TraderService { public static readonly Dictionary<Entity, TraderModel> TraderEntities = new Dictionary<Entity, TraderModel>(); public static readonly Dictionary<Entity, TraderModel> StorageEntities = new Dictionary<Entity, TraderModel>(); public static readonly Dictionary<Entity, TraderModel> StandEntities = new Dictionary<Entity, TraderModel>(); public static readonly Dictionary<ulong, TraderModel> TraderById = new Dictionary<ulong, TraderModel>(); public static readonly List<PlotModel> Plots = new List<PlotModel>(); private static Entity _defaultStandEntity; public static ActionId RunningAnimationCheck { get; private set; } private static Settings Settings => Plugin.Settings; public static Entity DefaultStandEntity { get { //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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) //IL_001a: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (_defaultStandEntity == Entity.Null) { Entity defaultStandEntity = default(Entity); if (!GameData.PrefabGuidToEntityMap.TryGetValue(Spawnable.StandChest, ref defaultStandEntity)) { DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(32, 1); defaultInterpolatedStringHandler.AppendLiteral("Failed to find prefab for GUID: "); PrefabGUID standChest = Spawnable.StandChest; defaultInterpolatedStringHandler.AppendFormatted(((PrefabGUID)(ref standChest)).GuidHash); Log.Error((object)defaultInterpolatedStringHandler.ToStringAndClear()); return Entity.Null; } _defaultStandEntity = defaultStandEntity; } return _defaultStandEntity; } } public static void Initialize() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) RegisterOnLoad(); RemoveInactiveTraders(); ActionScheduler.Repeating((Action)SetRandomAnimation, 20f, -1); } public static void SetRandomAnimation() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) foreach (TraderModel value in TraderEntities.Values) { if (ECSExtensions.Exists(value.Trader) && Random.Range(0, 3) == 0) { KeyValuePair<PrefabGUID, float> randomAnimation = Animations.GetRandomAnimation(); Animations.RemoveAnimations(value.Trader); BuffService.TryApplyBuff(value.Trader, randomAnimation.Key, randomAnimation.Value); } } } public static void RemoveInactiveTraders() { if (!Plugin.Settings.Get<bool>("TraderTimeoutEnabled")) { Log.Info((object)"Trader timeout is disabled, skipping removal of inactive traders."); return; } if (Plugin.Settings.Get<bool>("RemoveEmptyTradersOnStartup")) { int num = ClearEmptyTraders(); if (num > 0) { Log.Info((object)$"Removed {num} empty traders."); } } foreach (TraderModel value in TraderEntities.Values) { PlayerData owner = value.Owner; DateTime connectedSince = owner.ConnectedSince; int num2 = Settings.Get<int>("MaxInactiveDays"); if (connectedSince < DateTime.Now.AddDays(-num2)) { ForceRemoveTrader(owner); Log.Info((object)$"Removed inactive trader {owner.Name} ({owner.PlatformId}) due to inactivity."); } } } public static void TryBuyPlot(PlayerData player) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (TraderById.ContainsKey(player.PlatformId)) { MessageService.Send(player, RichTextFormatter.FormatError("You already have a shop!")); return; } if (!TryGetPlot(player.Position, out var plot)) { MessageService.Send(player, RichTextFormatter.FormatError("You need to be inside a plot to create a shop.")); return; } PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(Settings.Get<int>("PrefabGUID")); int num = Settings.Get<int>("Amount"); if (((PrefabGUID)(ref val)).GuidHash != 0 && num > 0 && !InventoryService.HasAmount(player.CharacterEntity, val, num)) { MessageService.Send(player, RichTextFormatter.FormatError("You don't have enough ~" + ItemSearchService.FindAllByPrefabGUID(val).Value.Name + "~ to claim this plot.")); } else { CreateTrader(player, plot); } } public static void CreateTrader(PlayerData player, PlotModel plot) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (!IsPlotEmpty(plot)) { MessageService.Send(player, RichTextFormatter.FormatError("This plot already has a shop!")); return; } TraderModel traderModel2 = (plot.Trader = new TraderModel(player, plot)); traderModel2.AlignToPlotRotation(); plot.Hide(); TraderEntities[traderModel2.Stand] = traderModel2; StorageEntities[traderModel2.StorageChest] = traderModel2; StandEntities[traderModel2.Trader] = traderModel2; TraderById[player.PlatformId] = traderModel2; MessageService.Send(player, RichTextFormatter.FormatSuccess("~Your shop has been created!~ You can now add items to sell.")); } public static bool TryCreatePlot(PlayerData player, bool force, out PlotModel plot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (TryGetPlot(player.Position, out plot)) { if (force) { MessageService.Send(player, RichTextFormatter.FormatError("~Cannot force plot:~ would block access to an existing one.")); } else { MessageService.Send(player, RichTextFormatter.FormatError("There's already a plot here!")); } return false; } if (!force && WillOverlapWithExistingPlot(player.Position)) { MessageService.Send(player, RichTextFormatter.FormatError("Can't create a plot here - it would overlap with an existing one!")); return false; } plot = new PlotModel(player.Position); Plots.Add(plot); return true; } public static bool TryRemoveTrader(PlayerData player) { if (!TraderById.TryGetValue(player.PlatformId, out var value)) { MessageService.Send(player, RichTextFormatter.FormatError("You don't have a shop to remove.")); return false; } if (value.IsEmpty()) { ForceRemoveTrader(player); return true; } MessageService.Send(player, RichTextFormatter.FormatError("Empty your ~shop~ and ~storage~ first before removing it.")); return false; } public static void ForceRemoveTrader(PlayerData player) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) if (!TraderById.TryGetValue(player.PlatformId, out var value)) { MessageService.Send(player, RichTextFormatter.FormatError("You don't have a shop to remove.")); return; } value.Plot.Show(); value.Plot.Trader = null; TraderEntities.Remove(value.Stand); StorageEntities.Remove(value.StorageChest); StandEntities.Remove(value.Trader); TraderById.Remove(player.PlatformId); value.Destroy(); MessageService.Send(player, RichTextFormatter.FormatSuccess("Your shop has been removed.")); } public static bool TryRemovePlot(PlotModel plot) { if (plot.Trader != null) { Log.Error((object)"Cannot remove plot while it has an associated trader."); return false; } ForceRemovePlot(plot); return true; } public static void ForceRemovePlot(PlotModel plot) { if (TryGetTraderInPlot(plot, out var trader)) { ForceRemoveTrader(trader.Owner); } plot.Destroy(); Plots.Remove(plot); } public static bool IsPlotEmpty(PlotModel plot) { TraderModel trader; return !TryGetTraderInPlot(plot, out trader); } public static TraderModel GetTrader(ulong platformId) { if (TraderById.TryGetValue(platformId, out var value)) { return value; } return null; } public static TraderModel GetTrader(Entity entity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (TraderEntities.TryGetValue(entity, out var value)) { return value; } if (StorageEntities.TryGetValue(entity, out value)) { return value; } if (StandEntities.TryGetValue(entity, out value)) { return value; } return null; } public static bool TryGetPlot(float3 position, out PlotModel plot, PlotModel exclude = null) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) plot = null; foreach (PlotModel plot2 in Plots) { if ((exclude == null || plot2 != exclude) && plot2.IsInside(position)) { plot = plot2; return true; } } return false; } public static bool TryGetTraderInPlot(PlotModel plot, out TraderModel trader) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) trader = null; foreach (TraderModel value in TraderEntities.Values) { if (plot.IsInside(value.Position)) { trader = value; return true; } } return false; } public static bool WillOverlapWithExistingPlot(float3 position, PlotModel excludePlot = null) { //IL_0029: 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) foreach (PlotModel plot in Plots) { if ((excludePlot == null || plot != excludePlot) && math.distance(plot.Position, position) < 4f) { return true; } } return false; } public static void RegisterOnLoad() { RegisterOnLoadEntities(); BindPlotsToTraders(); } public static void RegisterOnLoadEntities() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0092: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_015a: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = default(EntityQueryBuilder); ((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2)); ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly<NameableInteractable>()); ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); EntityManager entityManager = GameSystems.EntityManager; EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val); NativeArray<Entity> val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Dictionary<PlayerData, Entity> dictionary = new Dictionary<PlayerData, Entity>(); Dictionary<PlayerData, Entity> dictionary2 = new Dictionary<PlayerData, Entity>(); Dictionary<PlayerData, Entity> dictionary3 = new Dictionary<PlayerData, Entity>(); Dictionary<PlayerData, Entity> dictionary4 = new Dictionary<PlayerData, Entity>(); Dictionary<Entity, Entity> dictionary5 = new Dictionary<Entity, Entity>(); Dictionary<Entity, Entity> dictionary6 = new Dictionary<Entity, Entity>(); Dictionary<Entity, Entity> dictionary7 = new Dictionary<Entity, Entity>(); Dictionary<Entity, Entity> dictionary8 = new Dictionary<Entity, Entity>(); Dictionary<Entity, Entity> dictionary9 = new Dictionary<Entity, Entity>(); Enumerator<Entity> enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!ECSExtensions.Has<NameableInteractable>(current)) { continue; } if (current.IdEquals("__ScarletMarket.Plot__")) { dictionary5[current] = current; } else { if (!ECSExtensions.Has<Follower>(current)) { continue; } Entity value = ECSExtensions.Read<Follower>(current).Followed._Value; if (current.IdEquals("__ScarletMarket.Inspect__")) { dictionary6[value] = current; continue; } if (current.IdEquals("__ScarletMarket.GStorage__")) { dictionary7[value] = current; continue; } if (current.IdEquals("__ScarletMarket.GTrader__")) { dictionary8[value] = current; continue; } if (current.IdEquals("__ScarletMarket.GCoffin__")) { dictionary9[value] = current; continue; } PlayerData playerData = PlayerDataExtensions.GetPlayerData(value); if (playerData != null) { if (current.IdEquals("__ScarletMarket.Trader__")) { dictionary[playerData] = current; } else if (current.IdEquals("__ScarletMarket.Storage__")) { dictionary2[playerData] = current; } else if (current.IdEquals("__ScarletMarket.Stand__")) { dictionary3[playerData] = current; } else if (current.IdEquals("__ScarletMarket.Coffin__")) { dictionary4[playerData] = current; } } } } RegisterPlotsFromEntities(dictionary5, dictionary6); RegisterTradersFromEntities(dictionary, dictionary2, dictionary3, dictionary4); RegisterGhostsFromEntities(dictionary7, dictionary8, dictionary9); } private static void RegisterPlotsFromEntities(Dictionary<Entity, Entity> plots, Dictionary<Entity, Entity> inspects) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) foreach (Entity key in plots.Keys) { Entity inspectEntity = inspects[key]; PlotModel item = new PlotModel(key, inspectEntity); Plots.Add(item); } } private static void RegisterTradersFromEntities(Dictionary<PlayerData, Entity> traders, Dictionary<PlayerData, Entity> storages, Dictionary<PlayerData, Entity> stands, Dictionary<PlayerData, Entity> coffins) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<PlayerData, Entity> trader in traders) { PlayerData key = trader.Key; Entity value = trader.Value; if (storages.TryGetValue(key, out var value2) && stands.TryGetValue(key, out var value3) && coffins.TryGetValue(key, out var value4)) { TraderModel value5 = new TraderModel(key, value2, value3, value, value4); TraderEntities[value3] = value5; StorageEntities[value2] = value5; StandEntities[value] = value5; TraderById[key.PlatformId] = value5; } } } private static void RegisterGhostsFromEntities(Dictionary<Entity, Entity> ghostStorages, Dictionary<Entity, Entity> ghostTraders, Dictionary<Entity, Entity> ghostCoffins) { //IL_001a: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) foreach (PlotModel plot in Plots) { if (!ghostStorages.TryGetValue(plot.Entity, out var value) || !ghostTraders.TryGetValue(plot.Entity, out var value2) || !ghostCoffins.TryGetValue(plot.Entity, out var value3)) { PlotModel plotModel = plot; if (plotModel.GhostPlaceholder == null) { GhostTraderModel ghostTraderModel2 = (plotModel.GhostPlaceholder = new GhostTraderModel(plot)); } } else { GhostTraderModel ghostPlaceholder = new GhostTraderModel(plot, value, value2, value3); plot.GhostPlaceholder = ghostPlaceholder; } } } public static void BindPlotsToTraders() { foreach (PlotModel plot in Plots) { if (!TryGetTraderInPlot(plot, out var trader)) { Log.Info((object)"No trader found in plot, showing plot instead."); plot.Show(); continue; } trader.Plot = plot; plot.Trader = trader; trader.RespawnTrader(); trader.AlignToPlotRotation(); plot.Hide(); } } public static int ClearEmptyTraders() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (TraderModel value in TraderEntities.Values) { if (value.IsEmpty()) { TraderEntities.Remove(value.Stand); StorageEntities.Remove(value.StorageChest); StandEntities.Remove(value.Trader); TraderById.Remove(value.Owner.PlatformId); value.Plot.Show(); value.Destroy(); num++; } } return num; } public static int ClearEmptyPlots() { int num = 0; for (int num2 = Plots.Count - 1; num2 >= 0; num2--) { PlotModel plotModel = Plots[num2]; if (IsPlotEmpty(plotModel)) { plotModel.Destroy(); Plots.RemoveAt(num2); num++; } } return num; } public static void ClearAll() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_008c: 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_009a: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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) EntityQueryBuilder val = default(EntityQueryBuilder); ((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2)); ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly<NameableInteractable>()); ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); EntityManager entityManager = GameSystems.EntityManager; EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val); Enumerator<Entity> enumerator = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (ECSExtensions.Has<NameableInteractable>(current) && (current.IdEquals("__ScarletMarket.Trader__") || current.IdEquals("__ScarletMarket.Storage__") || current.IdEquals("__ScarletMarket.Coffin__") || current.IdEquals("__ScarletMarket.Stand__") || current.IdEquals("__ScarletMarket.Inspect__") || current.IdEquals("__ScarletMarket.Plot__") || current.IdEquals("__ScarletMarket.GTrader__") || current.IdEquals("__ScarletMarket.GStorage__") || current.IdEquals("__ScarletMarket.GCoffin__"))) { ECSExtensions.Destroy(current, false); } } TraderEntities.Clear(); StorageEntities.Clear(); StandEntities.Clear(); TraderById.Clear(); Plots.Clear(); } public static void SendSucessSCT(PlayerData player, string message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) ScrollingCombatTextMessage.Create(GameSystems.EntityManager, ((EntityCommandBufferSystem)GameSystems.EndSimulationEntityCommandBufferSystem).CreateCommandBuffer(), AssetGuid.FromString(message), player.Position, new float3(1f, 0f, 0f), player.CharacterEntity, 0f, Constants.SCT_PREFAB, player.UserEntity); } public static void SendErrorSCT(PlayerData player, string message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) ScrollingCombatTextMessage.Create(GameSystems.EntityManager, ((EntityCommandBufferSystem)GameSystems.EndSimulationEntityCommandBufferSystem).CreateCommandBuffer(), AssetGuid.FromString(message), player.Position, new float3(1f, 0f, 0f), player.CharacterEntity, 0f, Constants.SCT_PREFAB, player.UserEntity); } } } namespace ScarletMarket.Patches { [HarmonyPatch(typeof(InteractValidateAndStopSystemServer), "OnUpdate")] internal static class InteractPatch { [HarmonyPrefix] public static void Prefix(InteractValidateAndStopSystemServer __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_008b: 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_0095: 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) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00ba: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) EntityQuery _query_195794971_ = __instance.__query_195794971_3; Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_195794971_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (ECSExtensions.GetPrefabGuid(current) != Constants.INTERACT_INSPECT) { continue; } Entity owner = ECSExtensions.Read<EntityOwner>(current).Owner; if (ECSExtensions.IsNull(owner) || !ECSExtensions.Has<PlayerCharacter>(owner)) { continue; } PlayerData playerData = PlayerDataExtensions.GetPlayerData(owner); if (playerData == null) { continue; } Entity target = ECSExtensions.Read<Interactor>(owner).Target; if (ECSExtensions.Has<Follower>(target)) { Entity value = ECSExtensions.Read<Follower>(target).Followed._Value; if (!ECSExtensions.IsNull(value) && ECSExtensions.Exists(value) && value.IdEquals("__ScarletMarket.Plot__")) { TraderService.TryBuyPlot(playerData); } } } } } [HarmonyPatch] internal static class InventoryPatches { [HarmonyPatch(typeof(MoveItemBetweenInventoriesSystem), "OnUpdate")] [HarmonyPrefix] public static void Prefix(MoveItemBetweenInventoriesSystem __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery _query_133601321_ = __instance.__query_133601321_0; NativeArray<Entity> val = ((EntityQuery)(ref _query_133601321_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); Entity val3 = default(Entity); Entity val4 = default(Entity); InventoryBuffer val6 = default(InventoryBuffer); while (enumerator.MoveNext()) { Entity current = enumerator.Current; MoveItemBetweenInventoriesEvent val2 = ECSExtensions.Read<MoveItemBetweenInventoriesEvent>(current); NativeParallelHashMap<NetworkId, Entity> networkIdToEntityMap = GameSystems.NetworkIdSystem._NetworkIdLookupMap._NetworkIdToEntityMap; if (!networkIdToEntityMap.TryGetValue(val2.ToInventory, ref val3) || !networkIdToEntityMap.TryGetValue(val2.FromInventory, ref val4)) { continue; } bool flag = val3.IdEquals("__ScarletMarket.Stand__"); bool flag2 = val3.IdEquals("__ScarletMarket.Storage__"); bool flag3 = val4.IdEquals("__ScarletMarket.Stand__"); bool flag4 = val4.IdEquals("__ScarletMarket.Storage__"); if (!flag3 && !flag && !flag2 && !flag4) { continue; } FromCharacter val5 = ECSExtensions.Read<FromCharacter>(current); if (!ECSExtensions.Has<PlayerCharacter>(val5.Character) || !ECSExtensions.Has<User>(val5.User)) { continue; } PlayerData playerData = PlayerDataExtensions.GetPlayerData(val5.Character); if (flag4 && ECSExtensions.Read<Follower>(val4).Followed._Value == playerData.UserEntity) { continue; } if (val3 == val4) { TraderService.SendErrorSCT(playerData, "298b546b-1686-414b-a952-09836842bedc"); ECSExtensions.Destroy(current, true); continue; } TraderModel traderModel = TraderService.GetTrader(val4) ?? TraderService.GetTrader(val3); if (traderModel == null) { continue; } bool flag5 = traderModel.Owner == playerData; bool flag6 = val4 != val3 && flag3; bool flag7 = flag; if (!flag5 && flag6 && TraderModel.IsValidSlot(val2.FromSlot)) { if (!traderModel.TryBuyItem(playerData, val2.FromSlot)) { Log.Info((object)("Player " + playerData.Name + " tried to remove an item from a trader they do not own.")); TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); ECSExtensions.Destroy(current, true); } continue; } bool flag8 = traderModel.State == TraderState.WaitingForItem || traderModel.State == TraderState.ReceivedCost; if (flag5 && flag7 && flag8 && InventoryService.TryGetItemAtSlot(val4, val2.FromSlot, ref val6)) { if (val2.ToSlot != -1 && !TraderModel.IsValidSlot(val2.ToSlot)) { ECSExtensions.Destroy(current, true); TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); } else { traderModel.HandleAddingItem(); } } else if (flag5 && flag6 && TraderModel.IsValidSlot(val2.FromSlot)) { traderModel.RemoveCostItem(val2.FromSlot + 7); } else { if (flag5 && flag7 && traderModel.State == TraderState.Ready) { traderModel.SendErrorSCT("3bf7e066-4e49-4ae4-b7a3-6703b7a15dc1"); } ECSExtensions.Destroy(current, true); } } } catch (Exception ex) { Log.Error((object)("Error in MoveItemBetweenInventoriesSystemPatch: " + ex.Message)); } finally { val.Dispose(); } } [HarmonyPatch(typeof(DropInventoryItemSystem), "OnUpdate")] [HarmonyPrefix] public static void Prefix(DropInventoryItemSystem __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00d4: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery _query_1470978904_ = __instance.__query_1470978904_0; NativeArray<Entity> val = ((EntityQuery)(ref _query_1470978904_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); Entity val3 = default(Entity); while (enumerator.MoveNext()) { Entity current = enumerator.Current; DropInventoryItemEvent val2 = ECSExtensions.Read<DropInventoryItemEvent>(current); NativeParallelHashMap<NetworkId, Entity> networkIdToEntityMap = GameSystems.NetworkIdSystem._NetworkIdLookupMap._NetworkIdToEntityMap; if (!networkIdToEntityMap.TryGetValue(val2.Inventory, ref val3) || (!val3.IdEquals("__ScarletMarket.Stand__") && !val3.IdEquals("__ScarletMarket.Storage__"))) { continue; } FromCharacter val4 = ECSExtensions.Read<FromCharacter>(current); if (ECSExtensions.Has<PlayerCharacter>(val4.Character) && ECSExtensions.Has<User>(val4.User)) { PlayerData playerData = PlayerDataExtensions.GetPlayerData(val4.Character); if (!val3.IdEquals("__ScarletMarket.Storage__") || !(ECSExtensions.Read<Follower>(val3).Followed._Value == playerData.UserEntity)) { TraderService.SendErrorSCT(playerData, "298b546b-1686-414b-a952-09836842bedc"); ECSExtensions.Destroy(current, true); } } } } catch (Exception ex) { Log.Error((object)("Error in DropInventoryItemSystemPatch: " + ex.Message)); } finally { val.Dispose(); } } [HarmonyPatch(typeof(SortSingleInventorySystem), "OnUpdate")] [HarmonyPrefix] public static void Prefix(SortSingleInventorySystem __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00d4: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery eventQuery = __instance._EventQuery; NativeArray<Entity> val = ((EntityQuery)(ref eventQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); Entity entity = default(Entity); while (enumerator.MoveNext()) { Entity current = enumerator.Current; SortSingleInventoryEvent val2 = ECSExtensions.Read<SortSingleInventoryEvent>(current); NativeParallelHashMap<NetworkId, Entity> networkIdToEntityMap = GameSystems.NetworkIdSystem._NetworkIdLookupMap._NetworkIdToEntityMap; if (!networkIdToEntityMap.TryGetValue(val2.Inventory, ref entity) || (!entity.IdEquals("__ScarletMarket.Storage__") && !entity.IdEquals("__ScarletMarket.Stand__"))) { continue; } FromCharacter val3 = ECSExtensions.Read<FromCharacter>(current); if (ECSExtensions.Has<PlayerCharacter>(val3.Character) && ECSExtensions.Has<User>(val3.User)) { PlayerData playerData = PlayerDataExtensions.GetPlayerData(val3.Character); TraderModel trader = TraderService.GetTrader(entity); if (trader.Owner == playerData) { trader?.SetAsNotReady(); } else { TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); } ECSExtensions.Destroy(current, true); } } } catch (Exception ex) { Log.Error((object)("Error in SortSingleInventorySystemPatch: " + ex.Message)); } finally { val.Dispose(); } } [HarmonyPatch(typeof(SortAllInventoriesSystem), "OnUpdate")] [HarmonyPrefix] public static void Prefix(SortAllInventoriesSystem __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery _query_133601798_ = __instance.__query_133601798_0; NativeArray<Entity> val = ((EntityQuery)(ref _query_133601798_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); Entity entity = default(Entity); while (enumerator.MoveNext()) { Entity current = enumerator.Current; SortAllInventoriesEvent val2 = ECSExtensions.Read<SortAllInventoriesEvent>(current); NativeParallelHashMap<NetworkId, Entity> networkIdToEntityMap = GameSystems.NetworkIdSystem._NetworkIdLookupMap._NetworkIdToEntityMap; if (networkIdToEntityMap.TryGetValue(val2.Inventory, ref entity) && (entity.IdEquals("__ScarletMarket.Storage__") || entity.IdEquals("__ScarletMarket.Stand__"))) { ECSExtensions.Destroy(current, true); } } } catch (Exception ex) { Log.Error((object)("Error in SortAllInventoriesSystemPatch: " + ex.Message)); } finally { val.Dispose(); } } [HarmonyPatch(typeof(MoveAllItemsBetweenInventoriesSystem), "OnUpdate")] [HarmonyPrefix] public static void Prefix(MoveAllItemsBetweenInventoriesSystem __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery _query_133601579_ = __instance.__query_133601579_0; NativeArray<Entity> val = ((EntityQuery)(ref _query_133601579_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); Entity entity = default(Entity); Entity val3 = default(Entity); while (enumerator.MoveNext()) { Entity current = enumerator.Current; MoveAllItemsBetweenInventoriesEvent val2 = ECSExtensions.Read<MoveAllItemsBetweenInventoriesEvent>(current); NativeParallelHashMap<NetworkId, Entity> networkIdToEntityMap = GameSystems.NetworkIdSystem._NetworkIdLookupMap._NetworkIdToEntityMap; if (!networkIdToEntityMap.TryGetValue(val2.ToInventory, ref entity) || !networkIdToEntityMap.TryGetValue(val2.FromInventory, ref val3) || (!val3.IdEquals("__ScarletMarket.Storage__") && !val3.IdEquals("__ScarletMarket.Stand__") && !entity.IdEquals("__ScarletMarket.Stand__") && !entity.IdEquals("__ScarletMarket.Storage__"))) { continue; } FromCharacter val4 = ECSExtensions.Read<FromCharacter>(current); if (!ECSExtensions.Has<PlayerCharacter>(val4.Character) || !ECSExtensions.Has<User>(val4.User)) { continue; } PlayerData playerData = PlayerDataExtensions.GetPlayerData(val4.Character); if (!val3.IdEquals("__ScarletMarket.Storage__") || !(ECSExtensions.Read<Follower>(val3).Followed._Value == playerData.UserEntity)) { TraderModel trader = TraderService.GetTrader(val3); if (trader.Owner == playerData) { trader?.SetAsReady(); } else { TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); } ECSExtensions.Destroy(current, true); } } } catch (Exception ex) { Log.Error((object)("Error in MoveAllItemsBetweenInventoriesSystemPatch: " + ex.Message)); } finally { val.Dispose(); } } [HarmonyPatch(typeof(MoveAllItemsBetweenInventoriesV2System), "OnUpdate")] [HarmonyPrefix] public static void Prefix(MoveAllItemsBetweenInventoriesV2System __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0113: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery _query_133601631_ = __instance.__query_133601631_0; NativeArray<Entity> val = ((EntityQuery)(ref _query_133601631_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); Entity entity = default(Entity); Entity val3 = default(Entity); while (enumerator.MoveNext()) { Entity current = enumerator.Current; MoveAllItemsBetweenInventoriesEventV2 val2 = ECSExtensions.Read<MoveAllItemsBetweenInventoriesEventV2>(current); NativeParallelHashMap<NetworkId, Entity> networkIdToEntityMap = GameSystems.NetworkIdSystem._NetworkIdLookupMap._NetworkIdToEntityMap; if (!networkIdToEntityMap.TryGetValue(val2.ToInventory, ref entity) || !networkIdToEntityMap.TryGetValue(val2.FromInventory, ref val3) || (!val3.IdEquals("__ScarletMarket.Storage__") && !val3.IdEquals("__ScarletMarket.Stand__") && !entity.IdEquals("__ScarletMarket.Stand__") && !entity.IdEquals("__ScarletMarket.Storage__"))) { continue; } FromCharacter val4 = ECSExtensions.Read<FromCharacter>(current); if (ECSExtensions.Has<PlayerCharacter>(val4.Character) && ECSExtensions.Has<User>(val4.User)) { PlayerData playerData = PlayerDataExtensions.GetPlayerData(val4.Character); if (!val3.IdEquals("__ScarletMarket.Storage__") || !(ECSExtensions.Read<Follower>(val3).Followed._Value == playerData.UserEntity)) { TraderService.SendErrorSCT(playerData, "298b546b-1686-414b-a952-09836842bedc"); ECSExtensions.Destroy(current, true); } } } } catch (Exception ex) { Log.Error((object)("Error in MoveAllItemsBetweenInventoriesV2SystemPatch: " + ex.Message)); } finally { val.Dispose(); } } [HarmonyPatch(typeof(SplitItemSystem), "OnUpdate")] [HarmonyPrefix] public static void Prefix(SplitItemSystem __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a6: 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_00b4: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery query = __instance._Query; NativeArray<Entity> val = ((EntityQuery)(ref query)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); Entity entity = default(Entity); while (enumerator.MoveNext()) { Entity current = enumerator.Current; SplitItemEvent val2 = ECSExtensions.Read<SplitItemEvent>(current); NativeParallelHashMap<NetworkId, Entity> networkIdToEntityMap = GameSystems.NetworkIdSystem._NetworkIdLookupMap._NetworkIdToEntityMap; if (networkIdToEntityMap.TryGetValue(val2.Inventory, ref entity) && (entity.IdEquals("__ScarletMarket.Storage__") || entity.IdEquals("__ScarletMarket.Stand__"))) { FromCharacter val3 = ECSExtensions.Read<FromCharacter>(current); if (ECSExtensions.Has<PlayerCharacter>(val3.Character) && ECSExtensions.Has<User>(val3.User)) { PlayerData playerData = PlayerDataExtensions.GetPlayerData(val3.Character); TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); ECSExtensions.Destroy(current, true); } } } } catch (Exception ex) { Log.Error((object)("Error in SplitItemSystemPatch: " + ex.Message)); } finally { val.Dispose(); } } [HarmonyPatch(typeof(SplitItemV2System), "OnUpdate")] [HarmonyPrefix] public static void Prefix(SplitItemV2System __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) //IL_00a9: 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) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery query = __instance._Query; NativeArray<Entity> val = ((EntityQuery)(ref query)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); Entity entity = default(Entity); Entity entity2 = default(Entity); while (enumerator.MoveNext()) { Entity current = enumerator.Current; SplitItemEventV2 val2 = ECSExtensions.Read<SplitItemEventV2>(current); NativeParallelHashMap<NetworkId, Entity> networkIdToEntityMap = GameSystems.NetworkIdSystem._NetworkIdLookupMap._NetworkIdToEntityMap; if (networkIdToEntityMap.TryGetValue(val2.FromInventory, ref entity) && networkIdToEntityMap.TryGetValue(val2.ToInventory, ref entity2) && (entity.IdEquals("__ScarletMarket.Storage__") || entity.IdEquals("__ScarletMarket.Stand__") || entity2.IdEquals("__ScarletMarket.Storage__") || entity2.IdEquals("__ScarletMarket.Stand__"))) { FromCharacter val3 = ECSExtensions.Read<FromCharacter>(current); if (ECSExtensions.Has<PlayerCharacter>(val3.Character) && ECSExtensions.Has<User>(val3.User)) { PlayerData playerData = PlayerDataExtensions.GetPlayerData(val3.Character); TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); ECSExtensions.Destroy(current, true); } } } } catch (Exception ex) { Log.Error((object)("Error in SplitItemV2SystemPatch: " + ex.Message));