using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Zichen-ValuablesScanner-1.1.0")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+41d5a9823539e401cb62387afbb6554cda1eb2f2")]
[assembly: AssemblyProduct("Zichen-ValuablesScanner-1.1.0")]
[assembly: AssemblyTitle("Zichen-ValuablesScanner-1.1.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public enum DisplayLanguage
{
中文,
English
}
public enum ScanDisplayMode
{
常显,
按键显示
}
[BepInPlugin("zichen.valuablesscanner", "A.Valuables Scanner", "1.1.0")]
public sealed class WzcValuablesScannerPlugin : BaseUnityPlugin
{
private sealed class EnemyLabelInfo
{
public Enemy Enemy;
public string Name = string.Empty;
public Transform ReferenceTransform;
public float LabelYOffset;
}
private sealed class ScanLabel
{
public Component Target;
public PhysGrabObject PhysGrabObject;
public Renderer[] Renderers = Array.Empty<Renderer>();
public string DisplayName = string.Empty;
public bool IsValuable;
public bool IsItem;
public bool IsCart;
public bool IsLotteryCoinBox;
public bool IsSmallCart;
public string ColorHex = "#62d8ff";
public Vector3 Position;
public string PlainText = string.Empty;
public string RichText = string.Empty;
public int DistanceMeters;
}
public const string PluginGuid = "zichen.valuablesscanner";
public const string PluginVersion = "1.1.0";
public const string PluginName = "A.Valuables Scanner";
private static WzcValuablesScannerPlugin Instance;
private const string InfoSection = "模组信息";
private const string GlobalSection = "A.全局设置";
private const string ScannerSection = "B.价值扫描";
private const string ValuablesSubSection = "B1.贵重品扫描";
private const string ItemsSubSection = "B2.装备武器扫描";
private const string LotterySubSection = "B3.抽奖箱扫描";
private const string CartSubSection = "B4.购物车扫描";
private const string EnemyScannerSection = "C.怪物扫描";
private const string LotteryCoinBoxNameZh = "抽奖箱";
private const string LotteryCoinBoxNameEn = "Lottery Box";
private const float MinimumScanIntervalSeconds = 0.1f;
private const float ContainmentRefreshIntervalSeconds = 0.12f;
private const float LocalPlayerRefreshIntervalSeconds = 1f;
private static readonly FieldInfo ValuableCurrentValueField = typeof(ValuableObject).GetField("dollarValueCurrent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ValuableValueSetField = typeof(ValuableObject).GetField("dollarValueSet", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ValuablePhysGrabObjectField = typeof(ValuableObject).GetField("physGrabObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemNameField = typeof(ItemAttributes).GetField("itemName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemValueField = typeof(ItemAttributes).GetField("value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemPhysGrabObjectField = typeof(ItemAttributes).GetField("physGrabObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemShopItemField = typeof(ItemAttributes).GetField("shopItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemPromptNameField = typeof(ItemAttributes).GetField("promptName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemAssetNameField = typeof(ItemAttributes).GetField("itemAssetName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemInstanceNameField = typeof(ItemAttributes).GetField("instanceName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemTagField = typeof(ItemAttributes).GetField("itemTag", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemTypeField = typeof(ItemAttributes).GetField("itemType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ItemEquippableField = typeof(ItemAttributes).GetField("itemEquippable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabObjectDeadField = typeof(PhysGrabObject).GetField("dead", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabObjectIsHiddenField = typeof(PhysGrabObject).GetField("isHidden", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabObjectPlayerGrabbingField = typeof(PhysGrabObject).GetField("playerGrabbing", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabberGrabbedPhysGrabObjectField = typeof(PhysGrabber).GetField("grabbedPhysGrabObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabberGrabbedField = typeof(PhysGrabber).GetField("grabbed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabberPlayerAvatarField = typeof(PhysGrabber).GetField("playerAvatar", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabCartItemsInCartField = typeof(PhysGrabCart).GetField("itemsInCart", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabCartInCartField = typeof(PhysGrabCart).GetField("physGrabInCart", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabCartIsSmallField = typeof(PhysGrabCart).GetField("isSmallCart", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabInCartObjectsField = typeof(PhysGrabInCart).GetField("inCartObjects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PhysGrabInCartCartObjectPhysGrabObjectField = typeof(PhysGrabInCart).GetNestedType("CartObject", BindingFlags.Public | BindingFlags.NonPublic)?.GetField("physGrabObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo RoundDirectorInstanceField = typeof(RoundDirector).GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo RoundDirectorDollarHaulListField = typeof(RoundDirector).GetField("dollarHaulList", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ValuableDiscoverCustomPhysGrabObjectField = typeof(ValuableDiscoverCustom).GetField("physGrabObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ValuableDiscoverCustomColorCornerField = typeof(ValuableDiscoverCustom).GetField("colorCorner", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ValuableDiscoverCustomColorMiddleField = typeof(ValuableDiscoverCustom).GetField("colorMiddle", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo EnemyParentField = typeof(Enemy).GetField("EnemyParent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo EnemyParentNameField = typeof(EnemyParent).GetField("enemyName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo EnemyParentLocalizedNameField = typeof(EnemyParent).GetField("enemyNameLocalized", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly MethodInfo LocalizedAssetGetStringMethod = typeof(LocalizedAsset).GetMethod("GetLocalizedString", Type.EmptyTypes);
private static readonly FieldInfo EnemyParentSpawnedField = typeof(EnemyParent).GetField("Spawned", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo EnemyHealthField = typeof(Enemy).GetField("Health", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo EnemyHealthDeadField = typeof(EnemyHealth).GetField("dead", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo EnemyCenterTransformField = typeof(Enemy).GetField("CenterTransform", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo EnemyTypeField = typeof(Enemy).GetField("Type", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PlayerIsLocalField = typeof(PlayerAvatar).GetField("isLocal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PlayerTransformField = typeof(PlayerAvatar).GetField("playerTransform", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly MethodInfo ValuableDiscoverMethod = typeof(ValuableObject).GetMethod("Discover", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private readonly List<ScanLabel> labels = new List<ScanLabel>();
private readonly Dictionary<int, GUIStyle> labelStyleCache = new Dictionary<int, GUIStyle>();
private readonly GUIContent labelContent = new GUIContent();
private readonly HashSet<int> seenObjects = new HashSet<int>();
private readonly HashSet<object> cartObjectSet = new HashSet<object>(ReferenceObjectComparer.Instance);
private readonly HashSet<object> haulObjectSet = new HashSet<object>(ReferenceObjectComparer.Instance);
private ConfigEntry<string> moduleNameInfo;
private ConfigEntry<string> moduleVersionInfo;
private ConfigEntry<string> contactInfo;
private ConfigEntry<DisplayLanguage> displayLanguage;
private ConfigEntry<bool> scannerEnabled;
private ConfigEntry<bool> shareScansWithTeam;
private ConfigEntry<bool> showValuables;
private ConfigEntry<bool> showValuableNames;
private ConfigEntry<bool> showValuablePrices;
private ConfigEntry<bool> showValuableDistance;
private ConfigEntry<bool> showItems;
private ConfigEntry<bool> showItemNames;
private ConfigEntry<bool> showItemDistance;
private ConfigEntry<bool> showLotteryCoinBoxes;
private ConfigEntry<bool> showLotteryCoinBoxDistance;
private ConfigEntry<bool> showBigCarts;
private ConfigEntry<bool> showSmallCarts;
private ConfigEntry<bool> showCartDistance;
private ConfigEntry<string> scanKey;
private ConfigEntry<int> scanHoldSeconds;
private ConfigEntry<float> scanIntervalSeconds;
private ConfigEntry<int> scanDistanceMeters;
private ConfigEntry<int> fontSize;
private ConfigEntry<int> farFontShrinkPercent;
private ConfigEntry<bool> enemyOverlayEnabled;
private ConfigEntry<ScanDisplayMode> enemyDisplayMode;
private ConfigEntry<string> enemyToggleKey;
private ConfigEntry<float> enemyUpdateInterval;
private ConfigEntry<int> enemyFontSize;
private ConfigEntry<int> enemyFarFontShrinkPercent;
private ConfigEntry<bool> enemyProximityAutoShowEnabled;
private ConfigEntry<int> enemyProximityAutoShowDistance;
private ConfigEntry<bool> enemyNicknameEnabled;
private ConfigEntry<bool> modEnabled;
private float visibleTimer;
private float scanCooldownTimer;
private int containmentSetFrame = -1;
private float enemyVisibleTimer;
private float enemyRefreshTimer;
private float enemyProximityVisibleTimer;
private float enemyProximityRefreshTimer;
private readonly List<EnemyLabelInfo> enemyLabels = new List<EnemyLabelInfo>();
private readonly HashSet<int> enemiesInsideProximityRange = new HashSet<int>();
private readonly Dictionary<int, float> enemyProximityPopTimers = new Dictionary<int, float>();
private const float ProximityAutoShowLingerSeconds = 5f;
private const float EnemyProximityPopSeconds = 1.2f;
private const float EnemyProximityPopFontMultiplier = 2f;
private const float MinRefreshIntervalSeconds = 0.1f;
private float nextContainmentRefreshTime;
private int cachedLocalPositionFrame = -1;
private Vector3 cachedLocalPosition;
private int cachedCameraFrame = -1;
private Camera cachedCamera;
private float nextLocalPlayerRefreshTime;
private PlayerAvatar cachedLocalPlayer;
private PhysGrabber[] grabberObjectsCache = Array.Empty<PhysGrabber>();
private float nextGrabberRefreshTime;
private KeyCode cachedScanKey = (KeyCode)102;
private string cachedScanKeyText = "f";
private static DisplayLanguage InstanceLanguage
{
get
{
if (!((Object)(object)Instance == (Object)null) && Instance.displayLanguage != null)
{
return Instance.displayLanguage.Value;
}
return DisplayLanguage.中文;
}
}
private void Awake()
{
DetachFromManager();
Instance = this;
MakePluginHostPersistent();
ResetConfigIfVersionChanged();
BindConfig();
UpdateCachedScanKey();
scanKey.SettingChanged += delegate
{
UpdateCachedScanKey();
};
((BaseUnityPlugin)this).Logger.LogInfo((object)"zichen-valuables-scanner loaded.");
}
private void DetachFromManager()
{
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
}
private void BindConfig()
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Expected O, but got Unknown
moduleNameInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "模组名称", "价值扫描器", new ConfigDescription("当前模组的中文名称。此处只是提示,不影响功能。", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 1000,
CustomDrawer = DrawInfo,
ReadOnly = true
}
}));
moduleNameInfo.Value = "价值扫描器";
moduleVersionInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "模组版本号", "1.1.0", new ConfigDescription("当前模组版本号。此处只是提示,不影响功能。", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 990,
CustomDrawer = DrawInfo,
ReadOnly = true
}
}));
moduleVersionInfo.Value = "1.1.0";
contactInfo = ((BaseUnityPlugin)this).Config.Bind<string>("模组信息", "REPO交流QQ群", "824639225", new ConfigDescription("REPO游戏交流、BUG反馈、优化建议、功能请求请加QQ群。此处只是提示,不影响功能。", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 980,
CustomDrawer = DrawInfo,
ReadOnly = true
}
}));
contactInfo.Value = "824639225";
modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("A.全局设置", "模组启用", true, ConfigDescriptionWithOrder("关闭后整个模组所有扫描和显示功能都不生效。默认开启。", 1005));
displayLanguage = ((BaseUnityPlugin)this).Config.Bind<DisplayLanguage>("A.全局设置", "语言/Language", DisplayLanguage.中文, ConfigDescriptionWithOrder("选择扫描标签显示语言。默认中文,English 会显示原始英文名称。", 1000));
enemyNicknameEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("A.全局设置", "敌人名字优化", true, ConfigDescriptionWithOrder("开启后怪物显示社区昵称(如 大眼哥 等)。关闭后显示标准中文名。默认开启。", 995));
scannerEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("B.价值扫描", "启用", true, ConfigDescriptionWithOrder("关闭后整个价值扫描显示都不生效。", 900));
shareScansWithTeam = ((BaseUnityPlugin)this).Config.Bind<bool>("B.价值扫描", "信息共享队友", true, ConfigDescriptionWithOrder("开启后,扫描到的贵重品会走游戏原生发现同步,队友不装这个模组也能收到发现效果。默认开启。", 895));
showValuables = ((BaseUnityPlugin)this).Config.Bind<bool>("B1.贵重品扫描", "启用", true, ConfigDescriptionWithOrder("显示可回收贵重品。", 890));
showValuableNames = ((BaseUnityPlugin)this).Config.Bind<bool>("B1.贵重品扫描", "显示名称", false, ConfigDescriptionWithOrder("开启后贵重品扫描标签显示物品名称。默认关闭。", 889));
showValuablePrices = ((BaseUnityPlugin)this).Config.Bind<bool>("B1.贵重品扫描", "显示价格", true, ConfigDescriptionWithOrder("开启后贵重品扫描标签显示当前价格。默认开启。", 888));
showValuableDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("B1.贵重品扫描", "显示米数", true, ConfigDescriptionWithOrder("开启后贵重品标签显示距离米数。默认开启。", 887));
showItems = ((BaseUnityPlugin)this).Config.Bind<bool>("B2.装备武器扫描", "启用", true, ConfigDescriptionWithOrder("显示枪、近战、血包、手雷等装备/武器。", 880));
showItemNames = ((BaseUnityPlugin)this).Config.Bind<bool>("B2.装备武器扫描", "显示名称", true, ConfigDescriptionWithOrder("开启后装备武器标签显示名称。默认开启。", 879));
showItemDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("B2.装备武器扫描", "显示米数", true, ConfigDescriptionWithOrder("开启后装备武器标签显示距离米数。默认开启。", 878));
showLotteryCoinBoxes = ((BaseUnityPlugin)this).Config.Bind<bool>("B3.抽奖箱扫描", "启用", true, ConfigDescriptionWithOrder("显示关卡中的投币机、硬币宝箱、代币箱和抽奖箱。不同类型用不同颜色区分。默认开启。", 870));
showLotteryCoinBoxDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("B3.抽奖箱扫描", "显示米数", true, ConfigDescriptionWithOrder("开启后抽奖箱标签显示距离米数。默认开启。", 869));
showBigCarts = ((BaseUnityPlugin)this).Config.Bind<bool>("B4.购物车扫描", "显示大购物车", false, ConfigDescriptionWithOrder("开启后扫描时显示大购物车。默认关闭。", 860));
showSmallCarts = ((BaseUnityPlugin)this).Config.Bind<bool>("B4.购物车扫描", "显示小购物车", false, ConfigDescriptionWithOrder("开启后扫描时显示小购物车。默认关闭。", 859));
showCartDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("B4.购物车扫描", "显示米数", true, ConfigDescriptionWithOrder("开启后购物车标签显示距离米数。默认开启。", 858));
scanKey = ((BaseUnityPlugin)this).Config.Bind<string>("B.价值扫描", "扫描按键", "f", ConfigDescriptionWithOrder("按下这个按键后显示附近贵重品和装备。只需要写单个按键,例如 f、g、t。", 870));
scanHoldSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("B.价值扫描", "显示持续秒数", 3, ConfigDescriptionWithOrder("按下扫描按键后,物品价值标签持续显示多少秒。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), 860));
scanIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("B.价值扫描", "扫描间隔/秒", 1f, ConfigDescriptionWithOrder("按下扫描按键后,多少秒内再次按下不会重新显示。最低会限制为0.1秒。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), 850));
scanDistanceMeters = ((BaseUnityPlugin)this).Config.Bind<int>("B.价值扫描", "扫描距离/米", 15, ConfigDescriptionWithOrder("按下扫描按键时,只扫描并显示距离自己多少米以内的物品。默认15米。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 300), 840));
fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("B.价值扫描", "字体大小", 24, ConfigDescriptionWithOrder("局内扫描标签的字体大小。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 48), 830));
farFontShrinkPercent = ((BaseUnityPlugin)this).Config.Bind<int>("B.价值扫描", "远处字体变小/%", 30, ConfigDescriptionWithOrder("距离较远时,文字最多变小多少百分比。默认30表示最远显示为字体大小的70%。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 75), 820));
enemyOverlayEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("C.怪物扫描", "启用", true, ConfigDescriptionWithOrder("关闭后不再显示怪物局内标签。默认开启。", 800));
enemyDisplayMode = ((BaseUnityPlugin)this).Config.Bind<ScanDisplayMode>("C.怪物扫描", "显示方式", ScanDisplayMode.按键显示, ConfigDescriptionWithOrder("常显,或按键后显示一段时间。", 790));
enemyToggleKey = ((BaseUnityPlugin)this).Config.Bind<string>("C.怪物扫描", "显示按键", "f", ConfigDescriptionWithOrder("按键显示模式下,按下后显示怪物标签。可以填写 f、t、y、g、f1、mouse3 等。", 780));
enemyUpdateInterval = ((BaseUnityPlugin)this).Config.Bind<float>("C.怪物扫描", "刷新间隔/秒", 0.5f, ConfigDescriptionWithOrder("每隔多少秒刷新一次怪物标签。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), 760));
enemyFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("C.怪物扫描", "字体大小", 22, ConfigDescriptionWithOrder("怪物标签的字体大小。默认22。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 48), 750));
enemyFarFontShrinkPercent = ((BaseUnityPlugin)this).Config.Bind<int>("C.怪物扫描", "远处字体变小/%", 30, ConfigDescriptionWithOrder("怪物标签距离较远时最多变小多少百分比。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 75), 740));
enemyProximityAutoShowEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("C.怪物扫描", "启用靠近自动显示", true, ConfigDescriptionWithOrder("开启后,只要怪物进入指定距离内,就会临时显示怪物标签;怪物离开范围后5秒恢复原显示方式。", 730));
enemyProximityAutoShowDistance = ((BaseUnityPlugin)this).Config.Bind<int>("C.怪物扫描", "靠近自动显示距离/米", 20, ConfigDescriptionWithOrder("怪物距离你多少米以内时自动临时显示。默认20米。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), 720));
}
private void ResetConfigIfVersionChanged()
{
try
{
string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
string text = ReadConfigPluginVersion(configFilePath);
if (!string.IsNullOrWhiteSpace(text) && !(text == "1.1.0"))
{
ResetConfigFileToDefaults(configFilePath);
((BaseUnityPlugin)this).Logger.LogWarning((object)"Config version changed. Old config was reset to defaults.");
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to reset config by version: " + ex.Message));
}
}
private static string ReadConfigPluginVersion(string configPath)
{
if (!File.Exists(configPath))
{
return null;
}
Match match = Regex.Match(File.ReadAllText(configPath), "(?m)^模组版本号\\s*=\\s*(.+?)\\s*$");
if (!match.Success)
{
return null;
}
return match.Groups[1].Value.Trim();
}
private void ResetConfigFileToDefaults(string configPath)
{
((BaseUnityPlugin)this).Config.Clear();
if (File.Exists(configPath))
{
File.Delete(configPath);
}
((BaseUnityPlugin)this).Config.Reload();
}
private void Update()
{
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (modEnabled != null && !modEnabled.Value)
{
visibleTimer = 0f;
scanCooldownTimer = 0f;
labels.Clear();
enemyLabels.Clear();
ClearEnemyProximityTracking();
enemyVisibleTimer = 0f;
enemyProximityVisibleTimer = 0f;
return;
}
if (scannerEnabled == null || !scannerEnabled.Value)
{
visibleTimer = 0f;
scanCooldownTimer = 0f;
labels.Clear();
return;
}
if (scanCooldownTimer > 0f)
{
scanCooldownTimer = Mathf.Max(0f, scanCooldownTimer - Time.deltaTime);
}
if (Input.GetKeyDown(cachedScanKey))
{
if (scanCooldownTimer > 0f)
{
return;
}
visibleTimer = Mathf.Max(0.1f, (float)((scanHoldSeconds == null) ? 3 : scanHoldSeconds.Value));
scanCooldownTimer = ClampScanInterval((scanIntervalSeconds == null) ? 1f : scanIntervalSeconds.Value);
RefreshLabels();
}
if (visibleTimer <= 0f)
{
labels.Clear();
return;
}
visibleTimer -= Time.deltaTime;
UpdateEnemyOverlayState();
}
private void UpdateEnemyOverlayState()
{
if (enemyOverlayEnabled == null || !enemyOverlayEnabled.Value)
{
enemyLabels.Clear();
ClearEnemyProximityTracking();
enemyVisibleTimer = 0f;
enemyProximityVisibleTimer = 0f;
return;
}
if (enemyDisplayMode.Value == ScanDisplayMode.按键显示 && IsConfiguredKeyDown(enemyToggleKey.Value))
{
enemyVisibleTimer = Mathf.Max(0.1f, (float)((scanHoldSeconds == null) ? 3 : scanHoldSeconds.Value));
}
if (enemyDisplayMode.Value == ScanDisplayMode.按键显示 && enemyVisibleTimer > 0f)
{
enemyVisibleTimer -= Time.deltaTime;
}
bool flag = UpdateEnemyProximityAutoShowState();
UpdateEnemyProximityPopTimers();
if (!(enemyDisplayMode.Value == ScanDisplayMode.常显 || enemyVisibleTimer > 0f || flag))
{
enemyLabels.Clear();
return;
}
enemyRefreshTimer += Time.deltaTime;
float num = Mathf.Max(0.1f, enemyUpdateInterval.Value);
if (enemyRefreshTimer >= num)
{
enemyRefreshTimer = 0f;
RefreshEnemyLabels();
}
}
private bool UpdateEnemyProximityAutoShowState()
{
if (enemyProximityAutoShowEnabled == null || !enemyProximityAutoShowEnabled.Value)
{
enemyProximityVisibleTimer = 0f;
ClearEnemyProximityTracking();
return false;
}
enemyProximityRefreshTimer += Time.deltaTime;
float num = Mathf.Max(0.1f, enemyUpdateInterval.Value);
bool flag = enemiesInsideProximityRange.Count > 0;
if (enemyProximityRefreshTimer >= num)
{
enemyProximityRefreshTimer = 0f;
flag = UpdateEnemiesWithinProximityDistance(enemyProximityAutoShowDistance.Value);
}
if (flag)
{
enemyProximityVisibleTimer = 5f;
return true;
}
if (enemyProximityVisibleTimer > 0f)
{
enemyProximityVisibleTimer -= Time.deltaTime;
return true;
}
ClearEnemyProximityTracking();
return false;
}
private bool UpdateEnemiesWithinProximityDistance(float distance)
{
//IL_0067: 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_006c: 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)
if (!TryGetLocalPosition(out var position))
{
return false;
}
float num = distance * distance;
enemiesInsideProximityRange.Clear();
Enemy[] array = Object.FindObjectsOfType<Enemy>();
foreach (Enemy val in array)
{
if (IsEnemyAliveAndSpawned(val))
{
object? obj = EnemyCenterTransformField?.GetValue(val);
Transform val2 = (Transform)((obj is Transform) ? obj : null);
Vector3 val3 = (((Object)(object)val2 != (Object)null) ? val2.position : ((Component)val).transform.position) - position;
if (((Vector3)(ref val3)).sqrMagnitude <= num)
{
enemiesInsideProximityRange.Add(((Object)val).GetInstanceID());
}
}
}
return enemiesInsideProximityRange.Count > 0;
}
private void UpdateEnemyProximityPopTimers()
{
if (enemyProximityPopTimers.Count == 0)
{
return;
}
List<int> list = null;
foreach (KeyValuePair<int, float> enemyProximityPopTimer in enemyProximityPopTimers)
{
float num = enemyProximityPopTimer.Value - Time.deltaTime;
if (num <= 0f)
{
if (list == null)
{
list = new List<int>();
}
list.Add(enemyProximityPopTimer.Key);
}
else
{
enemyProximityPopTimers[enemyProximityPopTimer.Key] = num;
}
}
if (list == null)
{
return;
}
foreach (int item in list)
{
enemyProximityPopTimers.Remove(item);
}
}
private void ClearEnemyProximityTracking()
{
enemiesInsideProximityRange.Clear();
enemyProximityPopTimers.Clear();
}
private void RefreshEnemyLabels()
{
enemyLabels.Clear();
if (!TryGetLocalPosition(out var localPosition))
{
return;
}
Enemy[] array = Object.FindObjectsOfType<Enemy>();
foreach (Enemy val in array)
{
if (IsEnemyAliveAndSpawned(val) && IsObjectUsable(((Component)val).gameObject))
{
string enemyDisplayName = GetEnemyDisplayName(val);
object? obj = EnemyCenterTransformField?.GetValue(val);
Transform val2 = (Transform)((obj is Transform) ? obj : null);
float enemyLabelYOffset = GetEnemyLabelYOffset(val, val2);
enemyLabels.Add(new EnemyLabelInfo
{
Enemy = val,
Name = enemyDisplayName,
ReferenceTransform = val2,
LabelYOffset = enemyLabelYOffset
});
}
}
enemyLabels.Sort(delegate(EnemyLabelInfo a, EnemyLabelInfo b)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0055: Unknown result type (might be due to invalid IL or missing references)
Transform obj2 = a.ReferenceTransform ?? ((Component)a.Enemy).transform;
Transform val3 = b.ReferenceTransform ?? ((Component)b.Enemy).transform;
Vector3 val4 = obj2.position - localPosition;
float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
val4 = val3.position - localPosition;
float sqrMagnitude2 = ((Vector3)(ref val4)).sqrMagnitude;
return sqrMagnitude.CompareTo(sqrMagnitude2);
});
}
private float GetEnemyLabelYOffset(Enemy enemy, Transform centerTransform)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
float result = 1.1f;
Transform transform = ((Component)enemy).transform;
if ((Object)(object)transform == (Object)null)
{
return result;
}
Renderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Renderer>();
Collider[] componentsInChildren2 = ((Component)transform).GetComponentsInChildren<Collider>();
float num = float.MinValue;
bool flag = false;
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
if (!((Object)(object)val == (Object)null) && val.enabled)
{
Bounds bounds = val.bounds;
float y = ((Bounds)(ref bounds)).max.y;
if (y > num)
{
num = y;
}
flag = true;
}
}
if (!flag)
{
Collider[] array2 = componentsInChildren2;
foreach (Collider val2 in array2)
{
if (!((Object)(object)val2 == (Object)null) && val2.enabled)
{
Bounds bounds2 = val2.bounds;
float y2 = ((Bounds)(ref bounds2)).max.y;
if (y2 > num)
{
num = y2;
}
flag = true;
}
}
}
if (flag)
{
Vector3 val3 = (((Object)(object)centerTransform != (Object)null) ? centerTransform.position : transform.position);
result = Mathf.Max(0.5f, num - val3.y + 0.3f);
}
return result;
}
private static int GetEnemyKey(Enemy enemy)
{
return ((Object)enemy).GetInstanceID();
}
private static bool IsEnemyDrawableFast(Enemy enemy)
{
if ((Object)(object)enemy != (Object)null && (Object)(object)((Component)enemy).gameObject != (Object)null)
{
return ((Component)enemy).gameObject.activeInHierarchy;
}
return false;
}
private bool ShouldLimitEnemyLabelsToProximity()
{
if (enemyProximityAutoShowEnabled != null && enemyProximityAutoShowEnabled.Value && enemyDisplayMode.Value != 0 && enemyVisibleTimer <= 0f)
{
return enemiesInsideProximityRange.Count > 0;
}
return false;
}
private void OnGUI()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
Event current = Event.current;
if ((current != null && (int)current.type != 7) || visibleTimer <= 0f || labels.Count == 0)
{
return;
}
Camera worldCameraCached = GetWorldCameraCached();
if ((Object)(object)worldCameraCached == (Object)null || !TryGetLocalPosition(out var position))
{
return;
}
int num = Mathf.Max(1, (scanDistanceMeters == null) ? 15 : scanDistanceMeters.Value);
if (visibleTimer > 0f && labels.Count > 0)
{
RefreshContainmentSetsForFrame();
for (int num2 = labels.Count - 1; num2 >= 0; num2--)
{
ScanLabel scanLabel = labels[num2];
if (!TryRefreshLabel(scanLabel, position, num))
{
labels.RemoveAt(num2);
}
else
{
int baseFontSize = Mathf.Clamp((fontSize == null) ? 24 : fontSize.Value, 8, 48);
int shrinkPercent = ((farFontShrinkPercent == null) ? 30 : farFontShrinkPercent.Value);
DrawLabel(worldCameraCached, scanLabel.Position, scanLabel.PlainText, scanLabel.RichText, scanLabel.DistanceMeters, num, baseFontSize, shrinkPercent);
}
}
}
DrawEnemyWorldLabels(worldCameraCached, position, num);
}
private void DrawEnemyWorldLabels(Camera camera, Vector3 localPosition, int maxDistance)
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
if (enemyLabels.Count == 0 || (Object)(object)camera == (Object)null)
{
return;
}
bool flag = ShouldLimitEnemyLabelsToProximity();
float num = Mathf.Max(0f, (float)enemyProximityAutoShowDistance.Value);
num *= num;
int num2 = Mathf.Clamp(enemyFontSize.Value, 10, 36);
GetCenteredLabelStyle(num2, shadow: false);
GetCenteredLabelStyle(num2, shadow: true);
for (int i = 0; i < enemyLabels.Count; i++)
{
EnemyLabelInfo enemyLabelInfo = enemyLabels[i];
Enemy enemy = enemyLabelInfo.Enemy;
if (!IsEnemyDrawableFast(enemy))
{
continue;
}
Vector3 val = (((Object)(object)enemyLabelInfo.ReferenceTransform != (Object)null) ? enemyLabelInfo.ReferenceTransform.position : ((Component)enemy).transform.position);
Vector3 val2 = val - localPosition;
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (flag && sqrMagnitude > num)
{
continue;
}
float num3 = ((enemyLabelInfo.LabelYOffset > 0.01f) ? enemyLabelInfo.LabelYOffset : 1.1f);
Vector3 worldPosition = val + Vector3.up * num3;
if (TryWorldToGuiPoint(camera, worldPosition, out var guiPosition))
{
int num4 = Mathf.RoundToInt(Mathf.Sqrt(sqrMagnitude));
string arg = (string.IsNullOrWhiteSpace(enemyLabelInfo.Name) ? GetEnemyDisplayName(enemy) : enemyLabelInfo.Name);
int enemyKey = GetEnemyKey(enemy);
if (flag && sqrMagnitude <= num && !enemiesInsideProximityRange.Contains(enemyKey) && !enemyProximityPopTimers.ContainsKey(enemyKey))
{
enemyProximityPopTimers[enemyKey] = 1.2f;
}
float value;
float num5 = (enemyProximityPopTimers.TryGetValue(enemyKey, out value) ? Mathf.Clamp01(value / 1.2f) : 0f);
int distanceScaledFontSize = GetDistanceScaledFontSize(num2, enemyFarFontShrinkPercent.Value, num4, enemyProximityAutoShowDistance.Value, 36);
float num6 = (float)Mathf.Max(distanceScaledFontSize, num2) * 2f;
int num7 = Mathf.RoundToInt(Mathf.Lerp((float)distanceScaledFontSize, num6, num5));
string text = $"{arg} {num4}m";
string text2 = "<color=#ff3333>" + text + "</color>";
GUIStyle centeredLabelStyle = GetCenteredLabelStyle(num7, shadow: false);
labelContent.text = text;
Vector2 val3 = centeredLabelStyle.CalcSize(labelContent);
GUI.Label(new Rect(guiPosition.x - val3.x / 2f, guiPosition.y - val3.y / 2f, val3.x + 14f, val3.y + 4f), text2, centeredLabelStyle);
}
}
}
private GUIStyle GetCenteredLabelStyle(int fontSize, bool shadow)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//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_0048: Unknown result type (might be due to invalid IL or missing references)
GUIStyle val = new GUIStyle(GUI.skin.label);
val.fontSize = fontSize;
val.fontStyle = (FontStyle)1;
val.alignment = (TextAnchor)4;
val.normal.textColor = (shadow ? Color.black : Color.white);
if (shadow)
{
val.normal.textColor = Color.black;
}
return val;
}
private void DrawLabel(Camera camera, Vector3 position, string plainText, string richText, int distanceMeters, int maxDistance, int baseFontSize, int shrinkPercent)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
if (TryWorldToGuiPoint(camera, position, out var guiPosition))
{
int distanceScaledFontSize = GetDistanceScaledFontSize(baseFontSize, shrinkPercent, distanceMeters, maxDistance, 48);
GUIStyle centeredStyle = GetCenteredStyle(distanceScaledFontSize, shadow: false);
labelContent.text = plainText;
Vector2 val = centeredStyle.CalcSize(labelContent);
float num = Mathf.Clamp(val.x + 18f, 80f, 420f);
float num2 = val.y + 6f;
GUI.Label(new Rect(guiPosition.x - num / 2f, guiPosition.y - num2 / 2f, num, num2), richText, centeredStyle);
}
}
private void RefreshLabels()
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_061d: Unknown result type (might be due to invalid IL or missing references)
//IL_0622: Unknown result type (might be due to invalid IL or missing references)
//IL_0624: Unknown result type (might be due to invalid IL or missing references)
//IL_0626: Unknown result type (might be due to invalid IL or missing references)
//IL_0627: 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_0684: Unknown result type (might be due to invalid IL or missing references)
//IL_0689: Unknown result type (might be due to invalid IL or missing references)
//IL_068b: Unknown result type (might be due to invalid IL or missing references)
//IL_0692: Unknown result type (might be due to invalid IL or missing references)
//IL_069a: Unknown result type (might be due to invalid IL or missing references)
//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0728: Unknown result type (might be due to invalid IL or missing references)
//IL_072a: Unknown result type (might be due to invalid IL or missing references)
//IL_044c: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
//IL_0455: Unknown result type (might be due to invalid IL or missing references)
//IL_0456: Unknown result type (might be due to invalid IL or missing references)
//IL_045b: Unknown result type (might be due to invalid IL or missing references)
//IL_052b: Unknown result type (might be due to invalid IL or missing references)
//IL_052d: Unknown result type (might be due to invalid IL or missing references)
labels.Clear();
seenObjects.Clear();
bool flag = shareScansWithTeam != null && shareScansWithTeam.Value;
if (!TryGetLocalPosition(out var position))
{
return;
}
float num = Mathf.Max(1, (scanDistanceMeters == null) ? 15 : scanDistanceMeters.Value);
float num2 = num * num;
ForceRefreshContainmentSets();
Vector3 val2;
if (showValuables == null || showValuables.Value)
{
ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
foreach (ValuableObject val in array)
{
if (!IsObjectUsable(((Object)(object)val == (Object)null) ? null : ((Component)val).gameObject))
{
continue;
}
object? obj = ValuablePhysGrabObjectField?.GetValue(val);
PhysGrabObject physGrabObject = (PhysGrabObject)((obj is PhysGrabObject) ? obj : null);
if (IsPhysGrabObjectHiddenOrDead(physGrabObject) || IsHeldByLocalPlayer(physGrabObject) || IsObjectInCart((Component)(object)val, physGrabObject) || IsObjectInHaul((Component)(object)val, physGrabObject))
{
continue;
}
Renderer[] usableRenderers = GetUsableRenderers((Component)(object)val);
Vector3 objectCenter = GetObjectCenter(((Component)val).transform, physGrabObject, usableRenderers);
val2 = objectCenter - position;
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (sqrMagnitude > num2)
{
continue;
}
int instanceID = ((Object)val).GetInstanceID();
seenObjects.Add(instanceID);
int distanceMeters = Mathf.RoundToInt(Mathf.Sqrt(sqrMagnitude));
string text = BuildValuableLabelText(TranslateItemName(CleanName(((Object)((Component)val).gameObject).name)), Mathf.RoundToInt(GetValuableCurrentValue(val)), distanceMeters);
if (!string.IsNullOrWhiteSpace(text))
{
labels.Add(new ScanLabel
{
Target = (Component)(object)val,
PhysGrabObject = physGrabObject,
IsValuable = true,
DisplayName = TranslateItemName(CleanName(((Object)((Component)val).gameObject).name)),
Renderers = usableRenderers,
Position = objectCenter,
PlainText = text,
RichText = "<color=#00C832>" + text + "</color>",
DistanceMeters = distanceMeters
});
if (flag)
{
RevealValuableToTeam(val);
}
}
}
}
bool flag2 = showLotteryCoinBoxes != null && showLotteryCoinBoxes.Value;
bool flag3 = (showBigCarts != null && showBigCarts.Value) || (showSmallCarts != null && showSmallCarts.Value);
if ((showItems != null && showItems.Value) || flag3)
{
ItemAttributes[] array2 = Object.FindObjectsOfType<ItemAttributes>();
bool flag4 = default(bool);
foreach (ItemAttributes val3 in array2)
{
if (!IsObjectUsable(((Object)(object)val3 == (Object)null) ? null : ((Component)val3).gameObject) || (Object)(object)((Component)val3).GetComponent<ValuableObject>() != (Object)null)
{
continue;
}
object? obj2 = ItemPhysGrabObjectField?.GetValue(val3);
PhysGrabObject val4 = (PhysGrabObject)((obj2 is PhysGrabObject) ? obj2 : null);
if (IsPhysGrabObjectHiddenOrDead(val4) || IsHeldByLocalPlayer(val4) || IsObjectInCart((Component)(object)val3, val4) || IsObjectInHaul((Component)(object)val3, val4))
{
continue;
}
object obj3 = ItemShopItemField?.GetValue(val3);
int num3;
if (obj3 is bool)
{
flag4 = (bool)obj3;
num3 = 1;
}
else
{
num3 = 0;
}
if (((uint)num3 & (flag4 ? 1u : 0u)) != 0)
{
continue;
}
bool flag5 = IsCartObject((Component)(object)val3, val4);
bool flag6 = false;
if (flag5 && (Object)(object)val4 != (Object)null)
{
PhysGrabCart val5 = ((Component)val4).GetComponent<PhysGrabCart>() ?? ((Component)val4).GetComponentInParent<PhysGrabCart>() ?? ((Component)val4).GetComponentInChildren<PhysGrabCart>();
if ((Object)(object)val5 != (Object)null && PhysGrabCartIsSmallField?.GetValue(val5) is bool flag7)
{
flag6 = flag7;
}
}
if ((flag5 && !flag6 && (showBigCarts == null || !showBigCarts.Value)) || (flag5 && flag6 && (showSmallCarts == null || !showSmallCarts.Value)) || (!flag5 && !ShouldScanItem(val3)) || (!flag5 && (showItems == null || !showItems.Value)))
{
continue;
}
Renderer[] usableRenderers2 = GetUsableRenderers((Component)(object)val3);
Vector3 objectCenter2 = GetObjectCenter(((Component)val3).transform, val4, usableRenderers2);
val2 = objectCenter2 - position;
float sqrMagnitude2 = ((Vector3)(ref val2)).sqrMagnitude;
if (!(sqrMagnitude2 > num2))
{
string text2;
string colorHex;
if (flag5)
{
text2 = ((InstanceLanguage != DisplayLanguage.English) ? (flag6 ? "小购物车" : "大购物车") : (flag6 ? "Small Cart" : "Cart"));
colorHex = "#62d8ff";
}
else
{
text2 = GetItemDisplayName(val3);
colorHex = "#62d8ff";
}
if (!string.IsNullOrWhiteSpace(text2))
{
int distanceMeters2 = Mathf.RoundToInt(Mathf.Sqrt(sqrMagnitude2));
string text3 = BuildItemLabelText(text2, distanceMeters2, isLotteryCoinBox: false, flag5);
labels.Add(new ScanLabel
{
Target = (Component)(object)val3,
PhysGrabObject = val4,
IsItem = true,
IsCart = flag5,
IsSmallCart = flag6,
ColorHex = colorHex,
DisplayName = text2,
Renderers = usableRenderers2,
Position = objectCenter2,
PlainText = text3,
RichText = WrapItemTextColor(text3, colorHex),
DistanceMeters = distanceMeters2
});
}
}
}
}
if (flag2)
{
ValuableDiscoverCustom[] array3 = Object.FindObjectsOfType<ValuableDiscoverCustom>();
foreach (ValuableDiscoverCustom val6 in array3)
{
if ((Object)(object)val6 == (Object)null || !IsObjectUsable(((Component)val6).gameObject) || seenObjects.Contains(((Object)val6).GetInstanceID()))
{
continue;
}
object? obj4 = ValuableDiscoverCustomPhysGrabObjectField?.GetValue(val6);
PhysGrabObject physGrabObject2 = (PhysGrabObject)((obj4 is PhysGrabObject) ? obj4 : null);
if (IsPhysGrabObjectHiddenOrDead(physGrabObject2) || IsHeldByLocalPlayer(physGrabObject2) || IsObjectInCart((Component)(object)val6, physGrabObject2) || IsObjectInHaul((Component)(object)val6, physGrabObject2))
{
continue;
}
Renderer[] usableRenderers3 = GetUsableRenderers((Component)(object)val6);
Vector3 objectCenter3 = GetObjectCenter(((Component)val6).transform, physGrabObject2, usableRenderers3);
val2 = objectCenter3 - position;
float sqrMagnitude3 = ((Vector3)(ref val2)).sqrMagnitude;
if (!(sqrMagnitude3 > num2))
{
int instanceID2 = ((Object)val6).GetInstanceID();
seenObjects.Add(instanceID2);
int distanceMeters3 = Mathf.RoundToInt(Mathf.Sqrt(sqrMagnitude3));
string colorHex2 = ((ValuableDiscoverCustomColorCornerField?.GetValue(val6) is Color val7 && val7.r + val7.g + val7.b > 0.05f) ? ColorUtility.ToHtmlStringRGB(val7) : "FFFFFF");
string text4 = ((InstanceLanguage == DisplayLanguage.English) ? "Lottery Box" : "抽奖箱");
string text5 = BuildItemLabelText(text4, distanceMeters3, isLotteryCoinBox: true);
if (!string.IsNullOrWhiteSpace(text5))
{
labels.Add(new ScanLabel
{
Target = (Component)(object)val6,
PhysGrabObject = physGrabObject2,
IsItem = true,
IsLotteryCoinBox = true,
ColorHex = colorHex2,
DisplayName = text4,
Renderers = usableRenderers3,
Position = objectCenter3,
PlainText = text5,
RichText = WrapItemTextColor(text5, colorHex2),
DistanceMeters = distanceMeters3
});
}
}
}
}
labels.Sort(delegate(ScanLabel a, ScanLabel b)
{
int num4 = a.DistanceMeters.CompareTo(b.DistanceMeters);
return (num4 == 0) ? GetLabelSortPriority(a).CompareTo(GetLabelSortPriority(b)) : num4;
});
}
private static int GetLabelSortPriority(ScanLabel label)
{
if (label.IsValuable)
{
return 0;
}
if (label.IsCart && !label.IsSmallCart)
{
return 3;
}
if (label.IsCart && label.IsSmallCart)
{
return 4;
}
if (label.IsLotteryCoinBox)
{
return 2;
}
return 1;
}
private void RevealValuableToTeam(ValuableObject valuable)
{
if ((Object)(object)valuable == (Object)null)
{
return;
}
try
{
if (!(ValuableDiscoverMethod == null))
{
ParameterInfo[] parameters = ValuableDiscoverMethod.GetParameters();
if (parameters.Length == 1 && parameters[0].ParameterType.IsEnum)
{
object obj = Enum.Parse(parameters[0].ParameterType, "Discover");
ValuableDiscoverMethod.Invoke(valuable, new object[1] { obj });
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Native valuable reveal failed: " + ex.GetType().Name + ": " + ex.Message));
}
}
private static bool IsObjectUsable(GameObject gameObject)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)gameObject != (Object)null && gameObject.activeInHierarchy)
{
Scene scene = gameObject.scene;
return ((Scene)(ref scene)).IsValid();
}
return false;
}
private static bool IsPhysGrabObjectHiddenOrDead(PhysGrabObject physGrabObject)
{
if ((Object)(object)physGrabObject == (Object)null)
{
return false;
}
object obj = PhysGrabObjectDeadField?.GetValue(physGrabObject);
bool flag = default(bool);
int num;
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
if (((uint)num & (flag ? 1u : 0u)) != 0)
{
return true;
}
obj = PhysGrabObjectIsHiddenField?.GetValue(physGrabObject);
bool flag2 = default(bool);
int num2;
if (obj is bool)
{
flag2 = (bool)obj;
num2 = 1;
}
else
{
num2 = 0;
}
return (byte)((uint)num2 & (flag2 ? 1u : 0u)) != 0;
}
private bool IsObjectInCart(Component component, PhysGrabObject physGrabObject)
{
return IsObjectInReferenceSet(component, physGrabObject, cartObjectSet);
}
private bool IsObjectInHaul(Component component, PhysGrabObject physGrabObject)
{
return IsObjectInReferenceSet(component, physGrabObject, haulObjectSet);
}
private static bool IsObjectInReferenceSet(Component component, PhysGrabObject physGrabObject, HashSet<object> set)
{
if (set == null || set.Count == 0)
{
return false;
}
GameObject val = (((Object)(object)component == (Object)null) ? null : component.gameObject);
GameObject val2 = (((Object)(object)physGrabObject == (Object)null) ? null : ((Component)physGrabObject).gameObject);
foreach (object item in set)
{
if (item != null)
{
if (item == component || item == val || item == physGrabObject || item == val2)
{
return true;
}
GameObject objectGameObject = GetObjectGameObject(item);
if ((Object)(object)objectGameObject != (Object)null && (objectGameObject == val || objectGameObject == val2))
{
return true;
}
}
}
return false;
}
private static bool IsCartObject(Component component, PhysGrabObject physGrabObject)
{
if ((Object)(object)component != (Object)null && ((Object)(object)component.GetComponent<PhysGrabCart>() != (Object)null || (Object)(object)component.GetComponentInParent<PhysGrabCart>() != (Object)null || (Object)(object)component.GetComponentInChildren<PhysGrabCart>(false) != (Object)null))
{
return true;
}
if ((Object)(object)physGrabObject != (Object)null)
{
if (!((Object)(object)((Component)physGrabObject).GetComponent<PhysGrabCart>() != (Object)null) && !((Object)(object)((Component)physGrabObject).GetComponentInParent<PhysGrabCart>() != (Object)null))
{
return (Object)(object)((Component)physGrabObject).GetComponentInChildren<PhysGrabCart>(false) != (Object)null;
}
return true;
}
return false;
}
private static bool ShouldScanItem(ItemAttributes item)
{
if ((Object)(object)item == (Object)null)
{
return false;
}
if (ItemEquippableField?.GetValue(item) != null)
{
return true;
}
string text = (((Object)(object)((Component)item).gameObject == (Object)null) ? string.Empty : ((Object)((Component)item).gameObject).name.ToLowerInvariant());
string[] array = new string[22]
{
"weapon", "gun", "melee", "tool", "grenade", "mine", "drone", "tracker", "medkit", "health",
"flashlight", "orb", "upgrade", "cart", "pistol", "shotgun", "revolver", "sword", "bat", "hammer",
"spear", "mace"
};
foreach (string value in array)
{
if (text.Contains(value))
{
return true;
}
}
return false;
}
private bool TryRefreshLabel(ScanLabel label, Vector3 localPosition, float maxDistance)
{
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
if (label == null || (Object)(object)label.Target == (Object)null || !IsObjectUsable(label.Target.gameObject))
{
return false;
}
PhysGrabObject physGrabObject = label.PhysGrabObject;
if (IsPhysGrabObjectHiddenOrDead(physGrabObject) || IsHeldByLocalPlayer(physGrabObject) || IsObjectInCart(label.Target, physGrabObject) || IsObjectInHaul(label.Target, physGrabObject))
{
return false;
}
if (label.IsCart && !label.IsSmallCart && (showBigCarts == null || !showBigCarts.Value))
{
return false;
}
if (label.IsCart && label.IsSmallCart && (showSmallCarts == null || !showSmallCarts.Value))
{
return false;
}
if (label.IsLotteryCoinBox && (showLotteryCoinBoxes == null || !showLotteryCoinBoxes.Value))
{
return false;
}
Vector3 objectCenter = GetObjectCenter(label.Target.transform, physGrabObject, label.Renderers);
Vector3 val = objectCenter - localPosition;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
if (sqrMagnitude > maxDistance * maxDistance)
{
return false;
}
int distanceMeters = Mathf.RoundToInt(Mathf.Sqrt(sqrMagnitude));
if (label.IsValuable)
{
Component target = label.Target;
ValuableObject val2 = (ValuableObject)(object)((target is ValuableObject) ? target : null);
if (val2 != null)
{
string text = BuildValuableLabelText(label.DisplayName, Mathf.RoundToInt(GetValuableCurrentValue(val2)), distanceMeters);
if (string.IsNullOrWhiteSpace(text))
{
return false;
}
label.PlainText = text;
label.RichText = "<color=#00C832>" + text + "</color>";
goto IL_01b0;
}
}
if (label.IsItem)
{
string text2 = BuildItemLabelText(label.DisplayName, distanceMeters, label.IsLotteryCoinBox, label.IsCart);
if (string.IsNullOrWhiteSpace(text2))
{
return false;
}
label.PlainText = text2;
label.RichText = WrapItemTextColor(text2, label.ColorHex);
}
goto IL_01b0;
IL_01b0:
label.Position = objectCenter;
label.DistanceMeters = distanceMeters;
return true;
}
private static Renderer[] GetUsableRenderers(Component root)
{
if (!((Object)(object)root == (Object)null))
{
return root.GetComponentsInChildren<Renderer>(false);
}
return Array.Empty<Renderer>();
}
private bool IsHeldByLocalPlayer(PhysGrabObject physGrabObject)
{
if ((Object)(object)physGrabObject == (Object)null)
{
return false;
}
PlayerAvatar localPlayerCached = GetLocalPlayerCached();
if ((Object)(object)localPlayerCached == (Object)null)
{
return false;
}
if (PhysGrabObjectPlayerGrabbingField?.GetValue(physGrabObject) is IEnumerable enumerable)
{
foreach (object item in enumerable)
{
if (IsLocalGrabberObject(item, localPlayerCached))
{
return true;
}
}
}
PhysGrabber[] grabberObjectsCached = GetGrabberObjectsCached();
foreach (PhysGrabber val in grabberObjectsCached)
{
if (!((Object)(object)val == (Object)null) && PhysGrabberGrabbedPhysGrabObjectField?.GetValue(val) == physGrabObject)
{
object obj = PhysGrabberGrabbedField?.GetValue(val);
if ((!(obj is bool) || (bool)obj) && IsLocalGrabberObject(val, localPlayerCached))
{
return true;
}
}
}
return false;
}
private PhysGrabber[] GetGrabberObjectsCached()
{
if (grabberObjectsCache != null && Time.unscaledTime < nextGrabberRefreshTime)
{
return grabberObjectsCache;
}
grabberObjectsCache = Object.FindObjectsOfType<PhysGrabber>(true) ?? Array.Empty<PhysGrabber>();
nextGrabberRefreshTime = Time.unscaledTime + 0.12f;
return grabberObjectsCache;
}
private static bool IsLocalGrabberObject(object grabberObject, PlayerAvatar localPlayer)
{
if (grabberObject == null || (Object)(object)localPlayer == (Object)null)
{
return false;
}
if (grabberObject == localPlayer)
{
return true;
}
Component val = (Component)((grabberObject is Component) ? grabberObject : null);
if (val != null && (val.GetComponentInParent<PlayerAvatar>() == localPlayer || val.GetComponentInChildren<PlayerAvatar>(true) == localPlayer))
{
return true;
}
PhysGrabber val2 = (PhysGrabber)((grabberObject is PhysGrabber) ? grabberObject : null);
if (val2 != null && PhysGrabberPlayerAvatarField?.GetValue(val2) == localPlayer)
{
return true;
}
return grabberObject.GetType().GetField("playerAvatar", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(grabberObject) == localPlayer;
}
private static Vector3 GetObjectCenter(Transform fallback, PhysGrabObject physGrabObject)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return GetObjectCenter(fallback, physGrabObject, null);
}
private static Vector3 GetObjectCenter(Transform fallback, PhysGrabObject physGrabObject, Renderer[] renderers)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_0039: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = (((Object)(object)physGrabObject != (Object)null) ? ((Component)physGrabObject).transform.position : (((Object)(object)fallback == (Object)null) ? Vector3.zero : fallback.position));
if (TryGetVisualBoundsCenter((Component)(object)fallback, val, renderers, out var center))
{
return center;
}
return val;
}
private static bool TryGetVisualBoundsCenter(Component root, Vector3 anchor, out Vector3 center)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return TryGetVisualBoundsCenter(root, anchor, null, out center);
}
private static bool TryGetVisualBoundsCenter(Component root, Vector3 anchor, Renderer[] cachedRenderers, out Vector3 center)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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_00af: Unknown result type (might be due to invalid IL or missing references)
center = Vector3.zero;
if ((Object)(object)root == (Object)null)
{
return false;
}
Bounds val = default(Bounds);
bool flag = false;
Renderer[] array = cachedRenderers ?? GetUsableRenderers(root);
foreach (Renderer val2 in array)
{
if ((Object)(object)val2 == (Object)null || !val2.enabled)
{
continue;
}
Bounds bounds = val2.bounds;
Vector3 val3 = ((Bounds)(ref bounds)).size;
if (((Vector3)(ref val3)).sqrMagnitude <= 0.0001f)
{
continue;
}
val3 = ((Bounds)(ref bounds)).extents;
float num = Mathf.Max(1.5f, ((Vector3)(ref val3)).magnitude * 4f);
val3 = ((Bounds)(ref bounds)).center - anchor;
if (!(((Vector3)(ref val3)).sqrMagnitude > num * num))
{
if (!flag)
{
val = bounds;
flag = true;
}
else
{
((Bounds)(ref val)).Encapsulate(bounds);
}
}
}
if (!flag)
{
return false;
}
center = ((Bounds)(ref val)).center;
return true;
}
private static bool TryGetBoundsCenter(Component root, out Vector3 center)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
center = Vector3.zero;
if ((Object)(object)root == (Object)null)
{
return false;
}
Bounds val = default(Bounds);
bool flag = false;
Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(false);
foreach (Renderer val2 in componentsInChildren)
{
if (!((Object)(object)val2 == (Object)null) && val2.enabled)
{
if (!flag)
{
val = val2.bounds;
flag = true;
}
else
{
((Bounds)(ref val)).Encapsulate(val2.bounds);
}
}
}
if (!flag)
{
Collider[] componentsInChildren2 = root.GetComponentsInChildren<Collider>(false);
foreach (Collider val3 in componentsInChildren2)
{
if (!((Object)(object)val3 == (Object)null) && val3.enabled)
{
if (!flag)
{
val = val3.bounds;
flag = true;
}
else
{
((Bounds)(ref val)).Encapsulate(val3.bounds);
}
}
}
}
if (!flag)
{
return false;
}
center = ((Bounds)(ref val)).center;
return true;
}
private static void FillCartObjectSet(HashSet<object> result)
{
result.Clear();
PhysGrabCart[] array = Object.FindObjectsOfType<PhysGrabCart>();
foreach (PhysGrabCart val in array)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
AddEnumerableObjects(result, PhysGrabCartItemsInCartField?.GetValue(val));
object obj = PhysGrabCartInCartField?.GetValue(val);
if (!(((obj == null) ? null : PhysGrabInCartObjectsField?.GetValue(obj)) is IEnumerable enumerable))
{
continue;
}
foreach (object item in enumerable)
{
object obj2 = PhysGrabInCartCartObjectPhysGrabObjectField?.GetValue(item);
if (obj2 != null)
{
result.Add(obj2);
}
}
}
}
private void RefreshContainmentSetsForFrame()
{
if (containmentSetFrame != Time.frameCount)
{
containmentSetFrame = Time.frameCount;
if (!(Time.unscaledTime < nextContainmentRefreshTime))
{
nextContainmentRefreshTime = Time.unscaledTime + 0.12f;
FillCartAndHaulObjectSets();
}
}
}
private void ForceRefreshContainmentSets()
{
containmentSetFrame = Time.frameCount;
nextContainmentRefreshTime = Time.unscaledTime + 0.12f;
FillCartAndHaulObjectSets();
}
private void FillCartAndHaulObjectSets()
{
FillCartObjectSet(cartObjectSet);
FillDollarHaulObjectSet(haulObjectSet);
}
private static void FillDollarHaulObjectSet(HashSet<object> result)
{
result.Clear();
object obj = RoundDirectorInstanceField?.GetValue(null);
object rawList = ((obj == null) ? null : RoundDirectorDollarHaulListField?.GetValue(obj));
AddEnumerableObjects(result, rawList);
}
private static void AddEnumerableObjects(HashSet<object> result, object rawList)
{
if (!(rawList is IEnumerable enumerable))
{
return;
}
foreach (object item in enumerable)
{
if (item != null)
{
result.Add(item);
}
}
}
private static GameObject GetObjectGameObject(object value)
{
GameObject val = (GameObject)((value is GameObject) ? value : null);
if (val != null)
{
return val;
}
Component val2 = (Component)((value is Component) ? value : null);
if (val2 != null)
{
return val2.gameObject;
}
return null;
}
private static float GetValuableCurrentValue(ValuableObject valuable)
{
if ((Object)(object)valuable == (Object)null)
{
return 0f;
}
object obj = ValuableValueSetField?.GetValue(valuable);
if (obj is bool && !(bool)obj)
{
return 0f;
}
if (ValuableCurrentValueField?.GetValue(valuable) is float num)
{
return Mathf.Max(0f, num);
}
return 0f;
}
private static string GetItemDisplayName(ItemAttributes item)
{
string[] array = new string[6]
{
ReadTrimmedString(ItemNameField?.GetValue(item)),
ReadTrimmedString(ItemPromptNameField?.GetValue(item)),
ReadTrimmedString(ItemAssetNameField?.GetValue(item)),
ReadTrimmedString(ItemInstanceNameField?.GetValue(item)),
ReadTrimmedString(ItemTagField?.GetValue(item)),
CleanName(((Object)(object)item == (Object)null) ? string.Empty : ((Object)((Component)item).gameObject).name)
};
foreach (string text in array)
{
if (!string.IsNullOrWhiteSpace(text))
{
return TranslateItemName(text);
}
}
return TranslateItemName(string.Empty);
}
private static string ReadTrimmedString(object value)
{
if (value == null)
{
return string.Empty;
}
string text = (value as string) ?? value.ToString();
if (!string.IsNullOrWhiteSpace(text))
{
return text.Trim();
}
return string.Empty;
}
private static string TranslateItemName(string rawName)
{
string text = CleanName(rawName);
rawName = ItemNameLocalizer.CleanDisplayName(text);
if (string.IsNullOrWhiteSpace(rawName))
{
rawName = (string.IsNullOrWhiteSpace(text) ? "未知物品" : text);
}
if (InstanceLanguage == DisplayLanguage.English)
{
return rawName;
}
return ItemNameLocalizer.Translate(rawName);
}
private static string CleanName(string rawName)
{
if (string.IsNullOrWhiteSpace(rawName))
{
return "未知物品";
}
string input = rawName.Replace("(Clone)", string.Empty).Trim();
input = Regex.Replace(input, "\\s+", " ");
if (!string.IsNullOrWhiteSpace(input))
{
return input;
}
return "未知物品";
}
private string GetEnemyDisplayName(Enemy enemy)
{
if ((Object)(object)enemy == (Object)null)
{
return "未知怪物";
}
bool useNicknames = InstanceLanguage == DisplayLanguage.中文 && enemyNicknameEnabled != null && enemyNicknameEnabled.Value;
object obj = EnemyParentField?.GetValue(enemy);
if (obj != null)
{
object obj2 = EnemyParentLocalizedNameField?.GetValue(obj);
if (obj2 != null)
{
string text = LocalizedAssetGetStringMethod?.Invoke(obj2, null) as string;
if (!string.IsNullOrWhiteSpace(text) && text != "ENM")
{
return EnemyNameLocalizer.Translate(text, InstanceLanguage, useNicknames);
}
}
object obj3 = EnemyParentNameField?.GetValue(obj);
if (obj3 != null)
{
string text2 = obj3.ToString()?.Trim();
if (!string.IsNullOrWhiteSpace(text2) && text2 != "ENM")
{
return EnemyNameLocalizer.Translate(text2, InstanceLanguage, useNicknames);
}
}
}
object obj4 = EnemyTypeField?.GetValue(enemy);
if (obj4 != null)
{
string text3 = obj4.ToString();
if (!string.IsNullOrWhiteSpace(text3))
{
return EnemyNameLocalizer.Translate(text3, InstanceLanguage, useNicknames);
}
}
string text4 = CleanName(((Object)(object)((Component)enemy).gameObject == (Object)null) ? string.Empty : ((Object)((Component)enemy).gameObject).name);
if (!string.IsNullOrWhiteSpace(text4))
{
return text4;
}
return "未知怪物";
}
private static bool IsEnemyAliveAndSpawned(Enemy enemy)
{
if ((Object)(object)enemy == (Object)null || (Object)(object)((Component)enemy).gameObject == (Object)null || !((Component)enemy).gameObject.activeInHierarchy)
{
return false;
}
object obj = EnemyHealthField?.GetValue(enemy);
if (obj != null)
{
object obj2 = EnemyHealthDeadField?.GetValue(obj);
bool flag = default(bool);
int num;
if (obj2 is bool)
{
flag = (bool)obj2;
num = 1;
}
else
{
num = 0;
}
if (((uint)num & (flag ? 1u : 0u)) != 0)
{
return false;
}
}
object obj3 = EnemyParentField?.GetValue(enemy);
if (obj3 != null)
{
object obj4 = EnemyParentSpawnedField?.GetValue(obj3);
if (obj4 is bool && !(bool)obj4)
{
return false;
}
}
return true;
}
private static string FormatMoney(int value)
{
return Math.Max(0, value).ToString("N0").Replace(".", ",");
}
private string BuildValuableLabelText(string name, int value, int distanceMeters)
{
List<string> list = new List<string>(3);
if (showValuableNames == null || showValuableNames.Value)
{
list.Add(string.IsNullOrWhiteSpace(name) ? "Unknown" : name.Trim());
}
if (showValuablePrices == null || showValuablePrices.Value)
{
list.Add("$" + FormatMoney(value));
}
if (showValuableDistance == null || showValuableDistance.Value)
{
list.Add($"{Mathf.Max(0, distanceMeters)}m");
}
return string.Join(" ", list);
}
private string BuildItemLabelText(string name, int distanceMeters, bool isLotteryCoinBox = false, bool isCart = false)
{
if (string.IsNullOrWhiteSpace(name))
{
return string.Empty;
}
if (isLotteryCoinBox ? (showLotteryCoinBoxDistance == null || showLotteryCoinBoxDistance.Value) : ((!isCart) ? (showItemDistance == null || showItemDistance.Value) : (showCartDistance == null || showCartDistance.Value)))
{
return $"{name.Trim()} {Mathf.Max(0, distanceMeters)}m";
}
return name.Trim();
}
private static string WrapItemTextColor(string text, string colorHex)
{
return "<color=" + colorHex + ">" + text + "</color>";
}
private bool TryGetLocalPosition(out Vector3 position)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
if (cachedLocalPositionFrame == Time.frameCount)
{
position = cachedLocalPosition;
return true;
}
PlayerAvatar localPlayerCached = GetLocalPlayerCached();
if ((Object)(object)localPlayerCached != (Object)null)
{
object? obj = PlayerTransformField?.GetValue(localPlayerCached);
Transform val = (Transform)((obj is Transform) ? obj : null);
position = (((Object)(object)val == (Object)null) ? ((Component)localPlayerCached).transform.position : val.position);
cachedLocalPosition = position;
cachedLocalPositionFrame = Time.frameCount;
return true;
}
Camera worldCameraCached = GetWorldCameraCached();
if ((Object)(object)worldCameraCached != (Object)null)
{
position = ((Component)worldCameraCached).transform.position;
cachedLocalPosition = position;
cachedLocalPositionFrame = Time.frameCount;
return true;
}
position = Vector3.zero;
return false;
}
private PlayerAvatar GetLocalPlayerCached()
{
if ((Object)(object)cachedLocalPlayer != (Object)null && (Object)(object)((Component)cachedLocalPlayer).gameObject != (Object)null && ((Component)cachedLocalPlayer).gameObject.activeInHierarchy && Time.unscaledTime < nextLocalPlayerRefreshTime)
{
return cachedLocalPlayer;
}
cachedLocalPlayer = GetLocalPlayer();
nextLocalPlayerRefreshTime = Time.unscaledTime + 1f;
return cachedLocalPlayer;
}
private static PlayerAvatar GetLocalPlayer()
{
PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
PlayerAvatar[] array2 = array;
bool flag = default(bool);
foreach (PlayerAvatar val in array2)
{
if (!((Object)(object)val == (Object)null))
{
object obj = PlayerIsLocalField?.GetValue(val);
int num;
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
if (((uint)num & (flag ? 1u : 0u)) != 0)
{
return val;
}
}
}
if (array.Length == 0)
{
return null;
}
return array[0];
}
private static Camera GetWorldCamera()
{
return Camera.main ?? Object.FindObjectOfType<Camera>();
}
private Camera GetWorldCameraCached()
{
if (cachedCameraFrame == Time.frameCount && (Object)(object)cachedCamera != (Object)null)
{
return cachedCamera;
}
cachedCameraFrame = Time.frameCount;
cachedCamera = GetWorldCamera();
return cachedCamera;
}
private static bool TryWorldToGuiPoint(Camera camera, Vector3 worldPosition, out Vector2 guiPosition)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
guiPosition = Vector2.zero;
if ((Object)(object)camera == (Object)null)
{
return false;
}
Vector3 val = camera.WorldToScreenPoint(worldPosition);
if (val.z <= 0f)
{
return false;
}
float num = ((camera.pixelWidth > 0) ? camera.pixelWidth : Screen.width);
float num2 = ((camera.pixelHeight > 0) ? camera.pixelHeight : Screen.height);
if ((Object)(object)camera.targetTexture != (Object)null)
{
num = Mathf.Max(1, ((Texture)camera.targetTexture).width);
num2 = Mathf.Max(1, ((Texture)camera.targetTexture).height);
}
float num3 = val.x * ((float)Screen.width / Mathf.Max(1f, num));
float num4 = val.y * ((float)Screen.height / Mathf.Max(1f, num2));
guiPosition = new Vector2(num3, (float)Screen.height - num4);
return true;
}
private GUIStyle GetCenteredStyle(int size, bool shadow)
{
//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_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0072: 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)
Dictionary<int, GUIStyle> dictionary = labelStyleCache;
if (dictionary.TryGetValue(size, out var value))
{
return value;
}
GUIStyle val = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
richText = true,
fontSize = size,
fontStyle = (FontStyle)1,
wordWrap = false,
clipping = (TextClipping)0
};
val.normal.textColor = (Color)(shadow ? new Color(0f, 0f, 0f, 0.88f) : Color.white);
dictionary[size] = val;
return val;
}
private static int GetDistanceScaledFontSize(int baseSize, int shrinkPercent, float distance, float maxDistance, int maxSize)
{
baseSize = Mathf.Clamp(baseSize, 8, maxSize);
shrinkPercent = Mathf.Clamp(shrinkPercent, 0, 75);
if (maxDistance <= 0.1f || shrinkPercent <= 0)
{
return baseSize;
}
float num = Mathf.Clamp01(distance / maxDistance);
float num2 = 1f - (float)shrinkPercent / 100f;
float num3 = Mathf.Lerp(1f, num2, num);
return Mathf.Clamp(Mathf.RoundToInt((float)baseSize * num3), 8, maxSize);
}
private void UpdateCachedScanKey()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
cachedScanKeyText = SanitizeKeyName((scanKey == null) ? "f" : scanKey.Value);
if (!Enum.TryParse<KeyCode>(cachedScanKeyText, ignoreCase: true, out cachedScanKey))
{
cachedScanKey = (KeyCode)102;
cachedScanKeyText = "f";
}
if (scanKey != null && scanKey.Value != cachedScanKeyText)
{
scanKey.Value = cachedScanKeyText;
}
}
private static string SanitizeKeyName(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
return "f";
}
string text = value.Trim();
if (text.EndsWith("键", StringComparison.OrdinalIgnoreCase))
{
text = text.Substring(0, text.Length - 1);
}
return text.Trim().ToLowerInvariant();
}
private static bool IsConfiguredKeyDown(string keyName)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrWhiteSpace(keyName))
{
return false;
}
if (Enum.TryParse<KeyCode>(SanitizeKeyName(keyName), ignoreCase: true, out KeyCode result))
{
return Input.GetKey(result);
}
return false;
}
private static float ClampScanInterval(float value)
{
return Mathf.Clamp(value, 0.1f, 5f);
}
private void MakePluginHostPersistent()
{
try
{
((Component)this).transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to mark plugin host persistent: " + ex.GetType().Name + ": " + ex.Message));
}
}
private static ConfigDescription ConfigDescriptionWithOrder(string description, int order)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
return new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = order
}
});
}
private static ConfigDescription ConfigDescriptionWithOrder(string description, AcceptableValueBase acceptableValues, int order)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
return new ConfigDescription(description, acceptableValues, new object[1]
{
new ConfigurationManagerAttributes
{
Order = order
}
});
}
private static void DrawInfo(ConfigEntryBase entry)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(entry.Definition.Key, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
GUILayout.Label(entry.BoxedValue?.ToString() ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
GUILayout.EndHorizontal();
}
}
internal sealed class ReferenceObjectComparer : IEqualityComparer<object>
{
public static readonly ReferenceObjectComparer Instance = new ReferenceObjectComparer();
public new bool Equals(object x, object y)
{
return x == y;
}
public int GetHashCode(object obj)
{
if (obj != null)
{
return RuntimeHelpers.GetHashCode(obj);
}
return 0;
}
}
internal static class EnemyNameLocalizer
{
private static readonly Dictionary<string, string> NameMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
["Animal"] = "蟑螂",
["Enemy Animal"] = "蟑螂",
["Apex Predator"] = "邪恶鸭子",
["Bang"] = "炸弹骷髅",
["Banger"] = "炸弹骷髅",
["Enemy Bang"] = "炸弹骷髅",
["Baby"] = "扔东西小孩",
["Beamer"] = "激光小丑",
["Enemy Beamer"] = "激光小丑",
["Bella"] = "三轮车",
["Birthday Boy"] = "生日男孩",
["Enemy Birthday Boy"] = "生日男孩",
["Bomb Thrower"] = "疯狂厨师青蛙",
["Enemy Bomb Thrower"] = "疯狂厨师青蛙",
["Bowtie"] = "尖叫大白",
["Enemy Bowtie"] = "尖叫大白",
["Ceiling Eye"] = "邪恶大眼",
["Enemy Ceiling Eye"] = "邪恶大眼",
["Chef"] = "疯狂厨师青蛙",
["Cleanup Crew"] = "清洁工",
["Clown"] = "激光小丑",
["Dog"] = "小狗",
["Elsa"] = "小狗",
["Enemy Elsa"] = "小狗",
["Duck"] = "邪恶鸭子",
["Enemy Duck"] = "邪恶鸭子",
["Floater"] = "外星人",
["Enemy Floater"] = "外星人",
["Frog"] = "疯狂厨师青蛙",
["Gambit"] = "赌盘怪",
["Gnome"] = "红帽子侏儒",
["Gnomes"] = "红帽子侏儒",
["Enemy Gnome"] = "红帽子侏儒",
["Head"] = "咬人骷髅头",
["Enemy Head"] = "咬人骷髅头",
["Head Grabber"] = "抢头怪",
["Enemy Head Grabber"] = "抢头怪",
["Headgrab"] = "抢头怪",
["Headman"] = "咬人骷髅头",
["Heart Hugger"] = "爱心花",
["Enemy Heart Hugger"] = "爱心花",
["Hidden"] = "隐身怪",
["Enemy Hidden"] = "隐身怪",
["Hunter"] = "猎人",
["Huntsman"] = "猎人",
["Enemy Hunter"] = "猎人",
["Loom"] = "拍手女",
["Mentalist"] = "外星人",
["Oogly"] = "绿灯怪",
["Enemy Oogly"] = "绿灯怪",
["Peeper"] = "邪恶大眼",
["Peeper Ceiling Eye"] = "邪恶大眼",
["Reaper"] = "电锯小丑",
["Robe"] = "长袍无脸男",
["Enemy Robe"] = "长袍无脸男",
["Rugrat"] = "熊孩子",
["Runner"] = "电锯小丑",
["Enemy Runner"] = "电锯小丑",
["Shadow"] = "拍手女",
["Enemy Shadow"] = "拍手女",
["Shadow Child"] = "娃娃脸小孩",
["Slow Mouth"] = "呕吐怪",
["Enemy Slow Mouth"] = "呕吐怪",
["Slow Walker"] = "大锤版钟馗",
["Enemy Slow Walker"] = "大锤版钟馗",
["Spewer"] = "呕吐怪",
["Spinny"] = "赌盘怪",
["Enemy Spinny"] = "赌盘怪",
["Thin Man"] = "娃娃脸小孩",
["Enemy Thin Man"] = "娃娃脸小孩",
["Tick"] = "吸血虫",
["Enemy Tick"] = "吸血虫",
["Tricycle"] = "三轮车",
["Enemy Tricycle"] = "三轮车",
["Trudge"] = "大锤版钟馗",
["Tumbler"] = "疯狂厨师青蛙",
["Enemy Tumbler"] = "疯狂厨师青蛙",
["Upscream"] = "尖叫",
["Enemy Upscream"] = "尖叫",
["Valuable Thrower"] = "熊孩子",
["Enemy Valuable Thrower"] = "熊孩子"
};
private static readonly Dictionary<string, string> NicknameMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
["Animal"] = "小六子",
["Enemy Animal"] = "小六子",
["Dog"] = "摸摸小狗",
["Elsa"] = "摸摸小狗",
["Enemy Elsa"] = "摸摸小狗"
};
private static readonly Dictionary<string, string> ChineseNicknameMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
["蟑螂"] = "小六子",
["邪恶鸭子"] = "暴走鸭",
["炸弹骷髅"] = "东方快递",
["扔东西小孩"] = "败家小子",
["激光小丑"] = "激光哥",
["三轮车"] = "鬼火少年",
["生日男孩"] = "气球哥",
["疯狂厨师青蛙"] = "青蛙厨神",
["尖叫大白"] = "白色电风扇",
["邪恶大眼"] = "大眼哥",
["清洁工"] = "卫生委员",
["小狗"] = "摸摸小狗",
["外星人"] = "苹果哥",
["赌盘怪"] = "转转乐",
["红帽子侏儒"] = "地精矿工",
["咬人骷髅头"] = "大头鬼",
["抢头怪"] = "抢头哥",
["爱心花"] = "心动花花",
["隐身怪"] = "隐身老六",
["猎人"] = "男枪",
["拍手女"] = "老奶奶",
["绿灯怪"] = "夜店绿苍蝇",
["电锯小丑"] = "双刀妹",
["长袍无脸男"] = "无脸鬼手男",
["熊孩子"] = "败家小子",
["娃娃脸小孩"] = "末影人",
["呕吐怪"] = "口水哥",
["大锤版钟馗"] = "大锤哥",
["吸血虫"] = "面包虫",
["尖叫"] = "尖叫鸡"
};
public static string Translate(string rawName, DisplayLanguage language, bool useNicknames)
{
if (string.IsNullOrWhiteSpace(rawName))
{
return string.Empty;
}
string text = rawName.Trim();
if (language == DisplayLanguage.English)
{
return NormalizeEnglishName(text);
}
Dictionary<string, string> activeMap = (useNicknames ? NicknameMap : NameMap);
if (TryGetName(activeMap, text, out var translated))
{
return translated;
}
string text2 = NormalizeKey(text);
if (TryGetName(activeMap, text2, out translated))
{
return translated;
}
string text3 = SimplifyEnemyComponentName(text2);
if (!string.Equals(text3, text2, StringComparison.OrdinalIgnoreCase) && TryGetName(activeMap, text3, out translated))
{
return translated;
}
return text;
}
private static bool TryGetName(Dictionary<string, string> activeMap, string key, out string translated)
{
if (activeMap.TryGetValue(key, out translated))
{
return true;
}
if (activeMap != NameMap && NameMap.TryGetValue(key, out translated))
{
if (ChineseNicknameMap.TryGetValue(translated, out var value))
{
translated = value;
}
return true;
}
translated = null;
return false;
}
private static string NormalizeEnglishName(string rawName)
{
string text = NormalizeKey(rawName);
string text2 = SimplifyEnemyComponentName(text);
if (!string.IsNullOrWhiteSpace(text2))
{
return text2;
}
return text;
}
private static string NormalizeKey(string rawName)
{
return Regex.Replace(Regex.Replace(Regex.Replace(rawName.Replace("(Clone)", string.Empty).Replace("Enemy Group - ", string.Empty).Replace("Enemy - ", string.Empty)
.Replace("_", " ")
.Replace("-", " ")
.Trim(), "(?<=[a-z])(?=[A-Z])", " "), "^Enemy\\s+", string.Empty, RegexOptions.IgnoreCase), "\\s+", " ").Trim();
}
private static string SimplifyEnemyComponentName(string cleaned)
{
if (string.IsNullOrWhiteSpace(cleaned))
{
return string.Empty;
}
string text = Regex.Replace(cleaned, "\\b(Anim|Animation System|Always Active|Attaching|Bot Tilt|Bomb|Camera Visuals|Catch Cutscene|Chase Offset|Controller|Cute Face|Director|Explosion|Eye|Eye Idle|Eye Target|Eye Tilt|Eye Tremble|Float|Fuse|Gas Checker|Gas Guider|Hair|Hair Lean|Hair Target|Hair Tilt|Heal Aura|Hive Attack|Lean|Local Camera|Loop|Old|Particle|Particle Puke Collision|Player Avatar Attached|Pupil|Screen Vein Effect|Sphere Effect|Stun Fly|Tentacle|Tilt|Up|Visual|Visuals)\\b.*$", string.Empty, RegexOptions.IgnoreCase).Trim();
if (!string.IsNullOrWhiteSpace(text))
{
return text;
}
return cleaned;
}
}
internal static class ItemNameLocalizer
{
private static readonly Dictionary<string, string> NameMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "Item Upgrade", "升级物品" },
{ "Upgrade", "升级" },
{ "Gun", "枪" },
{ "Shotgun", "霰弹枪" },
{ "Tranq Gun", "麻醉枪" },
{ "Tranq", "麻醉枪" },
{ "Handgun", "手枪" },
{ "Pistol", "手枪" },
{ "Revolver", "左轮手枪" },
{ "Grenade", "手雷" },
{ "Stun Grenade", "眩晕手雷" },
{ "Shockwave Grenade", "冲击波手雷" },
{ "Explosive Grenade", "爆炸手雷" },
{ "Mine", "地雷" },
{ "Explosive Mine", "爆炸地雷" },
{ "Health Pack", "血包" },
{ "Healthpack", "血包" },
{ "Medkit", "医疗包" },
{ "First Aid", "急救包" },
{ "Melee", "近战武器" },
{ "Baseball Bat", "棒球棍" },
{ "Bat", "球棒" },
{ "Hammer", "锤子" },
{ "Sword", "剑" },
{ "Pan", "平底锅" },
{ "Frying Pan", "平底锅" },
{ "Cart", "购物车" },
{ "Small Cart", "小购物车" },
{ "Extraction Tracker", "提取点追踪器" },
{ "Tracker", "追踪器" },
{ "Map", "地图" },
{ "Drone", "无人机" },
{ "Orb", "球体" },
{ "Crystal", "水晶" },
{ "Diamond", "钻石" },
{ "Gold", "黄金" },
{ "Gold Bar", "金条" },
{ "Money", "钱" },
{ "Cash", "现金" },
{ "Coin", "硬币" },
{ "Coins", "硬币" },
{ "Token", "代币" },
{ "Tokens", "代币" },
{ "Coin Chest", "硬币宝箱" },
{ "Token Chest", "硬币宝箱" },
{ "Prize Chest", "硬币宝箱" },
{ "Reward Chest", "硬币宝箱" },
{ "Coin Crate", "硬币宝箱" },
{ "Token Crate", "硬币宝箱" },
{ "Cosmetic Shop Machine", "投币机" },
{ "Coin Machine", "投币机" },
{ "Token Machine", "投币机" },
{ "Prize Machine", "投币机" },
{ "Gacha Machine", "投币机" },
{ "Token Box", "代币箱" },
{ "Lottery Box", "抽奖箱" },
{ "Prize Box", "代币箱" },
{ "Loot Box", "代币箱" },
{ "Gacha Box", "抽奖箱" },
{ "Reward Box", "代币箱" },
{ "Capsule Box", "代币箱" },
{ "Capsule Token", "代币箱" },
{ "Prize Token", "代币箱" },
{ "Painting", "画作" },
{ "Vase", "花瓶" },
{ "Statue", "雕像" },
{ "Crown", "王冠" },
{ "Ring", "戒指" },
{ "Necklace", "项链" },
{ "Cup", "杯子" },
{ "Trophy", "奖杯" },
{ "Bottle", "瓶子" },
{ "Box", "箱子" },
{ "Crate", "木箱" },
{ "Chest", "宝箱" },
{ "Book", "书" },
{ "Clock", "钟表" },
{ "Lamp", "灯" },
{ "Mirror", "镜子" },
{ "Computer", "电脑" },
{ "Phone", "电话" },
{ "Radio", "收音机" },
{ "Toy", "玩具" },
{ "Robot", "机器人" },
{ "Skull", "头骨" }
};
private static readonly Dictionary<string, string> WordMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "upgrade", "升级" },
{ "gun", "枪" },
{ "shotgun", "霰弹枪" },
{ "tranq", "麻醉" },
{ "pistol", "手枪" },
{ "revolver", "左轮" },
{ "grenade", "手雷" },
{ "stun", "眩晕" },
{ "shockwave", "冲击波" },
{ "explosive", "爆炸" },
{ "mine", "地雷" },
{ "health", "生命" },
{ "pack", "包" },
{ "medkit", "医疗包" },
{ "melee", "近战" },
{ "bat", "球棒" },
{ "hammer", "锤子" },
{ "sword", "剑" },
{ "pan", "锅" },
{ "cart", "购物车" },
{ "small", "小" },
{ "big", "大" },
{ "large", "大" },
{ "extraction", "提取" },
{ "tracker", "追踪器" },
{ "map", "地图" },
{ "drone", "无人机" },
{ "orb", "球" },
{ "crystal", "水晶" },
{ "diamond", "钻石" },
{ "gold", "黄金" },
{ "bar", "条" },
{ "money", "钱" },
{ "cash", "现金" },
{ "coin", "硬币" },
{ "coins", "硬币" },
{ "token", "代币" },
{ "tokens", "代币" },
{ "prize", "奖励" },
{ "reward", "奖励" },
{ "lottery", "抽奖" },
{ "gacha", "抽奖" },
{ "loot", "战利品" },
{ "capsule", "胶囊" },
{ "machine", "机器" },
{ "dispenser", "发放机" },
{ "vendor", "贩卖机" },
{ "shop", "商店" },
{ "painting", "画作" },
{ "vase", "花瓶" },
{ "statue", "雕像" },
{ "crown", "王冠" },
{ "ring", "戒指" },
{ "necklace", "项链" },
{ "cup", "杯子" },
{ "trophy", "奖杯" },
{ "bottle", "瓶子" },
{ "box", "箱子" },
{ "crate", "木箱" },
{ "chest", "箱子" },
{ "book", "书" },
{ "clock", "钟表" },
{ "lamp", "灯" },
{ "mirror", "镜子" },
{ "computer", "电脑" },
{ "phone", "电话" },
{ "radio", "收音机" },
{ "toy", "玩具" },
{ "robot", "机器人" },
{ "skull", "头骨" },
{ "wood", "木制" },
{ "metal", "金属" },
{ "silver", "银色" },
{ "bronze", "青铜" },
{ "red", "红色" },
{ "blue", "蓝色" },
{ "green", "绿色" },
{ "black", "黑色" },
{ "white", "白色" },
{ "old", "旧" },
{ "new", "新" }
};
public static string Translate(string rawName)
{
string text = CleanDisplayName(rawName);
if (string.IsNullOrWhiteSpace(text))
{
return CleanName(rawName);
}
if (NameMap.TryGetValue(text, out var value))
{
return value;
}
string name = SplitWords(text);
name = StripTypePrefix(name);
if (NameMap.TryGetValue(name, out value))
{
return value;
}
string[] array = name.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (array.Length == 0)
{
return text;
}
bool flag = false;
List<string> list = new List<string>(array.Length);
string[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
string text2 = Regex.Replace(array2[i], "[^A-Za-z0-9]", string.Empty);
if (!string.IsNullOrWhiteSpace(text2) && !IsIgnoredTypeWord(text2))
{
int result;
if (WordMap.TryGetValue(text2, out var value2))
{
list.Add(value2);
flag = true;
}
else if (!int.TryParse(text2, out result))
{
list.Add(text2);
}
}
}
if (!flag || list.Count <= 0)
{
return text;
}
return string.Join("", list);
}
public static string CleanDisplayName(string rawName)
{
string text = CleanName(rawName);
string text2 = StripTypePrefix(text);
if (!string.IsNullOrWhiteSpace(text2))
{
return text2;
}
return text;
}
private static string StripTypePrefix(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
return string.Empty;
}
return Regex.Replace(Regex.Replace(Regex.Replace(SplitWords(name), "^(valuable\\s*object|valuable|item)\\s+", string.Empty, RegexOptions.IgnoreCase), "\\s+(valuable\\s*object|valuable|item)$", string.Empty, RegexOptions.IgnoreCase), "\\s+", " ").Trim();
}
private static bool IsIgnoredTypeWord(string word)
{
if (!string.Equals(word, "valuable", StringComparison.OrdinalIgnoreCase) && !string.Equals(word, "object", StringComparison.OrdinalIgnoreCase))
{
return string.Equals(word, "item", StringComparison.OrdinalIgnoreCase);
}
return true;
}
private static string CleanName(string rawName)
{
if (string.IsNullOrWhiteSpace(rawName))
{
return string.Empty;
}
return Regex.Replace(Regex.Replace(rawName.Replace("(Clone)", string.Empty).Trim(), "[_\\-]+", " "), "\\s+", " ").Trim();
}
private static string SplitWords(string value)
{
return Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(value, "([a-z])([A-Z])", "$1 $2"), "([A-Za-z])(\\d)", "$1 $2"), "(\\d)([A-Za-z])", "$1 $2"), "[_\\-]+", " "), "\\s+", " ").Trim();
}
}
internal sealed class ConfigurationManagerAttributes
{
public bool? ShowRangeAsPercent;
public Action<ConfigEntryBase> CustomDrawer;
public bool? Browsable;
public string Category;
public object DefaultValue;
public bool? HideDefaultButton;
public bool? HideSettingName;
public int? Order;
public bool? ReadOnly;
}