using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Agents;
using GameData;
using Gear;
using Hikaria.CGHUDInfo.Utils;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem.Collections.Generic;
using Localization;
using Player;
using SNetwork;
using TMPro;
using TheArchive.Core;
using TheArchive.Core.Attributes;
using TheArchive.Core.Attributes.Feature.Settings;
using TheArchive.Core.FeaturesAPI;
using TheArchive.Core.FeaturesAPI.Settings;
using TheArchive.Core.Localization;
using TheArchive.Interfaces;
using TheArchive.Loader;
using TheArchive.Utilities;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyProduct("Hikaria.CGHUDInfo")]
[assembly: AssemblyTitle("Hikaria.CGHUDInfo")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c4908902-68bd-4a34-b1c8-6bc3cbf763e5")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Hikaria.CGHUDInfo
{
[ArchiveModule("Hikaria.CGHUDInfo", "ColorGradingHUDInfo", "1.0.0")]
public class EntryPoint : IArchiveModule
{
public bool ApplyHarmonyPatches => false;
public bool UsesLegacyPatches => false;
public ArchiveLegacyPatcher Patcher { get; set; }
public string ModuleGroup => FeatureGroup.op_Implicit(FeatureGroups.GetOrCreateModuleGroup("CGHUDInfo", new Dictionary<Language, string>
{
{
(Language)0,
"Color Grading HUD Info"
},
{
(Language)1,
"颜色分级 HUD 信息"
}
}));
public void Init()
{
Logs.LogMessage("OK");
}
public void OnSceneWasLoaded(int buildIndex, string sceneName)
{
}
public void OnLateUpdate()
{
}
public void OnExit()
{
}
}
internal static class Logs
{
private static IArchiveLogger _logger;
private static IArchiveLogger Logger => _logger ?? (_logger = LoaderWrapper.CreateLoggerInstance("Hikaria.CGHUDInfo", ConsoleColor.White));
public static void LogDebug(object data)
{
Logger.Debug(data.ToString());
}
public static void LogError(object data)
{
Logger.Error(data.ToString());
}
public static void LogInfo(object data)
{
Logger.Info(data.ToString());
}
public static void LogMessage(object data)
{
Logger.Msg(ConsoleColor.White, data.ToString());
}
public static void LogWarning(object data)
{
Logger.Warning(data.ToString());
}
public static void LogNotice(object data)
{
Logger.Notice(data.ToString());
}
public static void LogSuccess(object data)
{
Logger.Success(data.ToString());
}
public static void LogException(Exception ex)
{
Logger.Exception(ex);
}
}
public static class PluginInfo
{
public const string GUID = "Hikaria.CGHUDInfo";
public const string NAME = "ColorGradingHUDInfo";
public const string VERSION = "1.0.0";
}
}
namespace Hikaria.CGHUDInfo.Utils
{
public class RatioColor
{
public Color Color;
public float Ratio;
public RatioColor(Color color, float ratio)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
Color = color;
Ratio = ratio;
}
}
public class RatioColorDeterminer
{
public List<RatioColor> _colorGrades;
public Color GetDeterminedColor(float ratio, float ratioScale = 1f)
{
//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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_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)
ratioScale = Mathf.Clamp(ratioScale, 0.001f, 1f);
Color result = Color.white;
float num = 0f;
Color val = Color.black;
for (int i = 0; i < _colorGrades.Count; i++)
{
RatioColor ratioColor = _colorGrades[i];
if (i != 0)
{
float num2 = (ratio - num) / (ratioColor.Ratio * ratioScale - num);
num = ratioColor.Ratio * ratioScale;
result = Color.Lerp(val, ratioColor.Color, Mathf.Clamp01(num2));
if (num2 < 1f)
{
break;
}
}
val = ratioColor.Color;
}
return result;
}
public string GetDeterminedColorHTML(float ratio, float ratioScale = 1f)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return ColorUtility.ToHtmlStringRGBA(GetDeterminedColor(ratio, ratioScale));
}
}
public class TextEntity
{
private string m_text;
public TextEntity(string text)
{
m_text = text;
}
public void AddColor(Color color)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
string text = ColorUtility.ToHtmlStringRGBA(color);
m_text = "<color=#" + text + ">" + m_text + "</color>";
}
public void AddSize(float ratio)
{
m_text = "<size=" + ratio * 100f + "%>" + m_text + "</size>";
}
public static implicit operator string(TextEntity component)
{
return component.m_text;
}
}
}
namespace Hikaria.CGHUDInfo.Features
{
public class CGHUDInfo : Feature
{
public class CGHUDInfoSettings
{
[FSDisplayName("显示栏位")]
public List<HUDInfos> ShowSlots { get; set; } = new List<HUDInfos>();
[FSDisplayName("隐藏空栏位")]
public bool HideEmptySlots { get; set; }
[FSDisplayName("瞄准时透明")]
public bool TransparentWhenAim { get; set; } = true;
[FSDisplayName("自动文本大小")]
[FSDescription("跟据手持物品自动调整对应文本大小")]
public bool AutoFontSizeUp { get; set; } = true;
[FSDisplayName("自动隐藏文本")]
[FSDescription("跟据手持物品自动隐藏无关内容")]
public bool AutoHideText { get; set; } = true;
[FSDisplayName("动态透明度")]
public bool DynamicTrasparency { get; set; } = true;
[FSDisplayName("信息常显")]
public bool AlwaysVisible { get; set; } = true;
[FSDisplayName("使用次数替代百分比")]
public bool UseTimesInsteadOfPercentage { get; set; } = true;
}
[Localized]
public enum HUDInfos
{
Health,
Infection,
GearStandard,
GearSpecial,
GearClass,
ResourcePack,
Consumable,
BotLeader
}
[ArchivePatch(/*Could not decode attribute arguments.*/)]
private class PlaceNavMarkerOnGO__PlaceMarker__Patch
{
private static void Postfix(PlaceNavMarkerOnGO __instance)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance.m_marker != (Object)null && (int)__instance.type == 0)
{
((TMP_Text)__instance.m_marker.m_playerName).alignment = (TextAlignmentOptions)1026;
((TMP_Text)__instance.m_marker.m_playerName).fontSizeMax = 30f;
((TMP_Text)__instance.m_marker.m_playerName).fontSizeMin = 25f;
}
}
}
[ArchivePatch(/*Could not decode attribute arguments.*/)]
private class PlayerAgent__Setup__Patch
{
private static void Postfix(PlayerAgent __instance)
{
if (!((Agent)__instance).IsLocallyOwned && (Object)(object)((Component)__instance).GetComponent<PlayerHudDistanceModifier>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<PlayerHudDistanceModifier>();
}
}
}
[ArchivePatch(/*Could not decode attribute arguments.*/)]
private class SentryGunInstance__OnSpawn__Patch
{
private static void Postfix(SentryGunInstance __instance)
{
if (Feature.CurrentGameState >= 10)
{
PlayerAgent owner = ((Item)__instance).Owner;
SNet_Player val = ((owner != null) ? owner.Owner : null);
if (!((Object)(object)val == (Object)null) && !val.IsLocal)
{
_sentryGunInstances[val.Lookup] = __instance;
}
}
}
}
[ArchivePatch(/*Could not decode attribute arguments.*/)]
private class SentryGunInstance__OnDestroy__Patch
{
private static void Prefix(SentryGunInstance __instance)
{
if (Feature.CurrentGameState >= 10)
{
PlayerAgent owner = ((Item)__instance).Owner;
SNet_Player val = ((owner != null) ? owner.Owner : null);
if (!((Object)(object)val == (Object)null) && !val.IsLocal)
{
_sentryGunInstances.Remove(val.Lookup);
}
}
}
}
[ArchivePatch(/*Could not decode attribute arguments.*/)]
private class PlayerInventoryLocal__DoWieldItem__Patch
{
private static void Postfix(PlayerInventoryLocal __instance)
{
PlaceNavMarkerOnGO__UpdateExtraInfo__Patch.UpdateSizeUp(((PlayerInventoryBase)__instance).Owner);
}
}
[ArchivePatch(/*Could not decode attribute arguments.*/)]
private class PlayerAgent__set_Alive__Patch
{
private static void Postfix(PlayerAgent __instance)
{
if (((Agent)__instance).IsLocallyOwned)
{
PlaceNavMarkerOnGO__UpdateExtraInfo__Patch.UpdateSizeUp(__instance);
}
}
}
[ArchivePatch(/*Could not decode attribute arguments.*/)]
private class PlaceNavMarkerOnGO__UpdateExtraInfo__Patch
{
private enum eResourcePackType : byte
{
None,
Health,
AmmoWeapon,
AmmoTool,
Disinfection
}
private static bool healthSizeUp = false;
private static bool weaponSizeUp = false;
private static bool toolSizeUp = false;
private static bool infectionSizeUp = false;
private static bool hideHealth = false;
private static bool hideWeaponAmmo = false;
private static bool hideInfection = false;
private static bool hideToolAmmo = false;
private static bool hideOthers = false;
private static eResourcePackType currentResourcePackType = eResourcePackType.None;
private static StringBuilder sb = new StringBuilder(300);
private static eResourcePackType GetPackType(eResourceContainerSpawnType spawnType)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected I4, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
switch ((int)spawnType)
{
default:
if ((int)spawnType == 9)
{
return eResourcePackType.Disinfection;
}
return eResourcePackType.None;
case 0:
return eResourcePackType.Health;
case 2:
return eResourcePackType.AmmoTool;
case 1:
return eResourcePackType.AmmoWeapon;
}
}
public static void UpdateSizeUp(PlayerAgent localPlayer)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Invalid comparison between Unknown and I4
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
healthSizeUp = false;
weaponSizeUp = false;
toolSizeUp = false;
infectionSizeUp = false;
hideHealth = false;
hideInfection = false;
hideWeaponAmmo = false;
hideToolAmmo = false;
hideOthers = false;
currentResourcePackType = (((int)localPlayer.Inventory.WieldedSlot == 4) ? GetPackType(((Il2CppObjectBase)localPlayer.Inventory.WieldedItem).Cast<ResourcePackFirstPerson>().m_packType) : eResourcePackType.None);
if (!((Agent)localPlayer).Alive || currentResourcePackType == eResourcePackType.None)
{
return;
}
if (Settings.AutoHideText)
{
hideHealth = currentResourcePackType != eResourcePackType.Health;
hideInfection = currentResourcePackType != eResourcePackType.Disinfection;
hideWeaponAmmo = currentResourcePackType != eResourcePackType.AmmoWeapon;
hideToolAmmo = currentResourcePackType != eResourcePackType.AmmoTool;
hideOthers = true;
}
if (Settings.AutoFontSizeUp)
{
switch (currentResourcePackType)
{
case eResourcePackType.Health:
healthSizeUp = true;
break;
case eResourcePackType.AmmoWeapon:
weaponSizeUp = true;
break;
case eResourcePackType.AmmoTool:
toolSizeUp = true;
break;
case eResourcePackType.Disinfection:
infectionSizeUp = true;
break;
}
}
}
private static bool Prefix(PlaceNavMarkerOnGO __instance)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0eb8: Unknown result type (might be due to invalid IL or missing references)
//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0425: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Invalid comparison between Unknown and I4
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
//IL_062c: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Invalid comparison between Unknown and I4
//IL_052e: Unknown result type (might be due to invalid IL or missing references)
//IL_0996: Unknown result type (might be due to invalid IL or missing references)
//IL_0c3b: Unknown result type (might be due to invalid IL or missing references)
//IL_0786: Unknown result type (might be due to invalid IL or missing references)
//IL_089a: Unknown result type (might be due to invalid IL or missing references)
//IL_08a0: Invalid comparison between Unknown and I4
//IL_0d5c: Unknown result type (might be due to invalid IL or missing references)
//IL_0d62: Invalid comparison between Unknown and I4
//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
//IL_0abd: Invalid comparison between Unknown and I4
//IL_0d93: Unknown result type (might be due to invalid IL or missing references)
//IL_0d99: Invalid comparison between Unknown and I4
//IL_0aee: Unknown result type (might be due to invalid IL or missing references)
//IL_0af4: Invalid comparison between Unknown and I4
if (!__instance.m_hasPlayer || (int)__instance.type != 0)
{
return true;
}
PlayerAgent player = __instance.Player;
if ((Object)(object)player == (Object)null || ((Agent)player).IsLocallyOwned)
{
return true;
}
SNet_Player owner = player.Owner;
if ((Object)(object)owner == (Object)null)
{
return true;
}
Dam_PlayerDamageBase damage = player.Damage;
if ((Object)(object)damage == (Object)null)
{
return true;
}
if (!hideHealth && Settings.ShowSlots.Contains(HUDInfos.Health))
{
float healthRel = ((Dam_SyncedDamageBase)damage).GetHealthRel();
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder2 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(41, 4, stringBuilder);
handler.AppendLiteral("<color=#");
handler.AppendFormatted(_determinerHealth.GetDeterminedColorHTML(healthRel, 1f - damage.Infection));
handler.AppendLiteral("><size=");
handler.AppendFormatted(healthSizeUp ? "100" : "75");
handler.AppendLiteral("%><u>");
handler.AppendFormatted(Localization.Get(1u));
handler.AppendLiteral(" ");
handler.AppendFormatted(healthRel * 100f, "N0");
handler.AppendLiteral("%</u></size></color>");
stringBuilder2.AppendLine(ref handler);
if ((int)Localization.CurrentLanguage != 0)
{
stringBuilder = sb;
StringBuilder stringBuilder3 = stringBuilder;
handler = new StringBuilder.AppendInterpolatedStringHandler(16, 1, stringBuilder);
handler.AppendLiteral("<size=");
handler.AppendFormatted(healthSizeUp ? "50" : "37.5");
handler.AppendLiteral("%> </size>");
stringBuilder3.AppendLine(ref handler);
}
}
if (!hideInfection && Settings.ShowSlots.Contains(HUDInfos.Infection) && damage.Infection > 0.1f)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder4 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(40, 3, stringBuilder);
handler.AppendLiteral("<color=#00FFA8><size=");
handler.AppendFormatted(infectionSizeUp ? "100" : "70");
handler.AppendLiteral("%>");
handler.AppendFormatted(Localization.Get(2u));
handler.AppendLiteral(" ");
handler.AppendFormatted(damage.Infection * 100f, "N0");
handler.AppendLiteral("%</size></color>");
stringBuilder4.AppendLine(ref handler);
}
PlayerBackpack playerBackpack = __instance.m_playerBackpack;
if (playerBackpack != null)
{
PlayerAmmoStorage ammoStorage = playerBackpack.AmmoStorage;
BackpackItem val = default(BackpackItem);
if (!hideWeaponAmmo && Settings.ShowSlots.Contains(HUDInfos.GearStandard) && playerBackpack.TryGetBackpackItem((InventorySlot)1, ref val))
{
ItemEquippable val2 = ((Il2CppObjectBase)val.Instance).TryCast<ItemEquippable>();
if ((Object)(object)val2 != (Object)null)
{
if ((((Item)val2).ItemDataBlock != null && ((Item)val2).ItemDataBlock.GUIShowAmmoInfinite) || !((Item)val2).ItemDataBlock.GUIShowAmmoTotalRel)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder5 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(32, 3, stringBuilder);
handler.AppendLiteral("<size=");
handler.AppendFormatted(weaponSizeUp ? "100" : "70");
handler.AppendLiteral("%><color=#");
handler.AppendFormatted(ColorUtility.ToHtmlStringRGBA(_determineAmmoWeaponRelInPack.GetDeterminedColor(100f)));
handler.AppendLiteral(">");
handler.AppendFormatted(((Item)val2).ArchetypeName);
handler.AppendLiteral("</color></size>");
stringBuilder5.AppendLine(ref handler);
}
else
{
float relInPack = ammoStorage.StandardAmmo.RelInPack;
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder6 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(34, 5, stringBuilder);
handler.AppendLiteral("<size=");
handler.AppendFormatted(weaponSizeUp ? "100" : "70");
handler.AppendLiteral("%><color=#");
handler.AppendFormatted(ColorUtility.ToHtmlStringRGBA(_determineAmmoWeaponRelInPack.GetDeterminedColor(relInPack)));
handler.AppendLiteral(">");
handler.AppendFormatted(((Item)val2).ArchetypeName);
handler.AppendLiteral(" ");
handler.AppendFormatted(relInPack * 100f, "N0");
handler.AppendLiteral("%</color>");
handler.AppendFormatted(((int)val.Status == 1) ? (" <color=red>[" + Text.Get(2505980868u) + "]</color>") : string.Empty);
handler.AppendLiteral("</size>");
stringBuilder6.AppendLine(ref handler);
}
}
}
BackpackItem val3 = default(BackpackItem);
if (!hideWeaponAmmo && Settings.ShowSlots.Contains(HUDInfos.GearSpecial) && playerBackpack.TryGetBackpackItem((InventorySlot)2, ref val3))
{
ItemEquippable val4 = ((Il2CppObjectBase)val3.Instance).TryCast<ItemEquippable>();
if ((Object)(object)val4 != (Object)null)
{
if ((((Item)val4).ItemDataBlock != null && ((Item)val4).ItemDataBlock.GUIShowAmmoInfinite) || !((Item)val4).ItemDataBlock.GUIShowAmmoTotalRel)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder7 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(32, 3, stringBuilder);
handler.AppendLiteral("<size=");
handler.AppendFormatted(weaponSizeUp ? "100" : "70");
handler.AppendLiteral("%><color=#");
handler.AppendFormatted(ColorUtility.ToHtmlStringRGBA(_determineAmmoWeaponRelInPack.GetDeterminedColor(100f)));
handler.AppendLiteral(">");
handler.AppendFormatted(((Item)val4).ArchetypeName);
handler.AppendLiteral("</color></size>");
stringBuilder7.AppendLine(ref handler);
}
else
{
float relInPack2 = ammoStorage.SpecialAmmo.RelInPack;
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder8 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(34, 5, stringBuilder);
handler.AppendLiteral("<size=");
handler.AppendFormatted(weaponSizeUp ? "100" : "70");
handler.AppendLiteral("%><color=#");
handler.AppendFormatted(ColorUtility.ToHtmlStringRGBA(_determineAmmoWeaponRelInPack.GetDeterminedColor(relInPack2)));
handler.AppendLiteral(">");
handler.AppendFormatted(((Item)val4).ArchetypeName);
handler.AppendLiteral(" ");
handler.AppendFormatted(relInPack2 * 100f, "N0");
handler.AppendLiteral("%</color>");
handler.AppendFormatted(((int)val3.Status == 1) ? (" <color=red>[" + Text.Get(2505980868u) + "]</color>") : string.Empty);
handler.AppendLiteral("</size>");
stringBuilder8.AppendLine(ref handler);
}
}
}
BackpackItem val5 = default(BackpackItem);
if (!hideToolAmmo && Settings.ShowSlots.Contains(HUDInfos.GearClass) && playerBackpack.TryGetBackpackItem((InventorySlot)3, ref val5) && val5 != null && (Object)(object)val5.Instance != (Object)null)
{
ItemEquippable val6 = ((Il2CppObjectBase)val5.Instance).TryCast<ItemEquippable>();
if ((Object)(object)val6 != (Object)null)
{
string value = ((Item)val6).ArchetypeName;
GearIDRange gearIDRange = val6.GearIDRange;
uint compID = gearIDRange.GetCompID((eGearComponent)2);
eWeaponFireMode val7 = (eWeaponFireMode)gearIDRange.GetCompID((eGearComponent)1);
if (compID == 12)
{
ArchetypeDataBlock archetypeDataForFireMode = SentryGunInstance_Firing_Bullets.GetArchetypeDataForFireMode(val7);
if (archetypeDataForFireMode != null)
{
value = LocalizedText.op_Implicit(archetypeDataForFireMode.PublicName);
}
}
if ((((Item)val6).ItemDataBlock != null && ((Item)val6).ItemDataBlock.GUIShowAmmoInfinite) || !((Item)val6).ItemDataBlock.GUIShowAmmoTotalRel)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder9 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(32, 3, stringBuilder);
handler.AppendLiteral("<size=");
handler.AppendFormatted(toolSizeUp ? "100" : "70");
handler.AppendLiteral("%><color=#");
handler.AppendFormatted(ColorUtility.ToHtmlStringRGBA(ColorExt.Hex("FDA1FF")));
handler.AppendLiteral(">");
handler.AppendFormatted(value);
handler.AppendLiteral("</color></size>");
stringBuilder9.AppendLine(ref handler);
}
else
{
float num = ammoStorage.ClassAmmo.RelInPack;
if (_sentryGunInstances.TryGetValue(owner.Lookup, out var value2))
{
num = value2.Ammo / value2.AmmoMaxCap;
}
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder10 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(34, 5, stringBuilder);
handler.AppendLiteral("<size=");
handler.AppendFormatted(toolSizeUp ? "100" : "70");
handler.AppendLiteral("%><color=#");
handler.AppendFormatted(_determineAmmoWeaponRelInPack.GetDeterminedColorHTML(num));
handler.AppendLiteral(">");
handler.AppendFormatted(value);
handler.AppendLiteral(" ");
handler.AppendFormatted(num * 100f, "N0");
handler.AppendLiteral("%</color>");
handler.AppendFormatted(((int)val5.Status == 1) ? (" <color=red>[" + Text.Get(2505980868u) + "]</color>") : string.Empty);
handler.AppendLiteral("</size>");
stringBuilder10.AppendLine(ref handler);
}
}
}
if (!hideOthers && Settings.ShowSlots.Contains(HUDInfos.ResourcePack))
{
bool flag = false;
BackpackItem val8 = default(BackpackItem);
if (playerBackpack.TryGetBackpackItem((InventorySlot)4, ref val8) && val8 != null && (Object)(object)val8.Instance != (Object)null)
{
ItemEquippable val9 = ((Il2CppObjectBase)val8.Instance).TryCast<ItemEquippable>();
if ((Object)(object)val9 != (Object)null)
{
if ((((Item)val9).ItemDataBlock != null && ((Item)val9).ItemDataBlock.GUIShowAmmoInfinite) || !((Item)val9).ItemDataBlock.GUIShowAmmoTotalRel)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder11 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(17, 2, stringBuilder);
handler.AppendLiteral("<color=#");
handler.AppendFormatted(ColorUtility.ToHtmlStringRGBA(_detemineAmmoResourceRelInPack.GetDeterminedColor(100f)));
handler.AppendLiteral(">");
handler.AppendFormatted(((Item)val9).ArchetypeName);
handler.AppendLiteral("</color>");
stringBuilder11.AppendLine(ref handler);
flag = true;
}
else
{
float num2 = (Settings.UseTimesInsteadOfPercentage ? ((float)ammoStorage.ResourcePackAmmo.BulletsInPack) : (ammoStorage.ResourcePackAmmo.RelInPack * 100f));
if (num2 > 0f)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder12 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(18, 5, stringBuilder);
handler.AppendLiteral("<color=#");
handler.AppendFormatted(_detemineAmmoResourceRelInPack.GetDeterminedColorHTML(ammoStorage.ResourcePackAmmo.RelInPack));
handler.AppendLiteral(">");
handler.AppendFormatted(((Item)val9).ArchetypeName);
handler.AppendLiteral(" ");
handler.AppendFormatted(num2, "N0");
handler.AppendFormatted(Settings.UseTimesInsteadOfPercentage ? (" " + Localization.Get(7u) + (((int)Localization.CurrentLanguage == 1 || num2 <= 1f) ? string.Empty : "s")) : "%");
handler.AppendLiteral("</color>");
handler.AppendFormatted(((int)val8.Status == 1) ? (" <color=red>[" + Text.Get(2505980868u) + "]</color>") : string.Empty);
stringBuilder12.AppendLine(ref handler);
flag = true;
}
}
}
}
if (!flag && !Settings.HideEmptySlots)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder13 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(23, 1, stringBuilder);
handler.AppendLiteral("<color=#B3B3B3>");
handler.AppendFormatted(Localization.Get(3u));
handler.AppendLiteral("</color>");
stringBuilder13.AppendLine(ref handler);
}
}
if (!hideOthers && Settings.ShowSlots.Contains(HUDInfos.Consumable))
{
bool flag2 = false;
BackpackItem val10 = default(BackpackItem);
if (playerBackpack.TryGetBackpackItem((InventorySlot)5, ref val10) && val10 != null && (Object)(object)val10.Instance != (Object)null)
{
ItemEquippable val11 = ((Il2CppObjectBase)val10.Instance).TryCast<ItemEquippable>();
if ((Object)(object)val11 != (Object)null)
{
if (((Item)val11).ItemDataBlock != null && (((Item)val11).ItemDataBlock.GUIShowAmmoInfinite || !((Item)val11).ItemDataBlock.GUIShowAmmoTotalRel))
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder14 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(17, 2, stringBuilder);
handler.AppendLiteral("<color=#");
handler.AppendFormatted(ColorUtility.ToHtmlStringRGBA(_detemineAmmoResourceRelInPack.GetDeterminedColor(100f)));
handler.AppendLiteral(">");
handler.AppendFormatted(((Item)val11).ArchetypeName);
handler.AppendLiteral("</color>");
stringBuilder14.AppendLine(ref handler);
flag2 = true;
}
else
{
float num3 = (Settings.UseTimesInsteadOfPercentage ? ((float)ammoStorage.ConsumableAmmo.BulletsInPack) : (ammoStorage.ConsumableAmmo.RelInPack * 100f));
if (num3 > 0f)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder15 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(18, 5, stringBuilder);
handler.AppendLiteral("<color=#");
handler.AppendFormatted(_detemineAmmoResourceRelInPack.GetDeterminedColorHTML(ammoStorage.ConsumableAmmo.RelInPack));
handler.AppendLiteral(">");
handler.AppendFormatted(((Item)val11).ArchetypeName);
handler.AppendLiteral(" ");
handler.AppendFormatted(num3, "N0");
handler.AppendFormatted(Settings.UseTimesInsteadOfPercentage ? (" " + Localization.Get(7u) + (((int)Localization.CurrentLanguage == 1 || num3 <= 1f) ? string.Empty : "s")) : "%");
handler.AppendLiteral("</color>");
handler.AppendFormatted(((int)val10.Status == 1) ? (" <color=red>[" + Text.Get(2505980868u) + "]</color>") : string.Empty);
stringBuilder15.AppendLine(ref handler);
flag2 = true;
}
}
}
}
if (!flag2 && !Settings.HideEmptySlots)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder16 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(23, 1, stringBuilder);
handler.AppendLiteral("<color=#B3B3B3>");
handler.AppendFormatted(Localization.Get(4u));
handler.AppendLiteral("</color>");
stringBuilder16.AppendLine(ref handler);
}
}
}
if (!hideOthers && Settings.ShowSlots.Contains(HUDInfos.BotLeader) && owner.IsBot)
{
PlayerAIBot component = ((Component)player).GetComponent<PlayerAIBot>();
if ((Object)(object)component != (Object)null)
{
PlayerAgent leader = component.SyncValues.Leader;
if ((Object)(object)leader != (Object)null)
{
StringBuilder stringBuilder = sb;
StringBuilder stringBuilder17 = stringBuilder;
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(18, 3, stringBuilder);
handler.AppendFormatted(Localization.Get(5u));
handler.AppendLiteral(" <color=#");
handler.AppendFormatted(ColorUtility.ToHtmlStringRGB(leader.Owner.PlayerColor));
handler.AppendLiteral(">");
handler.AppendFormatted(((Agent)leader).IsLocallyOwned ? (Localization.Get(6u) ?? "") : leader.Owner.NickName);
handler.AppendLiteral("</color>");
stringBuilder17.AppendLine(ref handler);
}
}
}
__instance.m_extraInfo = $"<color=#CCCCCC66><size=70%>{sb}</size></color>";
sb.Clear();
return false;
}
}
private class PlayerHudDistanceModifier : MonoBehaviour
{
private PlayerAgent m_owner;
private static PlayerAgent s_localPlayerAgent;
private readonly float MAX_SIZE = 15f;
private readonly float MIN_SIZE = 1.5f;
private readonly float MAX_DISTANCE = 40f;
private readonly float MIN_DISTANCE = 10f;
private readonly float MIN_ANGLE_ALPHA_VALUE = 0.075f;
private readonly float MAX_ANGLE_VALUE = 40f;
private readonly float MIN_ANGLE_VALUE = 8f;
private void Awake()
{
m_owner = ((Component)this).GetComponent<PlayerAgent>();
}
private void Update()
{
UpdateNavMarkerOnPlayer();
}
private void OnDestroy()
{
//IL_002d: 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)
PlaceNavMarkerOnGO navMarker = m_owner.NavMarker;
if (!((Object)(object)navMarker == (Object)null))
{
NavMarker marker = navMarker.m_marker;
if (!((Object)(object)marker == (Object)null))
{
((Component)marker).transform.localScale = Vector3.one * 0.8412f;
navMarker.m_isInfoDirty = true;
}
}
}
public void UpdateNavMarkerOnPlayer(bool manualUpdate = false)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: 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_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Invalid comparison between Unknown and I4
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Invalid comparison between Unknown and I4
//IL_01d9: 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)
PlaceNavMarkerOnGO navMarker = m_owner.NavMarker;
if ((Object)(object)navMarker == (Object)null)
{
return;
}
NavMarker marker = navMarker.m_marker;
if ((Object)(object)marker == (Object)null)
{
return;
}
if (manualUpdate)
{
navMarker.m_isInfoDirty = true;
}
if ((Object)(object)s_localPlayerAgent == (Object)null)
{
s_localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
((Component)marker).transform.localScale = Vector3.one * 0.8412f;
return;
}
float num = Mathf.Clamp(Mathf.Clamp(Vector3.Distance(((Agent)m_owner).Position, ((Agent)s_localPlayerAgent).Position), MIN_DISTANCE, MAX_DISTANCE) / MAX_DISTANCE, MIN_SIZE, MAX_SIZE);
((Component)marker).transform.localScale = Vector3.one * num;
if (Settings.TransparentWhenAim && (Object)(object)s_localPlayerAgent.Inventory.WieldedItem != (Object)null && s_localPlayerAgent.Inventory.WieldedItem.AimButtonHeld && (int)s_localPlayerAgent.Inventory.WieldedSlot >= 1 && (int)s_localPlayerAgent.Inventory.WieldedSlot <= 3)
{
marker.SetAlpha(MIN_ANGLE_ALPHA_VALUE);
}
else if (Settings.DynamicTrasparency)
{
Vector3 val = ((Agent)m_owner).EyePosition - ((Agent)s_localPlayerAgent).EyePosition;
float num2 = Vector3.Angle(s_localPlayerAgent.FPSCamera.CameraRayDir, val);
num2 = Mathf.Clamp(num2, MIN_ANGLE_VALUE, MAX_ANGLE_VALUE);
float num3 = MIN_ANGLE_VALUE / num2;
marker.SetAlpha(Mathf.Clamp(num3, MIN_ANGLE_ALPHA_VALUE, 1f));
}
else
{
marker.SetAlpha(1f);
}
if (Settings.AlwaysVisible)
{
if (!navMarker.m_extraInfoVisible)
{
navMarker.m_extraInfoVisible = true;
}
}
else if (!navMarker.m_extraInfoVisible)
{
((Component)marker).transform.localScale = Vector3.one * 0.8412f;
}
navMarker.OnPlayerInfoUpdated(true);
}
}
private static RatioColorDeterminer _determinerHealth = new RatioColorDeterminer
{
_colorGrades = new List<RatioColor>
{
new RatioColor(Color.red, 0f),
new RatioColor(Color.red, 0.2f),
new RatioColor(Color.yellow, 0.5f),
new RatioColor(Color.green, 0.8f),
new RatioColor(Color.cyan, 1f)
}
};
private static RatioColorDeterminer _determineAmmoWeaponRelInPack = new RatioColorDeterminer
{
_colorGrades = new List<RatioColor>
{
new RatioColor(Color.red, 0f),
new RatioColor(Color.yellow, 0.5f),
new RatioColor(Color.green, 0.8f),
new RatioColor(Color.cyan, 1f)
}
};
private static RatioColorDeterminer _detemineAmmoResourceRelInPack = new RatioColorDeterminer
{
_colorGrades = new List<RatioColor>
{
new RatioColor(ColorExt.Hex("FF8B47"), 0f),
new RatioColor(Color.yellow, 0.2f),
new RatioColor(Color.green, 0.4f),
new RatioColor(Color.cyan, 1f)
}
};
private static Dictionary<ulong, SentryGunInstance> _sentryGunInstances = new Dictionary<ulong, SentryGunInstance>();
public override string Name => "HUD信息增强";
public override string Description => "使HUD信息更清晰易读";
public override FeatureGroup Group => FeatureGroups.Accessibility;
public static ILocalizationService Localization { get; set; }
[FeatureConfig]
public static CGHUDInfoSettings Settings { get; set; }
public override void Init()
{
ClassInjector.RegisterTypeInIl2Cpp<PlayerHudDistanceModifier>(false);
}
public override void OnEnable()
{
_sentryGunInstances.Clear();
if (Feature.CurrentGameState < 10)
{
return;
}
foreach (SentryGunInstance item in Object.FindObjectsOfType<SentryGunInstance>())
{
PlayerAgent owner = ((Item)item).Owner;
SNet_Player val = ((owner != null) ? owner.Owner : null);
if ((Object)(object)val != (Object)null)
{
_sentryGunInstances[val.Lookup] = item;
}
}
Enumerator<PlayerAgent> enumerator2 = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
while (enumerator2.MoveNext())
{
PlayerAgent current2 = enumerator2.Current;
if (!((Agent)current2).IsLocallyOwned && (Object)(object)((Component)current2).GetComponent<PlayerHudDistanceModifier>() == (Object)null)
{
((Component)current2).gameObject.AddComponent<PlayerHudDistanceModifier>();
}
}
}
public override void OnDisable()
{
foreach (PlayerHudDistanceModifier item in Object.FindObjectsOfType<PlayerHudDistanceModifier>())
{
SharedUtils.SafeDestroy((Component)(object)item);
}
_sentryGunInstances.Clear();
}
public override void OnFeatureSettingChanged(FeatureSetting setting)
{
foreach (PlayerHudDistanceModifier item in Object.FindObjectsOfType<PlayerHudDistanceModifier>())
{
item.UpdateNavMarkerOnPlayer(manualUpdate: true);
}
}
}
}