Decompiled source of CrimsonShards v0.1.4
CrimsonShards.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CrimsonShards.Patches.ShardTeleportBlockers; using CrimsonShards.Services; using CrimsonShards.Structs; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.Gameplay.Scripting; using ProjectM.Network; using ProjectM.Scripting; using ProjectM.Sequencer; using ProjectM.Shared; using ProjectM.Tiles; using Stunlock.Core; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; using UnityEngine; using VAMP; using VAMP.Data; using VAMP.Models; using VAMP.Services; using VAMP.Utilities; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("CrimsonShards")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A collection of features for Soul Shards")] [assembly: AssemblyFileVersion("0.1.4.0")] [assembly: AssemblyInformationalVersion("0.1.4+2.Branch.master.Sha.73ef6009937d690d7c23287e35eb48562640b65f.73ef6009937d690d7c23287e35eb48562640b65f")] [assembly: AssemblyProduct("CrimsonShards")] [assembly: AssemblyTitle("CrimsonShards")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public struct MessagePair { public string Key { get; set; } public string Value { get; set; } } namespace CrimsonShards { [BepInPlugin("CrimsonShards", "CrimsonShards", "0.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private Harmony _harmony; public static readonly string ConfigFiles = Path.Combine(Paths.ConfigPath, "CrimsonShards"); private static bool Purged = false; internal static Plugin Instance { get; private set; } public static Settings Settings { get; private set; } public static Harmony Harmony => Instance._harmony; public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log; public static ShardService ShardService { get; internal set; } public static TeleportShard Teleport { get; internal set; } public static BagService Bag { get; internal set; } public static ClanService ClanService { get; internal set; } public static CastleHeartService CastleHeartService { get; internal set; } public static CastleTerritoryService CastleTerritory { get; internal set; } public static Database DB { get; internal set; } public static RelicDestroySystem RelicDestroySystem { get; internal set; } public static bool UsingCL { get; private set; } = false; public override void Load() { Instance = this; Settings = default(Settings); foreach (KeyValuePair<string, PluginInfo> plugin in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins) { if (plugin.Value.Metadata.GUID.Equals("CrimsonLog")) { UsingCL = true; } } if (Settings.InitConfig()) { _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); CommandRegistry.RegisterAll(); Events.OnCoreLoaded = (Action)Delegate.Combine(Events.OnCoreLoaded, new Action(Loaded)); } } public override bool Unload() { DB.SaveFootballs(); CommandRegistry.UnregisterAssembly(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } public static void Loaded() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown CastleHeartService = new CastleHeartService(); CastleTerritory = new CastleTerritoryService(); DB = new Database(); ShardService = new ShardService(); Teleport = new TeleportShard(); Bag = new BagService(); ClanService = new ClanService(); RelicDestroySystem = Core.Server.GetExistingSystemManaged<RelicDestroySystem>(); if (Settings.FootballMode.Value) { Core.StartCoroutine(ResetTimer()); } if (Settings.FootballMode.Value) { Core.StartCoroutine(BagSearch()); } Core.SystemService.ServerGameSettingsSystem._Settings.BatBoundShards = false; ManualLogSource logInstance = LogInstance; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrimsonShards"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } logInstance.LogInfo(val); } public static IEnumerator ResetTimer() { while (true) { yield return (object)new WaitForSeconds(60f); ResetService.CheckForResets(); if (!Purged && DB?.Footballs != null) { Purged = true; DB.Footballs = DB.Footballs.Where((KeyValuePair<int, Football> kvp) => kvp.Value.LastEntityID != 0).ToDictionary((KeyValuePair<int, Football> kvp) => kvp.Key, (KeyValuePair<int, Football> kvp) => kvp.Value); DB.SaveFootballs(); } } } public static IEnumerator BagSearch() { while (true) { yield return (object)new WaitForSeconds(2.5f); ItemDrop.CheckDrops(); yield return (object)new WaitForSeconds(2.5f); BagService.FindBags(); yield return (object)new WaitForSeconds(2.5f); FootballService.Touchdowns(); yield return (object)new WaitForSeconds(2.5f); foreach (Entity allSoulShard in ShardService.GetAllSoulShards()) { FootballService.Add(allSoulShard); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "CrimsonShards"; public const string PLUGIN_NAME = "CrimsonShards"; public const string PLUGIN_VERSION = "0.1.4"; } } namespace CrimsonShards.Structs { public class Database { public static string ResetFileOld = Path.Combine(Plugin.ConfigFiles, "DoNotTouch.json"); public static string ResetFile = Path.Combine(FilePaths.WipeData, "cshards_lastresets.json"); public static string LocationFile = Path.Combine(Plugin.ConfigFiles, "TeleportLocations.json"); public static string LockedFileOld = Path.Combine(Plugin.ConfigFiles, "DoNotTouchThis.json"); public static string LockedFile = Path.Combine(FilePaths.WipeData, "cshards_footballs.json"); public static string MessagesFile = Path.Combine(Plugin.ConfigFiles, "Messages.json"); private static bool TimesInUTC => Settings.TimesInUTC.Value; private static DateTime Now { get { if (!TimesInUTC) { return DateTime.Now; } return DateTime.UtcNow; } } public List<LastReset> LastResets { get; set; } public List<Location> Locations { get; set; } public Dictionary<int, Football> Footballs { get; set; } public List<MessagePair> Messages { get; set; } public Database() { CreateDatabaseFiles(); LoadDatabase(); } private void LoadResets() { try { string json = File.ReadAllText(ResetFile); LastResets = JsonSerializer.Deserialize<List<LastReset>>(json); } catch { LastResets = new List<LastReset>(); } } private void LoadLocations() { try { string json = File.ReadAllText(LocationFile); Locations = JsonSerializer.Deserialize<List<Location>>(json); } catch { Locations = new List<Location> { new Location(-2503.8252f, 3.8146973E-06f, -891.8753f), new Location(-858.38257f, 3.8146973E-06f, -133.18175f), new Location(-1892.1616f, 20f, 334.44138f), new Location(-1733.4835f, 3.8146973E-06f, -19.83845f), new Location(-2327.0393f, 15.120003f, -382.17343f), new Location(-1740.3412f, -4.999996f, -438.5668f), new Location(-839.40826f, 15f, -510.73773f), new Location(-1367.2324f, 3.8146973E-06f, -1070.0701f), new Location(-845.0174f, 3.8146973E-06f, -1092.3484f), new Location(-605.5023f, 15f, -1098.0139f), new Location(-668.2479f, 3.8146973E-06f, -1532.5363f), new Location(-1946.2354f, 3.8146973E-06f, -1170.7656f), new Location(-1838.5779f, 3.8146973E-06f, -1614.2041f), new Location(-1207.6846f, 5.000004f, -1497.7047f), new Location(-280.26462f, 15f, -692.31854f), new Location(-448.72324f, 10.000004f, -286.32108f), new Location(-1277.4636f, 3.8146973E-06f, 53.855026f), new Location(-1379.1515f, 3.8146973E-06f, -1724.4404f), new Location(-2100.4019f, 10.000004f, -791.0097f), new Location(-1818.5552f, 3.8146973E-06f, -1177.8752f), new Location(-704.7303f, 3.8146973E-06f, 125.429054f), new Location(-1167.8878f, 15f, -382.65298f), new Location(-453.12616f, 3.8146973E-06f, -868.31067f), new Location(-2381.4087f, 3.8146973E-06f, -726.95374f), new Location(-1892.274f, 3.8146973E-06f, -867.4698f), new Location(-1362.4796f, 10.000004f, -331.5614f), new Location(-904.042f, 3.8146973E-06f, 253.97159f) }; } } private void LoadMessages() { try { string json = File.ReadAllText(MessagesFile); Messages = JsonSerializer.Deserialize<List<MessagePair>>(json, new JsonSerializerOptions { WriteIndented = true }); } catch { Messages = new List<MessagePair> { new MessagePair { Key = "TeleportBlocked", Value = "Cannot teleport with a Soul Shard before returning to your castle." }, new MessagePair { Key = "DraculaReset", Value = "Dracula Soul Shard has been reset!" }, new MessagePair { Key = "MonsterReset", Value = "Adam Soul Shard has been reset!" }, new MessagePair { Key = "SolarusReset", Value = "Solarus Soul Shard has been reset!" }, new MessagePair { Key = "HorrorReset", Value = "Winged Horror Soul Shard has been reset!" }, new MessagePair { Key = "MegaraReset", Value = "Megara Soul Shard has been reset!" }, new MessagePair { Key = "ShardTeleported", Value = "A shard has been teleported to a random location." } }; } } private void LoadFootballs() { if (File.Exists(LockedFile)) { try { string json = File.ReadAllText(LockedFile); Footballs = JsonSerializer.Deserialize<Dictionary<int, Football>>(json, new JsonSerializerOptions { WriteIndented = true }); foreach (Football value in Footballs.Values) { value.LastEntityID = 0; } } catch { Footballs = new Dictionary<int, Football>(); } SaveFootballs(); } else { Footballs = new Dictionary<int, Football>(); } } public bool LoadDatabase() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown try { if (Settings.TimedReset) { LoadResets(); } LoadLocations(); LoadMessages(); if (Settings.FootballMode.Value) { LoadFootballs(); } else if (File.Exists(LockedFile)) { File.Delete(LockedFile); } return true; } catch (Exception ex) { ManualLogSource logInstance = Plugin.LogInstance; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to load database. "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } logInstance.LogError(val); return false; } } public void SaveDatabase() { string contents = JsonSerializer.Serialize(LastResets); File.WriteAllText(ResetFile, contents); } public void AddNewLocation(Location newLoc) { Locations.Add(newLoc); string contents = JsonSerializer.Serialize(Locations); File.WriteAllText(LocationFile, contents); } public static void CreateDatabaseFiles() { if (File.Exists(ResetFileOld)) { File.Move(ResetFileOld, ResetFile, overwrite: true); File.Delete(ResetFileOld); } if (File.Exists(LockedFileOld)) { File.Move(LockedFileOld, LockedFile, overwrite: true); File.Delete(LockedFileOld); } if (!File.Exists(ResetFile) && Settings.TimedReset) { string contents = JsonSerializer.Serialize(new List<LastReset>(5) { CreateShardReset("Dracula"), CreateShardReset("TheMonster"), CreateShardReset("Solarus"), CreateShardReset("WingedHorror"), CreateShardReset("Morgana") }); File.WriteAllText(ResetFile, contents); } else if (File.Exists(ResetFile) && !Settings.TimedReset) { File.Delete(ResetFile); } if (!File.Exists(LocationFile)) { string contents2 = JsonSerializer.Serialize(new List<Location> { new Location(-2503.8252f, 3.8146973E-06f, -891.8753f), new Location(-858.38257f, 3.8146973E-06f, -133.18175f), new Location(-1892.1616f, 20f, 334.44138f), new Location(-1733.4835f, 3.8146973E-06f, -19.83845f), new Location(-2327.0393f, 15.120003f, -382.17343f), new Location(-1740.3412f, -4.999996f, -438.5668f), new Location(-839.40826f, 15f, -510.73773f), new Location(-1367.2324f, 3.8146973E-06f, -1070.0701f), new Location(-845.0174f, 3.8146973E-06f, -1092.3484f), new Location(-605.5023f, 15f, -1098.0139f), new Location(-668.2479f, 3.8146973E-06f, -1532.5363f), new Location(-1946.2354f, 3.8146973E-06f, -1170.7656f), new Location(-1838.5779f, 3.8146973E-06f, -1614.2041f), new Location(-1207.6846f, 5.000004f, -1497.7047f), new Location(-280.26462f, 15f, -692.31854f), new Location(-448.72324f, 10.000004f, -286.32108f), new Location(-1277.4636f, 3.8146973E-06f, 53.855026f), new Location(-1379.1515f, 3.8146973E-06f, -1724.4404f), new Location(-2100.4019f, 10.000004f, -791.0097f), new Location(-1818.5552f, 3.8146973E-06f, -1177.8752f), new Location(-704.7303f, 3.8146973E-06f, 125.429054f), new Location(-1167.8878f, 15f, -382.65298f), new Location(-453.12616f, 3.8146973E-06f, -868.31067f), new Location(-2381.4087f, 3.8146973E-06f, -726.95374f), new Location(-1892.274f, 3.8146973E-06f, -867.4698f), new Location(-1362.4796f, 10.000004f, -331.5614f), new Location(-904.042f, 3.8146973E-06f, 253.97159f) }, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(LocationFile, contents2); } if (!File.Exists(MessagesFile)) { string contents3 = JsonSerializer.Serialize(new List<MessagePair> { new MessagePair { Key = "TeleportBlocked", Value = "Cannot teleport with a Soul Shard before returning to your castle." }, new MessagePair { Key = "DraculaReset", Value = "Dracula Soul Shard has been reset!" }, new MessagePair { Key = "MonsterReset", Value = "Adam Soul Shard has been reset!" }, new MessagePair { Key = "SolarusReset", Value = "Solarus Soul Shard has been reset!" }, new MessagePair { Key = "HorrorReset", Value = "Winged Horror Soul Shard has been reset!" }, new MessagePair { Key = "MegaraReset", Value = "Megara Soul Shard has been reset!" }, new MessagePair { Key = "ShardTeleported", Value = "A shard has been teleported to a random location." } }, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(MessagesFile, contents3); } } public string GetShardResetMessage(string shardName) { if (shardName == "TheMonster") { shardName = "Monster"; } if (shardName == "WingedHorror") { shardName = "Horror"; } if (shardName == "Morgana") { shardName = "Megara"; } return Messages.FirstOrDefault((MessagePair x) => x.Key == shardName + "Reset").Value; } public static void AddTPLocation(float3 newLoc) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Location item = new Location(newLoc.x, newLoc.y, newLoc.z); Plugin.DB.Locations.Add(item); Plugin.DB.SaveLocations(); } private static LastReset CreateShardReset(string shardName) { return new LastReset { Key = shardName, Last = Now }; } public void SaveFootballs() { string contents = JsonSerializer.Serialize(Footballs); File.WriteAllText(LockedFile, contents); } public void SaveLocations() { string contents = JsonSerializer.Serialize(Locations, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(LocationFile, contents); } public bool IsLocked(string playerName) { if (Footballs == null || Footballs.Count == 0) { return false; } if (Footballs.Values.Any((Football x) => x.PlayerName == playerName && x.Locked)) { return true; } return false; } } public class DroppedShard { public Entity entity; public DateTime timedFound; public bool teleported; public DroppedShard(Entity entity, DateTime timedFound) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) this.entity = entity; this.timedFound = timedFound; if (Settings.TeleportDropped.Value != 0) { Core.StartCoroutine(Teleport()); } } private IEnumerator Teleport() { Translation translation = EntityUtil.Read<Translation>(entity); if (Plugin.UsingCL && Settings.CrimsonLog_Teleports.Value) { Logger.Log($"Shard ({entity.Index}) was dropped at Position({translation.Value.x}, {translation.Value.y}, {translation.Value.z}).", "teleported"); } yield return (object)new WaitForSeconds((float)Settings.TeleportDropped.Value); EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entity) || ((Entity)(ref entity)).Equals(Entity.Null)) { yield break; } try { if (Settings.DroppedPlotsOnly.Value) { Entity heartForTerritory = Plugin.CastleTerritory.GetHeartForTerritory(Plugin.CastleTerritory.GetTerritoryIndex(translation.Value)); if (((Entity)(ref heartForTerritory)).Equals(Entity.Null)) { yield break; } } if (Plugin.DB.Locations.Count <= 0) { yield break; } _ = translation; Location location = Plugin.DB.Locations[Random.Range(0, Plugin.DB.Locations.Count)]; translation.Value.x = location.X; translation.Value.y = location.Y; translation.Value.z = location.Z; entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity) || ((Entity)(ref entity)).Equals(Entity.Null)) { if (Plugin.UsingCL && Settings.CrimsonLog_Teleports.Value) { Logger.Log($"Shard ({entity.Index}) was teleported to Position({location.X}, {location.Y}, {location.Z}).", "teleported"); } EntityUtil.Write<Translation>(entity, translation); teleported = true; ChatUtil.SystemSendAll(Plugin.DB.Messages[6].Value); } } catch (Exception ex) { ManualLogSource logInstance = Plugin.LogInstance; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error in Teleport coroutine: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } logInstance.LogError(val); } } } [Serializable] public class Football { public string PlayerName { get; set; } public int RelicType { get; set; } public bool Locked { get; set; } public int LastEntityID { get; set; } public Football(string playerName, int relicType, bool locked, int lastEntityID) { PlayerName = playerName; RelicType = relicType; Locked = locked; LastEntityID = lastEntityID; } } public class LastReset { [JsonPropertyName("ShardName")] public string Key { get; set; } [JsonPropertyName("Last")] public DateTime Last { get; set; } } public class Location { public float X { get; set; } public float Y { get; set; } public float Z { get; set; } public Location(float x, float y, float z) { X = x; Y = y; Z = z; } } public class ResetInfo { public bool Reset; public int Mode; public string Time = ""; public int Interval; public int Day; public int SkipWeeks; public string Message = ""; } [StructLayout(LayoutKind.Sequential, Size = 1)] public readonly struct Settings { private static readonly List<string> OrderedSections = new List<string> { "Config", "Replenish", "DropLimit", "Reset_Shards", "Reset_Dracula", "Reset_Monster", "Reset_WingedHorror", "Reset_Solarus", "Reset_Megara", "Integrations" }; private static readonly List<string> directoryPaths = new List<string>(1) { Plugin.ConfigFiles }; public static ConfigEntry<bool> ToggleMod { get; private set; } public static ConfigEntry<int> ShardDurabilityTime { get; private set; } public static ConfigEntry<bool> BlockStorage { get; private set; } public static ConfigEntry<int> TeleportDropped { get; private set; } public static ConfigEntry<bool> DroppedPlotsOnly { get; private set; } public static ConfigEntry<bool> FootballMode { get; private set; } public static ConfigEntry<bool> ClanCastleFootball { get; private set; } public static ConfigEntry<bool> TimesInUTC { get; private set; } public static ConfigEntry<bool> BatShardOverride { get; private set; } public static ConfigEntry<bool> TeamCombatLocksBat { get; private set; } public static ConfigEntry<bool> ReplenishOnKill { get; private set; } public static ConfigEntry<bool> RequireDrain { get; private set; } public static ConfigEntry<int> ReplenishPercentage { get; private set; } public static ConfigEntry<bool> ReplenishEquippedOnly { get; private set; } public static ConfigEntry<int> ShardDraculaDropLimit { get; private set; } public static ConfigEntry<int> ShardWingedHorrorDropLimit { get; private set; } public static ConfigEntry<int> ShardMonsterDropLimit { get; private set; } public static ConfigEntry<int> ShardSolarusDropLimit { get; private set; } public static ConfigEntry<int> ShardMorganaDropLimit { get; private set; } public static ConfigEntry<bool> ResetDracula { get; private set; } public static ConfigEntry<bool> ResetMonster { get; private set; } public static ConfigEntry<bool> ResetWingedHorror { get; private set; } public static ConfigEntry<bool> ResetSolarus { get; private set; } public static ConfigEntry<bool> ResetMorgana { get; private set; } public static ConfigEntry<int> Dracula_Mode { get; private set; } public static ConfigEntry<string> Dracula_Time { get; private set; } public static ConfigEntry<int> Dracula_Interval_Count { get; private set; } public static ConfigEntry<int> Dracula_Fixed_Day { get; private set; } public static ConfigEntry<int> Dracula_Fixed_SkipWeeks { get; private set; } public static ConfigEntry<int> Monster_Mode { get; private set; } public static ConfigEntry<string> Monster_Time { get; private set; } public static ConfigEntry<int> Monster_Interval_Count { get; private set; } public static ConfigEntry<int> Monster_Fixed_Day { get; private set; } public static ConfigEntry<int> Monster_Fixed_SkipWeeks { get; private set; } public static ConfigEntry<int> WingedHorror_Mode { get; private set; } public static ConfigEntry<string> WingedHorror_Time { get; private set; } public static ConfigEntry<int> WingedHorror_Interval_Count { get; private set; } public static ConfigEntry<int> WingedHorror_Fixed_Day { get; private set; } public static ConfigEntry<int> WingedHorror_Fixed_SkipWeeks { get; private set; } public static ConfigEntry<int> Solarus_Mode { get; private set; } public static ConfigEntry<string> Solarus_Time { get; private set; } public static ConfigEntry<int> Solarus_Interval_Count { get; private set; } public static ConfigEntry<int> Solarus_Fixed_Day { get; private set; } public static ConfigEntry<int> Solarus_Fixed_SkipWeeks { get; private set; } public static ConfigEntry<int> Morgana_Mode { get; private set; } public static ConfigEntry<string> Morgana_Time { get; private set; } public static ConfigEntry<int> Morgana_Interval_Count { get; private set; } public static ConfigEntry<int> Morgana_Fixed_Day { get; private set; } public static ConfigEntry<int> Morgana_Fixed_SkipWeeks { get; private set; } public static ConfigEntry<bool> CrimsonLog_Resets { get; private set; } public static ConfigEntry<bool> CrimsonLog_Teleports { get; private set; } public static bool TimedReset { get; private set; } = false; public static bool InitConfig() { foreach (string directoryPath in directoryPaths) { CreateDirectories(directoryPath); } ToggleMod = InitConfigEntry(OrderedSections[0], "ToggleMod", defaultValue: true, "Enable or disable the mod."); ShardDurabilityTime = InitConfigEntry(OrderedSections[0], "DurabilityTime", 129600, "How long to drain the energy from shards."); BlockStorage = InitConfigEntry(OrderedSections[0], "BlockStorage", defaultValue: false, "Disables ability to store shards in containers & disables building of pedestals."); TeleportDropped = InitConfigEntry(OrderedSections[0], "TeleportDropped", 0, "After a shard has been dropped it will teleport away after X seconds; 0 disables teleporting."); DroppedPlotsOnly = InitConfigEntry(OrderedSections[0], "DroppedPlotsOnly", defaultValue: false, "If true, only shards dropped on castle plots will be affected by TeleportDropped. \nWARNING: Read disclaimer in README.md / Thunderstore Page."); FootballMode = InitConfigEntry(OrderedSections[0], "FootballMode", defaultValue: false, "If true, a player must bring a newly aquired shard to their castle before they can teleport. \nWARNING: Read performance disclaimer in README.md / Thunderstore Page."); ClanCastleFootball = InitConfigEntry(OrderedSections[0], "ClanCastleFootball", defaultValue: false, "If true, clan member's castles will count for Football Mode."); TimesInUTC = InitConfigEntry(OrderedSections[0], "TimesInUTC", defaultValue: false, "If true, times in config files will be read as UTC times instead of the server's local time."); BatShardOverride = InitConfigEntry(OrderedSections[0], "BatShardOverride", defaultValue: true, "If true, having an unlocked (brought to castle in footballmode) shard will allow you to use batform."); TeamCombatLocksBat = InitConfigEntry(OrderedSections[0], "TeamCombatLocksBat", defaultValue: true, "If true, clan members in combat will lock batform for shard holders."); ReplenishOnKill = InitConfigEntry(OrderedSections[1], "ReplenishOnKill", defaultValue: false, "If true, shards will replenish durability when killing other players."); RequireDrain = InitConfigEntry(OrderedSections[1], "RequireDrain", defaultValue: false, "If true, ReplenishOnKill will require drain killing other players to count."); ReplenishPercentage = InitConfigEntry(OrderedSections[1], "ReplenishPercentage", 5, "The percentage of durability to replenish when killing a player."); ReplenishEquippedOnly = InitConfigEntry(OrderedSections[1], "ReplenishEquippedOnly", defaultValue: false, "If true, shards will only replenish durability when equipped."); ShardDraculaDropLimit = InitConfigEntry(OrderedSections[2], "Dracula_DropLimit", 1, "How many of the Dracula soul shard can exist at once. Server RelicSpawnType must be set to \"Unique\"."); ShardMonsterDropLimit = InitConfigEntry(OrderedSections[2], "Monster_DropLimit", 1, "How many of the Monster soul shard can exist at once. Server RelicSpawnType must be set to \"Unique\"."); ShardWingedHorrorDropLimit = InitConfigEntry(OrderedSections[2], "WingedHorror_DropLimit", 1, "How many of the Winged Horror soul shard can exist at once. Server RelicSpawnType must be set to \"Unique\"."); ShardSolarusDropLimit = InitConfigEntry(OrderedSections[2], "Solarus_DropLimit", 1, "How many of the Solarus soul shard can exist at once. Server RelicSpawnType must be set to \"Unique\"."); ShardMorganaDropLimit = InitConfigEntry(OrderedSections[2], "Megara_DropLimit", 1, "How many of the Megara soul shard can exist at once. Server RelicSpawnType must be set to \"Unique\"."); ResetDracula = InitConfigEntry(OrderedSections[3], "Reset_Dracula", defaultValue: false, "Enable or disable the resetting of the Dracula soul shard."); ResetMonster = InitConfigEntry(OrderedSections[3], "Reset_Monster", defaultValue: false, "Enable or disable the resetting of the Monster soul shard."); ResetWingedHorror = InitConfigEntry(OrderedSections[3], "Reset_WingedHorror", defaultValue: false, "Enable or disable the resetting of the Winged Horror soul shard."); ResetSolarus = InitConfigEntry(OrderedSections[3], "Reset_Solarus", defaultValue: false, "Enable or disable the resetting of the Solarus soul shard."); ResetMorgana = InitConfigEntry(OrderedSections[3], "Reset_Megara", defaultValue: false, "Enable or disable the resetting of the Megara soul shard."); Dracula_Mode = InitConfigEntry(OrderedSections[4], "Dracula_Mode", 0, "Interval (0) is for X days between resets. Fixed Day (1) is to reset on a specific day of the week."); Dracula_Time = InitConfigEntry(OrderedSections[4], "Dracula_Time", "12:00:00", "Time of day to reset. (HH:mm:ss format) (Both Interval and Fixed Day Modes)"); Dracula_Interval_Count = InitConfigEntry(OrderedSections[4], "Dracula_Interval_Count", 3, "Number of days between each reset. (Interval Mode)"); Dracula_Fixed_Day = InitConfigEntry(OrderedSections[4], "Dracula_Fixed_Day", 1, "Day of the week to reset. 0 = Sunday, 1 = Monday, ..., 6 = Saturday. (Fixed Day Mode)"); Dracula_Fixed_SkipWeeks = InitConfigEntry(OrderedSections[4], "Dracula_Fixed_SkipWeeks", 0, "Number of weeks to skip between resets. (Fixed Day Mode)"); Monster_Mode = InitConfigEntry(OrderedSections[5], "Monster_Mode", 0, "Interval (0) is for X days between resets. Fixed Day (1) is to reset on a specific day of the week."); Monster_Time = InitConfigEntry(OrderedSections[5], "Monster_Time", "12:00:00", "Time of day to reset. (HH:mm:ss format) (Both Interval and Fixed Day Modes)"); Monster_Interval_Count = InitConfigEntry(OrderedSections[5], "Monster_Interval_Count", 3, "Number of days between each reset. (Interval Mode)"); Monster_Fixed_Day = InitConfigEntry(OrderedSections[5], "Monster_Fixed_Day", 1, "Day of the week to reset. 0 = Sunday, 1 = Monday, ..., 6 = Saturday. (Fixed Day Mode)"); Monster_Fixed_SkipWeeks = InitConfigEntry(OrderedSections[5], "Monster_Fixed_SkipWeeks", 0, "Number of weeks to skip between resets. (Fixed Day Mode)"); WingedHorror_Mode = InitConfigEntry(OrderedSections[6], "WingedHorror_Mode", 0, "Interval (0) is for X days between resets. Fixed Day (1) is to reset on a specific day of the week."); WingedHorror_Time = InitConfigEntry(OrderedSections[6], "WingedHorror_Time", "12:00:00", "Time of day to reset. (HH:mm:ss format) (Both Interval and Fixed Day Modes)"); WingedHorror_Interval_Count = InitConfigEntry(OrderedSections[6], "WingedHorror_Interval_Count", 3, "Number of days between each reset. (Interval Mode)"); WingedHorror_Fixed_Day = InitConfigEntry(OrderedSections[6], "WingedHorror_Fixed_Day", 1, "Day of the week to reset. 0 = Sunday, 1 = Monday, ..., 6 = Saturday. (Fixed Day Mode)"); WingedHorror_Fixed_SkipWeeks = InitConfigEntry(OrderedSections[6], "WingedHorror_Fixed_SkipWeeks", 0, "Number of weeks to skip between resets. (Fixed Day Mode)"); Solarus_Mode = InitConfigEntry(OrderedSections[7], "Solarus_Mode", 0, "Interval (0) is for X days between resets. Fixed Day (1) is to reset on a specific day of the week."); Solarus_Time = InitConfigEntry(OrderedSections[7], "Solarus_Time", "12:00:00", "Time of day to reset. (HH:mm:ss format) (Both Interval and Fixed Day Modes)"); Solarus_Interval_Count = InitConfigEntry(OrderedSections[7], "Solarus_Interval_Count", 3, "Number of days between each reset. (Interval Mode)"); Solarus_Fixed_Day = InitConfigEntry(OrderedSections[7], "Solarus_Fixed_Day", 1, "Day of the week to reset. 0 = Sunday, 1 = Monday, ..., 6 = Saturday. (Fixed Day Mode)"); Solarus_Fixed_SkipWeeks = InitConfigEntry(OrderedSections[7], "Solarus_Fixed_SkipWeeks", 0, "Number of weeks to skip between resets. (Fixed Day Mode)"); Morgana_Mode = InitConfigEntry(OrderedSections[8], "Megara_Mode", 0, "Interval (0) is for X days between resets. Fixed Day (1) is to reset on a specific day of the week."); Morgana_Time = InitConfigEntry(OrderedSections[8], "Megara_Time", "12:00:00", "Time of day to reset. (HH:mm:ss format) (Both Interval and Fixed Day Modes)"); Morgana_Interval_Count = InitConfigEntry(OrderedSections[8], "Megara_Interval_Count", 3, "Number of days between each reset. (Interval Mode)"); Morgana_Fixed_Day = InitConfigEntry(OrderedSections[8], "Megara_Fixed_Day", 1, "Day of the week to reset. 0 = Sunday, 1 = Monday, ..., 6 = Saturday. (Fixed Day Mode)"); Morgana_Fixed_SkipWeeks = InitConfigEntry(OrderedSections[8], "Megara_Fixed_SkipWeeks", 0, "Number of weeks to skip between resets. (Fixed Day Mode)"); if (ResetSolarus.Value || ResetMonster.Value || ResetWingedHorror.Value || ResetDracula.Value || ResetMorgana.Value) { TimedReset = true; } if (Plugin.UsingCL) { CrimsonLog_Resets = InitConfigEntry(OrderedSections[9], "CrimsonLog_Resets", defaultValue: true, "This will log timed shard resets to CrimsonLog's files."); CrimsonLog_Teleports = InitConfigEntry(OrderedSections[9], "CrimsonLog_Teleports", defaultValue: false, "This will log origin and destination of any shards and bags that were teleported due to drops or deathbags."); } ReorderConfigSections(); return ToggleMod.Value; } private static ConfigEntry<T> InitConfigEntry<T>(string section, string key, T defaultValue, string description) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<T> val = ((BasePlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, description); string text = Path.Combine(Paths.ConfigPath, "CrimsonShards.cfg"); ConfigEntry<T> val2 = default(ConfigEntry<T>); if (File.Exists(text) && new ConfigFile(text, true).TryGetEntry<T>(section, key, ref val2)) { val.Value = val2.Value; } return val; } private static void CreateDirectories(string path) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } private static void ReorderConfigSections() { string path = Path.Combine(Paths.ConfigPath, "CrimsonShards.cfg"); if (!File.Exists(path)) { return; } List<string> list = File.ReadAllLines(path).ToList(); Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>(); string text = ""; foreach (string item in list) { if (item.StartsWith("[")) { text = item.Trim('[', ']'); dictionary[text] = new List<string> { item }; } else if (!string.IsNullOrWhiteSpace(text)) { dictionary[text].Add(item); } } using StreamWriter streamWriter = new StreamWriter(path, append: false); foreach (string orderedSection in OrderedSections) { if (!dictionary.ContainsKey(orderedSection)) { continue; } foreach (string item2 in dictionary[orderedSection]) { streamWriter.WriteLine(item2); } streamWriter.WriteLine(); } } } } namespace CrimsonShards.Services { public class BagService { public static EntityQuery bagSearchQuery; public static EntityQuery relicMapIconsQuery; public BagService() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_001a: 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_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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00e4: 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_00f5: 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_0106: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[6] { ComponentType.ReadOnly(Il2CppType.Of<PrefabGUID>()), ComponentType.ReadOnly(Il2CppType.Of<Interactable>()), ComponentType.ReadOnly(Il2CppType.Of<ItemPickup>()), ComponentType.ReadOnly(Il2CppType.Of<DestroyAfterDuration>()), ComponentType.ReadOnly(Il2CppType.Of<AttachedBuffer>()), ComponentType.ReadOnly(Il2CppType.Of<InventoryInstanceElement>()) }); val.Options = (EntityQueryOptions)16; EntityQueryDesc val2 = val; EntityManager entityManager = Core.EntityManager; bagSearchQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 }); val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[5] { ComponentType.ReadOnly(Il2CppType.Of<PrefabGUID>()), ComponentType.ReadOnly(Il2CppType.Of<Attach>()), ComponentType.ReadOnly(Il2CppType.Of<MapIconData>()), ComponentType.ReadOnly(Il2CppType.Of<MapIconTargetEntity>()), ComponentType.ReadOnly(Il2CppType.Of<RelicMapIcon>()) }); val.Options = (EntityQueryOptions)16; EntityQueryDesc val3 = val; entityManager = Core.EntityManager; relicMapIconsQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val3 }); } public static void FindBags() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0021: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NativeArray<Entity> val = ((EntityQuery)(ref bagSearchQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); NativeArray<Entity> val2 = ((EntityQuery)(ref relicMapIconsQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); List<float3> list = new List<float3>(); Enumerator<Entity> enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { float3 value = EntityUtil.Read<Translation>(enumerator.Current).Value; list.Add(value); } enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity entity = enumerator.Current; float3 value2 = EntityUtil.Read<Translation>(entity).Value; if (list.Contains(value2) && !TeleportShard.DroppedShards.Exists((DroppedShard x) => x.entity == entity)) { TeleportShard.DroppedShards.Add(new DroppedShard(entity, DateTime.Now)); } } } } public class CastleHeartService { private static readonly ComponentType[] CastleHeartComponent = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly(Il2CppType.Of<CastleHeart>()) }; private static EntityQuery HeartQuery; public CastleHeartService() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; HeartQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { new EntityQueryDesc { All = Il2CppStructArray<ComponentType>.op_Implicit(CastleHeartComponent), Options = (EntityQueryOptions)2 } }); } public static IEnumerable<Entity> GetHearts() { NativeArray<Entity> heartEntities = ((EntityQuery)(ref HeartQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)); try { Enumerator<Entity> enumerator = heartEntities.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(current)) { yield return current; } } } finally { heartEntities.Dispose(); } } public unsafe static bool GetHeartByOwnerName(string playerName, out Entity heartEntity) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0083: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0065: Unknown result type (might be due to invalid IL or missing references) foreach (Entity heart in GetHearts()) { if (EntityUtil.Has<UserOwner>(heart) && EntityUtil.Has<User>(EntityUtil.Read<UserOwner>(heart).Owner._Entity)) { User val = EntityUtil.Read<User>(EntityUtil.Read<UserOwner>(heart).Owner._Entity); if (((object)(*(FixedString64Bytes*)(&val.CharacterName))/*cast due to .constrained prefix*/).ToString() == playerName) { heartEntity = heart; return true; } } } heartEntity = Entity.Null; return false; } } public class CastleTerritoryService { private const float BLOCK_SIZE = 10f; private Dictionary<int2, int> blockCoordToTerritoryIndex = new Dictionary<int2, int>(); public CastleTerritoryService() { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_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) NativeArray<Entity> entitiesByComponentType = EntityUtil.GetEntitiesByComponentType<CastleTerritory>(true, false, false, false, false); Enumerator<Entity> enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; int castleTerritoryIndex = EntityUtil.Read<CastleTerritory>(current).CastleTerritoryIndex; EntityManager entityManager = Core.EntityManager; DynamicBuffer<CastleTerritoryBlocks> buffer = ((EntityManager)(ref entityManager)).GetBuffer<CastleTerritoryBlocks>(current, false); for (int i = 0; i < buffer.Length; i++) { blockCoordToTerritoryIndex[buffer[i].BlockCoordinate] = castleTerritoryIndex; } } entitiesByComponentType.Dispose(); } public int GetTerritoryIndexFromTileCoord(int2 tilePos) { //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_0007: 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) int2 key = ConvertTileGridToBlockCoord(tilePos); if (blockCoordToTerritoryIndex.TryGetValue(key, out var value)) { return value; } return -1; } public int GetTerritoryIndex(float3 pos) { //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_0007: 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) int2 key = ConvertPosToBlockCoord(pos); if (blockCoordToTerritoryIndex.TryGetValue(key, out var value)) { return value; } return -1; } public Entity GetHeartForTerritory(int territoryIndex) { //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_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0032: 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_0061: 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_004f: Unknown result type (might be due to invalid IL or missing references) if (territoryIndex == -1) { return Entity.Null; } NativeArray<Entity> entitiesByComponentType = EntityUtil.GetEntitiesByComponentType<CastleHeart>(false, false, false, false, false); Enumerator<Entity> enumerator = entitiesByComponentType.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; Entity castleTerritoryEntity = EntityUtil.Read<CastleHeart>(current).CastleTerritoryEntity; if (!((Entity)(ref castleTerritoryEntity)).Equals(Entity.Null) && EntityUtil.Read<CastleTerritory>(castleTerritoryEntity).CastleTerritoryIndex == territoryIndex) { return current; } } entitiesByComponentType.Dispose(); return Entity.Null; } private int2 ConvertPosToBlockCoord(float3 pos) { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) float3 val = ConvertPosToTileGrid(pos); return new int2((int)math.floor(val.x / 10f), (int)math.floor(val.z / 10f)); } private static float3 ConvertPosToTileGrid(float3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) return new float3((float)(Mathf.FloorToInt(pos.x * 2f) + 6400), pos.y, (float)(Mathf.FloorToInt(pos.z * 2f) + 6400)); } private int2 ConvertTileGridToBlockCoord(int2 tileCoord) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) return new int2((int)math.floor((float)tileCoord.x / 10f), (int)math.floor((float)tileCoord.y / 10f)); } } internal static class FootballService { public static readonly PrefabGUID[] ShardTypes = (PrefabGUID[])(object)new PrefabGUID[5] { Prefabs.Item_EquipBuff_MagicSource_Soulshard_Dracula, Prefabs.Item_EquipBuff_MagicSource_Soulshard_Manticore, Prefabs.Item_EquipBuff_MagicSource_Soulshard_TheMonster, Prefabs.Item_EquipBuff_MagicSource_Soulshard_Solarus, Prefabs.Item_EquipBuff_MagicSource_Soulshard_Morgana }; public static bool Add(Entity shard) { //IL_0006: 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_0018: 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) if (!ValidateShardOwnership(shard, out var characterName)) { return false; } PrefabGUID relicType = EntityUtil.Read<PrefabGUID>(shard); int index = shard.Index; KeyValuePair<int, Football> keyValuePair = Plugin.DB.Footballs.FirstOrDefault((KeyValuePair<int, Football> x) => x.Value.PlayerName == characterName && x.Value.RelicType == relicType._Value); if (keyValuePair.Value != null) { Plugin.DB.Footballs.Remove(keyValuePair.Key); Plugin.DB.Footballs[index] = new Football(characterName, relicType._Value, keyValuePair.Value.Locked, index); Plugin.DB.SaveFootballs(); return true; } if (Plugin.DB.Footballs.TryGetValue(index, out var value)) { if (!(value.PlayerName != characterName)) { return false; } Plugin.DB.Footballs.Remove(index); Plugin.DB.SaveFootballs(); } Plugin.DB.Footballs[index] = new Football(characterName, relicType._Value, locked: true, index); Plugin.DB.SaveFootballs(); return true; } private static bool ValidateShardOwnership(Entity shard, out string characterName) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0036: 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) characterName = string.Empty; bool flag = false; if (!EntityUtil.Exists(shard)) { return false; } if (EntityUtil.Has<Equippable>(shard)) { flag = ValidateEquippable(shard, out characterName); } if (EntityUtil.Has<InventoryItem>(shard) && !flag) { flag = ValidateInventoryItem(shard, out characterName); } EntityUtil.Exists(shard); return flag; } public unsafe static bool ValidateEquippable(Entity shard, out string characterName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //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_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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) characterName = string.Empty; Entity entity = EntityUtil.Read<Equippable>(shard).EquipTarget._Entity; if (((Entity)(ref entity)).Equals(Entity.Null) || !EntityUtil.Has<PlayerCharacter>(entity)) { return false; } PlayerCharacter val = EntityUtil.Read<PlayerCharacter>(entity); characterName = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString(); return true; } public unsafe static bool ValidateInventoryItem(Entity shard, out string characterName) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //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_0023: 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_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_0036: 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_0042: 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) characterName = string.Empty; Entity containerEntity = EntityUtil.Read<InventoryItem>(shard).ContainerEntity; if (((Entity)(ref containerEntity)).Equals(Entity.Null)) { return false; } if (EntityUtil.Has<InventoryConnection>(containerEntity)) { Entity inventoryOwner = EntityUtil.Read<InventoryConnection>(containerEntity).InventoryOwner; if (!EntityUtil.Has<PlayerCharacter>(inventoryOwner)) { return false; } PlayerCharacter val = EntityUtil.Read<PlayerCharacter>(inventoryOwner); characterName = ((object)(*(FixedString64Bytes*)(&val.Name))/*cast due to .constrained prefix*/).ToString(); return true; } return false; } public static bool Remove(Entity shard) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) bool num = Plugin.DB.Footballs.Remove(shard.Index); if (num) { Plugin.DB.SaveFootballs(); } return num; } public static void RevalidatePlayerShards(string playerName, Entity playerEntity) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0088: 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) if (Plugin.DB != null && Plugin.DB.Footballs != null && Plugin.DB.Footballs.Count > 0) { foreach (KeyValuePair<int, Football> item in Plugin.DB.Footballs.Where((KeyValuePair<int, Football> x) => x.Value.PlayerName == playerName).ToList()) { InventoryUtilities.HasItemInInventory<EntityManager>(Core.EntityManager, playerEntity, new PrefabGUID(item.Value.RelicType), 1, default(Nullable_Unboxed<int>)); } } if (Plugin.ShardService == null || Plugin.ShardService.GetAllSoulShards() == null || !IsShardMissing(Plugin.ShardService.GetAllSoulShards(), out var missingShards)) { return; } foreach (Entity item2 in missingShards) { Add(item2); } } public static bool IsShardMissing(List<Entity> shards, out List<Entity> missingShards) { //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_0022: 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) missingShards = new List<Entity>(); foreach (Entity shard in shards) { if (!Plugin.DB.Footballs.ContainsKey(shard.Index)) { missingShards.Add(shard); } } return missingShards.Count > 0; } public unsafe static void Touchdowns() { //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_0125: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) if (Plugin.DB?.Footballs == null) { return; } Player val = default(Player); CastleTerritory val6 = default(CastleTerritory); foreach (KeyValuePair<int, Football> item in Plugin.DB.Footballs.Where((KeyValuePair<int, Football> x) => x.Value.Locked)) { Football value = item.Value; if (!PlayerService.TryFindByName(value.PlayerName, ref val)) { continue; } User val2 = EntityUtil.Read<User>(val.User); TilePosition val3 = EntityUtil.Read<TilePosition>(val2.LocalCharacter._Entity); EntityManager entityManager = Core.EntityManager; Entity val4 = (((EntityManager)(ref entityManager)).Exists(val2.ClanEntity._Entity) ? val2.ClanEntity._Entity : Entity.Null); bool flag = false; if (!Settings.ClanCastleFootball.Value || ((Entity)(ref val4)).Equals(Entity.Null)) { if (!CastleHeartService.GetHeartByOwnerName(value.PlayerName, out var heartEntity)) { continue; } CastleHeart val5 = EntityUtil.Read<CastleHeart>(heartEntity); flag = CastleTerritoryExtensions.IsTileInTerritory(Core.EntityManager, val3.Tile, ref val5.CastleTerritoryEntity, ref val6); } else { Enumerator<SyncToUserBuffer> enumerator2 = EntityUtil.ReadBuffer<SyncToUserBuffer>(val4).GetEnumerator(); while (enumerator2.MoveNext()) { User val7 = EntityUtil.Read<User>(enumerator2.Current.UserEntity); if (CastleHeartService.GetHeartByOwnerName(((object)(*(FixedString64Bytes*)(&val7.CharacterName))/*cast due to .constrained prefix*/).ToString(), out var heartEntity2)) { CastleHeart val8 = EntityUtil.Read<CastleHeart>(heartEntity2); if (CastleTerritoryExtensions.IsTileInTerritory(Core.EntityManager, val3.Tile, ref val8.CastleTerritoryEntity, ref val6)) { flag = true; } } } } if (flag) { value.Locked = false; Plugin.ShardService.GetShardByID(value.LastEntityID, out var _); Plugin.DB.SaveFootballs(); } } } } internal class GearService { private EntityQuery itemQuery; private static readonly PrefabGUID[] shardPrefabs = (PrefabGUID[])(object)new PrefabGUID[5] { Prefabs.Item_MagicSource_SoulShard_Dracula, Prefabs.Item_MagicSource_SoulShard_Manticore, Prefabs.Item_MagicSource_SoulShard_Monster, Prefabs.Item_MagicSource_SoulShard_Solarus, Prefabs.Item_MagicSource_SoulShard_Morgana }; public GearService() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //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_002d: 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_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_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_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_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) EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[4] { new ComponentType(Il2CppType.Of<InventoryItem>(), (AccessMode)0), new ComponentType(Il2CppType.Of<PrefabGUID>(), (AccessMode)0), new ComponentType(Il2CppType.Of<ItemData>(), (AccessMode)0), new ComponentType(Il2CppType.Of<EquippableData>(), (AccessMode)0) }); val.Options = (EntityQueryOptions)3; EntityQueryDesc val2 = val; EntityManager entityManager = Core.EntityManager; itemQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 }); } public void SetShardsRestricted(bool shardsRestricted) { //IL_001f: 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_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_0047: 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_0083: 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_0054: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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) ItemCategory itemCategory = (ItemCategory)(shardsRestricted ? (0x40000000L | (long)(ShardService.IsPlentiful ? 8 : 0)) : 268435456); NativeParallelHashMap<PrefabGUID, ItemData> itemHashLookupMap = Core.Server.GetExistingSystemManaged<GameDataSystem>().ItemHashLookupMap; PrefabGUID[] array = shardPrefabs; ItemData val2 = default(ItemData); foreach (PrefabGUID val in array) { if (itemHashLookupMap.TryGetValue(val, ref val2)) { val2.ItemCategory = itemCategory; itemHashLookupMap[val] = val2; } } NativeArray<Entity> val3 = ((EntityQuery)(ref itemQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator<Entity> enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (shardPrefabs.Contains(EntityUtil.Read<PrefabGUID>(current))) { ItemData val4 = EntityUtil.Read<ItemData>(current); val4.ItemCategory = itemCategory; EntityUtil.Write<ItemData>(current, val4); } } val3.Dispose(); } } internal class ItemDrop { private static EntityQueryDesc invBagsQueryDesc; private static EntityQuery invBagQuery; private static bool queryInitialized; public static void CheckDrops() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0054: 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_0064: 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_008a: 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_0093: 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_009d: 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_00df: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager; if (!queryInitialized) { entityManager = Core.EntityManager; invBagQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { invBagsQueryDesc }); queryInitialized = true; } NativeArray<Entity> val = ((EntityQuery)(ref invBagQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator<Entity> enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity entity = enumerator.Current; if (!((Entity)(ref entity)).Equals(Entity.Null) && EntityUtil.Read<PrefabGUID>(entity) == Prefabs.Resource_Drop_SoulShard) { entityManager = Core.EntityManager; Translation componentData = ((EntityManager)(ref entityManager)).GetComponentData<Translation>(entity); if (!TeleportShard.DroppedShards.Exists((DroppedShard x) => x.entity == entity) && !((float3)(ref componentData.Value)).Equals(new float3(0f, 0f, 0f))) { TeleportShard.DroppedShards.Add(new DroppedShard(entity, DateTime.Now)); } } } val.Dispose(); } static ItemDrop() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_005d: 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_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_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) EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[7] { new ComponentType(Il2CppType.Of<ItemPickup>(), (AccessMode)0), new ComponentType(Il2CppType.Of<DestroyAfterDuration>(), (AccessMode)0), new ComponentType(Il2CppType.Of<Interactable>(), (AccessMode)0), new ComponentType(Il2CppType.Of<PrefabGUID>(), (AccessMode)0), new ComponentType(Il2CppType.Of<SpawnSequenceForEntity>(), (AccessMode)0), new ComponentType(Il2CppType.Of<InventoryBuffer>(), (AccessMode)0), new ComponentType(Il2CppType.Of<InventoryOwner>(), (AccessMode)0) }); val.Options = (EntityQueryOptions)1; invBagsQueryDesc = val; queryInitialized = false; } } public static class Logger { public static void Log(string message, string file, bool console = false) { if (Plugin.UsingCL && !console) { Type type = Type.GetType("CrimsonLog.Systems.Logger, CrimsonLog"); if (type != null) { type.GetMethod("Record").Invoke(null, new object[3] { "Shards", file, message + "\n" }); } else { Plugin.LogInstance.LogInfo((object)message); } } } } public class ClanService { private static readonly ComponentType[] ClanComponent = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly(Il2CppType.Of<ClanMemberStatus>()) }; private static EntityQuery ClansQuery; public ClanService() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) EntityManager entityManager = Core.EntityManager; ClansQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(ClanComponent); } public static IEnumerable<Entity> GetClans() { NativeArray<Entity> clanEntities = ((EntityQuery)(ref ClansQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)); try { Enumerator<Entity> enumerator = clanEntities.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(current)) { yield return current; } } } finally { clanEntities.Dispose(); } } public static Entity GetClanByName(string clanName) { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) Entity val = ((IEnumerable<Entity>)(from x in GetClans() where EntityUtil.ReadBuffer<SyncToUserBuffer>(x).Length > 0 select x).ToList()).FirstOrDefault((Func<Entity, bool>)delegate(Entity entity) { //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_0006: Unknown result type (might be due to invalid IL or missing references) ClanTeam val2 = EntityUtil.Read<ClanTeam>(entity); return ((FixedString64Bytes)(ref val2.Name)).Value.ToLower() == clanName.ToLower(); }); if (!(val != Entity.Null)) { return Entity.Null; } return val; } public static Entity GetClanByGUID(Guid clanGuid) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) Entity val = GetClans().FirstOrDefault((Func<Entity, bool>)((Entity entity) => EntityUtil.Read<ClanTeam>(entity).ClanGuid == clanGuid)); if (!(val != Entity.Null)) { return Entity.Null; } return val; } } public static class ResetService { private static bool TimesInUTC => Settings.TimesInUTC.Value; private static DateTime Now { get { if (!TimesInUTC) { return DateTime.Now; } return DateTime.UtcNow; } } public static void CheckForResets() { if (!Settings.TimedReset) { return; } foreach (LastReset lastReset in Plugin.DB.LastResets) { ResetInfo resetInfoFromKey = GetResetInfoFromKey(lastReset); if (resetInfoFromKey != null && resetInfoFromKey.Reset && (TimeService.NextReset(lastReset, resetInfoFromKey) - Now).TotalSeconds < 0.0) { ResetShard(lastReset); lastReset.Last = Now; Plugin.DB.SaveDatabase(); } } } public unsafe static void ResetShard(LastReset reset) { //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_0034: 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_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_0050: 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_00a4: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) ChatUtil.SystemSendAll(GetResetInfoFromKey(reset)?.Message); bool flag = default(bool); foreach (Entity allSoulShard in Plugin.ShardService.GetAllSoulShards()) { if (!EntityUtil.Exists(allSoulShard) || !EntityUtil.Has<Relic>(allSoulShard)) { continue; } Relic val = EntityUtil.Read<Relic>(allSoulShard); if (((object)(*(RelicType*)(&val.RelicType))/*cast due to .constrained prefix*/).ToString() == reset.Key) { if (Settings.FootballMode.Value) { FootballService.Remove(allSoulShard); } Core.StartCoroutine(BreakShardInAMoment(reset.Key)); ManualLogSource logInstance = Plugin.LogInstance; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Shard "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(reset.Key); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" has been reset by CrimsonShards."); } logInstance.LogInfo(val2); } } } public unsafe static bool ResetShard(string shardName) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0031: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) bool result = false; List<Entity> allSoulShards = Plugin.ShardService.GetAllSoulShards(); bool flag = default(bool); if (allSoulShards.Count > 4) { List<Entity> list = new List<Entity>(); foreach (Entity item in allSoulShards) { if (!EntityUtil.Exists(item)) { continue; } Relic val = EntityUtil.Read<Relic>(item); if (((object)(*(RelicType*)(&val.RelicType))/*cast due to .constrained prefix*/).ToString() == shardName) { list.Add(item); ManualLogSource logInstance = Plugin.LogInstance; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(71, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Shard "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(shardName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" has been added to list of delayed reset shards by CrimsonShards!"); } logInstance.LogInfo(val2); result = true; } } if (list.Count > 0) { Core.StartCoroutine(MassBreakShardInAMoment(list)); } } else { foreach (Entity item2 in allSoulShards) { if (!EntityUtil.Exists(item2) || !EntityUtil.Has<Relic>(item2)) { continue; } Relic val3 = EntityUtil.Read<Relic>(item2); if (((object)(*(RelicType*)(&val3.RelicType))/*cast due to .constrained prefix*/).ToString() == shardName) { if (Settings.FootballMode.Value) { FootballService.Remove(item2); } Core.StartCoroutine(BreakShardInAMoment(shardName)); ManualLogSource logInstance2 = Plugin.LogInstance; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Shard "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(shardName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" has been reset by CrimsonShards!"); } logInstance2.LogInfo(val2); result = true; } } } return result; } private unsafe static IEnumerator BreakShardInAMoment(string shardName) { yield return null; Enumerator<Entity> enumerator = EntityUtil.GetEntitiesByComponentType<Relic>(false, false, false, false, false).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (EntityUtil.Has<Durability>(current)) { Relic val = EntityUtil.Read<Relic>(current); if (!(((object)(*(RelicType*)(&val.RelicType))/*cast due to .constrained prefix*/).ToString().ToLower() != shardName.ToLower())) { Durability val2 = EntityUtil.Read<Durability>(current); val2.Value = 0f; val2.DestroyItemWhenBroken = true; EntityUtil.Write<Durability>(current, val2); } } } } private unsafe static IEnumerator MassBreakShardInAMoment(List<Entity> shards) { yield return (object)new WaitForEndOfFrame(); ManualLogSource logInstance = Plugin.LogInstance; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Mass breaking "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(shards.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" shards..."); } logInstance.LogInfo(val); foreach (Entity shard in shards) { if (EntityUtil.Exists(shard) && EntityUtil.Has<Durability>(shard)) { if (Plugin.DB?.Footballs != null) { FootballService.Remove(shard); } Durability val2 = EntityUtil.Read<Durability>(shard); val2.Value = 0f; val2.DestroyItemWhenBroken = true; EntityUtil.Write<Durability>(shard, val2); ManualLogSource logInstance2 = Plugin.LogInstance; val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Shard "); BepInExInfoLogInterpolatedStringHandler obj = val; Relic val3 = EntityUtil.Read<Relic>(shard); ((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>(((object)(*(RelicType*)(&val3.RelicType))/*cast due to .constrained prefix*/).ToString()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has been mass broken by CrimsonShards!"); } logInstance2.LogInfo(val); yield return (object)new WaitForSeconds(0.2f); } } } public static ResetInfo? GetResetInfoFromKey(LastReset reset) { LastReset reset2; return GetResetInfoFromString(reset.Key, out reset2); } public static ResetInfo? GetResetInfoFromString(string name, out LastReset? reset) { reset = Plugin.DB.LastResets.FirstOrDefault((LastReset x) => x.Key.ToLower().Replace(" ", "") == name.ToLower().Replace(" ", "")) ?? null; if (reset != null) { return reset.Key switch { "Dracula" => new ResetInfo { Reset = Settings.ResetDracula.Value, Mode = Settings.Dracula_Mode.Value, Time = Settings.Dracula_Time.Value, Interval = Settings.Dracula_Interval_Count.Value, Day = Settings.Dracula_Fixed_Day.Value, SkipWeeks = Settings.Dracula_Fixed_SkipWeeks.Value, Message = Plugin.DB.Messages[1].Value }, "TheMonster" => new ResetInfo { Reset = Settings.ResetMonster.Value, Mode = Settings.Monster_Mode.Value, Time = Settings.Monster_Time.Value, Interval = Settings.Monster_Interval_Count.Value, Day = Settings.Monster_Fixed_Day.Value, SkipWeeks = Settings.Monster_Fixed_SkipWeeks.Value, Message = Plugin.DB.Messages[2].Value }, "Solarus" => new ResetInfo { Reset = Settings.ResetSolarus.Value, Mode = Settings.Solarus_Mode.Value, Time = Settings.Solarus_Time.Value, Interval = Settings.Solarus_Interval_Count.Value, Day = Settings.Solarus_Fixed_Day.Value, SkipWeeks = Settings.Solarus_Fixed_SkipWeeks.Value, Message = Plugin.DB.Messages[3].Value }, "WingedHorror" => new ResetInfo { Reset = Settings.ResetWingedHorror.Value, Mode = Settings.WingedHorror_Mode.Value, Time = Settings.WingedHorror_Time.Value, Interval = Settings.WingedHorror_Interval_Count.Value, Day = Settings.WingedHorror_Fixed_Day.Value, SkipWeeks = Settings.WingedHorror_Fixed_SkipWeeks.Value, Message = Plugin.DB.Messages[4].Value }, "Morgana" => new ResetInfo { Reset = Settings.ResetMorgana.Value, Mode = Settings.Morgana_Mode.Value, Time = Settings.Morgana_Time.Value, Interval = Settings.Morgana_Interval_Count.Value, Day = Settings.Morgana_Fixed_Day.Value, SkipWeeks = Settings.Morgana_Fixed_SkipWeeks.Value, Message = Plugin.DB.Messages[5].Value }, _ => null, }; } return null; } public static bool SetReset(LastReset reset, ResetInfo resetInfo) { try { reset.Last = Now; Plugin.DB.SaveDatabase(); return true; } catch (Exception) { return false; } } } public class ShardService { public static readonly PrefabGUID[] ShardPrefabs = (PrefabGUID[])(object)new PrefabGUID[5] { Prefabs.Item_MagicSource_SoulShard_Dracula, Prefabs.Item_MagicSource_SoulShard_Manticore, Prefabs.Item_MagicSource_SoulShard_Monster, Prefabs.Item_MagicSource_SoulShard_Solarus, Prefabs.Item_MagicSource_SoulShard_Morgana }; private readonly List<Entity> droppedSoulshards = new List<Entity>(); private readonly List<Entity> spawnedSoulshards = new List<Entity>(); private EntityQuery relicDroppedQuery; private EntityQuery soulshardAndPrefabsQuery; public static EntityQuery itemQuery; public static bool IsPlentiful => (int)Core.Server.GetExistingSystemManaged<ServerGameSettingsSystem>()._Settings.RelicSpawnType == 1; public ShardService() { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00e4: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_013c: 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_014f: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<InventoryItem>(), (