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.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Stunlock.Core;
using Stunlock.Localization;
using WeaponsOnBLOODLUST.Core;
using WeaponsOnBLOODLUST.Eclipse;
using WeaponsOnBLOODLUST.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("WeaponsOnBLOODLUST")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Client-side weapon renamer for the BLOODLUST server: replaces the vanilla names of chosen weapons in the tooltip, inventory, crafting, shop and Eclipse panels with custom RU/EN names. Server installs nothing.")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("WeaponsOnBLOODLUST")]
[assembly: AssemblyTitle("WeaponsOnBLOODLUST")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace WeaponsOnBLOODLUST
{
[BepInPlugin("bloodlust.weaponnames", "Weapons on BLOODLUST", "1.1.0")]
[BepInProcess("VRising.exe")]
public sealed class Plugin : BasePlugin
{
public const string PluginGuid = "bloodlust.weaponnames";
public const string PluginVersion = "1.1.0";
public const string PluginName = "Weapons on BLOODLUST";
internal static Plugin Instance;
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<string> Language;
internal static ConfigEntry<bool> ColorizeNames;
internal static ConfigEntry<string> NameColor;
internal static ConfigEntry<bool> Debug;
internal static ConfigEntry<bool> EclipseIntegration;
internal static ConfigEntry<bool> DescriptionEnabled;
internal static ConfigEntry<string> Description;
internal static ConfigEntry<string> DescriptionEn;
public override void Load()
{
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Expected O, but got Unknown
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Expected O, but got Unknown
Instance = this;
bool flag = default(bool);
try
{
((BasePlugin)this).Config.SaveOnConfigSet = true;
Enabled = ((BasePlugin)this).Config.Bind<bool>("01 General", "Enabled", true, "Подменять ванильные названия оружия в интерфейсе игры (тултип, инвентарь, крафт).");
Language = ((BasePlugin)this).Config.Bind<string>("01 General", "Language", "auto", "auto | ru | en. auto — язык клиента игры; uk/be тоже получают ru.");
ColorizeNames = ((BasePlugin)this).Config.Bind<bool>("01 General", "ColorizeNames", true, "Красить названия оружия из таблицы (rich-text тег <color>).");
NameColor = ((BasePlugin)this).Config.Bind<string>("01 General", "NameColor", "#FF0000", "Цвет названий в формате #RRGGBB (или RRGGBB). Красный по умолчанию.");
Debug = ((BasePlugin)this).Config.Bind<bool>("02 Diagnostics", "Debug", false, "Подробный лог (какие ключи найдены и применены).");
EclipseIntegration = ((BasePlugin)this).Config.Bind<bool>("03 Integration", "EclipseIntegration", true, "Дописывать имена в сервис локализации Eclipse, если мод Eclipse загружен (мягкая интеграция).");
DescriptionEnabled = ((BasePlugin)this).Config.Bind<bool>("04 Description", "DescriptionEnabled", true, "Подменять описание оружия из таблицы (блок «атрибуты» в тултипе).");
Description = ((BasePlugin)this).Config.Bind<string>("04 Description", "Description", "Все подробности об оружии в нашем дискорде - https://discord.com/invite/HGRBMwSyse", "Текст описания (RU и все остальные языки). Переносы строк можно писать как \\n.");
DescriptionEn = ((BasePlugin)this).Config.Bind<string>("04 Description", "DescriptionEn", "", "Текст описания для английского клиента. Пусто — используется Description.");
NameTable.Init(Paths.ConfigPath, ((BasePlugin)this).Log);
ApplyPatches();
ManualLogSource log = ((BasePlugin)this).Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[WeaponsOnBLOODLUST] v");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(NameTable.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" name(s), ");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("table='");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(NameTable.Path);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
}
log.LogInfo(val);
EclipseBridge.RequestApply();
}
catch (Exception ex)
{
ManualLogSource log2 = ((BasePlugin)this).Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[WeaponsOnBLOODLUST] load failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
log2.LogError(val2);
}
}
private void ApplyPatches()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Harmony harmony = new Harmony("bloodlust.weaponnames");
PatchOne(harmony, typeof(GetByLocalizationKeyPatch), "Localization.Get(LocalizationKey,bool)");
PatchOne(harmony, typeof(GetByAssetGuidPatch), "Localization.Get(AssetGuid,bool)");
PatchOne(harmony, typeof(LoadLanguagePatch), "Localization.LoadLanguage(string)");
PatchOne(harmony, typeof(LoadDefaultLanguagePatch), "Localization.LoadDefaultLanguage()");
PatchOne(harmony, typeof(LoadLanguagesPatch), "Localization.LoadLanguages(List<string>)");
PatchOne(harmony, typeof(InitializePatch), "Localization.Initialize(LocalizationSettings)");
PatchOne(harmony, typeof(ManagedDataRegistryPatch), "ManagedDataSystem_Base.ManagedDataRegistry (get)");
PatchOne(harmony, typeof(ManagedDataSystemCreatePatch), "ManagedDataSystem_Base.OnCreate");
}
private void PatchOne(Harmony harmony, Type type, string name)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
bool flag = default(bool);
try
{
harmony.PatchAll(type);
ManualLogSource log = ((BasePlugin)this).Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[WeaponsOnBLOODLUST] patch ok: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
}
log.LogInfo(val);
}
catch (Exception ex)
{
ManualLogSource log2 = ((BasePlugin)this).Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(37, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[WeaponsOnBLOODLUST] patch failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log2.LogError(val2);
}
}
}
}
namespace WeaponsOnBLOODLUST.Patches
{
[HarmonyPatch(typeof(Localization), "Get", new Type[]
{
typeof(LocalizationKey),
typeof(bool)
})]
internal static class GetByLocalizationKeyPatch
{
[HarmonyPostfix]
private static void Postfix(LocalizationKey key, ref string __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
try
{
if (NameTable.TryGet(key.Key, out var text))
{
__result = text;
}
}
catch (Exception e)
{
NameTable.ReportPatchError(e);
}
}
}
[HarmonyPatch(typeof(Localization), "Get", new Type[]
{
typeof(AssetGuid),
typeof(bool)
})]
internal static class GetByAssetGuidPatch
{
[HarmonyPostfix]
private static void Postfix(AssetGuid guid, ref string __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
try
{
if (NameTable.TryGet(guid, out var text))
{
__result = text;
}
}
catch (Exception e)
{
NameTable.ReportPatchError(e);
}
}
}
[HarmonyPatch(typeof(Localization), "LoadLanguage")]
internal static class LoadLanguagePatch
{
[HarmonyPostfix]
private static void Postfix(string language)
{
try
{
NameTable.OnLocalizationLoaded(language);
}
catch (Exception e)
{
NameTable.ReportPatchError(e);
}
}
}
[HarmonyPatch(typeof(Localization), "LoadDefaultLanguage")]
internal static class LoadDefaultLanguagePatch
{
[HarmonyPostfix]
private static void Postfix()
{
try
{
NameTable.OnLocalizationLoaded(null);
}
catch (Exception e)
{
NameTable.ReportPatchError(e);
}
}
}
[HarmonyPatch(typeof(Localization), "LoadLanguages")]
internal static class LoadLanguagesPatch
{
[HarmonyPostfix]
private static void Postfix()
{
try
{
NameTable.OnLocalizationLoaded(null);
}
catch (Exception e)
{
NameTable.ReportPatchError(e);
}
}
}
[HarmonyPatch(typeof(Localization), "Initialize")]
internal static class InitializePatch
{
[HarmonyPostfix]
private static void Postfix()
{
try
{
NameTable.OnLocalizationLoaded(null);
}
catch (Exception e)
{
NameTable.ReportPatchError(e);
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal static class ManagedDataRegistryPatch
{
[HarmonyPostfix]
private static void Postfix(ManagedDataRegistry __result)
{
try
{
DescriptionResolver.Capture(__result);
NameTable.OnRegistryAvailable();
}
catch (Exception e)
{
NameTable.ReportPatchError(e);
}
}
}
[HarmonyPatch(typeof(ManagedDataSystem_Base), "OnCreate")]
internal static class ManagedDataSystemCreatePatch
{
private static bool _done;
[HarmonyPostfix]
private static void Postfix(ManagedDataSystem_Base __instance)
{
if (_done)
{
return;
}
try
{
DescriptionResolver.Capture(__instance.ManagedDataRegistry);
NameTable.OnRegistryAvailable();
_done = DescriptionResolver.Ready || DescriptionResolver.Failed;
}
catch (Exception e)
{
_done = true;
NameTable.ReportPatchError(e);
}
}
}
}
namespace WeaponsOnBLOODLUST.Eclipse
{
internal static class EclipseBridge
{
private const string LogPrefix = "[WeaponsOnBLOODLUST]";
private const string EclipseAssemblyName = "Eclipse";
private const string LocalizationServiceTypeName = "Eclipse.Services.LocalizationService";
private static readonly object Sync = new object();
private static bool _initialised;
private static bool _disabled;
private static bool _reportedMissing;
private static string _lastSignature;
internal static void RequestApply()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
try
{
if (!_disabled)
{
ConfigEntry<bool> eclipseIntegration = Plugin.EclipseIntegration;
if (eclipseIntegration == null || eclipseIntegration.Value)
{
Apply();
}
}
}
catch (Exception ex)
{
_disabled = true;
Plugin instance = Plugin.Instance;
if (instance == null)
{
return;
}
ManualLogSource log = ((BasePlugin)instance).Log;
if (log != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(46, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Eclipse integration disabled after an error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
}
}
}
private static void Apply()
{
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Expected O, but got Unknown
Type type = FindLocalizationService();
if (type == null)
{
return;
}
ActiveName[] array = NameTable.Snapshot();
if (array.Length == 0)
{
return;
}
FieldInfo fieldInfo = FindField(type, "_guidStringsToLocalizedNames");
FieldInfo fieldInfo2 = FindField(type, "_localizedNamesToGuidStrings");
if (fieldInfo == null || fieldInfo2 == null)
{
Disable("Eclipse.LocalizationService layout changed - custom names stay in the game UI only");
return;
}
IDictionary dictionary = fieldInfo.GetValue(null) as IDictionary;
IDictionary dictionary2 = fieldInfo2.GetValue(null) as IDictionary;
if (dictionary == null || dictionary2 == null)
{
return;
}
bool isRussian = NameTable.IsRussian;
int num = 0;
lock (Sync)
{
ActiveName[] array2 = array;
foreach (ActiveName activeName in array2)
{
if (string.IsNullOrEmpty(activeName.KeyString))
{
continue;
}
string text = activeName.For(isRussian);
if (!string.IsNullOrEmpty(text))
{
dictionary[activeName.KeyString] = text;
if (!dictionary2.Contains(text))
{
dictionary2[text] = activeName.KeyString;
}
num++;
}
}
}
string text2 = isRussian + "|" + num + "|" + NameTable.ResolvedLanguage;
if (text2 != _lastSignature)
{
_lastSignature = text2;
Plugin instance = Plugin.Instance;
if (instance != null)
{
ManualLogSource log = ((BasePlugin)instance).Log;
if (log != null)
{
bool flag;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(83, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Eclipse integration: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" name(s) written into ");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Eclipse.LocalizationService (language=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(NameTable.ResolvedLanguage);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
}
log.LogInfo(val);
}
}
}
_initialised = true;
}
private static Type FindLocalizationService()
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
string name;
try
{
name = assembly.GetName().Name;
}
catch
{
continue;
}
if (string.Equals(name, "Eclipse", StringComparison.Ordinal))
{
Type type = assembly.GetType("Eclipse.Services.LocalizationService", throwOnError: false);
if (type != null)
{
return type;
}
Disable("Eclipse is loaded but Eclipse.LocalizationService was not found - running standalone");
return null;
}
}
if (!_reportedMissing)
{
_reportedMissing = true;
if (!_initialised)
{
ConfigEntry<bool> debug = Plugin.Debug;
if (debug == null || !debug.Value)
{
goto IL_00d3;
}
}
Plugin instance = Plugin.Instance;
if (instance != null)
{
ManualLogSource log = ((BasePlugin)instance).Log;
if (log != null)
{
bool flag = default(bool);
BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(82, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Eclipse is not loaded yet - standalone mode (vanilla UI names are still replaced)");
}
log.LogDebug(val);
}
}
}
goto IL_00d3;
IL_00d3:
return null;
}
private static FieldInfo FindField(Type type, string fieldName)
{
return type.GetField(fieldName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
private static void Disable(string reason)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
if (_disabled)
{
return;
}
_disabled = true;
Plugin instance = Plugin.Instance;
if (instance == null)
{
return;
}
ManualLogSource log = ((BasePlugin)instance).Log;
if (log != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(1, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason);
}
log.LogWarning(val);
}
}
}
}
namespace WeaponsOnBLOODLUST.Core
{
internal static class DescriptionResolver
{
private const string LogPrefix = "[WeaponsOnBLOODLUST]";
private static readonly object Sync = new object();
private static readonly Dictionary<int, AssetGuid> Cache = new Dictionary<int, AssetGuid>();
private static object _registry;
private static MethodInfo _getOrDefault;
private static Type _itemType;
private static bool _failed;
internal static bool Ready
{
get
{
lock (Sync)
{
return !_failed && _registry != null && _getOrDefault != null;
}
}
}
internal static bool Failed
{
get
{
lock (Sync)
{
return _failed;
}
}
}
internal static void Capture(object registry)
{
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
if (registry == null)
{
return;
}
lock (Sync)
{
if (_failed || _registry != null)
{
return;
}
try
{
Type type = FindItemDataType();
if (type == null)
{
Fail("ProjectM.ManagedItemData not found");
return;
}
MethodInfo methodInfo = registry.GetType().GetMethod("GetOrDefaultWithoutLogging", BindingFlags.Instance | BindingFlags.Public) ?? registry.GetType().GetMethod("GetOrDefault", BindingFlags.Instance | BindingFlags.Public);
if (methodInfo == null || !methodInfo.IsGenericMethodDefinition)
{
Fail("ManagedDataRegistry.GetOrDefault not found");
return;
}
_itemType = type;
_getOrDefault = methodInfo.MakeGenericMethod(type);
_registry = registry;
Plugin instance = Plugin.Instance;
if (instance == null)
{
return;
}
ManualLogSource log = ((BasePlugin)instance).Log;
if (log != null)
{
bool flag = default(bool);
BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(54, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" managed data registry captured for description lookup");
}
log.LogDebug(val);
}
}
catch (Exception ex)
{
Fail(ex.Message);
}
}
}
internal static bool TryResolve(int prefabGuid, out AssetGuid descriptionKey)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
descriptionKey = default(AssetGuid);
lock (Sync)
{
if (Cache.TryGetValue(prefabGuid, out var value))
{
descriptionKey = value;
return !((AssetGuid)(ref value)).IsEmpty;
}
if (_failed || _registry == null || _getOrDefault == null)
{
return false;
}
try
{
object obj = _getOrDefault.Invoke(_registry, new object[2]
{
(object)new PrefabGUID(prefabGuid),
null
});
if (obj == null)
{
return false;
}
object obj2 = _itemType.GetProperty("Description", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj);
if (obj2 == null)
{
return false;
}
object obj3 = obj2.GetType().GetField("Key", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj2);
if (obj3 == null)
{
return false;
}
FieldInfo field = obj3.GetType().GetField("Key", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field == null)
{
return false;
}
AssetGuid val = (AssetGuid)field.GetValue(obj3);
Cache[prefabGuid] = val;
descriptionKey = val;
return !((AssetGuid)(ref val)).IsEmpty;
}
catch (Exception ex)
{
Fail(ex.GetBaseException().Message);
return false;
}
}
}
private static Type FindItemDataType()
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type type;
try
{
type = assembly.GetType("ProjectM.ManagedItemData", throwOnError: false);
}
catch
{
continue;
}
if (type != null)
{
return type;
}
}
return null;
}
private static void Fail(string reason)
{
if (_failed)
{
return;
}
_failed = true;
Plugin instance = Plugin.Instance;
if (instance != null)
{
ManualLogSource log = ((BasePlugin)instance).Log;
if (log != null)
{
log.LogWarning((object)("[WeaponsOnBLOODLUST] description lookup disabled: " + reason + " (names are still replaced, descriptions stay vanilla)"));
}
}
}
}
internal readonly struct GuidKey : IEquatable<GuidKey>
{
private readonly int _a;
private readonly int _b;
private readonly int _c;
private readonly int _d;
internal GuidKey(AssetGuid guid)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
_a = guid._a;
_b = guid._b;
_c = guid._c;
_d = guid._d;
}
public bool Equals(GuidKey other)
{
if (_a == other._a && _b == other._b && _c == other._c)
{
return _d == other._d;
}
return false;
}
public override bool Equals(object obj)
{
if (obj is GuidKey other)
{
return Equals(other);
}
return false;
}
public override int GetHashCode()
{
return (((((_a * 397) ^ _b) * 397) ^ _c) * 397) ^ _d;
}
internal AssetGuid ToAssetGuid()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
return new AssetGuid
{
_a = _a,
_b = _b,
_c = _c,
_d = _d
};
}
}
internal sealed class NameEntry
{
public int Guid { get; set; }
public string Key { get; set; }
public string Ru { get; set; }
public string En { get; set; }
public bool Enabled { get; set; } = true;
}
internal sealed class NameFile
{
public int Version { get; set; } = 1;
public List<NameEntry> Weapons { get; set; } = new List<NameEntry>();
}
internal sealed class ActiveName
{
internal int PrefabGuid;
internal AssetGuid Key;
internal string KeyString;
internal string Ru;
internal string En;
internal bool HasDescription;
internal AssetGuid DescriptionKey;
internal string For(bool russian)
{
string text = (russian ? Ru : En);
if (string.IsNullOrEmpty(text))
{
text = (russian ? En : Ru);
}
return text;
}
}
internal static class NameTable
{
private const string DefaultResource = "WeaponsOnBLOODLUST.weapon-names.bloodlust.default.json";
private const string PrefabKeysResource = "WeaponsOnBLOODLUST.prefab-keys.json";
private const string LogPrefix = "[WeaponsOnBLOODLUST]";
private static readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
ReadCommentHandling = JsonCommentHandling.Skip,
AllowTrailingCommas = true
};
private static readonly object Sync = new object();
private static Dictionary<GuidKey, ActiveName> _map = new Dictionary<GuidKey, ActiveName>();
private static ActiveName[] _applied = Array.Empty<ActiveName>();
private static Dictionary<GuidKey, string> _descriptions = new Dictionary<GuidKey, string>();
private static Dictionary<int, string> _prefabKeys = new Dictionary<int, string>();
private static string _path;
private static ManualLogSource _log;
private static DateTime _lastWriteUtc;
private static bool _isRussian;
private static string _resolvedLanguage;
private static string _lastAppliedLanguage;
private static string _appliedSignature;
private static bool _descFullyResolved;
private static int _patchErrors;
private static bool _patchDisabled;
internal static string Path => _path;
internal static int Count
{
get
{
lock (Sync)
{
return _map.Count;
}
}
}
internal static bool IsRussian => _isRussian;
internal static string ResolvedLanguage => _resolvedLanguage;
internal static ActiveName[] Snapshot()
{
return _applied;
}
internal static void Init(string configDir, ManualLogSource log)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
_log = log;
string text = System.IO.Path.Combine(configDir, "WeaponsOnBLOODLUST");
_path = System.IO.Path.Combine(text, "weapon-names.bloodlust.json");
try
{
Directory.CreateDirectory(text);
}
catch (Exception ex)
{
ManualLogSource log2 = _log;
if (log2 != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(35, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" config directory creation failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log2.LogWarning(val);
}
}
EnsureDefaultFile();
LoadPrefabKeys();
Load(initial: true);
StartWatcher();
}
private static void Load(bool initial)
{
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Expected O, but got Unknown
bool flag = default(bool);
try
{
if (!File.Exists(_path))
{
return;
}
DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(_path);
if (!initial && lastWriteTimeUtc == _lastWriteUtc)
{
return;
}
NameFile nameFile;
using (FileStream utf8Json = File.OpenRead(_path))
{
nameFile = JsonSerializer.Deserialize<NameFile>(utf8Json, JsonOptions);
}
Dictionary<GuidKey, ActiveName> dictionary = new Dictionary<GuidKey, ActiveName>();
List<ActiveName> list = new List<ActiveName>();
int num = 0;
foreach (NameEntry item in nameFile?.Weapons ?? new List<NameEntry>())
{
if (item == null || !item.Enabled || (string.IsNullOrWhiteSpace(item.Ru) && string.IsNullOrWhiteSpace(item.En)))
{
continue;
}
if (!ResolveKey(item, out var key, out var keyString))
{
num++;
ManualLogSource log = _log;
if (log != null)
{
log.LogWarning((object)($"{"[WeaponsOnBLOODLUST]"} {item.Guid}: ключ локализации не найден, пропущено " + "(укажите поле \"key\" в таблице)"));
}
continue;
}
ActiveName activeName = new ActiveName
{
PrefabGuid = item.Guid,
Key = key,
KeyString = keyString,
Ru = item.Ru,
En = item.En
};
GuidKey key2 = new GuidKey(key);
if (!dictionary.ContainsKey(key2))
{
list.Add(activeName);
}
dictionary[key2] = activeName;
}
lock (Sync)
{
_map = dictionary;
_applied = list.ToArray();
}
_lastWriteUtc = lastWriteTimeUtc;
_descFullyResolved = false;
ManualLogSource log2 = _log;
if (log2 != null)
{
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(46, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" table applied: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(dictionary.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" name(s), skipped=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (revision ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(nameFile?.Version ?? 1);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
}
log2.LogInfo(val);
}
ResolveDescriptions();
RebuildDescriptions();
EclipseBridge.RequestApply();
}
catch (Exception ex)
{
ManualLogSource log2 = _log;
if (log2 != null)
{
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(20, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" table load failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
log2.LogError(val2);
}
}
}
private static void EnsureDefaultFile()
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
bool flag = default(bool);
try
{
if (File.Exists(_path))
{
return;
}
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WeaponsOnBLOODLUST.weapon-names.bloodlust.default.json");
if (stream == null)
{
return;
}
using StreamReader streamReader = new StreamReader(stream);
File.WriteAllText(_path, streamReader.ReadToEnd(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
ManualLogSource log = _log;
if (log != null)
{
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" created default table: '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_path);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
}
log.LogInfo(val);
}
}
catch (Exception ex)
{
ManualLogSource log = _log;
if (log != null)
{
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(32, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" default table creation failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val2);
}
}
}
private static void StartWatcher()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
try
{
GC.KeepAlive(new Timer(delegate
{
try
{
Load(initial: false);
RefreshIfNeeded();
EclipseBridge.RequestApply();
}
catch
{
}
}, null, 4000, 4000));
}
catch (Exception ex)
{
ManualLogSource log = _log;
if (log != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(25, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" hot reload unavailable: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
}
}
}
private static void LoadPrefabKeys()
{
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
try
{
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WeaponsOnBLOODLUST.prefab-keys.json");
if (stream == null)
{
return;
}
Dictionary<string, string> dictionary = JsonSerializer.Deserialize<Dictionary<string, string>>(stream, JsonOptions);
Dictionary<int, string> dictionary2 = new Dictionary<int, string>(dictionary?.Count ?? 0);
if (dictionary != null)
{
foreach (KeyValuePair<string, string> item in dictionary)
{
if (int.TryParse(item.Key, out var result))
{
dictionary2[result] = item.Value;
}
}
}
_prefabKeys = dictionary2;
}
catch (Exception ex)
{
ManualLogSource log = _log;
if (log != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(24, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" prefab key map failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
}
}
}
private static bool ResolveKey(NameEntry entry, out AssetGuid key, out string keyString)
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
keyString = null;
if (!string.IsNullOrWhiteSpace(entry.Key) && TryParse(entry.Key, out key))
{
keyString = Normalize(entry.Key);
return true;
}
if (_prefabKeys != null && _prefabKeys.TryGetValue(entry.Guid, out var value) && TryParse(value, out key))
{
keyString = Normalize(value);
return true;
}
key = default(AssetGuid);
return false;
}
private static string Normalize(string text)
{
return text?.Trim().ToLowerInvariant();
}
private static bool TryParse(string text, out AssetGuid key)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
key = default(AssetGuid);
if (string.IsNullOrWhiteSpace(text))
{
return false;
}
string text2 = text.Trim();
try
{
key = AssetGuid.FromString(text2);
}
catch
{
key = default(AssetGuid);
}
if (!((AssetGuid)(ref key)).IsEmpty)
{
return true;
}
try
{
key = AssetGuid.FromString(text2.Replace("-", string.Empty));
}
catch
{
key = default(AssetGuid);
}
return !((AssetGuid)(ref key)).IsEmpty;
}
internal static void OnRegistryAvailable()
{
if (!_descFullyResolved && ResolveDescriptions())
{
RebuildDescriptions();
Apply(logIt: true);
}
}
private static bool ResolveDescriptions()
{
//IL_0038: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
ActiveName[] applied = _applied;
if (applied.Length == 0)
{
return false;
}
bool flag = false;
int num = 0;
ActiveName[] array = applied;
foreach (ActiveName activeName in array)
{
if (!activeName.HasDescription)
{
if (DescriptionResolver.TryResolve(activeName.PrefabGuid, out var descriptionKey))
{
activeName.DescriptionKey = descriptionKey;
activeName.HasDescription = true;
flag = true;
}
else
{
num++;
}
}
}
_descFullyResolved = num == 0;
if (flag)
{
ManualLogSource log = _log;
if (log != null)
{
bool flag2 = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 3, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" descriptions: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(applied.Length - num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(applied.Length);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" item(s) resolved");
}
log.LogInfo(val);
}
}
return flag;
}
private static void RebuildDescriptions()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
Dictionary<GuidKey, string> dictionary = new Dictionary<GuidKey, string>();
try
{
ConfigEntry<bool> descriptionEnabled = Plugin.DescriptionEnabled;
if (descriptionEnabled == null || descriptionEnabled.Value)
{
string value = DescriptionText(_isRussian);
if (!string.IsNullOrEmpty(value))
{
ActiveName[] applied = _applied;
foreach (ActiveName activeName in applied)
{
if (activeName.HasDescription)
{
dictionary[new GuidKey(activeName.DescriptionKey)] = value;
}
}
}
}
}
catch (Exception ex)
{
ManualLogSource log = _log;
if (log != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(33, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" description table build failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
}
}
_descriptions = dictionary;
}
private static string DescriptionText(bool russian)
{
string text = Plugin.Description?.Value ?? string.Empty;
string text2 = Plugin.DescriptionEn?.Value ?? string.Empty;
string text3 = ((russian || string.IsNullOrWhiteSpace(text2)) ? text : text2);
if (string.IsNullOrEmpty(text3))
{
return null;
}
return text3.Replace("\\n", "\n");
}
internal static bool TryGet(AssetGuid key, out string text)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
text = null;
if (_patchDisabled)
{
return false;
}
ConfigEntry<bool> enabled = Plugin.Enabled;
if (enabled != null && !enabled.Value)
{
return false;
}
Dictionary<GuidKey, ActiveName> map = _map;
if (map.Count == 0)
{
return false;
}
if (_resolvedLanguage == null)
{
RefreshLanguage();
}
if (map.TryGetValue(new GuidKey(key), out var value))
{
text = Format(value, _isRussian);
return !string.IsNullOrEmpty(text);
}
Dictionary<GuidKey, string> descriptions = _descriptions;
if (descriptions.Count > 0 && descriptions.TryGetValue(new GuidKey(key), out var value2))
{
text = value2;
return !string.IsNullOrEmpty(text);
}
return false;
}
private static string Format(ActiveName entry, bool russian)
{
string text = entry.For(russian);
if (string.IsNullOrEmpty(text))
{
return text;
}
string text2 = ColorTag();
if (text2 == null)
{
return text;
}
return $"<color={text2}>{text}</color>";
}
private static string ColorTag()
{
try
{
ConfigEntry<bool> colorizeNames = Plugin.ColorizeNames;
if (colorizeNames != null && !colorizeNames.Value)
{
return null;
}
string text = Plugin.NameColor?.Value;
if (string.IsNullOrWhiteSpace(text))
{
return null;
}
text = text.Trim();
if (!text.StartsWith("#", StringComparison.Ordinal))
{
text = "#" + text;
}
return text;
}
catch
{
return null;
}
}
internal static void ReportPatchError(Exception e)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
if (_patchDisabled)
{
return;
}
_patchErrors++;
if (_patchErrors <= 5)
{
ManualLogSource log = _log;
if (log != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" name patch failed (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_patchErrors);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
}
log.LogWarning(val);
}
}
if (_patchErrors >= 5)
{
_patchDisabled = true;
ManualLogSource log2 = _log;
if (log2 != null)
{
log2.LogError((object)"[WeaponsOnBLOODLUST] подмена имён отключена до перезапуска после 5 ошибок; в интерфейсе остаются ванильные названия.");
}
}
}
internal static void OnLocalizationLoaded(string language)
{
SetLanguage(language);
bool logIt = _lastAppliedLanguage != _resolvedLanguage;
_lastAppliedLanguage = _resolvedLanguage;
RebuildDescriptions();
Apply(logIt);
}
internal static void ApplyNow()
{
RefreshLanguage();
RebuildDescriptions();
Apply(logIt: true);
}
internal static void RefreshIfNeeded()
{
if (!(Signature() == _appliedSignature))
{
RefreshLanguage();
RebuildDescriptions();
Apply(logIt: true);
}
}
private static string Signature()
{
ConfigEntry<bool> colorizeNames = Plugin.ColorizeNames;
string text = ((colorizeNames == null || !colorizeNames.Value) ? "off" : (Plugin.NameColor?.Value ?? string.Empty));
string[] obj = new string[9] { text, "|", null, null, null, null, null, null, null };
ConfigEntry<bool> descriptionEnabled = Plugin.DescriptionEnabled;
obj[2] = ((descriptionEnabled != null && descriptionEnabled.Value) ? "1" : "0");
obj[3] = "|";
obj[4] = Plugin.Description?.Value ?? string.Empty;
obj[5] = "|";
obj[6] = Plugin.DescriptionEn?.Value ?? string.Empty;
obj[7] = "|";
obj[8] = (_isRussian ? "ru" : "en");
return string.Concat(obj);
}
private static void RefreshLanguage()
{
SetLanguage(null);
}
private static void SetLanguage(string language)
{
string a = Plugin.Language?.Value;
if (string.Equals(a, "ru", StringComparison.OrdinalIgnoreCase))
{
_isRussian = true;
_resolvedLanguage = "ru (config)";
return;
}
if (string.Equals(a, "en", StringComparison.OrdinalIgnoreCase))
{
_isRussian = false;
_resolvedLanguage = "en (config)";
return;
}
string text = language;
if (string.IsNullOrEmpty(text))
{
try
{
text = Localization.CurrentLanguage;
}
catch
{
text = null;
}
}
_isRussian = LooksRussian(text);
_resolvedLanguage = (text ?? "unknown") + (_isRussian ? " -> ru" : " -> en");
}
private static bool LooksRussian(string language)
{
if (string.IsNullOrEmpty(language))
{
return false;
}
string text = language.Trim().ToLowerInvariant();
if (!text.StartsWith("ru") && !text.Contains("russ") && !text.Contains("ukrain") && !text.Contains("belarus") && !text.Contains("укра") && !text.Contains("бела"))
{
return text.Contains("рус");
}
return true;
}
private static void Apply(bool logIt)
{
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Expected O, but got Unknown
if (_patchDisabled)
{
return;
}
ActiveName[] applied = _applied;
if (applied.Length == 0)
{
return;
}
_appliedSignature = Signature();
bool flag = default(bool);
try
{
Dictionary<AssetGuid, string> localizedStrings = Localization.LocalizedStrings;
ManualLogSource log;
if (localizedStrings == null)
{
if (!logIt)
{
return;
}
log = _log;
if (log != null)
{
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" localization dictionary is not ready yet");
}
log.LogWarning(val);
}
return;
}
int num = 0;
int num2 = 0;
ActiveName[] array = applied;
foreach (ActiveName activeName in array)
{
if (!Localization.HasKey(activeName.Key))
{
num2++;
continue;
}
localizedStrings[activeName.Key] = Format(activeName, _isRussian);
num++;
}
Dictionary<GuidKey, string> descriptions = _descriptions;
int num3 = 0;
foreach (KeyValuePair<GuidKey, string> item in descriptions)
{
AssetGuid val2 = item.Key.ToAssetGuid();
if (!((AssetGuid)(ref val2)).IsEmpty && Localization.HasKey(val2))
{
localizedStrings[val2] = item.Value;
num3++;
}
}
if (num <= 0)
{
goto IL_0203;
}
if (!logIt)
{
ConfigEntry<bool> debug = Plugin.Debug;
if (debug == null || !debug.Value)
{
goto IL_0203;
}
}
log = _log;
if (log != null)
{
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(83, 6, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" applied ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(applied.Length);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" name(s) to client localization ");
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("(language=");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(_resolvedLanguage);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", missing keys=");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num2);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", descriptions=");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num3);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")");
}
log.LogInfo(val3);
}
goto IL_0275;
IL_0275:
EclipseBridge.RequestApply();
return;
IL_0203:
if (num == 0)
{
ConfigEntry<bool> debug2 = Plugin.Debug;
if (debug2 != null && debug2.Value)
{
log = _log;
if (log != null)
{
BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(57, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" localization not ready for injection yet ");
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("(missing keys=");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num2);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")");
}
log.LogDebug(val4);
}
}
}
goto IL_0275;
}
catch (Exception ex)
{
if (!logIt)
{
return;
}
ManualLogSource log = _log;
if (log != null)
{
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(28, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[WeaponsOnBLOODLUST]");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" localization apply failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
}
}
}
}
}