Decompiled source of ConVicted v1.0.0
ConVicted.dll
Decompiled a day 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.UI; using Stunlock.Core; using Stunlock.Network; using TMPro; using Unity.Collections; using Unity.Entities; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : System.Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(/*Could not decode attribute arguments.*/)] internal sealed class RefSafetyRulesAttribute : System.Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ConVicted { [BepInPlugin("com.zeeCameLsnake.ConVicted", "ConVicted", "1.0.0")] public class ConVictedPlugin : BasePlugin { public const string PluginGUID = "com.zeeCameLsnake.ConVicted"; public const string PluginName = "ConVicted"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private Harmony _harmony; public override void Load() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown Log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; if (Application.productName == "VRisingServer") { _harmony = new Harmony("com.zeeCameLsnake.ConVicted"); ServerPart.Load((BasePlugin)(object)this, _harmony); ManualLogSource log = Log; val = new BepInExInfoLogInterpolatedStringHandler(43, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ConVicted"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded (server part: target protection)."); } log.LogInfo(val); return; } ConVictedConfig.Bind(((BasePlugin)this).Config); _harmony = new Harmony("com.zeeCameLsnake.ConVicted"); _harmony.PatchAll(typeof(HudPatches)); _harmony.PatchAll(typeof(ClientLink)); ManualLogSource log2 = Log; val = new BepInExInfoLogInterpolatedStringHandler(103, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ConVicted"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded (client part: Blood Hunger HUD, subdue indicator, screen tint, settings for the server part)."); } log2.LogInfo(val); } public override bool Unload() { if (Application.productName != "VRisingServer") { HudBloodHunger.Teardown(); SubdueIndicator.Teardown(); MarkIndicator.Teardown(); ScreenTint.Restore(); } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } internal static class ConVictedConfig { private const string SectionGeneral = "1. General"; private const string SectionHud = "2. Blood Hunger HUD"; private const string SectionTint = "3. Screen Tint"; private const string SectionProtection = "4. Target Protection - shared"; private const string SectionAuto = "5. Protection A - Autopilot by blood quality"; private const string SectionDominate = "6. Protection B - Dominate Human reaction"; private const string SectionMarks = "7. Protection C - Marked targets"; private const string SectionDebug = "8. Debug"; internal static ConfigFile File; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> LiveReload; internal static ConfigEntry<bool> KeepHealthBarsInBloodHunger; internal static ConfigEntry<bool> ShowBloodInfo; internal static ConfigEntry<float> BloodInfoOffsetX; internal static ConfigEntry<float> BloodInfoOffsetY; internal static ConfigEntry<float> BloodInfoScale; internal static ConfigEntry<bool> ShowSubdueIndicator; internal static ConfigEntry<int> SubdueThresholdPercent; internal static ConfigEntry<float> SubdueIconSize; internal static ConfigEntry<float> SubdueIconOffsetX; internal static ConfigEntry<float> SubdueIconOffsetY; internal static ConfigEntry<int> ScreenTintIntensity; internal static ConfigEntry<int> ProtectedHealthPercent; internal static ConfigEntry<bool> EnableAutoBloodProtection; internal static ConfigEntry<int> AutoProtectMinBloodQuality; internal static ConfigEntry<bool> EnableDominateMinionReaction; internal static ConfigEntry<DominateAction> DominateMinionAction; internal static ConfigEntry<DominateTrigger> DominateReactionTrigger; internal static ConfigEntry<bool> EnableManualTargetMark; internal static Hotkey MarkTargetKey; internal static Hotkey ClearAllMarksKey; internal static ConfigEntry<int> MaxMarkedTargets; internal static ConfigEntry<bool> MarkedTargetsImmortal; internal static ConfigEntry<string> MarkIconColor; internal static ConfigEntry<float> MarkIconSize; internal static ConfigEntry<float> MarkIconOffsetX; internal static ConfigEntry<float> MarkIconOffsetY; internal static ConfigEntry<bool> LogDiagnostics; private const float PollSeconds = 0.5f; private static float _nextPoll; private static System.DateTime _loadedWriteTime; private static System.DateTime _pendingWriteTime; private static bool _reloadErrorLogged; internal static void Bind(ConfigFile cfg) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Expected O, but got Unknown //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Expected O, but got Unknown //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Expected O, but got Unknown File = cfg; Enabled = cfg.Bind<bool>("1. General", "Enabled", true, "Master switch. Off: the mod changes nothing and the game behaves like vanilla."); LiveReload = cfg.Bind<bool>("1. General", "LiveReload", true, "Re-reads this config file automatically within about a second after it was saved (e.g. by a mod manager or text editor), so changes show up in-game without a restart."); KeepHealthBarsInBloodHunger = cfg.Bind<bool>("2. Blood Hunger HUD", "KeepHealthBarsInBloodHunger", true, "Vanilla replaces the health bars of enemies with their blood type icon while Blood Hunger is active. On: enemies keep their normal health bar (with level and cast bar) during Blood Hunger; the bar follows the same rules as outside Blood Hunger (for example, some enemies only show it once they are damaged). Off: vanilla behaviour."); ShowBloodInfo = cfg.Bind<bool>("2. Blood Hunger HUD", "ShowBloodInfo", true, "Shows the blood type icon and the blood quality in percent above the health bar during Blood Hunger. Only used while KeepHealthBarsInBloodHunger is on. Off: health bars only, no blood information."); BloodInfoOffsetX = cfg.Bind<float>("2. Blood Hunger HUD", "BloodInfoOffsetX", 0f, new ConfigDescription("Horizontal position of the blood information relative to the enemy's health bar, in HUD pixels. 0 = centered, negative = further left, positive = further right. Example: 40 puts it to the right of the bar's center.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-200f, 200f), System.Array.Empty<object>())); BloodInfoOffsetY = cfg.Bind<float>("2. Blood Hunger HUD", "BloodInfoOffsetY", 11f, new ConfigDescription("Vertical position of the blood information relative to the enemy's health bar, in HUD pixels. Higher = further up. Example: 0 puts it on top of the health bar, 11 puts it just above the bar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-200f, 200f), System.Array.Empty<object>())); BloodInfoScale = cfg.Bind<float>("2. Blood Hunger HUD", "BloodInfoScale", 1.1f, new ConfigDescription("Size of the blood information. 1.1 is close to the size of the vanilla blood icon; 0.55 = half of that, 2.2 = double.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 3f), System.Array.Empty<object>())); ShowSubdueIndicator = cfg.Bind<bool>("2. Blood Hunger HUD", "ShowSubdueIndicator", true, "Shows the Dominating Presence icon at the right end of an enemy's health bar as soon as the enemy can be subdued with Dominate Human, i.e. it is a charmable unit and its health is at or below SubdueThresholdPercent. Works with and without Blood Hunger. If the game's icon cannot be found, a plain violet dot is shown instead."); SubdueThresholdPercent = cfg.Bind<int>("2. Blood Hunger HUD", "SubdueThresholdPercent", 30, new ConfigDescription("Health in percent at or below which the subdue icon appears. 30 is the game's own limit for Dominate Human (and for Feed). Example: 30 = the icon appears when an enemy with 200 max health is at 60 or less.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), System.Array.Empty<object>())); SubdueIconSize = cfg.Bind<float>("2. Blood Hunger HUD", "SubdueIconSize", 30.5f, new ConfigDescription("Size of the subdue icon in HUD pixels. Example: 30.5 is easy to see next to the health bar; 15 = half of that, 61 = double.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 80f), System.Array.Empty<object>())); SubdueIconOffsetX = cfg.Bind<float>("2. Blood Hunger HUD", "SubdueIconOffsetX", 4f, new ConfigDescription("Horizontal distance of the subdue icon from the right end of the health bar, in HUD pixels. 0 = touching the bar's end, positive = further right, negative = moved onto the bar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-200f, 200f), System.Array.Empty<object>())); SubdueIconOffsetY = cfg.Bind<float>("2. Blood Hunger HUD", "SubdueIconOffsetY", 0f, new ConfigDescription("Vertical position of the subdue icon relative to the middle of the health bar, in HUD pixels. 0 = level with the bar, positive = higher.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), System.Array.Empty<object>())); ScreenTintIntensity = cfg.Bind<int>("3. Screen Tint", "ScreenTintIntensity", 25, new ConfigDescription("Strength of the red screen tint (and the color fringes) of Blood Hunger. 100 = vanilla, 0 = no tint at all, 25 = a light tint. This changes only the full-screen effect; the red glow around your own character stays.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), System.Array.Empty<object>())); ProtectedHealthPercent = cfg.Bind<int>("4. Target Protection - shared", "ProtectedHealthPercent", 28, new ConfigDescription("ConVicted has three ways to keep a unit alive until you can subdue it. Each has its own section below, and you can combine them: A (Autopilot) works by itself for every unit with good blood, B (Dominate Human reaction) acts in the moment you use Dominate Human, C (Marked targets) protects exactly the units you pick. This value is shared by A and C: the health in percent that a protected unit cannot be pushed below. Dominate Human works at 30 % health or less. With a value below 30 (default 28) a protected unit is brought into reach for you and stops there. With a value above 30 the unit is left further up and you have to bring it into reach yourself, if you want more control or more of a challenge (with MarkedTargetsImmortal on, a marked unit could then never be subdued, because your own hits stop at this value too). Example: with 28, a unit with 200 max health stays at 56. 100 = protected units take no limited damage at all.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), System.Array.Empty<object>())); EnableAutoBloodProtection = cfg.Bind<bool>("5. Protection A - Autopilot by blood quality", "EnableAutoBloodProtection", true, "The autopilot: needs no action from you. Your minions (skeletons and other summons) cannot push charmable units with at least AutoProtectMinBloodQuality below ProtectedHealthPercent (section 4). They keep hitting such a unit, but their hits no longer take health off it. What it does NOT cover: the unit can still die from your own hits and area spells (including the impact of spells that summon minions), from fire and from other enemies. For that, see section 7. Target protection is done by the server: in solo play and when hosting it needs the ServerLaunchFix mod, on a dedicated server ConVicted must be installed there. Your settings are sent to the server automatically; a server owner can decide to use the server's settings for everyone instead."); AutoProtectMinBloodQuality = cfg.Bind<int>("5. Protection A - Autopilot by blood quality", "AutoProtectMinBloodQuality", 80, new ConfigDescription("Blood quality in percent from which a unit is protected from your minions, as whole numbers like the game shows them. Example: 80 protects every unit shown with 80 % or more and lets your minions kill everything below; 0 protects every charmable unit.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), System.Array.Empty<object>())); EnableDominateMinionReaction = cfg.Bind<bool>("6. Protection B - Dominate Human reaction", "EnableDominateMinionReaction", true, "The manual way, for players who like to decide the moment themselves: nothing is protected until you use Dominate Human; then your minions react at once, so they cannot kill the unit you are about to subdue. What they do is set by DominateMinionAction. Until that moment your minions fight at full strength, so a unit can die before you react (unless A or C protects it). Target protection is done by the server: in solo play and when hosting it needs the ServerLaunchFix mod, on a dedicated server ConVicted must be installed there. Your settings are sent to the server automatically; a server owner can decide to use the server's settings for everyone instead."); DominateMinionAction = cfg.Bind<DominateAction>("6. Protection B - Dominate Human reaction", "DominateMinionAction", DominateAction.KillAllMinions, "KillAllMinions: all your minions die at once. MinionsDealNoDamage: your minions stay alive and keep attacking, which keeps enemies busy, but their hits take no health off charmable units while Dominate Human is in use. They do not stand still or stop attacking; their hits just have no effect."); DominateReactionTrigger = cfg.Bind<DominateTrigger>("6. Protection B - Dominate Human reaction", "DominateReactionTrigger", DominateTrigger.OnDominateStanceActivated, "When the reaction happens. OnDominateStanceActivated: as soon as you enter the Dominating Presence form (for MinionsDealNoDamage: as long as you stay in it). OnSubdueBeamCast: only when you start channeling the subdue beam on a unit (for MinionsDealNoDamage: only while the beam is channeled)."); EnableManualTargetMark = cfg.Bind<bool>("7. Protection C - Marked targets", "EnableManualTargetMark", true, "The targeted way: you pick single units with MarkTargetKey, before or during a fight. Your minions deal no damage at all to a marked unit, whatever its blood quality. They may still attack it, but their hits have no effect; your own damage works as usual. A marked unit shows a shield icon in MarkIconColor at the left end of its health bar. The icon tells you what the mark does: a shield with spikes around it (the Frost Barrier icon) = safe from your minions only, it can still be 'poked' by everything else; a shield inside a closed ring (the Chaos Barrier icon) = protected all around, see MarkedTargetsImmortal. Marks last until the unit dies or you leave the world, or until you remove them (MarkTargetKey on a marked unit, or ClearAllMarksKey for all). Switching this off removes all marks too. Without MarkedTargetsImmortal a marked unit can still die from your own hits, from fire and from other enemies; with it, this is the safest of the three ways. Target protection is done by the server: in solo play and when hosting it needs the ServerLaunchFix mod, on a dedicated server ConVicted must be installed there. Your settings are sent to the server automatically; a server owner can decide to use the server's settings for everyone instead."); MarkTargetKey = Hotkey.Bind(cfg, "7. Protection C - Marked targets", "MarkTargetKey", HotkeyKey.F4, "Marks the charmable unit under your mouse cursor as protected from your minions; pressing it again on the same unit removes the mark."); ClearAllMarksKey = Hotkey.Bind(cfg, "7. Protection C - Marked targets", "ClearAllMarksKey", HotkeyKey.Delete, "Removes all your marks at once, wherever the marked units are; a chat line tells you how many were removed. Useful when marked units are out of reach, e.g. prisoners you already locked away, and still count against MaxMarkedTargets. Example: with MaxMarkedTargets = 2 and two marks on prisoners in your castle, press it once and you can mark two new targets."); MaxMarkedTargets = cfg.Bind<int>("7. Protection C - Marked targets", "MaxMarkedTargets", 2, new ConfigDescription("How many units you can have marked at the same time. When the limit is reached, the mark key marks nothing more and a chat line tells you so; remove a mark (same key on a marked unit), remove all marks with ClearAllMarksKey, or wait until a marked unit has died to mark another. A limit keeps a fight from never ending: with MarkedTargetsImmortal on, marked enemies that fight each other, or a crowd in which you marked everyone, cannot die. Example: 2 = at most two marked units, e.g. one to feed on and one to take home; 1 = only one target at a time; 10 = up to ten.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), System.Array.Empty<object>())); MarkedTargetsImmortal = cfg.Bind<bool>("7. Protection C - Marked targets", "MarkedTargetsImmortal", false, "Makes marked units unkillable in a fight: no combat damage from anyone can push a marked unit below ProtectedHealthPercent (section 4). That covers other enemies, fire and other area damage, other players, and your own hits too (your minions deal no damage to marked units anyway). Example: with ProtectedHealthPercent = 28, a marked unit that walks through fire stops losing health at 28 % and can then be subdued. To kill such a unit, remove its mark first. Off: a mark only protects from your minions. Needs EnableManualTargetMark. The mark icon shows which of the two is in effect: a shield inside a closed ring while this is on, a shield with spikes while it is off. On a server that uses its own settings for everyone, the icon follows the server's rule."); MarkIconColor = cfg.Bind<string>("7. Protection C - Marked targets", "MarkIconColor", "#00FF1A", "Colour of the shield icons on marked units (both kinds), as #RRGGBB. The icon takes over the hue of this colour. A pure, bright colour keeps the icon as vivid as the original; a paler colour makes the whole icon paler, a darker colour makes it darker. Examples: #00FF1A = green (default), #FFC800 = yellow, #0078FF = blue, #FF00B4 = the pink of the original Chaos Barrier icon, #007F0D = dark green."); MarkIconSize = cfg.Bind<float>("7. Protection C - Marked targets", "MarkIconSize", 23.4f, new ConfigDescription("Size of the shield icon on marked units, in HUD pixels. Example: 23.4 looks as big as the subdue icon at 30.5 (the shield fills more of its frame); 47 = double.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 80f), System.Array.Empty<object>())); MarkIconOffsetX = cfg.Bind<float>("7. Protection C - Marked targets", "MarkIconOffsetX", 4f, new ConfigDescription("Horizontal distance of the shield icon from the left end of the health bar, in HUD pixels. 0 = touching the bar's end, positive = further left, negative = moved onto the bar.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-200f, 200f), System.Array.Empty<object>())); MarkIconOffsetY = cfg.Bind<float>("7. Protection C - Marked targets", "MarkIconOffsetY", 0f, new ConfigDescription("Vertical position of the shield icon relative to the middle of the health bar, in HUD pixels. 0 = level with the bar, positive = higher.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), System.Array.Empty<object>())); LogDiagnostics = cfg.Bind<bool>("8. Debug", "LogDiagnostics", false, "Writes extra details to the log files. Only needed when reporting a problem. Details about the HUD and the mark key go to BepInEx/LogOutput.log. This switch is also sent to the server part: it then writes every reduced hit, every Dominate reaction, every mark request, every hit on a marked unit (with its source) and every mark the server drops because the unit died or vanished to the server's log (in solo play and when hosting: BepInEx_Server/LogOutput.log in the same profile folder)."); _loadedWriteTime = WriteTime(); _pendingWriteTime = _loadedWriteTime; } private static System.DateTime WriteTime() { try { string configFilePath = File.ConfigFilePath; return File.Exists(configFilePath) ? File.GetLastWriteTimeUtc(configFilePath) : System.DateTime.MinValue; } catch (System.Exception) { return System.DateTime.MinValue; } } internal static void PollLiveReload() { if (File == null || !LiveReload.Value) { return; } float unscaledTime = Time.unscaledTime; if (unscaledTime < _nextPoll) { return; } _nextPoll = unscaledTime + 0.5f; System.DateTime dateTime = WriteTime(); if (dateTime == System.DateTime.MinValue || dateTime == _loadedWriteTime) { return; } if (dateTime != _pendingWriteTime) { _pendingWriteTime = dateTime; return; } bool saveOnConfigSet = File.SaveOnConfigSet; File.SaveOnConfigSet = false; try { File.Reload(); _loadedWriteTime = WriteTime(); _pendingWriteTime = _loadedWriteTime; _reloadErrorLogged = false; ConVictedPlugin.Log.LogInfo((object)"Config file changed, reloaded (LiveReload)."); } catch (System.Exception ex) { if (!_reloadErrorLogged) { _reloadErrorLogged = true; ConVictedPlugin.Log.LogWarning((object)("Config reload failed, trying again: " + ex.Message)); } } finally { File.SaveOnConfigSet = saveOnConfigSet; } } } public enum DominateAction { KillAllMinions, MinionsDealNoDamage } public enum DominateTrigger { OnDominateStanceActivated, OnSubdueBeamCast } internal static class Protocol { internal const int Version = 5; internal const string Marker = "[[ConVicted]] "; internal const string Hello = "[ConVicted] Target protection is active on this server."; } internal class ProtectionSettings { internal bool AutoProtect = true; internal float MinBloodQuality = 80f; internal float FloorPercent = 28f; internal bool DominateReaction = true; internal DominateAction Action = DominateAction.KillAllMinions; internal DominateTrigger Trigger = DominateTrigger.OnDominateStanceActivated; internal bool MarkedImmortal; internal bool Diagnostics; internal int MaxMarks = 2; private static readonly CultureInfo Inv = CultureInfo.InvariantCulture; internal string ToWire() { string[] obj = new string[11] { "set", 5.ToString((IFormatProvider)(object)Inv), AutoProtect ? "1" : "0", MinBloodQuality.ToString("0.##", (IFormatProvider)(object)Inv), FloorPercent.ToString("0.##", (IFormatProvider)(object)Inv), DominateReaction ? "1" : "0", null, null, null, null, null }; int action = (int)Action; obj[6] = action.ToString((IFormatProvider)(object)Inv); action = (int)Trigger; obj[7] = action.ToString((IFormatProvider)(object)Inv); obj[8] = (MarkedImmortal ? "1" : "0"); obj[9] = (Diagnostics ? "1" : "0"); obj[10] = MaxMarks.ToString((IFormatProvider)(object)Inv); return string.Join(" ", obj); } internal static bool TryParse(string[] parts, out ProtectionSettings settings) { settings = null; if (parts.Length < 8) { return false; } float num = default(float); if (!float.TryParse(parts[3], (NumberStyles)167, (IFormatProvider)(object)Inv, ref num)) { return false; } float num2 = default(float); if (!float.TryParse(parts[4], (NumberStyles)167, (IFormatProvider)(object)Inv, ref num2)) { return false; } int num3 = default(int); if (!int.TryParse(parts[6], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num3)) { return false; } int num4 = default(int); if (!int.TryParse(parts[7], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num4)) { return false; } if (!System.Enum.IsDefined(typeof(DominateAction), (object)num3) || !System.Enum.IsDefined(typeof(DominateTrigger), (object)num4)) { return false; } int num5 = default(int); settings = new ProtectionSettings { AutoProtect = (parts[2] == "1"), MinBloodQuality = Math.Max(0f, Math.Min(100f, num)), FloorPercent = Math.Max(1f, Math.Min(100f, num2)), DominateReaction = (parts[5] == "1"), Action = (DominateAction)num3, Trigger = (DominateTrigger)num4, MarkedImmortal = (parts.Length > 8 && parts[8] == "1"), Diagnostics = (parts.Length > 9 && parts[9] == "1"), MaxMarks = ((parts.Length > 10 && int.TryParse(parts[10], (NumberStyles)7, (IFormatProvider)(object)Inv, ref num5)) ? Math.Max(1, Math.Min(50, num5)) : 2) }; return true; } internal string Describe() { return $"auto protection {(AutoProtect ? "on" : "off")} (blood quality >= {MinBloodQuality.ToString("0.##", (IFormatProvider)(object)Inv)} %, floor {FloorPercent.ToString("0.##", (IFormatProvider)(object)Inv)} % HP), Dominate reaction {(DominateReaction ? "on" : "off")} ({Action}, {Trigger}), marked units immortal {(MarkedImmortal ? "on" : "off")}, at most {MaxMarks} mark(s), diagnostics {(Diagnostics ? "on" : "off")}"; } } [HarmonyPatch] internal static class HudPatches { [HarmonyPatch(typeof(GetCharacterHUDSystem), "OnUpdate")] [HarmonyPostfix] private static void GetPostfix(GetCharacterHUDSystem __instance) { try { ConVictedConfig.PollLiveReload(); HudBloodHunger.RestoreUnitHudTypes(__instance); } catch (System.Exception ex) { HudBloodHunger.LogExceptionOnce("GetPostfix", ex); } try { ScreenTint.Tick(); } catch (System.Exception ex2) { HudBloodHunger.LogExceptionOnce("ScreenTint", ex2); } try { ClientLink.Tick(__instance); } catch (System.Exception ex3) { HudBloodHunger.LogExceptionOnce("ClientLink", ex3); } try { TargetMarks.Tick(__instance); } catch (System.Exception ex4) { HudBloodHunger.LogExceptionOnce("TargetMarks", ex4); } } [HarmonyPatch(typeof(SetCharacterHUDSystem), "OnUpdate")] [HarmonyPostfix] private static void SetPostfix(SetCharacterHUDSystem __instance) { try { HudBloodHunger.UpdateBloodInfo(__instance); } catch (System.Exception ex) { HudBloodHunger.LogExceptionOnce("SetPostfix", ex); } try { SubdueIndicator.Update(__instance); } catch (System.Exception ex2) { HudBloodHunger.LogExceptionOnce("SubdueIndicator", ex2); } try { MarkIndicator.Update(__instance); } catch (System.Exception ex3) { HudBloodHunger.LogExceptionOnce("MarkIndicator", ex3); } } } internal static class HudBloodHunger { private class BloodInfo { public GameObject Root; public RectTransform Rect; public CharacterHUD_BloodComponent Blood; public bool HasData; public int ShownQuality; public int ShownType; } private const int EntityIndexOffset = 0; private const int EntityVersionOffset = 4; private const int LastFrameOffset = 8; private const int PrefabTypeOffset = 112; private static readonly int[] StrideCandidates; private static readonly HashSet<string> LoggedExceptions; private static int _stride; private static bool _strideFailed; private static readonly Dictionary<System.IntPtr, BloodInfo> Infos; private static bool _refreshFailed; private static int _nextPruneFrame; private static ManualLogSource Log => ConVictedPlugin.Log; private static bool FeatureOn => ConVictedConfig.Enabled.Value && ConVictedConfig.KeepHealthBarsInBloodHunger.Value; internal static void LogExceptionOnce(string where, System.Exception ex) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown string text = string.Concat(new string[5] { where, ":", ((MemberInfo)ex.GetType()).Name, ":", ex.Message }); if (LoggedExceptions.Add(text)) { ManualLogSource log = Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(3, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(where); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<System.Exception>(ex); } log.LogError(val); } } internal static void Teardown() { //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) Enumerator<System.IntPtr, BloodInfo> enumerator = Infos.Values.GetEnumerator(); try { while (enumerator.MoveNext()) { BloodInfo current = enumerator.Current; if ((Object)(object)current.Root != (Object)null) { Object.Destroy((Object)(object)current.Root); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } Infos.Clear(); } internal unsafe static void RestoreUnitHudTypes(GetCharacterHUDSystem sys) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_01fc: Invalid comparison between Unknown and I4 //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected I4, but got Unknown if (!FeatureOn || _strideFailed) { return; } NativeArray<Data> entries = sys.Entries; int length = entries.Length; if (length == 0) { return; } int frameCount = Time.frameCount; bool flag = false; for (int i = 0; i < length; i++) { Data val = entries[i]; if (val.LastFrame == frameCount && (int)val.PrefabType == 4) { flag = true; break; } } if (!flag) { return; } byte* buffer = (byte*)entries.m_Buffer; if (buffer == null) { return; } if (_stride == 0) { if (length < 2) { return; } _stride = FindStride(entries, buffer); if (_stride == 0) { _strideFailed = true; Log.LogWarning((object)"The HUD data of this game version does not have the expected layout. Health bars in Blood Hunger are switched off; the rest of the mod is not affected."); return; } if (ConVictedConfig.LogDiagnostics.Value) { ManualLogSource log = Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(43, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("HUD entry size verified: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_stride); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" bytes ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(length); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" entries)."); } log.LogInfo(val2); } } EntityManager entityManager = ((ComponentSystemBase)sys).EntityManager; for (int j = 0; j < length; j++) { Data val3 = entries[j]; if (val3.LastFrame != frameCount || (int)val3.PrefabType != 4) { continue; } Entity entity = val3.Entity; if (!((EntityManager)(ref entityManager)).Exists(entity) || !((EntityManager)(ref entityManager)).HasComponent<CharacterHUD>(entity)) { continue; } CharacterHUD componentData = ((EntityManager)(ref entityManager)).GetComponentData<CharacterHUD>(entity); CharacterHUDEntryType prefabType = ((CharacterHUD)(ref componentData)).PrefabType; if ((int)prefabType != 0 && (int)prefabType != 4) { byte* ptr = buffer + (long)j * (long)_stride; if (*(int*)ptr == entity.Index && ((int*)ptr)[28] == 4) { ((int*)ptr)[28] = (int)prefabType; } } } } private unsafe static int FindStride(NativeArray<Data> entries, byte* buffer) { //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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between I4 and Unknown int[] strideCandidates = StrideCandidates; foreach (int num in strideCandidates) { bool flag = true; int num2 = 0; while (flag && num2 < entries.Length) { Data val = entries[num2]; byte* ptr = buffer + (long)num2 * (long)num; flag = *(int*)ptr == val.Entity.Index && ((int*)ptr)[1] == val.Entity.Version && ((int*)ptr)[2] == val.LastFrame && ((int*)ptr)[28] == (int)val.PrefabType; num2++; } if (flag) { return num; } } return 0; } internal static void UpdateBloodInfo(SetCharacterHUDSystem sys) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Invalid comparison between Unknown and I4 //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Invalid comparison between Unknown and I4 //IL_01bc: Unknown result type (might be due to invalid IL or missing references) List<CharacterHUDEntry> instances = sys._Instances; if (instances == null) { return; } GetCharacterHUDSystem characterHUDSystem = sys._CharacterHUDSystem; if (characterHUDSystem == null) { return; } bool flag = FeatureOn && !_strideFailed && ConVictedConfig.ShowBloodInfo.Value; if (!flag && Infos.Count == 0) { return; } NativeArray<Data> entries = characterHUDSystem.Entries; int frameCount = Time.frameCount; int count = instances.Count; BloodInfo bloodInfo = default(BloodInfo); for (int i = 0; i < count; i++) { CharacterHUDEntry val = instances[i]; if ((Object)(object)val == (Object)null) { continue; } bool flag2 = false; Data val2 = default(Data); if (flag && i < entries.Length) { val2 = entries[i]; flag2 = val2.LastFrame == frameCount && val2.BloodQuality.HasValue && (int)val.EntryType != 4 && (int)val.EntryType != 6; } Infos.TryGetValue(((Il2CppObjectBase)val).Pointer, ref bloodInfo); if (bloodInfo != null && (Object)(object)bloodInfo.Root == (Object)null) { Infos.Remove(((Il2CppObjectBase)val).Pointer); bloodInfo = null; } if (!flag2) { if (bloodInfo != null && bloodInfo.Root.activeSelf) { bloodInfo.Root.SetActive(false); } continue; } if (bloodInfo == null) { bloodInfo = Create(sys, val); if (bloodInfo == null) { continue; } Infos[((Il2CppObjectBase)val).Pointer] = bloodInfo; } Show(sys, bloodInfo, val2); } if (frameCount >= _nextPruneFrame) { _nextPruneFrame = frameCount + 600; Prune(); } } private static BloodInfo Create(SetCharacterHUDSystem sys, CharacterHUDEntry inst) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown UIDataSystem uIDataSystem = sys._UIDataSystem; CharacterHUDEntryCollection val = ((uIDataSystem != null) ? uIDataSystem.CharacterHUDs : null); GameObject val2 = ((val != null) ? val.BloodTypeEntry : null); if ((Object)(object)val2 == (Object)null) { return null; } Transform val3 = (((Object)(object)inst.RootCanvasGroup != (Object)null) ? ((Component)inst.RootCanvasGroup).transform : ((Component)inst).transform); GameObject val4 = Object.Instantiate<GameObject>(val2, val3, false); ((Object)val4).name = "ConVicted_BloodInfo"; val4.SetActive(false); CharacterHUDEntry component = val4.GetComponent<CharacterHUDEntry>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } CharacterHUD_BloodComponent component2 = val4.GetComponent<CharacterHUD_BloodComponent>(); RectTransform component3 = val4.GetComponent<RectTransform>(); if ((Object)(object)component2 == (Object)null || (Object)(object)component3 == (Object)null) { Object.Destroy((Object)(object)val4); LogExceptionOnce("Create", (System.Exception)new InvalidOperationException("The blood HUD prefab has no CharacterHUD_BloodComponent or RectTransform.")); return null; } component3.anchorMin = new Vector2(0.5f, 0.5f); component3.anchorMax = new Vector2(0.5f, 0.5f); component3.pivot = new Vector2(0.5f, 0.5f); System.Collections.Generic.IEnumerator<CanvasGroup> enumerator = val4.GetComponentsInChildren<CanvasGroup>(true).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { CanvasGroup current = enumerator.Current; current.alpha = 1f; current.interactable = false; current.blocksRaycasts = false; } } finally { ((System.IDisposable)enumerator)?.Dispose(); } System.Collections.Generic.IEnumerator<Graphic> enumerator2 = val4.GetComponentsInChildren<Graphic>(true).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator2).MoveNext()) { Graphic current2 = enumerator2.Current; current2.raycastTarget = false; } } finally { ((System.IDisposable)enumerator2)?.Dispose(); } if (ConVictedConfig.LogDiagnostics.Value) { ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Blood info created on '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)((Component)inst).gameObject).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Infos.Count + 1); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" in total)."); } log.LogInfo(val5); } return new BloodInfo { Root = val4, Rect = component3, Blood = component2 }; } private static void Show(SetCharacterHUDSystem sys, BloodInfo info, Data d) { //IL_0026: 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_00aa: Unknown result type (might be due to invalid IL or missing references) float value = ConVictedConfig.BloodInfoScale.Value; info.Rect.anchoredPosition = new Vector2(ConVictedConfig.BloodInfoOffsetX.Value, ConVictedConfig.BloodInfoOffsetY.Value); ((Transform)info.Rect).localScale = new Vector3(value, value, 1f); int num = Mathf.FloorToInt(d.BloodQuality.Value * 100f); int guidHash = ((PrefabGUID)(ref d.BloodType)).GuidHash; if (!info.HasData || num != info.ShownQuality || guidHash != info.ShownType) { info.HasData = true; info.ShownQuality = num; info.ShownType = guidHash; Refresh(sys, info, d); } if (!info.Root.activeSelf) { info.Root.SetActive(true); } } private static void Refresh(SetCharacterHUDSystem sys, BloodInfo info, Data d) { //IL_0033: 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_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (!_refreshFailed) { try { GameDataSystem gameDataSystem = sys._GameDataSystem; ManagedDataRegistry val = ((gameDataSystem != null) ? gameDataSystem.ManagedDataRegistry : null); if (val != null) { Data val2 = new Data { BloodQuality = d.BloodQuality, BloodType = d.BloodType }; info.Blood.RefreshData(ref val2, val); return; } } catch (System.Exception ex) { _refreshFailed = true; LogExceptionOnce("Refresh", ex); Log.LogWarning((object)"The game's blood HUD component could not be refreshed. The blood quality is shown as text only, without the blood type icon."); } } LocalizedText bloodQualityText = info.Blood.BloodQualityText; if ((Object)(object)bloodQualityText != (Object)null && (Object)(object)bloodQualityText.Text != (Object)null) { ((TMP_Text)bloodQualityText.Text).text = Mathf.FloorToInt(d.BloodQuality.Value) + "%"; } } private static void Prune() { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) List<System.IntPtr> val = null; Enumerator<System.IntPtr, BloodInfo> enumerator = Infos.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair<System.IntPtr, BloodInfo> current = enumerator.Current; if (!((Object)(object)current.Value.Root != (Object)null)) { if (val == null) { val = new List<System.IntPtr>(); } val.Add(current.Key); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (val == null) { return; } Enumerator<System.IntPtr> enumerator2 = val.GetEnumerator(); try { while (enumerator2.MoveNext()) { System.IntPtr current2 = enumerator2.Current; Infos.Remove(current2); } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } static HudBloodHunger() { int[] array = new int[4]; RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); StrideCandidates = array; LoggedExceptions = new HashSet<string>(); Infos = new Dictionary<System.IntPtr, BloodInfo>(); } } internal static class SubdueIndicator { private class Icon { public GameObject Root; public RectTransform Rect; public Image Image; public Transform Bar; } private const string WheelNamePart = "DominatingPresence"; private const int DominateAbilityGroup = -1908054166; private const int SpriteSearchIntervalFrames = 120; private static readonly Color FallbackColor = new Color(0.78f, 0.45f, 1f, 1f); private static readonly Dictionary<System.IntPtr, Icon> Icons = new Dictionary<System.IntPtr, Icon>(); private static int _nextPruneFrame; private static Sprite _gameSprite; private static int _nextSpriteSearchFrame; private static bool _wheelLogged; private static Texture2D _fallbackTexture; private static Sprite _fallbackSprite; private static ManualLogSource Log => ConVictedPlugin.Log; internal static void Teardown() { //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) Enumerator<System.IntPtr, Icon> enumerator = Icons.Values.GetEnumerator(); try { while (enumerator.MoveNext()) { Icon current = enumerator.Current; if ((Object)(object)current.Root != (Object)null) { Object.Destroy((Object)(object)current.Root); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } Icons.Clear(); } internal static void Update(SetCharacterHUDSystem sys) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Invalid comparison between Unknown and I4 //IL_00fd: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) List<CharacterHUDEntry> instances = sys._Instances; if (instances == null) { return; } GetCharacterHUDSystem characterHUDSystem = sys._CharacterHUDSystem; if (characterHUDSystem == null) { return; } bool flag = ConVictedConfig.Enabled.Value && ConVictedConfig.ShowSubdueIndicator.Value; if (!flag && Icons.Count == 0) { return; } NativeArray<Data> entries = characterHUDSystem.Entries; EntityManager entityManager = ((ComponentSystemBase)sys).EntityManager; int frameCount = Time.frameCount; float num = Mathf.Clamp((float)ConVictedConfig.SubdueThresholdPercent.Value, 1f, 100f) / 100f; int count = instances.Count; Sprite val = null; bool isGameSprite = false; Icon icon = default(Icon); for (int i = 0; i < count; i++) { CharacterHUDEntry val2 = instances[i]; if ((Object)(object)val2 == (Object)null) { continue; } bool flag2 = false; if (flag && i < entries.Length && (int)val2.EntryType != 4) { Data val3 = entries[i]; if (val3.LastFrame == frameCount && val3.HealthFill > 0f && val3.HealthFill <= num) { Entity entity = val3.Entity; flag2 = ((EntityManager)(ref entityManager)).Exists(entity) && ((EntityManager)(ref entityManager)).HasComponent<CharmSource>(entity) && ((EntityManager)(ref entityManager)).HasComponent<Health>(entity) && !((EntityManager)(ref entityManager)).GetComponentData<Health>(entity).IsDead; } } Icons.TryGetValue(((Il2CppObjectBase)val2).Pointer, ref icon); if (icon != null && (Object)(object)icon.Root == (Object)null) { Icons.Remove(((Il2CppObjectBase)val2).Pointer); icon = null; } if (!flag2) { if (icon != null && icon.Root.activeSelf) { icon.Root.SetActive(false); } continue; } if (icon == null) { icon = Create(val2); if (icon == null) { continue; } Icons[((Il2CppObjectBase)val2).Pointer] = icon; } if ((Object)(object)val == (Object)null) { val = GetSprite(((ComponentSystemBase)sys).World, frameCount, out isGameSprite); if ((Object)(object)val == (Object)null) { continue; } } Place(val2, icon, val, isGameSprite); if (!icon.Root.activeSelf) { icon.Root.SetActive(true); } } if (frameCount >= _nextPruneFrame) { _nextPruneFrame = frameCount + 600; Prune(); } } private static Icon Create(CharacterHUDEntry inst) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_007f: 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_00ab: Unknown result type (might be due to invalid IL or missing references) CharacterHUD_HealthComponent health = inst.Health; if ((Object)(object)health == (Object)null || (Object)(object)health.Image == (Object)null) { return null; } Transform transform = ((Component)health.Image).transform; GameObject val = new GameObject("ConVicted_SubdueIcon"); RectTransform val2 = val.AddComponent<RectTransform>(); val.transform.SetParent(transform, false); Image val3 = val.AddComponent<Image>(); ((Graphic)val3).raycastTarget = false; val3.preserveAspect = true; val2.anchorMin = new Vector2(1f, 0.5f); val2.anchorMax = new Vector2(1f, 0.5f); val2.pivot = new Vector2(0f, 0.5f); val.SetActive(false); return new Icon { Root = val, Rect = val2, Image = val3, Bar = transform }; } private static void Place(CharacterHUDEntry inst, Icon icon, Sprite sprite, bool isGameSprite) { //IL_0035: 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_0046: 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_0092: 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) if ((Object)(object)icon.Image.sprite != (Object)(object)sprite) { icon.Image.sprite = sprite; } ((Graphic)icon.Image).color = (isGameSprite ? Color.white : FallbackColor); float x = ((Component)inst).transform.lossyScale.x; float x2 = icon.Bar.lossyScale.x; float num = ((x > 0.0001f && x2 > 0.0001f) ? (x / x2) : 1f); float num2 = ConVictedConfig.SubdueIconSize.Value * num; icon.Rect.sizeDelta = new Vector2(num2, num2); icon.Rect.anchoredPosition = new Vector2(ConVictedConfig.SubdueIconOffsetX.Value * num, ConVictedConfig.SubdueIconOffsetY.Value * num); } private static void Prune() { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) List<System.IntPtr> val = null; Enumerator<System.IntPtr, Icon> enumerator = Icons.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair<System.IntPtr, Icon> current = enumerator.Current; if (!((Object)(object)current.Value.Root != (Object)null)) { if (val == null) { val = new List<System.IntPtr>(); } val.Add(current.Key); } } } finally { ((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (val == null) { return; } Enumerator<System.IntPtr> enumerator2 = val.GetEnumerator(); try { while (enumerator2.MoveNext()) { System.IntPtr current2 = enumerator2.Current; Icons.Remove(current2); } } finally { ((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } private static Sprite GetSprite(World world, int frame, out bool isGameSprite) { if ((Object)(object)_gameSprite == (Object)null && frame >= _nextSpriteSearchFrame) { _nextSpriteSearchFrame = frame + 120; try { FindGameSprite(world); } catch (System.Exception ex) { HudBloodHunger.LogExceptionOnce("FindGameSprite", ex); } } if ((Object)(object)_gameSprite != (Object)null) { isGameSprite = true; return _gameSprite; } isGameSprite = false; return Fallback(); } private static void FindGameSprite(World world) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if (world == null) { return; } ActionWheelSystem existingSystemManaged = world.GetExistingSystemManaged<ActionWheelSystem>(); if (existingSystemManaged == null) { return; } PrefabCollectionSystem existingSystemManaged2 = world.GetExistingSystemManaged<PrefabCollectionSystem>(); if (existingSystemManaged2 == null) { return; } int seen = 0; Sprite val = SearchWheel(existingSystemManaged2, existingSystemManaged._PowerWheelDataList, ref seen); if ((Object)(object)val == (Object)null) { val = SearchWheel(existingSystemManaged2, existingSystemManaged._PowerWheelShortcutList, ref seen); } string text = "power wheel"; if ((Object)(object)val == (Object)null) { try { GameDataSystem existingSystemManaged3 = world.GetExistingSystemManaged<GameDataSystem>(); ManagedDataRegistry val2 = ((existingSystemManaged3 != null) ? existingSystemManaged3.ManagedDataRegistry : null); if (val2 != null) { ManagedAbilityGroupData orDefault = val2.GetOrDefault<ManagedAbilityGroupData>(new PrefabGUID(-1908054166), (ManagedAbilityGroupData)null); if (orDefault != null && (Object)(object)orDefault.Icon != (Object)null) { val = orDefault.Icon; text = "ability data"; } } } catch (System.Exception ex) { HudBloodHunger.LogExceptionOnce("FindGameSprite.registry", ex); } } bool flag = default(bool); if ((Object)(object)val != (Object)null) { _gameSprite = val; ManualLogSource log = Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(53, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Subdue indicator uses the game's icon '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' (from the "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log.LogInfo(val3); } else if (seen > 0 && !_wheelLogged) { _wheelLogged = true; ManualLogSource log2 = Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(106, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Subdue indicator: no power wheel entry with '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("DominatingPresence"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' in its name among "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(seen); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" entries; a plain marker is used instead."); } log2.LogInfo(val3); } } private unsafe static Sprite SearchWheel(PrefabCollectionSystem prefabs, List<ActionWheelData> list, ref int seen) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) if (list == null) { return null; } bool flag = ConVictedConfig.LogDiagnostics.Value && !_wheelLogged; Sprite val = null; bool flag2 = default(bool); for (int i = 0; i < list.Count; i++) { ActionWheelData val2 = list[i]; if (val2 == null) { continue; } seen++; string text = ""; FixedString128Bytes val3 = default(FixedString128Bytes); PrefabLookupMap prefabLookupMap = prefabs._PrefabLookupMap; if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetFixedName(val2.PrefabGUID, ref val3)) { text = ((object)(*(FixedString128Bytes*)(&val3))/*cast due to .constrained prefix*/).ToString(); } Sprite icon = val2.Icon; if (flag) { ManualLogSource log = Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(30, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Power wheel entry: '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' ("); PrefabGUID prefabGUID = val2.PrefabGUID; ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(((PrefabGUID)(ref prefabGUID)).GuidHash); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(") icon="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)(object)icon != (Object)null) ? ((Object)icon).name : "none"); } log.LogInfo(val4); } if ((Object)(object)val == (Object)null && (Object)(object)icon != (Object)null && text.IndexOf("DominatingPresence", (StringComparison)5) >= 0) { val = icon; } } return val; } private static Sprite Fallback() { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fallbackSprite != (Object)null && (Object)(object)_fallbackTexture != (Object)null) { return _fallbackSprite; } Color32[] array = (Color32[])(object)new Color32[1024]; float num = 15.5f; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { float num2 = ((float)j - num) / num; float num3 = ((float)i - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.7f, 1f, num4)); array[i * 32 + j] = new Color32((byte)255, (byte)255, (byte)255, (byte)Mathf.RoundToInt(num5 * 255f)); } } _fallbackTexture = new Texture2D(32, 32, (TextureFormat)4, false); ((Object)_fallbackTexture).name = "ConVicted_SubdueMarker"; ((Texture)_fallbackTexture).wrapMode = (TextureWrapMode)1; ((Texture)_fallbackTexture).filterMode = (FilterMode)1; _fallbackTexture.SetPixels32(new Il2CppStructArray<Color32>(array)); _fallbackTexture.Apply(); ((Object)_fallbackTexture).hideFlags = (HideFlags)32; _fallbackSprite = Sprite.Create(_fallbackTexture, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f)); ((Object)_fallbackSprite).name = "ConVicted_SubdueMarker"; ((Object)_fallbackSprite).hideFlags = (HideFlags)32; return _fallbackSprite; } } internal static class ScreenTint { private const string ProfileName = "BloodHunger Settings"; private const int SearchIntervalFrames = 30; private static readonly Vector4 NeutralTone = new Vector4(1f, 1f, 1f, 0f); private static VolumeProfile _profile; private static int _nextSearchFrame; private static float _applied = -1f; private static ColorAdjustments _color; private static float _postExposure; private static float _contrast; private static float _hueShift; private static float _saturation; private static Color _colorFilter; private static ChromaticAberration _chromatic; private static float _chromaticIntensity; private static ShadowsMidtonesHighlights _tones; private static Vector4 _shadows; private static Vector4 _midtones; private static Vector4 _highlights; private static ManualLogSource Log => ConVictedPlugin.Log; internal static void Tick() { if ((Object)(object)_profile == (Object)null) { int frameCount = Time.frameCount; if (frameCount < _nextSearchFrame) { return; } _nextSearchFrame = frameCount + 30; if (!Find()) { return; } } float num = (ConVictedConfig.Enabled.Value ? Mathf.Clamp01((float)ConVictedConfig.ScreenTintIntensity.Value / 100f) : 1f); if (!(Mathf.Abs(num - _applied) < 0.0005f)) { Apply(num); } } internal static void Restore() { if ((Object)(object)_profile != (Object)null && _applied >= 0f) { Apply(1f); } } private static bool Find() { //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_012d: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) _profile = null; _color = null; _chromatic = null; _tones = null; _applied = -1f; Il2CppArrayBase<VolumeProfile> val = Resources.FindObjectsOfTypeAll<VolumeProfile>(); VolumeProfile val2 = null; for (int i = 0; i < val.Length; i++) { VolumeProfile val3 = val[i]; if ((Object)(object)val3 != (Object)null && ((Object)val3).name != null && ((Object)val3).name.StartsWith("BloodHunger Settings", (StringComparison)4)) { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { return false; } List<VolumeComponent> components = val2.components; for (int j = 0; j < components.Count; j++) { VolumeComponent val4 = components[j]; if ((Object)(object)val4 == (Object)null) { continue; } ColorAdjustments val5 = ((Il2CppObjectBase)val4).TryCast<ColorAdjustments>(); if ((Object)(object)val5 != (Object)null) { _color = val5; _postExposure = ((VolumeParameter<float>)(object)val5.postExposure).value; _contrast = ((VolumeParameter<float>)(object)val5.contrast).value; _hueShift = ((VolumeParameter<float>)(object)val5.hueShift).value; _saturation = ((VolumeParameter<float>)(object)val5.saturation).value; _colorFilter = ((VolumeParameter<Color>)(object)val5.colorFilter).value; continue; } ChromaticAberration val6 = ((Il2CppObjectBase)val4).TryCast<ChromaticAberration>(); if ((Object)(object)val6 != (Object)null) { _chromatic = val6; _chromaticIntensity = ((VolumeParameter<float>)(object)val6.intensity).value; continue; } ShadowsMidtonesHighlights val7 = ((Il2CppObjectBase)val4).TryCast<ShadowsMidtonesHighlights>(); if ((Object)(object)val7 != (Object)null) { _tones = val7; _shadows = ((VolumeParameter<Vector4>)(object)val7.shadows).value; _midtones = ((VolumeParameter<Vector4>)(object)val7.midtones).value; _highlights = ((VolumeParameter<Vector4>)(object)val7.highlights).value; } } _profile = val2; if (ConVictedConfig.LogDiagnostics.Value) { ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val8 = new BepInExInfoLogInterpolatedStringHandler(106, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("Blood Hunger tint profile found: '"); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<string>(((Object)val2).name); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("' (ColorAdjustments="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<bool>((Object)(object)_color != (Object)null); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(", ChromaticAberration="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<bool>((Object)(object)_chromatic != (Object)null); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(", ShadowsMidtonesHighlights="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<bool>((Object)(object)_tones != (Object)null); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(")."); } log.LogInfo(val8); } return true; } private static void Apply(float strength) { //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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown if ((Object)(object)_color != (Object)null) { ((VolumeParameter<float>)(object)_color.postExposure).value = _postExposure * strength; ((VolumeParameter<float>)(object)_color.contrast).value = _contrast * strength; ((VolumeParameter<float>)(object)_color.hueShift).value = _hueShift * strength; ((VolumeParameter<float>)(object)_color.saturation).value = _saturation * strength; ((VolumeParameter<Color>)(object)_color.colorFilter).value = Color.Lerp(Color.white, _colorFilter, strength); } if ((Object)(object)_chromatic != (Object)null) { ((VolumeParameter<float>)(object)_chromatic.intensity).value = _chromaticIntensity * strength; } if ((Object)(object)_tones != (Object)null) { ((VolumeParameter<Vector4>)(object)_tones.shadows).value = Vector4.Lerp(NeutralTone, _shadows, strength); ((VolumeParameter<Vector4>)(object)_tones.midtones).value = Vector4.Lerp(NeutralTone, _midtones, strength); ((VolumeParameter<Vector4>)(object)_tones.highlights).value = Vector4.Lerp(NeutralTone, _highlights, strength); } _applied = strength; if (ConVictedConfig.LogDiagnostics.Value) { ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blood Hunger tint set to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Mathf.RoundToInt(strength * 100f)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" %."); } log.LogInfo(val); } } } [HarmonyPatch] internal static class ClientLink { private const int CheckIntervalFrames = 30; private static ulong _greetedWorld; private static bool _greeted; private static string _lastSent; private static ulong _tickWorld; private static bool _spawnSeen; private static int _nextCheckFrame; private static bool _serverDecides; private static bool _serverMarksImmortal; private static ManualLogSource Log => ConVictedPlugin.Log; internal static bool ServerDecides(World world) { return ServerPresent(world) && _serverDecides; } internal static bool MarksAreImmortal(World world) { if (ServerDecides(world)) { return _serverMarksImmortal; } return ConVictedConfig.Enabled.Value && ConVictedConfig.MarkedTargetsImmortal.Value; } internal static bool ServerPresent(World world) { return _greeted && world != null && world.SequenceNumber == _greetedWorld; } [HarmonyPatch(typeof(ClientChatSystem), "OnUpdate")] [HarmonyPrefix] private unsafe static void ChatPrefix(ClientChatSystem __instance) { //IL_0003: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) NativeArray<Entity> val = default(NativeArray<Entity>); try { EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager; EntityQuery receiveChatMessagesQuery = __instance._ReceiveChatMessagesQuery; val = ((EntityQuery)(ref receiveChatMessagesQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator<Entity> enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!((EntityManager)(ref entityManager)).HasComponent<ChatMessageServerEvent>(current)) { continue; } ChatMessageServerEvent componentData = ((EntityManager)(ref entityManager)).GetComponentData<ChatMessageServerEvent>(current); if ((int)componentData.MessageType == 6) { string text = ((object)(*(FixedString512Bytes*)(&componentData.MessageText))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("[ConVicted] Target protection is active on this server.", (StringComparison)4)) { ((EntityManager)(ref entityManager)).DestroyEntity(current); _greeted = true; _greetedWorld = ((ComponentSystemBase)__instance).World.SequenceNumber; _lastSent = null; _serverDecides = false; Log.LogInfo((object)"The server runs ConVicted: target protection is available."); } else if (text.StartsWith("[[ConVicted]] ", (StringComparison)4)) { ((EntityManager)(ref entityManager)).DestroyEntity(current); OnHidden(text.Substring("[[ConVicted]] ".Length)); } } } } catch (System.Exception ex) { HudBloodHunger.LogExceptionOnce("ChatPrefix", ex); } finally { if (val.IsCreated) { val.Dispose(); } } } private static void OnHidden(string body) { string[] array = body.Split(new char[1] { ' ' }, (StringSplitOptions)1); if (array.Length >= 2 && array[0] == "marked") { TargetMarks.OnServerAnswer(array[1]); } else if (array.Length >= 2 && array[0] == "rules") { bool flag = array[1] == "1"; if (flag != _serverDecides || flag) { if (flag) { Log.LogInfo((object)("This server uses its own target protection settings for all players. The settings in sections 4 to 7 of your config have no effect here, except the mark key and the look of the mark icon." + ((array.Length >= 3 && array[2] == "0") ? " Marking targets is switched off on this server." : ((array.Length < 4) ? "" : ((array[3] == "1") ? " Marked targets are immortal on this server." : " Marked targets are NOT immortal on this server, whatever MarkedTargetsImmortal says in your config: a mark only protects from your minions."))))); } else if (_serverDecides) { Log.LogInfo((object)"This server uses your own target protection settings again."); } } _serverDecides = flag; _serverMarksImmortal = array.Length >= 4 && array[3] == "1"; } else if (ConVictedConfig.LogDiagnostics.Value) { Log.LogInfo((object)("Unknown message from the server part: " + body)); } } internal static void Tick(GetCharacterHUDSystem sys) { World world = ((ComponentSystemBase)sys).World; if (world == null) { return; } int frameCount = Time.frameCount; if (frameCount < _nextCheckFrame) { return; } _nextCheckFrame = frameCount + 30; ulong sequenceNumber = world.SequenceNumber; if (sequenceNumber != _tickWorld) { _tickWorld = sequenceNumber; _spawnSeen = false; } if (!_spawnSeen && HasLocalCharacter(sys, frameCount)) { _spawnSeen = true; if (!ServerPresent(world)) { Log.LogInfo((object)"Your character is in the world, and no ConVicted server part has greeted so far. If no line \"The server runs ConVicted\" follows, target protection is not available here: in solo play and when hosting it needs the ServerLaunchFix mod; on a dedicated server, ConVicted must be installed on the server."); } } if (ServerPresent(world)) { string text = CurrentSettings().ToWire(); if (!(text == _lastSent)) { Send(world, text); _lastSent = text; Log.LogInfo((object)"Target protection settings sent to the server."); } } } private static bool HasLocalCharacter(GetCharacterHUDSystem sys, int frame) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0016: 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) NativeArray<Data> entries = sys.Entries; for (int i = 0; i < entries.Length; i++) { Data val = entries[i]; if (val.LastFrame == frame && val.IsLocalPlayer) { return true; } } return false; } private static ProtectionSettings CurrentSettings() { bool value = ConVictedConfig.Enabled.Value; return new ProtectionSettings { AutoProtect = (value && ConVictedConfig.EnableAutoBloodProtection.Value), MinBloodQuality = ConVictedConfig.AutoProtectMinBloodQuality.Value, FloorPercent = ConVictedConfig.ProtectedHealthPercent.Value, DominateReaction = (value && ConVictedConfig.EnableDominateMinionReaction.Value), Action = ConVictedConfig.DominateMinionAction.Value, Trigger = ConVictedConfig.DominateReactionTrigger.Value, MarkedImmortal = (value && ConVictedConfig.EnableManualTargetMark.Value && ConVictedConfig.MarkedTargetsImmortal.Value), Diagnostics = ConVictedConfig.LogDiagnostics.Value, MaxMarks = ConVictedConfig.MaxMarkedTargets.Value }; } internal static void Send(World world, string text) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = world.EntityManager; Entity val = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3] { ComponentType.ReadOnly<SendNetworkEventTag>(), ComponentType.ReadOnly<NetworkEventType>(), ComponentType.ReadOnly<ChatMessageEvent>() }); try { ((EntityManager)(ref entityManager)).SetComponentData<ChatMessageEvent>(val, new ChatMessageEvent { MessageType = (ChatMessageType)4, MessageText = new FixedString512Bytes("[[ConVicted]] " + text) }); ((EntityManager)(ref entityManager)).SetComponentData<NetworkEventType>(val, new NetworkEventType { EventId = NetworkEvents.EventId_ChatMessageEvent, IsAdminEvent = false, IsDebugEvent = false }); } catch { ((EntityManager)(ref entityManager)).DestroyEntity(val); throw; } } } internal static class ServerPart { private class DominateState { public bool Form; public bool Channel; } private class Victim { public Entity Entity; public float Hp; public float MaxHp; public bool Charmable; public float BloodQuality; public float ImmortalFloor; public float OtherDamage; public float MinionAllowed; public bool Marked; } private struct MinionHit { public int EventIndex; public Victim Victim; public float FloorFraction; } private struct MarkedDamage { public int EventIndex; public Victim Victim; public float Original; } private const int DominateFormBuff = -1447419822; private const int CharmChannelBuff = 1002852223; private const int MaxOwnerHops = 5; private const string ServerConfigFileName = "com.zeeCameLsnake.ConVicted.Server.cfg"; private const string SectionRules = "Server 1. Who decides"; private const string SectionSettings = "Server 2. Server settings"; private const string SectionDebug = "Server 3. Debug"; private const string ServerFileNote = " (This file is read only by the server process, once at its start.)"; private static readonly HashSet<string> LoggedExceptions = new HashSet<string>(); private static ConfigEntry<bool> _serverDecides; private static ConfigEntry<int> _floorPercent; private static ConfigEntry<bool> _autoProtect; private static ConfigEntry<int> _minBloodQuality; private static ConfigEntry<bool> _dominateReaction; private static ConfigEntry<DominateAction> _action; private static ConfigEntry<DominateTrigger> _trigger; private static ConfigEntry<bool> _allowMarks; private static ConfigEntry<int> _maxMarks; private static ConfigEntry<bool> _markedImmortal; private static ConfigEntry<bool> _logDiagnostics; private static bool _clientDiagnostics; private static readonly Dictionary<ulong, ProtectionSettings> PlayerSettings = new Dictionary<ulong, ProtectionSettings>(); private static readonly Dictionary<long, ulong> PlatformIds = new Dictionary<long, ulong>(); private static readonly Dictionary<long, DominateState> Dominating = new Dictionary<long, DominateState>(); private static World _world; private static EntityQuery _playerQuery; private static bool _hasPlayerQuery; private static readonly Dictionary<ulong, HashSet<long>> Marks = new Dictionary<ulong, HashSet<long>>(); private static int _nextMarkPruneFrame; private static readonly Dictionary<long, string> MarkNames = new Dictionary<long, string>(); private static readonly Dictionary<long, Victim> Victims = new Dictionary<long, Victim>(); private static readonly List<MinionHit> Hits = new List<MinionHit>(); private static readonly List<MarkedDamage> MarkedHits = new List<MarkedDamage>(); private static ManualLogSource Log => ConVictedPlugin.Log; private static bool Diagnostics => _logDiagnostics.Value || _clientDiagnostics; internal static void Load(BasePlugin plugin, Harmony harmony) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown BepInPlugin val = new BepInPlugin("com.zeeCameLsnake.ConVicted", "ConVicted", "1.0.0"); ConfigFile val2 = new ConfigFile(Path.Combine(Paths.ConfigPath, "com.zeeCameLsnake.ConVicted.Server.cfg"), true, val); _serverDecides = val2.Bind<bool>("Server 1. Who decides", "ServerSettingsForEveryone", false, "Who decides how target protection works. Off (default): every player decides for themselves. Players who run ConVicted in their own game send their settings to the server, and those apply to their own minions and marks; the values in section 'Server 2' are used only for players without ConVicted in their game. This is what solo players want. On: the values in section 'Server 2' apply to ALL players, and the protection settings players send are ignored. Use this on a shared server if protection should be the same for everyone, for fairness or balance. Players keep their own HUD, screen tint, mark key and icon looks in both cases. (This file is read only by the server process, once at its start.)"); _floorPercent = val2.Bind<int>("Server 2. Server settings", "ProtectedHealthPercent", 28, new ConfigDescription("Used for players without ConVicted in their game, and for everyone if ServerSettingsForEveryone is on. Health in percent that a protected unit cannot be pushed below. Dominate Human works at 30 % or less: below 30, protected units are brought into reach; above 30, players have to bring them into reach themselves.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), System.Array.Empty<object>())); _autoProtect = val2.Bind<bool>("Server 2. Server settings", "EnableAutoBloodProtection", true, "Protection A (autopilot): a player's minions cannot push charmable units with at least AutoProtectMinBloodQuality below ProtectedHealthPercent."); _minBloodQuality = val2.Bind<int>("Server 2. Server settings", "AutoProtectMinBloodQuality", 80, new ConfigDescription("Blood quality in percent from which a unit is protected by protection A. Example: 80 protects units with 80 % and better.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), System.Array.Empty<object>())); _dominateReaction = val2.Bind<bool>("Server 2. Server settings", "EnableDominateMinionReaction", true, "Protection B: a player's minions react when the player uses Dominate Human (see DominateMinionAction)."); _action = val2.Bind<DominateAction>("Server 2. Server settings", "DominateMinionAction", DominateAction.KillAllMinions, "KillAllMinions: the minions die at once. MinionsDealNoDamage: they stay and keep attacking, but their hits take no health off charmable units while Dominate Human is in use."); _trigger = val2.Bind<DominateTrigger>("Server 2. Server settings", "DominateReactionTrigger", DominateTrigger.OnDominateStanceActivated, "OnDominateStanceActivated: react when the player enters the Dominating Presence form. OnSubdueBeamCast: react only while the subdue beam is channeled."); _allowMarks = val2.Bind<bool>("Server 2. Server settings", "AllowTargetMarks", true, "Protection C: players may mark single units, and their minions deal no damage to those. Marking needs ConVicted in the player's game. This switch only counts while ServerSettingsForEveryone is on; otherwise every player decides in their own config."); _maxMarks = val2.Bind<int>("Server 2. Server settings", "MaxMarkedTargets", 2, new ConfigDescription("How many units one player can have marked at the same time. This value only counts while ServerSettingsForEveryone is on; otherwise every player decides in their own config.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), System.Array.Empty<object>())); _markedImmortal = val2.Bind<bool>("Server 2. Server settings", "MarkedTargetsImmortal", false, "On: no combat damage from anyone can push a marked unit below ProtectedHealthPercent. Off: a mark only protects from the marking player's minions. This switch only counts while ServerSettingsForEveryone is on; otherwise every player decides in their own config."); _logDiagnostics = val2.Bind<bool>("Server 3. Debug", "LogDiagnostics", false, "Writes every reduced hit, every Dominate reaction and every mark request to the server log (BepInEx_Server/LogOutput.log in solo play and when hosting). Only needed when reporting a problem. A player can switch the same log lines on from their own game with LogDiagnostics in their own config, so in solo play this entry does not need to be touched. (This file is read only by the server process, once at its start.)"); harmony.PatchAll(typeof(ServerPatches)); ClassInjector.RegisterTypeInIl2Cpp<ServerTickBehaviour>(); plugin.AddComponent<ServerTickBehaviour>(); Log.LogInfo((object)(_serverDecides.Value ? "Target protection: the server's settings apply to all players (ServerSettingsForEveryone is on)." : "Target protection: every player uses their own settings (ServerSettingsForEveryone is off).")); } internal static void LogExceptionOnce(string where, System.Exception ex) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown string text = string.Concat(new string[5] { where, ":", ((MemberInfo)ex.GetType()).Name, ":", ex.Message }); if (LoggedExceptions.Add(text)) { ManualLogSource log = Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(3, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(where); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<System.Exception>(ex); } log.LogError(val); } } private static long Key(Entity e) { //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) return ((long)e.Index << 32) | (uint)e.Version; } private static bool IsNull(Entity e) { //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) return e.Index == 0 && e.Version == 0; } private static bool Same(Entity a, Entity b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) return a.Index == b.Index && a.Version == b.Version; } private static ProtectionSettings ServerSettings() { return new ProtectionSettings { AutoProtect = _autoProtect.Value, MinBloodQuality = _minBloodQuality.Value, FloorPercent = _floorPercent.Value, DominateReaction = _dominateReaction.Value, Action = _action.Value, Trigger = _trigger.Value, MarkedImmortal = _markedImmortal.Value, MaxMarks = _maxMarks.Value }; } private static ProtectionSettings SettingsForPlatform(ulong platformId) { if (_serverDecides.Value) { return ServerSettings(); } ProtectionSettings protectionSettings = default(ProtectionSettings); return (platformId != 0L && PlayerSettings.TryGetValue(platformId, ref protectionSettings)) ? protectionSettings : ServerSettings(); } private static ProtectionSettings SettingsFor(EntityManager em, Entity player) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return SettingsForPlatform(PlatformIdOf(em, player)); } private static ulong PlatformIdOf(EntityManager em, Entity player) { //IL_0001: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) long num = Key(player); ulong num2 = default(ulong); if (!PlatformIds.TryGetValue(num, ref num2)) { num2 = 0uL; if (((EntityManager)(ref em)).HasComponent<PlayerCharacter>(player)) { Entity userEntity = ((EntityManager)(ref em)).GetComponentData<PlayerCharacter>(player).UserEntity; if (!IsNull(userEntity) && ((EntityManager)(ref em)).Exists(userEntity) && ((EntityManager)(ref em)).HasComponent<User>(userEntity)) { num2 = ((EntityManager)(ref em)).GetComponentData<User>(userEntity).PlatformId; } } if (num2 != 0) { PlatformIds[num] = num2; } } return num2; } internal static void OnHiddenMessage(EntityManager em, FromCharacter from, string body) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: 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) //IL_006e: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: