Decompiled source of BloodyEncounters v1.5.1
BloodyEncounters.dll
Decompiled 5 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.Concurrent; 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; using System.Text.Json; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using Bloodstone.API; using Bloodstone.Hooks; using BloodyEncounters.Commands; using BloodyEncounters.Components; using BloodyEncounters.Configuration; using BloodyEncounters.DB; using BloodyEncounters.DB.Models; using BloodyEncounters.Exceptions; using BloodyEncounters.Patch; using BloodyEncounters.Services; using BloodyEncounters.Systems; using BloodyEncounters.Utils; using BloodyEncounters_VRising.GameData; using BloodyEncounters_VRising.GameData.Methods; using BloodyEncounters_VRising.GameData.Models; using BloodyEncounters_VRising.GameData.Models.Base; using BloodyEncounters_VRising.GameData.Models.Data; using BloodyEncounters_VRising.GameData.Models.Internals; using BloodyEncounters_VRising.GameData.Patch; using BloodyEncounters_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("BloodyEncounters")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A server side mod for V Rising which spawns a random NPC near a random online player at random intervals, and the player wins a random item reward if the NPC is killed within the given time limit.")] [assembly: AssemblyFileVersion("1.5.0.0")] [assembly: AssemblyInformationalVersion("1.5.0")] [assembly: AssemblyProduct("BloodyEncounters")] [assembly: AssemblyTitle("BloodyEncounters")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BloodyEncounters { 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("BloodyEncounters", "BloodyEncounters", "1.5.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin, IRunOnInitialized { [CompilerGenerated] private static class <>O { public static OnGameDataInitializedEventHandler <0>__GameDataOnInitialize; public static OnGameDataDestroyedEventHandler <1>__GameDataOnDestroy; public static GameFrameUpdateEventHandler <2>__GameFrameUpdate; } public static ManualLogSource Logger; private static Harmony _harmony; public static World World; internal static Plugin Instance { get; private set; } public override void Load() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown Logger = ((BasePlugin)this).Log; _harmony = new Harmony("BloodyEncounters"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); _harmony.PatchAll(typeof(BloodyEncounters.Patch.ServerEvents)); _harmony.PatchAll(typeof(UnitSpawnerService)); GameData.OnInitialize += GameDataOnInitialize; GameData.OnDestroy += GameDataOnDestroy; CommandRegistry.RegisterAll(); 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>("BloodyEncounters"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } log.LogInfo(val); } public override bool Unload() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown GameData.OnInitialize -= GameDataOnInitialize; GameData.OnDestroy -= GameDataOnDestroy; ((BasePlugin)this).Config.Clear(); TimerSystem._encounterTimer?.Stop(); EncounterSystem.Destroy(); GameFrame.Uninitialize(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } ManualLogSource logger = Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BloodyEncounters"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is unloaded!"); } logger.LogInfo(val); return true; } public void OnGameInitialized() { World = VWorld.Server; } private static void GameDataOnInitialize(World world) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown Logger.LogInfo((object)"Loading main data"); Database.Initialize(); Logger.LogInfo((object)"Binding configuration"); PluginConfig.Initialize(); EncounterSystem.Initialize(); TimerSystem._encounterTimer = new Timer(); if (PluginConfig.Enabled.Value) { TimerSystem.StartEncounterTimer(); } GameFrame.Initialize(); object obj = <>O.<2>__GameFrameUpdate; if (obj == null) { GameFrameUpdateEventHandler val = WorldBossSystem.GameFrameUpdate; <>O.<2>__GameFrameUpdate = val; obj = (object)val; } GameFrame.OnUpdate += (GameFrameUpdateEventHandler)obj; } private static void GameDataOnDestroy() { } } public static class MyPluginInfo { public const string PLUGIN_GUID = "BloodyEncounters"; public const string PLUGIN_NAME = "BloodyEncounters"; public const string PLUGIN_VERSION = "1.5.0"; } } namespace BloodyEncounters.Utils { internal static class DataFactory { private static readonly Random Random = new Random(); private static List<NpcEncounterModel> _npcs; private static List<ItemEncounterModel> _items; internal static NpcEncounterModel GetRandomNpc() { _npcs = Database.NPCS; return _npcs.GetRandomItem(); } internal static ItemEncounterModel GetRandomItem(NpcEncounterModel npc) { _items = npc.items; return _items.GetRandomItem(); } private static T GetRandomItem<T>(this List<T> items) { if (items == null || items.Count == 0) { return default(T); } return items[Random.Next(items.Count)]; } } } namespace BloodyEncounters.Systems { internal class BuffSystem { public const int NO_DURATION = 0; public const int DEFAULT_DURATION = -1; public const int RANDOM_POWER = -1; public static bool BuffBoss(Entity character, Entity user, PrefabGUID buff, int duration = -1) { //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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 = character; FromCharacter val4 = val3; Entity entity = default(Entity); if (!BuffUtility.TryGetBuff(VWorld.Server.EntityManager, character, buff, ref entity)) { existingSystem.ApplyBuff(val4, val2); if (BuffUtility.TryGetBuff(VWorld.Server.EntityManager, character, buff, ref entity)) { if (entity.Has<CreateGameplayEventsOnSpawn>()) { entity.Remove<CreateGameplayEventsOnSpawn>(); } if (entity.Has<GameplayEventListeners>()) { entity.Remove<GameplayEventListeners>(); } if (duration > 0 && duration != -1) { if (entity.Has<LifeTime>()) { LifeTime componentData = entity.Read<LifeTime>(); componentData.Duration = duration; entity.Write<LifeTime>(componentData); } } else if (duration == 0) { if (entity.Has<LifeTime>()) { LifeTime componentData2 = entity.Read<LifeTime>(); componentData2.Duration = -1f; componentData2.EndAction = (LifeTimeEndAction)0; entity.Write<LifeTime>(componentData2); } if (entity.Has<RemoveBuffOnGameplayEvent>()) { entity.Remove<RemoveBuffOnGameplayEvent>(); } if (entity.Has<RemoveBuffOnGameplayEventEntry>()) { entity.Remove<RemoveBuffOnGameplayEventEntry>(); } } return true; } return false; } return false; } public static bool BuffPlayer(Entity character, Entity user, PrefabGUID buff, int duration = -1, bool persistsThroughDeath = false) { //IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) ClearExtraBuffs(character); 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 = character; FromCharacter val4 = val3; Entity entity = default(Entity); if (!BuffUtility.TryGetBuff(VWorld.Server.EntityManager, character, buff, ref entity)) { existingSystem.ApplyBuff(val4, val2); if (BuffUtility.TryGetBuff(VWorld.Server.EntityManager, character, buff, ref entity)) { if (entity.Has<CreateGameplayEventsOnSpawn>()) { entity.Remove<CreateGameplayEventsOnSpawn>(); } if (entity.Has<GameplayEventListeners>()) { entity.Remove<GameplayEventListeners>(); } if (persistsThroughDeath) { entity.Add<Buff_Persists_Through_Death>(); if (entity.Has<RemoveBuffOnGameplayEvent>()) { entity.Remove<RemoveBuffOnGameplayEvent>(); } if (entity.Has<RemoveBuffOnGameplayEventEntry>()) { entity.Remove<RemoveBuffOnGameplayEventEntry>(); } } if (duration > 0 && duration != -1) { if (entity.Has<LifeTime>()) { LifeTime componentData = entity.Read<LifeTime>(); componentData.Duration = duration; entity.Write<LifeTime>(componentData); } } else if (duration == 0) { if (entity.Has<LifeTime>()) { LifeTime componentData2 = entity.Read<LifeTime>(); componentData2.Duration = -1f; componentData2.EndAction = (LifeTimeEndAction)0; entity.Write<LifeTime>(componentData2); } if (entity.Has<RemoveBuffOnGameplayEvent>()) { entity.Remove<RemoveBuffOnGameplayEvent>(); } if (entity.Has<RemoveBuffOnGameplayEventEntry>()) { entity.Remove<RemoveBuffOnGameplayEventEntry>(); } } return true; } return false; } return false; } public static void ClearExtraBuffs(Entity player) { //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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_00fc: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = VWorld.Server.EntityManager; DynamicBuffer<BuffBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<BuffBuffer>(player); List<string> list = new List<string> { "BloodBuff", "SetBonus", "EquipBuff", "Combat", "VBlood_Ability_Replace", "Shapeshift", "Interact", "AB_Consumable" }; Enumerator<BuffBuffer> enumerator = buffer.GetEnumerator(); while (enumerator.MoveNext()) { BuffBuffer current = enumerator.Current; bool flag = true; foreach (string item in list) { if (current.PrefabGuid.LookupName().Contains(item)) { flag = false; break; } } if (flag) { DestroyUtility.Destroy(VWorld.Server.EntityManager, current.Entity, (DestroyDebugReason)13, (string)null, 0); } } Equipment val = player.Read<Equipment>(); EquipmentType val2 = default(EquipmentType); if (!((Equipment)(ref val)).IsEquipped(new PrefabGUID(1063517722), ref val2) && BuffUtility.HasBuff(VWorld.Server.EntityManager, player, new PrefabGUID(476186894))) { UnbuffCharacter(player, new PrefabGUID(476186894)); } } public static void UnbuffCharacter(Entity Character, PrefabGUID buffGUID) { //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, Character, buffGUID, ref val)) { DestroyUtility.Destroy(VWorld.Server.EntityManager, val, (DestroyDebugReason)13, (string)null, 0); } } } internal class EncounterSystem { private static readonly ConcurrentDictionary<ulong, ConcurrentDictionary<int, ItemEncounterModel>> RewardsMap = new ConcurrentDictionary<ulong, ConcurrentDictionary<int, ItemEncounterModel>>(); private static readonly ConcurrentDictionary<int, UserModel> NpcPlayerMap = new ConcurrentDictionary<int, UserModel>(); internal static Dictionary<long, (float actualDuration, Action<Entity> Actions)> PostActions = new Dictionary<long, (float, Action<Entity>)>(); public static Random Random = new Random(); private static string MessageTemplate => PluginConfig.EncounterMessageTemplate.Value; internal static void Initialize() { BloodyEncounters.Patch.ServerEvents.OnDeath += ServerEvents_OnDeath; BloodyEncounters.Patch.ServerEvents.OnUnitSpawned += ServerEvents_OnUnitSpawned; } internal static void Destroy() { BloodyEncounters.Patch.ServerEvents.OnDeath -= ServerEvents_OnDeath; BloodyEncounters.Patch.ServerEvents.OnUnitSpawned -= ServerEvents_OnUnitSpawned; } internal static void StartEncounter(UserModel user = null) { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) World world = Plugin.World; if (user == null) { IEnumerable<UserModel> source = GameData.Users.Online.Where((UserModel u) => GameData.Users.FromEntity(u.Entity).Character.Equipment.Level >= (float)PluginConfig.EncounterMinLevel.Value); if (PluginConfig.SkipPlayersInCastle.Value) { source = source.Where((UserModel u) => !u.IsInCastle()); } if (PluginConfig.SkipPlayersInCombat.Value) { source = source.Where((UserModel u) => !u.IsInCombat()); } user = source.OrderBy((UserModel _) => Random.Next()).FirstOrDefault(); } if (user == null) { Plugin.Logger.LogMessage((object)"Could not find any eligible players for a random encounter..."); return; } NpcEncounterModel randomNpc = DataFactory.GetRandomNpc(); bool flag = default(bool); if (randomNpc == null) { ManualLogSource logger = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not find any NPCs"); } logger.LogWarning(val); return; } ManualLogSource logger2 = Plugin.Logger; BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(46, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Attempting to start a new encounter for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(user.CharacterName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" with "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(randomNpc.name); } logger2.LogMessage(val2); try { NpcPlayerMap[randomNpc.PrefabGUID] = user; randomNpc.SpawnWithLocation(user.Entity, user.Position); } catch (Exception ex) { Plugin.Logger.LogError((object)ex); } } public static void ServerEvents_OnUnitSpawned(World world, Entity entity) { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0214: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = world.EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<PrefabGUID>(entity)) { return; } PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(entity); if (!NpcPlayerMap.TryGetValue(componentData.GuidHash, out var value) || !((EntityManager)(ref entityManager)).HasComponent<LifeTime>(entity) || !Database.GetNPCFromEntity(entity, out var npc)) { return; } LifeTime componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<LifeTime>(entity); if ((double)Math.Abs(componentData2.Duration - npc.Lifetime) > 0.001) { return; } NpcPlayerMap.TryRemove(componentData.GuidHash, out var _); if (!RewardsMap.ContainsKey(value.PlatformId)) { RewardsMap[value.PlatformId] = new ConcurrentDictionary<int, ItemEncounterModel>(); } string message = string.Format(MessageTemplate, npc.name, npc.Lifetime); value.SendSystemMessage(message); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Encounters started: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" vs. "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(npc.name); } logger.LogDebug(val); if (PluginConfig.NotifyAdminsAboutEncountersAndRewards.Value) { IEnumerable<UserModel> enumerable = GameData.Users.Online.Where((UserModel x) => x.IsAdmin); foreach (UserModel item in enumerable) { item.SendSystemMessage("Encounter started: " + value.CharacterName + " vs. " + npc.name); } } RewardsMap[value.PlatformId][entity.Index] = DataFactory.GetRandomItem(npc); } public static void ServerEvents_OnDeath(DeathEventListenerSystem sender, NativeArray<DeathEvent> deathEvents) { //IL_0004: 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_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_0043: 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_004c: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) Enumerator<DeathEvent> enumerator = deathEvents.GetEnumerator(); PrefabGUID itemGuid = default(PrefabGUID); bool flag = default(bool); while (enumerator.MoveNext()) { DeathEvent current = enumerator.Current; EntityManager entityManager = ((ComponentSystemBase)sender).EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(current.Killer)) { continue; } entityManager = ((ComponentSystemBase)sender).EntityManager; PlayerCharacter componentData = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(current.Killer); UserModel userModel = GameData.Users.FromEntity(componentData.UserEntity); if (!RewardsMap.TryGetValue(userModel.PlatformId, out var value) || !value.TryGetValue(current.Died.Index, out var value2)) { continue; } ((PrefabGUID)(ref itemGuid))..ctor(value2.ItemID); int stack = value2.Stack; if (!userModel.TryGiveItem(new PrefabGUID(value2.ItemID), stack, out var _)) { userModel.DropItemNearby(itemGuid, stack); } string message = string.Format(PluginConfig.RewardMessageTemplate.Value, value2.Color, value2.name); userModel.SendSystemMessage(message); value.TryRemove(current.Died.Index, out var _); ManualLogSource logger = Plugin.Logger; BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(16, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(userModel.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" earned reward: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value2.name); } logger.LogDebug(val); string message2 = string.Format(PluginConfig.RewardAnnouncementMessageTemplate.Value, userModel.CharacterName, value2.Color, value2.name); if (PluginConfig.NotifyAllPlayersAboutRewards.Value) { IEnumerable<UserModel> online = GameData.Users.Online; foreach (UserModel item in online.Where((UserModel u) => u.PlatformId != userModel.PlatformId)) { item.SendSystemMessage(message2); } } else { if (!PluginConfig.NotifyAdminsAboutEncountersAndRewards.Value) { continue; } IEnumerable<UserModel> enumerable = GameData.Users.Online.Where((UserModel x) => x.IsAdmin); foreach (UserModel item2 in enumerable) { item2.SendSystemMessage($"{userModel.CharacterName} earned an encounter reward: <color={value2.Color}>{value2.name}</color>"); } } } } } internal class FontColorChatSystem { public static string Color(string hexColor, string text) { return $"<color={hexColor}>{text}</color>"; } public static string Red(string text) { return Color("#E90000", text); } public static string Blue(string text) { return Color("#0000ff", text); } public static string Green(string text) { return Color("#7FE030", text); } public static string Yellow(string text) { return Color("#FBC01E", text); } } internal class TimerSystem { public static Timer _encounterTimer; public static void StartEncounterTimer() { _encounterTimer.Start(delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown ManualLogSource logger2 = Plugin.Logger; bool flag2 = default(bool); BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(23, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(DateTime.Now.ToString()); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Starting an encounter."); } logger2.LogDebug(val2); EncounterSystem.StartEncounter(); }, delegate(object input) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (!(input is int num) || 1 == 0) { Plugin.Logger.LogError((object)"Encounter timer delay function parameter is not a valid integer"); return TimeSpan.MaxValue; } if (num < 1) { num = 1; } int num2 = new Random().Next(PluginConfig.EncounterTimerMin.Value, PluginConfig.EncounterTimerMax.Value); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DateTime.Now.ToString()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Next encounter will start in "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2 / num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" seconds."); } logger.LogDebug(val); return TimeSpan.FromSeconds(num2) / num; }); } } internal class WorldBossSystem { public static Dictionary<string, HashSet<string>> vbloodKills = new Dictionary<string, HashSet<string>>(); private static DateTime lastDateMinute = DateTime.Now; private static DateTime lastDateSecond = DateTime.Now; public static void AddKiller(string vblood, string killerCharacterName) { if (!vbloodKills.ContainsKey(vblood)) { vbloodKills[vblood] = new HashSet<string>(); } vbloodKills[vblood].Add(killerCharacterName); } public static void RemoveKillers(string vblood) { vbloodKills[vblood] = new HashSet<string>(); } public static List<string> GetKillers(string vblood) { return vbloodKills[vblood].ToList(); } public static void SendAnnouncementMessage(string vblood, BossEncounterModel bossModel) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) string announcementMessage = GetAnnouncementMessage(vblood, bossModel.name); if (announcementMessage == null) { return; } IEnumerable<UserModel> online = GameData.Users.Online; bossModel.DropItems(vblood); foreach (UserModel item in online) { ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, announcementMessage); } RemoveKillers(vblood); } public static string GetAnnouncementMessage(string vblood, string name) { List<string> killers = GetKillers(vblood); StringBuilder stringBuilder = new StringBuilder(); if (killers.Count == 0) { return null; } if (killers.Count == 1) { stringBuilder.Append(FontColorChatSystem.Yellow(killers[0])); } if (killers.Count == 2) { StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(2, 3, stringBuilder2); handler.AppendFormatted(FontColorChatSystem.Yellow(killers[0])); handler.AppendLiteral(" "); handler.AppendFormatted(PluginConfig.VBloodFinalConcatCharacters.Value); handler.AppendLiteral(" "); handler.AppendFormatted(FontColorChatSystem.Yellow(killers[1])); stringBuilder3.Append(ref handler); } if (killers.Count > 2) { for (int i = 0; i < killers.Count; i++) { if (i == killers.Count - 1) { StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(1, 2, stringBuilder2); handler.AppendFormatted(PluginConfig.VBloodFinalConcatCharacters.Value); handler.AppendLiteral(" "); handler.AppendFormatted(FontColorChatSystem.Yellow(killers[i])); stringBuilder4.Append(ref handler); } else { StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder5 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(2, 1, stringBuilder2); handler.AppendFormatted(FontColorChatSystem.Yellow(killers[i])); handler.AppendLiteral(", "); stringBuilder5.Append(ref handler); } } } string value = PluginConfig.KillMessageBossTemplate.Value; value = value.Replace("#user#", $"{stringBuilder}"); value = value.Replace("#vblood#", FontColorChatSystem.Red(name) ?? ""); return FontColorChatSystem.Green(value ?? ""); } public static void GameFrameUpdate() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) DateTime date = DateTime.Now; if (lastDateMinute.ToString("HH:mm") != date.ToString("HH:mm")) { lastDateMinute = date; List<BossEncounterModel> list = Database.WORLDBOSS.Where((BossEncounterModel x) => x.Hour == date.ToString("HH:mm")).ToList(); if (list != null && GameData.Users.Online.Count() > 0) { UserModel userModel = GameData.Users.Online.FirstOrDefault(); foreach (BossEncounterModel item in list) { item.Spawn(userModel.Entity); WorldBossCommand._lastBossSpawnModel = item; } } } if (!(lastDateSecond.ToString("HH:mm:ss") != date.ToString("HH:mm:ss"))) { return; } lastDateSecond = date; List<BossEncounterModel> list2 = Database.WORLDBOSS.Where((BossEncounterModel x) => x.HourDespawn == date.ToString("HH:mm:ss") && x.bossEntity.HasValue).ToList(); if (list2 == null || GameData.Users.Online.Count() <= 0) { return; } foreach (BossEncounterModel item2 in list2) { string value = PluginConfig.DespawnMessageBossTemplate.Value; value = value.Replace("#worldbossname#", FontColorChatSystem.Yellow(WorldBossCommand._lastBossSpawnModel.name ?? "")); ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, FontColorChatSystem.Green(value ?? "")); WorldBossCommand._lastBossSpawnModel = null; } } } } namespace BloodyEncounters.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 BloodyEncounters.Patch { [HarmonyPatch] public class VBloodSystem_Patch { private const double SendMessageDelay = 2.0; private static bool checkKiller = false; private static Dictionary<string, DateTime> lastKillerUpdate = new Dictionary<string, DateTime>(); private static EntityManager entityManager = VWorld.Server.EntityManager; [HarmonyPatch(typeof(VBloodSystem), "OnUpdate")] [HarmonyPrefix] public static void OnUpdate_Prefix(VBloodSystem __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_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) //IL_0069: 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_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_007c: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) if (__instance.EventList.Length > 0) { Enumerator<VBloodConsumed> enumerator = __instance.EventList.GetEnumerator(); while (enumerator.MoveNext()) { VBloodConsumed current = enumerator.Current; if (((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(current.Target)) { PlayerCharacter componentData = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(current.Target); User componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<User>(componentData.UserEntity); FixedString128 vblood = ((PrefabCollectionSystem_Base)__instance._PrefabCollectionSystem).PrefabDataLookup[current.Source].AssetName; BossEncounterModel bossEncounterModel = Database.WORLDBOSS.Where((BossEncounterModel x) => x.AssetName == ((object)(FixedString128)(ref vblood)).ToString() && x.bossEntity.HasValue).FirstOrDefault(); if (bossEncounterModel != null) { WorldBossSystem.AddKiller(((object)(FixedString128)(ref vblood)).ToString(), ((object)(FixedString64)(ref componentData2.CharacterName)).ToString()); lastKillerUpdate[((object)(FixedString128)(ref vblood)).ToString()] = DateTime.Now; checkKiller = true; } } } } else { if (!checkKiller) { return; } bool flag = false; foreach (KeyValuePair<string, DateTime> kvp in lastKillerUpdate) { DateTime value = kvp.Value; if (DateTime.Now - value < TimeSpan.FromSeconds(2.0)) { flag = true; continue; } BossEncounterModel bossEncounterModel2 = Database.WORLDBOSS.Where((BossEncounterModel x) => x.AssetName == kvp.Key && x.bossEntity.HasValue).FirstOrDefault(); if (bossEncounterModel2 == null) { continue; } EntityManager val = ((ComponentSystemBase)__instance).EntityManager; EntityQueryDesc[] array = new EntityQueryDesc[1]; EntityQueryDesc val2 = new EntityQueryDesc(); val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2] { ComponentType.ReadOnly<VBloodUnit>(), ComponentType.ReadOnly<LifeTime>() }); val2.Options = (EntityQueryOptions)27; array[0] = val2; EntityQuery val3 = ((EntityManager)(ref val)).CreateEntityQuery((EntityQueryDesc[])(object)array); Enumerator<Entity> enumerator3 = ((EntityQuery)(ref val3)).ToEntityArray((Allocator)2).GetEnumerator(); while (enumerator3.MoveNext()) { Entity current2 = enumerator3.Current; if (((object)(Entity)(ref current2)).Equals((object?)bossEncounterModel2.bossEntity)) { WorldBossCommand._lastBossSpawnModel = null; WorldBossSystem.SendAnnouncementMessage(kvp.Key, bossEncounterModel2); break; } } } checkKiller = flag; } } } public delegate void OnUnitSpawnedEventHandler(World world, Entity entity); public delegate void DeathEventHandler(DeathEventListenerSystem sender, NativeArray<DeathEvent> deathEvents); public static class ServerEvents { public static event DeathEventHandler OnDeath; public static event OnUnitSpawnedEventHandler OnUnitSpawned; [HarmonyPatch(typeof(DeathEventListenerSystem), "OnUpdate")] [HarmonyPostfix] private static void DeathEventListenerSystemPatch_Postfix(DeathEventListenerSystem __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(33, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DeathEventListenerSystem.OnUpdate"); } logger.LogDebug(val); try { EntityQuery deathEventQuery = __instance._DeathEventQuery; NativeArray<DeathEvent> deathEvents = ((EntityQuery)(ref deathEventQuery)).ToComponentDataArray<DeathEvent>((Allocator)2); if (deathEvents.Length > 0) { ServerEvents.OnDeath?.Invoke(__instance, deathEvents); } } catch (Exception ex) { Plugin.Logger.LogError((object)ex); } } [HarmonyPatch(typeof(UnitSpawnerReactSystem), "OnUpdate")] [HarmonyPostfix] public static void Prefix(UnitSpawnerReactSystem __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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_0062: Unknown result type (might be due to invalid IL or missing references) ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(31, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("UnitSpawnerReactSystem.OnUpdate"); } logger.LogDebug(val); EntityQuery _OnUpdate_LambdaJob0_entityQuery = __instance.__OnUpdate_LambdaJob0_entityQuery; Enumerator<Entity> enumerator = ((EntityQuery)(ref _OnUpdate_LambdaJob0_entityQuery)).ToEntityArray((Allocator)2).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; try { ServerEvents.OnUnitSpawned?.Invoke(((ComponentSystemBase)__instance).World, current); } catch (Exception ex) { Plugin.Logger.LogError((object)ex); } } } } } namespace BloodyEncounters.Exceptions { internal class NPCDontExistException : Exception { public NPCDontExistException() { } public NPCDontExistException(string message) : base(message) { } public NPCDontExistException(string message, Exception innerException) : base(message, innerException) { } protected NPCDontExistException(SerializationInfo info, StreamingContext context) : base(info, context) { } } internal class NPCExistException : Exception { public NPCExistException() { } public NPCExistException(string message) : base(message) { } public NPCExistException(string message, Exception innerException) : base(message, innerException) { } protected NPCExistException(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) { } } internal class WorldBossDontExistException : Exception { public WorldBossDontExistException() { } public WorldBossDontExistException(string message) : base(message) { } public WorldBossDontExistException(string message, Exception innerException) : base(message, innerException) { } protected WorldBossDontExistException(SerializationInfo info, StreamingContext context) : base(info, context) { } } internal class WorldBossExistException : Exception { public WorldBossExistException() { } public WorldBossExistException(string message) : base(message) { } public WorldBossExistException(string message, Exception innerException) : base(message, innerException) { } protected WorldBossExistException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } namespace BloodyEncounters.DB { internal static class Database { private static readonly Random Random = new Random(); public static readonly string ConfigPath = Path.Combine(Paths.ConfigPath, "BloodyEncounters"); public static string NPCSListFile = Path.Combine(ConfigPath, "NPCS.json"); public static string WORLDBOSSListFile = Path.Combine(ConfigPath, "WORLDBOSS.json"); public static List<NpcEncounterModel> NPCS { get; set; } = new List<NpcEncounterModel>(); public static List<BossEncounterModel> WORLDBOSS { get; set; } = new List<BossEncounterModel>(); public static void Initialize() { createDatabaseFiles(); loadDatabase(); } public static bool createDatabaseFiles() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown if (!Directory.Exists(ConfigPath)) { Directory.CreateDirectory(ConfigPath); } if (!File.Exists(NPCSListFile)) { File.WriteAllText(NPCSListFile, "[]"); } if (!File.Exists(WORLDBOSSListFile)) { File.WriteAllText(WORLDBOSSListFile, "[]"); } ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(19, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Create Database: OK"); } logger.LogDebug(val); return true; } public static bool saveDatabase() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown bool flag = default(bool); try { string contents = JsonSerializer.Serialize(NPCS, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(NPCSListFile, contents); contents = JsonSerializer.Serialize(WORLDBOSS, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(WORLDBOSSListFile, contents); ManualLogSource logger = Plugin.Logger; BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(17, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Save Database: OK"); } logger.LogDebug(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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown bool flag = default(bool); try { string json = File.ReadAllText(NPCSListFile); NPCS = JsonSerializer.Deserialize<List<NpcEncounterModel>>(json); json = File.ReadAllText(WORLDBOSSListFile); WORLDBOSS = JsonSerializer.Deserialize<List<BossEncounterModel>>(json); ManualLogSource logger = Plugin.Logger; BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(17, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Load Database: OK"); } logger.LogDebug(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 GetNPC(string NPCName, out NpcEncounterModel npc) { npc = NPCS.Where((NpcEncounterModel x) => x.name == NPCName).FirstOrDefault(); if (npc == null) { return false; } return true; } public static bool GetNPCFromEntity(Entity npcEntity, out NpcEncounterModel npc) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) npc = NPCS.Where(delegate(NpcEncounterModel x) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Entity npcEntity2 = x.npcEntity; return ((Entity)(ref npcEntity2)).Equals(npcEntity); }).FirstOrDefault(); if (npc == null) { return false; } return true; } public static bool AddNPC(string NPCName, int prefabGUIDOfNPC, int levelAbove, int lifetime) { if (GetNPC(NPCName, out var npc)) { throw new NPCExistException(); } npc = new NpcEncounterModel(); npc.name = NPCName; npc.PrefabGUID = prefabGUIDOfNPC; npc.levelAbove = levelAbove; npc.Lifetime = lifetime; NPCS.Add(npc); saveDatabase(); return true; } public static bool RemoveNPC(string NPCName) { if (GetNPC(NPCName, out var npc)) { NPCS.Remove(npc); saveDatabase(); return true; } throw new NPCDontExistException(); } public static bool GetBoss(string NPCName, out BossEncounterModel boss) { boss = WORLDBOSS.Where((BossEncounterModel x) => x.name == NPCName).FirstOrDefault(); if (boss == null) { return false; } return true; } public static bool GetBOSSFromEntity(Entity npcEntity, out BossEncounterModel boss) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) boss = WORLDBOSS.Where((BossEncounterModel x) => x.bossEntity.Equals(npcEntity)).FirstOrDefault(); if (boss == null) { return false; } return true; } public static bool AddBoss(string NPCName, int prefabGUIDOfNPC, int level, int multiplier, int lifetime) { //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_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) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (GetBoss(NPCName, out var boss)) { throw new WorldBossExistException(); } ConvertedAssetData val = ((PrefabCollectionSystem_Base)VWorld.Server.GetExistingSystem<PrefabCollectionSystem>()).PrefabDataLookup[new PrefabGUID(prefabGUIDOfNPC)]; string assetName = ((object)(FixedString128)(ref val.AssetName)).ToString(); boss = new BossEncounterModel(); boss.name = NPCName; boss.PrefabGUID = prefabGUIDOfNPC; boss.AssetName = assetName; boss.level = level; boss.multiplier = multiplier; boss.Lifetime = lifetime; WORLDBOSS.Add(boss); saveDatabase(); return true; } public static bool RemoveBoss(string BossName) { if (GetBoss(BossName, out var boss)) { WORLDBOSS.Remove(boss); saveDatabase(); return true; } throw new WorldBossDontExistException(); } public static T GetRandomItem<T>(this List<T> items) { if (items == null || items.Count == 0) { return default(T); } return items[Random.Next(items.Count)]; } } } namespace BloodyEncounters.DB.Models { internal class BossEncounterModel { public string name { get; set; } = string.Empty; public string AssetName { get; set; } = string.Empty; public string Hour { get; set; } = string.Empty; public string HourDespawn { get; set; } = string.Empty; public int PrefabGUID { get; set; } public int level { get; set; } public int multiplier { get; set; } public List<ItemEncounterModel> items { get; set; } = new List<ItemEncounterModel>(); public Entity? bossEntity { get; set; } = null; public NpcModel npcModel { get; set; } public float Lifetime { get; set; } public float x { get; set; } public float y { get; set; } public float z { get; set; } public List<ItemEncounterModel> GetItems() { return items; } public bool GetItem(int itemPrefabID, out ItemEncounterModel item) { item = items.Where((ItemEncounterModel x) => x.ItemID == itemPrefabID).FirstOrDefault(); if (item == null) { return false; } return true; } public bool GetItemFromName(string ItemName, out ItemEncounterModel item) { item = items.Where((ItemEncounterModel x) => x.name == ItemName).FirstOrDefault(); if (item == null) { return false; } return true; } public bool AddItem(string ItemName, int ItemPrefabID, int Stack, int Chance = 1) { if (!GetItem(ItemPrefabID, out var item)) { item = new ItemEncounterModel(); item.name = ItemName; item.ItemID = ItemPrefabID; item.Stack = Stack; item.Chance = Chance; items.Add(item); Database.saveDatabase(); return true; } throw new ProductExistException(); } public bool RemoveItem(string ItemName) { if (GetItemFromName(ItemName, out var item)) { items.Remove(item); Database.saveDatabase(); return true; } throw new ProductDontExistException(); } 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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) UnitSpawnerService.UnitSpawner.SpawnWithCallback(sender, new PrefabGUID(PrefabGUID), new float2(pos.x, pos.z), Lifetime, delegate(Entity e) { //IL_000c: 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_0024: Unknown result type (might be due to invalid IL or missing references) npcModel = GameData.Npcs.FromEntity(e); ModifyBoss(sender, e); }); return true; } public bool Spawn(Entity sender) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_00b9: Unknown result type (might be due to invalid IL or missing references) UnitSpawnerService.UnitSpawner.SpawnWithCallback(sender, new PrefabGUID(PrefabGUID), new float2(x, z), Lifetime, delegate(Entity e) { //IL_000c: 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_0024: Unknown result type (might be due to invalid IL or missing references) npcModel = GameData.Npcs.FromEntity(e); ModifyBoss(sender, e); }); string value = PluginConfig.SpawnMessageBossTemplate.Value; value = value.Replace("#time#", FontColorChatSystem.Yellow($"{Lifetime / 60f}")); value = value.Replace("#worldbossname#", FontColorChatSystem.Yellow(name ?? "")); ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, FontColorChatSystem.Green(value ?? "")); return true; } public bool DropItems(string vblood) { //IL_0070: 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) PrefabGUID itemGuid = default(PrefabGUID); foreach (ItemEncounterModel item in items) { if (!probabilityGeneratingReward(item.Chance)) { continue; } List<string> killers = WorldBossSystem.GetKillers(vblood); foreach (string item2 in killers) { ((PrefabGUID)(ref itemGuid))..ctor(item.ItemID); int stack = item.Stack; UserModel userByCharacterName = GameData.Users.GetUserByCharacterName(item2); if (!userByCharacterName.TryGiveItem(itemGuid, stack, out var _)) { userByCharacterName.DropItemNearby(itemGuid, stack); } } } bossEntity = null; HourDespawn = DateTime.Parse(Hour).AddSeconds(Lifetime).ToString("HH:mm:ss"); return true; } private static bool probabilityGeneratingReward(int percentage) { int num = new Random().Next(1, 100); if (num <= percentage * 100) { return true; } return false; } public void ModifyBoss(Entity user, Entity boss) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) int num = GameData.Users.Online.Count(); UnitLevel componentData = boss.Read<UnitLevel>(); componentData.Level = level; boss.Write<UnitLevel>(componentData); Health val = boss.Read<Health>(); ((ModifiableFloat)(ref val.MaxHealth)).Value = ModifiableFloat.op_Implicit(val.MaxHealth) * (float)(num * multiplier); val.Value = ((ModifiableFloat)(ref val.MaxHealth)).Value; boss.Write<Health>(val); if (BuffSystem.BuffBoss(boss, user, new PrefabGUID(PluginConfig.BuffForWorldBoss.Value), 0)) { } RenameBoss(boss, name); bossEntity = boss; } public void SetLocation(float3 position) { //IL_0002: 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_001c: Unknown result type (might be due to invalid IL or missing references) x = position.x; z = position.z; y = position.y; Database.saveDatabase(); } private static void RenameBoss(Entity merchant, string nameMerchant) { } internal void SetAssetName(string v) { AssetName = v; Database.saveDatabase(); } internal void SetHour(string hour) { Hour = hour; HourDespawn = DateTime.Parse(hour).AddSeconds(Lifetime).ToString("HH:mm:ss"); Database.saveDatabase(); } internal void SetHourDespawn() { HourDespawn = DateTime.Now.AddSeconds(Lifetime).ToString("HH:mm:ss"); Database.saveDatabase(); } } internal class ItemEncounterModel { public string name { get; set; } public int ItemID { get; set; } public int Stack { get; set; } public int Chance { get; set; } = 1; public string Color { get; set; } = "#daa520"; } internal class NpcEncounterModel { public string name { get; set; } = string.Empty; public int PrefabGUID { get; set; } public int levelAbove { get; set; } public List<ItemEncounterModel> items { get; set; } = new List<ItemEncounterModel>(); public Entity npcEntity { get; set; } = default(Entity); public NpcModel npcModel { get; set; } public float Lifetime { get; set; } public List<ItemEncounterModel> GetItems() { return items; } public bool GetItem(int itemPrefabID, out ItemEncounterModel item) { item = items.Where((ItemEncounterModel x) => x.ItemID == itemPrefabID).FirstOrDefault(); if (item == null) { return false; } return true; } public bool GetItemFromName(string ItemName, out ItemEncounterModel item) { item = items.Where((ItemEncounterModel x) => x.name == ItemName).FirstOrDefault(); if (item == null) { return false; } return true; } public bool AddItem(string ItemName, int ItemPrefabID, int Stack) { if (!GetItem(ItemPrefabID, out var item)) { item = new ItemEncounterModel(); item.name = ItemName; item.ItemID = ItemPrefabID; item.Stack = Stack; items.Add(item); Database.saveDatabase(); return true; } throw new ProductExistException(); } public bool RemoveItem(string ItemName) { if (GetItemFromName(ItemName, out var item)) { items.Remove(item); Database.saveDatabase(); return true; } throw new ProductDontExistException(); } 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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) UnitSpawnerService.UnitSpawner.SpawnWithCallback(sender, new PrefabGUID(PrefabGUID), new float2(pos.x, pos.z), Lifetime, delegate(Entity e) { //IL_0007: 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_0036: 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) npcEntity = e; npcModel = GameData.Npcs.FromEntity(npcEntity); ModifyNPC(sender, e); }); return true; } public void ModifyNPC(Entity user, Entity npc) { //IL_0006: 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_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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0056: Unknown result type (might be due to invalid IL or missing references) float level = GameData.Users.FromEntity(user).Character.Equipment.Level; EntityManager entityManager = Plugin.World.EntityManager; UnitLevel componentData = ((EntityManager)(ref entityManager)).GetComponentData<UnitLevel>(npc); componentData.Level = (int)(level + (float)levelAbove); entityManager = Plugin.World.EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<UnitLevel>(npc, componentData); RenameNPCt(npc, name); } private static void RenameNPCt(Entity merchant, string nameMerchant) { } } } namespace BloodyEncounters.Configuration { internal class PluginConfig { private static ConfigFile _mainConfig; public static ConfigEntry<bool> Enabled { get; private set; } public static ConfigEntry<bool> SkipPlayersInCastle { get; private set; } public static ConfigEntry<int> EncounterTimerMin { get; private set; } public static ConfigEntry<int> EncounterTimerMax { get; private set; } public static ConfigEntry<int> EncounterMinLevel { get; private set; } public static ConfigEntry<int> BuffForWorldBoss { get; private set; } public static ConfigEntry<string> EncounterMessageTemplate { get; private set; } public static ConfigEntry<string> RewardMessageTemplate { get; private set; } public static ConfigEntry<string> SpawnMessageBossTemplate { get; private set; } public static ConfigEntry<string> DespawnMessageBossTemplate { get; private set; } public static ConfigEntry<string> KillMessageBossTemplate { get; private set; } public static ConfigEntry<string> RewardAnnouncementMessageTemplate { get; private set; } public static ConfigEntry<string> VBloodFinalConcatCharacters { get; private set; } public static ConfigEntry<bool> NotifyAdminsAboutEncountersAndRewards { get; private set; } public static ConfigEntry<bool> NotifyAllPlayersAboutRewards { get; private set; } public static ConfigEntry<bool> SkipPlayersInCombat { get; private set; } public static void Initialize() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown string path = Paths.ConfigPath ?? Path.Combine("BepInEx", "config"); string text = Path.Combine(path, "BloodyEncounters"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } string text2 = Path.Combine(text, "BloodyEncounters.cfg"); _mainConfig = (File.Exists(text2) ? new ConfigFile(text2, false) : new ConfigFile(text2, true)); Enabled = _mainConfig.Bind<bool>("Main", "Enabled", true, "Determines whether the random encounter timer is enabled or not."); SkipPlayersInCastle = _mainConfig.Bind<bool>("Main", "SkipPlayersInCastle", true, "When enabled, players who are in a castle are excluded from encounters"); SkipPlayersInCombat = _mainConfig.Bind<bool>("Main", "SkipPlayersInCombat", false, "When enabled, players who are in combat are excluded from the random encounters."); EncounterTimerMin = _mainConfig.Bind<int>("Main", "EncounterTimerMin", 1200, "Minimum seconds before a new encounter is initiated. This value is divided by the online users count."); EncounterTimerMax = _mainConfig.Bind<int>("Main", "EncounterTimerMax", 2400, "Maximum seconds before a new encounter is initiated. This value is divided by the online users count."); EncounterMinLevel = _mainConfig.Bind<int>("Main", "EncounterMinLevel", 10, "The lower value for the Player level for encounter."); EncounterMessageTemplate = _mainConfig.Bind<string>("Main", "EncounterMessageTemplate", "You have encountered a <color=#daa520>{0}</color>. You have <color=#daa520>{1}</color> seconds to kill it for a chance of a random reward.", "System message template for the encounter."); RewardMessageTemplate = _mainConfig.Bind<string>("Main", "RewardMessageTemplate", "Congratulations. Your reward: <color={0}>{1}</color>.", "System message template for the reward."); RewardAnnouncementMessageTemplate = _mainConfig.Bind<string>("Main", "RewardAnnouncementMessageTemplate", "{0} earned an encounter reward: <color={1}>{2}</color>.", "System message template for the reward announcement."); NotifyAdminsAboutEncountersAndRewards = _mainConfig.Bind<bool>("Main", "NotifyAdminsAboutEncountersAndRewards", true, "If enabled, all online admins are notified about encounters and rewards."); NotifyAllPlayersAboutRewards = _mainConfig.Bind<bool>("Main", "NotifyAllPlayersAboutRewards", false, "When enabled, all online players are notified about any player's rewards."); KillMessageBossTemplate = _mainConfig.Bind<string>("Main", "KillMessageBossTemplate", "The World Boss has been defeated. Congratulations to #user# for beating #vblood#!", "The message that will appear globally once the boss gets killed."); SpawnMessageBossTemplate = _mainConfig.Bind<string>("Main", "SpawnMessageBossTemplate", "A World Boss #worldbossname# has been summon you got #time# minutes to defeat it!. Use the command <color=#FBC01E>.encounter worldboss tp</color> to teleport to his position and start the fight!", "The message that will appear globally one the boss gets spawned."); DespawnMessageBossTemplate = _mainConfig.Bind<string>("Main", "DespawnMessageBossTemplate", "You failed to kill the World Boss #worldbossname# in time.", "The message that will appear globally if the players failed to kill the boss."); BuffForWorldBoss = _mainConfig.Bind<int>("Main", "BuffForWorldBoss", 1163490655, "Buff that applies to each of the World Bosses that we create with our mod."); VBloodFinalConcatCharacters = _mainConfig.Bind<string>("Main", "WorldBossFinalConcatCharacters", "and", "Final string for concat two or more players kill a WorldBoss Boss."); } public static void Destroy() { _mainConfig.Clear(); } private static string CleanupName(string name) { Regex regex = new Regex("[^a-zA-Z0-9 -]"); return regex.Replace(name, ""); } } } namespace BloodyEncounters.Components { public class Timer : IDisposable { private bool _enabled; private bool _isRunning; private DateTime _lastRunTime; private TimeSpan _delay; private Action<World> _action; private Func<object, TimeSpan> _delayAction; public void Start(Action<World> action, TimeSpan delay) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown _delay = delay; _lastRunTime = DateTime.UtcNow - delay; _action = action; _enabled = true; GameFrame.OnUpdate += new GameFrameUpdateEventHandler(GameFrame_OnUpdate); } public void Start(Action<World> action, Func<object, TimeSpan> delayAction) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown _delayAction = delayAction; _delay = _delayAction(1); _lastRunTime = DateTime.UtcNow; _action = action; _enabled = true; GameFrame.OnUpdate += new GameFrameUpdateEventHandler(GameFrame_OnUpdate); } private void GameFrame_OnUpdate() { Update(GameData.World); } private void Update(World world) { if (!_enabled || _isRunning || _lastRunTime + _delay >= DateTime.UtcNow) { return; } _isRunning =