The current BepInExPack is broken due to the Oakveil update, and mods installed through a mod manager may not work. Join the modding Discord for more information.
Decompiled source of CrimsonLog v1.3.2
CrimsonLog.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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.Json; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CrimsonLog.Services; using CrimsonLog.Structs; using CrimsonLog.Systems; using HarmonyLib; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.CastleBuilding.Rebuilding; using ProjectM.Gameplay.Clan; using ProjectM.Gameplay.Systems; using ProjectM.Network; using Unity.Collections; using Unity.Entities; using UnityEngine; using VAMP; using VAMP.Services; using VAMP.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("CrimsonLog")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A simplistic logger for V Rising")] [assembly: AssemblyFileVersion("1.3.2.0")] [assembly: AssemblyInformationalVersion("1.3.2+Branch.master.Sha.ef94f0072454fdb3a176a7d44ffa29417d7c7941.ef94f0072454fdb3a176a7d44ffa29417d7c7941")] [assembly: AssemblyProduct("CrimsonLog")] [assembly: AssemblyTitle("CrimsonLog")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CrimsonLog { [BepInPlugin("CrimsonLog", "CrimsonLog", "1.3.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private Harmony _harmony; public static readonly string ConfigFiles = Path.Combine(Paths.ConfigPath, "CrimsonLog"); 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 Tracked Tracked { get; private set; } public override void Load() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown Instance = this; Settings = default(Settings); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); Settings.InitConfig(); ManualLogSource logInstance = LogInstance; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(7, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrimsonLog"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded"); } logInstance.LogInfo(val); Plugin.OnCoreLoaded = (Action)Delegate.Combine(Plugin.OnCoreLoaded, new Action(Loaded)); } public void Loaded() { Tracked = new Tracked(); } public override bool Unload() { ((BasePlugin)this).Config.Clear(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "CrimsonLog"; public const string PLUGIN_NAME = "CrimsonLog"; public const string PLUGIN_VERSION = "1.3.2"; } } namespace CrimsonLog.Structs { [StructLayout(LayoutKind.Sequential, Size = 1)] public readonly struct Settings { public static ConfigEntry<bool> ToggleLog { get; private set; } public static ConfigEntry<int> DaysToKeep { get; private set; } public static ConfigEntry<bool> ChatSingleFile { get; private set; } public static ConfigEntry<bool> GlobalChat { get; private set; } public static ConfigEntry<bool> WhisperChat { get; private set; } public static ConfigEntry<bool> RegionChat { get; private set; } public static ConfigEntry<bool> LocalChat { get; private set; } public static ConfigEntry<bool> TeamChat { get; private set; } public static ConfigEntry<bool> CastleHeart { get; private set; } public static ConfigEntry<bool> BloodTransfer { get; private set; } public static ConfigEntry<bool> ClanMembership { get; private set; } public static void InitConfig() { ToggleLog = InitConfigEntry("_Config", "ToggleLog", defaultValue: true, "Enable or disable the mod overall"); DaysToKeep = InitConfigEntry("_Config", "DaysToKeep", 5, "How many days (server time) to keep logs before automated delete. -1 to set to manually delete only."); ChatSingleFile = InitConfigEntry("Chat", "SingleFile", defaultValue: true, "If this is true, all chats will go to a single file; otherwise they will have their own files"); GlobalChat = InitConfigEntry("Chat", "Global", defaultValue: true, "Log the global chat"); WhisperChat = InitConfigEntry("Chat", "Whisper", defaultValue: false, "Log player whispers"); RegionChat = InitConfigEntry("Chat", "Region", defaultValue: false, "Log region chat"); LocalChat = InitConfigEntry("Chat", "Local", defaultValue: false, "Log local chat"); TeamChat = InitConfigEntry("Chat", "Team", defaultValue: false, "Log team chat"); CastleHeart = InitConfigEntry("CastleHeart", "CastleHeart", defaultValue: true, "Log castle heart activity"); BloodTransfer = InitConfigEntry("CastleHeart", "BloodTransfer", defaultValue: false, "Logs transfers of Blood Essense in and out of castle hearts (seperate file from heart activity)"); ClanMembership = InitConfigEntry("Clans", "Membership", defaultValue: true, "Log clan membership changes"); } 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, "CrimsonLog.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; } } public class Tracked { public static string DecayFile = Path.Combine(Plugin.ConfigFiles, "DoNotTouch.json"); public static List<string> Decaying; public Tracked() { CreateDirectories(Path.GetDirectoryName(DecayFile)); LoadDatabase(); } private static bool LoadDatabase() { if (!File.Exists(DecayFile)) { Decaying = new List<string>(); return false; } Decaying = JsonSerializer.Deserialize<List<string>>(File.ReadAllText(DecayFile)); return true; } public static bool SaveDatabase() { File.WriteAllText(DecayFile, JsonSerializer.Serialize(Decaying)); return true; } private static void CreateDirectories(string path) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } } } namespace CrimsonLog.Systems { public static class Logger { public static Task<string> CreateDirectory(string folderName) { if (!Directory.Exists("CrimsonLogs/" + folderName)) { Directory.CreateDirectory("CrimsonLogs/" + folderName); } return Task.FromResult("CrimsonLogs/" + folderName); } public static async void Record(string folderName, string recordName, string message) { string text = await CreateDirectory(folderName); string path = $"{text}/{recordName}_{DateTime.Now:yyyy-MM-dd}"; if (!File.Exists(path)) { File.Create(path).Dispose(); DeleteOldLogs(text, recordName); } File.AppendAllText(path, Time() + " | " + message); } public static string Time() { return $"{DateTime.Now:HH:mm.ss}"; } public static void DeleteOldLogs(string folderPath, string prefix) { int value = Settings.DaysToKeep.Value; if (value < 0) { return; } string[] files = Directory.GetFiles(folderPath, prefix + "*"); foreach (string text in files) { FileInfo fileInfo = new FileInfo(text); if ((DateTime.Now - fileInfo.CreationTime).Days > value) { File.Delete(text); } } } } } namespace CrimsonLog.Services { public static class Chat { private static readonly bool SingleFile = Settings.ChatSingleFile.Value; private static readonly bool LogGlobal = Settings.GlobalChat.Value; private static readonly bool LogWhisper = Settings.WhisperChat.Value; private static readonly bool LogRegion = Settings.RegionChat.Value; private static readonly bool LogLocal = Settings.LocalChat.Value; private static readonly bool LogTeam = Settings.TeamChat.Value; private static async void LogMessage(string chatType, string prefix, string message, string characterName, string additionalInfo = "") { string text = await Logger.CreateDirectory("Chat"); string value = (SingleFile ? (Logger.Time() + " | " + chatType) : Logger.Time()); string contents = $"{value} | {characterName}{additionalInfo} | {message}\n"; string path = $"{text}/{(SingleFile ? "chat_" : prefix)}{DateTime.Now:yyy-MM-dd}"; if (!File.Exists(path)) { File.Create(path).Dispose(); Logger.DeleteOldLogs(text, prefix); } File.AppendAllText(path, contents); } public static void Global(ChatMessageEvent message, User fromUser) { if (LogGlobal) { LogMessage("Global", "global_", ((object)(FixedString512Bytes)(ref message.MessageText)).ToString(), ((object)(FixedString64Bytes)(ref fromUser.CharacterName)).ToString()); } } public static void Region(ChatMessageEvent message, User fromUser) { if (LogRegion) { LogMessage("Region", "region_", ((object)(FixedString512Bytes)(ref message.MessageText)).ToString(), ((object)(FixedString64Bytes)(ref fromUser.CharacterName)).ToString()); } } public static void Local(ChatMessageEvent message, User fromUser) { if (LogLocal) { LogMessage("Local", "local_", ((object)(FixedString512Bytes)(ref message.MessageText)).ToString(), ((object)(FixedString64Bytes)(ref fromUser.CharacterName)).ToString()); } } public static void Team(ChatMessageEvent message, User fromUser) { //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) if (LogTeam) { ClanTeam val = EntityUtil.Read<ClanTeam>(fromUser.ClanEntity._Entity); string value = ((FixedString64Bytes)(ref val.Name)).Value; LogMessage("Clan", "clan_", ((object)(FixedString512Bytes)(ref message.MessageText)).ToString(), ((object)(FixedString64Bytes)(ref fromUser.CharacterName)).ToString(), " | " + value); } } public static void Whisper(ChatMessageEvent message, User fromUser) { //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) if (LogWhisper) { User val = EntityUtil.Read<User>(GetEntityFromNetworkId(message.ReceiverEntity)); string text = ((object)(FixedString64Bytes)(ref val.CharacterName)).ToString(); LogMessage("Whisper", "whisper_", ((object)(FixedString512Bytes)(ref message.MessageText)).ToString(), ((object)(FixedString64Bytes)(ref fromUser.CharacterName)).ToString(), " -> " + text); } } public static Entity GetEntityFromNetworkId(NetworkId networkid) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Singleton val = EntityUtil.Read<Singleton>(EntityUtil.GetEntitiesByComponentTypes<Singleton>((EntityQueryOptions)16)[0]); NetworkIdLookupMap networkIdLookupRW = ((Singleton)(ref val)).GetNetworkIdLookupRW(); Entity result = default(Entity); ((NetworkIdLookupMap)(ref networkIdLookupRW)).TryGetValue(networkid, ref result); return result; } } } namespace CrimsonLog.Hooks { [HarmonyPatch(typeof(CastleRebuildRegistryOnDestroySystem), "OnUpdate")] internal class DismantlePatch { private static void Prefix(CastleRebuildRegistryOnDestroySystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) EntityQuery _query_1821521061_ = __instance.__query_1821521061_0; Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_1821521061_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!EntityUtil.Has<UserOwner>(current)) { continue; } UserOwner val = EntityUtil.Read<UserOwner>(current); if (EntityUtil.Has<User>(val.Owner._Entity)) { User val2 = EntityUtil.Read<User>(val.Owner._Entity); if (EntityUtil.Has<CastleHeart>(current) && EntityUtil.Read<CastleHeart>(current).CastleTerritoryId.ZoneId == 0) { Logger.Record("CastleHeart", "heart_events", $"{val2.CharacterName} has relocated their own castle."); } } } } } [HarmonyPatch(typeof(CastleHeartEventSystem), "OnUpdate")] internal class CastleHeartEventSystemPatch { public static void Prefix(CastleHeartEventSystem __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_0032: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0091: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_00b0: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected I4, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) NativeArray<Entity> val = default(NativeArray<Entity>); try { EntityQuery castleHeartInteractEventQuery = __instance._CastleHeartInteractEventQuery; val = ((EntityQuery)(ref castleHeartInteractEventQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator<Entity> enumerator = val.GetEnumerator(); Entity val6 = default(Entity); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!EntityUtil.Exists(current) || !EntityUtil.Has<CastleHeartInteractEvent>(current) || !EntityUtil.Has<FromCharacter>(current)) { continue; } CastleHeartInteractEvent val2 = EntityUtil.Read<CastleHeartInteractEvent>(current); FromCharacter val3 = EntityUtil.Read<FromCharacter>(current); if (!EntityUtil.Exists(val3.User) || !EntityUtil.Has<User>(val3.User)) { continue; } User val4 = EntityUtil.Read<User>(val3.User); User val5 = val4; if (CastleHeartService.TryGetByID(val2.CastleHeart, ref val6) && EntityUtil.Exists(val6) && EntityUtil.Has<UserOwner>(val6)) { UserOwner val7 = EntityUtil.Read<UserOwner>(val6); if (EntityUtil.Exists(val7.Owner._Entity)) { val5 = EntityUtil.Read<User>(val7.Owner._Entity); } } CastleHeart val8 = EntityUtil.Read<CastleHeart>(val6); string text = ((val5 == val4) ? "their own castle." : $"{val4.CharacterName}'s castle."); CastleHeartInteractEventType eventType = val2.EventType; switch ((int)eventType) { case 0: Logger.Record("CastleHeart", "heart_events", $"{val4.CharacterName} has upgraded {text.Replace(".", "")} to Level {val8.Level + 1}.\n"); break; case 1: Logger.Record("CastleHeart", "heart_events", $"{val4.CharacterName} has abandoned {text}\n"); break; case 2: Logger.Record("CastleHeart", "heart_events", $"{val4.CharacterName} has exposed {text}\n"); break; case 3: Logger.Record("CastleHeart", "heart_events", $"{val4.CharacterName} has claimed {text}\n"); break; case 4: Logger.Record("CastleHeart", "heart_events", $"{val4.CharacterName} has disabled defenses of {text}\n"); break; case 5: Logger.Record("CastleHeart", "heart_events", $"{val4.CharacterName} has destroyed {text}\n"); break; } } } catch (Exception ex) { Plugin.LogInstance.LogError((object)ex); } finally { val.Dispose(); } } } [HarmonyPatch(typeof(CastleHeartStateUpdateSystem), "OnUpdate")] internal class CastleHeartStateUpdateSystemPatch { public static void Prefix(CastleHeartStateUpdateSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) EntityQuery stateUpdateQuery = __instance._StateUpdateQuery; Enumerator<Entity> enumerator = ((EntityQuery)(ref stateUpdateQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!EntityUtil.Exists(current) || Plugin.Tracked == null || Tracked.Decaying == null || !EntityUtil.Has<CastleHeart>(current) || !EntityUtil.Has<UserOwner>(current)) { continue; } UserOwner val = EntityUtil.Read<UserOwner>(current); if (!EntityUtil.Exists(val.Owner._Entity)) { continue; } CastleHeart val2 = EntityUtil.Read<CastleHeart>(current); User user = EntityUtil.Read<User>(val.Owner._Entity); if (((CastleHeart)(ref val2)).IsPhased()) { continue; } if (Tracked.Decaying.Exists((string x) => x == ((FixedString64Bytes)(ref user.CharacterName)).Value)) { if (!((CastleHeart)(ref val2)).IsDecaying()) { Tracked.Decaying.Remove(((FixedString64Bytes)(ref user.CharacterName)).Value); Tracked.SaveDatabase(); Logger.Record("CastleHeart", "heart_events", $"{user.CharacterName}'s castle has stopped decaying.\n"); } } else if (((CastleHeart)(ref val2)).IsDecaying()) { Tracked.Decaying.Add(((FixedString64Bytes)(ref user.CharacterName)).Value); Tracked.SaveDatabase(); Logger.Record("CastleHeart", "heart_events", $"{user.CharacterName}'s castle has begun to decay.\n"); } } } } [HarmonyPatch] public static class ChatMessageSystem_Patch { [HarmonyPatch(typeof(ChatMessageSystem), "OnUpdate")] [HarmonyPrefix] public static bool OnUpdate(ChatMessageSystem __instance) { //IL_000f: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_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_008f: 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_0097: Invalid comparison between Unknown and I4 //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (!Settings.ToggleLog.Value) { return true; } _ = __instance.__query_661171423_0; EntityQuery _query_661171423_ = __instance.__query_661171423_0; Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_661171423_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager; FromCharacter componentData = ((EntityManager)(ref entityManager)).GetComponentData<FromCharacter>(current); entityManager = ((ComponentSystemBase)__instance).EntityManager; User componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<User>(componentData.User); entityManager = ((ComponentSystemBase)__instance).EntityManager; ChatMessageEvent componentData3 = ((EntityManager)(ref entityManager)).GetComponentData<ChatMessageEvent>(current); if ((int)componentData3.MessageType == 0) { Chat.Global(componentData3, componentData2); } else if ((int)componentData3.MessageType == 1) { Chat.Region(componentData3, componentData2); } else if ((int)componentData3.MessageType == 4) { Chat.Region(componentData3, componentData2); } else if ((int)componentData3.MessageType == 2) { Chat.Team(componentData3, componentData2); } else if (((NetworkId)(ref componentData3.ReceiverEntity)).IsValid) { Chat.Whisper(componentData3, componentData2); } } return true; } } [HarmonyPatch(typeof(ClanSystem_Server), "OnUpdate")] internal class ClanSystemServerPatch { public static void Prefix(ClanSystem_Server __instance) { //IL_0016: 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_0044: 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_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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a4: Unknown result type (might be due to invalid IL or missing references) if (!Settings.ClanMembership.Value) { return; } (EntityQuery, string)[] array = new(EntityQuery, string)[4] { (__instance._ClanInviteResponseQuery, "Response"), (__instance._KickRequestQuery, "Kick"), (__instance._CreateClanEventQuery, "Create"), (__instance._LeaveClanEventQuery, "Leave") }; for (int i = 0; i < array.Length; i++) { (EntityQuery, string) tuple = array[i]; EntityQuery item = tuple.Item1; string item2 = tuple.Item2; NativeArray<Entity> val = ((EntityQuery)(ref item)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator<Entity> enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Log(enumerator.Current, item2); } val.Dispose(); } } private static void Log(Entity entity, string type) { //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_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_004f: 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_0058: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) User val = EntityUtil.Read<User>(EntityUtil.Read<FromCharacter>(entity).User); EntityManager entityManager; switch (type) { case "Create": entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity)) { CreateClan_Request val8 = EntityUtil.Read<CreateClan_Request>(entity); Logger.Record("Clans", "clan", $"{val.CharacterName} created the \"{((FixedString64Bytes)(ref val8.ClanName)).Value}.\" clan.\n"); } break; case "Leave": entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity)) { Entity val5 = default(Entity); if (CastleHeartService.TryGetByID(EntityUtil.Read<LeaveClan>(entity).ClanId, ref val5)) { ClanTeam val6 = EntityUtil.Read<ClanTeam>(val5); Logger.Record("Clans", "clan", $"{val.CharacterName} left the \"{((FixedString64Bytes)(ref val6.Name)).Value}\" clan.\n"); } else { ClanTeam val7 = EntityUtil.Read<ClanTeam>(val.ClanEntity._Entity); Logger.Record("Clans", "clan", $"{val.CharacterName} left the \"{((FixedString64Bytes)(ref val7.Name)).Value}\" clan.\n"); } } break; case "Response": { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entity)) { break; } ClanInviteResponse val9 = EntityUtil.Read<ClanInviteResponse>(entity); if (!((object)(InviteRequestResponse)(ref val9.Response)).Equals((object)(InviteRequestResponse)1)) { break; } Entity val10 = default(Entity); if (!CastleHeartService.TryGetByID(val9.ClanId, ref val10)) { ManualLogSource logInstance = Plugin.LogInstance; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val11 = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val11).AppendLiteral("Couldn't find clan for "); ((BepInExLogInterpolatedStringHandler)val11).AppendFormatted<FixedString64Bytes>(val.CharacterName); ((BepInExLogInterpolatedStringHandler)val11).AppendLiteral(" join response."); } logInstance.LogError(val11); } else { ClanTeam val12 = EntityUtil.Read<ClanTeam>(val10); Logger.Record("Clans", "clan", $"{val.CharacterName} joined \"{((FixedString64Bytes)(ref val12.Name)).Value}\" clan.\n"); } break; } case "Kick": { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).Exists(entity)) { break; } Kick_Request val2 = EntityUtil.Read<Kick_Request>(entity); ClanTeam val3 = EntityUtil.Read<ClanTeam>(val.ClanEntity._Entity); entityManager = Core.EntityManager; DynamicBuffer<ClanMemberStatus> buffer = ((EntityManager)(ref entityManager)).GetBuffer<ClanMemberStatus>(val.ClanEntity._Entity, false); entityManager = Core.EntityManager; DynamicBuffer<SyncToUserBuffer> buffer2 = ((EntityManager)(ref entityManager)).GetBuffer<SyncToUserBuffer>(val.ClanEntity._Entity, false); for (int i = 0; i < buffer.Length; i++) { if (buffer[i].UserIndex == val2.TargetUserIndex) { User val4 = EntityUtil.Read<User>(buffer2[i].UserEntity); Logger.Record("Clans", "clan", $"{val4.CharacterName} was kicked from \"{((FixedString64Bytes)(ref val3.Name)).Value}\" clan by {val.CharacterName}.\n"); break; } } break; } } } } [HarmonyPatch(typeof(ReactToInventoryChangedSystem), "OnUpdate")] internal class ReactToInventoryChangedPatch { public static void Prefix(ReactToInventoryChangedSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0094: 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_00cb: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) EntityQuery _query_2096870026_ = __instance.__query_2096870026_0; NativeArray<Entity> val = ((EntityQuery)(ref _query_2096870026_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); InventoryChangedEvent val2 = default(InventoryChangedEvent); while (enumerator.MoveNext()) { if (!EntityUtil.TryGetComponent<InventoryChangedEvent>(enumerator.Current, ref val2) || !Settings.BloodTransfer.Value || val2.Item._Value != 862477668) { continue; } Entity inventoryOwner = EntityUtil.Read<InventoryConnection>(val2.InventoryEntity).InventoryOwner; if (!EntityUtil.Has<CastleHeart>(inventoryOwner)) { continue; } UserOwner val3 = EntityUtil.Read<UserOwner>(inventoryOwner); EntityUtil.Read<CastleHeart>(inventoryOwner); User val4 = EntityUtil.Read<User>(val3.Owner._Entity); if (((object)(InventoryChangedEventType)(ref val2.ChangeType)).Equals((object)(InventoryChangedEventType)1)) { Logger.Record("CastleHeart", "blood_transfer", $"{Mathf.Abs(val2.Amount)} Blood Essence has been added to {val4.CharacterName}'s Castle.\n"); } else if (((object)(InventoryChangedEventType)(ref val2.ChangeType)).Equals((object)(InventoryChangedEventType)0)) { if (val2.Amount == -1) { return; } Logger.Record("CastleHeart", "blood_transfer", $"{Mathf.Abs(val2.Amount)} Blood Essence has been removed from {val4.CharacterName}'s Castle.\n"); } } val.Dispose(); } catch (Exception) { } } } }