Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CoalGrades v0.1.1
CoalGrades.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CoalGrades.Config; using CoalGrades.Items; using CoalGrades.Kiln; using CoalGrades.Localization; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CoalGrades { [BepInPlugin("LJS.CoalGrades", "CoalGrades", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string ModGuid = "LJS.CoalGrades"; public const string ModName = "CoalGrades"; public const string ModVersion = "0.1.1"; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; CoalGradesConfig.Init(((BaseUnityPlugin)this).Config); CoalGradeLocalization.Register(); _harmony = new Harmony("LJS.CoalGrades"); _harmony.PatchAll(); PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; Log.LogInfo((object)"[CoalGrades] CoalGrades v0.1.1 로드 완료"); } private void OnVanillaPrefabsAvailable() { try { CoalGradeItems.RegisterItems(); } catch (Exception arg) { Log.LogError((object)$"[CoalGrades] 아이템 등록 중 오류: {arg}"); } try { LogLocalizedNames(); } catch (Exception arg2) { Log.LogError((object)$"[CoalGrades] 등급 석탄 표시 이름 로그 출력 중 오류: {arg2}"); } try { KilnConversionSetup.Apply(); } catch (Exception arg3) { Log.LogError((object)$"[CoalGrades] 숯가마 변환 설정 중 오류: {arg3}"); } } private static void LogLocalizedNames() { string[] allGradeIds = CoalGradeItems.AllGradeIds; foreach (string text in allGradeIds) { ItemDrop itemDrop = CoalGradeItems.GetItemDrop(text); if (!((Object)(object)itemDrop == (Object)null)) { string text2 = Localization.instance.Localize(itemDrop.m_itemData.m_shared.m_name); Log.LogInfo((object)("[CoalGrades] " + text + " 표시 이름: " + text2)); } } } } } namespace CoalGrades.Localization { internal static class CoalGradeLocalization { private const string KoreanLanguage = "Korean"; private const string EnglishLanguage = "English"; private static readonly Dictionary<string, string> s_english = new Dictionary<string, string> { { "item_ljs_lignite", "Lignite" }, { "item_ljs_lignite_desc", "Coal baked from logs. Burns longer than ordinary coal." }, { "item_ljs_subbituminous", "Subbituminous Coal" }, { "item_ljs_subbituminous_desc", "Coal baked from ancient bark. Noticeably hotter burning." }, { "item_ljs_bituminous", "Bituminous Coal" }, { "item_ljs_bituminous_desc", "Glossy black coal baked from Yggdrasil wood." }, { "item_ljs_anthracite", "Anthracite" }, { "item_ljs_anthracite_desc", "Premium coal baked from Ashwood. Burns hot and smokeless." }, { "item_ljs_graphite", "Graphite" }, { "item_ljs_graphite_desc", "The final stage of carbonization for wood of the far north. Burns the hottest of all." } }; private static readonly Dictionary<string, string> s_korean = new Dictionary<string, string> { { "item_ljs_lignite", "갈탄" }, { "item_ljs_lignite_desc", "통나무를 구워 낸 석탄. 보통 석탄보다 오래 탄다." }, { "item_ljs_subbituminous", "아역청탄" }, { "item_ljs_subbituminous_desc", "고대 나무껍질로 구운 석탄. 화력이 한층 좋다." }, { "item_ljs_bituminous", "역청탄" }, { "item_ljs_bituminous_desc", "이그드라실 나무로 구운, 검게 윤이 나는 석탄." }, { "item_ljs_anthracite", "무연탄" }, { "item_ljs_anthracite_desc", "잿가루나무로 구운 최상급 석탄. 연기 없이 뜨겁게 탄다." }, { "item_ljs_graphite", "흑연" }, { "item_ljs_graphite_desc", "북부의 나무가 도달한 석탄화의 끝. 가장 뜨겁게 탄다." } }; private static bool s_registered; private static Action<Localization, string, string> s_addWord; private static bool s_addWordBuilt; public static void Register() { if (!s_registered) { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string>(s_english)); text = "Korean"; localization.AddTranslation(ref text, new Dictionary<string, string>(s_korean)); s_registered = true; } } public static void ReapplyTo(Localization instance, string language) { if (instance == null) { return; } Dictionary<string, string> dictionary = ((language == "Korean") ? s_korean : s_english); EnsureAddWordBuilt(); if (s_addWord == null) { return; } foreach (KeyValuePair<string, string> item in dictionary) { s_addWord(instance, item.Key, item.Value); } } private static void EnsureAddWordBuilt() { if (s_addWordBuilt) { return; } s_addWordBuilt = true; try { MethodInfo methodInfo = AccessTools.Method(typeof(Localization), "AddWord", (Type[])null, (Type[])null); s_addWord = AccessTools.MethodDelegate<Action<Localization, string, string>>(methodInfo, (object)null, true); } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] Localization.AddWord 델리게이트 생성 실패: {arg}"); } } } [HarmonyPatch(typeof(Localization), "SetupLanguage")] internal static class LocalizationSetupLanguagePatch { private static void Postfix(Localization __instance, string language) { try { CoalGradeLocalization.ReapplyTo(__instance, language); } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] 언어 전환 시 번역 재적용 중 오류: {arg}"); } } } } namespace CoalGrades.Kiln { internal static class KilnConversionSetup { private const string KilnPrefabName = "charcoal_kiln"; public static void Apply() { if (!CoalGradesConfig.EnableKilnConversions.Value) { return; } GameObject prefab = PrefabManager.Instance.GetPrefab("charcoal_kiln"); if ((Object)(object)prefab == (Object)null) { Plugin.Log.LogWarning((object)"[CoalGrades] 프리팹 \"charcoal_kiln\"을 찾을 수 없어 숯가마 변환 설정을 건너뜁니다."); return; } Smelter component = prefab.GetComponent<Smelter>(); if ((Object)(object)component == (Object)null) { Plugin.Log.LogWarning((object)"[CoalGrades] \"charcoal_kiln\"에 Smelter 컴포넌트가 없어 숯가마 변환 설정을 건너뜁니다."); } else { ApplyMapping(component); } } public static void ApplyToInstance(Smelter smelter) { if (CoalGradesConfig.EnableKilnConversions.Value && !((Object)(object)smelter == (Object)null) && !((Object)(object)((Component)smelter).gameObject == (Object)null) && ((Object)((Component)smelter).gameObject).name.StartsWith("charcoal_kiln")) { ApplyMapping(smelter); } } private static void ApplyMapping(Smelter smelter) { //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown Dictionary<string, string> dictionary = CoalGradesConfig.ParseConversionMap(); foreach (KeyValuePair<string, string> item in dictionary) { string key = item.Key; string value = item.Value; GameObject prefab = PrefabManager.Instance.GetPrefab(key); if ((Object)(object)prefab == (Object)null) { Plugin.Log.LogWarning((object)("[CoalGrades] ConversionMap 입력 프리팹 \"" + key + "\"을 찾을 수 없어 이 항목을 건너뜁니다.")); continue; } GameObject prefab2 = PrefabManager.Instance.GetPrefab(value); if ((Object)(object)prefab2 == (Object)null) { Plugin.Log.LogWarning((object)("[CoalGrades] ConversionMap 산출 프리팹 \"" + value + "\"을 찾을 수 없어 이 항목을 건너뜁니다.")); continue; } ItemDrop component = prefab.GetComponent<ItemDrop>(); ItemDrop component2 = prefab2.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Plugin.Log.LogWarning((object)("[CoalGrades] \"" + key + ":" + value + "\"에 ItemDrop이 없어 이 항목을 건너뜁니다.")); } else { ItemConversion val = FindConversion(smelter, key); if (val != null) { val.m_to = component2; continue; } smelter.m_conversion.Add(new ItemConversion { m_from = component, m_to = component2 }); } } } private static ItemConversion FindConversion(Smelter smelter, string fromName) { foreach (ItemConversion item in smelter.m_conversion) { if ((Object)(object)item.m_from != (Object)null && ((Object)((Component)item.m_from).gameObject).name == fromName) { return item; } } return null; } } [HarmonyPatch(typeof(Smelter), "Awake")] internal static class SmelterAwakeKilnPatch { private static void Postfix(Smelter __instance) { try { KilnConversionSetup.ApplyToInstance(__instance); } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] 숯가마 인스턴스 보강 중 오류: {arg}"); } } } } namespace CoalGrades.Items { internal static class CoalGradeIcons { private static readonly Dictionary<string, Sprite> s_icons = new Dictionary<string, Sprite> { { "LJS_Lignite", null }, { "LJS_Subbituminous", null }, { "LJS_Bituminous", null }, { "LJS_Anthracite", null }, { "LJS_Graphite", null } }; public static void ApplyIcon(CustomItem item, string prefabId) { if (s_icons.TryGetValue(prefabId, out var value) && !((Object)(object)value == (Object)null)) { item.ItemDrop.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { value }; } } } internal static class CoalGradeItems { public const string Lignite = "LJS_Lignite"; public const string Subbituminous = "LJS_Subbituminous"; public const string Bituminous = "LJS_Bituminous"; public const string Anthracite = "LJS_Anthracite"; public const string Graphite = "LJS_Graphite"; public static readonly string[] AllGradeIds = new string[5] { "LJS_Lignite", "LJS_Subbituminous", "LJS_Bituminous", "LJS_Anthracite", "LJS_Graphite" }; private static readonly Dictionary<string, CustomItem> s_registered = new Dictionary<string, CustomItem>(); private static bool s_itemsRegistered; public static void RegisterItems() { //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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown if (s_itemsRegistered) { return; } string[] allGradeIds = AllGradeIds; foreach (string text in allGradeIds) { if (!s_registered.ContainsKey(text)) { string text2 = "item_" + text.ToLowerInvariant(); ItemConfig val = new ItemConfig { Name = "$" + text2, Description = "$" + text2 + "_desc" }; CustomItem val2 = new CustomItem(text, "Coal", val); if (!ItemManager.Instance.AddItem(val2)) { Plugin.Log.LogWarning((object)("[CoalGrades] 아이템 등록 실패: " + text)); continue; } CoalGradeIcons.ApplyIcon(val2, text); s_registered[text] = val2; } } s_itemsRegistered = true; } public static ItemDrop GetItemDrop(string prefabId) { CustomItem value; return s_registered.TryGetValue(prefabId, out value) ? value.ItemDrop : null; } } } namespace CoalGrades.Fuel { internal readonly struct FuelPick { public readonly string PrefabName; public readonly ItemData Item; public FuelPick(string prefabName, ItemData item) { PrefabName = prefabName; Item = item; } } internal static class FuelHelpers { public const string CoalPrefabName = "Coal"; private const float CoalFuelValue = 1f; public static float GetFuelValue(string prefabName) { if (prefabName == "Coal") { return 1f; } Dictionary<string, float> dictionary = CoalGradesConfig.ParseFuelValues(); float value; return dictionary.TryGetValue(prefabName, out value) ? value : (-1f); } public static bool IsFuelItem(string prefabName) { return GetFuelValue(prefabName) > 0f; } public static List<string> GetOrderedCandidates() { Dictionary<string, float> collection = CoalGradesConfig.ParseFuelValues(); List<KeyValuePair<string, float>> list = new List<KeyValuePair<string, float>> { new KeyValuePair<string, float>("Coal", 1f) }; list.AddRange(collection); return ((CoalGradesConfig.ConsumeOrderSetting.Value == ConsumeOrder.LowestFirst) ? list.OrderBy((KeyValuePair<string, float> p) => p.Value) : list.OrderByDescending((KeyValuePair<string, float> p) => p.Value)).Select((KeyValuePair<string, float> p) => p.Key).ToList(); } public static FuelPick? FindAvailableFuel(Inventory inventory) { foreach (string orderedCandidate in GetOrderedCandidates()) { ItemData item = inventory.GetItem(orderedCandidate, -1, true); if (item == null) { string sharedName = GetSharedName(orderedCandidate); if (!string.IsNullOrEmpty(sharedName)) { item = inventory.GetItem(sharedName, -1, false); } } if (item != null) { return new FuelPick(orderedCandidate, item); } } return null; } private static string GetSharedName(string prefabName) { object obj; if (!(prefabName == "Coal")) { obj = CoalGradeItems.GetItemDrop(prefabName); } else { GameObject prefab = PrefabManager.Instance.GetPrefab("Coal"); obj = ((prefab != null) ? prefab.GetComponent<ItemDrop>() : null); } ItemDrop val = (ItemDrop)obj; return ((Object)(object)val != (Object)null) ? val.m_itemData.m_shared.m_name : null; } } [HarmonyPatch(typeof(Smelter), "Awake")] internal static class SmelterAwakeFuelRpcPatch { private const string RpcName = "RPC_AddFuelGraded"; private static void Postfix(Smelter __instance) { try { ZNetView nview = SmelterAccess.GetNetView(__instance); if (!((Object)(object)nview == (Object)null) && nview.IsValid() && IsCoalFueled(__instance)) { nview.Register<float>("RPC_AddFuelGraded", (Action<long, float>)delegate(long sender, float amount) { RPC_AddFuelGraded(__instance, nview, sender, amount); }); } } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] 등급 석탄 연료 RPC 등록 중 오류: {arg}"); } } private static void RPC_AddFuelGraded(Smelter smelter, ZNetView nview, long sender, float amount) { //IL_003b: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) try { if (nview.IsOwner()) { float value = Mathf.Min(SmelterAccess.GetFuel(smelter) + amount, (float)smelter.m_maxFuel); SmelterAccess.SetFuel(smelter, value); smelter.m_fuelAddedEffects.Create(((Component)smelter).transform.position, ((Component)smelter).transform.rotation, ((Component)smelter).transform, 1f, -1, default(ZDOID)); } } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] RPC_AddFuelGraded 처리 중 오류: {arg}"); } } public static bool IsCoalFueled(Smelter smelter) { return (Object)(object)smelter.m_fuelItem != (Object)null && ((Object)((Component)smelter.m_fuelItem).gameObject).name == "Coal"; } public static void InvokeAddFuel(Smelter smelter, float amount) { ZNetView netView = SmelterAccess.GetNetView(smelter); if (netView != null) { netView.InvokeRPC("RPC_AddFuelGraded", new object[1] { amount }); } } } [HarmonyPatch(typeof(Smelter), "OnAddFuel")] internal static class SmelterOnAddFuelPatch { private static bool Prefix(Smelter __instance, Switch sw, Humanoid user, ItemData item, ref bool __result) { try { if (!CoalGradesConfig.EnableFuelValues.Value) { return true; } if (!SmelterAwakeFuelRpcPatch.IsCoalFueled(__instance)) { return true; } string prefabName; if (item != null) { if ((Object)(object)item.m_dropPrefab == (Object)null || !FuelHelpers.IsFuelItem(((Object)item.m_dropPrefab).name)) { ((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null, false); __result = false; return false; } prefabName = ((Object)item.m_dropPrefab).name; } else { FuelPick? fuelPick = FuelHelpers.FindAvailableFuel(user.GetInventory()); if (!fuelPick.HasValue) { ((Character)user).Message((MessageType)2, "$msg_donthaveany " + __instance.m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null, false); __result = false; return false; } prefabName = fuelPick.Value.PrefabName; item = fuelPick.Value.Item; } if (SmelterAccess.GetFuel(__instance) >= (float)__instance.m_maxFuel) { ((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null, false); __result = false; return false; } ((Character)user).Message((MessageType)2, "$msg_added " + item.m_shared.m_name, 0, (Sprite)null, false); user.GetInventory().RemoveItem(item, 1); float fuelValue = FuelHelpers.GetFuelValue(prefabName); SmelterAwakeFuelRpcPatch.InvokeAddFuel(__instance, fuelValue); __result = true; return false; } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] 연료 투입 처리 중 오류: {arg}"); return true; } } } internal static class SmelterAccess { private static Func<Smelter, float> s_getFuel; private static Action<Smelter, float> s_setFuel; private static FieldInfo s_nviewField; private static bool s_built; private static void EnsureBuilt() { if (s_built) { return; } s_built = true; try { MethodInfo methodInfo = AccessTools.Method(typeof(Smelter), "GetFuel", (Type[])null, (Type[])null); s_getFuel = AccessTools.MethodDelegate<Func<Smelter, float>>(methodInfo, (object)null, true); } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] Smelter.GetFuel 델리게이트 생성 실패: {arg}"); } try { MethodInfo methodInfo2 = AccessTools.Method(typeof(Smelter), "SetFuel", (Type[])null, (Type[])null); s_setFuel = AccessTools.MethodDelegate<Action<Smelter, float>>(methodInfo2, (object)null, true); } catch (Exception arg2) { Plugin.Log.LogError((object)$"[CoalGrades] Smelter.SetFuel 델리게이트 생성 실패: {arg2}"); } try { s_nviewField = AccessTools.Field(typeof(Smelter), "m_nview"); } catch (Exception arg3) { Plugin.Log.LogError((object)$"[CoalGrades] Smelter.m_nview FieldInfo 확보 실패: {arg3}"); } } public static float GetFuel(Smelter smelter) { EnsureBuilt(); try { return (s_getFuel != null) ? s_getFuel(smelter) : 0f; } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] Smelter.GetFuel 호출 실패: {arg}"); return 0f; } } public static void SetFuel(Smelter smelter, float value) { EnsureBuilt(); try { s_setFuel?.Invoke(smelter, value); } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] Smelter.SetFuel 호출 실패: {arg}"); } } public static ZNetView GetNetView(Smelter smelter) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown ZNetView component = ((Component)smelter).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null) { return component; } component = ((Component)smelter).GetComponentInParent<ZNetView>(); if ((Object)(object)component != (Object)null) { return component; } EnsureBuilt(); if (s_nviewField == null) { return null; } try { return (ZNetView)s_nviewField.GetValue(smelter); } catch (Exception arg) { Plugin.Log.LogError((object)$"[CoalGrades] Smelter.m_nview 리플렉션 읽기 실패: {arg}"); return null; } } } } namespace CoalGrades.Config { public enum ConsumeOrder { LowestFirst, HighestFirst } internal static class CoalGradesConfig { public static ConfigEntry<bool> EnableKilnConversions; public static ConfigEntry<bool> EnableFuelValues; public static ConfigEntry<string> ConversionMap; public static ConfigEntry<string> FuelValues; public static ConfigEntry<ConsumeOrder> ConsumeOrderSetting; public const string DefaultConversionMap = "Wood:Coal,FineWood:Coal,RoundLog:LJS_Lignite,ElderBark:LJS_Subbituminous,YggdrasilWood:LJS_Bituminous,Blackwood:LJS_Anthracite,Frostwood:LJS_Graphite"; public const string DefaultFuelValues = "LJS_Lignite:1.5,LJS_Subbituminous:2.0,LJS_Bituminous:2.5,LJS_Anthracite:3.0,LJS_Graphite:4.0"; public static void Init(ConfigFile config) { EnableKilnConversions = config.Bind<bool>("General", "EnableKilnConversions", true, "숯가마의 나무별 등급 석탄 변환을 활성화합니다."); EnableFuelValues = config.Bind<bool>("General", "EnableFuelValues", true, "제련 시설에서 등급 석탄을 배율이 적용된 연료로 사용할 수 있게 합니다."); ConversionMap = config.Bind<string>("Kiln", "ConversionMap", "Wood:Coal,FineWood:Coal,RoundLog:LJS_Lignite,ElderBark:LJS_Subbituminous,YggdrasilWood:LJS_Bituminous,Blackwood:LJS_Anthracite,Frostwood:LJS_Graphite", "숯가마 변환 목록(\"입력프리팹:산출프리팹\" 쉼표 구분). 매핑에 있는 입력은 기존 숯가마 변환을 대체합니다."); FuelValues = config.Bind<string>("Fuel", "FuelValues", "LJS_Lignite:1.5,LJS_Subbituminous:2.0,LJS_Bituminous:2.5,LJS_Anthracite:3.0,LJS_Graphite:4.0", "등급 석탄 연료 가치(\"아이템프리팹:배율\" 쉼표 구분). Coal은 목록에 없어도 항상 배율 1로 취급됩니다."); ConsumeOrderSetting = config.Bind<ConsumeOrder>("Fuel", "ConsumeOrder", ConsumeOrder.LowestFirst, "여러 등급의 석탄을 보유 중일 때 자동으로 소모할 우선순위."); } public static Dictionary<string, string> ParseConversionMap() { return ParsePairs(ConversionMap.Value); } public static Dictionary<string, float> ParseFuelValues() { Dictionary<string, float> dictionary = new Dictionary<string, float>(); foreach (KeyValuePair<string, string> item in SplitPairs(FuelValues.Value)) { if (float.TryParse(item.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { dictionary[item.Key] = result; continue; } Plugin.Log.LogWarning((object)("[CoalGrades] FuelValues 항목 \"" + item.Key + ":" + item.Value + "\"의 배율을 숫자로 변환할 수 없어 무시합니다.")); } return dictionary; } private static Dictionary<string, string> ParsePairs(string raw) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (KeyValuePair<string, string> item in SplitPairs(raw)) { dictionary[item.Key] = item.Value; } return dictionary; } private static IEnumerable<KeyValuePair<string, string>> SplitPairs(string raw) { if (string.IsNullOrWhiteSpace(raw)) { yield break; } string[] array = raw.Split(new char[1] { ',' }); foreach (string entry in array) { string trimmed = entry.Trim(); if (trimmed.Length != 0) { int idx = trimmed.IndexOf(':'); if (idx <= 0 || idx == trimmed.Length - 1) { Plugin.Log.LogWarning((object)("[CoalGrades] 설정 항목 \"" + trimmed + "\" 형식이 \"키:값\"이 아니라 무시합니다.")); } else { yield return new KeyValuePair<string, string>(trimmed.Substring(0, idx).Trim(), trimmed.Substring(idx + 1).Trim()); } } } } } }