Decompiled source of ScarletMarket v1.1.0
ScarletMarket.dll
Decompiled a month 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("Create automated player-to-player shops with NPC traders that work 24/7. Use any item as currency and trade even when offline.")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+60dcb83f5694a991a0e463942ceda79827af0be3")] [assembly: AssemblyProduct("ScarletMarket")] [assembly: AssemblyTitle("ScarletMarket")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.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); public static readonly PrefabGUID Root = new PrefabGUID(-1527408583); } 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.1.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.1.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(); GameSystems.OnInitialize((Action)OnInitialize); } public static void OnInitialize() { TraderService.Initialize(); } public override bool Unload() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } CommandRegistry.UnregisterAssembly(); ActionScheduler.UnregisterAssembly(Assembly.GetExecutingAssembly()); EventManager.UnregisterAssembly(Assembly.GetExecutingAssembly()); return true; } public static void ReloadSettings() { 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.1.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; } } } return 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) .ToList(); } 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(new object[1] { $"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 { private const float ANIMATION_CHECK_INTERVAL = 20f; private const int ANIMATION_CHANCE_DENOMINATOR = 3; 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 readonly List<Entity> OrphanCandidates = new List<Entity>(); 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_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_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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0079: 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)) { object[] array = new object[1]; DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(32, 1); defaultInterpolatedStringHandler.AppendLiteral("Failed to find prefab for GUID: "); PrefabGUID standChest = Spawnable.StandChest; defaultInterpolatedStringHandler.AppendFormatted(((PrefabGUID)(ref standChest)).GuidHash); array[0] = defaultInterpolatedStringHandler.ToStringAndClear(); Log.Error(array); 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")) { return; } if (Plugin.Settings.Get<bool>("RemoveEmptyTradersOnStartup")) { ClearEmptyTraders(); } foreach (TraderModel value in TraderEntities.Values) { PlayerData owner = value.Owner; DateTime connectedSince = owner.ConnectedSince; int num = Settings.Get<int>("MaxInactiveDays"); if (connectedSince < DateTime.Now.AddDays(-num)) { ForceRemoveTrader(owner); } } } 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0101: 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_0056: 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) 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(); if (!ECSExtensions.Has<AttachedBuffer>(plot.Entity)) { ECSExtensions.AddBuffer<AttachedBuffer>(plot.Entity); } DynamicBuffer<AttachedBuffer> val = ECSExtensions.ReadBuffer<AttachedBuffer>(plot.Entity); val.Add(new AttachedBuffer { Entity = traderModel2.StorageChest }); val.Add(new AttachedBuffer { Entity = traderModel2.Stand }); val.Add(new AttachedBuffer { Entity = traderModel2.Trader }); val.Add(new AttachedBuffer { Entity = traderModel2.Coffin }); TraderEntities[traderModel2.Trader] = traderModel2; StorageEntities[traderModel2.StorageChest] = traderModel2; StandEntities[traderModel2.Stand] = 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0061: 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; } if (value.Plot != null && ECSExtensions.Has<AttachedBuffer>(value.Plot.Entity)) { ECSExtensions.ReadBuffer<AttachedBuffer>(value.Plot.Entity).Clear(); } value.Plot.Show(); value.Plot.Trader = null; TraderEntities.Remove(value.Trader); StorageEntities.Remove(value.StorageChest); StandEntities.Remove(value.Stand); 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(new object[1] { "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) { TraderModel value; return TraderById.TryGetValue(platformId, out value) ? value : null; } public static TraderModel GetTrader(Entity entity) { //IL_0006: 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_0024: Unknown result type (might be due to invalid IL or missing references) TraderModel value; return TraderEntities.TryGetValue(entity, out value) ? value : (StorageEntities.TryGetValue(entity, out value) ? value : (StandEntities.TryGetValue(entity, out value) ? value : 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_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) float minDistance = 4f; return Plots.Where((PlotModel plot) => excludePlot == null || plot != excludePlot).Any((PlotModel plot) => math.distance(plot.Position, position) < minDistance); } 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_0073: 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_0081: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00d8: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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) //IL_010d: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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<Entity, Entity> dictionary = new Dictionary<Entity, Entity>(); Dictionary<Entity, Entity> dictionary2 = new Dictionary<Entity, Entity>(); Dictionary<Entity, Entity> dictionary3 = new Dictionary<Entity, Entity>(); Dictionary<Entity, Entity> dictionary4 = new Dictionary<Entity, Entity>(); Dictionary<Entity, Entity> dictionary5 = new Dictionary<Entity, Entity>(); OrphanCandidates.Clear(); Enumerator<Entity> enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!ECSExtensions.Has<NameableInteractable>(current)) { continue; } if (current.IdEquals("__ScarletMarket.Plot__")) { dictionary[current] = current; } else if (ECSExtensions.Has<Follower>(current)) { Entity value = ECSExtensions.Read<Follower>(current).Followed._Value; if (current.IdEquals("__ScarletMarket.Inspect__")) { dictionary2[value] = current; } else if (current.IdEquals("__ScarletMarket.GStorage__")) { dictionary3[value] = current; } else if (current.IdEquals("__ScarletMarket.GTrader__")) { dictionary4[value] = current; } else if (current.IdEquals("__ScarletMarket.GCoffin__")) { dictionary5[value] = current; } else if (current.IdEquals("__ScarletMarket.Trader__") || current.IdEquals("__ScarletMarket.Storage__") || current.IdEquals("__ScarletMarket.Stand__") || current.IdEquals("__ScarletMarket.Coffin__")) { OrphanCandidates.Add(current); } } } RegisterPlotsFromEntities(dictionary, dictionary2); RegisterTradersFromPlots(dictionary); RegisterGhostsFromEntities(dictionary3, dictionary4, dictionary5); RegisterOrphanTraders(); } 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 RegisterTradersFromPlots(Dictionary<Entity, Entity> plots) { //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_001c: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) //IL_006f: 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_007d: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_011a: 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_00ae: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_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_015a: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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) foreach (Entity key in plots.Keys) { if (!ECSExtensions.Has<AttachedBuffer>(key)) { continue; } DynamicBuffer<AttachedBuffer> val = ECSExtensions.ReadBuffer<AttachedBuffer>(key); if (val.Length == 0) { continue; } Entity val2 = Entity.Null; Entity val3 = Entity.Null; Entity val4 = Entity.Null; Entity val5 = Entity.Null; Enumerator<AttachedBuffer> enumerator2 = val.GetEnumerator(); while (enumerator2.MoveNext()) { AttachedBuffer current2 = enumerator2.Current; Entity entity = current2.Entity; if (ECSExtensions.Exists(entity)) { if (entity.IdEquals("__ScarletMarket.Storage__")) { val2 = entity; } else if (entity.IdEquals("__ScarletMarket.Stand__")) { val3 = entity; } else if (entity.IdEquals("__ScarletMarket.Trader__")) { val4 = entity; } else if (entity.IdEquals("__ScarletMarket.Coffin__")) { val5 = entity; } } } if (!(val2 != Entity.Null) || !ECSExtensions.Has<Follower>(val2)) { continue; } PlayerData playerData = PlayerDataExtensions.GetPlayerData(ECSExtensions.Read<Follower>(val2).Followed._Value); if (playerData != null) { TraderModel traderModel = new TraderModel(playerData, val2, val3, val4, val5); TraderEntities[traderModel.Trader] = traderModel; StorageEntities[traderModel.StorageChest] = traderModel; StandEntities[traderModel.Stand] = traderModel; TraderById[playerData.PlatformId] = traderModel; HashSet<Entity> hashSet = ((IEnumerable<Entity>)(object)new Entity[4] { val2, val3, val4, val5 }).Where((Entity e) => e != Entity.Null).ToHashSet(); OrphanCandidates.RemoveAll(hashSet.Contains); } } } private static void RegisterOrphanTraders() { //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_002e: 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_0056: 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_0069: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_011b: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: 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_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) Dictionary<PlayerData, Entity> dictionary = new Dictionary<PlayerData, Entity>(); Dictionary<PlayerData, Entity> dictionary2 = new Dictionary<PlayerData, Entity>(); Dictionary<PlayerData, Entity> dictionary3 = new Dictionary<PlayerData, Entity>(); foreach (Entity orphanCandidate in OrphanCandidates) { PlayerData playerData = PlayerDataExtensions.GetPlayerData(ECSExtensions.Read<Follower>(orphanCandidate).Followed._Value); if (playerData != null && (!orphanCandidate.IdEquals("__ScarletMarket.Trader__") || !TraderEntities.ContainsKey(orphanCandidate)) && (!orphanCandidate.IdEquals("__ScarletMarket.Storage__") || !StorageEntities.ContainsKey(orphanCandidate)) && (!orphanCandidate.IdEquals("__ScarletMarket.Stand__") || !StandEntities.ContainsKey(orphanCandidate))) { if (orphanCandidate.IdEquals("__ScarletMarket.Trader__")) { ECSExtensions.Destroy(orphanCandidate, false); } else if (orphanCandidate.IdEquals("__ScarletMarket.Storage__")) { dictionary[playerData] = orphanCandidate; } else if (orphanCandidate.IdEquals("__ScarletMarket.Stand__")) { dictionary2[playerData] = orphanCandidate; } else if (orphanCandidate.IdEquals("__ScarletMarket.Coffin__")) { dictionary3[playerData] = orphanCandidate; } } } foreach (KeyValuePair<PlayerData, Entity> item in dictionary) { PlayerData key = item.Key; if (TraderById.ContainsKey(key.PlatformId)) { continue; } Entity valueOrDefault = dictionary.GetValueOrDefault(key); Entity valueOrDefault2 = dictionary2.GetValueOrDefault(key); Entity @null = Entity.Null; Entity valueOrDefault3 = dictionary3.GetValueOrDefault(key); List<Entity> entities = ((IEnumerable<Entity>)(object)new Entity[3] { valueOrDefault, valueOrDefault2, valueOrDefault3 }).Where((Entity e) => e != Entity.Null).ToList(); var (plotModel, num) = (from plot in Plots select new { plot = plot, count = entities.Count((Entity e) => plot.IsInside(ECSExtensions.Position(e))) } into x where x.count > 0 orderby x.count descending select (x.plot, x.count)).FirstOrDefault(); if (plotModel != null && num > 0) { TraderModel traderModel2 = (plotModel.Trader = new TraderModel(key, valueOrDefault, valueOrDefault2, @null, valueOrDefault3) { Plot = plotModel }); if (!ECSExtensions.Has<AttachedBuffer>(plotModel.Entity)) { ECSExtensions.AddBuffer<AttachedBuffer>(plotModel.Entity); } DynamicBuffer<AttachedBuffer> plotBuffer = ECSExtensions.ReadBuffer<AttachedBuffer>(plotModel.Entity); IEnumerable<Entity> enumerable = ((IEnumerable<Entity>)(object)new Entity[4] { valueOrDefault, valueOrDefault2, valueOrDefault3, traderModel2.Trader }).Where((Entity e) => e != Entity.Null && !BufferContainsEntity(plotBuffer, e)); foreach (Entity item2 in enumerable) { plotBuffer.Add(new AttachedBuffer { Entity = item2 }); } TraderEntities[traderModel2.Trader] = traderModel2; StorageEntities[traderModel2.StorageChest] = traderModel2; StandEntities[traderModel2.Stand] = traderModel2; TraderById[key.PlatformId] = traderModel2; } else { Log.Warning(new object[1] { "Could not find suitable plot for orphan trader of " + key.Name }); } } } private static bool BufferContainsEntity(DynamicBuffer<AttachedBuffer> buffer, Entity entity) { //IL_0009: 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_0013: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < buffer.Length; i++) { if (buffer[i].Entity == entity) { return true; } } return false; } 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)) { plot.Show(); continue; } trader.Plot = plot; plot.Trader = trader; trader.RespawnTrader(); trader.AlignToPlotRotation(); plot.Hide(); } } public static int ClearEmptyTraders() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) List<TraderModel> list = TraderEntities.Values.Where((TraderModel trader) => trader.IsEmpty()).ToList(); foreach (TraderModel item in list) { TraderEntities.Remove(item.Trader); StorageEntities.Remove(item.StorageChest); StandEntities.Remove(item.Stand); TraderById.Remove(item.Owner.PlatformId); item.Plot.Show(); item.Destroy(); } return list.Count; } 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(); OrphanCandidates.Clear(); } private static void SendSCT(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 SendSuccessSCT(PlayerData player, string message) { SendSCT(player, message); } public static void SendErrorSCT(PlayerData player, string message) { SendSCT(player, message); } public static void Reload() { TraderEntities.Clear(); StorageEntities.Clear(); StandEntities.Clear(); TraderById.Clear(); Plots.Clear(); OrphanCandidates.Clear(); RegisterOnLoad(); } } } 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_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0367: 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) { TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); playerData.SendMessage(RichTextFormatter.FormatError("~Something went wrong~. This trader is not registered.")); playerData.SendMessage("Please contact an administrator."); ECSExtensions.Destroy(current, true); 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(new object[1] { "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(new object[1] { "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(new object[1] { "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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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 val3 = 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 val3) || (!val3.IdEquals("__ScarletMarket.Storage__") && !val3.IdEquals("__ScarletMarket.Stand__"))) { 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 (ECSExtensions.Read<Follower>(val3).Followed._Value != playerData.UserEntity) { TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); ECSExtensions.Destroy(current, true); continue; } TraderModel trader = TraderService.GetTrader(val3); if (trader == null) { TraderService.SendErrorSCT(playerData, "45e3238f-36c1-427c-b21c-7d50cfbd77bc"); playerData.SendMessage(RichTextFormatter.FormatError("~Something went wrong~. This trader is not registered.")); playerData.SendMessage("Please contact an administrator."); ECSExtensions.Destroy(current, true); } else { trader.SetAsNotReady(); ECSExtensions.Destroy(current, true); } } } catch (Exception ex) { Log.Error(new object[1] { "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(new object[1] { "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