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.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using DyWorldRising.Config; using DyWorldRising.Data; using DyWorldRising.Persistence; using DyWorldRising.Systems; using HarmonyLib; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.Network; using ProjectM.Scripting; using Stunlock.Core; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("DyWorld Rising")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Heat-based faction aggression system for V Rising")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("DyWorldRising")] [assembly: AssemblyTitle("DyWorldRising")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace DyWorldRising { [BepInPlugin("com.dysoch.dyworldrising", "DyWorld Rising", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private Harmony _harmony; private HeatDecayService _decayService; private SpawnOrchestrator _spawnOrchestrator; private SiegeOrchestrator _siegeOrchestrator; public static ManualLogSource Log { get; private set; } internal static HeatPersistenceService? Persistence { get; private set; } public override void Load() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown Log = ((BasePlugin)this).Log; ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Loading "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("DyWorld Rising"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("0.1.0"); } log.LogInfo(val); DyWorldConfig.Init(((BasePlugin)this).Config); Persistence = new HeatPersistenceService(Paths.BepInExRootPath); Persistence.Load(); _decayService = new HeatDecayService(); _decayService.Start(); _spawnOrchestrator = new SpawnOrchestrator(); _spawnOrchestrator.Start(); _siegeOrchestrator = new SiegeOrchestrator(); _siegeOrchestrator.Start(); _harmony = new Harmony("com.dysoch.dyworldrising"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); CommandRegistry.RegisterAll(); Log.LogInfo((object)"[DyWorld Rising] Heat and Siege systems active."); } public override bool Unload() { Persistence?.Save(); _decayService?.Dispose(); _spawnOrchestrator?.Dispose(); _siegeOrchestrator?.Dispose(); CommandRegistry.UnregisterAssembly(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.dysoch.dyworldrising"; public const string PLUGIN_NAME = "DyWorld Rising"; public const string PLUGIN_VERSION = "0.1.0"; } } namespace DyWorldRising.Systems { public static class CastleSafetyChecker { private static int _diagCounter; public static bool IsInsideCastle(EntityManager em, Entity playerCharacter) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) bool flag2 = default(bool); try { if (!((EntityManager)(ref em)).Exists(playerCharacter)) { return false; } if (!((EntityManager)(ref em)).HasComponent(playerCharacter)) { return false; } if (!((EntityManager)(ref em)).HasComponent(playerCharacter)) { return false; } LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(playerCharacter); float3 position = ((LocalToWorld)(ref componentData)).Position; int value = ((EntityManager)(ref em)).GetComponentData(playerCharacter).Value; EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); int length = val2.Length; int num = 0; bool flag = false; try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (((EntityManager)(ref em)).HasComponent(current) && ((EntityManager)(ref em)).GetComponentData(current).Value == value) { num++; if (PositionInsideTerritory(em, current, position)) { flag = true; break; } } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } if (++_diagCounter >= 300) { _diagCounter = 0; ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(87, 6, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DyWorld Rising] CastleCheck: territories="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(length); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", owned="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("playerTeam="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", pos=("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(position.x, "F0"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(position.z, "F0"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("), insideCastle="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(flag); } log.LogInfo(val3); } return flag; } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[DyWorld Rising] CastleSafetyChecker: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); } log2.LogWarning(val4); } return false; } private static bool PositionInsideTerritory(EntityManager em, Entity territory, float3 pos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_003b: Unknown result type (might be due to invalid IL or missing references) if (!((EntityManager)(ref em)).HasComponent(territory)) { return false; } LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(territory); float3 position = ((LocalToWorld)(ref componentData)).Position; float value = DyWorldConfig.SafeCastleRadius.Value; float num = pos.x - position.x; float num2 = pos.z - position.z; return num * num + num2 * num2 < value * value; } } public static class DayNightHelper { private const float DayDurationSeconds = 3600f; private const int DayStartHour = 9; private const int DayEndHour = 17; public static float GetNormalisedTime(World? _ = null) { return (float)(DateTimeOffset.UtcNow.TimeOfDay.TotalSeconds % 3600.0 / 3600.0); } public static bool IsNight(World? _ = null) { float normalisedTime = GetNormalisedTime(); float num = 0.375f; float num2 = 17f / 24f; if (!(normalisedTime < num)) { return normalisedTime >= num2; } return true; } public static bool IsDawnOrDusk(World? _ = null) { float normalisedTime = GetNormalisedTime(); float num = 0.375f; float num2 = 17f / 24f; float num3 = 1f / 48f; if (!(normalisedTime > num - num3) || !(normalisedTime < num + num3)) { if (normalisedTime > num2 - num3) { return normalisedTime < num2 + num3; } return false; } return true; } } public readonly struct AllianceEntry { public readonly VRisingFaction Ally; public readonly float HeatShare; public AllianceEntry(VRisingFaction ally, float share) { Ally = ally; HeatShare = share; } } public static class FactionAlliances { private static readonly Dictionary _alliances = new Dictionary { [VRisingFaction.Militia] = new AllianceEntry[1] { new AllianceEntry(VRisingFaction.ChurchOfLuminance, 0.2f) }, [VRisingFaction.ChurchOfLuminance] = new AllianceEntry[1] { new AllianceEntry(VRisingFaction.Militia, 0.2f) }, [VRisingFaction.Bandits] = new AllianceEntry[1] { new AllianceEntry(VRisingFaction.Blackfang, 0.15f) }, [VRisingFaction.Blackfang] = new AllianceEntry[1] { new AllianceEntry(VRisingFaction.Bandits, 0.15f) }, [VRisingFaction.Undead] = new AllianceEntry[1] { new AllianceEntry(VRisingFaction.Cursed, 0.1f) }, [VRisingFaction.Cursed] = new AllianceEntry[2] { new AllianceEntry(VRisingFaction.Undead, 0.1f), new AllianceEntry(VRisingFaction.Werewolves, 0.1f) }, [VRisingFaction.Werewolves] = new AllianceEntry[1] { new AllianceEntry(VRisingFaction.Cursed, 0.1f) } }; public static bool TryGetAllies(VRisingFaction faction, out AllianceEntry[] allies) { return _alliances.TryGetValue(faction, out allies); } } public enum VRisingFaction { Unknown, Militia, ChurchOfLuminance, Bandits, Werewolves, Undead, Gloomrot, DunleyFarmers, Legion, Creature, Blackfang, Cursed } public class FactionData { public string DisplayName { get; init; } = string.Empty; public NamedPrefab[] PatrolUnits { get; init; } = Array.Empty(); public TieredVBlood[] VBloods { get; init; } = Array.Empty(); } public readonly struct NamedPrefab { public readonly string Name; public readonly PrefabGUID Guid; public readonly int Level; public NamedPrefab(string name, int hash, int level = 0) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Name = name; Guid = new PrefabGUID(hash); Level = level; } } public static class FactionDatabase { private static readonly Dictionary _resolvedByName = new Dictionary(); private static readonly Dictionary _data = new Dictionary { [VRisingFaction.Militia] = new FactionData { DisplayName = "Militia", PatrolUnits = new NamedPrefab[11] { new NamedPrefab("CHAR_Militia_Guard", 1730498275, 28), new NamedPrefab("CHAR_Militia_Longbowman", 203103783, 32), new NamedPrefab("CHAR_Militia_Crossbow", 956965183, 30), new NamedPrefab("CHAR_Militia_Heavy", 2005508157, 36), new NamedPrefab("CHAR_Militia_Light", -63435588, 22), new NamedPrefab("CHAR_Militia_Bomber", 847893333, 26), new NamedPrefab("CHAR_Militia_Horseman", -235172198, 34), new NamedPrefab("CHAR_Militia_Devoted", 1660801216, 30), new NamedPrefab("CHAR_Militia_Hound", -249647316, 24), new NamedPrefab("CHAR_Militia_Rider", -1719333743, 34), new NamedPrefab("CHAR_Militia_Miner_Standard", -1072754152, 20) }, VBloods = new TieredVBlood[7] { new TieredVBlood("Vincent the Frostbringer", "CHAR_Militia_Guard_VBlood", -29797003, 40), new TieredVBlood("Christina the Sun Priestess", "CHAR_Militia_Nun_VBlood", -99012450, 44), new TieredVBlood("Tristan the Vampire Hunter", "CHAR_VHunter_Leader_VBlood", -1449631170, 46), new TieredVBlood("The Bishop of Dunley", "CHAR_Militia_BishopOfDunley_VBlood", -680831417, 52), new TieredVBlood("Fabian the Knight Captain", "CHAR_Militia_Fabian_VBlood", 619948378, 48), new TieredVBlood("The Hound Master", "CHAR_Militia_HoundMaster_VBlood", -784265984, 42), new TieredVBlood("Octavian the Militia Captain", "CHAR_Militia_Leader_VBlood", 1688478381, 58) } }, [VRisingFaction.Bandits] = new FactionData { DisplayName = "Bandits", PatrolUnits = new NamedPrefab[10] { new NamedPrefab("CHAR_Bandit_Thug", -301730941, 12), new NamedPrefab("CHAR_Bandit_Stalker", -309264723, 18), new NamedPrefab("CHAR_Bandit_Trapper", -589412777, 16), new NamedPrefab("CHAR_Bandit_Hunter", -1301144178, 20), new NamedPrefab("CHAR_Bandit_Bomber", -1128238456, 22), new NamedPrefab("CHAR_Bandit_Deadeye", -1030822544, 20), new NamedPrefab("CHAR_Bandit_Scout", 1220569089, 14), new NamedPrefab("CHAR_Bandit_Rascal", -1194643220, 10), new NamedPrefab("CHAR_Bandit_Thief", 923140362, 14), new NamedPrefab("CHAR_Bandit_Mugger", 2057508774, 12) }, VBloods = new TieredVBlood[6] { new TieredVBlood("Rufus the Foreman", "CHAR_Bandit_Foreman_VBlood", 2122229952, 16), new TieredVBlood("Keely the Frost Archer", "CHAR_Bandit_Frostarrow_VBlood", 1124739990, 20), new TieredVBlood("Errol the Stonebreaker", "CHAR_Bandit_StoneBreaker_VBlood", -2025101517, 20), new TieredVBlood("Lidia the Chaos Archer", "CHAR_Bandit_Chaosarrow_VBlood", 763273073, 26), new TieredVBlood("Clive the Firestarter", "CHAR_Bandit_Bomber_VBlood", 1896428751, 30), new TieredVBlood("Quincey the Bandit King", "CHAR_Bandit_Tourok_VBlood", -1659822956, 37) } }, [VRisingFaction.ChurchOfLuminance] = new FactionData { DisplayName = "Church of Luminance", PatrolUnits = new NamedPrefab[11] { new NamedPrefab("CHAR_ChurchOfLight_Archer", 426583055, 36), new NamedPrefab("CHAR_ChurchOfLight_Paladin", 1728773109, 46), new NamedPrefab("CHAR_ChurchOfLight_Cleric", -1464869978, 40), new NamedPrefab("CHAR_ChurchOfLight_Lightweaver", 1185952775, 44), new NamedPrefab("CHAR_ChurchOfLight_Priest", 1406393857, 38), new NamedPrefab("CHAR_ChurchOfLight_Footman", 2128996433, 32), new NamedPrefab("CHAR_ChurchOfLight_Knight_2H", -930333806, 50), new NamedPrefab("CHAR_ChurchOfLight_Knight_Shield", 794228023, 48), new NamedPrefab("CHAR_ChurchOfLight_Rifleman", 1148936156, 42), new NamedPrefab("CHAR_ChurchOfLight_SlaveMaster_Enforcer", 891705701, 52), new NamedPrefab("CHAR_ChurchOfLight_SlaveRuffian", -1875351031, 36) }, VBloods = new TieredVBlood[4] { new TieredVBlood("Magnus the Overseer", "CHAR_ChurchOfLight_Overseer_VBlood", -26105228, 41), new TieredVBlood("Azariel the Sunbringer", "CHAR_ChurchOfLight_Cardinal_VBlood", 114912615, 68), new TieredVBlood("Solarus the Immaculate", "CHAR_ChurchOfLight_Paladin_VBlood", -740796338, 82), new TieredVBlood("The Sommelier", "CHAR_ChurchOfLight_Sommelier_VBlood", 192051202, 60) } }, [VRisingFaction.Undead] = new FactionData { DisplayName = "Undead", PatrolUnits = new NamedPrefab[13] { new NamedPrefab("CHAR_Undead_Necromancer", -572568236, 36), new NamedPrefab("CHAR_Undead_Assassin", -1365627158, 28), new NamedPrefab("CHAR_Undead_Priest", -1653554504, 32), new NamedPrefab("CHAR_Undead_RottingGhoul", -1722506709, 20), new NamedPrefab("CHAR_Undead_SkeletonSoldier_Armored_Farbane", -837329073, 22), new NamedPrefab("CHAR_Undead_SkeletonSoldier_Armored_Dunley", 952695804, 38), new NamedPrefab("CHAR_Undead_SkeletonMage", -1287507270, 34), new NamedPrefab("CHAR_Undead_SkeletonApprentice", -1789347076, 18), new NamedPrefab("CHAR_Undead_Guardian", -1967480038, 40), new NamedPrefab("CHAR_Undead_ShadowSoldier", 678628353, 36), new NamedPrefab("CHAR_Undead_UndyingGhoul", 1640311129, 26), new NamedPrefab("CHAR_Undead_GhostBanshee", -1146194149, 30), new NamedPrefab("CHAR_Undead_GhostAssassin", 849891426, 32) }, VBloods = new TieredVBlood[8] { new TieredVBlood("Nicholaus the Fallen", "CHAR_Undead_Priest_VBlood", 153390636, 37), new TieredVBlood("The Bishop of Death", "CHAR_Undead_BishopOfDeath_VBlood", 577478542, 48), new TieredVBlood("Foulrot the Soultaker", "CHAR_Undead_ZealousCultist_VBlood", -1208888966, 62), new TieredVBlood("The Bishop of Shadows", "CHAR_Undead_BishopOfShadows_VBlood", 939467639, 66), new TieredVBlood("The Undead Infiltrator", "CHAR_Undead_Infiltrator_VBlood", 613251918, 50), new TieredVBlood("The Undead Leader", "CHAR_Undead_Leader_Vblood", -1365931036, 55), new TieredVBlood("The Cursed Smith", "CHAR_Undead_CursedSmith_VBlood", 326378955, 44), new TieredVBlood("The Arena Champion", "CHAR_Undead_ArenaChampion_VBlood", -753453016, 70) } }, [VRisingFaction.Werewolves] = new FactionData { DisplayName = "Werewolves", PatrolUnits = new NamedPrefab[2] { new NamedPrefab("CHAR_Farmlands_HostileVillager_Werewolf", -951976780, 36), new NamedPrefab("CHAR_WerewolfChieftain_Human", -1505705712, 56) }, VBloods = new TieredVBlood[1] { new TieredVBlood("Willfred the Werewolf Chief", "CHAR_WerewolfChieftain_VBlood_GateBoss_Major", 2079933370, 64) } }, [VRisingFaction.Gloomrot] = new FactionData { DisplayName = "Gloomrot", PatrolUnits = new NamedPrefab[9] { new NamedPrefab("CHAR_Gloomrot_Technician", 820492683, 55), new NamedPrefab("CHAR_Gloomrot_Railgunner", 1732477970, 60), new NamedPrefab("CHAR_Gloomrot_TractorBeamer", -293507834, 58), new NamedPrefab("CHAR_Gloomrot_Tazer", 674807351, 56), new NamedPrefab("CHAR_Gloomrot_Pyro", -322293503, 52), new NamedPrefab("CHAR_Gloomrot_SentryOfficer", 1401026468, 62), new NamedPrefab("CHAR_Gloomrot_AceIncinerator", 1756241788, 64), new NamedPrefab("CHAR_Gloomrot_Batoon", -1707267769, 54), new NamedPrefab("CHAR_Gloomrot_Technician_Labworker", -825299465, 50) }, VBloods = new TieredVBlood[8] { new TieredVBlood("The Gloomrot Purifier", "CHAR_Gloomrot_Purifier_VBlood", 106480588, 58), new TieredVBlood("Iva the Rampant", "CHAR_Gloomrot_Iva_VBlood", 172235178, 60), new TieredVBlood("Jade the Vampire Hunter", "CHAR_VHunter_Jade_VBlood", -1968372384, 62), new TieredVBlood("The Professor", "CHAR_Gloomrot_TheProfessor_VBlood", 814083983, 65), new TieredVBlood("The Gloomrot Monster", "CHAR_Gloomrot_Monster_VBlood", 1233988687, 68), new TieredVBlood("Voltatia the Power Master", "CHAR_Gloomrot_Voltage_VBlood", -1101874342, 77), new TieredVBlood("The Railgun Sergeant", "CHAR_Gloomrot_RailgunSergeant_VBlood", 2054432370, 64), new TieredVBlood("The Archmage", "CHAR_ArchMage_VBlood", -2013903325, 70) } }, [VRisingFaction.DunleyFarmers] = new FactionData { DisplayName = "Dunley Farmers", PatrolUnits = new NamedPrefab[8] { new NamedPrefab("CHAR_Farmlands_Villager_Male", 1887807944, 26), new NamedPrefab("CHAR_Farmlands_Villager_Female", 525027204, 26), new NamedPrefab("CHAR_Farmlands_Farmer", -1342764880, 24), new NamedPrefab("CHAR_Farmlands_Woodcutter_Standard", -893091615, 28), new NamedPrefab("CHAR_Farmlands_HostileVillager_Male_Club", -164116132, 22), new NamedPrefab("CHAR_Farmlands_HostileVillager_Male_Shovel", -864975423, 22), new NamedPrefab("CHAR_Farmlands_HostileVillager_Female_Pitchfork", 1576267559, 22), new NamedPrefab("CHAR_Farmlands_HostileVillager_Female_FryingPan", 729746981, 22) }, VBloods = new TieredVBlood[2] { new TieredVBlood("Beatrice the Tailor", "CHAR_Villager_Tailor_VBlood", -1942352521, 38), new TieredVBlood("The Cursed Wanderer", "CHAR_Villager_CursedWanderer_VBlood", 109969450, 42) } }, [VRisingFaction.Legion] = new FactionData { DisplayName = "Legion", PatrolUnits = new NamedPrefab[8] { new NamedPrefab("CHAR_Legion_NightMaiden", -494298686, 62), new NamedPrefab("CHAR_Legion_Assassin", -1076780215, 64), new NamedPrefab("CHAR_Legion_Shadowkin", 1980594081, 60), new NamedPrefab("CHAR_Legion_Nightmare", -1009917656, 68), new NamedPrefab("CHAR_Legion_Vargulf", -653348998, 66), new NamedPrefab("CHAR_Legion_BloodProphet", 1912966420, 58), new NamedPrefab("CHAR_Legion_Dreadhorn", 981369753, 64), new NamedPrefab("CHAR_Legion_Gargoyle", -65981941, 60) }, VBloods = new TieredVBlood[5] { new TieredVBlood("The Blood Knight", "CHAR_Vampire_BloodKnight_VBlood", 495971434, 60), new TieredVBlood("The Ice Ranger", "CHAR_Vampire_IceRanger_VBlood", 795262842, 66), new TieredVBlood("The Bat Vampire", "CHAR_BatVampire_VBlood", 1112948824, 68), new TieredVBlood("The High Lord", "CHAR_Vampire_HighLord_VBlood", -496360395, 78), new TieredVBlood("Dracula", "CHAR_Vampire_Dracula_VBlood", -327335305, 90) } }, [VRisingFaction.Creature] = new FactionData { DisplayName = "Creatures", PatrolUnits = new NamedPrefab[18] { new NamedPrefab("CHAR_Forest_Wolf", -1418430647, 8), new NamedPrefab("CHAR_Forest_Bear_Standard", 1043643344, 26), new NamedPrefab("CHAR_Forest_Deer", 1897056612, 4), new NamedPrefab("CHAR_Forest_Moose", -831097925, 22), new NamedPrefab("CHAR_Forest_AngryMoose", 2097040330, 28), new NamedPrefab("CHAR_Spider_Melee", 2136899683, 14), new NamedPrefab("CHAR_Spider_Range", 2103131615, 16), new NamedPrefab("CHAR_Spider_Forest", -581295882, 18), new NamedPrefab("CHAR_Spider_Forestling", 574276383, 12), new NamedPrefab("CHAR_Spider_Broodmother", 342127250, 22), new NamedPrefab("CHAR_Winter_Wolf", 134039094, 18), new NamedPrefab("CHAR_Winter_Bear_Standard", 2041915372, 30), new NamedPrefab("CHAR_Winter_Moose", -779632831, 26), new NamedPrefab("CHAR_Harpy_Scratcher", 1462269123, 40), new NamedPrefab("CHAR_Harpy_Dasher", -1846851895, 42), new NamedPrefab("CHAR_Harpy_Sorceress", 1224283123, 44), new NamedPrefab("CHAR_Mutant_Wolf", 572729167, 48), new NamedPrefab("CHAR_Mutant_Bear_Standard", 1938756250, 52) }, VBloods = new TieredVBlood[10] { new TieredVBlood("Alpha Wolf", "CHAR_Forest_Wolf_VBlood", -1905691330, 16), new TieredVBlood("Ungora the Spider Queen", "CHAR_Spider_Queen_VBlood", -548489519, 27), new TieredVBlood("Putrid Rat", "CHAR_Vermin_DireRat_VBlood", -2039908510, 30), new TieredVBlood("Polora the Feywalker", "CHAR_Poloma_VBlood", -484556888, 34), new TieredVBlood("Ferocious Bear", "CHAR_Forest_Bear_Dire_Vblood", -1391546313, 36), new TieredVBlood("The Harpy Matriarch", "CHAR_Harpy_Matriarch_VBlood", 685266977, 54), new TieredVBlood("The Manticore", "CHAR_Manticore_VBlood", -393555055, 68), new TieredVBlood("The Wendigo", "CHAR_Wendigo_VBlood", 24378719, 70), new TieredVBlood("The Winter Yeti", "CHAR_Winter_Yeti_VBlood", -1347412392, 60), new TieredVBlood("The Geomancer", "CHAR_Geomancer_Human_VBlood", -1065970933, 55) } }, [VRisingFaction.Blackfang] = new FactionData { DisplayName = "Blackfang", PatrolUnits = new NamedPrefab[9] { new NamedPrefab("CHAR_Blackfang_Peon", -1562098554, 14), new NamedPrefab("CHAR_Blackfang_Striker", 761646020, 18), new NamedPrefab("CHAR_Blackfang_Sentinel", 1531777139, 22), new NamedPrefab("CHAR_Blackfang_DartFlinger", 1209580976, 20), new NamedPrefab("CHAR_Blackfang_Lurker", -1733829912, 20), new NamedPrefab("CHAR_Blackfang_Viper", -436956599, 24), new NamedPrefab("CHAR_Blackfang_Venomblade", 1864177126, 26), new NamedPrefab("CHAR_Blackfang_Alchemist", 326501064, 22), new NamedPrefab("CHAR_Blackfang_WoodCarver", -1508046438, 18) }, VBloods = new TieredVBlood[5] { new TieredVBlood("Valyr the Cunning", "CHAR_Blackfang_Valyr_VBlood", 173259239, 26), new TieredVBlood("Lucie the Scourge", "CHAR_Blackfang_Lucie_VBlood", 1295855316, 28), new TieredVBlood("Livith the Mad", "CHAR_Blackfang_Livith_VBlood", -1383529374, 32), new TieredVBlood("Morgana the Witch Queen", "CHAR_Blackfang_Morgana_VBlood", 591725925, 40), new TieredVBlood("The Carver Boss", "CHAR_Blackfang_CarverBoss_VBlood", -1669199769, 36) } }, [VRisingFaction.Cursed] = new FactionData { DisplayName = "Cursed", PatrolUnits = new NamedPrefab[9] { new NamedPrefab("CHAR_Cursed_Wolf", -218175217, 38), new NamedPrefab("CHAR_Cursed_Bear_Standard", -559819989, 44), new NamedPrefab("CHAR_Cursed_Witch", -56441915, 40), new NamedPrefab("CHAR_Cursed_MonsterToad", 575918722, 44), new NamedPrefab("CHAR_Cursed_ToadSpitter", 1478790879, 38), new NamedPrefab("CHAR_Cursed_Nightlurker", -2046268156, 40), new NamedPrefab("CHAR_Cursed_Mosquito", -744966291, 36), new NamedPrefab("CHAR_Corrupted_Wolf", 616274140, 50), new NamedPrefab("CHAR_Corrupted_Bear_Standard", -1697944553, 52) }, VBloods = new TieredVBlood[3] { new TieredVBlood("The Cursed Witch", "CHAR_Cursed_Witch_VBlood", -910296704, 40), new TieredVBlood("The Toad King", "CHAR_Cursed_ToadKing_VBlood", -203043163, 44), new TieredVBlood("The Cursed Mountain Beast", "CHAR_Cursed_MountainBeast_VBlood", -1936575244, 56) } } }; private static Dictionary _prefabIndex = BuildPrefabIndex(); public static int ResolvedCount => _resolvedByName.Count; public static IEnumerable AllFactions => _data.Keys; public static void AutoResolve(PrefabCollectionSystem prefabSystem) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_00b4: 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) //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) _resolvedByName.Clear(); Dictionary dictionary = new Dictionary(StringComparer.Ordinal); Enumerator enumerator = prefabSystem.SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; dictionary[current.Key] = current.Value; } if (dictionary.Count == 0) { Plugin.Log.LogWarning((object)"[DyWorld Rising] AutoResolve: SpawnableNameToPrefabGuidDictionary is empty — running too early? Will retry next frame."); return; } int resolved = 0; int mismatch = 0; int failed = 0; foreach (KeyValuePair datum in _data) { datum.Deconstruct(out var _, out var value); FactionData factionData = value; NamedPrefab[] patrolUnits = factionData.PatrolUnits; PrefabGUID guid; for (int i = 0; i < patrolUnits.Length; i++) { NamedPrefab namedPrefab = patrolUnits[i]; string name = namedPrefab.Name; guid = namedPrefab.Guid; Resolve(dictionary, name, ((PrefabGUID)(ref guid)).GuidHash, ref resolved, ref mismatch, ref failed); } TieredVBlood[] vBloods = factionData.VBloods; for (int i = 0; i < vBloods.Length; i++) { TieredVBlood tieredVBlood = vBloods[i]; string name2 = (string.IsNullOrEmpty(tieredVBlood.PrefabName) ? tieredVBlood.DisplayName : tieredVBlood.PrefabName); guid = tieredVBlood.Guid; Resolve(dictionary, name2, ((PrefabGUID)(ref guid)).GuidHash, ref resolved, ref mismatch, ref failed); } } RebuildPrefabIndex(); ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(80, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] AutoResolve complete: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(resolved); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ok, "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(mismatch); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" hash mismatches logged, "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(failed); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" not found."); } log.LogInfo(val); } private static void Resolve(Dictionary managed, string name, int fallbackHash, ref int resolved, ref int mismatch, ref int failed) { //IL_0022: 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_0042: Expected O, but got Unknown PrefabGUID value; if (string.IsNullOrEmpty(name)) { failed++; } else if (managed.TryGetValue(name, out value)) { _resolvedByName[name] = value; if (((PrefabGUID)(ref value)).GuidHash != fallbackHash) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(53, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Hash mismatch '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': hardcoded="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(fallbackHash); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" actual="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((PrefabGUID)(ref value)).GuidHash); } log.LogWarning(val); mismatch++; } resolved++; } else { failed++; } } private static void RebuildPrefabIndex() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); foreach (KeyValuePair datum in _data) { datum.Deconstruct(out var key, out var value); VRisingFaction item = key; FactionData factionData = value; NamedPrefab[] patrolUnits = factionData.PatrolUnits; for (int i = 0; i < patrolUnits.Length; i++) { NamedPrefab namedPrefab = patrolUnits[i]; PrefabGUID resolvedGuid = GetResolvedGuid(namedPrefab.Name, namedPrefab.Guid); dictionary[((PrefabGUID)(ref resolvedGuid)).GuidHash] = (item, namedPrefab.Name, namedPrefab.Level); } TieredVBlood[] vBloods = factionData.VBloods; for (int i = 0; i < vBloods.Length; i++) { TieredVBlood tieredVBlood = vBloods[i]; PrefabGUID resolvedGuid2 = GetResolvedGuid(string.IsNullOrEmpty(tieredVBlood.PrefabName) ? tieredVBlood.DisplayName : tieredVBlood.PrefabName, tieredVBlood.Guid); dictionary[((PrefabGUID)(ref resolvedGuid2)).GuidHash] = (item, tieredVBlood.DisplayName, tieredVBlood.Level); } } _prefabIndex = dictionary; } public static PrefabGUID GetResolvedGuid(string name, PrefabGUID fallback) { //IL_0011: 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) if (!_resolvedByName.TryGetValue(name, out var value)) { return fallback; } return value; } public static PrefabGUID GetResolvedGuid(NamedPrefab unit) { //IL_0007: 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) return GetResolvedGuid(unit.Name, unit.Guid); } public static PrefabGUID GetResolvedGuid(TieredVBlood vb) { //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) return GetResolvedGuid(string.IsNullOrEmpty(vb.PrefabName) ? vb.DisplayName : vb.PrefabName, vb.Guid); } public static int DumpSpawnables(PrefabCollectionSystem prefabSystem, string filter, string outputPath) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) Dictionary spawnableNameToPrefabGuidDictionary = prefabSystem.SpawnableNameToPrefabGuidDictionary; List list = new List(); string text = filter.ToUpperInvariant(); Enumerator enumerator = spawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; if (text.Length == 0 || current.Key.ToUpperInvariant().Contains(text)) { DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 2); PrefabGUID value = current.Value; defaultInterpolatedStringHandler.AppendFormatted(((PrefabGUID)(ref value)).GuidHash, 12); defaultInterpolatedStringHandler.AppendLiteral(" "); defaultInterpolatedStringHandler.AppendFormatted(current.Key); list.Add(defaultInterpolatedStringHandler.ToStringAndClear()); } } list.Sort(StringComparer.OrdinalIgnoreCase); File.WriteAllLines(outputPath, list); return list.Count; } public static bool TryGetFaction(PrefabGUID prefab, out VRisingFaction faction) { if (_prefabIndex.TryGetValue(((PrefabGUID)(ref prefab)).GuidHash, out (VRisingFaction, string, int) value)) { (faction, _, _) = value; return true; } faction = VRisingFaction.Unknown; return false; } public static int GetUnitLevel(PrefabGUID prefab) { if (!_prefabIndex.TryGetValue(((PrefabGUID)(ref prefab)).GuidHash, out (VRisingFaction, string, int) value)) { return 0; } return value.Item3; } public static bool TryGetData(VRisingFaction faction, out FactionData data) { return _data.TryGetValue(faction, out data); } public static void ValidateAllPrefabs(PrefabCollectionSystem _) { //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_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Expected O, but got Unknown //IL_0132: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown int count = 0; foreach (KeyValuePair datum in _data) { datum.Deconstruct(out var key, out var value); VRisingFaction value2 = key; FactionData factionData = value; NamedPrefab[] patrolUnits = factionData.PatrolUnits; PrefabGUID guid2; for (int i = 0; i < patrolUnits.Length; i++) { NamedPrefab namedPrefab = patrolUnits[i]; if (!_resolvedByName.ContainsKey(namedPrefab.Name)) { string label = $"{value2}/{namedPrefab.Name}"; guid2 = namedPrefab.Guid; Warn(ref count, label, ((PrefabGUID)(ref guid2)).GuidHash, "not in spawnable dict"); } } TieredVBlood[] vBloods = factionData.VBloods; for (int i = 0; i < vBloods.Length; i++) { TieredVBlood tieredVBlood = vBloods[i]; string key2 = (string.IsNullOrEmpty(tieredVBlood.PrefabName) ? tieredVBlood.DisplayName : tieredVBlood.PrefabName); if (!_resolvedByName.ContainsKey(key2)) { string label2 = $"{value2}/{tieredVBlood.DisplayName}"; guid2 = tieredVBlood.Guid; Warn(ref count, label2, ((PrefabGUID)(ref guid2)).GuidHash, "not in spawnable dict"); } } } bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val; foreach (VRisingRegion allRegion in RegionDatabase.AllRegions) { if (!RegionDatabase.TryGetData(allRegion, out RegionData data)) { continue; } PrefabGUID[] guardianUnits = data.GuardianUnits; for (int i = 0; i < guardianUnits.Length; i++) { PrefabGUID guid = guardianUnits[i]; if (!_resolvedByName.Values.Any((PrefabGUID v) => ((PrefabGUID)(ref v)).GuidHash == ((PrefabGUID)(ref guid)).GuidHash)) { ManualLogSource log = Plugin.Log; val = new BepInExWarningLogInterpolatedStringHandler(81, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising][WARN] Region guardian "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((PrefabGUID)(ref guid)).GuidHash); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(allRegion); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") — hash not confirmed by spawnable dict"); } log.LogWarning(val); } } } if (count == 0) { Plugin.Log.LogInfo((object)"[DyWorld Rising] All faction/VBlood names confirmed in spawnable dict."); return; } ManualLogSource log2 = Plugin.Log; val = new BepInExWarningLogInterpolatedStringHandler(128, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" entry/ies not found in spawnable dict — will use hardcoded hash fallback for kill tracking; spawning may fail."); } log2.LogWarning(val); } private static void Warn(ref int count, string label, int hash, string file) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(55, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising][WARN] Invalid PrefabGUID "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(hash); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(label); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") — update "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(file); } log.LogWarning(val); count++; } private static Dictionary BuildPrefabIndex() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) Dictionary dictionary = new Dictionary(); foreach (KeyValuePair datum in _data) { datum.Deconstruct(out var key, out var value); VRisingFaction item = key; FactionData factionData = value; NamedPrefab[] patrolUnits = factionData.PatrolUnits; PrefabGUID guid; for (int i = 0; i < patrolUnits.Length; i++) { NamedPrefab namedPrefab = patrolUnits[i]; guid = namedPrefab.Guid; dictionary[((PrefabGUID)(ref guid)).GuidHash] = (item, namedPrefab.Name, namedPrefab.Level); } TieredVBlood[] vBloods = factionData.VBloods; for (int i = 0; i < vBloods.Length; i++) { TieredVBlood tieredVBlood = vBloods[i]; guid = tieredVBlood.Guid; dictionary[((PrefabGUID)(ref guid)).GuidHash] = (item, tieredVBlood.DisplayName, tieredVBlood.Level); } } return dictionary; } } public static class GearLevelHelper { public static int GetPlayerGearLevel(EntityManager em, Entity characterEntity) { //IL_0002: 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_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_0024: Unknown result type (might be due to invalid IL or missing references) try { if (!((EntityManager)(ref em)).Exists(characterEntity)) { return 0; } if (!((EntityManager)(ref em)).HasComponent(characterEntity)) { return 0; } Equipment componentData = ((EntityManager)(ref em)).GetComponentData(characterEntity); return (int)((Equipment)(ref componentData)).GetFullLevel(); } catch { return 0; } } public static int GetUnitLevel(PrefabGUID prefabGuid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return FactionDatabase.GetUnitLevel(prefabGuid); } public static float ComputeHeatMultiplier(int playerGearLevel, int unitGearLevel) { if (playerGearLevel <= 0 || unitGearLevel <= 0) { return 1f; } float num = (float)unitGearLevel / (float)playerGearLevel; float value = ((num >= 2f) ? 5f : ((num >= 1f) ? (1f + (num - 1f) * 4f) : ((!(num >= 0.5f)) ? 0.1f : (0.2f + (num - 0.5f) * 1.6f)))); return Math.Clamp(value, 0.05f, 5f); } } public class HeatDecayService : IDisposable { private Timer? _factionTimer; private Timer? _regionTimer; public void Start() { int num = (int)(DyWorldConfig.DecayIntervalSeconds.Value * 1000f); _factionTimer = new Timer(delegate { MainThreadDispatcher.Enqueue(delegate { HeatManager.Instance.DecayAll(DyWorldConfig.DecayAmountPerInterval.Value); }); }, null, num, num); int num2 = (int)(DyWorldConfig.RegionDecayIntervalSeconds.Value * 1000f); _regionTimer = new Timer(delegate { MainThreadDispatcher.Enqueue(delegate { HeatManager.Instance.DecayRegionAll(DyWorldConfig.RegionDecayAmountPerInterval.Value); }); }, null, num2, num2); } public void Dispose() { _factionTimer?.Dispose(); _regionTimer?.Dispose(); _factionTimer = (_regionTimer = null); } } public class HeatManager { private readonly ConcurrentDictionary _states = new ConcurrentDictionary(); private readonly Dictionary<(ulong, VRisingFaction), double> _lastKillNotify = new Dictionary<(ulong, VRisingFaction), double>(); private readonly Dictionary _globalRegionHeat = new Dictionary(); private readonly object _regionLock = new object(); public static HeatManager Instance { get; } = new HeatManager(); private HeatManager() { } public void AddKill(ulong steamId, VRisingFaction faction, float amount = 1f) { if (faction == VRisingFaction.Unknown) { return; } PlayerHeatState orCreate = GetOrCreate(steamId); HeatLevel heatLevel = GetHeatLevel(steamId, faction); lock (orCreate.FactionHeat) { orCreate.FactionHeat.TryGetValue(faction, out var value); value.HeatValue = Math.Min(value.HeatValue + amount, DyWorldConfig.MaximumHeatKills.Value * 1.5f); value.LastKillTimestamp = Timestamp(); orCreate.FactionHeat[faction] = value; } HeatLevel heatLevel2 = GetHeatLevel(steamId, faction); if (heatLevel2 > heatLevel && DyWorldConfig.NotificationsEnabled.Value) { NotifyTierChange(steamId, faction, heatLevel2); } if (DyWorldConfig.NotificationsEnabled.Value) { FactionData data; string value2 = (FactionDatabase.TryGetData(faction, out data) ? data.DisplayName : faction.ToString()); (ulong, VRisingFaction) key = (steamId, faction); double num = Timestamp(); if (!_lastKillNotify.TryGetValue(key, out var value3) || num - value3 >= 3.0) { _lastKillNotify[key] = num; PlayerNotifier.Notify(steamId, $"+{amount:F0} heat with the {value2}."); } } if (DyWorldConfig.AllianceHeatEnabled.Value && FactionAlliances.TryGetAllies(faction, out AllianceEntry[] allies)) { AllianceEntry[] array = allies; for (int i = 0; i < array.Length; i++) { AllianceEntry allianceEntry = array[i]; AddKillSilent(steamId, allianceEntry.Ally, amount * allianceEntry.HeatShare); } } } private void AddKillSilent(ulong steamId, VRisingFaction faction, float amount) { if (faction == VRisingFaction.Unknown || amount <= 0f) { return; } PlayerHeatState orCreate = GetOrCreate(steamId); lock (orCreate.FactionHeat) { orCreate.FactionHeat.TryGetValue(faction, out var value); value.HeatValue = Math.Min(value.HeatValue + amount, DyWorldConfig.MaximumHeatKills.Value * 1.5f); value.LastKillTimestamp = Timestamp(); orCreate.FactionHeat[faction] = value; } } public void SubtractKill(ulong steamId, VRisingFaction faction, float amount) { if (faction == VRisingFaction.Unknown || amount <= 0f || !_states.TryGetValue(steamId, out PlayerHeatState value)) { return; } lock (value.FactionHeat) { if (value.FactionHeat.TryGetValue(faction, out var value2)) { value2.HeatValue = Math.Max(0f, value2.HeatValue - amount); if (value2.HeatValue == 0f) { value.FactionHeat.Remove(faction); } else { value.FactionHeat[faction] = value2; } } } } public void ResetOnDeath(ulong steamId) { if (!_states.TryGetValue(steamId, out PlayerHeatState value)) { return; } float value2 = DyWorldConfig.HeatDeathRetentionFactor.Value; lock (value.FactionHeat) { foreach (VRisingFaction item in value.FactionHeat.Keys.ToList()) { FactionHeatRecord value3 = value.FactionHeat[item]; float heatValue = value3.HeatValue; value3.HeatValue *= value2; if (DyWorldConfig.NotificationsEnabled.Value && heatValue >= DyWorldConfig.LowHeatKills.Value) { FactionData data; string text = (FactionDatabase.TryGetData(item, out data) ? data.DisplayName : item.ToString()); if (value3.HeatValue < DyWorldConfig.LowHeatKills.Value) { PlayerNotifier.Notify(steamId, "The " + text + " have lost your trail."); } else { PlayerNotifier.Notify(steamId, $"The {text} still remember you. ({value3.HeatValue:F0} heat remaining)"); } } if (value3.HeatValue <= 0f) { value.FactionHeat.Remove(item); } else { value.FactionHeat[item] = value3; } } } } public void DecayAll(float amount) { foreach (PlayerHeatState value in _states.Values) { lock (value.FactionHeat) { _ = value.FactionHeat.Count; } DecayDict(value.FactionHeat, amount); } } public HeatLevel GetHeatLevel(ulong steamId, VRisingFaction faction) { if (!_states.TryGetValue(steamId, out PlayerHeatState value)) { return HeatLevel.None; } float heatValue; lock (value.FactionHeat) { if (!value.FactionHeat.TryGetValue(faction, out var value2)) { return HeatLevel.None; } heatValue = value2.HeatValue; } return FactionLevel(heatValue); } public bool TryGetRecord(ulong steamId, VRisingFaction faction, out FactionHeatRecord record) { record = default(FactionHeatRecord); if (!_states.TryGetValue(steamId, out PlayerHeatState value)) { return false; } lock (value.FactionHeat) { return value.FactionHeat.TryGetValue(faction, out record); } } public void SetRecord(ulong steamId, VRisingFaction faction, FactionHeatRecord record) { PlayerHeatState orCreate = GetOrCreate(steamId); lock (orCreate.FactionHeat) { orCreate.FactionHeat[faction] = record; } } public void UpdateSpawnTimestamp(ulong steamId, VRisingFaction faction, bool isBoss) { if (!_states.TryGetValue(steamId, out PlayerHeatState value)) { return; } lock (value.FactionHeat) { if (value.FactionHeat.TryGetValue(faction, out var value2)) { if (isBoss) { value2.LastBossSpawnTimestamp = Timestamp(); } else { value2.LastSpawnTimestamp = Timestamp(); } value.FactionHeat[faction] = value2; } } } public IReadOnlyDictionary GetAllRecords(ulong steamId) { if (!_states.TryGetValue(steamId, out PlayerHeatState value)) { return new Dictionary(); } lock (value.FactionHeat) { return new Dictionary(value.FactionHeat); } } public void AddRegionKill(ulong steamId, VRisingRegion region, float amount = 1f) { if (region == VRisingRegion.Unknown) { return; } lock (_regionLock) { _globalRegionHeat.TryGetValue(region, out var value); value.HeatValue = Math.Min(value.HeatValue + amount, DyWorldConfig.RegionMaximumHeatKills.Value * 1.5f); value.LastKillTimestamp = Timestamp(); _globalRegionHeat[region] = value; } } public void DecayRegionAll(float amount) { lock (_regionLock) { List list = new List(); foreach (VRisingRegion item in _globalRegionHeat.Keys.ToList()) { RegionHeatRecord value = _globalRegionHeat[item]; value.HeatValue = Math.Max(0f, value.HeatValue - amount); if (value.HeatValue == 0f) { list.Add(item); } else { _globalRegionHeat[item] = value; } } foreach (VRisingRegion item2 in list) { _globalRegionHeat.Remove(item2); } } } public HeatLevel GetRegionHeatLevel(VRisingRegion region) { lock (_regionLock) { if (!_globalRegionHeat.TryGetValue(region, out var value)) { return HeatLevel.None; } return RegionLevel(value.HeatValue); } } public HeatLevel GetRegionHeatLevel(ulong steamId, VRisingRegion region) { return GetRegionHeatLevel(region); } public bool TryGetRegionRecord(VRisingRegion region, out RegionHeatRecord record) { lock (_regionLock) { return _globalRegionHeat.TryGetValue(region, out record); } } public bool TryGetRegionRecord(ulong steamId, VRisingRegion region, out RegionHeatRecord record) { return TryGetRegionRecord(region, out record); } public void SetRegionRecord(VRisingRegion region, RegionHeatRecord record) { lock (_regionLock) { _globalRegionHeat[region] = record; } } public void SetRegionRecord(ulong steamId, VRisingRegion region, RegionHeatRecord record) { SetRegionRecord(region, record); } public void UpdateRegionSpawnTimestamp(VRisingRegion region, bool isGuardian) { lock (_regionLock) { if (_globalRegionHeat.TryGetValue(region, out var value)) { if (isGuardian) { value.LastGuardianSpawnTimestamp = Timestamp(); } else { value.LastSpawnTimestamp = Timestamp(); } _globalRegionHeat[region] = value; } } } public void UpdateRegionSpawnTimestamp(ulong steamId, VRisingRegion region, bool isGuardian) { UpdateRegionSpawnTimestamp(region, isGuardian); } public IReadOnlyDictionary GetAllRegionRecords() { lock (_regionLock) { return new Dictionary(_globalRegionHeat); } } public IReadOnlyDictionary GetAllRegionRecords(ulong steamId) { return GetAllRegionRecords(); } public void LoadGlobalRegionState(Dictionary records) { lock (_regionLock) { _globalRegionHeat.Clear(); foreach (var (key, value) in records) { _globalRegionHeat[key] = value; } } } public IEnumerable GetAllStates() { return _states.Values; } public void LoadState(ulong steamId, Dictionary factionRecords, Dictionary regionRecords) { PlayerHeatState orCreate = GetOrCreate(steamId); lock (orCreate.FactionHeat) { orCreate.FactionHeat.Clear(); foreach (var (key, value) in factionRecords) { orCreate.FactionHeat[key] = value; } } lock (orCreate.RegionHeat) { orCreate.RegionHeat.Clear(); foreach (var (key2, value2) in regionRecords) { orCreate.RegionHeat[key2] = value2; } } } private PlayerHeatState GetOrCreate(ulong steamId) { return _states.GetOrAdd(steamId, (ulong id) => new PlayerHeatState { SteamId = id }); } private static void DecayDict(Dictionary dict, float amount) where TKey : notnull { lock (dict) { List list = new List(); foreach (TKey item in dict.Keys.ToList()) { FactionHeatRecord value = dict[item]; value.HeatValue = Math.Max(0f, value.HeatValue - amount); if (value.HeatValue == 0f) { list.Add(item); } else { dict[item] = value; } } foreach (TKey item2 in list) { dict.Remove(item2); } } } private static void DecayDict(Dictionary dict, float amount) where TKey : notnull { lock (dict) { List list = new List(); foreach (TKey item in dict.Keys.ToList()) { RegionHeatRecord value = dict[item]; value.HeatValue = Math.Max(0f, value.HeatValue - amount); if (value.HeatValue == 0f) { list.Add(item); } else { dict[item] = value; } } foreach (TKey item2 in list) { dict.Remove(item2); } } } private static HeatLevel FactionLevel(float heat) { if (heat >= DyWorldConfig.MaximumHeatKills.Value) { return HeatLevel.Maximum; } if (heat >= DyWorldConfig.HighHeatKills.Value) { return HeatLevel.High; } if (heat >= DyWorldConfig.MediumHeatKills.Value) { return HeatLevel.Medium; } if (heat >= DyWorldConfig.LowHeatKills.Value) { return HeatLevel.Low; } return HeatLevel.None; } private static HeatLevel RegionLevel(float heat) { if (heat >= DyWorldConfig.RegionMaximumHeatKills.Value) { return HeatLevel.Maximum; } if (heat >= DyWorldConfig.RegionHighHeatKills.Value) { return HeatLevel.High; } if (heat >= DyWorldConfig.RegionMediumHeatKills.Value) { return HeatLevel.Medium; } if (heat >= DyWorldConfig.RegionLowHeatKills.Value) { return HeatLevel.Low; } return HeatLevel.None; } private static void NotifyTierChange(ulong steamId, VRisingFaction faction, HeatLevel level) { FactionData data; string text = (FactionDatabase.TryGetData(faction, out data) ? data.DisplayName : faction.ToString()); string text2 = level switch { HeatLevel.Low => "The " + text + " have taken notice of you.", HeatLevel.Medium => "The " + text + " are actively hunting you.", HeatLevel.High => "The " + text + " have declared you an enemy. Expect reinforcements.", HeatLevel.Maximum => "The " + text + " are sending their deadliest after you.", _ => string.Empty, }; if (!string.IsNullOrEmpty(text2)) { PlayerNotifier.Notify(steamId, text2); } } private static double Timestamp() { return (double)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000.0; } } public static class HuntTracker { private static readonly ConcurrentDictionary _tracked = new ConcurrentDictionary(); public static int Count => _tracked.Count; public static void Register(Entity entity, ulong ownerSteamId, VRisingFaction faction, bool isVBlood = false, bool isSiegeWave = false) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) _tracked[entity] = new HuntInfo(ownerSteamId, faction, isVBlood, isSiegeWave); } public static bool TryGet(Entity entity, out HuntInfo info) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return _tracked.TryGetValue(entity, out info); } public static void Remove(Entity entity) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) _tracked.TryRemove(entity, out var _); } public static void Prune(EntityManager em) { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) foreach (Entity item in _tracked.Keys.ToList()) { if (!((EntityManager)(ref em)).Exists(item)) { _tracked.TryRemove(item, out var _); } } } } public static class MainThreadDispatcher { private static readonly ConcurrentQueue _queue = new ConcurrentQueue(); public static void Enqueue(Action action) { _queue.Enqueue(action); } public static void Drain() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Action result; bool flag = default(bool); while (_queue.TryDequeue(out result)) { try { result(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] MainThreadDispatcher: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } } } } public static class PlayerNotifier { public static void Notify(ulong steamId, string message) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //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_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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_003c: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) try { World serverWorld = GetServerWorld(); if (serverWorld == null) { return; } EntityManager entityManager = serverWorld.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); if (componentData.PlatformId == steamId) { SendToUser(entityManager, componentData, message); break; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DyWorld Rising] PlayerNotifier.Notify failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogWarning(val3); } } public static void BroadcastToAll(string message) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) try { World serverWorld = GetServerWorld(); if (serverWorld != null) { EntityManager entityManager = serverWorld.EntityManager; FixedString512Bytes val = default(FixedString512Bytes); ((FixedString512Bytes)(ref val))..ctor(message); ServerChatUtils.SendSystemMessageToAllClients(entityManager, ref val); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DyWorld Rising] PlayerNotifier.BroadcastToAll failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } public static string GetPlayerName(ulong steamId) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) try { World serverWorld = GetServerWorld(); if (serverWorld == null) { return "Unknown"; } EntityManager entityManager = serverWorld.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); if (componentData.PlatformId == steamId) { return ((FixedString64Bytes)(ref componentData.CharacterName)).Value; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch { } return "Unknown"; } private static void SendToUser(EntityManager em, User user, string message) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown try { FixedString512Bytes val = default(FixedString512Bytes); ((FixedString512Bytes)(ref val))..ctor(message); ServerChatUtils.SendSystemMessageToClient(em, user, ref val); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DyWorld Rising] PlayerNotifier send failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } private static World? GetServerWorld() { Enumerator enumerator = World.All.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == "Server") { return current; } } return null; } } public enum VRisingRegion { Unknown, FarbaneFoods, DunleyFarmlands, HallowedMountains, SilverlightHills, Gloomrot, CursedForest } public class RegionData { public string DisplayName { get; init; } = string.Empty; public float3 BoundsMin { get; init; } public float3 BoundsMax { get; init; } public VRisingFaction[] InhabitantFactions { get; init; } = Array.Empty(); public PrefabGUID[] GuardianUnits { get; init; } = Array.Empty(); } public static class RegionDatabase { private static readonly Dictionary _data = new Dictionary { [VRisingRegion.FarbaneFoods] = new RegionData { DisplayName = "Farbane Woods", BoundsMin = new float3(-3200f, -500f, -3200f), BoundsMax = new float3(200f, 500f, -400f), InhabitantFactions = new VRisingFaction[3] { VRisingFaction.Bandits, VRisingFaction.Blackfang, VRisingFaction.Creature }, GuardianUnits = (PrefabGUID[])(object)new PrefabGUID[3] { new PrefabGUID(2122229952), new PrefabGUID(-1905691330), new PrefabGUID(173259239) } }, [VRisingRegion.DunleyFarmlands] = new RegionData { DisplayName = "Dunley Farmlands", BoundsMin = new float3(-1000f, -500f, -400f), BoundsMax = new float3(1800f, 500f, 1600f), InhabitantFactions = new VRisingFaction[4] { VRisingFaction.Militia, VRisingFaction.DunleyFarmers, VRisingFaction.Werewolves, VRisingFaction.Creature }, GuardianUnits = (PrefabGUID[])(object)new PrefabGUID[3] { new PrefabGUID(-29797003), new PrefabGUID(2079933370), new PrefabGUID(-1942352521) } }, [VRisingRegion.HallowedMountains] = new RegionData { DisplayName = "Hallowed Mountains", BoundsMin = new float3(-3200f, -500f, -400f), BoundsMax = new float3(-1000f, 500f, 2200f), InhabitantFactions = new VRisingFaction[2] { VRisingFaction.ChurchOfLuminance, VRisingFaction.Undead }, GuardianUnits = (PrefabGUID[])(object)new PrefabGUID[3] { new PrefabGUID(-26105228), new PrefabGUID(153390636), new PrefabGUID(577478542) } }, [VRisingRegion.SilverlightHills] = new RegionData { DisplayName = "Silverlight Hills", BoundsMin = new float3(1800f, -500f, -400f), BoundsMax = new float3(3600f, 500f, 2200f), InhabitantFactions = new VRisingFaction[2] { VRisingFaction.ChurchOfLuminance, VRisingFaction.Legion }, GuardianUnits = (PrefabGUID[])(object)new PrefabGUID[3] { new PrefabGUID(114912615), new PrefabGUID(-740796338), new PrefabGUID(495971434) } }, [VRisingRegion.Gloomrot] = new RegionData { DisplayName = "Gloomrot", BoundsMin = new float3(-1000f, -500f, 1600f), BoundsMax = new float3(1800f, 500f, 3600f), InhabitantFactions = new VRisingFaction[1] { VRisingFaction.Gloomrot }, GuardianUnits = (PrefabGUID[])(object)new PrefabGUID[3] { new PrefabGUID(106480588), new PrefabGUID(-1101874342), new PrefabGUID(814083983) } }, [VRisingRegion.CursedForest] = new RegionData { DisplayName = "Cursed Forest", BoundsMin = new float3(-3200f, -500f, 1600f), BoundsMax = new float3(-1000f, 500f, 3600f), InhabitantFactions = new VRisingFaction[4] { VRisingFaction.Undead, VRisingFaction.Werewolves, VRisingFaction.Cursed, VRisingFaction.Creature }, GuardianUnits = (PrefabGUID[])(object)new PrefabGUID[3] { new PrefabGUID(939467639), new PrefabGUID(2079933370), new PrefabGUID(-910296704) } } }; public static IEnumerable AllRegions => _data.Keys; public static VRisingRegion GetRegion(float3 position) { //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_0039: 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_004c: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) foreach (var (result, regionData2) in _data) { if (position.x >= regionData2.BoundsMin.x && position.x <= regionData2.BoundsMax.x && position.z >= regionData2.BoundsMin.z && position.z <= regionData2.BoundsMax.z) { return result; } } return VRisingRegion.Unknown; } public static bool TryGetData(VRisingRegion region, out RegionData data) { return _data.TryGetValue(region, out data); } } public static class RewardGiver { public static void GiveHunterKillReward(EntityManager em, ulong steamId, Entity killerCharEntity, float3 dropPosition, bool isVBlood) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //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_0043: Unknown result type (might be due to invalid IL or missing references) if (!DyWorldConfig.RewardsEnabled.Value) { return; } try { int playerGearLevel = GearLevelHelper.GetPlayerGearLevel(em, killerCharEntity); int count = (isVBlood ? DyWorldConfig.VBloodKillRewardCount.Value : DyWorldConfig.HunterKillRewardCount.Value); float value = DyWorldConfig.NextTierBiasChance.Value; RewardEntry[] rewards = RewardTable.PickRewards(playerGearLevel, count, value); DeliverRewards(em, steamId, rewards); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] GiveHunterKillReward: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } public static void GiveSiegeReward(EntityManager em, ulong steamId, Entity charEntity, float3 dropPosition, int factionCount) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //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_0044: Unknown result type (might be due to invalid IL or missing references) if (!DyWorldConfig.RewardsEnabled.Value) { return; } try { int playerGearLevel = GearLevelHelper.GetPlayerGearLevel(em, charEntity); int count = DyWorldConfig.SiegeBaseRewardCount.Value + Math.Max(0, factionCount - 1); float value = DyWorldConfig.NextTierBiasChance.Value; RewardEntry[] rewards = ScaleQuantities(RewardTable.PickRewards(playerGearLevel, count, value), 3); DeliverRewards(em, steamId, rewards); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] GiveSiegeReward: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } private static void DeliverRewards(EntityManager em, ulong steamId, RewardEntry[] rewards) { //IL_0010: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown Random random = new Random(); World serverWorld = GetServerWorld(); if (serverWorld == null) { return; } Entity val = FindCharEntity(em, steamId); if (!((EntityManager)(ref em)).Exists(val)) { return; } ServerGameManager serverGameManager = serverWorld.GetExistingSystemManaged().GetServerGameManager(); bool flag = default(bool); for (int i = 0; i < rewards.Length; i++) { RewardEntry entry = rewards[i]; PrefabGUID guid = RewardTable.Resolve(entry); if (((PrefabGUID)(ref guid)).GuidHash == 0) { continue; } int num = random.Next(entry.MinQty, entry.MaxQty + 1); bool num2 = TryAddToInventory(serverGameManager, val, guid, num); string value = entry.PrefabName.Replace("Item_Ingredient_", "").Replace("Item_Consumable_", "").Replace("Item_", "") .Replace("_", " ") .Trim(); if (num2) { PlayerNotifier.Notify(steamId, $"Received: {num}x {value}"); continue; } ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(38, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DyWorld Rising] Could not give "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(entry.PrefabName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" to "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(steamId); } log.LogWarning(val2); } } private static bool TryAddToInventory(ServerGameManager sgm, Entity charEntity, PrefabGUID guid, int qty) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown try { ((ServerGameManager)(ref sgm)).TryAddInventoryItem(charEntity, guid, qty); return true; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] TryAddInventoryItem failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); return false; } } private static Entity FindCharEntity(EntityManager em, ulong steamId) { //IL_000a: 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_0019: 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_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_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_007d: 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_003c: 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_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) try { EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref em)).GetComponentData(current); if (componentData.PlatformId == steamId) { return componentData.LocalCharacter._Entity; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch { } return Entity.Null; } private static RewardEntry[] ScaleQuantities(RewardEntry[] rewards, int multiplier) { RewardEntry[] array = new RewardEntry[rewards.Length]; for (int i = 0; i < rewards.Length; i++) { RewardEntry rewardEntry = rewards[i]; array[i] = new RewardEntry(rewardEntry.PrefabName, rewardEntry.FallbackHash, rewardEntry.MinQty * multiplier, rewardEntry.MaxQty * multiplier, rewardEntry.Weight); } return array; } private static World? GetServerWorld() { Enumerator enumerator = World.All.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == "Server") { return current; } } return null; } } public readonly struct RewardEntry { public readonly string PrefabName; public readonly int FallbackHash; public readonly int MinQty; public readonly int MaxQty; public readonly int Weight; public RewardEntry(string name, int hash, int minQty, int maxQty, int weight = 10) { PrefabName = name; FallbackHash = hash; MinQty = minQty; MaxQty = maxQty; Weight = weight; } } public static class RewardTable { private static readonly Dictionary _resolved = new Dictionary(); private static readonly RewardEntry[] Tier1 = new RewardEntry[7] { new RewardEntry("Item_BloodEssence_T01", 862477668, 2, 5, 25), new RewardEntry("Item_Ingredient_Bone", 1821405450, 3, 8, 20), new RewardEntry("Item_Ingredient_Leather", -1907572080, 2, 5, 20), new RewardEntry("Item_Ingredient_Whetstone", 1252507075, 1, 3, 15), new RewardEntry("Item_Consumable_HealingPotion_T01", 800879747, 1, 2, 15), new RewardEntry("Item_Ingredient_Mineral_CopperIngot", -1237019921, 2, 4, 15), new RewardEntry("Item_Ingredient_Gravedust", -608131642, 1, 3) }; private static readonly RewardEntry[] Tier2 = new RewardEntry[7] { new RewardEntry("Item_Ingredient_Mineral_IronBar", -1750550553, 2, 5, 25), new RewardEntry("Item_BloodEssence_T02_Greater", 271594022, 1, 3, 20), new RewardEntry("Item_Ingredient_Gravedust", -608131642, 2, 5, 15), new RewardEntry("Item_Ingredient_PristineHide", 1658596502, 2, 4, 15), new RewardEntry("Item_Consumable_PhysicalPowerPotion_T02", -1568756102, 1, 2), new RewardEntry("Item_Ingredient_Mineral_Sulfur", 880699252, 2, 5), new RewardEntry("Item_Ingredient_BloodCrystal", -1913156733, 1, 2) }; private static readonly RewardEntry[] Tier3 = new RewardEntry[6] { new RewardEntry("Item_Ingredient_Mineral_DarkSilverBar", -762000259, 2, 4, 25), new RewardEntry("Item_Ingredient_Spectraldust", -2130812821, 2, 5, 20), new RewardEntry("Item_Ingredient_Witchdust", -223452038, 2, 4, 15), new RewardEntry("Item_BloodEssence_T03_Primal", 1566989408, 1, 2, 15), new RewardEntry("Item_Ingredient_Crystal", -257494203, 2, 5, 15), new RewardEntry("Item_Ingredient_Coin_Silver", -949672483, 3, 8) }; private static readonly RewardEntry[] Tier4 = new RewardEntry[7] { new RewardEntry("Item_BloodEssence_T03_Primal", 1566989408, 2, 4, 25), new RewardEntry("Item_Ingredient_Thread_Imperial", -898917584, 1, 3, 20), new RewardEntry("Item_Ingredient_Glass", -1233716303, 3, 6, 15), new RewardEntry("Item_Ingredient_Research_Paper", 780044299, 1, 2, 15), new RewardEntry("Item_Ingredient_TechScrap", 834864259, 2, 5, 15), new RewardEntry("Item_Ingredient_Vampiricdust", 805157024, 2, 4), new RewardEntry("Item_Ingredient_Coin_Silver", -949672483, 5, 12) }; private static readonly RewardEntry[] Tier5 = new RewardEntry[7] { new RewardEntry("Item_BloodEssence_T03_Primal", 1566989408, 3, 6, 25), new RewardEntry("Item_Ingredient_OnyxTear", -651878258, 1, 2, 20), new RewardEntry("Item_Ingredient_Coin_Royal", -571562864, 2, 5, 15), new RewardEntry("Item_Ingredient_Thread_Imperial", -898917584, 2, 4, 15), new RewardEntry("Item_Ingredient_Gemdust", 820932258, 3, 6, 15), new RewardEntry("Item_Ingredient_TechScrap", 834864259, 3, 6), new RewardEntry("Item_Ingredient_Crystal", -257494203, 3, 7) }; private static readonly RewardEntry[][] _tiers = new RewardEntry[5][] { Tier1, Tier2, Tier3, Tier4, Tier5 }; public static int ResolvedCount => _resolved.Count; public static void AutoResolveItems(PrefabCollectionSystem prefabSystem) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_00b1: 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_00d9: Expected O, but got Unknown _resolved.Clear(); Dictionary dictionary = new Dictionary(StringComparer.Ordinal); Enumerator enumerator = prefabSystem.SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; dictionary[current.Key] = current.Value; } if (dictionary.Count == 0) { Plugin.Log.LogWarning((object)"[DyWorld Rising] RewardTable: spawnable dict empty — items not resolved."); return; } int num = 0; int num2 = 0; int num3 = 0; RewardEntry[][] tiers = _tiers; bool flag = default(bool); foreach (RewardEntry[] array in tiers) { for (int j = 0; j < array.Length; j++) { RewardEntry rewardEntry = array[j]; if (dictionary.TryGetValue(rewardEntry.PrefabName, out var value)) { _resolved[rewardEntry.PrefabName] = value; if (((PrefabGUID)(ref value)).GuidHash != rewardEntry.FallbackHash) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(60, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Reward hash mismatch '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rewardEntry.PrefabName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': hardcoded="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rewardEntry.FallbackHash); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" actual="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((PrefabGUID)(ref value)).GuidHash); } log.LogWarning(val); num2++; } num++; } else { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Reward item not in spawnable dict: '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(rewardEntry.PrefabName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'"); } log2.LogWarning(val); num3++; } } } ManualLogSource log3 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(65, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DyWorld Rising] RewardTable: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" resolved, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" mismatches, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" not found."); } log3.LogInfo(val2); } public static int GetTierIndex(int gearLevel) { if (gearLevel <= 20) { return 0; } if (gearLevel <= 40) { return 1; } if (gearLevel <= 60) { return 2; } if (gearLevel <= 80) { return 3; } return 4; } public static RewardEntry[] PickRewards(int gearLevel, int count, float nextTierBias = 0.3f) { Random random = new Random(); RewardEntry[] array = new RewardEntry[count]; int tierIndex = GetTierIndex(gearLevel); for (int i = 0; i < count; i++) { bool flag = tierIndex < _tiers.Length - 1 && random.NextDouble() < (double)nextTierBias; array[i] = PickWeighted(_tiers[flag ? (tierIndex + 1) : tierIndex], random); } return array; } private static RewardEntry PickWeighted(RewardEntry[] pool, Random rng) { int maxValue = pool.Sum((RewardEntry e) => e.Weight); int num = rng.Next(maxValue); int num2 = 0; for (int i = 0; i < pool.Length; i++) { RewardEntry result = pool[i]; num2 += result.Weight; if (num < num2) { return result; } } return pool[^1]; } public static PrefabGUID Resolve(RewardEntry entry) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!_resolved.TryGetValue(entry.PrefabName, out var value)) { return new PrefabGUID(entry.FallbackHash); } return value; } } public class SiegeManager { private readonly ConcurrentDictionary _states = new ConcurrentDictionary(); public static SiegeManager Instance { get; } = new SiegeManager(); private SiegeManager() { } public bool CanStartSiege(ulong steamId) { if (!_states.TryGetValue(steamId, out SiegeState value)) { return true; } if (value.IsActive) { return false; } return Now() - value.LastSiegeEndTime >= (double)DyWorldConfig.SiegeCooldownSeconds.Value; } public SiegeState? GetState(ulong steamId) { if (!_states.TryGetValue(steamId, out SiegeState value)) { return null; } return value; } public SiegeState StartSiege(ulong steamId, VRisingFaction[] factions, float3 castleCenter) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) SiegeState orAdd = _states.GetOrAdd(steamId, (ulong _) => new SiegeState { SteamId = steamId }); SiegeState siegeState = new SiegeState { SteamId = steamId, SiegingFactions = factions, CurrentWave = 0, SiegeStartTime = Now(), WaveStartTime = Now(), CastleCenter = castleCenter, IsActive = true, LastSiegeEndTime = orAdd.LastSiegeEndTime }; _states[steamId] = siegeState; return siegeState; } public void AdvanceWave(ulong steamId) { if (_states.TryGetValue(steamId, out SiegeState value) && value.IsActive) { value.CurrentWave++; value.WaveStartTime = Now(); } } public void EndSiege(ulong steamId) { if (_states.TryGetValue(steamId, out SiegeState value)) { value.IsActive = false; value.LastSiegeEndTime = Now(); } } public IEnumerable GetAllActive() { return _states.Values.Where((SiegeState s) => s.IsActive); } public void LoadCooldown(ulong steamId, double lastSiegeEndTime) { _states.GetOrAdd(steamId, (ulong _) => new SiegeState { SteamId = steamId }).LastSiegeEndTime = lastSiegeEndTime; } public IEnumerable<(ulong SteamId, double LastSiegeEndTime)> GetAllCooldownData() { return _states.Select, (ulong, double)>((KeyValuePair kvp) => (kvp.Key, kvp.Value.LastSiegeEndTime)); } private static double Now() { return (double)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000.0; } } public class SiegeOrchestrator : IDisposable { private Timer? _timer; public void Start() { int num = (int)(DyWorldConfig.SiegeCheckIntervalSeconds.Value * 1000f); _timer = new Timer(delegate { MainThreadDispatcher.Enqueue(RunSiegeCheck); }, null, num, num); } private static void RunSiegeCheck() { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_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_006d: 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_0076: 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_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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (!DyWorldConfig.Enabled.Value || !DyWorldConfig.SiegeEnabled.Value) { return; } try { World serverWorld = GetServerWorld(); if (serverWorld == null) { return; } EntityManager entityManager = serverWorld.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); if (componentData.IsConnected) { Entity entity = componentData.LocalCharacter._Entity; if (((EntityManager)(ref entityManager)).Exists(entity)) { ulong platformId = componentData.PlatformId; ProcessPlayer(entityManager, platformId, entity); } } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DyWorld Rising] SiegeOrchestrator: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogError(val3); } } private static void ProcessPlayer(EntityManager em, ulong steamId, Entity charEntity) { //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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) double num = Now(); SiegeState state = SiegeManager.Instance.GetState(steamId); if (state != null && state.IsActive) { int value = DyWorldConfig.SiegeWaveCount.Value; if (state.CurrentWave < value && num - state.WaveStartTime >= (double)DyWorldConfig.SiegeWaveDurationSeconds.Value) { SiegeManager.Instance.AdvanceWave(steamId); SpawnSiegeWave(em, state); } else if (state.CurrentWave >= value && num - state.WaveStartTime >= (double)DyWorldConfig.SiegeWaveDurationSeconds.Value) { EndSiege(em, steamId, state, survived: true); } } else { if (!SiegeManager.Instance.CanStartSiege(steamId)) { return; } VRisingFaction[] array = FactionDatabase.AllFactions.Where((VRisingFaction f) => HeatManager.Instance.GetHeatLevel(steamId, f) == HeatLevel.Maximum).ToArray(); if (array.Length < DyWorldConfig.SiegeMinimumFactions.Value) { return; } float3? val = FindCastleCenter(em, charEntity); if (!val.HasValue) { return; } SiegeState siegeState = SiegeManager.Instance.StartSiege(steamId, array, val.Value); string playerName = PlayerNotifier.GetPlayerName(steamId); string factionNames = siegeState.FactionNames; PlayerNotifier.BroadcastToAll($"[DyWorld Rising] A coalition of {factionNames} marches on {playerName}'s castle!"); PlayerNotifier.Notify(steamId, "Multiple factions have located your castle! Prepare to defend it!"); ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DyWorld Rising] Siege started for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(steamId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(factionNames); } log.LogInfo(val2); MainThreadDispatcher.Enqueue(delegate { //IL_002e: Unknown result type (might be due to invalid IL or missing references) SiegeState state2 = SiegeManager.Instance.GetState(steamId); if (state2 != null && state2.IsActive) { SiegeManager.Instance.AdvanceWave(steamId); SpawnSiegeWave(em, state2); } }); } } private static void SpawnSiegeWave(EntityManager em, SiegeState state) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) int currentWave = state.CurrentWave; int value = DyWorldConfig.SiegeWaveCount.Value; int value2 = DyWorldConfig.SiegeWaveSpawnCount.Value; float value3 = DyWorldConfig.SiegeSpawnRadius.Value; int num = currentWave switch { 1 => value2, 2 => (int)((float)value2 * 1.5f), _ => value2 * 2, }; List list = BuildUnitPool(state.SiegingFactions, currentWave); Random random = new Random(); for (int i = 0; i < num; i++) { if (list.Count == 0) { break; } PrefabGUID prefabGuid = list[random.Next(list.Count)]; float3 targetPosition = UnitSpawnerHelper.RandomOffsetPosition(state.CastleCenter, value3); VRisingFaction faction = ((state.SiegingFactions.Length != 0) ? state.SiegingFactions[0] : VRisingFaction.Bandits); UnitSpawnerHelper.SpawnQueue.Enqueue(new UnitSpawnerHelper.SpawnQueueEntry(prefabGuid, targetPosition, state.SteamId, faction)); } if (currentWave >= value && DyWorldConfig.MaximumHeatBossTrigger.Value) { SpawnSiegeBoss(em, state, value3); } PlayerNotifier.Notify(state.SteamId, $"Wave {currentWave}/{value} of the siege has arrived at your castle!"); ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(51, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Siege wave "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(currentWave); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" spawned ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" units) for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(state.SteamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } private static List BuildUnitPool(VRisingFaction[] factions, int wave) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < factions.Length; i++) { if (!FactionDatabase.TryGetData(factions[i], out FactionData data)) { continue; } NamedPrefab[] array = data.PatrolUnits; if (wave >= 2 && array.Length > 2) { array = array.OrderByDescending((NamedPrefab u) => u.Level).Take(Math.Max(2, array.Length / 2)).ToArray(); } NamedPrefab[] array2 = array; foreach (NamedPrefab unit in array2) { list.Add(FactionDatabase.GetResolvedGuid(unit)); } } return list; } private static void SpawnSiegeBoss(EntityManager em, SiegeState state, float radius) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) FactionData data2; VRisingFaction vRisingFaction = state.SiegingFactions.Where((VRisingFaction f) => FactionDatabase.TryGetData(f, out data2) && data2.VBloods.Length != 0).FirstOrDefault(); if (vRisingFaction != 0 && FactionDatabase.TryGetData(vRisingFaction, out FactionData data) && data.VBloods.Length != 0) { TieredVBlood vb = SpawnOrchestrator.SelectVBloodTier(data.VBloods, 999); float3 position = UnitSpawnerHelper.RandomOffsetPosition(state.CastleCenter, radius * 1.5f); Entity val = UnitSpawnerHelper.SpawnUnit(em, FactionDatabase.GetResolvedGuid(vb), position, state.SteamId, vRisingFaction, isVBlood: true); if (val != Entity.Null) { HuntTracker.Register(val, state.SteamId, vRisingFaction, isVBlood: false, isSiegeWave: true); } PlayerNotifier.Notify(state.SteamId, vb.DisplayName + " leads the final assault on your castle!"); PlayerNotifier.BroadcastToAll($"[DyWorld Rising] {vb.DisplayName} personally leads the siege on {PlayerNotifier.GetPlayerName(state.SteamId)}'s castle!"); } } private static void EndSiege(EntityManager em, ulong steamId, SiegeState state, bool survived) { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) SiegeManager.Instance.EndSiege(steamId); string playerName = PlayerNotifier.GetPlayerName(steamId); string factionNames = state.FactionNames; if (survived) { PlayerNotifier.Notify(steamId, "You have repelled the siege! The " + factionNames + " retreat in defeat."); PlayerNotifier.BroadcastToAll($"[DyWorld Rising] {playerName} has repelled a coalition siege by {factionNames}!"); float value = DyWorldConfig.SiegeHeatReductionOnSurvival.Value; VRisingFaction[] siegingFactions = state.SiegingFactions; foreach (VRisingFaction faction in siegingFactions) { HeatManager.Instance.SubtractKill(steamId, faction, value); HeatManager.Instance.SubtractKill(steamId, faction, value); } Entity val = FindCharEntityForPlayer(em, steamId); float3 val2; if (!((EntityManager)(ref em)).Exists(val) || !((EntityManager)(ref em)).HasComponent(val)) { val2 = state.CastleCenter; } else { LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(val); val2 = ((LocalToWorld)(ref componentData)).Position; } float3 dropPosition = val2; RewardGiver.GiveSiegeReward(em, steamId, val, dropPosition, state.SiegingFactions.Length); } else { PlayerNotifier.Notify(steamId, "The siege has ended."); } ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(46, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DyWorld Rising] Siege ended for "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(steamId); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (survived="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(survived); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log.LogInfo(val3); } public static void ForceStartSiege(ulong steamId) { MainThreadDispatcher.Enqueue(delegate { //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //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_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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_003c: 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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { World serverWorld = GetServerWorld(); if (serverWorld != null) { EntityManager entityManager = serverWorld.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Entity val3 = Entity.Null; try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); if (componentData.PlatformId == steamId) { val3 = componentData.LocalCharacter._Entity; break; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } if (((EntityManager)(ref entityManager)).Exists(val3)) { SiegeManager.Instance.LoadCooldown(steamId, 0.0); VRisingFaction[] array = FactionDatabase.AllFactions.Where((VRisingFaction f) => HeatManager.Instance.GetHeatLevel(steamId, f) == HeatLevel.Maximum).ToArray(); if (array.Length < 2) { array = new VRisingFaction[2] { VRisingFaction.Bandits, VRisingFaction.Militia }; } float3? val4 = FindCastleCenter(entityManager, val3); if (!val4.HasValue) { float3 value; if (!((EntityManager)(ref entityManager)).HasComponent(val3)) { value = float3.zero; } else { LocalToWorld componentData2 = ((EntityManager)(ref entityManager)).GetComponentData(val3); value = ((LocalToWorld)(ref componentData2)).Position; } val4 = value; } SiegeState state = SiegeManager.Instance.StartSiege(steamId, array, val4.Value); ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[DyWorld Rising] Force siege started for "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(steamId); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("."); } log.LogInfo(val5); PlayerNotifier.Notify(steamId, "SIEGE STARTED (forced). Defenders are coming!"); SiegeManager.Instance.AdvanceWave(steamId); SpawnSiegeWave(entityManager, state); } } } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[DyWorld Rising] ForceStartSiege: "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(ex.Message); } log2.LogError(val6); } }); } public static void ForceEndSiege(ulong steamId) { MainThreadDispatcher.Enqueue(delegate { //IL_0028: Unknown result type (might be due to invalid IL or missing references) SiegeState state = SiegeManager.Instance.GetState(steamId); if (state != null && state.IsActive) { World serverWorld = GetServerWorld(); if (serverWorld != null) { EndSiege(serverWorld.EntityManager, steamId, state, survived: false); } } }); } private static Entity FindCharEntityForPlayer(EntityManager em, ulong steamId) { //IL_000a: 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_0019: 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_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_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_007d: 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_003c: 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_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) try { EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref em)).GetComponentData(current); if (componentData.PlatformId == steamId) { return componentData.LocalCharacter._Entity; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch { } return Entity.Null; } private static float3? FindCastleCenter(EntityManager em, Entity charEntity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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_003b: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) try { if (!((EntityManager)(ref em)).HasComponent(charEntity)) { return null; } int value = ((EntityManager)(ref em)).GetComponentData(charEntity).Value; EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (((EntityManager)(ref em)).HasComponent(current) && ((EntityManager)(ref em)).GetComponentData(current).Value == value && ((EntityManager)(ref em)).HasComponent(current)) { LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(current); return ((LocalToWorld)(ref componentData)).Position; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch { } return null; } private static World? GetServerWorld() { Enumerator enumerator = World.All.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == "Server") { return current; } } return null; } private static double Now() { return (double)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000.0; } public void Dispose() { _timer?.Dispose(); _timer = null; } } public class SpawnOrchestrator : IDisposable { private Timer? _factionTimer; private Timer? _regionTimer; public void Start() { int num = (int)(DyWorldConfig.SpawnCheckIntervalSeconds.Value * 1000f); _factionTimer = new Timer(delegate { MainThreadDispatcher.Enqueue(RunFactionSpawnCheck); }, null, num, num); int num2 = (int)(DyWorldConfig.RegionSpawnCheckIntervalSeconds.Value * 1000f); _regionTimer = new Timer(delegate { MainThreadDispatcher.Enqueue(RunRegionSpawnCheck); }, null, num2, num2); } private static void RunFactionSpawnCheck() { if (DyWorldConfig.Enabled.Value) { ForEachOnlinePlayer(delegate(EntityManager em, World world, ulong steamId, Entity charEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) ProcessFactionSpawns(em, world, steamId, charEntity); }); } } private static void ProcessFactionSpawns(EntityManager em, World world, ulong steamId, Entity charEntity) { //IL_0018: 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_000d: 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_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_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) //IL_0156: 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_0147: 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_014e: Unknown result type (might be due to invalid IL or missing references) if ((DyWorldConfig.SafeInsideCastle.Value && CastleSafetyChecker.IsInsideCastle(em, charEntity)) || !((EntityManager)(ref em)).HasComponent(charEntity)) { return; } LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(charEntity); float3 position = ((LocalToWorld)(ref componentData)).Position; double num = Now(); bool flag = DyWorldConfig.DayNightModifiersEnabled.Value && DayNightHelper.IsNight(world); foreach (VRisingFaction allFaction in FactionDatabase.AllFactions) { HeatLevel heatLevel = HeatManager.Instance.GetHeatLevel(steamId, allFaction); if (heatLevel == HeatLevel.None || !HeatManager.Instance.TryGetRecord(steamId, allFaction, out var record) || !FactionDatabase.TryGetData(allFaction, out FactionData data) || (DyWorldConfig.DayNightModifiersEnabled.Value && allFaction == VRisingFaction.Werewolves && !flag)) { continue; } bool flag2 = heatLevel == HeatLevel.Maximum && DyWorldConfig.MaximumHeatBossTrigger.Value && data.VBloods.Length != 0; double num2 = (flag2 ? DyWorldConfig.BossCooldownSeconds.Value : DyWorldConfig.SpawnCooldownSeconds.Value); if (flag && (allFaction == VRisingFaction.Undead || allFaction == VRisingFaction.Werewolves || allFaction == VRisingFaction.Cursed)) { num2 /= 2.0; } double num3 = (flag2 ? record.LastBossSpawnTimestamp : record.LastSpawnTimestamp); if (!(num - num3 < num2)) { HeatManager.Instance.UpdateSpawnTimestamp(steamId, allFaction, flag2); if (flag2) { SpawnFactionBoss(em, data, position, steamId, allFaction, charEntity); } else { SpawnFactionSquad(em, data, position, FactionSquadSize(heatLevel), steamId, allFaction, heatLevel); } } } } private static void SpawnFactionSquad(EntityManager em, FactionData factionData, float3 origin, int count, ulong steamId, VRisingFaction faction, HeatLevel heatTier = HeatLevel.None) { //IL_0010: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown if (factionData.PatrolUnits.Length == 0) { return; } int playerGearLevel = GearLevelHelper.GetPlayerGearLevel(em, FindCharEntityForPlayer(em, steamId)); int maxLevel = ((playerGearLevel > 0) ? (playerGearLevel + 10) : 999); NamedPrefab[] array = factionData.PatrolUnits.Where((NamedPrefab u) => u.Level == 0 || u.Level <= maxLevel).ToArray(); if (array.Length == 0) { array = factionData.PatrolUnits; } if (heatTier >= HeatLevel.Maximum && array.Length > 2) { array = array.OrderByDescending((NamedPrefab u) => u.Level).Take(Math.Max(2, array.Length / 2)).ToArray(); } else if (heatTier == HeatLevel.High && array.Length > 2) { array = array.OrderByDescending((NamedPrefab u) => u.Level).Take(Math.Max(2, array.Length * 3 / 4)).ToArray(); } Random random = new Random(); float3 targetPosition = default(float3); for (int i = 0; i < count; i++) { NamedPrefab unit = array[random.Next(array.Length)]; ((float3)(ref targetPosition))..ctor(origin.x + (float)(random.NextDouble() * 4.0 - 2.0), origin.y, origin.z + (float)(random.NextDouble() * 4.0 - 2.0)); UnitSpawnerHelper.SpawnQueue.Enqueue(new UnitSpawnerHelper.SpawnQueueEntry(FactionDatabase.GetResolvedGuid(unit), targetPosition, steamId, faction)); } if (DyWorldConfig.NotificationsEnabled.Value) { PlayerNotifier.Notify(steamId, factionData.DisplayName + " hunters are closing in on your location!"); } ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Spawned "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(factionData.DisplayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" hunter(s) for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(PlayerNotifier.GetPlayerName(steamId)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } private static void SpawnFactionBoss(EntityManager em, FactionData factionData, float3 origin, ulong steamId, VRisingFaction faction, Entity charEntity) { //IL_000a: 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_0020: 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_0038: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown if (factionData.VBloods.Length != 0) { int playerGearLevel = GearLevelHelper.GetPlayerGearLevel(em, charEntity); TieredVBlood vb = SelectVBloodTier(factionData.VBloods, playerGearLevel); UnitSpawnerHelper.SpawnUnit(em, FactionDatabase.GetResolvedGuid(vb), RandomOffset(origin, DyWorldConfig.SpawnRadius.Value * 1.5f), steamId, faction, isVBlood: true); string playerName = PlayerNotifier.GetPlayerName(steamId); if (DyWorldConfig.NotificationsEnabled.Value) { PlayerNotifier.Notify(steamId, $"{vb.DisplayName} (Lv{vb.Level}) has been sent to end you by the {factionData.DisplayName}!"); } PlayerNotifier.BroadcastToAll($"[DyWorld Rising] {playerName} has enraged the {factionData.DisplayName}. " + vb.DisplayName + " has been dispatched to hunt them down!"); ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(62, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Spawned V Blood '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(vb.DisplayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (Lv"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(vb.Level); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") for "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("gear-"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerGearLevel); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(faction); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogInfo(val); } } private static void RunRegionSpawnCheck() { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_0025: 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_00e0: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) if (!DyWorldConfig.Enabled.Value || !DyWorldConfig.RegionHeatEnabled.Value) { return; } World serverWorld = GetServerWorld(); if (serverWorld == null) { return; } try { EntityManager entityManager = serverWorld.EntityManager; double num = Now(); foreach (VRisingRegion allRegion in RegionDatabase.AllRegions) { HeatLevel regionHeatLevel = HeatManager.Instance.GetRegionHeatLevel(allRegion); if (regionHeatLevel == HeatLevel.None || !HeatManager.Instance.TryGetRegionRecord(allRegion, out var record) || !RegionDatabase.TryGetData(allRegion, out RegionData data)) { continue; } bool flag = regionHeatLevel >= HeatLevel.High && data.GuardianUnits.Length != 0; double num2 = (flag ? DyWorldConfig.RegionGuardianCooldownSeconds.Value : DyWorldConfig.RegionSpawnCooldownSeconds.Value); double num3 = (flag ? record.LastGuardianSpawnTimestamp : record.LastSpawnTimestamp); if (num - num3 < num2) { continue; } HeatManager.Instance.UpdateRegionSpawnTimestamp(allRegion, flag); CollectPlayersInRegion(entityManager, allRegion, out List<(ulong, Entity, float3)> result); foreach (var (steamId, playerCharacter, origin) in result) { if (!DyWorldConfig.SafeInsideCastle.Value || !CastleSafetyChecker.IsInsideCastle(entityManager, playerCharacter)) { if (flag) { SpawnRegionGuardian(entityManager, data, origin, steamId, allRegion); } else { SpawnRegionMixedPatrol(entityManager, data, origin, FactionSquadSize(regionHeatLevel), steamId, allRegion); } } } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag2 = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] RunRegionSpawnCheck: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } } private static void CollectPlayersInRegion(EntityManager em, VRisingRegion region, out List<(ulong SteamId, Entity CharEntity, float3 Position)> result) { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_003b: 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_0043: 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_0049: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_006f: 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_007c: 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_0085: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a1: Unknown result type (might be due to invalid IL or missing references) result = new List<(ulong, Entity, float3)>(); try { EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref em)).GetComponentData(current); if (!componentData.IsConnected) { continue; } Entity entity = componentData.LocalCharacter._Entity; if (((EntityManager)(ref em)).Exists(entity) && ((EntityManager)(ref em)).HasComponent(entity)) { LocalToWorld componentData2 = ((EntityManager)(ref em)).GetComponentData(entity); float3 position = ((LocalToWorld)(ref componentData2)).Position; if (RegionDatabase.GetRegion(position) == region) { result.Add((componentData.PlatformId, entity, position)); } } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch { } } private static void ProcessRegionSpawns(EntityManager em, World world, ulong steamId, Entity charEntity) { //IL_0018: 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_000d: 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_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_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) //IL_00f7: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if ((DyWorldConfig.SafeInsideCastle.Value && CastleSafetyChecker.IsInsideCastle(em, charEntity)) || !((EntityManager)(ref em)).HasComponent(charEntity)) { return; } LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(charEntity); float3 position = ((LocalToWorld)(ref componentData)).Position; double num = Now(); foreach (VRisingRegion allRegion in RegionDatabase.AllRegions) { HeatLevel regionHeatLevel = HeatManager.Instance.GetRegionHeatLevel(allRegion); if (regionHeatLevel == HeatLevel.None || !HeatManager.Instance.TryGetRegionRecord(allRegion, out var record) || !RegionDatabase.TryGetData(allRegion, out RegionData data)) { continue; } bool flag = regionHeatLevel >= HeatLevel.High && data.GuardianUnits.Length != 0; double num2 = (flag ? DyWorldConfig.RegionGuardianCooldownSeconds.Value : DyWorldConfig.RegionSpawnCooldownSeconds.Value); double num3 = (flag ? record.LastGuardianSpawnTimestamp : record.LastSpawnTimestamp); if (!(num - num3 < num2)) { HeatManager.Instance.UpdateRegionSpawnTimestamp(steamId, allRegion, flag); if (flag) { SpawnRegionGuardian(em, data, position, steamId, allRegion); } else { SpawnRegionMixedPatrol(em, data, position, FactionSquadSize(regionHeatLevel), steamId, allRegion); } } } } private static void SpawnRegionMixedPatrol(EntityManager em, RegionData regionData, float3 origin, int count, ulong steamId, VRisingRegion region) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown int playerGearLevel = GearLevelHelper.GetPlayerGearLevel(em, FindCharEntityForPlayer(em, steamId)); int num = ((playerGearLevel > 0) ? (playerGearLevel + 10) : 999); List list = new List(); VRisingFaction[] inhabitantFactions = regionData.InhabitantFactions; for (int i = 0; i < inhabitantFactions.Length; i++) { if (!FactionDatabase.TryGetData(inhabitantFactions[i], out FactionData data)) { continue; } NamedPrefab[] patrolUnits = data.PatrolUnits; for (int j = 0; j < patrolUnits.Length; j++) { NamedPrefab unit = patrolUnits[j]; if (unit.Level == 0 || unit.Level <= num) { list.Add(FactionDatabase.GetResolvedGuid(unit)); } } } if (list.Count != 0) { Random random = new Random(); float3 targetPosition = default(float3); for (int k = 0; k < count; k++) { ((float3)(ref targetPosition))..ctor(origin.x + (float)(random.NextDouble() * 4.0 - 2.0), origin.y, origin.z + (float)(random.NextDouble() * 4.0 - 2.0)); UnitSpawnerHelper.SpawnQueue.Enqueue(new UnitSpawnerHelper.SpawnQueueEntry(list[random.Next(list.Count)], targetPosition, steamId, VRisingFaction.Unknown)); } if (DyWorldConfig.NotificationsEnabled.Value) { PlayerNotifier.Notify(steamId, "A patrol from " + regionData.DisplayName + " is hunting you!"); } ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(51, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Region patrol ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" units) from "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(regionData.DisplayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(PlayerNotifier.GetPlayerName(steamId)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } } private static void SpawnRegionGuardian(EntityManager em, RegionData regionData, float3 origin, ulong steamId, VRisingRegion region) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown if (regionData.GuardianUnits.Length != 0) { Random random = new Random(); PrefabGUID prefabGuid = regionData.GuardianUnits[random.Next(regionData.GuardianUnits.Length)]; UnitSpawnerHelper.SpawnQueue.Enqueue(new UnitSpawnerHelper.SpawnQueueEntry(prefabGuid, RandomOffset(origin, DyWorldConfig.SpawnRadius.Value * 1.5f), steamId, VRisingFaction.Unknown)); if (DyWorldConfig.NotificationsEnabled.Value) { PlayerNotifier.Notify(steamId, "A guardian of " + regionData.DisplayName + " has been roused and is coming for you!"); } ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Region guardian from "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(regionData.DisplayName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } } public static TieredVBlood SelectVBloodTier(TieredVBlood[] vBloods, int playerGear) { TieredVBlood result = vBloods[0]; for (int i = 0; i < vBloods.Length; i++) { TieredVBlood tieredVBlood = vBloods[i]; if (tieredVBlood.Level <= playerGear + 10) { result = tieredVBlood; } } return result; } private static void ForEachOnlinePlayer(Action action) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //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_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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_003c: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0088: Unknown result type (might be due to invalid IL or missing references) try { World serverWorld = GetServerWorld(); if (serverWorld == null) { return; } EntityManager entityManager = serverWorld.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current); if (componentData.IsConnected) { Entity entity = componentData.LocalCharacter._Entity; if (((EntityManager)(ref entityManager)).Exists(entity)) { action(entityManager, serverWorld, componentData.PlatformId, entity); } } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DyWorld Rising] SpawnOrchestrator: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogError(val3); } } private static int FactionSquadSize(HeatLevel level) { return level switch { HeatLevel.Low => DyWorldConfig.LowHeatSquadSize.Value, HeatLevel.Medium => DyWorldConfig.MediumHeatSquadSize.Value, _ => DyWorldConfig.HighHeatSquadSize.Value, }; } private static float3 RandomOffset(float3 origin, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return UnitSpawnerHelper.RandomOffsetPosition(origin, radius); } private static Entity FindCharEntityForPlayer(EntityManager em, ulong steamId) { //IL_000a: 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_0019: 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_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_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_007d: 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_003c: 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_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) try { EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref em)).GetComponentData(current); if (componentData.PlatformId == steamId) { return componentData.LocalCharacter._Entity; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch { } return Entity.Null; } private static World? GetServerWorld() { Enumerator enumerator = World.All.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == "Server") { return current; } } return null; } private static double Now() { return (double)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000.0; } public void Dispose() { _factionTimer?.Dispose(); _regionTimer?.Dispose(); _factionTimer = (_regionTimer = null); } } public readonly struct TieredVBlood { public readonly string DisplayName; public readonly string PrefabName; public readonly PrefabGUID Guid; public readonly int Level; public TieredVBlood(string displayName, string prefabName, int hash, int level) { //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) DisplayName = displayName; PrefabName = prefabName; Guid = new PrefabGUID(hash); Level = level; } } public static class UnitSpawnerHelper { public record SpawnQueueEntry(PrefabGUID PrefabGuid, float3 TargetPosition, ulong OwnerSteamId, VRisingFaction Faction, bool IsVBlood = false) { [CompilerGenerated] protected virtual bool PrintMembers(StringBuilder builder) { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) RuntimeHelpers.EnsureSufficientExecutionStack(); builder.Append("PrefabGuid = "); PrefabGUID prefabGuid = PrefabGuid; builder.Append(((object)(PrefabGUID)(ref prefabGuid)).ToString()); builder.Append(", TargetPosition = "); float3 targetPosition = TargetPosition; builder.Append(((object)(float3)(ref targetPosition)).ToString()); builder.Append(", OwnerSteamId = "); builder.Append(OwnerSteamId.ToString()); builder.Append(", Faction = "); builder.Append(Faction.ToString()); builder.Append(", IsVBlood = "); builder.Append(IsVBlood.ToString()); return true; } } public static readonly Queue SpawnQueue = new Queue(); public static readonly Dictionary PendingTeleports = new Dictionary(); public static readonly Dictionary SpawnedUnitTimestamps = new Dictionary(); private static readonly Dictionary _entityFrameAge = new Dictionary(); private static readonly Dictionary _factionEntityCache = new Dictionary(); public static void DrainSpawnQueue(EntityManager em, int maxPerTick) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) for (int i = 0; i < maxPerTick; i++) { if (SpawnQueue.Count <= 0) { break; } SpawnQueueEntry spawnQueueEntry = SpawnQueue.Dequeue(); SpawnUnit(em, spawnQueueEntry.PrefabGuid, spawnQueueEntry.TargetPosition, Entity.Null, spawnQueueEntry.OwnerSteamId, spawnQueueEntry.Faction, spawnQueueEntry.IsVBlood); } } public static int GetEntityFrameAge(Entity e) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!_entityFrameAge.TryGetValue(e, out var value)) { return 0; } return value; } public static void SetEntityAge(Entity e, int age) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) _entityFrameAge[e] = age; } public static void ClearEntityAge(Entity e) { //IL_0005: 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) _entityFrameAge.Remove(e); PendingTeleports.Remove(e); } public static Entity SpawnUnit(EntityManager em, PrefabGUID prefabGuid, float3 position, Entity ownerCharEntity, ulong ownerSteamId = 0uL, VRisingFaction faction = VRisingFaction.Unknown, bool isVBlood = false) { //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //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_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_028b: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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) //IL_00a5: 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_0042: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_006a: Expected O, but got Unknown //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0144: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { World serverWorld = GetServerWorld(); if (serverWorld == null) { return Entity.Null; } Entity val = FindFactionEntity(em, faction, prefabGuid); if (!((EntityManager)(ref em)).Exists(val)) { if (!((EntityManager)(ref em)).Exists(ownerCharEntity) && ownerSteamId != 0L) { ownerCharEntity = FindCharEntityLocal(em, ownerSteamId); } val = ownerCharEntity; if (!((EntityManager)(ref em)).Exists(val)) { return Entity.Null; } ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(84, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DyWorld Rising] SpawnUnit: no faction entity for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(faction); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", using player (will be friendly)."); } log.LogWarning(val2); } ServerScriptMapper existingSystemManaged = serverWorld.GetExistingSystemManaged(); if (existingSystemManaged == null) { return Entity.Null; } ServerGameManager serverGameManager = existingSystemManaged.GetServerGameManager(); float3 val3 = default(float3); ((float3)(ref val3))..ctor(position.x + 50000f, position.y, position.z); Entity val4 = ((ServerGameManager)(ref serverGameManager)).InstantiateEntityImmediate(val, prefabGuid); if (!((EntityManager)(ref em)).Exists(val4)) { return Entity.Null; } if (((EntityManager)(ref em)).HasComponent(val4)) { ((EntityManager)(ref em)).SetComponentData(val4, new Translation { Value = val3 }); } if (((EntityManager)(ref em)).HasComponent(val4)) { ((EntityManager)(ref em)).SetComponentData(val4, new LastTranslation { Value = val3 }); } if (((EntityManager)(ref em)).HasComponent(val4)) { LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(val4); ((EntityManager)(ref em)).SetComponentData(val4, new LocalToWorld { Value = float4x4.TRS(val3, ((LocalToWorld)(ref componentData)).Rotation, new float3(1f, 1f, 1f)) }); } PendingTeleports[val4] = position; _entityFrameAge[val4] = 0; if (ownerSteamId != 0L) { HuntTracker.Register(val4, ownerSteamId, faction, isVBlood); } ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(65, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[DyWorld Rising] Spawned "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((PrefabGUID)(ref prefabGuid)).GuidHash); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" at far pos (teleport pending). Owner: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted((val == ownerCharEntity) ? "PLAYER(fallback)" : "ENEMY"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("."); } log2.LogInfo(val5); return val4; } catch (Exception ex) { ManualLogSource log3 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(40, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[DyWorld Rising] SpawnUnit failed for "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(((PrefabGUID)(ref prefabGuid)).GuidHash); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(ex.Message); } log3.LogError(val6); return Entity.Null; } } public static Entity SpawnUnit(EntityManager em, PrefabGUID prefabGuid, float3 position, ulong ownerSteamId = 0uL, VRisingFaction faction = VRisingFaction.Unknown, bool isVBlood = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return SpawnUnit(em, prefabGuid, position, Entity.Null, ownerSteamId, faction, isVBlood); } public static void ProcessPendingRegistrations(EntityManager em) { } private static Entity FindFactionEntity(EntityManager em, VRisingFaction faction, PrefabGUID targetGuid) { //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0114: 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_011d: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) try { if (_factionEntityCache.TryGetValue(faction, out var value) && ((EntityManager)(ref em)).Exists(value)) { return value; } _factionEntityCache.Remove(faction); if (!FactionDatabase.TryGetData(faction, out FactionData data)) { return Entity.Null; } HashSet hashSet = new HashSet(); NamedPrefab[] patrolUnits = data.PatrolUnits; PrefabGUID val; foreach (NamedPrefab unit in patrolUnits) { val = FactionDatabase.GetResolvedGuid(unit); hashSet.Add(((PrefabGUID)(ref val)).GuidHash); } TieredVBlood[] vBloods = data.VBloods; foreach (TieredVBlood vb in vBloods) { val = FactionDatabase.GetResolvedGuid(vb); hashSet.Add(((PrefabGUID)(ref val)).GuidHash); } if (hashSet.Count == 0) { return Entity.Null; } EntityQuery val2 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Entity val4 = Entity.Null; try { Enumerator enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (((EntityManager)(ref em)).HasComponent(current)) { val = ((EntityManager)(ref em)).GetComponentData(current); int guidHash = ((PrefabGUID)(ref val)).GuidHash; if (hashSet.Contains(guidHash)) { val4 = current; break; } } } } finally { val3.Dispose(); ((EntityQuery)(ref val2)).Dispose(); } if (((EntityManager)(ref em)).Exists(val4)) { _factionEntityCache[faction] = val4; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[DyWorld Rising] Cached faction entity for "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(faction); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val4); } log.LogInfo(val5); } return val4; } catch { return Entity.Null; } } public static void RestoreTeamFromPrefab(EntityManager em, Entity spawned, World world) { } public static float3 RandomOffsetPosition(float3 origin, float radius) { //IL_003f: 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_0054: 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) Random random = new Random(); float num = (float)(random.NextDouble() * Math.PI * 2.0); float num2 = radius * 0.75f + (float)(random.NextDouble() * (double)radius * 0.25); return new float3(origin.x + math.cos(num) * num2, origin.y, origin.z + math.sin(num) * num2); } private static Entity FindCharEntityLocal(EntityManager em, ulong steamId) { //IL_000a: 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_0019: 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_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_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_007d: 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_003c: 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_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) try { EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User componentData = ((EntityManager)(ref em)).GetComponentData(current); if (componentData.PlatformId == steamId) { return componentData.LocalCharacter._Entity; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch { } return Entity.Null; } private static World? GetServerWorld() { Enumerator enumerator = World.All.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == "Server") { return current; } } return null; } } } namespace DyWorldRising.Persistence { public class HeatPersistenceService { private record SaveData(int Version, DateTime SavedAt, List Players, List GlobalRegionHeat); private record PlayerDto(ulong SteamId, List FactionHeat, double LastSiegeEndTime = 0.0); private record FactionEntry(string Key, float HeatValue, double LastKillTimestamp, double LastSpawnTimestamp, double LastBossSpawnTimestamp); private record RegionEntry(string Key, float HeatValue, double LastKillTimestamp, double LastSpawnTimestamp, double LastGuardianSpawnTimestamp); private readonly string _savePath; private static readonly JsonSerializerOptions _json = new JsonSerializerOptions { WriteIndented = true }; public HeatPersistenceService(string bepInExRootPath) { string text = Path.Combine(bepInExRootPath, "data", "dyworldrising"); Directory.CreateDirectory(text); _savePath = Path.Combine(text, "heat_data.json"); } public void Load() { //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown if (!File.Exists(_savePath)) { return; } bool flag = default(bool); try { SaveData saveData = JsonSerializer.Deserialize(File.ReadAllText(_savePath), _json); if (saveData == null) { return; } foreach (PlayerDto item in saveData.Players ?? new List()) { Dictionary dictionary = new Dictionary(); foreach (FactionEntry item2 in item.FactionHeat) { if (Enum.TryParse(item2.Key, out var result)) { dictionary[result] = new FactionHeatRecord { HeatValue = item2.HeatValue, LastKillTimestamp = item2.LastKillTimestamp, LastSpawnTimestamp = item2.LastSpawnTimestamp, LastBossSpawnTimestamp = item2.LastBossSpawnTimestamp }; } } HeatManager.Instance.LoadState(item.SteamId, dictionary, new Dictionary()); if (item.LastSiegeEndTime > 0.0) { SiegeManager.Instance.LoadCooldown(item.SteamId, item.LastSiegeEndTime); } } Dictionary dictionary2 = new Dictionary(); foreach (RegionEntry item3 in saveData.GlobalRegionHeat ?? new List()) { if (Enum.TryParse(item3.Key, out var result2)) { dictionary2[result2] = new RegionHeatRecord { HeatValue = item3.HeatValue, LastKillTimestamp = item3.LastKillTimestamp, LastSpawnTimestamp = item3.LastSpawnTimestamp, LastGuardianSpawnTimestamp = item3.LastGuardianSpawnTimestamp }; } } HeatManager.Instance.LoadGlobalRegionState(dictionary2); ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(64, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Loaded heat data for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(saveData.Players?.Count ?? 0); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" players, "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(dictionary2.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" global regions."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[DyWorld Rising] Failed to load heat data: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log2.LogError(val2); } } public void Save() { //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown try { List list = new List(); foreach (PlayerHeatState allState in HeatManager.Instance.GetAllStates()) { List list2 = new List(); lock (allState.FactionHeat) { foreach (var (vRisingFaction2, factionHeatRecord2) in allState.FactionHeat) { list2.Add(new FactionEntry(vRisingFaction2.ToString(), factionHeatRecord2.HeatValue, factionHeatRecord2.LastKillTimestamp, factionHeatRecord2.LastSpawnTimestamp, factionHeatRecord2.LastBossSpawnTimestamp)); } } double num = SiegeManager.Instance.GetState(allState.SteamId)?.LastSiegeEndTime ?? 0.0; if (list2.Count > 0 || num > 0.0) { list.Add(new PlayerDto(allState.SteamId, list2, num)); } } List list3 = new List(); foreach (var (vRisingRegion2, regionHeatRecord2) in HeatManager.Instance.GetAllRegionRecords()) { list3.Add(new RegionEntry(vRisingRegion2.ToString(), regionHeatRecord2.HeatValue, regionHeatRecord2.LastKillTimestamp, regionHeatRecord2.LastSpawnTimestamp, regionHeatRecord2.LastGuardianSpawnTimestamp)); } SaveData value = new SaveData(2, DateTime.UtcNow, list, list3); File.WriteAllText(_savePath, JsonSerializer.Serialize(value, _json)); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Failed to save heat data: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } } } } namespace DyWorldRising.Patches { [HarmonyPatch(typeof(DeathEventListenerSystem), "OnUpdate")] public static class OnDeathSystemPatch { [HarmonyPostfix] public static void Postfix(DeathEventListenerSystem __instance) { //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Expected O, but got Unknown //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_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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_003c: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_015e: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0295: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Expected O, but got Unknown //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Expected O, but got Unknown if (!DyWorldConfig.Enabled.Value) { return; } bool flag = default(bool); try { EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToComponentDataArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { DeathEvent current = enumerator.Current; Entity died = current.Died; Entity killer = current.Killer; if (!((EntityManager)(ref entityManager)).Exists(died)) { continue; } PrefabGUID val3 = (PrefabGUID)(((EntityManager)(ref entityManager)).HasComponent(died) ? ((EntityManager)(ref entityManager)).GetComponentData(died) : default(PrefabGUID)); if (((EntityManager)(ref entityManager)).HasComponent(died)) { Entity userEntity = ((EntityManager)(ref entityManager)).GetComponentData(died).UserEntity; if (((EntityManager)(ref entityManager)).Exists(userEntity) && ((EntityManager)(ref entityManager)).HasComponent(userEntity)) { ulong platformId = ((EntityManager)(ref entityManager)).GetComponentData(userEntity).PlatformId; HeatManager.Instance.ResetOnDeath(platformId); ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(43, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[DyWorld Rising] Player "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(platformId); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" died - heat reset."); } log.LogInfo(val4); } continue; } Entity val5 = ResolvePlayer(entityManager, killer); if (DyWorldConfig.FightingBackEnabled.Value && HuntTracker.TryGet(died, out var info)) { HuntTracker.Remove(died); float3 position = GetPosition(entityManager, died); if (!info.IsVBlood) { float num = (float)Math.Max(GearLevelHelper.GetUnitLevel(val3), 1) * DyWorldConfig.HunterKillHeatReductionMultiplier.Value; HeatManager.Instance.SubtractKill(info.OwnerSteamId, info.Faction, num); if (DyWorldConfig.NotificationsEnabled.Value) { FactionData data; string value = (FactionDatabase.TryGetData(info.Faction, out data) ? data.DisplayName : info.Faction.ToString()); PlayerNotifier.Notify(info.OwnerSteamId, $"You fought off a {value} hunter! (-{num:F0} heat with the {value})"); } } RewardGiver.GiveHunterKillReward(entityManager, info.OwnerSteamId, val5, position, info.IsVBlood); } else { if (!((EntityManager)(ref entityManager)).Exists(val5)) { continue; } Entity userEntity2 = ((EntityManager)(ref entityManager)).GetComponentData(val5).UserEntity; if (!((EntityManager)(ref entityManager)).Exists(userEntity2) || !((EntityManager)(ref entityManager)).HasComponent(userEntity2)) { continue; } ulong platformId2 = ((EntityManager)(ref entityManager)).GetComponentData(userEntity2).PlatformId; int unitLevel = GearLevelHelper.GetUnitLevel(val3); int playerGearLevel = GearLevelHelper.GetPlayerGearLevel(entityManager, val5); float num2 = GearLevelHelper.ComputeHeatMultiplier(playerGearLevel, unitLevel); FactionDatabase.TryGetFaction(val3, out var faction); VRisingRegion region = RegionDatabase.GetRegion(GetPosition(entityManager, died)); if (((EntityManager)(ref entityManager)).HasComponent(died)) { float num3 = (float)((unitLevel > 0) ? unitLevel : 16) * DyWorldConfig.VBloodLevelMultiplier.Value * num2; if (faction != 0) { HeatManager.Instance.AddKill(platformId2, faction, num3); } if (DyWorldConfig.RegionHeatEnabled.Value && region != 0) { HeatManager.Instance.AddRegionKill(platformId2, region, num3 * 0.5f); } if (DyWorldConfig.NotificationsEnabled.Value) { string playerName = PlayerNotifier.GetPlayerName(platformId2); FactionData data2; string value2 = ((faction != 0 && FactionDatabase.TryGetData(faction, out data2)) ? data2.DisplayName : "the unknown"); PlayerNotifier.BroadcastToAll($"[DyWorld Rising] {playerName} has slain a V Blood of {value2}!"); } ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(64, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[DyWorld Rising] V Blood Lv"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(unitLevel); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" killed! +"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num3, "F0"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" heat "); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("→ "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(faction); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" / "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(region); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (gear "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(playerGearLevel); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", mult x"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num2, "F2"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")"); } log2.LogInfo(val4); continue; } float num4 = (float)((unitLevel <= 0) ? 1 : unitLevel) * num2; if (faction != 0) { HeatManager.Instance.AddKill(platformId2, faction, num4); string playerName2 = PlayerNotifier.GetPlayerName(platformId2); ManualLogSource log3 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(58, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[DyWorld Rising] "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(playerName2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (gear "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(playerGearLevel); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(") killed Lv"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(unitLevel); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(faction); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("(heat +"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num4, "F1"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" = "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(unitLevel); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("×"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num2, "F2"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("). "); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Total: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(HeatManager.Instance.GetHeatLevel(platformId2, faction)); } log3.LogInfo(val4); } if (DyWorldConfig.RegionHeatEnabled.Value && region != 0) { HeatManager.Instance.AddRegionKill(platformId2, region, num4 * 0.5f); } } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } catch (Exception ex) { ManualLogSource log4 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[DyWorld Rising] OnDeathSystemPatch: "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(ex.Message); } log4.LogError(val6); } } private static Entity ResolvePlayer(EntityManager em, Entity source) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0040: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0076: Unknown result type (might be due to invalid IL or missing references) if (!((EntityManager)(ref em)).Exists(source)) { return Entity.Null; } if (((EntityManager)(ref em)).HasComponent(source)) { return source; } if (((EntityManager)(ref em)).HasComponent(source)) { Entity owner = ((EntityManager)(ref em)).GetComponentData(source).Owner; if (((EntityManager)(ref em)).Exists(owner)) { if (((EntityManager)(ref em)).HasComponent(owner)) { return owner; } if (((EntityManager)(ref em)).HasComponent(owner)) { Entity owner2 = ((EntityManager)(ref em)).GetComponentData(owner).Owner; if (((EntityManager)(ref em)).Exists(owner2) && ((EntityManager)(ref em)).HasComponent(owner2)) { return owner2; } } } } return Entity.Null; } private static float3 GetPosition(EntityManager em, Entity entity) { //IL_0002: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0028: 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) if (((EntityManager)(ref em)).HasComponent(entity)) { LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(entity); return ((LocalToWorld)(ref componentData)).Position; } if (((EntityManager)(ref em)).HasComponent(entity)) { return ((EntityManager)(ref em)).GetComponentData(entity).Value; } return float3.zero; } } [HarmonyPatch(typeof(TriggerPersistenceSaveSystem), "OnUpdate")] public static class SaveSystemPatch { [HarmonyPostfix] public static void Postfix() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown try { Plugin.Persistence?.Save(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[DyWorld Rising] Save hook failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } } [HarmonyPatch(typeof(ServerBootstrapSystem), "OnUpdate")] public static class ServerBootstrapPatch { private static int _expireCheckCounter; [HarmonyPostfix] public static void Postfix(ServerBootstrapSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager; MainThreadDispatcher.Drain(); UnitSpawnerHelper.ProcessPendingRegistrations(entityManager); UnitSpawnerHelper.DrainSpawnQueue(entityManager, DyWorldConfig.SpawnQueueRatePerTick.Value); ProcessPendingTeleports(entityManager); ProcessExpiredUnits(entityManager); } private static void ProcessPendingTeleports(EntityManager em) { //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_0035: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00cf: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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) Dictionary pendingTeleports = UnitSpawnerHelper.PendingTeleports; if (pendingTeleports.Count == 0) { return; } List list = new List(); bool flag = default(bool); try { foreach (var (val3, val4) in pendingTeleports) { if (!((EntityManager)(ref em)).Exists(val3)) { list.Add(val3); continue; } int num = UnitSpawnerHelper.GetEntityFrameAge(val3) + 1; UnitSpawnerHelper.SetEntityAge(val3, num); if (num >= 3) { if (((EntityManager)(ref em)).HasComponent(val3)) { ((EntityManager)(ref em)).SetComponentData(val3, new Translation { Value = val4 }); } if (((EntityManager)(ref em)).HasComponent(val3)) { ((EntityManager)(ref em)).SetComponentData(val3, new LastTranslation { Value = val4 }); } if (((EntityManager)(ref em)).HasComponent(val3)) { LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData(val3); ((EntityManager)(ref em)).SetComponentData(val3, new LocalToWorld { Value = float4x4.TRS(val4, ((LocalToWorld)(ref componentData)).Rotation, new float3(1f, 1f, 1f)) }); } UnitSpawnerHelper.SpawnedUnitTimestamps[val3] = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(64, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[DyWorld Rising] Teleported deferred spawn to ("); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val4.x, "F0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val4.z, "F0"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(") after "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" frames."); } log.LogInfo(val5); list.Add(val3); } } } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val6 = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[DyWorld Rising] ProcessPendingTeleports: "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(ex.Message); } log2.LogWarning(val6); } foreach (Entity item in list) { UnitSpawnerHelper.ClearEntityAge(item); } } private static void ProcessExpiredUnits(EntityManager em) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown double num = DyWorldConfig.SpawnedUnitLifetimeSeconds.Value; if (num <= 0.0 || ++_expireCheckCounter < 300) { return; } _expireCheckCounter = 0; double num2 = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); List list = new List(); foreach (var (val2, num4) in UnitSpawnerHelper.SpawnedUnitTimestamps) { if (num2 - num4 < num) { continue; } if (!((EntityManager)(ref em)).Exists(val2)) { list.Add(val2); continue; } try { ((EntityManager)(ref em)).DestroyEntity(val2); } catch { } list.Add(val2); } if (list.Count <= 0) { return; } foreach (Entity item in list) { UnitSpawnerHelper.SpawnedUnitTimestamps.Remove(item); } ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(49, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DyWorld Rising] Auto-despawned "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" expired unit(s)."); } log.LogInfo(val3); } } [HarmonyPatch(typeof(PrefabCollectionSystem), "OnUpdate")] public static class WorldReadyPatch { private static bool _initialized; private static int _retryCount; private const int MaxRetries = 300; [HarmonyPostfix] public static void Postfix(PrefabCollectionSystem __instance) { if (_initialized) { return; } if (_retryCount++ > 300) { _initialized = true; return; } _ = FactionDatabase.ResolvedCount; FactionDatabase.AutoResolve(__instance); if (FactionDatabase.ResolvedCount != 0) { _initialized = true; FactionDatabase.ValidateAllPrefabs(__instance); RewardTable.AutoResolveItems(__instance); } } } } namespace DyWorldRising.Data { public struct FactionHeatRecord { public float HeatValue; public double LastKillTimestamp; public double LastSpawnTimestamp; public double LastBossSpawnTimestamp; } public enum HeatLevel { None, Low, Medium, High, Maximum } public readonly struct HuntInfo { public readonly ulong OwnerSteamId; public readonly VRisingFaction Faction; public readonly bool IsVBlood; public readonly bool IsSiegeWave; public HuntInfo(ulong steamId, VRisingFaction faction, bool isVBlood = false, bool isSiegeWave = false) { OwnerSteamId = steamId; Faction = faction; IsVBlood = isVBlood; IsSiegeWave = isSiegeWave; } } public class PlayerHeatState { public ulong SteamId { get; init; } public Dictionary FactionHeat { get; } = new Dictionary(); public Dictionary RegionHeat { get; } = new Dictionary(); } public struct RegionHeatRecord { public float HeatValue; public double LastKillTimestamp; public double LastSpawnTimestamp; public double LastGuardianSpawnTimestamp; } public class SiegeState { public ulong SteamId { get; init; } public VRisingFaction[] SiegingFactions { get; init; } = Array.Empty(); public int CurrentWave { get; set; } public double WaveStartTime { get; set; } public double SiegeStartTime { get; set; } public float3 CastleCenter { get; init; } public bool IsActive { get; set; } public double LastSiegeEndTime { get; set; } public string FactionNames { get { FactionData data; return string.Join(" and ", SiegingFactions.Select((VRisingFaction f) => (!FactionDatabase.TryGetData(f, out data)) ? f.ToString() : data.DisplayName)); } } } } namespace DyWorldRising.Config { public static class DyWorldConfig { public static ConfigEntry Enabled { get; private set; } public static ConfigEntry LowHeatKills { get; private set; } public static ConfigEntry MediumHeatKills { get; private set; } public static ConfigEntry HighHeatKills { get; private set; } public static ConfigEntry MaximumHeatKills { get; private set; } public static ConfigEntry VBloodLevelMultiplier { get; private set; } public static ConfigEntry DecayIntervalSeconds { get; private set; } public static ConfigEntry DecayAmountPerInterval { get; private set; } public static ConfigEntry SpawnCheckIntervalSeconds { get; private set; } public static ConfigEntry LowHeatSquadSize { get; private set; } public static ConfigEntry MediumHeatSquadSize { get; private set; } public static ConfigEntry HighHeatSquadSize { get; private set; } public static ConfigEntry MaximumHeatBossTrigger { get; private set; } public static ConfigEntry BossCooldownSeconds { get; private set; } public static ConfigEntry SpawnCooldownSeconds { get; private set; } public static ConfigEntry SpawnRadius { get; private set; } public static ConfigEntry SpawnQueueRatePerTick { get; private set; } public static ConfigEntry SpawnedUnitLifetimeSeconds { get; private set; } public static ConfigEntry SafeInsideCastle { get; private set; } public static ConfigEntry SafeCastleRadius { get; private set; } public static ConfigEntry RegionHeatEnabled { get; private set; } public static ConfigEntry RegionLowHeatKills { get; private set; } public static ConfigEntry RegionMediumHeatKills { get; private set; } public static ConfigEntry RegionHighHeatKills { get; private set; } public static ConfigEntry RegionMaximumHeatKills { get; private set; } public static ConfigEntry RegionDecayIntervalSeconds { get; private set; } public static ConfigEntry RegionDecayAmountPerInterval { get; private set; } public static ConfigEntry RegionSpawnCheckIntervalSeconds { get; private set; } public static ConfigEntry RegionSpawnCooldownSeconds { get; private set; } public static ConfigEntry RegionGuardianCooldownSeconds { get; private set; } public static ConfigEntry NotificationsEnabled { get; private set; } public static ConfigEntry FightingBackEnabled { get; private set; } public static ConfigEntry HunterKillHeatReductionMultiplier { get; private set; } public static ConfigEntry HeatDeathRetentionFactor { get; private set; } public static ConfigEntry AllianceHeatEnabled { get; private set; } public static ConfigEntry DayNightModifiersEnabled { get; private set; } public static ConfigEntry SiegeEnabled { get; private set; } public static ConfigEntry SiegeCheckIntervalSeconds { get; private set; } public static ConfigEntry SiegeMinimumFactions { get; private set; } public static ConfigEntry SiegeCooldownSeconds { get; private set; } public static ConfigEntry SiegeWaveCount { get; private set; } public static ConfigEntry SiegeWaveDurationSeconds { get; private set; } public static ConfigEntry SiegeWaveSpawnCount { get; private set; } public static ConfigEntry SiegeSpawnRadius { get; private set; } public static ConfigEntry SiegeHeatReductionOnSurvival { get; private set; } public static ConfigEntry RewardsEnabled { get; private set; } public static ConfigEntry HunterKillRewardCount { get; private set; } public static ConfigEntry VBloodKillRewardCount { get; private set; } public static ConfigEntry SiegeBaseRewardCount { get; private set; } public static ConfigEntry NextTierBiasChance { get; private set; } public static void Init(ConfigFile cfg) { Enabled = cfg.Bind("General", "Enabled", true, "Enable or disable the entire DyWorld Rising heat system."); LowHeatKills = cfg.Bind("FactionHeatThresholds", "LowHeatKills", 500f, "Heat to reach Low faction anger (unit level is now the base heat per kill)."); MediumHeatKills = cfg.Bind("FactionHeatThresholds", "MediumHeatKills", 1800f, "Heat to reach Medium faction anger."); HighHeatKills = cfg.Bind("FactionHeatThresholds", "HighHeatKills", 4000f, "Heat to reach High faction anger."); MaximumHeatKills = cfg.Bind("FactionHeatThresholds", "MaximumHeatKills", 8000f, "Heat to reach Maximum faction anger."); VBloodLevelMultiplier = cfg.Bind("FactionHeatThresholds", "VBloodLevelMultiplier", 10f, "V Blood heat = unit level × this multiplier × gear multiplier. Alpha Wolf (lv16) = 160, Dracula (lv91) = 910."); DecayIntervalSeconds = cfg.Bind("FactionHeatDecay", "DecayIntervalSeconds", 60f, "Seconds between faction heat decay ticks."); DecayAmountPerInterval = cfg.Bind("FactionHeatDecay", "DecayAmountPerInterval", 10f, "Heat removed per faction decay tick (scaled up for new formula)."); SpawnCheckIntervalSeconds = cfg.Bind("FactionSpawning", "SpawnCheckIntervalSeconds", 30f, "Seconds between faction spawn checks."); LowHeatSquadSize = cfg.Bind("FactionSpawning", "LowHeatSquadSize", 3, "Units in a Low-heat faction squad."); MediumHeatSquadSize = cfg.Bind("FactionSpawning", "MediumHeatSquadSize", 5, "Units in a Medium-heat faction squad."); HighHeatSquadSize = cfg.Bind("FactionSpawning", "HighHeatSquadSize", 8, "Units in a High/Maximum-heat faction squad."); MaximumHeatBossTrigger = cfg.Bind("FactionSpawning", "MaximumHeatBossTrigger", false, "Spawn a faction V Blood at Maximum heat (level-appropriate)."); BossCooldownSeconds = cfg.Bind("FactionSpawning", "BossCooldownSeconds", 300f, "Minimum seconds between V Blood spawns per player per faction."); SpawnCooldownSeconds = cfg.Bind("FactionSpawning", "SpawnCooldownSeconds", 120f, "Minimum seconds between faction squad spawns per player per faction."); SpawnRadius = cfg.Bind("FactionSpawning", "SpawnRadius", 40f, "Distance from player at which faction hunters spawn."); SpawnQueueRatePerTick = cfg.Bind("FactionSpawning", "SpawnQueueRatePerTick", 1, "Units dequeued and spawned per server tick. Higher = faster but more load per tick."); SpawnedUnitLifetimeSeconds = cfg.Bind("FactionSpawning", "SpawnedUnitLifetimeSeconds", 300f, "Seconds before DyWorld Rising-spawned units auto-despawn. 0 = never despawn."); SafeInsideCastle = cfg.Bind("Castle", "SafeInsideCastle", true, "Players inside their own castle territory are not hunted."); SafeCastleRadius = cfg.Bind("Castle", "SafeCastleRadius", 200f, "Radius (units) from the castle territory center considered 'inside'. Increase if large castles are not covered."); RegionHeatEnabled = cfg.Bind("RegionHeat", "Enabled", true, "Enable global region heat system. All players killing in a region share the same heat counter."); RegionLowHeatKills = cfg.Bind("RegionHeat", "LowHeatKills", 2500f, "Global region heat to trigger Low anger (shared across all players in the region)."); RegionMediumHeatKills = cfg.Bind("RegionHeat", "MediumHeatKills", 7500f, "Global region heat for Medium anger."); RegionHighHeatKills = cfg.Bind("RegionHeat", "HighHeatKills", 15000f, "Global region heat for High anger."); RegionMaximumHeatKills = cfg.Bind("RegionHeat", "MaximumHeatKills", 25000f, "Global region heat for Maximum anger."); RegionDecayIntervalSeconds = cfg.Bind("RegionHeat", "DecayIntervalSeconds", 90f, "Seconds between global region heat decay ticks."); RegionDecayAmountPerInterval = cfg.Bind("RegionHeat", "DecayAmountPerInterval", 20f, "Heat removed per region decay tick."); RegionSpawnCheckIntervalSeconds = cfg.Bind("RegionHeat", "SpawnCheckIntervalSeconds", 45f, "Seconds between region spawn checks."); RegionSpawnCooldownSeconds = cfg.Bind("RegionHeat", "SpawnCooldownSeconds", 180f, "Seconds between region patrol spawns per region."); RegionGuardianCooldownSeconds = cfg.Bind("RegionHeat", "GuardianCooldownSeconds", 600f, "Seconds between region guardian spawns."); NotificationsEnabled = cfg.Bind("Notifications", "Enabled", true, "Send in-game chat messages to players when their heat tier changes or hunters spawn."); FightingBackEnabled = cfg.Bind("FightingBack", "Enabled", true, "Killing a hunter spawned by DyWorld Rising reduces your heat with that faction."); HunterKillHeatReductionMultiplier = cfg.Bind("FightingBack", "HeatReductionMultiplier", 2f, "Heat removed per hunter kill = hunter unit level × this multiplier. lv35 hunter = 70 heat removed."); HeatDeathRetentionFactor = cfg.Bind("Death", "HeatRetentionOnDeath", 0.5f, "Fraction of faction heat kept on death (0 = full reset, 1 = no reset, 0.5 = keep half)."); AllianceHeatEnabled = cfg.Bind("Alliances", "Enabled", true, "Allied factions share a portion of heat when you kill one of them."); DayNightModifiersEnabled = cfg.Bind("DayNight", "Enabled", true, "Undead/Werewolves spawn more aggressively at night; Werewolves will not spawn during the day."); SiegeEnabled = cfg.Bind("CastleSiege", "Enabled", true, "Enable the Castle Siege system."); SiegeCheckIntervalSeconds = cfg.Bind("CastleSiege", "SiegeCheckIntervalSeconds", 300f, "How often (seconds) to check if a siege should trigger."); SiegeMinimumFactions = cfg.Bind("CastleSiege", "MinimumFactionsRequired", 2, "Factions at Maximum heat required to trigger a siege."); SiegeCooldownSeconds = cfg.Bind("CastleSiege", "SiegeCooldownSeconds", 7200f, "Minimum seconds between castle sieges per player."); SiegeWaveCount = cfg.Bind("CastleSiege", "WaveCount", 3, "Number of enemy waves in a siege."); SiegeWaveDurationSeconds = cfg.Bind("CastleSiege", "WaveDurationSeconds", 120f, "Time (seconds) between siege waves."); SiegeWaveSpawnCount = cfg.Bind("CastleSiege", "WaveSpawnCount", 6, "Units in wave 1. Wave 2 = ×1.5, Wave 3 = ×2."); SiegeSpawnRadius = cfg.Bind("CastleSiege", "SiegeSpawnRadius", 30f, "Distance from castle center for siege unit spawns."); SiegeHeatReductionOnSurvival = cfg.Bind("CastleSiege", "HeatReductionOnSurvival", 1000f, "Heat removed per faction when the player survives all waves (scaled up)."); RewardsEnabled = cfg.Bind("Rewards", "Enabled", true, "Give item rewards when hunters are killed or siege is repelled."); HunterKillRewardCount = cfg.Bind("Rewards", "HunterKillRewardCount", 1, "Item types rewarded per hunter kill."); VBloodKillRewardCount = cfg.Bind("Rewards", "VBloodKillRewardCount", 2, "Item types rewarded when a VBlood hunter is killed."); SiegeBaseRewardCount = cfg.Bind("Rewards", "SiegeBaseRewardCount", 3, "Base item types rewarded for surviving a siege."); NextTierBiasChance = cfg.Bind("Rewards", "NextTierBiasChance", 0.3f, "Probability that a reward pulls from the next gear tier up."); } } } namespace DyWorldRising.Commands { [CommandGroup("dyworldrising", "dw")] public class HeatCommands { [Command("heat", "h", null, "Show your current faction heat levels and decay estimates", null, false)] public static void HeatStatus(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; ctx.Reply(BuildFactionReport(platformId, "Your")); } [Command("heat check", null, null, "Show another player's faction heat (admin)", null, true)] public static void HeatCheck(ChatCommandContext ctx, string playerName) { if (TryFindPlayer(ctx, playerName, out var steamId)) { ctx.Reply(BuildFactionReport(steamId, playerName + "'s")); } } [Command("heat set", "hs", null, "Set YOUR faction heat for testing (admin)", null, true)] public static void HeatSetSelf(ChatCommandContext ctx, string factionName, float value) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; if (!Enum.TryParse(factionName, ignoreCase: true, out var result)) { ctx.Reply("Unknown faction. Valid: " + string.Join(", ", from n in Enum.GetNames() where n != "Unknown" select n)); return; } HeatManager.Instance.TryGetRecord(platformId, result, out var record); record.HeatValue = Math.Max(0f, value); HeatManager.Instance.SetRecord(platformId, result, record); HeatLevel heatLevel = HeatManager.Instance.GetHeatLevel(platformId, result); ctx.Reply($"{result} heat set to {value:F1} ({heatLevel})."); } [Command("heat set player", null, null, "Set another player's faction heat (admin)", null, true)] public static void HeatSet(ChatCommandContext ctx, string playerName, string factionName, float value) { if (!TryFindPlayer(ctx, playerName, out var steamId)) { return; } if (!Enum.TryParse(factionName, ignoreCase: true, out var result)) { ctx.Reply("Unknown faction '" + factionName + "'. Valid: " + string.Join(", ", from n in Enum.GetNames() where n != "Unknown" select n)); return; } HeatManager.Instance.TryGetRecord(steamId, result, out var record); record.HeatValue = Math.Max(0f, value); HeatManager.Instance.SetRecord(steamId, result, record); ctx.Reply($"Set {playerName}'s {result} heat to {value:F1}."); } [Command("heat reset", null, null, "Reset all YOUR faction heat (admin). Pass a name to reset another player.", null, true)] public static void HeatReset(ChatCommandContext ctx, string playerName = "") { //IL_0012: Unknown result type (might be due to invalid IL or missing references) ulong steamId = (string.IsNullOrEmpty(playerName) ? ctx.Event.User.PlatformId : 0); if (steamId == 0L && !TryFindPlayer(ctx, playerName, out steamId)) { return; } string text = (string.IsNullOrEmpty(playerName) ? "Your" : (playerName + "'s")); foreach (VRisingFaction allFaction in FactionDatabase.AllFactions) { if (HeatManager.Instance.TryGetRecord(steamId, allFaction, out var record)) { record.HeatValue = 0f; HeatManager.Instance.SetRecord(steamId, allFaction, record); } } ctx.Reply("Reset all faction heat for " + text.Replace("Your", "you") + "."); } [Command("heat resetall", null, null, "Reset faction heat for ALL players (admin)", null, true)] public static void HeatResetAll(ChatCommandContext ctx) { foreach (PlayerHeatState allState in HeatManager.Instance.GetAllStates()) { foreach (VRisingFaction allFaction in FactionDatabase.AllFactions) { if (HeatManager.Instance.TryGetRecord(allState.SteamId, allFaction, out var record)) { record.HeatValue = 0f; HeatManager.Instance.SetRecord(allState.SteamId, allFaction, record); } } } ctx.Reply("Reset faction heat for all players."); } [Command("spawn", null, null, "Force-spawn a faction squad on yourself for testing (admin)", null, true)] public static void ForceSpawn(ChatCommandContext ctx, string factionName) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!Enum.TryParse(factionName, ignoreCase: true, out var result)) { ctx.Reply("Unknown faction '" + factionName + "'."); return; } ulong platformId = ctx.Event.User.PlatformId; HeatManager.Instance.TryGetRecord(platformId, result, out var record); if (record.HeatValue < DyWorldConfig.LowHeatKills.Value) { record.HeatValue = DyWorldConfig.LowHeatKills.Value; } record.LastSpawnTimestamp = 0.0; HeatManager.Instance.SetRecord(platformId, result, record); ctx.Reply($"Heat set to Low for {result}. A squad will spawn within ~{DyWorldConfig.SpawnCheckIntervalSeconds.Value:F0}s."); } [Command("region heat", "rh", null, "Show current GLOBAL region heat levels", null, false)] public static void RegionHeatStatus(ChatCommandContext ctx) { ctx.Reply(BuildRegionReport()); } [Command("region heat set", null, null, "Set global region heat (admin)", null, true)] public static void RegionHeatSet(ChatCommandContext ctx, string regionName, float value) { if (!Enum.TryParse(regionName, ignoreCase: true, out var result)) { ctx.Reply("Unknown region '" + regionName + "'. Valid: " + string.Join(", ", Enum.GetNames())); return; } HeatManager.Instance.TryGetRegionRecord(result, out var record); record.HeatValue = Math.Max(0f, value); HeatManager.Instance.SetRegionRecord(result, record); ctx.Reply($"Global {result} heat set to {value:F1}."); } [Command("region heat reset", null, null, "Reset all global region heat (admin)", null, true)] public static void RegionHeatReset(ChatCommandContext ctx) { foreach (VRisingRegion allRegion in RegionDatabase.AllRegions) { HeatManager.Instance.TryGetRegionRecord(allRegion, out var record); record.HeatValue = 0f; HeatManager.Instance.SetRegionRecord(allRegion, record); } ctx.Reply("Reset all global region heat."); } [Command("region spawn", null, null, "Force-spawn a region patrol on yourself (admin)", null, true)] public static void RegionForceSpawn(ChatCommandContext ctx, string regionName) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!Enum.TryParse(regionName, ignoreCase: true, out var result)) { ctx.Reply("Unknown region '" + regionName + "'."); return; } _ = ctx.Event.User; HeatManager.Instance.TryGetRegionRecord(result, out var record); if (record.HeatValue < DyWorldConfig.RegionLowHeatKills.Value) { record.HeatValue = DyWorldConfig.RegionLowHeatKills.Value; } record.LastSpawnTimestamp = 0.0; HeatManager.Instance.SetRegionRecord(result, record); ctx.Reply($"Global region heat set to Low for {result}. A patrol spawns within ~{DyWorldConfig.RegionSpawnCheckIntervalSeconds.Value:F0}s."); } [Command("status", "s", null, "Show your combined faction and region heat overview", null, false)] public static void Status(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("=== DyWorld Rising Heat Status ==="); IReadOnlyDictionary allRecords = HeatManager.Instance.GetAllRecords(platformId); if (allRecords.Count == 0) { stringBuilder.AppendLine("Faction heat: None"); } else { stringBuilder.AppendLine("Faction heat:"); foreach (KeyValuePair item in allRecords.OrderByDescending((KeyValuePair x) => x.Value.HeatValue)) { item.Deconstruct(out var key, out var value); VRisingFaction faction = key; FactionHeatRecord factionHeatRecord = value; HeatLevel heatLevel = HeatManager.Instance.GetHeatLevel(platformId, faction); FactionData data; string value2 = (FactionDatabase.TryGetData(faction, out data) ? data.DisplayName : faction.ToString()); string value3 = FormatDecayEstimate(factionHeatRecord.HeatValue, DyWorldConfig.DecayAmountPerInterval.Value, DyWorldConfig.DecayIntervalSeconds.Value, GetNextFactionThreshold(heatLevel)); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(7, 4, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(value2); handler.AppendLiteral(": "); handler.AppendFormatted(heatLevel); handler.AppendLiteral(" ("); handler.AppendFormatted(factionHeatRecord.HeatValue, "F0"); handler.AppendLiteral(")"); handler.AppendFormatted(value3); stringBuilder3.AppendLine(ref handler); } } IReadOnlyDictionary allRegionRecords = HeatManager.Instance.GetAllRegionRecords(); if (allRegionRecords.Count == 0) { stringBuilder.AppendLine("Global region heat: None"); } else { stringBuilder.AppendLine("Global region heat:"); foreach (KeyValuePair item2 in allRegionRecords.OrderByDescending((KeyValuePair x) => x.Value.HeatValue)) { item2.Deconstruct(out var key2, out var value4); VRisingRegion vRisingRegion = key2; RegionHeatRecord regionHeatRecord = value4; HeatLevel regionHeatLevel = HeatManager.Instance.GetRegionHeatLevel(vRisingRegion); string value5 = FormatDecayEstimate(regionHeatRecord.HeatValue, DyWorldConfig.RegionDecayAmountPerInterval.Value, DyWorldConfig.RegionDecayIntervalSeconds.Value, GetNextRegionThreshold(regionHeatLevel)); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(7, 4, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(vRisingRegion); handler.AppendLiteral(": "); handler.AppendFormatted(regionHeatLevel); handler.AppendLiteral(" ("); handler.AppendFormatted(regionHeatRecord.HeatValue, "F0"); handler.AppendLiteral(")"); handler.AppendFormatted(value5); stringBuilder4.AppendLine(ref handler); } } ctx.Reply(stringBuilder.ToString().TrimEnd()); } [Command("siege status", "ss", null, "Show your current siege status (active wave, time until next wave)", null, false)] public static void SiegeStatus(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.Event.User.PlatformId; SiegeState state = SiegeManager.Instance.GetState(platformId); if (state == null || !state.IsActive) { if (SiegeManager.Instance.CanStartSiege(platformId)) { ctx.Reply("No active siege. (You are eligible for a new siege if 2+ factions reach Maximum heat.)"); return; } int value = (int)Math.Ceiling(((double)DyWorldConfig.SiegeCooldownSeconds.Value - ((double)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000.0 - (state?.LastSiegeEndTime ?? 0.0))) / 60.0); ctx.Reply($"No active siege. Cooldown: ~{value}m remaining before next siege can trigger."); return; } double num = (double)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000.0; int value2 = DyWorldConfig.SiegeWaveCount.Value; double num2 = (double)DyWorldConfig.SiegeWaveDurationSeconds.Value - (num - state.WaveStartTime); int value3 = (int)Math.Max(0.0, Math.Ceiling(num2 / 60.0)); ctx.Reply($"ACTIVE SIEGE — Wave {state.CurrentWave}/{value2} | Factions: {state.FactionNames}\n" + ((state.CurrentWave < value2) ? $" Next wave in ~{value3}m" : " Final wave! Survive to end the siege.")); } [Command("siege start", null, null, "Force-trigger a siege on yourself (or another player if name given) (admin)", null, true)] public static void SiegeStart(ChatCommandContext ctx, string playerName = "") { //IL_0012: 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) ulong steamId = (string.IsNullOrEmpty(playerName) ? ctx.Event.User.PlatformId : 0); if (steamId != 0L || TryFindPlayer(ctx, playerName, out steamId)) { SiegeManager.Instance.LoadCooldown(steamId, 0.0); SiegeOrchestrator.ForceStartSiege(steamId); string text = ((steamId == ctx.Event.User.PlatformId) ? "your" : (playerName + "'s")); ctx.Reply("Forcing siege on " + text + " castle. A siege will start if you have a castle and 2+ factions at Maximum heat. Use .dw heat set 1000 to trigger."); } } [Command("siege end", null, null, "End an active siege on yourself or another player (admin)", null, true)] public static void SiegeEnd(ChatCommandContext ctx, string playerName = "") { //IL_0012: Unknown result type (might be due to invalid IL or missing references) ulong steamId = (string.IsNullOrEmpty(playerName) ? ctx.Event.User.PlatformId : 0); if (steamId != 0L || TryFindPlayer(ctx, playerName, out steamId)) { SiegeState state = SiegeManager.Instance.GetState(steamId); if (state == null || !state.IsActive) { ctx.Reply("No active siege to end."); return; } SiegeOrchestrator.ForceEndSiege(steamId); ctx.Reply("Siege ended."); } } [Command("dumpprefabs", null, null, "Dump matching prefab names+GUIDs to a file (admin)", null, true)] public static void DumpPrefabs(ChatCommandContext ctx, string filter = "CHAR_") { PrefabCollectionSystem prefabSystem = GetPrefabSystem(); if (prefabSystem == null) { ctx.Reply("PrefabCollectionSystem not ready."); return; } string text = Path.Combine(Paths.BepInExRootPath, "data", "dyworldrising"); Directory.CreateDirectory(text); string text2 = string.Concat(filter.Split(Path.GetInvalidFileNameChars())); string outputPath = Path.Combine(text, "prefab_dump_" + text2 + ".txt"); int value = FactionDatabase.DumpSpawnables(prefabSystem, filter, outputPath); ctx.Reply($"Dumped {value} prefabs matching '{filter}' to BepInEx/data/DyWorldRising/prefab_dump_{text2}.txt"); } private static string BuildFactionReport(ulong steamId, string label) { IReadOnlyDictionary allRecords = HeatManager.Instance.GetAllRecords(steamId); if (allRecords.Count == 0) { return label + " faction heat: None"; } StringBuilder stringBuilder = new StringBuilder(label + " faction heat:\n"); foreach (KeyValuePair item in allRecords.OrderByDescending((KeyValuePair x) => x.Value.HeatValue)) { item.Deconstruct(out var key, out var value); VRisingFaction faction = key; FactionHeatRecord factionHeatRecord = value; HeatLevel heatLevel = HeatManager.Instance.GetHeatLevel(steamId, faction); FactionData data; string value2 = (FactionDatabase.TryGetData(faction, out data) ? data.DisplayName : faction.ToString()); string value3 = FormatDecayEstimate(factionHeatRecord.HeatValue, DyWorldConfig.DecayAmountPerInterval.Value, DyWorldConfig.DecayIntervalSeconds.Value, GetNextFactionThreshold(heatLevel)); StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(7, 4, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(value2); handler.AppendLiteral(": "); handler.AppendFormatted(heatLevel); handler.AppendLiteral(" ("); handler.AppendFormatted(factionHeatRecord.HeatValue, "F0"); handler.AppendLiteral(")"); handler.AppendFormatted(value3); stringBuilder2.AppendLine(ref handler); } return stringBuilder.ToString().TrimEnd(); } private static string BuildRegionReport() { IReadOnlyDictionary allRegionRecords = HeatManager.Instance.GetAllRegionRecords(); if (allRegionRecords.Count == 0) { return "Global region heat: None"; } StringBuilder stringBuilder = new StringBuilder("Global region heat:\n"); foreach (KeyValuePair item in allRegionRecords.OrderByDescending((KeyValuePair x) => x.Value.HeatValue)) { item.Deconstruct(out var key, out var value); VRisingRegion vRisingRegion = key; RegionHeatRecord regionHeatRecord = value; HeatLevel regionHeatLevel = HeatManager.Instance.GetRegionHeatLevel(vRisingRegion); string value2 = FormatDecayEstimate(regionHeatRecord.HeatValue, DyWorldConfig.RegionDecayAmountPerInterval.Value, DyWorldConfig.RegionDecayIntervalSeconds.Value, GetNextRegionThreshold(regionHeatLevel)); StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(7, 4, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(vRisingRegion); handler.AppendLiteral(": "); handler.AppendFormatted(regionHeatLevel); handler.AppendLiteral(" ("); handler.AppendFormatted(regionHeatRecord.HeatValue, "F0"); handler.AppendLiteral(")"); handler.AppendFormatted(value2); stringBuilder2.AppendLine(ref handler); } return stringBuilder.ToString().TrimEnd(); } private static string FormatDecayEstimate(float heat, float decayPerTick, float intervalSecs, float? nextThreshold) { if (!nextThreshold.HasValue || heat <= 0f || decayPerTick <= 0f) { return string.Empty; } float num = heat - nextThreshold.Value; if (num <= 0f) { return string.Empty; } int value = (int)Math.Ceiling(num / decayPerTick * intervalSecs / 60f); return $" — cools in ~{value}m"; } private static float? GetNextFactionThreshold(HeatLevel current) { return current switch { HeatLevel.Maximum => DyWorldConfig.HighHeatKills.Value, HeatLevel.High => DyWorldConfig.MediumHeatKills.Value, HeatLevel.Medium => DyWorldConfig.LowHeatKills.Value, HeatLevel.Low => 0f, _ => null, }; } private static float? GetNextRegionThreshold(HeatLevel current) { return current switch { HeatLevel.Maximum => DyWorldConfig.RegionHighHeatKills.Value, HeatLevel.High => DyWorldConfig.RegionMediumHeatKills.Value, HeatLevel.Medium => DyWorldConfig.RegionLowHeatKills.Value, HeatLevel.Low => 0f, _ => null, }; } private static PrefabCollectionSystem? GetPrefabSystem() { Enumerator enumerator = World.All.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (!(current.Name != "Server")) { return current.GetExistingSystemManaged(); } } return null; } private static bool TryFindPlayer(ChatCommandContext ctx, string name, out ulong steamId) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //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_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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) steamId = 0uL; if (ulong.TryParse(name, out steamId)) { return true; } try { Enumerator enumerator = World.All.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name != "Server") { continue; } EntityManager entityManager = current.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly() }); NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator2 = val2.GetEnumerator(); while (enumerator2.MoveNext()) { Entity current2 = enumerator2.Current; User componentData = ((EntityManager)(ref entityManager)).GetComponentData(current2); if (((FixedString64Bytes)(ref componentData.CharacterName)).Value.Equals(name, StringComparison.OrdinalIgnoreCase)) { steamId = componentData.PlatformId; return true; } } } finally { val2.Dispose(); ((EntityQuery)(ref val)).Dispose(); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(51, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[DyWorld Rising] TryFindPlayer name lookup failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogWarning(val3); } ctx.Reply("Player '" + name + "' not found online. Use character name or Steam ID."); return false; } } public class HelloCommands { [Command("hello", null, null, "Says hello to the vampire who types the command", null, false)] public static void Hello(ChatCommandContext ctx) { ctx.Reply("Hello, Vampire!"); } } }