diff --git a/HarmonySrc/CinerariumGroups.cs b/HarmonySrc/CinerariumGroups.cs index 9e8dd50..d53033c 100644 --- a/HarmonySrc/CinerariumGroups.cs +++ b/HarmonySrc/CinerariumGroups.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Xml; namespace NecromancerTome { @@ -48,8 +50,11 @@ namespace NecromancerTome static readonly HashSet MaterialNames = new HashSet { "resourceWood", "resourceWoodBundle", "resourceCloth", "resourceLeather", "resourceBone", "resourceFeather", - "resourceYuccaFibers", "resourcePaper", "resourceCement", "resourceConcreteMix", "resourceBeeswax", "resourceCandleStick" + "resourceYuccaFibers", "resourcePaper", "resourceCement", "resourceConcreteMix", "resourceBeeswax", "resourceCandleStick", + "resourceAnimalFat" }; + /// Детали, которые теги отнесли бы не туда (гвозди - патроны гвоздомёта). + static readonly HashSet PartNames = new HashSet { "resourceNail" }; static readonly HashSet AmmoParts = new HashSet { "resourceArrowHeadIron", "resourceArrowHeadSteelAP", "resourceBuckshot", "resourceBulletCasing", "resourceBulletTip", @@ -57,9 +62,39 @@ namespace NecromancerTome }; static readonly HashSet RawNames = new HashSet { - "foodRawMeat", "foodRawMeatBundle", "foodEgg", "foodHoney", "foodRottingFlesh" + "foodRawMeat", "foodRawMeatBundle", "foodEgg", "foodHoney", "foodRottingFlesh", "resourceChickenFeed" }; + /// Предметы и блоки самого мода - по его Config/items.xml и blocks.xml (у многих нет «necro» в имени: книги + /// призыва, браслет, камни портала, прах зомби, кожа жертвы). Читается один раз. + static HashSet _modNames; + + static HashSet ModNames() + { + if (_modNames != null) + { + return _modNames; + } + _modNames = new HashSet(); + foreach (string f in new[] { "items.xml", "blocks.xml" }) + { + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(Path.Combine(ModEntry.Instance.Path, "Config", f)); + foreach (XmlNode n in doc.SelectNodes("//item[@name] | //block[@name]")) + { + _modNames.Add(n.Attributes["name"].Value); + } + } + catch (Exception e) + { + UnityEngine.Debug.LogWarning("[NecromancerTome] CinerariumGroups: " + f + " мода не прочитан (" + e.Message + ")"); + } + } + return _modNames; + } + static readonly Dictionary _cache = new Dictionary(); public static int Of(ItemValue _iv) @@ -85,7 +120,7 @@ namespace NecromancerTome static int Classify(ItemClass _ic, ItemValue _iv) { string n = _ic.GetItemName() ?? ""; - if (n.IndexOf("necro", StringComparison.OrdinalIgnoreCase) >= 0) + if (n.IndexOf("necro", StringComparison.OrdinalIgnoreCase) >= 0 || ModNames().Contains(n)) { return Necro; } @@ -117,6 +152,10 @@ namespace NecromancerTome { return Chemicals; } + if (PartNames.Contains(n)) + { + return Parts; + } if (MaterialNames.Contains(n)) { return Materials; @@ -129,6 +168,10 @@ namespace NecromancerTome { return Parts; } + if (n.StartsWith("meleeTool")) + { + return Tools; // раньше оружия: у факела тег weapon + } if (n.StartsWith("gun") || n.StartsWith("meleeWpn") || Tag(_ic, "weapon")) { return Weapons; @@ -153,7 +196,7 @@ namespace NecromancerTome { return Raw; } - if (n.StartsWith("drink")) + if (n.StartsWith("drink") || n.StartsWith("tinCan")) { return Drinks; } diff --git a/NecromancerHarmony.dll b/NecromancerHarmony.dll index 085acf6..e7dc6ff 100644 Binary files a/NecromancerHarmony.dll and b/NecromancerHarmony.dll differ