Decompiled source of CrimsonRaidGuard v0.1.11
CrimsonRaidGuard.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.Json; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CrimsonRaidGuard.Commands; using CrimsonRaidGuard.Guards; using CrimsonRaidGuard.Services; using CrimsonRaidGuard.Structs; using CrimsonRaidGuard.Utility; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.Scripting; using ProjectM.Shared; using Stunlock.Core; using Stunlock.Network; using Unity.Collections; using Unity.Entities; using UnityEngine; using VAMP; using VAMP.Attributes; using VAMP.Data; using VAMP.Models; using VAMP.Services; using VAMP.Utilities; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("CrimsonRaidGuard")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.11.0")] [assembly: AssemblyInformationalVersion("0.1.11+2.Branch.master.Sha.e5d27a65eaf6edeb4330ee027eb7dbc8ae9b9644.e5d27a65eaf6edeb4330ee027eb7dbc8ae9b9644")] [assembly: AssemblyProduct("CrimsonRaidGuard")] [assembly: AssemblyTitle("CrimsonRaidGuard")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.11.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CrimsonRaidGuard { [BepInPlugin("CrimsonRaidGuard", "CrimsonRaidGuard", "0.1.11")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BasePlugin { private Harmony _harmony; public static readonly string ConfigFiles = Path.Combine(Paths.ConfigPath, "CrimsonRaidGuard"); 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 Database Database { get; internal set; } public static bool UsingCL { get; private set; } = false; public static bool UsingAlliance { get; private set; } = false; public static DateTime ServerBootTime { get; private set; } public static Type AllianceAPI { get { if (!UsingAlliance) { return null; } return ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins["CrimsonAlliance"].Instance.GetType().Assembly.GetType("CrimsonAlliance.API"); } } public override void Load() { Instance = this; Settings = default(Settings); foreach (KeyValuePair<string, PluginInfo> plugin in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins) { BepInPlugin metadata = plugin.Value.Metadata; if (metadata.GUID.Equals("CrimsonLog")) { UsingCL = true; } if (metadata.GUID.Equals("CrimsonAlliance")) { UsingAlliance = true; } } if (Settings.InitConfig()) { _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); CommandRegistry.RegisterCommandType(typeof(RaidCommands)); if (Settings.ToggleOptOut.Value) { CommandRegistry.RegisterCommandType(typeof(OptCommands)); } if (Settings.CancelGuard.Value) { CommandRegistry.RegisterCommandType(typeof(CancelCommand)); } if (Settings.OfflineGuard.Value) { CommandRegistry.RegisterCommandType(typeof(SafeLogoutCommands)); } Events.OnCoreLoaded = (Action)Delegate.Combine(Events.OnCoreLoaded, new Action(Loaded)); } } public void Loaded() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown ServerBootTime = DateTime.Now; Database = new Database(); ManualLogSource logInstance = LogInstance; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrimsonRaidGuard"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.11"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] loaded!"); } logInstance.LogInfo(val); } public override bool Unload() { ((BasePlugin)this).Config.Clear(); _harmony.UnpatchSelf(); return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "CrimsonRaidGuard"; public const string PLUGIN_NAME = "CrimsonRaidGuard"; public const string PLUGIN_VERSION = "0.1.11"; } } namespace CrimsonRaidGuard.Utility { public static class GuardUtils { public static bool IsGolemAttacker(Entity attacker) { //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) return BuffUtil.HasBuff(attacker, Prefabs.AB_Shapeshift_Golem_T02_Buff); } public static bool IsHeartConnected(Entity attacked, out Entity castleHeartEntity) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) castleHeartEntity = Entity.Null; if (!EntityUtil.Exists(attacked)) { return false; } CastleHeartConnection val = default(CastleHeartConnection); if (EntityUtil.TryGetComponent<CastleHeartConnection>(attacked, ref val)) { if (((Entity)(ref val.CastleHeartEntity._Entity)).Equals(Entity.Null)) { return false; } castleHeartEntity = val.CastleHeartEntity._Entity; return true; } return false; } } } namespace CrimsonRaidGuard.Structs { public class ActiveList { public Entity PrimaryClan { get; private set; } public List<Entity> Entities { get; private set; } public ActiveList(Entity entity, EntityManager manager) { //IL_0012: 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) Entities = new List<Entity>(); InitializePrimaryClan(entity, manager); } private void InitializePrimaryClan(Entity entity, EntityManager manager) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) User val = EntityUtil.Read<User>(entity); Entity validClanEntity = GetValidClanEntity(val.ClanEntity._Entity, manager); if (validClanEntity != Entity.Null) { PrimaryClan = validClanEntity; } } private Entity GetValidClanEntity(Entity clanEntity, EntityManager manager) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!((EntityManager)(ref manager)).Exists(clanEntity)) { return Entity.Null; } return clanEntity; } public bool Contains(Entity entity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Entities.Contains(entity); } public int Add(Entity entity, EntityManager manager) { //IL_0006: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_003f: Unknown result type (might be due to invalid IL or missing references) if (Entities.Contains(entity)) { return 0; } if (Entities.Count == 0) { Entities.Add(entity); return 1; } if (PrimaryClan != Entity.Null) { if (!AddToClanBasedList(entity, manager)) { return -1; } return 1; } Entities.Add(entity); EnforceLimitIfNeeded(); if (!Contains(entity)) { return -1; } return 1; } private bool AddToClanBasedList(Entity entity, EntityManager manager) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0030: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) User val = EntityUtil.Read<User>(entity); Entity validClanEntity = GetValidClanEntity(val.ClanEntity._Entity, manager); if (validClanEntity == Entity.Null) { return false; } if (Settings.Alliances && validClanEntity == PrimaryClan && Settings.LockClanPriority.Value) { AddToPrimaryClan(entity); } else { Entities.Add(entity); } EnforceLimitIfNeeded(); return Contains(entity); } private void AddToPrimaryClan(Entity entity) { //IL_0000: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) ClanRole val = default(ClanRole); if (EntityUtil.TryGetComponent<ClanRole>(entity, ref val) && (int)val.Value == 2) { Entities.Insert(0, entity); } else if (Entities.Count > 0 && IsFirstEntityClanLeader()) { Entities.Insert(1, entity); } else { Entities.Insert(0, entity); } } private bool IsFirstEntityClanLeader() { //IL_0006: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 ClanRole val = default(ClanRole); if (EntityUtil.TryGetComponent<ClanRole>(Entities.First(), ref val)) { return (int)val.Value == 2; } return false; } private void EnforceLimitIfNeeded() { if (Settings.Alliances && Settings.LimitAssists.Value && Entities.Count > Settings.AllianceAssists.Value) { int value = Settings.AllianceAssists.Value; Entities.RemoveRange(value, Entities.Count - value); } } public void Remove(Entity entity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Entities.Remove(entity); } public override string ToString() { return string.Join(", ", Entities.Select(delegate(Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) User val = EntityUtil.Read<User>(entity); return ((FixedString64Bytes)(ref val.CharacterName)).Value; })); } } public class Database { [FileReload("LoadHandicaps")] public static string ShardHandicapFile = Path.Combine(Plugin.ConfigFiles, "shard_handicaps.json"); public static string OptOutFile = Path.Combine(FilePaths.WipeData, "craidguard_optedout.json"); public static List<ShardHandicap> ShardHandicaps; public static List<OptedOut> OptedOut; public Database() { LoadHandicaps(); LoadOptedOut(); } private static void LoadOptedOut() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if (File.Exists(OptOutFile)) { try { OptedOut = JsonSerializer.Deserialize<List<OptedOut>>(File.ReadAllText(OptOutFile)); return; } catch { ManualLogSource logInstance = Plugin.LogInstance; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error loading "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(OptOutFile); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", please verify your json file."); } logInstance.LogError(val); OptedOut = new List<OptedOut>(); return; } } OptedOut = new List<OptedOut>(); SaveOptedOut(); } public static void SaveOptedOut() { if (Settings.OptOutPersistance.Value) { File.WriteAllText(OptOutFile, JsonSerializer.Serialize(OptedOut)); } } private static void LoadHandicaps() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown if (File.Exists(ShardHandicapFile)) { try { ShardHandicaps = JsonSerializer.Deserialize<List<ShardHandicap>>(File.ReadAllText(ShardHandicapFile), JsonUtil.PrettyJsonOptions); return; } catch { ShardHandicaps = new List<ShardHandicap>(6) { new ShardHandicap(0, 1), new ShardHandicap(1, 1), new ShardHandicap(2, 1), new ShardHandicap(3, 1), new ShardHandicap(4, 1), new ShardHandicap(5, 1) }; ManualLogSource logInstance = Plugin.LogInstance; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(99, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error loading shard_handicaps.json, please verify your json file. Setting all Shard Handicaps to 1."); } logInstance.LogError(val); return; } } ShardHandicaps = new List<ShardHandicap>(6) { new ShardHandicap(0, 1), new ShardHandicap(1, 2), new ShardHandicap(2, 3), new ShardHandicap(3, 4), new ShardHandicap(4, 5), new ShardHandicap(5, 128) }; string text = "Shard Handicap allows multiple attacking raid parties to siege a castle based on " + Environment.NewLine + "the number of shards owned by the attacker." + Environment.NewLine + "For example with default settings if you own 2 shards than up to 3 raid parties can attack the castle." + Environment.NewLine + "Note: Saved changes will immediately take effect for new raids, but will not affect existing raids. No server restart is required."; File.WriteAllText(ShardHandicapFile, JsonUtil.SerializeWithComments<List<ShardHandicap>>(ShardHandicaps, text, JsonUtil.PrettyJsonOptions)); } } public class OptedOut { public ulong Steamid { get; set; } public DateTime Until { get; set; } public OptedOut(ulong steamid, DateTime until) { Steamid = steamid; Until = until; } } [StructLayout(LayoutKind.Sequential, Size = 1)] public readonly struct Settings { private static readonly List<string> OrderedSections = new List<string> { "Config", "ThirdParty", "GolemGuard", "OfflineGuard", "ShardHandicap", "OptOut", "SafeLogout", "Alliance" }; private static readonly List<string> directoryPaths = new List<string> { Plugin.ConfigFiles ?? Path.Combine(Paths.ConfigPath, "CrimsonRaidGuard") }; public static ConfigEntry<bool> ToggleMod { get; private set; } public static ConfigEntry<bool> RaidGuard { get; private set; } public static ConfigEntry<bool> LockParticipants { get; private set; } public static bool Alliances => Plugin.UsingAlliance; public static ConfigEntry<bool> LimitAssists { get; private set; } public static ConfigEntry<bool> FriendlyFireRaid { get; private set; } public static ConfigEntry<bool> FriendlyFireWorld { get; private set; } public static ConfigEntry<int> AllianceAssists { get; private set; } public static ConfigEntry<bool> LockClanPriority { get; private set; } public static ConfigEntry<bool> BlockOutsideDamage { get; private set; } public static ConfigEntry<bool> BurnOutsideAttackers { get; private set; } public static ConfigEntry<bool> HuntBurnedAttackers { get; private set; } public static ConfigEntry<bool> AutoKillRats { get; private set; } public static ConfigEntry<bool> AutoKillOutsiders { get; private set; } public static ConfigEntry<bool> ProtectionOffPlot { get; private set; } public static ConfigEntry<bool> GolemGuard { get; private set; } public static ConfigEntry<int> GolemEntryProtection { get; private set; } public static ConfigEntry<int> GolemHitAttackProtection { get; private set; } public static ConfigEntry<int> GolemHitBreachedProtection { get; private set; } public static ConfigEntry<bool> OfflineGuard { get; private set; } public static ConfigEntry<bool> FactorAllies { get; private set; } public static ConfigEntry<int> MaxAllyCacheAge { get; private set; } public static ConfigEntry<int> ExpireOfflineGuard { get; private set; } public static ConfigEntry<bool> ShardHandicaps { get; private set; } public static ConfigEntry<bool> OnPlotJoining { get; private set; } public static ConfigEntry<bool> OnDamageJoining { get; private set; } public static ConfigEntry<bool> DefenderPlotRequired { get; private set; } public static ConfigEntry<bool> ToggleOptOut { get; private set; } public static ConfigEntry<bool> OptOutPersistance { get; private set; } public static ConfigEntry<bool> CancelGuard { get; private set; } public static ConfigEntry<bool> SafeLogout { get; private set; } public static ConfigEntry<int> TimeUntilSafe { get; private set; } public static ConfigEntry<int> AFKCancel { get; private set; } public bool InitConfig() { foreach (string directoryPath in directoryPaths) { CreateDirectories(directoryPath); } ToggleMod = InitConfigEntry(OrderedSections[0], "ToggleMod", defaultValue: true, "Enable or disable the mod."); RaidGuard = InitConfigEntry(OrderedSections[0], "RaidGuard", defaultValue: true, "Enable or disable the prevention of raid interference (only territory clan members and raiding clan members are allowed in territory for duration of the raid once breach by raiders is detected)."); LockParticipants = InitConfigEntry(OrderedSections[0], "LockParticipants", defaultValue: true, "If this is true, leaving the territory will not remove clan or ally members from the raid, meaning rotation of alliance members is not allowed."); BlockOutsideDamage = InitConfigEntry(OrderedSections[1], "BlockThirdPartyDamage", defaultValue: true, "If set to true, third parties and raid participants are unable to hurt each other."); BurnOutsideAttackers = InitConfigEntry(OrderedSections[1], "BurnThirdParties", defaultValue: false, "If set to true, applies the burn and anti-heal debuffs to third parties."); HuntBurnedAttackers = InitConfigEntry(OrderedSections[1], "KillBurned", defaultValue: false, "If set to true, burning third parties or intruders can be killed by active raid participants."); AutoKillRats = InitConfigEntry(OrderedSections[1], "AutoKillIntruders", defaultValue: false, "If this is true, if third parties are burning on plot they will automatically die at 10 or less hp."); AutoKillOutsiders = InitConfigEntry(OrderedSections[1], "AutoKillInterference", defaultValue: false, "If this is true, third parties will automatically die at 10 or less hp when attacking raid participants."); ProtectionOffPlot = InitConfigEntry(OrderedSections[1], "ProtectionOffPlot", defaultValue: false, "If this is true, raid participants will be protected from damage off plot."); GolemGuard = InitConfigEntry(OrderedSections[2], "GolemGuard", defaultValue: true, "Enable or disable the protections granted to golems off-plot from a raid."); GolemEntryProtection = InitConfigEntry(OrderedSections[2], "GolemEntryProtection", 30, "Time of protection upon entering a summoned golem from anyone."); GolemHitAttackProtection = InitConfigEntry(OrderedSections[2], "GolemHitAttackProtection", 15, "Time of protection given per hit of a castle (pre-breach) from third party attacks."); GolemHitBreachedProtection = InitConfigEntry(OrderedSections[2], "GolemHitBreachedProtection", 30, "Time of protection given per hit of a castle (post-breach) from third party attacks."); OfflineGuard = InitConfigEntry(OrderedSections[3], "OfflineGuard", defaultValue: false, "Enable or disable the protections for offline raids."); FactorAllies = InitConfigEntry(OrderedSections[3], "FactorClanMembers", defaultValue: false, "Should clan members being online be considered for offline check of a raid."); MaxAllyCacheAge = InitConfigEntry(OrderedSections[3], "TimeToVerifyOffline", 300, "Set this for the amount of time (in seconds) since logging off to be considered \"offline\". Stops players from logging off when being breached."); ExpireOfflineGuard = InitConfigEntry(OrderedSections[3], "ExpireOfflineGuard", 2880, "The amount of time (in minutes) since last login until offline guard will cease to protect the castle."); ShardHandicaps = InitConfigEntry(OrderedSections[4], "ShardHandicaps", defaultValue: false, "If set to true, shard handicaps will be enforced during raids allowing multiple raid parties on shard owning clans."); OnPlotJoining = InitConfigEntry(OrderedSections[4], "OnPlotJoining", defaultValue: true, "If set to true, walking onto the plot of a raid will attempt joining the raid."); OnDamageJoining = InitConfigEntry(OrderedSections[4], "OnDamageJoining", defaultValue: true, "If set to true, damaging the castle or an active defender will attempt joining the raid."); DefenderPlotRequired = InitConfigEntry(OrderedSections[4], "DefenderPlotRequired", defaultValue: true, "If set to true, the defender must be on the plot to join the raid via OnDamageJoining."); ToggleOptOut = InitConfigEntry(OrderedSections[5], "ToggleOptOut", defaultValue: false, "If set to true, players can opt out of the Raid Guard system."); OptOutPersistance = InitConfigEntry(OrderedSections[5], "OptOutPersistance", defaultValue: false, "If set to true, the opt-out status will be persisted between server reboots."); CancelGuard = InitConfigEntry(OrderedSections[5], "CancelGuard", defaultValue: false, "If set to true, players can cancel an ongoing raid guard on their castle."); SafeLogout = InitConfigEntry(OrderedSections[5], "SafeLogout", defaultValue: false, "If set to true, players will need to enter coffin for a set period of time to get protection."); TimeUntilSafe = InitConfigEntry(OrderedSections[5], "TimeUntilSafe", 300, "The amount of time (in seconds) since entering coffin to be considered \"offline protected\"."); AFKCancel = InitConfigEntry(OrderedSections[5], "AFKCancel", 120, "The amount of time (in seconds) past TimeUntilSafe to lose \"offline protected\" for not logging out."); if (Plugin.UsingAlliance && Plugin.AllianceAPI != null) { LimitAssists = InitConfigEntry(OrderedSections[7], "LimitAssists", defaultValue: false, "True to limit the number of assists during a raid (see below config option for how many allowed if this is set to true)."); FriendlyFireRaid = InitConfigEntry(OrderedSections[7], "FriendlyFireRaid", defaultValue: true, "False to prevent damage between players in alliances during raids, true to allow."); FriendlyFireWorld = InitConfigEntry(OrderedSections[7], "FriendlyFireWorld", defaultValue: true, "False to prevent damage between players in alliance outside of raids, true to allow."); AllianceAssists = InitConfigEntry(OrderedSections[7], "AllianceAssists", 4, "The maximum number of alliance members that can enter a raided territory to assist (this number includes members of the territory-owning clan that are on the territory during the raid)."); LockClanPriority = InitConfigEntry(OrderedSections[7], "LockClanPriority", defaultValue: false, "If set to true, clan members can replace alliance members while LockParticipants is active."); if (Plugin.UsingAlliance && Plugin.AllianceAPI != null) { Plugin.AllianceAPI.GetMethod("OverrideFriendlyFire")?.Invoke(null, null); } } ReorderConfigSections(); return ToggleMod.Value; } private static ConfigEntry<T> InitConfigEntry<T>(string section, string key, T defaultValue, string description) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<T> val = ((BasePlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, description); string text = Path.Combine(Paths.ConfigPath, "CrimsonRaidGuard.cfg"); ConfigEntry<T> val2 = default(ConfigEntry<T>); if (File.Exists(text) && new ConfigFile(text, true).TryGetEntry<T>(section, key, ref val2)) { val.Value = val2.Value; } return val; } private static void CreateDirectories(string path) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } private static void ReorderConfigSections() { string path = Path.Combine(Paths.ConfigPath, "CrimsonRaidGuard.cfg"); if (!File.Exists(path)) { return; } List<string> list = File.ReadAllLines(path).ToList(); Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>(); string text = ""; foreach (string item in list) { if (item.StartsWith("[")) { text = item.Trim('[', ']'); dictionary[text] = new List<string> { item }; } else if (!string.IsNullOrWhiteSpace(text)) { dictionary[text].Add(item); } } using StreamWriter streamWriter = new StreamWriter(path, append: false); foreach (string orderedSection in OrderedSections) { if (!dictionary.ContainsKey(orderedSection)) { continue; } foreach (string item2 in dictionary[orderedSection]) { streamWriter.WriteLine(item2); } streamWriter.WriteLine(); } } } public struct ShardHandicap { public int ShardsOwned { get; set; } public int AllowedRaidParties { get; set; } public ShardHandicap(int shardsOwned, int allowedRaidParties) { ShardsOwned = shardsOwned; AllowedRaidParties = allowedRaidParties; } } public class Warning { public Entity entity; public DateTime lastMessage; public Warning(Entity e) { //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) entity = e; lastMessage = DateTime.Now; } } } namespace CrimsonRaidGuard.Services { internal class GolemService { public static List<GolemTrack> TempProtectedGolems = new List<GolemTrack>(); public static void ProtectGolem(Entity entity, Entity heartOwner, int length) { //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_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_004f: Unknown result type (might be due to invalid IL or missing references) GolemTrack golemTrack = TempProtectedGolems.FirstOrDefault((GolemTrack x) => x.entity == entity); if (golemTrack == null) { golemTrack = new GolemTrack(); golemTrack.entity = entity; golemTrack.protectionUntil = DateTime.Now.AddSeconds(length); golemTrack.defenders = RaidService.GetEntities(heartOwner); TempProtectedGolems.Add(golemTrack); } else { golemTrack.protectionUntil = DateTime.Now.AddSeconds(length); } } public static bool IsProtected(Entity entity, Entity attacker) { //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_0040: Unknown result type (might be due to invalid IL or missing references) GolemTrack golemTrack = TempProtectedGolems.FirstOrDefault((GolemTrack x) => x.entity == entity); if (golemTrack != null && golemTrack.protectionUntil.CompareTo(DateTime.Now) > 0) { if (golemTrack.defenders.Contains(attacker)) { return false; } return true; } return false; } } public class GolemTrack { public Entity entity; public DateTime protectionUntil; public List<Entity> defenders; } public static class Logger { public static void Log(string message, bool console = false) { if (Plugin.UsingCL && !console) { Type type = Type.GetType("CrimsonLog.Systems.Logger, CrimsonLog"); if (type != null) { type.GetMethod("Record").Invoke(null, new object[3] { "RaidGuard", "raids", message + "\n" }); return; } } Plugin.LogInstance.LogInfo((object)message); } } public static class OptOutService { public static void Add(ulong steamid, DateTime until) { if (Database.OptedOut.Exists((OptedOut x) => x.Steamid == steamid)) { Database.OptedOut.FirstOrDefault((OptedOut x) => x.Steamid == steamid).Until = until; } else { Database.OptedOut.Add(new OptedOut(steamid, until)); } Database.SaveOptedOut(); } public static bool Remove(ulong steamid) { OptedOut optedOut = Database.OptedOut.FirstOrDefault((OptedOut x) => x.Steamid == steamid); if (optedOut == null) { return false; } Database.OptedOut.Remove(optedOut); Database.SaveOptedOut(); return true; } public static bool Exists(ulong steamid) { return Database.OptedOut.Exists((OptedOut x) => x.Steamid == steamid); } public static OptedOut Get(ulong steamid) { return Database.OptedOut.FirstOrDefault((OptedOut x) => x.Steamid == steamid); } public static List<OptedOut> GetAll() { return Database.OptedOut; } public static bool IsOptedOut(ulong steamid) { Logger.Log($"Checking opt-out status for SteamID: {steamid}"); if (!Exists(steamid)) { Logger.Log($"SteamID {steamid} not found in opt-out list"); return false; } OptedOut optedOut = Get(steamid); if (optedOut == null) { Logger.Log($"OptedOut record is null for SteamID {steamid}"); return false; } Logger.Log($"SteamID {steamid} opted out until {optedOut.Until}, current time: {DateTime.Now}"); if (DateTime.Now > optedOut.Until) { Logger.Log($"Opt-out expired for SteamID {steamid}, removing from list"); Remove(steamid); return false; } Logger.Log($"SteamID {steamid} is currently opted out"); return true; } public static bool IsOptedOut(Entity userEntity) { //IL_0000: 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_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_0053: 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) if (!EntityUtil.Has<User>(userEntity)) { Logger.Log("Entity does not have User component"); return false; } User val = EntityUtil.Read<User>(userEntity); Logger.Log($"Checking opt-out for user: {((FixedString64Bytes)(ref val.CharacterName)).Value}, SteamID: {val.PlatformId}"); return IsOptedOut(val.PlatformId); } } internal class RaidService { private static readonly bool PlayerAlliances = Settings.Alliances && Plugin.UsingAlliance; private static readonly bool LockParticipants = Settings.LockParticipants.Value; private static readonly PrefabGUID debuff = Prefabs.EH_UnholyChasmEruption_Burn_Debuff; public static Dictionary<Entity, (List<Entity> AllowedAllies, List<Entity> AllowedRaiders, ActiveList ActiveAllies, List<ActiveList> RaidParties, List<GolemTrack> ActiveGolems, int MaxRaidParties)> Participants = new Dictionary<Entity, (List<Entity>, List<Entity>, ActiveList, List<ActiveList>, List<GolemTrack>, int)>(); private static bool active = false; private static List<Warning> Warnings = new List<Warning>(); private static Coroutine raidMonitor; private static EntityManager EntityManager => Core.EntityManager; private static DebugEventsSystem DebugEventsSystem => Core.SystemService.DebugEventsSystem; private static ServerGameManager ServerGameManager => Core.ServerGameManager; public static void StartRaidMonitor(Entity raider, Entity breached) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_016f: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) Entity val = (EntityUtil.Has<CastleHeartConnection>(breached) ? EntityUtil.Read<CastleHeartConnection>(breached).CastleHeartEntity._Entity : Entity.Null); if (((Entity)(ref val)).Equals(Entity.Null)) { Logger.Log("A raid was started... but the heart entity was null. This should never happen. Check the VAMPDumps for Breached_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"); DevUtil.Dump(breached, "Breached_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"); return; } Entity entity = EntityUtil.Read<UserOwner>(val).Owner._Entity; if (OptOutService.IsOptedOut(entity)) { Entity userEntity = EntityUtil.Read<PlayerCharacter>(raider).UserEntity; Logger.Log($"Raid started on {EntityUtil.Read<User>(entity).CharacterName}'s castle, but they have opted out of raid protection."); ChatUtil.SystemSendUser(EntityUtil.Read<User>(userEntity), $"<color=#def>[RaidGuard]</color> {EntityUtil.Read<User>(entity).CharacterName}'s castle has opted out of raid protection."); } else if (!active && raidMonitor == null) { Logger.Log("Starting raid monitor...", console: true); Participants.Clear(); AddRaidParticipants(val, raider, breached); raidMonitor = Core.StartCoroutine(RaidMonitor()); } else if (active) { AddRaidParticipants(val, raider, breached); } } private static void AddRaidParticipants(Entity heartEntity, Entity raider, Entity breached) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //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_0099: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_023d: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_0133: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: 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_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) if (!((Entity)(ref heartEntity)).Equals(Entity.Null)) { Entity entity = EntityUtil.Read<UserOwner>(EntityUtil.Read<CastleHeartConnection>(breached).CastleHeartEntity._Entity).Owner._Entity; if (OptOutService.IsOptedOut(entity)) { Logger.Log($"Attempted to add raid participants for {EntityUtil.Read<User>(entity).CharacterName}'s castle, but they have opted out."); return; } Logger.Log($"Opt-out check passed for {EntityUtil.Read<User>(entity).CharacterName}'s castle - proceeding with raid setup."); Entity userEntity = EntityUtil.Read<PlayerCharacter>(raider).UserEntity; int num = CalculateMaxRaidParties(heartEntity, entity); if (Participants.TryGetValue(heartEntity, out var participants)) { if (participants.RaidParties.Count < participants.MaxRaidParties) { participants.AllowedRaiders.AddRange(from e in GetAllowedRaiders(raider) where !participants.AllowedRaiders.Contains(e) select e); ActiveList item = new ActiveList(userEntity, EntityManager); participants.RaidParties.Add(item); Logger.Log($"Additional raid party started on {EntityUtil.Read<User>(entity).CharacterName}'s Castle by {EntityUtil.Read<User>(userEntity).CharacterName}"); } else { Logger.Log($"Maximum raid parties ({participants.MaxRaidParties}) already reached for {EntityUtil.Read<User>(entity).CharacterName}'s Castle"); } } else if (Participants.TryAdd(heartEntity, (GetAllowedAllies(breached), GetAllowedRaiders(raider), new ActiveList(entity, EntityManager), new List<ActiveList>(), new List<GolemTrack>(), num))) { if (TryAddNewRaiderParty(heartEntity, userEntity)) { Logger.Log($"Raid Started on {EntityUtil.Read<User>(entity).CharacterName}'s Castle by {EntityUtil.Read<User>(userEntity).CharacterName} (Max Raid Parties: {num})"); } else { Logger.Log($"Failed to add original raider party for {EntityUtil.Read<User>(entity).CharacterName}'s Castle. This is a bug and should be reported to skytech6 on Discord."); } } else { Logger.Log("A raid was started... but we failed to add Participants. This should never happen. Check the VAMPDumps for Breached_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"); DevUtil.Dump(breached, "Breached_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"); } } else { Logger.Log("A raid was started... but the heart entity was null. This should never happen. Check the VAMPDumps for Breached_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"); DevUtil.Dump(breached, "Breached_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"); } } private static int CalculateMaxRaidParties(Entity heartEntity, Entity heartOwner) { //IL_0014: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: 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_02b1: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: 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_02c8: 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_02d7: 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_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: 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_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0316: 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_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) if (!Settings.ShardHandicaps.Value) { return 1; } if (!EntityUtil.Exists(heartOwner)) { return Database.ShardHandicaps.Where((ShardHandicap x) => x.ShardsOwned == 0).First().AllowedRaidParties; } if (!EntityUtil.Has<User>(heartOwner)) { return Database.ShardHandicaps.Where((ShardHandicap x) => x.ShardsOwned == 0).First().AllowedRaidParties; } HashSet<Entity> hashSet = new HashSet<Entity>(); User val = EntityUtil.Read<User>(heartOwner); _ = ((FixedString64Bytes)(ref val.CharacterName)).Value; EntityManager entityManager = EntityManager; Entity val2 = (((EntityManager)(ref entityManager)).Exists(val.ClanEntity._Entity) ? val.ClanEntity._Entity : Entity.Null); if (!((Entity)(ref val2)).Equals(Entity.Null)) { DynamicBuffer<SyncToUserBuffer> val3 = EntityUtil.ReadBuffer<SyncToUserBuffer>(val2); for (int num = 0; num < val3.Length; num++) { hashSet.Add(val3[num].UserEntity); } } else { hashSet.Add(heartOwner); } NativeArray<Entity> entitiesByComponentTypes = EntityUtil.GetEntitiesByComponentTypes<ItemData, Relic>(false, false, false, false, false); int ownedShards = 0; Enumerator<Entity> enumerator = entitiesByComponentTypes.GetEnumerator(); PlayerCharacter val4 = default(PlayerCharacter); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!EntityUtil.Exists(current)) { continue; } if (EntityUtil.Has<Equippable>(current)) { Entity entity = EntityUtil.Read<Equippable>(current).EquipTarget._Entity; if (!((Entity)(ref entity)).Equals(Entity.Null) && EntityUtil.Exists(entity) && EntityUtil.Has<PlayerCharacter>(entity) && hashSet.Contains(EntityUtil.Read<PlayerCharacter>(entity).UserEntity)) { ownedShards++; continue; } } if (!EntityUtil.Has<InventoryItem>(current)) { continue; } Entity containerEntity = EntityUtil.Read<InventoryItem>(current).ContainerEntity; if (!((Entity)(ref containerEntity)).Equals(Entity.Null) && EntityUtil.Exists(containerEntity) && EntityUtil.Has<InventoryConnection>(containerEntity)) { Entity inventoryOwner = EntityUtil.Read<InventoryConnection>(containerEntity).InventoryOwner; if (!((Entity)(ref inventoryOwner)).Equals(Entity.Null) && EntityUtil.Exists(inventoryOwner) && EntityUtil.TryGetComponent<PlayerCharacter>(inventoryOwner, ref val4) && hashSet.Contains(val4.UserEntity)) { ownedShards++; } } } entitiesByComponentTypes.Dispose(); NativeArray<Entity> entitiesByComponentTypes2 = EntityUtil.GetEntitiesByComponentTypes<InventoryRouteParent, BlueprintData>(true, true, false, false, false); enumerator = entitiesByComponentTypes2.GetEnumerator(); PrefabGUID val5 = default(PrefabGUID); UserOwner val6 = default(UserOwner); InventoryOwner val7 = default(InventoryOwner); while (enumerator.MoveNext()) { Entity current2 = enumerator.Current; if (EntityUtil.Exists(current2) && EntityUtil.TryGetComponent<PrefabGUID>(current2, ref val5) && EntityUtil.TryGetComponent<UserOwner>(current2, ref val6) && EntityUtil.Exists(val6.Owner._Entity) && hashSet.Contains(val6.Owner._Entity) && EntityUtil.TryGetComponent<InventoryOwner>(current2, ref val7) && val7.HasItems) { if (val5 == Prefabs.TM_Castle_Container_Specialized_Soulshards_Manticore) { ownedShards++; } else if (val5 == Prefabs.TM_Castle_Container_Specialized_Soulshards_Solarus) { ownedShards++; } else if (val5 == Prefabs.TM_Castle_Container_Specialized_Soulshards_Monster) { ownedShards++; } else if (val5 == Prefabs.TM_Castle_Container_Specialized_Soulshards_Morgana) { ownedShards++; } else if (val5 == Prefabs.TM_Castle_Container_Specialized_Soulshards_Dracula) { ownedShards++; } } } entitiesByComponentTypes2.Dispose(); if (ownedShards > 5) { ownedShards = 5; } return Database.ShardHandicaps.Where((ShardHandicap x) => x.ShardsOwned == ownedShards).First().AllowedRaidParties; } private static List<Entity> GetAllowedAllies(Entity breached) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return GetEntities(EntityUtil.Read<UserOwner>(EntityUtil.Read<CastleHeartConnection>(breached).CastleHeartEntity._Entity).Owner._Entity); } private static List<Entity> GetAllowedRaiders(Entity raider) { //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) return GetEntities(EntityUtil.Read<PlayerCharacter>(raider).UserEntity); } private static HashSet<Entity> GetAllowedParticipants(Entity raider, Entity breached) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) HashSet<Entity> hashSet = new HashSet<Entity>(); hashSet.UnionWith(GetEntities(EntityUtil.Read<UserOwner>(EntityUtil.Read<CastleHeartConnection>(breached).CastleHeartEntity._Entity).Owner._Entity)); hashSet.UnionWith(GetEntities(EntityUtil.Read<PlayerCharacter>(raider).UserEntity)); return hashSet; } public static List<Entity> GetEntities(Entity userEntity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0025: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e6: 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_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_015c: 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_017d: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) HashSet<Entity> hashSet = new HashSet<Entity>(); User val = EntityUtil.Read<User>(userEntity); string value = ((FixedString64Bytes)(ref val.CharacterName)).Value; string text = ""; EntityManager entityManager = EntityManager; Entity val2 = (((EntityManager)(ref entityManager)).Exists(val.ClanEntity._Entity) ? val.ClanEntity._Entity : Entity.Null); if (!((Entity)(ref val2)).Equals(Entity.Null)) { string text2 = text; ClanTeam val3 = EntityUtil.Read<ClanTeam>(val2); text = text2 + value + " is a member of " + ((FixedString64Bytes)(ref val3.Name)).Value; DynamicBuffer<SyncToUserBuffer> val4 = EntityUtil.ReadBuffer<SyncToUserBuffer>(val2); for (int i = 0; i < val4.Length; i++) { hashSet.Add(val4[i].UserEntity); } if (PlayerAlliances) { List<string> list = (Plugin.AllianceAPI?.GetMethod("GetAllianceClanNames")?.Invoke(null, new object[1] { val2 }) as List<string>) ?? new List<string>(); if (list != null && list.Count > 0) { foreach (string item in list) { val3 = EntityUtil.Read<ClanTeam>(val2); if (item == ((FixedString64Bytes)(ref val3.Name)).Value) { continue; } Entity val5 = ClanService.GetAllWithName(item).FirstOrDefault(); if (!((Entity)(ref val5)).Equals(Entity.Null)) { Logger.Log(text + " | allied with " + item); val4 = EntityUtil.ReadBuffer<SyncToUserBuffer>(val5); for (int j = 0; j < val4.Length; j++) { hashSet.Add(val4[j].UserEntity); } } } } } } else { text = text + value + " has no allies for this raid."; hashSet.Add(userEntity); } Logger.Log(text); HashSet<Entity> hashSet2 = hashSet; List<Entity> list2 = new List<Entity>(hashSet2.Count); list2.AddRange(hashSet2); return list2; } private static IEnumerator RaidMonitor() { yield return (object)new WaitForSeconds(5f); active = true; yield return null; Logger.Log("Raid Monitor Started", console: true); while (ShouldContinueMonitoring()) { Dictionary<Entity, (List<Entity>, List<Entity>, ActiveList, List<ActiveList>, List<GolemTrack>, int)>.KeyCollection keys = Participants.Keys; List<Entity> list = new List<Entity>(keys.Count); list.AddRange(keys); List<Entity> heartEntities = list; Dictionary<string, Entity> dictionary = (from val in PlayerService.GetUsersOnline() where EntityUtil.Exists(val) && EntityUtil.Has<User>(val) select val).ToDictionary(delegate(Entity val2) { //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) User val = EntityUtil.Read<User>(val2); return ((FixedString64Bytes)(ref val.CharacterName)).Value; }, (Entity result) => result); foreach (KeyValuePair<string, Entity> item in dictionary) { if (!IsPlayerEligibleForCheck(item.Value)) { continue; } Entity value = item.Value; Entity entity = EntityUtil.Read<User>(value).LocalCharacter._Entity; TilePosition pos = EntityUtil.Read<TilePosition>(entity); foreach (Entity item2 in heartEntities) { ProcessHeartEntity(item2, value, entity, pos); } yield return null; } yield return null; } Logger.Log("Stopping monitoring: ShouldContinueMonitoring returned false", console: true); StopMonitoring(); } private static bool ShouldContinueMonitoring() { if (Participants.Keys.Count > 0) { return Settings.RaidGuard.Value; } return false; } private static void StopMonitoring() { active = false; Logger.Log("Stopping raid monitor...", console: true); Core.StopCoroutine(raidMonitor); raidMonitor = null; } private static bool IsPlayerEligibleForCheck(Entity userEntity) { //IL_0000: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!EntityUtil.Exists(userEntity) || !EntityUtil.Has<User>(userEntity)) { return false; } User val = EntityUtil.Read<User>(userEntity); if (val.IsConnected && EntityUtil.Exists(val.LocalCharacter._Entity)) { return EntityUtil.Has<TilePosition>(val.LocalCharacter._Entity); } return false; } private unsafe static void ProcessHeartEntity(Entity heartEntity, Entity userEntity, Entity character, TilePosition pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0010: 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_006f: 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_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_0081: 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_0078: 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_008b: 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) CastleHeart val = EntityUtil.Read<CastleHeart>(heartEntity); if (!((CastleHeart)(ref val)).IsSieged()) { RemoveParticipant(heartEntity); return; } CastleTerritory val2 = default(CastleTerritory); bool territoryCheck = CastleTerritoryExtensions.IsTileInTerritory(EntityManager, pos.Tile, ref val.CastleTerritoryEntity, ref val2); User val3 = EntityUtil.Read<User>(EntityUtil.Read<UserOwner>(heartEntity).Owner._Entity); string defenderHeart = ((object)(*(FixedString64Bytes*)(&val3.CharacterName))/*cast due to .constrained prefix*/).ToString(); if (IsUnauthorizedPresence(heartEntity, userEntity, territoryCheck)) { HandleUnauthorizedPresence(character, userEntity, heartEntity); } else if (IsAuthorizedPresence(heartEntity, userEntity, territoryCheck)) { HandleAuthorizedPresence(heartEntity, userEntity, defenderHeart); } else if (IsLeavingAuthorizedZone(heartEntity, userEntity, territoryCheck)) { HandleLeavingAuthorizedZone(heartEntity, userEntity, defenderHeart); } } private static void RemoveParticipant(Entity heartEntity) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (Participants.Remove(heartEntity)) { Logger.Log($"{EntityUtil.Read<User>(EntityUtil.Read<UserOwner>(heartEntity).Owner._Entity).CharacterName}'s castle is no longer under siege."); } } private static bool IsUnauthorizedPresence(Entity heartEntity, Entity userEntity, bool territoryCheck) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!territoryCheck) { return false; } if (Participants.TryGetValue(heartEntity, out (List<Entity>, List<Entity>, ActiveList, List<ActiveList>, List<GolemTrack>, int) value)) { if (!value.Item1.Contains(userEntity)) { return !value.Item2.Contains(userEntity); } return false; } return false; } private static void HandleUnauthorizedPresence(Entity character, Entity userEntity, Entity heartEntity) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_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_0054: 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_00b6: 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_0094: 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_00a6: 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) if (Settings.OnPlotJoining.Value && TryAddNewRaiderParty(heartEntity, userEntity)) { Logger.Log($"{EntityUtil.Read<User>(userEntity).CharacterName} created a new raid party by trespassing on {EntityUtil.Read<User>(EntityUtil.Read<UserOwner>(heartEntity).Owner._Entity).CharacterName}'s castle"); } else if (IsMaxRaidPartiesReached(heartEntity)) { if (Settings.AutoKillRats.Value && EntityUtil.Has<Health>(character) && EntityUtil.Read<Health>(character).Value <= 10f) { ApplyDebuff(character, userEntity, sendMessage: true, "Actions have consequences.", kill: true); } else { ApplyDebuff(character, userEntity, sendMessage: true, "You are not allowed in this territory during a raid."); } } } private static bool IsAuthorizedPresence(Entity heartEntity, Entity userEntity, bool territoryCheck) { //IL_0008: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (territoryCheck) { if (!Participants[heartEntity].AllowedAllies.Contains(userEntity)) { return Participants[heartEntity].AllowedRaiders.Contains(userEntity); } return true; } return false; } private static void HandleAuthorizedPresence(Entity heartEntity, Entity userEntity, string defenderHeart) { //IL_0005: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (Participants[heartEntity].AllowedAllies.Contains(userEntity)) { HandleAlliedPresence(heartEntity, userEntity, defenderHeart); } else if (Participants[heartEntity].AllowedRaiders.Contains(userEntity)) { HandleRaiderPresence(heartEntity, userEntity, defenderHeart); } } private static void HandleAlliedPresence(Entity heartEntity, Entity userEntity, string defenderHeart) { //IL_0005: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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) if (!Participants[heartEntity].ActiveAllies.Contains(userEntity)) { switch (Participants[heartEntity].ActiveAllies.Add(userEntity, EntityManager)) { case -1: ApplyDebuff(EntityUtil.Read<User>(userEntity).LocalCharacter._Entity, userEntity, sendMessage: true, "You are not allowed in this territory during a raid (maximum raider assists reached)."); break; case 0: Logger.Log($"{EntityUtil.Read<User>(userEntity).CharacterName} re-entered {defenderHeart}'s castle plot."); break; case 1: Logger.Log($"{EntityUtil.Read<User>(userEntity).CharacterName} added to defending raid members on {defenderHeart}'s castle"); break; } } } private static void HandleRaiderPresence(Entity heartEntity, Entity userEntity, string defenderHeart) { //IL_0007: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) bool flag = false; foreach (ActiveList item in Participants[heartEntity].RaidParties) { if (item.Contains(userEntity)) { flag = true; break; } } if (flag) { return; } ActiveList activeList = FindRaidPartyByClanOrAlliance(heartEntity, userEntity); if (activeList != null) { switch (activeList.Add(userEntity, EntityManager)) { case -1: ApplyDebuff(EntityUtil.Read<User>(userEntity).LocalCharacter._Entity, userEntity, sendMessage: true, "You are not allowed in this territory during a raid (maximum raider assists reached)."); break; case 0: Logger.Log($"{EntityUtil.Read<User>(userEntity).CharacterName} re-entered {defenderHeart}'s castle plot."); break; case 1: Logger.Log($"{EntityUtil.Read<User>(userEntity).CharacterName} added to attacking raid members on {defenderHeart}'s castle"); ChatUtil.SystemSendUser(EntityUtil.Read<User>(userEntity), "<color=#def>[RaidGuard]</color> You have joined the raid."); break; } } else { ApplyDebuff(EntityUtil.Read<User>(userEntity).LocalCharacter._Entity, userEntity, sendMessage: true, "You are not allowed to join this raid (no clan or alliance relationship with existing raiders)."); } } private static ActiveList FindRaidPartyByClanOrAlliance(Entity heartEntity, Entity userEntity) { //IL_0000: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0039: 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_01a7: 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_01c2: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_01f9: 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_0224: 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_0246: 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_0092: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_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_00f0: 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_0128: 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_0144: 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) if (!EntityUtil.Exists(userEntity) || !EntityUtil.Has<User>(userEntity)) { return null; } Entity entity = EntityUtil.Read<User>(userEntity).ClanEntity._Entity; if (!((Entity)(ref entity)).Equals(Entity.Null)) { EntityManager entityManager = EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity)) { foreach (ActiveList item in Participants[heartEntity].RaidParties) { foreach (Entity item2 in item.Entities.ToList()) { if (!EntityUtil.Exists(item2) || !EntityUtil.Has<User>(item2)) { continue; } Entity entity2 = EntityUtil.Read<User>(item2).ClanEntity._Entity; if (((Entity)(ref entity2)).Equals(entity)) { return item; } if (!Plugin.UsingAlliance || !Settings.Alliances || ((Entity)(ref entity2)).Equals(Entity.Null)) { continue; } entityManager = EntityManager; if (((EntityManager)(ref entityManager)).Exists(entity2) && EntityUtil.Has<ClanTeam>(entity2)) { List<string> obj = (Plugin.AllianceAPI?.GetMethod("GetAllianceClanNames")?.Invoke(null, new object[1] { entity }) as List<string>) ?? new List<string>(); ClanTeam val = EntityUtil.Read<ClanTeam>(entity2); string value = ((FixedString64Bytes)(ref val.Name)).Value; if (obj.Contains(value)) { return item; } } } } if (Participants[heartEntity].AllowedRaiders.Contains(userEntity) && Participants[heartEntity].RaidParties.Count < Participants[heartEntity].MaxRaidParties) { ActiveList activeList = new ActiveList(userEntity, EntityManager); Participants[heartEntity].RaidParties.Add(activeList); Logger.Log($"Created new raid party for {EntityUtil.Read<User>(userEntity).CharacterName} (Total parties: {Participants[heartEntity].RaidParties.Count}/{Participants[heartEntity].MaxRaidParties})"); return activeList; } return null; } } return null; } private static bool IsLeavingAuthorizedZone(Entity heartEntity, Entity userEntity, bool territoryCheck) { //IL_0008: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!territoryCheck) { if (!Participants[heartEntity].AllowedAllies.Contains(userEntity)) { return Participants[heartEntity].AllowedRaiders.Contains(userEntity); } return true; } return false; } private static void HandleLeavingAuthorizedZone(Entity heartEntity, Entity userEntity, string defenderHeart) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: 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_0082: 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_00c7: 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_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_0127: Unknown result type (might be due to invalid IL or missing references) if (LockParticipants) { return; } if (Participants[heartEntity].ActiveAllies.Contains(userEntity)) { Participants[heartEntity].ActiveAllies.Remove(userEntity); Logger.Log($"{EntityUtil.Read<User>(userEntity).CharacterName} removed from defending raid members on {defenderHeart}'s castle"); ChatUtil.SystemSendUser(EntityUtil.Read<User>(userEntity), "<color=#def>[RaidGuard]</color> You have left the raid."); return; } foreach (ActiveList item in Participants[heartEntity].RaidParties.ToList()) { if (item.Contains(userEntity)) { item.Remove(userEntity); Logger.Log($"{EntityUtil.Read<User>(userEntity).CharacterName} removed from attacking raid members on {defenderHeart}'s castle"); if (item.Entities.Count == 0) { Participants[heartEntity].RaidParties.Remove(item); Logger.Log("Removed empty raid party from " + defenderHeart + "'s castle"); } break; } } } public static void ApplyDebuff(Entity character, Entity userEntity, bool sendMessage, string message, bool kill = false) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0069: 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_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_009f: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00d3: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_028b: 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_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0165: 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_016e: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) message = "<color=#def>[RaidGuard]</color> " + message; ServerGameManager serverGameManager = ServerGameManager; PrefabGUID val = new PrefabGUID(77473184); Entity val2 = default(Entity); if (((ServerGameManager)(ref serverGameManager)).TryGetBuff(character, ((PrefabGUID)(ref val)).ToIdentifier(), ref val2))