using 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 ProjectM.Scripting;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using VAMP;
using VAMP.Models;
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.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1+1.Branch.master.Sha.c844e145f58f76e58ce4c984587047f431bcdc61.c844e145f58f76e58ce4c984587047f431bcdc61")]
[assembly: AssemblyProduct("CrimsonLog")]
[assembly: AssemblyTitle("CrimsonLog")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.1.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;
}
}
}
public class Looting
{
private static PrefabLookupMap LookupMap;
public Looting()
{
//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)
LookupMap = Core.ServerScriptMapper._PrefabCollectionSystem._PrefabLookupMap;
}
public static void Looted(InventoryBuffer item, PrefabGUID containerGuid, bool allies, bool ownerLooted, CastleHeart castleHeart, Player looter, Player looted)
{
//IL_0000: 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)
string itemName = GetItemName(item);
string inventoryName = GetInventoryName(containerGuid);
if (allies)
{
return;
}
if (((CastleHeart)(ref castleHeart)).IsDecaying())
{
if (Settings.LootingDecayedCastle.Value)
{
LogLooting("decayed_looting", $"{looter.FullName} looted {itemName} from a decaying {inventoryName}.\n");
}
}
else if (!ownerLooted && Settings.LootingCastle.Value)
{
LogLooting("castle_looting", $"{looter.FullName} looted {itemName} from {looted.FullName}'s {inventoryName}.\n");
}
}
public static void Placed(InventoryBuffer item, PrefabGUID containerGuid, bool allies, bool ownerLooted, CastleHeart castleHeart, Player looter, Player looted)
{
//IL_0000: 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)
string itemName = GetItemName(item);
string inventoryName = GetInventoryName(containerGuid);
if (!allies && !((CastleHeart)(ref castleHeart)).IsDecaying())
{
}
}
private static string GetItemName(InventoryBuffer item)
{
//IL_0005: 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_008c: Unknown result type (might be due to invalid IL or missing references)
FixedString128Bytes fixedName = ((PrefabLookupMap)(ref LookupMap)).GetFixedName(item.ItemType);
string value = ItemUtil.CleanItemName(((FixedString128Bytes)(ref fixedName)).Value).Replace(" ", "") + $" ({((PrefabGUID)(ref item.ItemType)).GuidHash})";
return $"{value} x{item.Amount}";
}
private static string GetInventoryName(PrefabGUID containerGuid)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
string empty = string.Empty;
FixedString128Bytes fixedName = ((PrefabLookupMap)(ref LookupMap)).GetFixedName(containerGuid);
empty = ((FixedString128Bytes)(ref fixedName)).Value;
empty = ItemUtil.CleanItemName(empty).Replace(" ", "");
empty = $"{empty} ({((PrefabGUID)(ref containerGuid)).GuidHash})";
if (string.IsNullOrEmpty(empty))
{
empty = "castle";
}
return empty;
}
private static void LogLooting(string filename, string message)
{
if (Settings.LootingSingleFile.Value)
{
filename = "looting";
}
Logger.Record("Looting", filename, message);
}
}
namespace CrimsonLog
{
[BepInPlugin("CrimsonLog", "CrimsonLog", "1.4.1")]
[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 static Looting Looting { 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);
Events.OnCoreLoaded = (Action)Delegate.Combine(Events.OnCoreLoaded, new Action(Loaded));
}
public void Loaded()
{
Tracked = new Tracked();
Looting = new Looting();
}
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.4.1";
}
}
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 ConfigEntry<bool> RenamesSingleFile { get; private set; }
public static ConfigEntry<bool> HorseRenames { get; private set; }
public static ConfigEntry<bool> ContainerRenames { get; private set; }
public static ConfigEntry<bool> UnknownRenames { get; private set; }
public static ConfigEntry<bool> LootingSingleFile { get; private set; }
public static ConfigEntry<bool> LootingCastle { get; private set; }
public static ConfigEntry<bool> LootingDecayedCastle { get; private set; }
public static bool AnyLooting
{
get
{
if (!LootingDecayedCastle.Value)
{
return LootingCastle.Value;
}
return true;
}
}
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");
RenamesSingleFile = InitConfigEntry("Renaming", "SingleFile", defaultValue: false, "If this is true, all renames will go to a single file; otherwise they will have their own files");
HorseRenames = InitConfigEntry("Renaming", "Horses", defaultValue: true, "Log horse renaming");
ContainerRenames = InitConfigEntry("Renaming", "Containers", defaultValue: true, "Log container renaming");
UnknownRenames = InitConfigEntry("Renaming", "Unknowns", defaultValue: true, "Log unknown renaming (this will capture any renaming not covered by the other settings / not yet properly supported by the mod)");
LootingSingleFile = InitConfigEntry("Looting", "SingleFile", defaultValue: false, "If this is true, all looting will go to a single file; otherwise they will have their own files");
LootingCastle = InitConfigEntry("Looting", "Castle", defaultValue: false, "Log looting of castles");
LootingDecayedCastle = InitConfigEntry("Looting", "DecayedCastle", defaultValue: false, "Log looting of decayed castles");
}
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}.txt";
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_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: 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_0154: 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_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: 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_00f8: 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_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: 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_02c9: 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_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: 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_02dd: 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_02e6: 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_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: 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_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Expected O, but got Unknown
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: 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 val7 = EntityUtil.Read<CreateClan_Request>(entity);
Logger.Record("Clans", "clan", $"{val.CharacterName} created the \"{((FixedString64Bytes)(ref val7.ClanName)).Value}.\" clan.\n");
}
break;
case "Leave":
entityManager = Core.EntityManager;
if (((EntityManager)(ref entityManager)).Exists(entity))
{
Entity byNetworkId = ClanService.GetByNetworkId(EntityUtil.Read<LeaveClan>(entity).ClanId);
if (!((Entity)(ref byNetworkId)).Equals(Entity.Null))
{
ClanTeam val5 = EntityUtil.Read<ClanTeam>(byNetworkId);
Logger.Record("Clans", "clan", $"{val.CharacterName} left the \"{((FixedString64Bytes)(ref val5.Name)).Value}\" clan.\n");
}
else
{
ClanTeam val6 = EntityUtil.Read<ClanTeam>(val.ClanEntity._Entity);
Logger.Record("Clans", "clan", $"{val.CharacterName} left the \"{((FixedString64Bytes)(ref val6.Name)).Value}\" clan.\n");
}
}
break;
case "Response":
{
entityManager = Core.EntityManager;
if (!((EntityManager)(ref entityManager)).Exists(entity))
{
break;
}
ClanInviteResponse val8 = EntityUtil.Read<ClanInviteResponse>(entity);
if (!((object)(InviteRequestResponse)(ref val8.Response)).Equals((object)(InviteRequestResponse)1))
{
break;
}
Entity byNetworkId2 = ClanService.GetByNetworkId(val8.ClanId);
if (((Entity)(ref byNetworkId2)).Equals(Entity.Null))
{
ManualLogSource logInstance = Plugin.LogInstance;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val9 = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral("Couldn't find clan for ");
((BepInExLogInterpolatedStringHandler)val9).AppendFormatted<FixedString64Bytes>(val.CharacterName);
((BepInExLogInterpolatedStringHandler)val9).AppendLiteral(" join response.");
}
logInstance.LogError(val9);
}
else
{
ClanTeam val10 = EntityUtil.Read<ClanTeam>(byNetworkId2);
Logger.Record("Clans", "clan", $"{val.CharacterName} joined \"{((FixedString64Bytes)(ref val10.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(NameableInteractableSystem), "OnUpdate")]
internal class NameableInteract
{
public static void Prefix(NameableInteractableSystem __instance)
{
//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_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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_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_004d: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_0096: 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_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_00a9: 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_00c8: 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_00b9: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: 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_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
if (!Settings.UnknownRenames.Value)
{
return;
}
EntityQuery renameQuery = __instance._RenameQuery;
Enumerator<Entity> enumerator = ((EntityQuery)(ref renameQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
if (!EntityUtil.Exists(current) || !EntityUtil.Has<FromCharacter>(current) || !EntityUtil.Has<RenameInteractable>(current))
{
continue;
}
FromCharacter val = EntityUtil.Read<FromCharacter>(current);
RenameInteractable val2 = EntityUtil.Read<RenameInteractable>(current);
User val3 = EntityUtil.Read<User>(val.User);
NativeArray<Entity> entitiesByComponentType = EntityUtil.GetEntitiesByComponentType<NameableInteractable>(false, false, false, false, false);
Entity val4 = Entity.Null;
Enumerator<Entity> enumerator2 = entitiesByComponentType.GetEnumerator();
while (enumerator2.MoveNext())
{
Entity current2 = enumerator2.Current;
if (EntityUtil.Read<NetworkId>(current2).Normal_Index == val2.InteractableId.Normal_Index)
{
val4 = current2;
break;
}
}
if (((Entity)(ref val4)).Equals(Entity.Null))
{
if (Settings.UnknownRenames.Value)
{
Log("unknown_entities", $"{((FixedString64Bytes)(ref val3.CharacterName)).Value} renamed something to \"{val2.NewName}\"\n");
}
continue;
}
if (EntityUtil.Has<Mountable>(val4))
{
if (Settings.HorseRenames.Value)
{
Log("horses", $"{((FixedString64Bytes)(ref val3.CharacterName)).Value} renamed a horse to \"{val2.NewName}\"\n");
}
break;
}
if (EntityUtil.Has<CastleWorkstation>(val4))
{
if (Settings.ContainerRenames.Value)
{
PrefabGUID val5 = EntityUtil.Read<PrefabGUID>(val4);
ServerGameManager serverGameManager = Core.ServerGameManager;
string value = ItemUtil.CleanItemName(((PrefabLookupMap)(ref serverGameManager.PrefabLookupMap)).GetName(val5)).Replace(" ", "");
Log("castles_containers", $"{((FixedString64Bytes)(ref val3.CharacterName)).Value} renamed a {value} ({((PrefabGUID)(ref val5)).GuidHash}) to \"{val2.NewName}\"\n");
}
break;
}
if (Settings.UnknownRenames.Value)
{
Log("unknown_entities", $"{((FixedString64Bytes)(ref val3.CharacterName)).Value} renamed something to \"{val2.NewName}\"\n");
}
}
}
private static void Log(string fileName, string messsage)
{
if (!Settings.RenamesSingleFile.Value)
{
Logger.Record("Renames", fileName, messsage);
}
else
{
Logger.Record("Renames", "renames", messsage);
}
}
}
[HarmonyPatch(typeof(MoveItemBetweenInventoriesSystem), "OnUpdate")]
internal class MoveItemBetweenInventoriesSystemPatch
{
public static void Prefix(MoveItemBetweenInventoriesSystem __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_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_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_0041: 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_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_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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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_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_0134: 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_009b: 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_00a7: 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_00b3: 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_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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_00c1: 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_0154: 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_0107: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: 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_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: 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_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: 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_02a8: 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_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
EntityQuery moveItemBetweenInventoriesEventQuery = __instance._MoveItemBetweenInventoriesEventQuery;
NativeArray<Entity> val = ((EntityQuery)(ref moveItemBetweenInventoriesEventQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
Enumerator<Entity> enumerator = val.GetEnumerator();
InventoryInstanceElement val6 = default(InventoryInstanceElement);
DynamicBuffer<InventoryBuffer> val7 = default(DynamicBuffer<InventoryBuffer>);
InventoryBuffer item = default(InventoryBuffer);
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
User val2 = EntityUtil.Read<User>(EntityUtil.Read<FromCharacter>(current).User);
MoveItemBetweenInventoriesEvent val3 = EntityUtil.Read<MoveItemBetweenInventoriesEvent>(current);
Entity val4 = Entity.Null;
Entity val5 = Entity.Null;
bool flag = false;
bool flag2 = false;
if (((NetworkId)(ref val3.FromInventory)).Equals(val3.ToInventory))
{
continue;
}
NativeArray<Entity> entitiesByComponentTypes = EntityUtil.GetEntitiesByComponentTypes<NetworkId, CastleWorkstation>(false, false, false, false, false);
Enumerator<Entity> enumerator2 = entitiesByComponentTypes.GetEnumerator();
while (enumerator2.MoveNext())
{
Entity current2 = enumerator2.Current;
if (EntityUtil.Exists(current2))
{
if (((Entity)(ref val4)).Equals(Entity.Null) && val3.FromInventory.Normal_Index == EntityUtil.Read<NetworkId>(current2).Normal_Index)
{
val4 = current2;
flag = false;
}
if (((Entity)(ref val5)).Equals(Entity.Null) && val3.ToInventory.Normal_Index == EntityUtil.Read<NetworkId>(current2).Normal_Index)
{
val5 = current2;
flag2 = false;
}
if (!((Entity)(ref val4)).Equals(Entity.Null) && !((Entity)(ref val5)).Equals(Entity.Null))
{
break;
}
}
}
entitiesByComponentTypes.Dispose();
NativeArray<Entity> entitiesByComponentTypes2 = EntityUtil.GetEntitiesByComponentTypes<NetworkId, PlayerCharacter>(false, false, false, false, false);
enumerator2 = entitiesByComponentTypes2.GetEnumerator();
while (enumerator2.MoveNext())
{
Entity current3 = enumerator2.Current;
if (EntityUtil.Exists(current3))
{
if (((Entity)(ref val5)).Equals(Entity.Null) && val3.ToInventory.Normal_Index == EntityUtil.Read<NetworkId>(current3).Normal_Index)
{
val5 = current3;
flag2 = true;
}
if (((Entity)(ref val4)).Equals(Entity.Null) && val3.FromInventory.Normal_Index == EntityUtil.Read<NetworkId>(current3).Normal_Index)
{
val4 = current3;
flag = true;
}
if (!((Entity)(ref val4)).Equals(Entity.Null) && !((Entity)(ref val5)).Equals(Entity.Null))
{
break;
}
}
}
entitiesByComponentTypes2.Dispose();
if (((Entity)(ref val4)).Equals(Entity.Null) || ((Entity)(ref val5)).Equals(Entity.Null) || !EntityUtil.Has<CastleWorkstation>(val4))
{
continue;
}
PrefabGUID containerGuid = default(PrefabGUID);
if (!EntityUtil.TryGetComponent<PrefabGUID>(val4, ref containerGuid) || !EntityUtil.TryGetComponent<InventoryInstanceElement>(val4, ref val6) || !GetInventoryResponse.op_Implicit(InventoryUtilitiesServer.TryGetInventoryBuffer(Core.EntityManager, val4, ref val7)) || !InventoryUtilities.TryGetItemAtSlot(val7, val3.FromSlot, ref item))
{
continue;
}
CastleHeart castleHeart = EntityUtil.Read<CastleHeart>(EntityUtil.Read<CastleHeartConnection>(val4).CastleHeartEntity._Entity);
User val8 = val2;
if (!EntityUtil.Has<UserOwner>(val4))
{
continue;
}
UserOwner val9 = EntityUtil.Read<UserOwner>(val4);
if (EntityUtil.Exists(val9.Owner._Entity))
{
val8 = EntityUtil.Read<User>(val9.Owner._Entity);
}
bool flag3 = val8 == val2;
if (flag3 && !Settings.LootingDecayedCastle.Value)
{
return;
}
bool flag4 = false;
if (!((Entity)(ref val2.ClanEntity._Entity)).Equals(Entity.Null) && !((Entity)(ref val8.ClanEntity._Entity)).Equals(Entity.Null) && ((Entity)(ref val8.ClanEntity._Entity)).Equals(val2.ClanEntity._Entity))
{
flag4 = true;
}
if (flag4)
{
continue;
}
Player looter = PlayerService.PlayerFromUser(val2);
Player looted = PlayerService.PlayerFromUser(val8);
if (!(flag && flag2) && (flag || flag2))
{
if (flag2)
{
Looting.Looted(item, containerGuid, flag4, flag3, castleHeart, looter, looted);
}
else
{
Looting.Placed(item, containerGuid, flag4, flag3, castleHeart, looter, looted);
}
}
}
val.Dispose();
}
}
[HarmonyPatch(typeof(MoveAllItemsBetweenInventoriesSystem), "OnUpdate")]
internal class MoveAllItemsBetweenInventoriesV2Patch
{
public static void Prefix(MoveAllItemsBetweenInventoriesSystem __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_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_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_0041: 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_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_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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: 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_00df: 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_00be: 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_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: 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_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: 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_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
EntityQuery eventQuery = __instance._EventQuery;
NativeArray<Entity> val = ((EntityQuery)(ref eventQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
Enumerator<Entity> enumerator = val.GetEnumerator();
InventoryInstanceElement val6 = default(InventoryInstanceElement);
DynamicBuffer<InventoryBuffer> val7 = default(DynamicBuffer<InventoryBuffer>);
InventoryBuffer item = default(InventoryBuffer);
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
User val2 = EntityUtil.Read<User>(EntityUtil.Read<FromCharacter>(current).User);
MoveAllItemsBetweenInventoriesEvent val3 = EntityUtil.Read<MoveAllItemsBetweenInventoriesEvent>(current);
Entity val4 = Entity.Null;
Entity val5 = Entity.Null;
bool flag = false;
bool flag2 = false;
if (((NetworkId)(ref val3.FromInventory)).Equals(val3.ToInventory))
{
continue;
}
NativeArray<Entity> entitiesByComponentTypes = EntityUtil.GetEntitiesByComponentTypes<NetworkId, CastleWorkstation>(false, false, false, false, false);
Enumerator<Entity> enumerator2 = entitiesByComponentTypes.GetEnumerator();
while (enumerator2.MoveNext())
{
Entity current2 = enumerator2.Current;
if (EntityUtil.Exists(current2))
{
if (((Entity)(ref val4)).Equals(Entity.Null) && val3.FromInventory.Normal_Index == EntityUtil.Read<NetworkId>(current2).Normal_Index)
{
val4 = current2;
flag = false;
}
if (((Entity)(ref val5)).Equals(Entity.Null) && val3.ToInventory.Normal_Index == EntityUtil.Read<NetworkId>(current2).Normal_Index)
{
val5 = current2;
flag2 = false;
}
}
}
entitiesByComponentTypes.Dispose();
NativeArray<Entity> entitiesByComponentTypes2 = EntityUtil.GetEntitiesByComponentTypes<NetworkId, PlayerCharacter>(false, false, false, false, false);
enumerator2 = entitiesByComponentTypes2.GetEnumerator();
while (enumerator2.MoveNext())
{
Entity current3 = enumerator2.Current;
if (EntityUtil.Exists(current3))
{
if (((Entity)(ref val5)).Equals(Entity.Null) && val3.ToInventory.Normal_Index == EntityUtil.Read<NetworkId>(current3).Normal_Index)
{
val5 = current3;
flag2 = true;
}
if (((Entity)(ref val4)).Equals(Entity.Null) && val3.FromInventory.Normal_Index == EntityUtil.Read<NetworkId>(current3).Normal_Index)
{
val4 = current3;
flag = true;
}
}
}
entitiesByComponentTypes2.Dispose();
if (((Entity)(ref val4)).Equals(Entity.Null) || ((Entity)(ref val5)).Equals(Entity.Null))
{
continue;
}
PrefabGUID containerGuid = default(PrefabGUID);
if (!EntityUtil.TryGetComponent<PrefabGUID>(val4, ref containerGuid) || !EntityUtil.TryGetComponent<InventoryInstanceElement>(val4, ref val6) || !GetInventoryResponse.op_Implicit(InventoryUtilitiesServer.TryGetInventoryBuffer(Core.EntityManager, val4, ref val7)))
{
continue;
}
CastleHeart castleHeart = EntityUtil.Read<CastleHeart>(EntityUtil.Read<CastleHeartConnection>(val4).CastleHeartEntity._Entity);
User val8 = val2;
if (!EntityUtil.Has<UserOwner>(val4))
{
continue;
}
UserOwner val9 = EntityUtil.Read<UserOwner>(val4);
if (EntityUtil.Exists(val9.Owner._Entity))
{
val8 = EntityUtil.Read<User>(val9.Owner._Entity);
}
bool flag3 = val8 == val2;
if (flag3 && !Settings.LootingDecayedCastle.Value)
{
return;
}
bool flag4 = false;
if (!((Entity)(ref val2.ClanEntity._Entity)).Equals(Entity.Null) && !((Entity)(ref val8.ClanEntity._Entity)).Equals(Entity.Null) && ((Entity)(ref val8.ClanEntity._Entity)).Equals(val2.ClanEntity._Entity))
{
flag4 = true;
}
if (flag4)
{
continue;
}
Player looter = PlayerService.PlayerFromUser(val2);
Player looted = PlayerService.PlayerFromUser(val8);
if ((flag && flag2) || (!flag && !flag2))
{
continue;
}
for (int i = 0; i < val7.Length; i++)
{
if (InventoryUtilities.TryGetItemAtSlot(val7, i, ref item))
{
if (flag2)
{
Looting.Looted(item, containerGuid, flag4, flag3, castleHeart, looter, looted);
}
else
{
Looting.Placed(item, containerGuid, flag4, flag3, castleHeart, looter, looted);
}
}
}
}
val.Dispose();
}
}
[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_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_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) || val2.Item._Value != 862477668 || !Settings.BloodTransfer.Value)
{
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");
}
}
}
catch
{
}
val.Dispose();
}
}
}