Decompiled source of BloodyMerchant v0.2.0
BloodyMerchant.dll
Decompiled 6 months ago
The result has been truncated due to the large size, download it to view full contents!
#define DEBUG 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.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.Json; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using Bloodstone.API; using BloodyMerchant.DB; using BloodyMerchant.DB.Models; using BloodyMerchant.Exceptions; using BloodyMerchant.Services; using BloodyMerchant.Systems; using BloodyMerchant_VRising.GameData; using BloodyMerchant_VRising.GameData.Models; using BloodyMerchant_VRising.GameData.Models.Base; using BloodyMerchant_VRising.GameData.Models.Data; using BloodyMerchant_VRising.GameData.Models.Internals; using BloodyMerchant_VRising.GameData.Patch; using BloodyMerchant_VRising.GameData.Utils; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Auth; using ProjectM.Behaviours; using ProjectM.CastleBuilding; using ProjectM.CastleBuilding.Placement; using ProjectM.Gameplay; using ProjectM.Gameplay.Clan; using ProjectM.Gameplay.Scripting; using ProjectM.Hybrid; using ProjectM.Network; using ProjectM.Pathfinding; using ProjectM.Physics; using ProjectM.Portrait; using ProjectM.Roofs; using ProjectM.Scripting; using ProjectM.Sequencer; using ProjectM.Shared; using ProjectM.Terrain; using ProjectM.Tiles; using ProjectM.UI; using Stunlock.Core; using Stunlock.Localization; using Stunlock.Sequencer; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Physics; using Unity.Physics.Systems; using Unity.Scenes; 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("BloodyMerchant")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Create VRising NPC merchant")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("BloodyMerchant")] [assembly: AssemblyTitle("BloodyMerchant")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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] internal sealed class IsUnmanagedAttribute : Attribute { } [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 BloodyMerchant { public static class ECSExtensions { public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct { //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_0046: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); byte[] array = StructureToByteArray(componentData); int num = Marshal.SizeOf<T>(); fixed (byte* ptr = array) { EntityManager entityManager = VWorld.Server.EntityManager; ((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num); } } public static byte[] StructureToByteArray<T>(T structure) where T : struct { int num = Marshal.SizeOf(structure); byte[] array = new byte[num]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true); Marshal.Copy(intPtr, array, 0, num); Marshal.FreeHGlobal(intPtr); return array; } public unsafe static T Read<T>(this Entity entity) where T : struct { //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_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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); EntityManager entityManager = VWorld.Server.EntityManager; void* componentDataRawRO = ((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex); return Marshal.PtrToStructure<T>(new IntPtr(componentDataRawRO)); } public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct { //IL_0006: 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_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_0014: 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) EntityManager entityManager = VWorld.Server.EntityManager; return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity); } public static void Add<T>(this Entity entity) { //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_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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); EntityManager entityManager = VWorld.Server.EntityManager; ((EntityManager)(ref entityManager)).AddComponent(entity, val); } public static void Remove<T>(this Entity entity) { //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_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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); EntityManager entityManager = VWorld.Server.EntityManager; ((EntityManager)(ref entityManager)).RemoveComponent(entity, val); } public static bool Has<T>(this Entity entity) { //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_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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); EntityManager entityManager = VWorld.Server.EntityManager; return ((EntityManager)(ref entityManager)).HasComponent(entity, val); } public static void LogComponentTypes(this Entity entity) { //IL_0006: 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_000e: 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_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) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = VWorld.Server.EntityManager; Enumerator<ComponentType> enumerator = ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2).GetEnumerator(); bool flag = default(bool); while (enumerator.MoveNext()) { ComponentType current = enumerator.Current; ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(0, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(current); } logger.LogInfo(val); } Plugin.Logger.LogInfo((object)"==="); } public static void LogComponentTypes(this EntityQuery entityQuery) { //IL_0014: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0040: 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_0078: Expected O, but got Unknown Il2CppStructArray<ComponentType> queryTypes = ((EntityQuery)(ref entityQuery)).GetQueryTypes(); bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; foreach (ComponentType item in (Il2CppArrayBase<ComponentType>)(object)queryTypes) { ManualLogSource logger = Plugin.Logger; val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Query Component Type: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(item); } logger.LogInfo(val); } ManualLogSource logger2 = Plugin.Logger; val = new BepInExInfoLogInterpolatedStringHandler(3, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("==="); } logger2.LogInfo(val); } public static string LookupName(this PrefabGUID prefabGuid) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) PrefabCollectionSystem existingSystem = VWorld.Server.GetExistingSystem<PrefabCollectionSystem>(); object obj; if (!((PrefabCollectionSystem_Base)existingSystem).PrefabGuidToNameDictionary.ContainsKey(prefabGuid)) { obj = "GUID Not Found"; } else { string text = ((PrefabCollectionSystem_Base)existingSystem).PrefabGuidToNameDictionary[prefabGuid]; PrefabGUID val = prefabGuid; obj = text + " " + ((object)(PrefabGUID)(ref val)).ToString(); } return obj.ToString(); } } [BepInPlugin("BloodyMerchant", "BloodyMerchant", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin, IRunOnInitialized { public static ManualLogSource Logger; private Harmony _harmony; public static World World; public override void Load() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown Logger = ((BasePlugin)this).Log; _harmony = new Harmony("BloodyMerchant"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); _harmony.PatchAll(typeof(BloodyMerchant.Systems.ServerEvents)); _harmony.PatchAll(typeof(AutorefillSystem)); _harmony.PatchAll(typeof(UnitSpawnerService)); GameData.OnInitialize += GameDataOnInitialize; GameData.OnDestroy += GameDataOnDestroy; CommandRegistry.RegisterAll(); Database.Initialize(); ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BloodyMerchant"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } log.LogInfo(val); } public override bool Unload() { ((BasePlugin)this).Config.Clear(); CommandRegistry.UnregisterAssembly(); _harmony.UnpatchSelf(); GameData.OnDestroy -= GameDataOnDestroy; GameData.OnInitialize -= GameDataOnInitialize; return true; } private static void GameDataOnInitialize(World world) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown Logger.LogInfo((object)"GameDataOnInitialize"); bool flag = default(bool); foreach (MerchantModel item in Database.Merchants.Where((MerchantModel x) => x.config.Autorepawn).ToList()) { ManualLogSource logger = Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Autorespawn Merchant "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item.name); } logger.LogInfo(val); item.AutorespawnMerchant(); } } private static void GameDataOnDestroy() { Logger.LogInfo((object)"GameDataOnDestroy"); } public void OnGameInitialized() { World = VWorld.Server; Logger.LogInfo((object)"OnGameInitialized"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "BloodyMerchant"; public const string PLUGIN_NAME = "BloodyMerchant"; public const string PLUGIN_VERSION = "0.1.0"; } } namespace BloodyMerchant.Services { internal class UnitSpawnerService { [HarmonyPatch(typeof(UnitSpawnerReactSystem), "OnUpdate")] public static class UnitSpawnerReactSystem_Patch { public static bool Enabled { get; set; } public static void Prefix(UnitSpawnerReactSystem __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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_006d: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00d2: 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_00db: 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_00f5: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0153: 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_01b8: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) if (!Enabled) { return; } EntityQuery _OnUpdate_LambdaJob0_entityQuery = __instance.__OnUpdate_LambdaJob0_entityQuery; NativeArray<Entity> val = ((EntityQuery)(ref _OnUpdate_LambdaJob0_entityQuery)).ToEntityArray((Allocator)2); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Processing "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(val.Length); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" in UnitSpawnerReactionSystem"); } logger.LogDebug(val2); Enumerator<Entity> enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ManualLogSource logger2 = Plugin.Logger; val2 = new BepInExDebugLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Checking if "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(current.Index); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" has lifetime.."); } logger2.LogDebug(val2); EntityManager entityManager = Plugin.World.EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<LifeTime>(current)) { break; } entityManager = Plugin.World.EntityManager; LifeTime componentData = ((EntityManager)(ref entityManager)).GetComponentData<LifeTime>(current); long num = (long)Mathf.Round(componentData.Duration); ManualLogSource logger3 = Plugin.Logger; val2 = new BepInExDebugLogInterpolatedStringHandler(34, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Found durationKey "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<long>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" from LifeTime("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(componentData.Duration); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")"); } logger3.LogDebug(val2); if (UnitSpawner.PostActions.TryGetValue(num, out (float, Action<Entity>) value)) { (float, Action<Entity>) tuple = value; float item = tuple.Item1; Action<Entity> item2 = tuple.Item2; ManualLogSource logger4 = Plugin.Logger; val2 = new BepInExDebugLogInterpolatedStringHandler(38, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Found post actions for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<long>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" with "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(item); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" duration"); } logger4.LogDebug(val2); UnitSpawner.PostActions.Remove(num); LifeTimeEndAction endAction = (LifeTimeEndAction)((!(item < 0f)) ? 2 : 0); LifeTime val3 = default(LifeTime); val3.Duration = item; val3.EndAction = endAction; LifeTime val4 = val3; entityManager = Plugin.World.EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<LifeTime>(current, val4); item2(current); } } } } private static Entity empty_entity = default(Entity); internal const int DEFAULT_MINRANGE = 1; internal const int DEFAULT_MAXRANGE = 1; internal Dictionary<long, (float actualDuration, Action<Entity> Actions)> PostActions = new Dictionary<long, (float, Action<Entity>)>(); public static UnitSpawnerService UnitSpawner { get; internal set; } = new UnitSpawnerService(); public void SpawnWithCallback(Entity user, PrefabGUID unit, float2 position, float duration, Action<Entity> postActions) { //IL_0006: 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_000f: 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_0018: 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_001f: 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_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_0054: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Plugin.World.EntityManager; Translation componentData = ((EntityManager)(ref entityManager)).GetComponentData<Translation>(user); float3 val = default(float3); ((float3)(ref val))..ctor(position.x, componentData.Value.y, position.y); UnitSpawnerUpdateSystem existingSystem = Plugin.World.GetExistingSystem<UnitSpawnerUpdateSystem>(); UnitSpawnerReactSystem_Patch.Enabled = true; long num = NextKey(); existingSystem.SpawnUnit(empty_entity, unit, val, 1, 1f, 1f, (float)num); PostActions.Add(num, (duration, postActions)); } internal long NextKey() { Random random = new Random(); int num = 5; long num2; do { num2 = random.NextInt64(10000L) * 3; num--; if (num < 0) { throw new Exception("Failed to generate a unique key for UnitSpawnerService"); } } while (PostActions.ContainsKey(num2)); return num2; } } } namespace BloodyMerchant.Systems { internal class AutorefillSystem { [HarmonyPatch(typeof(TraderPurchaseSystem), "OnUpdate")] [HarmonyPrefix] public static void Prefix(TraderPurchaseSystem __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_0014: 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_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_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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0084: 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_008b: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a8: 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_00bb: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) EntityQuery _TraderPurchaseJob_entityQuery = __instance.__TraderPurchaseJob_entityQuery; Enumerator<Entity> enumerator = ((EntityQuery)(ref _TraderPurchaseJob_entityQuery)).ToEntityArray((Allocator)2).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; TraderPurchaseEvent val = current.Read<TraderPurchaseEvent>(); Entity entity = VWorld.Server.GetExistingSystem<NetworkIdSystem>()._NetworkIdToEntityMap[val.Trader]; Health val2 = entity.Read<Health>(); if (((ModifiableFloat)(ref val2.MaxHealth)).Value != 1111f) { continue; } DynamicBuffer<TraderEntry> val3 = entity.ReadBuffer<TraderEntry>(); DynamicBuffer<TradeCost> val4 = entity.ReadBuffer<TradeCost>(); DynamicBuffer<TradeOutput> val5 = entity.ReadBuffer<TradeOutput>(); for (int i = 0; i < val3.Length; i++) { TraderEntry val6 = val3[i]; if (val3[i].StockAmount != 1 || val.ItemIndex != val6.OutputStartIndex) { continue; } PrefabGUID _outputItem = val5[i].Item; PrefabGUID _inputItem = val4[i].Item; foreach (MerchantModel merchant in Database.Merchants) { BloodyMerchant.DB.Models.ItemModel itemModel = merchant.items.Where((BloodyMerchant.DB.Models.ItemModel x) => new PrefabGUID(x.InputItem) == _inputItem && new PrefabGUID(x.OutputItem) == _outputItem).FirstOrDefault(); if (itemModel != null && itemModel.Autorefill) { val6.StockAmount = itemModel.StockAmount + 1; val3[i] = val6; } } } } } } public static class Il2cppService { private static Type GetType<T>() { return Il2CppType.Of<T>(); } public unsafe static T GetComponentDataAOT<T>(this EntityManager entityManager, Entity entity) where T : unmanaged { //IL_000e: Unknown result type (might be due to invalid IL or missing references) int typeIndex = TypeManager.GetTypeIndex(GetType<T>()); T* componentDataRawRW = (T*)((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, typeIndex); return *componentDataRawRW; } public static NativeArray<Entity> GetEntitiesByComponentTypes<T1>(bool includeAll = false) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //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_0038: 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_004c: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_006a: 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) EntityQueryOptions options = (EntityQueryOptions)(includeAll ? 27 : 0); EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1] { new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0) }); val.Options = options; EntityQueryDesc val2 = val; EntityManager entityManager = VWorld.Server.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 }); return ((EntityQuery)(ref val3)).ToEntityArray((Allocator)2); } public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(bool includeAll = false) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //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_0033: 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_004a: 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_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_0075: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) EntityQueryOptions options = (EntityQueryOptions)(includeAll ? 27 : 0); EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2] { new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0), new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0) }); val.Options = options; EntityQueryDesc val2 = val; EntityManager entityManager = VWorld.Server.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 }); return ((EntityQuery)(ref val3)).ToEntityArray((Allocator)2); } public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2, T3>(bool includeAll = false) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //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_0033: 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_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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_008d: 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_0092: Unknown result type (might be due to invalid IL or missing references) EntityQueryOptions options = (EntityQueryOptions)(includeAll ? 27 : 0); EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[3] { new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0), new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0), new ComponentType(Il2CppType.Of<T3>(), (AccessMode)0) }); val.Options = options; EntityQueryDesc val2 = val; EntityManager entityManager = VWorld.Server.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 }); return ((EntityQuery)(ref val3)).ToEntityArray((Allocator)2); } } internal class ServerEvents { [HarmonyPatch(typeof(GameBootstrap), "OnApplicationQuit")] [HarmonyPrefix] public static void OnApplicationQuit(GameBootstrap __instance) { //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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) Plugin.Logger.LogInfo((object)"Kill Merchants"); Database.saveDatabase(); bool flag = default(bool); foreach (MerchantModel item in Database.Merchants.Where((MerchantModel x) => x.config.IsEnabled).ToList()) { Entity anyUser = GetAnyUser(); ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Kill Merchant "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item.name); } logger.LogInfo(val); item.KillMerchant(anyUser); } Database.saveDatabase(); } public static Entity GetAnyUser() { //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_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_001d: 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_0031: Unknown result type (might be due to invalid IL or missing references) Enumerator<Entity> enumerator = Il2cppService.GetEntitiesByComponentTypes<User>().GetEnumerator(); if (enumerator.MoveNext()) { return enumerator.Current; } return Entity.Null; } } } namespace BloodyMerchant.Exceptions { internal class MerchantDontEnableException : Exception { public MerchantDontEnableException() { } public MerchantDontEnableException(string message) : base(message) { } public MerchantDontEnableException(string message, Exception innerException) : base(message, innerException) { } protected MerchantDontEnableException(SerializationInfo info, StreamingContext context) : base(info, context) { } } internal class MerchantDontExistException : Exception { public MerchantDontExistException() { } public MerchantDontExistException(string message) : base(message) { } public MerchantDontExistException(string message, Exception innerException) : base(message, innerException) { } protected MerchantDontExistException(SerializationInfo info, StreamingContext context) : base(info, context) { } } internal class MerchantEnableException : Exception { public MerchantEnableException() { } public MerchantEnableException(string message) : base(message) { } public MerchantEnableException(string message, Exception innerException) : base(message, innerException) { } protected MerchantEnableException(SerializationInfo info, StreamingContext context) : base(info, context) { } } internal class MerchantExistException : Exception { public MerchantExistException() { } public MerchantExistException(string message) : base(message) { } public MerchantExistException(string message, Exception innerException) : base(message, innerException) { } protected MerchantExistException(SerializationInfo info, StreamingContext context) : base(info, context) { } } internal class ProductDontExistException : Exception { public ProductDontExistException() { } public ProductDontExistException(string message) : base(message) { } public ProductDontExistException(string message, Exception innerException) : base(message, innerException) { } protected ProductDontExistException(SerializationInfo info, StreamingContext context) : base(info, context) { } } internal class ProductExistException : Exception { public ProductExistException() { } public ProductExistException(string message) : base(message) { } public ProductExistException(string message, Exception innerException) : base(message, innerException) { } protected ProductExistException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } namespace BloodyMerchant.DB { internal class Database { public static readonly string ConfigPath = Path.Combine(Paths.ConfigPath, "BloodyMerchant"); public static string MerchantListFile = Path.Combine(ConfigPath, "merchants.json"); public static List<MerchantModel> Merchants { get; set; } = new List<MerchantModel>(); public static void Initialize() { createDatabaseFiles(); loadDatabase(); } public static bool saveDatabase() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown bool flag = default(bool); try { string contents = JsonSerializer.Serialize(Merchants, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(MerchantListFile, contents); ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Save Database: OK"); } logger.LogInfo(val); return true; } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(20, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error SaveDatabase: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } logger2.LogError(val2); return false; } } public static bool loadDatabase() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown bool flag = default(bool); try { string json = File.ReadAllText(MerchantListFile); Merchants = JsonSerializer.Deserialize<List<MerchantModel>>(json); ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Load Database: OK"); } logger.LogInfo(val); return true; } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(20, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error LoadDatabase: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } logger2.LogError(val2); return false; } } public static bool createDatabaseFiles() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (!Directory.Exists(ConfigPath)) { Directory.CreateDirectory(ConfigPath); } if (!File.Exists(MerchantListFile)) { File.WriteAllText(MerchantListFile, "[]"); } ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(19, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Create Database: OK"); } logger.LogInfo(val); return true; } public static bool GetMerchant(string MerchantName, out MerchantModel merchant) { merchant = Merchants.Where((MerchantModel x) => x.name == MerchantName).FirstOrDefault(); if (merchant == null) { return false; } return true; } public static bool AddMerchant(string MerchantName, int prefabGUIDOfMerchant, bool immortal, bool canMove, bool autoRespawn) { if (GetMerchant(MerchantName, out var merchant)) { throw new MerchantExistException(); } merchant = new MerchantModel(); merchant.name = MerchantName; merchant.PrefabGUID = prefabGUIDOfMerchant; merchant.config.Immortal = immortal; merchant.config.CanMove = canMove; merchant.config.Autorepawn = autoRespawn; Merchants.Add(merchant); saveDatabase(); return true; } public static bool RemoveMerchant(string MerchantName) { if (GetMerchant(MerchantName, out var merchant)) { if (merchant.config.IsEnabled) { throw new MerchantEnableException(); } Merchants.Remove(merchant); saveDatabase(); return true; } throw new MerchantDontExistException(); } } } namespace BloodyMerchant.DB.Models { internal class ConfigMerchantModel { public bool IsEnabled { get; set; } = false; public float x { get; set; } = 0f; public float z { get; set; } = 0f; public bool Immortal { get; set; } = false; public bool CanMove { get; set; } = false; public bool Autorepawn { get; set; } = false; } public class ItemModel { public int OutputItem { get; set; } public int OutputAmount { get; set; } public int InputItem { get; set; } public int InputAmount { get; set; } public int StockAmount { get; set; } public bool Autorefill { get; set; } public ItemModel(int outputItem, int outputAmount, int inputItem, int inputAmount, int stockAmount, bool autorefill) { OutputItem = outputItem; OutputAmount = outputAmount; InputItem = inputItem; InputAmount = inputAmount; StockAmount = stockAmount; Autorefill = autorefill; } } internal class MerchantModel { public string name { get; set; } = string.Empty; public int PrefabGUID { get; set; } public List<ItemModel> items { get; set; } = new List<ItemModel>(); public Entity merchantEntity { get; set; } = default(Entity); public ConfigMerchantModel config { get; set; } = new ConfigMerchantModel(); public List<TraderItem> GetTraderItems() { //IL_0027: 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) List<TraderItem> list = new List<TraderItem>(); foreach (ItemModel item2 in items) { TraderItem item = new TraderItem(new PrefabGUID(item2.OutputItem), item2.OutputAmount, new PrefabGUID(item2.InputItem), item2.InputAmount, item2.StockAmount); list.Add(item); } return list; } public bool GetProduct(int itemPrefabID, out ItemModel item) { item = items.Where((ItemModel x) => x.OutputItem == itemPrefabID).FirstOrDefault(); if (item == null) { return false; } return true; } public bool AddProduct(int ItemPrefabID, int CurrencyfabID, int Stack, int Price, int Amount, bool Autorefill) { if (!GetProduct(ItemPrefabID, out var item)) { item = new ItemModel(ItemPrefabID, Stack, CurrencyfabID, Price, Amount, Autorefill); items.Add(item); Database.saveDatabase(); return true; } throw new ProductExistException(); } public bool RemoveProduct(int ItemPrefabID) { if (GetProduct(ItemPrefabID, out var item)) { items.Remove(item); Database.saveDatabase(); return true; } throw new ProductDontExistException(); } public bool AutorespawnMerchant() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_003a: 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) Entity sender = BloodyMerchant.Systems.ServerEvents.GetAnyUser(); if (config.Autorepawn) { UnitSpawnerService.UnitSpawner.SpawnWithCallback(sender, new PrefabGUID(PrefabGUID), new float2(config.x, config.z), -1f, delegate(Entity e) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) merchantEntity = e; config.IsEnabled = true; ModifyMerchant(sender, e); }); return true; } throw new MerchantEnableException(); } public bool SpawnWithLocation(Entity sender, float3 pos) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0040: 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 (!config.IsEnabled) { UnitSpawnerService.UnitSpawner.SpawnWithCallback(sender, new PrefabGUID(PrefabGUID), new float2(pos.x, pos.z), -1f, delegate(Entity e) { //IL_0007: 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_0064: Unknown result type (might be due to invalid IL or missing references) merchantEntity = e; config.z = pos.z; config.x = pos.x; config.IsEnabled = true; ModifyMerchant(sender, e); }); return true; } throw new MerchantEnableException(); } public void ModifyMerchant(Entity user, Entity merchant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //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_000f: 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_0016: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0076: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_01d4: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01b8: Expected O, but got Unknown List<TraderItem> traderItems = GetTraderItems(); DynamicBuffer<TradeOutput> val = merchant.ReadBuffer<TradeOutput>(); DynamicBuffer<TraderEntry> val2 = merchant.ReadBuffer<TraderEntry>(); DynamicBuffer<TradeCost> val3 = merchant.ReadBuffer<TradeCost>(); val.Clear(); val2.Clear(); val3.Clear(); int num = 0; foreach (TraderItem item in traderItems) { val.Add(new TradeOutput { Amount = item.OutputAmount, Item = item.OutputItem }); val3.Add(new TradeCost { Amount = item.InputAmount, Item = item.InputItem }); val2.Add(new TraderEntry { RechargeInterval = -1f, CostCount = 1, CostStartIndex = num, FullRechargeTime = -1f, OutputCount = 1, OutputStartIndex = num, StockAmount = item.StockAmount }); num++; } bool flag2 = default(bool); if (config.Immortal) { bool flag = MakeNPCImmortal(user, merchant, new PrefabGUID(-61473528)); ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("NPC immortal: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<bool>(flag); } logger.LogInfo(val4); } if (!config.CanMove) { merchant.Remove<MoveEntity>(); ManualLogSource logger2 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(15, 0, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("NPC Remove Move"); } logger2.LogInfo(val4); } Health componentData = merchant.Read<Health>(); ((ModifiableFloat)(ref componentData.MaxHealth)).Value = 1111f; merchant.Write<Health>(componentData); RenameMerchant(merchant, name); } private static void RenameMerchant(Entity merchant, string nameMerchant) { } public bool MakeNPCImmortal(Entity user, Entity merchant, PrefabGUID buff) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001c: 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_0021: 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) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_003b: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_008e: 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_00a3: 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) DebugEventsSystem existingSystem = VWorld.Server.GetExistingSystem<DebugEventsSystem>(); ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent); val.BuffPrefabGUID = buff; ApplyBuffDebugEvent val2 = val; FromCharacter val3 = default(FromCharacter); val3.User = user; val3.Character = merchant; FromCharacter val4 = val3; existingSystem.ApplyBuff(val4, val2); Entity entity = default(Entity); if (BuffUtility.TryGetBuff(Plugin.World.EntityManager, merchant, buff, ref entity)) { entity.Add<Buff_Persists_Through_Death>(); if (entity.Has<LifeTime>()) { LifeTime componentData = entity.Read<LifeTime>(); componentData.Duration = -1f; componentData.EndAction = (LifeTimeEndAction)0; entity.Write<LifeTime>(componentData); } if (entity.Has<RemoveBuffOnGameplayEvent>()) { entity.Remove<RemoveBuffOnGameplayEvent>(); } if (entity.Has<RemoveBuffOnGameplayEventEntry>()) { entity.Remove<RemoveBuffOnGameplayEventEntry>(); } return true; } return false; } public bool MakeNPCMortal(Entity user, Entity merchant, PrefabGUID buff) { //IL_0006: 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_000c: 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_0023: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (BuffUtility.TryGetBuff(VWorld.Server.EntityManager, merchant, buff, ref val)) { DestroyUtility.Destroy(VWorld.Server.EntityManager, val, (DestroyDebugReason)13, (string)null, 0); return true; } return false; } public bool KillMerchant(Entity user) { //IL_0023: 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) if (config.IsEnabled) { config.IsEnabled = false; StatChangeUtility.KillEntity(Plugin.World.EntityManager, merchantEntity, user, 0.0, true); return true; } throw new MerchantDontEnableException(); } } public struct TraderItem { public PrefabGUID OutputItem { get; set; } public int OutputAmount { get; set; } public PrefabGUID InputItem { get; set; } public int InputAmount { get; set; } public int StockAmount { get; set; } public TraderItem(PrefabGUID outputItem, int outputAmount, PrefabGUID inputItem, int inputAmount, int stockAmount) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) OutputItem = outputItem; OutputAmount = outputAmount; InputItem = inputItem; InputAmount = inputAmount; StockAmount = stockAmount; } } } namespace BloodyMerchant.Commands { [CommandGroup("merchant config", null)] internal class ConfigCommand { [Command("show", null, "<NameOfMerchant>", "Show config of merchant", null, true)] public void ShowConfigMerchant(ChatCommandContext ctx, string merchantName) { try { if (Database.GetMerchant(merchantName, out var merchant)) { ctx.Reply("Merchant '" + merchantName + "' config:"); ctx.Reply("----------------------------------------------"); ctx.Reply($"Immortal: '{merchant.config.Immortal}'"); ctx.Reply($"Move: '{merchant.config.CanMove}'"); ctx.Reply($"Autorespawn '{merchant.config.Autorepawn}' config:"); } } catch (MerchantExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' exist."); } catch (Exception ex2) { throw ctx.Error("Error: " + ex2.Message); } } [Command("immortal", null, "<NameOfMerchant> <true/false>", "Set config immortal of merchant", null, true)] public void InmortalMerchant(ChatCommandContext ctx, string merchantName, bool value) { //IL_0052: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) try { if (Database.GetMerchant(merchantName, out var merchant)) { merchant.config.Immortal = value; if (value) { merchant.MakeNPCImmortal(ctx.Event.SenderUserEntity, merchant.merchantEntity, new PrefabGUID(-61473528)); } else { merchant.MakeNPCMortal(ctx.Event.SenderUserEntity, merchant.merchantEntity, new PrefabGUID(-61473528)); } Database.saveDatabase(); ctx.Reply($"Merchant '{merchantName}' immortal {value}"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (Exception ex2) { throw ctx.Error("Error: " + ex2.Message); } } [Command("move", null, "<NameOfMerchant> <true/false>", "Set config move of merchant", null, true)] public void MoveMerchant(ChatCommandContext ctx, string merchantName, bool value) { //IL_0062: 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) //IL_0080: Expected O, but got Unknown //IL_0026: 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_0043: Expected O, but got Unknown try { if (Database.GetMerchant(merchantName, out var merchant)) { merchant.config.CanMove = value; bool flag = default(bool); if (value) { merchant.merchantEntity.Add<MoveEntity>(); ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(12, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("NPC Add Move"); } logger.LogInfo(val); } else { merchant.merchantEntity.Remove<MoveEntity>(); ManualLogSource logger2 = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("NPC Remove Move"); } logger2.LogInfo(val); } Database.saveDatabase(); ctx.Reply($"Merchant '{merchantName}' move {value}"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (Exception ex2) { throw ctx.Error("Error: " + ex2.Message); } } [Command("enabled", null, "<NameOfMerchant> <true/false>", "Enable merchant", null, true)] public void EnableMerchant(ChatCommandContext ctx, string merchantName, bool value) { try { if (Database.GetMerchant(merchantName, out var merchant)) { merchant.config.IsEnabled = value; Database.saveDatabase(); ctx.Reply($"Merchant '{merchantName}' enabled {value}"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (Exception ex2) { throw ctx.Error("Error: " + ex2.Message); } } [Command("autorespawn", null, "<NameOfMerchant> <true/false>", "Autorespawn of merchant", null, true)] public void AutorespawnMerchant(ChatCommandContext ctx, string merchantName, bool value) { try { if (Database.GetMerchant(merchantName, out var merchant)) { merchant.config.Autorepawn = value; Database.saveDatabase(); ctx.Reply($"Merchant '{merchantName}' autorespawn {value}"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (Exception ex2) { throw ctx.Error("Error: " + ex2.Message); } } } [CommandGroup("merchant", null)] internal class MerchantCommand { [Command("list", null, "", "List of merchant", null, true)] public void ListMerchant(ChatCommandContext ctx) { List<MerchantModel> list = Database.Merchants.ToList(); if (list.Count == 0) { throw ctx.Error("There are no merchants created"); } ctx.Reply("Merchant List"); ctx.Reply("----------------------------"); ctx.Reply("--"); foreach (MerchantModel item in list) { ctx.Reply("Merchant " + item.name); ctx.Reply("--"); } ctx.Reply("----------------------------"); } [Command("create", null, "<NameOfMerchant> [PrefabGUIDOfMerchant] [Immortal] [Move] [Autorespawn]", "Create a merchant", null, true)] public void CreateMerchant(ChatCommandContext ctx, string merchantName, int prefabGUIDOfMerchant = -1810631919, bool immortal = false, bool canMove = true, bool autorespawn = true) { try { if (Database.AddMerchant(merchantName, prefabGUIDOfMerchant, immortal, canMove, autorespawn)) { ctx.Reply("Merchant '" + merchantName + "' created successfully"); } } catch (MerchantExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' exist."); } catch (Exception ex2) { throw ctx.Error("Error: " + ex2.Message); } } [Command("remove", null, "<NameOfMerchant>", "Remove a merchant", null, true)] public void RemoveMerchant(ChatCommandContext ctx, string merchantName) { try { if (Database.RemoveMerchant(merchantName)) { ctx.Reply("Merchant '" + merchantName + "' remove successfully"); } } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (MerchantEnableException) { throw ctx.Error("The merchant is in the world, you must kill the merchant with the command .merchant kill " + merchantName); } catch (Exception ex3) { throw ctx.Error("Error: " + ex3.Message); } } [Command("spawn", null, "<NameOfMerchant>", "Spawn a merchant in your location", null, true)] public void Spawn(ChatCommandContext ctx, string merchantName) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002f: 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_0038: 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_003b: Unknown result type (might be due to invalid IL or missing references) try { if (Database.GetMerchant(merchantName, out var merchant)) { Entity senderUserEntity = ctx.Event.SenderUserEntity; EntityManager entityManager = VWorld.Server.EntityManager; LocalToWorld componentData = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(senderUserEntity); float3 position = ((LocalToWorld)(ref componentData)).Position; merchant.SpawnWithLocation(senderUserEntity, position); ctx.Reply("Merchant '" + merchantName + "' has spawned correctly"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (MerchantEnableException) { throw ctx.Error("Merchant with name '" + merchantName + "' already in world."); } catch (Exception ex3) { throw ctx.Error("Error: " + ex3.Message); } } [Command("kill", null, "<NameOfMerchant>", "Kill a merchant", null, true)] public void Kill(ChatCommandContext ctx, string merchantName) { //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) try { if (Database.GetMerchant(merchantName, out var merchant)) { Entity senderUserEntity = ctx.Event.SenderUserEntity; merchant.KillMerchant(senderUserEntity); ctx.Reply("Merchant '" + merchantName + "' has killed correctly"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (MerchantDontEnableException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist in world."); } catch (Exception ex3) { throw ctx.Error("Error: " + ex3.Message); } } } [CommandGroup("merchant product", null)] internal class ProductsCommand { [Command("list", null, "", "List product of merchant", null, true)] public void ListMerchant(ChatCommandContext ctx, string merchantName) { try { if (Database.GetMerchant(merchantName, out var merchant)) { ctx.Reply(merchant.name + " Products List"); ctx.Reply("----------------------------"); ctx.Reply("--"); foreach (BloodyMerchant.DB.Models.ItemModel item in merchant.items) { ctx.Reply($"Currency {item.InputItem}"); ctx.Reply($"Item {item.OutputItem}"); ctx.Reply($"Price {item.InputAmount}"); ctx.Reply($"Stack {item.OutputAmount}"); ctx.Reply($"Stock {item.StockAmount}"); ctx.Reply("--"); } ctx.Reply("----------------------------"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (ProductExistException) { throw ctx.Error("This product configuration already exists at merchant '" + merchantName + "'"); } catch (Exception ex3) { throw ctx.Error("Error: " + ex3.Message); } } [Command("add", null, "<NameOfMerchant> <ItemPrefabID> <CurrencyfabID> <Stack> <Price> <Stock> [Autorefill true/false]", "Add a product to a merchant", null, true)] public void CreateProduct(ChatCommandContext ctx, string merchantName, int ItemPrefabID, int CurrencyfabID, int Stack, int Price, int Stock, bool Autorefill = false) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) try { if (Database.GetMerchant(merchantName, out var merchant)) { merchant.AddProduct(ItemPrefabID, CurrencyfabID, Stack, Price, Stock, Autorefill); if (merchant.config.IsEnabled) { merchant.ModifyMerchant(ctx.Event.SenderUserEntity, merchant.merchantEntity); } ctx.Reply("Product successfully added to merchant '" + merchantName + "'"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (ProductExistException) { throw ctx.Error("This product configuration already exists at merchant '" + merchantName + "'"); } catch (Exception ex3) { throw ctx.Error("Error: " + ex3.Message); } } [Command("remove", null, "<NameOfMerchant> <ItemPrefabID>", "Remove a product to a merchant", null, true)] public void RemoveProduct(ChatCommandContext ctx, string merchantName, int ItemPrefabID) { //IL_002e: 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) try { if (Database.GetMerchant(merchantName, out var merchant)) { merchant.RemoveProduct(ItemPrefabID); if (merchant.config.IsEnabled) { merchant.ModifyMerchant(ctx.Event.SenderUserEntity, merchant.merchantEntity); } ctx.Reply("Merchant '" + merchantName + "''s product has been successfully removed"); return; } throw new MerchantDontExistException(); } catch (MerchantDontExistException) { throw ctx.Error("Merchant with name '" + merchantName + "' does not exist."); } catch (ProductDontExistException) { throw ctx.Error("This product does not exist at merchant '" + merchantName + "'"); } catch (Exception ex3) { throw ctx.Error("Error: " + ex3.Message); } } } } namespace BloodyMerchant_VRising.GameData { internal delegate void OnGameDataInitializedEventHandler(World world); internal static class GameData { private static bool _initialized; private static bool _worldDataInitialized; private const string NotInitializedError = "GameData is not initialized"; public static bool IsServer; public static bool IsClient; private static World _world; private static Harmony _harmonyInstance; internal static ManualLogSource Logger; public static GameVersionData GameVersion => GameVersionUtils.GetVersionData(); public static World World => _world ?? throw new InvalidOperationException("GameData is not initialized"); public static Systems Systems { get { if (!_worldDataInitialized) { throw new InvalidOperationException("GameData is not initialized"); } return Systems.Instance; } } public static Users Users { get { if (!_worldDataInitialized) { throw new InvalidOperationException("GameData is not initialized"); } return Users.Instance; } } public static Items Items { get { if (!_worldDataInitialized) { throw new InvalidOperationException("GameData is not initialized"); } return Items.Instance; } } public static Npcs Npcs { get { if (!_worldDataInitialized) { throw new InvalidOperationException("GameData is not initialized"); } return Npcs.Instance; } } public static bool Initialized => _worldDataInitialized; public static event OnGameDataInitializedEventHandler OnInitialize; public static event OnGameDataDestroyedEventHandler OnDestroy; static GameData() { IsServer = Application.productName == "VRisingServer"; IsClient = Application.productName == "VRising"; Logger = Logger.CreateLogSource("VRising.GameData"); Create(); } internal static void Create() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (!_initialized) { _initialized = true; _harmonyInstance = new Harmony("VRising.GameData"); if (IsClient) { _harmonyInstance.PatchAll(typeof(ClientEvents)); ClientEvents.OnGameDataInitialized += OnGameDataInitialized; ClientEvents.OnGameDataDestroyed += OnGameDataDestroyed; } if (IsServer) { _harmonyInstance.PatchAll(typeof(BloodyMerchant_VRising.GameData.Patch.ServerEvents)); BloodyMerchant_VRising.GameData.Patch.ServerEvents.OnGameDataInitialized += OnGameDataInitialized; } } } internal static void Destroy() { GameData.OnInitialize = null; if (IsClient) { ClientEvents.OnGameDataInitialized -= OnGameDataInitialized; } if (IsServer) { BloodyMerchant_VRising.GameData.Patch.ServerEvents.OnGameDataInitialized -= OnGameDataInitialized; } _harmonyInstance.UnpatchSelf(); _harmonyInstance = null; } private static void OnGameDataDestroyed() { _world = null; _worldDataInitialized = false; GameData.OnDestroy?.Invoke(); if (GameData.OnDestroy == null) { return; } Delegate[] invocationList = GameData.OnDestroy.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { @delegate.DynamicInvoke(); } catch (Exception ex) { Logger.LogError((object)ex); } } } private static void OnGameDataInitialized(World world) { _world = world; _worldDataInitialized = true; if (GameData.OnInitialize == null) { return; } Delegate[] invocationList = GameData.OnInitialize.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { @delegate.DynamicInvoke(world); } catch (Exception ex) { Logger.LogError((object)ex); } } Logger.LogInfo((object)"GameData initialized"); } } internal delegate void OnGameDataDestroyedEventHandler(); internal class Systems { private static Systems _instance; internal static Systems Instance => _instance ?? (_instance = new Systems()); public PrefabCollectionSystem PrefabCollectionSystem => GameData.World.GetExistingSystem<PrefabCollectionSystem>(); public GameDataSystem GameDataSystem => GameData.World.GetExistingSystem<GameDataSystem>(); public ManagedDataRegistry ManagedDataRegistry => GameDataSystem.ManagedDataRegistry; private Systems() { } } internal class Users { private static Users _instance; internal static ulong CurrentUserSteamId { get; set; } internal static Users Instance => _instance ?? (_instance = new Users()); public IEnumerable<UserModel> Online => All.Where((UserModel u) => u.IsConnected); public IEnumerable<UserModel> All { get { EntityManager entityManager = GameData.World.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray((Allocator)2).GetEnumerator(); while (enumerator.MoveNext()) { Entity userEntity = enumerator.Current; yield return FromEntity(userEntity); } } } private Users() { } public UserModel GetCurrentUser() { return GetUserByPlatformId(CurrentUserSteamId); } public UserModel GetUserByPlatformId(ulong platformId) { return All.FirstOrDefault((UserModel u) => u.PlatformId == platformId); } public UserModel GetUserByCharacterName(string characterName) { return All.FirstOrDefault((UserModel u) => u.CharacterName == characterName); } public UserModel FromEntity(Entity userEntity) { //IL_0006: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = GameData.World.EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<User>(userEntity)) { throw new Exception("Given entity does not have User component."); } return new UserModel(userEntity); } } } namespace BloodyMerchant_VRising.GameData.Models.Base { internal abstract class EntityModel { public Entity Entity { get; } public PrefabGUID PrefabGUID => Internals.PrefabGUID.GetValueOrDefault(); public BaseEntityModel Internals { get; } protected EntityModel(Entity entity) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) Entity = entity; Internals = new BaseEntityModel(GameData.World, entity); } } } namespace BloodyMerchant_VRising.GameData.Models.Internals { internal class BaseEntityModel { private readonly World _world; public readonly Entity _entity; public SceneReference? SceneReference { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) SceneReference value; return _world.EntityManager.TryGetComponentDataInternal<SceneReference>(_entity, out value) ? new SceneReference?(value) : null; } } public RequestSceneLoaded? RequestSceneLoaded { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) RequestSceneLoaded value; return _world.EntityManager.TryGetComponentDataInternal<RequestSceneLoaded>(_entity, out value) ? new RequestSceneLoaded?(value) : null; } } public ResolvedSceneHash? ResolvedSceneHash { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ResolvedSceneHash value; return _world.EntityManager.TryGetComponentDataInternal<ResolvedSceneHash>(_entity, out value) ? new ResolvedSceneHash?(value) : null; } } public List<LinkedEntityGroup> LinkedEntityGroups => _world.EntityManager.GetBufferInternal<LinkedEntityGroup>(_entity); public List<ResolvedSectionEntity> ResolvedSectionEntities => _world.EntityManager.GetBufferInternal<ResolvedSectionEntity>(_entity); public PostLoadCommandBuffer PostLoadCommandBuffer { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) PostLoadCommandBuffer value; return _world.EntityManager.TryGetComponentDataInternal<PostLoadCommandBuffer>(_entity, out value) ? value : null; } } public ServerRuntimeSettings ServerRuntimeSettings { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) ServerRuntimeSettings value; return (ServerRuntimeSettings)(_world.EntityManager.TryGetComponentDataInternal<ServerRuntimeSettings>(_entity, out value) ? value : default(ServerRuntimeSettings)); } } public bool Prefab => _world.EntityManager.HasComponentInternal<Prefab>(_entity); public NetworkedSettings? NetworkedSettings { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) NetworkedSettings value; return _world.EntityManager.TryGetComponentDataInternal<NetworkedSettings>(_entity, out value) ? new NetworkedSettings?(value) : null; } } public FrameChanged? FrameChanged { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) FrameChanged value; return _world.EntityManager.TryGetComponentDataInternal<FrameChanged>(_entity, out value) ? new FrameChanged?(value) : null; } } public NetworkSnapshot? NetworkSnapshot { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) NetworkSnapshot value; return _world.EntityManager.TryGetComponentDataInternal<NetworkSnapshot>(_entity, out value) ? new NetworkSnapshot?(value) : null; } } public DestroyedEntity? DestroyedEntity { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) DestroyedEntity value; return _world.EntityManager.TryGetComponentDataInternal<DestroyedEntity>(_entity, out value) ? new DestroyedEntity?(value) : null; } } public List<NetSnapshot> NetSnapshots => _world.EntityManager.GetBufferInternal<NetSnapshot>(_entity); public List<SnapshotFrameChangedBuffer> SnapshotFrameChangedBuffers => _world.EntityManager.GetBufferInternal<SnapshotFrameChangedBuffer>(_entity); public List<Snapshot_InventoryBuffer> Snapshot_InventoryBuffer => _world.EntityManager.GetBufferInternal<Snapshot_InventoryBuffer>(_entity); public List<Snapshot_PerksBuffer> Snapshot_PerksBuffer => _world.EntityManager.GetBufferInternal<Snapshot_PerksBuffer>(_entity); public bool NewDestroyedEntity => _world.EntityManager.HasComponentInternal<NewDestroyedEntity>(_entity); public WorldTypeSingleton? WorldTypeSingleton { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) WorldTypeSingleton value; return _world.EntityManager.TryGetComponentDataInternal<WorldTypeSingleton>(_entity, out value) ? new WorldTypeSingleton?(value) : null; } } public WorldFrame? WorldFrame { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) WorldFrame value; return _world.EntityManager.TryGetComponentDataInternal<WorldFrame>(_entity, out value) ? new WorldFrame?(value) : null; } } public TerrainChunkLoadedEvent? TerrainChunkLoadedEvent { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) TerrainChunkLoadedEvent value; return _world.EntityManager.TryGetComponentDataInternal<TerrainChunkLoadedEvent>(_entity, out value) ? new TerrainChunkLoadedEvent?(value) : null; } } public List<PublicEntityRef> PublicEntityRefs => _world.EntityManager.GetBufferInternal<PublicEntityRef>(_entity); public TerrainChunkMetadataLoadedEvent? TerrainChunkMetadataLoadedEvent { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) TerrainChunkMetadataLoadedEvent value; return _world.EntityManager.TryGetComponentDataInternal<TerrainChunkMetadataLoadedEvent>(_entity, out value) ? new TerrainChunkMetadataLoadedEvent?(value) : null; } } public LoadToTargetWorld? LoadToTargetWorld { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) LoadToTargetWorld value; return _world.EntityManager.TryGetComponentDataInternal<LoadToTargetWorld>(_entity, out value) ? new LoadToTargetWorld?(value) : null; } } public ServerGameBalanceSettings ServerGameBalanceSettings { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) ServerGameBalanceSettings value; return (ServerGameBalanceSettings)(_world.EntityManager.TryGetComponentDataInternal<ServerGameBalanceSettings>(_entity, out value) ? value : default(ServerGameBalanceSettings)); } } public ToggleDisabledEvent? ToggleDisabledEvent { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ToggleDisabledEvent value; return _world.EntityManager.TryGetComponentDataInternal<ToggleDisabledEvent>(_entity, out value) ? new ToggleDisabledEvent?(value) : null; } } public List<Snapshot_CastleBuildingAttachedChildrenBuffer> Snapshot_CastleBuildingAttachedChildrenBuffer => _world.EntityManager.GetBufferInternal<Snapshot_CastleBuildingAttachedChildrenBuffer>(_entity); public List<Snapshot_CastleBuildingAttachToParentsBuffer> Snapshot_CastleBuildingAttachToParentsBuffer => _world.EntityManager.GetBufferInternal<Snapshot_CastleBuildingAttachToParentsBuffer>(_entity); public List<Snapshot_RefinementstationRecipesBuffer> Snapshot_RefinementstationRecipesBuffer => _world.EntityManager.GetBufferInternal<Snapshot_RefinementstationRecipesBuffer>(_entity); public List<Snapshot_ActiveServantMission> Snapshot_ActiveServantMission => _world.EntityManager.GetBufferInternal<Snapshot_ActiveServantMission>(_entity); public LocalToWorld? LocalToWorld { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) LocalToWorld value; return _world.EntityManager.TryGetComponentDataInternal<LocalToWorld>(_entity, out value) ? new LocalToWorld?(value) : null; } } public TileBounds? TileBounds { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) TileBounds value; return _world.EntityManager.TryGetComponentDataInternal<TileBounds>(_entity, out value) ? new TileBounds?(value) : null; } } public TilePosition? TilePosition { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) TilePosition value; return _world.EntityManager.TryGetComponentDataInternal<TilePosition>(_entity, out value) ? new TilePosition?(value) : null; } } public TileModelSpatialData? TileModelSpatialData { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) TileModelSpatialData value; return _world.EntityManager.TryGetComponentDataInternal<TileModelSpatialData>(_entity, out value) ? new TileModelSpatialData?(value) : null; } } public TileData TileData { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) TileData value; return (TileData)(_world.EntityManager.TryGetComponentDataInternal<TileData>(_entity, out value) ? value : default(TileData)); } } public MapZoneData? MapZoneData { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) MapZoneData value; return _world.EntityManager.TryGetComponentDataInternal<MapZoneData>(_entity, out value) ? new MapZoneData?(value) : null; } } public TileModel? TileModel { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) TileModel value; return _world.EntityManager.TryGetComponentDataInternal<TileModel>(_entity, out value) ? new TileModel?(value) : null; } } public List<MapZonePolygonVertexElement> MapZonePolygonVertexElements => _world.EntityManager.GetBufferInternal<MapZonePolygonVertexElement>(_entity); public List<MapZoneDiscoverableElement> MapZoneDiscoverableElements => _world.EntityManager.GetBufferInternal<MapZoneDiscoverableElement>(_entity); public bool TileRestrictionAreaTag => _world.EntityManager.HasComponentInternal<TileRestrictionAreaTag>(_entity); public bool TileModelRegistrationState => _world.EntityManager.HasComponentInternal<TileModelRegistrationState>(_entity); public RetainBlobAssets RetainBlobAssets { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) RetainBlobAssets value; return (RetainBlobAssets)(_world.EntityManager.TryGetComponentDataInternal<RetainBlobAssets>(_entity, out value) ? value : default(RetainBlobAssets)); } } public RetainBlobAssetBatchPtr? RetainBlobAssetBatchPtr { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) RetainBlobAssetBatchPtr value; return _world.EntityManager.TryGetComponentDataInternal<RetainBlobAssetBatchPtr>(_entity, out value) ? new RetainBlobAssetBatchPtr?(value) : null; } } public bool BlobAssetOwner => _world.EntityManager.HasComponentInternal<BlobAssetOwner>(_entity); public List<WorldAssetChunks> WorldAssetChunks => _world.EntityManager.GetBufferInternal<WorldAssetChunks>(_entity); public bool WorldAssetSingleton => _world.EntityManager.HasComponentInternal<WorldAssetSingleton>(_entity); public bool WorldConfigSingleton => _world.EntityManager.HasComponentInternal<WorldConfigSingleton>(_entity); public List<RelicDropped> RelicDroppeds => _world.EntityManager.GetBufferInternal<RelicDropped>(_entity); public KnockbackAssetsSingleton? KnockbackAssetsSingleton { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) KnockbackAssetsSingleton value; return _world.EntityManager.TryGetComponentDataInternal<KnockbackAssetsSingleton>(_entity, out value) ? new KnockbackAssetsSingleton?(value) : null; } } public List<Snapshot_SpawnedUnitsBuffer> Snapshot_SpawnedUnitsBuffer => _world.EntityManager.GetBufferInternal<Snapshot_SpawnedUnitsBuffer>(_entity); public SceneEntityReference? SceneEntityReference { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) SceneEntityReference value; return _world.EntityManager.TryGetComponentDataInternal<SceneEntityReference>(_entity, out value) ? new SceneEntityReference?(value) : null; } } public SceneSectionData? SceneSectionData { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) SceneSectionData value; return _world.EntityManager.TryGetComponentDataInternal<SceneSectionData>(_entity, out value) ? new SceneSectionData?(value) : null; } } public ResolvedSectionPath? ResolvedSectionPath { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ResolvedSectionPath value; return _world.EntityManager.TryGetComponentDataInternal<ResolvedSectionPath>(_entity, out value) ? new ResolvedSectionPath?(value) : null; } } public SceneBoundingVolume? SceneBoundingVolume { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missin