| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using SPTarkov.DI.Annotations;
- using SPTarkov.Server.Core.DI;
- using SPTarkov.Server.Core.Models.Common;
- using SPTarkov.Server.Core.Models.Eft.Common.Tables;
- using SPTarkov.Server.Core.Models.Spt.Tables;
- using SPTarkov.Common.Models.Logging;
- namespace Pj568.WeaponCrossModding;
- /// <summary>
- /// 服务端 mod:
- /// 1. 让 UZI StormWerkz 瞄具基座的 mod_scope 槽支持安装 ELCAN SpecterDR 1x/4x 及其 FDE 变体,
- /// 以及 SIG Sauer BRAVO4 4x30 瞄准镜;
- /// 2. 让 StormWerkz 顶盖导轨可安装到 CR 200DS 转轮手枪的前准星槽;
- /// 3. 让 CR 200DS 的前准星槽支持安装 MP-18 瞄具基座;
- /// 4. 让 PPSh-41 冲锋枪的枪管槽支持安装莫辛纳甘的全部 4 种尺寸枪管;
- /// 5. 让 PPSh-41 冲锋枪的枪托槽支持安装 Benelli M3 可伸缩枪托、PKM / PKP 枪托、Ultima MP-155 塑料手枪式握把与 KS-23 金属枪托;
- /// 6. 让 HUXWRX HX-QD 消音器(含黄褐色变体)与 PPSh-41 防尘盖互不兼容;
- /// 7. 让 Aim Sports“三轨”莫辛步枪导轨的第一个战术配件槽(mod_tactical_000)支持安装多种前握把(不含 KeyMod / M-LOK 型);
- /// 8. 让 UZI StormWerkz 护木底轨的 mod_tactical 槽支持安装 Zenit RK 系列前握把;
- /// 9. 让 PPSh-41 冲锋枪的枪托槽支持安装 M14 SAGE International M14ALCS (MOD-0) 枪托;
- /// 10. 让 Aim Sports“三轨”的瞄具槽支持安装 M14 DCSB 瞄具基座;
- /// 11. 让 Aim Sports“三轨”的第一个战术配件槽支持安装 SV-98 隔热带与 Fortis Shift 战术前握把;
- /// 12. 让 Aim Sports“三轨”的第二个战术配件槽支持安装 SV-98 隔热带;
- /// 13. 让 M14 SAGE International M14ALCS (MOD-0) 枪托的握把位支持安装 AR-15 Tactical Dynamics 镂空手枪式握把、
- /// Tyrant Designs MOD Chevron AR-15 镂空手枪式握把(黑 / 黄 / 红)与 AS VAL Rotor 43 手枪式握把附缓冲管转接器;
- /// 14. 让 CR 50DS 转轮手枪的前准星槽支持安装 StormWerkz 顶盖导轨与 MP-18 瞄具基座;
- /// 15. 让 CR 50DS 转轮手枪的战术设备槽支持安装 Zenit RK 系列前握把、KAC MWS 脚架转接器
- /// 与 BT10 V8 Atlas 折叠脚架;
- /// 16. 让 730mm 标准莫辛枪管的前准星槽支持安装 MDR BLK LBL ALX 脚架(16 与 20 型号);
- /// 17. 让 AA-12 457mm 枪管的导轨槽(mod_mount)支持安装 M60 脚架;
- /// 18. 让 MP-18 与 Marlin MXLR 的枪托槽(mod_stock)支持安装 KS-23 金属枪托;
- /// 19. 让 RPD 520mm 枪管的枪口槽(mod_muzzle)支持安装 AKM PBS-1 消音器;
- /// 20. 让 PPSh-41 冲锋枪的枪管槽支持安装 M700 的全部 4 种枪管、ORSIS T-5000M 枪管
- /// 与 SKS / OP-SKS 的 520mm 枪管;
- /// 21. 让 PPSh-41 冲锋枪的枪托槽支持安装 Zveno PK 缓冲管转接器;
- /// 22. 让 PPSh-41 冲锋枪的机匣槽支持安装 TAPCO Intrafuse 与 Fab Defence UAS SKS 枪身套件;
- /// 23. 让两个 SKS 枪身套件与除 KS-23 金属枪托之外的全部 PPSh-41 枪托(含原装木制枪托与 Zveno 缓冲管转接器)互不兼容;
- /// 24. 让两个 SKS 枪身套件与 PPSh-41 的 71 发弹鼓互不兼容;
- /// 25. 让 KS-23 金属枪托与两个 SKS 枪身套件枪托槽可装的配件互不兼容;
- /// 26. 让 SKS 与 OP-SKS 照门固定环的照门槽(mod_sight_rear)支持安装 TKPD 导轨防尘盖;
- /// 27. 让 TKPD 导轨防尘盖与 SKS / OP-SKS 枪本体互不兼容;
- /// 28. 让 PPSh-41 冲锋枪的枪管槽支持安装 SVT-40 / AVT-40 共用的 7.62x54R 625mm 枪管;
- /// 29. 让 SVT-40 625mm 枪管的照门槽(mod_sight_rear)支持安装 TKPD 导轨防尘盖;
- /// 30. 让 TKPD 导轨防尘盖与 SVT-40 / AVT-40 枪本体双向互不兼容;
- /// 31. 让 SVT-40 标准枪口装置的准星槽(mod_sight_front)支持安装 MDR BLK LBL ALX 脚架(16 与 20 型号);
- /// 32. 让 PPSh-41 冲锋枪的枪管槽支持安装 SVDS 照门固定环;
- /// 33. 将莫辛 200mm、M700 全部 4 种、ORSIS T-5000M 枪管自 PPSh-41 枪管槽移至 SVDS 照门固定环的护木槽(mod_handguard),
- /// 并让这些枪管与 SVDS 枪本体双向互不兼容;
- /// 34. 让 SVDS 照门固定环的照门槽(mod_sight_rear)支持安装 TKPD 导轨防尘盖,且该防尘盖与 SVDS 枪本体双向互不兼容;
- /// 35. 让 SVDS 照门固定环的护木槽(mod_handguard)支持安装 SVDS 枪管,且 SVDS 枪管与自身互斥;
- /// 36. 让 SVDS 照门固定环与 PPSh-41 防尘盖双向互不兼容;
- /// 37. 让 SVDS 照门固定环与 TAPCO Intrafuse SKS 枪身套件双向互不兼容;
- /// 38. 让 SVDS 照门固定环护木槽可装的 3 种原版 SVDS 护木与 PPSh-41 枪本体双向互不兼容;
- /// 39. 让 Fab Defence UAS SKS 枪身套件的下导轨(mod_tactical_002)支持安装 MDR BLK LBL ALX 20 脚架;
- /// 40. 让 SVDS 照门固定环的护木槽支持安装 SVT-40 625mm 枪管,且该枪管与 SVDS 枪本体双向互不兼容;
- /// 41. 让 TKPD 导轨防尘盖与自身互斥,防止重复安装;
- /// 42. 让 SVT-40 625mm 枪管的照门槽支持安装 5 种 SKS 导气管防尘盖;
- /// 43. 让 MDR BLK LBL ALX 20 脚架与自身互斥,防止重复安装;
- /// 44. 让 SVDS 照门固定环的护木槽支持安装照门固定环自身;
- /// 45. 让 SVDS 照门固定环的照门槽支持安装 OP-SKS 标准 / SKS 木制标准 / ATI Monte Carlo 3 种 SKS 导气管防尘盖与 UltiMAK M1-B AK 导气管套件;
- /// 46. 让 5 种 SKS 导气管防尘盖与 UltiMAK M1-B AK 导气管套件彼此之间(含与自身)互不兼容,使一把武器上最多只能装一个;
- /// 47. 让 UltiMAK M1-B AK 导气管套件的战术配件槽(mod_tactical_000)支持安装 MDR BLK LBL ALX 20 脚架。
- /// 48. 让 20x1mm 玩具枪的膛室在保留 20x1mm 能力的同时支持全部 7 种 7.62x25 托卡列夫弹药
- /// (只补膛室白名单,不动武器单值 ammoCaliber;其原装弹匣不直接支持,改由 MXLR 弹仓链路供弹)。
- /// 49. 让 Marlin MXLR .308 ME 杠杆步枪的 5 发管状弹仓支持全部 7 种 7.62x25 托卡列夫弹药。
- /// 50. 让 20x1mm 玩具枪的 mod_magazine 槽支持安装 Marlin MXLR 的 5 发管状弹仓。
- /// 51. 让 Alpha Dog Alpha 9 9x19 声音抑制器的 mod_scope 槽支持安装 M14 SAGE International DCSB 瞄具基座。
- /// 52. 让 EMTI-019 基座的 mod_scope 槽支持安装 DCSB 瞄具基座。
- /// 53. 让 MTs-255-12 12 号左轮霰弹枪的护木槽(mod_handguard)支持安装 MP-18 的全部护木(木制 / 塑料),
- /// 枪托槽(mod_stock)支持安装雷明顿 Model 870 的 Magpul SGA、Remington SPS 与 Shockwave Raptor 枪托
- /// (不含 Mesa Tactical LEO 转接器与 Fab Defence AGR 握把)。
- ///
- /// 做法:往目标槽的 SlotFilter.Filter(HashSet<MongoId>)追加物品 id(幂等)。
- /// </summary>
- [Injectable(InjectionType.Singleton, OnLoadOrder.Preload + 4)]
- public class WeaponCrossModdingPlugin(
- ISptLogger<WeaponCrossModdingPlugin> logger,
- TemplateTable templateTable) : IOnLoad
- {
- private const string ScopeSlotName = "mod_scope";
- private const string SightSlotName = "mod_sight_front";
- private const string SightRearSlotName = "mod_sight_rear";
- private const string BarrelSlotName = "mod_barrel";
- private const string StockSlotName = "mod_stock";
- private const string TacticalSlotName = "mod_tactical";
- private const string MountSlotName = "mod_mount";
- private const string MuzzleSlotName = "mod_muzzle";
- private const string RecieverSlotName = "mod_reciever"; // 游戏数据拼写即 reciever
- private const string HandguardSlotName = "mod_handguard";
- // UZI StormWerkz 瞄具基座(顶盖导轨)
- private const string StormwerkzTopCoverRailId = "6698c90829e062525d0ad8ad";
- // ELCAN SpecterDR 1x/4x(黑)与 FDE 变体
- private const string SpecterDrId = "57ac965c24597706be5f975c";
- private const string SpecterDrFdeId = "57aca93d2459771f2c7e26db";
- // SIG Sauer BRAVO4 4x30 瞄准镜
- private const string Bravo4Id = "57adff4f24597737f373b6e6";
- // CR 200DS 转轮手枪(Chiappa Rhino 200DS 9x19 revolver)—— 前准星槽。
- private const string Cr200DsId = "624c2e8614da335f1e034d8c";
- // CR 50DS 转轮手枪(Chiappa Rhino 50DS .357 revolver)—— 前准星槽与战术设备槽。
- private const string Cr50DsId = "61a4c8884f95bc3b2c5dc96f";
- // MP-18 瞄具基座
- private const string Mp18ScopeBaseId = "61f804acfcba9556ea304cb8";
- // KAC MWS 脚架转接器(自带 mod_bipod 槽)与 BT10 V8 Atlas 折叠脚架。
- private const string KacMwsBipodAdapterId = "676175bb48fa5c377e06fc36";
- private const string Bt10AtlasBipodId = "6644920d49817dc7d505ca71";
- // PPSh-41 冲锋枪(承载枪管槽与枪托槽)。
- private const string Ppsh41Id = "5ea03f7400685063ec28bfa8";
- // 莫辛纳甘枪管(4 种尺寸)
- private const string MosinBarrel200Id = "5bfd4cc90db834001d23e846"; // 200mm 锯短
- private const string MosinBarrel220ThreadedId = "5bfd4cd60db834001c38f095"; // 220mm 锯短螺纹
- private const string MosinBarrel514Id = "5bfd4cbe0db834001b73449f"; // 514mm 卡宾
- private const string MosinBarrel730Id = "5ae09bff5acfc4001562219d"; // 730mm 标准
- // MDR BLK LBL ALX 脚架(16 / 20 型号,由 WTT-ContentBackport 注入;安装于 730mm 标准莫辛枪管的前准星槽)。
- private const string AlxBipod16Id = "680f6d9a4d7624d36e06527b";
- private const string AlxBipod20Id = "680f7e4aeee716732708e84e";
- private const string AlxBipod20Label = "MDR BLK LBL ALX 20 bipod";
- // PPSh-41 枪托槽兼容的枪托 / 握把。
- private const string BenelliM3TelescopicStockId = "6259c3387d6aab70bc23a18d"; // Benelli M3 可伸缩枪托
- private const string PkmWoodenStockId = "646371a9f2404ab67905c8e6"; // PKM 木制枪托
- private const string PkZenitPt2StockId = "6492d7847363b8a52206bc52"; // Zenit PT-2 "Klassika" PK 机枪枪托
- private const string PkpPolymerStockId = "6492e3a97df7d749100e29ee"; // PKP 聚合物枪托
- private const string UltimaMp155PistolGripId = "606eef46232e5a31c233d500"; // Ultima MP-155 塑料手枪式握把
- private const string Ks23MetalStockId = "5e848dc4e4dbc5266a4ec63d"; // KS-23 金属枪托(原版仅可装于 KS-23M 聚合物手枪式握把的 mod_stock 槽)
- // M14 SAGE International M14ALCS (MOD-0) 枪托。
- private const string M14AlcsButtstockId = "5addc7ac5acfc400194dbd90";
- // M14 SAGE International DCSB 瞄具基座。
- private const string M14DcsbMountId = "5addbffe5acfc4001714dfac";
- // Alpha Dog Alpha 9 9x19 声音抑制器(其 mod_scope 槽承载 M14 DCSB 瞄具基座)。
- private const string AlphaDogSuppressorId = "5a33a8ebc4a282000c5a950d";
- private const string AlphaDogSuppressorLabel = "Alpha Dog 9x19 suppressor";
- // PPSh-41 防尘盖(mod_reciever 槽承载物品)。
- private const string Ppsh41DustCoverId = "5ea03e5009aa976f2e7a514b";
- // HUXWRX HX-QD 7.62x51 消音器(黑 / 黄褐色变体)—— 由 WTT-ContentBackport 注入。
- private const string HuxwrxHxQdId = "6a158e4abf497aade10030e0";
- private const string HuxwrxHxQdTanId = "6a1eb32c6cd328ea90037455";
- // Aim Sports“三轨”莫辛步枪导轨;改第一个与第二个战术配件槽(mod_tactical_000 / mod_tactical_001)。
- private const string AimSportsTriRailId = "5bbdb811d4351e45020113c7";
- private const string AimSportsTriRailTacticalSlotName = "mod_tactical_000";
- private const string AimSportsTriRailSecondTacticalSlotName = "mod_tactical_001";
- private const string AimSportsTriRailLabel = "Aim Sports tri-rail";
- // Fab Defence UAS SKS 枪身套件的下导轨(原本兼容脚架的第三个战术槽)。
- private const string FabDefenceUasLowerRailSlotName = "mod_tactical_002";
- // UltiMAK M1-B AK 导气管套件的第一个战术配件槽。
- private const string UltimakM1BTacticalSlotName = "mod_tactical_000";
- // UZI StormWerkz 护木底轨(mod_tactical 槽)。
- private const string StormwerkzLowerHandguardRailId = "66992f7d9950f5f4cd0602a8";
- private const string StormwerkzLowerHandguardLabel = "UZI StormWerkz lower handguard rail";
- // Zenit RK 系列前握把。
- private static readonly string[] ZenitRkForegripIds =
- [
- "5c1bc4812e22164bef5cfde7", // RK-0
- "5c1bc5612e221602b5429350", // RK-1
- "5c1bc5af2e221602b412949b", // RK-2
- "5c1bc5fb2e221602b1779b32", // RK-4
- "5c1bc7432e221602b412949d", // RK-5
- "5c1bc7752e221602b1779b34", // RK-6
- ];
- // Aim Sports“三轨”第一个战术配件槽兼容的前握把(RK 系列见上;不含 KeyMod / M-LOK 型)。
- private static readonly string[] AimSportsTriRailForegripIds =
- [
- .. ZenitRkForegripIds,
- // 镂空前握把
- "5f6340d3ca442212f4047eb2", // Tactical Dynamics 镂空前握把
- // 垂直前握把
- "5c7fc87d2e221644f31c0298", // BCM GUNFIGHTER MOD 3 vertical
- "5c87ca002e221600114cb150", // KAC vertical
- "5cda9bcfd7f00c0c0b53e900", // ASh-12 vertical
- // TangoDown Stubby BGV-MK46K
- "558032614bdc2de7118b4585", // (Black)
- "58c157be86f77403c74b2bb6", // (FDE)
- "58c157c886f774032749fb06", // (Stealth Grey)
- ];
- // Aim Sports“三轨”第一 / 第二个战术配件槽兼容的其它配件。
- private const string Sv98HeatRibbonId = "56083eab4bdc2d26448b456a"; // SV-98 隔热带(anti-heat ribbon)
- private const string FortisShiftForegripId = "59f8a37386f7747af3328f06"; // Fortis Shift 战术前握把
- // AK-100 系列聚合物护木(handguard_ak_izhmash_ak100_rail_plastic)的 mod_foregrip 槽兼容的全部前握把。
- private static readonly string[] Ak100PolymerHandguardForegripIds =
- [
- // 垂直前握把
- "5c7fc87d2e221644f31c0298", // BCM GUNFIGHTER MOD 3 vertical
- "5cda9bcfd7f00c0c0b53e900", // ASh-12 vertical
- "5c87ca002e221600114cb150", // KAC vertical
- // Zenit RK 系列
- "5c1bc4812e22164bef5cfde7", // RK-0
- "5c1bc5612e221602b5429350", // RK-1
- "5c1bc5af2e221602b412949b", // RK-2
- "5c1bc5fb2e221602b1779b32", // RK-4
- "5c1bc7432e221602b412949d", // RK-5
- "5c1bc7752e221602b1779b34", // RK-6
- // 镂空前握把
- "5f6340d3ca442212f4047eb2", // Tactical Dynamics 镂空前握把
- // TangoDown Stubby BGV-MK46K
- "558032614bdc2de7118b4585", // (Black)
- "58c157be86f77403c74b2bb6", // (FDE)
- "58c157c886f774032749fb06", // (Stealth Grey)
- // 其它前握把
- "59f8a37386f7747af3328f06", // Fortis Shift 战术前握把
- "619386379fb0c665d5490dbe",
- "59fc48e086f77463b1118392",
- "5fce0cf655375d18a253eff0",
- "5cf4fb76d7f00c065703d3ac",
- "5b057b4f5acfc4771e1bd3e9",
- "5c791e872e2216001219c40a",
- "591af28e86f77414a27a9e1d",
- "5c1cd46f2e22164bef5cfedb",
- // 较新增前握把(可能来自更新或模组)
- "64806bdd26c80811d408d37a",
- "64807a29e5ffe165600abc97",
- "648067db042be0705c0b3009",
- "65169d5b30425317755f8e25",
- "655df24fdf80b12750626d0a",
- "655dccfdbdcc6b5df71382b6",
- "661e52e29c8b4dadef008577",
- "661e53149c8b4dadef008579",
- "661e52415be02310ed07a07a",
- "661e52b5b099f32c28003586",
- ];
- // M14 SAGE International M14ALCS (MOD-0) 枪托的握把位兼容的握把。
- private const string M14AlcsPistolGripSlotName = "mod_pistol_grip";
- private const string TacticalDynamicsSkeletonizedGripId = "5b07db875acfc40dc528a5f6"; // AR-15 Tactical Dynamics 镂空手枪式握把
- // Tyrant Designs MOD Chevron AR-15 镂空手枪式握把(黑 / 黄 / 红变体)—— 由 WTT-ContentBackport 注入。
- private const string TyrantChevronGripBlackId = "6984b7d56be2752c150e6895";
- private const string TyrantChevronGripYellowId = "698dac21772d6f3dc00e4284";
- private const string TyrantChevronGripRedId = "6985eb089edef67ade080b72";
- // AS VAL Rotor 43 手枪式握把附缓冲管转接器(自带 AR 规格缓冲管与 mod_stock_000 槽)。
- private const string AsValRotor43GripId = "5a69a2ed8dc32e000d46d1f1";
- // AA-12 457mm 枪管(mod_mount 导轨槽宿主)。
- private const string Aa12Barrel457Id = "670fced86a7e274b1a0964e8";
- // MTs-255-12 12 号左轮霰弹枪(weapon_ckib_mc_255_12g)—— 护木槽与枪托槽宿主。
- private const string Mts255Id = "60db29ce99594040e04c4a27";
- // MP-18 7.62x54R 单发步枪及其全部护木(木制 / 塑料)。
- private const string Mp18RifleId = "61f7c9e189e6fb1a5e3ea78d";
- private const string Mp18HandguardWoodId = "61f7b85367ddd414173fdb36";
- private const string Mp18HandguardPlasticId = "61f8024263dc1250e26eb029";
- // 雷明顿 Model 870 12 号霰弹枪(5a7828548dc32e5a9c28b516)mod_stock 枪托槽支持的枪托
- //(已去掉 Mesa Tactical LEO 转接器与 Fab Defence AGR 握把)。
- private static readonly string[] M870StockIds =
- [
- "5a78813bc5856700186c4abe", // Magpul SGA
- "5a7880d0c5856700142fdd9d", // Remington SPS
- "5a788169c5856700142fdd9e", // Shockwave Technologies Raptor grip
- ];
- // Marlin MXLR .308 ME 杠杆步枪(由 WTT-ContentBackport 注入)。
- private const string MarlinMxlrId = "67c6de3ce39861860909e8e5";
- // M60 脚架。
- private const string M60BipodId = "66012d9a3dff5074ed002e33";
- // RPD 520mm 枪管(mod_muzzle 枪口槽宿主)与 AKM PBS-1 消音器。
- private const string RpdBarrel520Id = "6513eff1e06849f06c0957d4";
- private const string AkmPbs1Id = "5a0d63621526d8dba31fe3bf";
- // M700 枪管(4 种)与 ORSIS T-5000M 枪管(可安装于 PPSh-41 枪管槽)。
- private const string M700Barrel660Id = "5bfebc250db834001a6694e1"; // 26 英寸
- private const string M700Barrel508ThreadedId = "5bfebc320db8340019668d79"; // 20 英寸螺纹
- private const string M700BarrelStainless660Id = "5d2702e88abbc31ed91efc44"; // 26 英寸不锈钢
- private const string M700BarrelStainless508ThreadedId = "5d2703038abbc3105103d94c"; // 20 英寸不锈钢螺纹
- private const string T5000Barrel660Id = "5df256570dee1b22f862e9c4"; // ORSIS T-5000M 660mm
- // SKS 与 OP-SKS 的 520mm 枪管(可安装于 PPSh-41 枪管槽)。
- private const string SksBarrel520Id = "634f02331f9f536910079b51"; // SKS(TOZ)
- private const string OpsksBarrel520Id = "634eff66517ccc8a960fc735"; // OP-SKS(Molot)
- // SKS 枪身套件(可安装于 PPSh-41 机匣槽):TAPCO Intrafuse 与 Fab Defence UAS。
- private const string TapcoIntrafuseSksId = "5afd7ded5acfc40017541f5e";
- private const string FabDefenceUasSksId = "5d0236dad7ad1a0940739d29";
- // UltiMAK M1-B AK 导气管套件(其 mod_tactical_000 战术配件槽承载 MDR BLK LBL ALX 20 脚架)。
- private const string UltimakM1BId = "59ccfdba86f7747f2109a587";
- // 上述两个套件的枪托槽分别只接受的配件(用于与 KS-23 金属枪托建立互斥)。
- private const string TapcoIntrafuseBufferTubeId = "5afd7e095acfc40017541f61";
- private const string FabDefenceUasFoldingStockId = "653ed132896b99b40a0292e6";
- // PPSh-41 原装木制枪托(用于与 SKS 枪身套件建立互斥)。
- private const string Ppsh41StockWoodId = "5ea03e9400685063ec28bfa4";
- // Zveno PK 缓冲管转接器(由 WTT-ContentBackport 注入;可安装于 PPSh-41 枪托槽)。
- private const string ZvenoBufferTubeId = "6a182c39b913af92800d8b5d";
- // PPSh-41 7.62x25 71 发弹鼓。
- private const string Ppsh71DrumMagId = "5ea034f65aad6446a939737e";
- // 20x1mm 玩具枪(weapon_ussr_pd_20x1mm):其膛室兼容 7.62x25,弹匣槽用于搭载 MXLR 弹仓。
- private const string ToyGunId = "66015072e9f84d5680039678";
- private const string ToyGunLabel = "20x1mm toy gun";
- // Marlin MXLR .308 ME 杠杆步枪的 5 发管状弹仓(由 WTT-ContentBackport 注入)。
- // 让 MXLR 弹仓兼容 7.62x25;玩具枪弹匣槽兼容 MXLR 弹仓。
- private const string MxlrMagId = "67c5424826265106dd0697a4";
- private const string MxlrMagLabel = "Marlin MXLR 5-round magazine";
- // 弹匣槽名(玩具枪等宿主共用)。
- private const string MagazineSlotName = "mod_magazine";
- // 7.62x25 托卡列夫弹药(Caliber762x25TT)全部 7 种。
- private static readonly (string Id, string Label)[] Caliber762x25Ammo =
- [
- ("5735fdcd2459776445391d61", "AKBS"),
- ("5735ff5c245977640e39ba7e", "FMJ43"),
- ("573601b42459776410737435", "LRN"),
- ("573602322459776445391df1", "LRNPC"),
- ("5736026a245977644601dc61", "P Gl"),
- ("573603562459776430731618", "Pst gzh"),
- ("573603c924597764442bd9cb", "T Gzh"),
- ];
- // EMTI-019 基座(游戏本体自带,非 Mod 物品):其瞄具槽支持 DCSB 瞄具基座。
- private const string EmtiId = "5dfe14f30b92095fd441edaf";
- private const string EmtiLabel = "EMTI-019 mount";
- // SKS / OP-SKS 照门固定环(mod_sight_rear 照门槽宿主)与 TKPD 导轨防尘盖(由 WTT 注入)。
- private const string SksRearSightBlockId = "634f04d82e5def262d0b30c6";
- private const string OpsksRearSightBlockId = "634f05a21f9f536910079b56";
- private const string TkpdRailedDustCoverId = "68aee8f8130c00663d08aeb3";
- // SKS 与 OP-SKS 枪本体(用于与 TKPD 导轨防尘盖建立互斥)。
- private const string SksWeaponId = "574d967124597745970e7c94";
- private const string OpsksWeaponId = "587e02ff24597743df3deaeb";
- // SVT-40 7.62x54R 625mm 枪管(可安装于 PPSh-41 枪管槽;其 mod_sight_rear 照门槽承载 TKPD 导轨防尘盖)。
- private const string Svt40Barrel625Id = "6410758c857473525b08bb77";
- // SVT-40 与 AVT-40 枪本体(用于与 TKPD 导轨防尘盖建立互斥)。
- private const string Svt40WeaponId = "643ea5b23db6f9f57107d9fd";
- private const string Avt40WeaponId = "6410733d5dd49d77bd07847e";
- // SVT-40 标准枪口装置(其 mod_sight_front 准星槽承载 MDR BLK LBL ALX 脚架;SVT-40 与 AVT-40 共用)。
- private const string Svt40MuzzleStdId = "64119d1f2c6d6f921a0929f8";
- // SVDS 照门固定环(mount_svd_izhmash_svd_s_lower_band_std,含 mod_handguard 护木槽与 mod_sight_rear 照门槽)。
- private const string SvdsRearSightBlockId = "5c471c2d2e22164bef5d077f";
- // SVDS 枪本体与 SVDS 枪管(枪管用于与自身建立互斥以防重复安装)。
- private const string SvdsWeaponId = "5c46fbd72e2216398b5a8c9c";
- private const string SvdsBarrelId = "5c471cb32e221602b177afaa";
- // 自 PPSh-41 枪管槽移至 SVDS 照门固定环护木槽的枪管(用于与 SVDS 枪本体建立互斥)。
- private static readonly (string Id, string Label)[] SvdsMovedBarrels =
- [
- (MosinBarrel200Id, "Mosin 200mm barrel"),
- (M700Barrel660Id, "M700 26-inch barrel"),
- (M700Barrel508ThreadedId, "M700 20-inch threaded barrel"),
- (M700BarrelStainless660Id, "M700 26-inch stainless barrel"),
- (M700BarrelStainless508ThreadedId, "M700 20-inch stainless threaded barrel"),
- (T5000Barrel660Id, "ORSIS T-5000M 660mm barrel"),
- ];
- // SVDS 照门固定环 mod_handguard 护木槽可装的原版护木(用于与 PPSh-41 枪本体建立双向互斥)。
- private static readonly (string Id, string Label)[] SvdsHandguards =
- [
- ("5e5699df2161e06ac158df6f", "SVDS CAA XRS DRG handguard"),
- ("5e56991336989c75ab4f03f6", "SVDS modernized kit handguard"),
- ("5c471c6c2e221602b66cd9ae", "SVDS standard handguard"),
- ];
- // 原生 SKS 导气箍 mod_mount_000 槽可装的 5 种导气管防尘盖(用于 SVT-40 625mm 枪管照门槽白名单)。
- private static readonly (string Id, string Label)[] SksGasTubeCovers =
- [
- ("634f03d40384a3ba4f06f874", "OP-SKS standard gas cover"),
- ("634f08a21f9f536910079b5a", "SKS wooden standard gas cover"),
- ("653ecd065a1690d9d90491e6", "TAPCO SKS gas cover"),
- ("653ece125a1690d9d90491e8", "Fab Defence UAS SKS gas cover"),
- ("653ecc425a1690d9d90491e4", "ATI Monte Carlo SKS gas cover"),
- ];
- // SVDS 照门固定环照门槽兼容的 4 种导气管件:3 种 SKS 导气管防尘盖与 UltiMAK M1-B AK 导气管套件。
- private static readonly (string Id, string Label)[] SvdsGasTubeItems =
- [
- ("634f03d40384a3ba4f06f874", "OP-SKS standard gas cover"),
- ("634f08a21f9f536910079b5a", "SKS wooden standard gas cover"),
- ("653ecc425a1690d9d90491e4", "ATI Monte Carlo SKS gas cover"),
- (UltimakM1BId, "UltiMAK M1-B AK gas tube kit"),
- ];
- // 参与“一把武器最多一个”互斥的 6 种导气管件:5 种 SKS 导气管防尘盖与 UltiMAK M1-B AK 导气管套件。
- private static readonly (string Id, string Label)[] ExclusiveGasTubeItems =
- [
- .. SksGasTubeCovers,
- (UltimakM1BId, "UltiMAK M1-B AK gas tube kit"),
- ];
- // PPSh-41 枪托槽可装的全部枪托(用于与 SKS 枪身套件建立双向互斥;不含 KS-23 金属枪托)。
- private static readonly (string Id, string Label)[] Ppsh41StockConflicts =
- [
- (Ppsh41StockWoodId, "PPSh-41 wooden stock"),
- (BenelliM3TelescopicStockId, "Benelli M3 telescopic stock"),
- (PkmWoodenStockId, "PKM wooden stock"),
- (PkZenitPt2StockId, "Zenit PT-2 stock"),
- (PkpPolymerStockId, "PKP polymer stock"),
- (UltimaMp155PistolGripId, "Ultima MP-155 pistol grip"),
- (M14AlcsButtstockId, "M14ALCS (MOD-0) stock"),
- (ZvenoBufferTubeId, "Zveno buffer tube adapter"),
- ];
- // PPSh-41 机匣槽可装的 SKS 枪身套件。
- private static readonly (string Id, string Label)[] SksChassisKits =
- [
- (TapcoIntrafuseSksId, "TAPCO Intrafuse SKS"),
- (FabDefenceUasSksId, "Fab Defence UAS SKS"),
- ];
- // 两个 SKS 枪身套件枪托槽可装的配件(用于与 KS-23 金属枪托建立双向互斥)。
- private static readonly (string Id, string Label)[] SksChassisStockParts =
- [
- (TapcoIntrafuseBufferTubeId, "TAPCO Intrafuse buffer tube"),
- (FabDefenceUasFoldingStockId, "Fab Defence UAS folding stock"),
- ];
- // 日志中用于标识槽位承载者的短名。
- private const string MountLabel = "mount";
- private const string Cr200DsLabel = "CR 200DS";
- private const string Cr50DsLabel = "CR 50DS";
- private const string Ppsh41Label = "PPSh-41";
- private const string M14ButtstockLabel = "M14ALCS (MOD-0) stock";
- private const string RpdBarrel520Label = "RPD 520mm barrel";
- private const string MosinBarrel730Label = "Mosin 730mm barrel";
- private const string Aa12Barrel457Label = "AA-12 457mm barrel";
- private const string Mp18RifleLabel = "MP-18 rifle";
- private const string Mts255Label = "MTs-255-12";
- private const string MarlinMxlrLabel = "Marlin MXLR";
- private const string SksRearSightBlockLabel = "SKS rear sight block";
- private const string OpsksRearSightBlockLabel = "OP-SKS rear sight block";
- private const string TkpdRailedDustCoverLabel = "TKPD railed dust cover";
- private const string Svt40Barrel625Label = "SVT-40 625mm barrel";
- private const string Svt40MuzzleStdLabel = "SVT-40 muzzle";
- private const string SvdsRearSightBlockLabel = "SVDS rear sight block";
- private const string SvdsBarrelLabel = "SVDS barrel";
- private const string FabDefenceUasSksLabel = "Fab Defence UAS SKS";
- private const string UltimakM1BLabel = "UltiMAK M1-B AK gas tube kit";
- public Task OnLoadAsync(CancellationToken cancellationToken)
- {
- try
- {
- cancellationToken.ThrowIfCancellationRequested();
- Dictionary<MongoId, TemplateItem> items = templateTable.Items;
- // UZI StormWerkz 顶盖导轨的 mod_scope 槽:追加 SpecterDR 与 BRAVO4 瞄具。
- AddItemIdsToSlot(items, StormwerkzTopCoverRailId, MountLabel, ScopeSlotName, SpecterDrId, SpecterDrFdeId, Bravo4Id);
- // CR 200DS 前准星槽:追加 StormWerkz 顶盖导轨与 MP-18 瞄具基座。
- AddItemIdsToSlot(items, Cr200DsId, Cr200DsLabel, SightSlotName, StormwerkzTopCoverRailId, Mp18ScopeBaseId);
- // CR 50DS 前准星槽:追加 StormWerkz 顶盖导轨与 MP-18 瞄具基座。
- AddItemIdsToSlot(items, Cr50DsId, Cr50DsLabel, SightSlotName, StormwerkzTopCoverRailId, Mp18ScopeBaseId);
- // CR 50DS 战术设备槽:追加 Zenit RK 系列前握把、KAC MWS 脚架转接器与 BT10 V8 Atlas 折叠脚架。
- AddItemIdsToSlot(items, Cr50DsId, Cr50DsLabel, TacticalSlotName, [.. ZenitRkForegripIds, KacMwsBipodAdapterId, Bt10AtlasBipodId]);
- // PPSh-41 枪管槽:追加莫辛纳甘 220mm 螺纹 / 514mm / 730mm 枪管、SKS / OP-SKS 的 520mm 枪管、
- // SVT-40 / AVT-40 共用的 625mm 枪管与 SVDS 照门固定环(原莫辛 200mm、M700、ORSIS T-5000M 已移至 SVDS 照门固定环)。
- AddItemIdsToSlot(items, Ppsh41Id, Ppsh41Label, BarrelSlotName,
- MosinBarrel220ThreadedId, MosinBarrel514Id, MosinBarrel730Id,
- SksBarrel520Id, OpsksBarrel520Id, Svt40Barrel625Id,
- SvdsRearSightBlockId);
- // PPSh-41 机匣槽(mod_reciever):追加 TAPCO Intrafuse 与 Fab Defence UAS SKS 枪身套件。
- AddItemIdsToSlot(items, Ppsh41Id, Ppsh41Label, RecieverSlotName, TapcoIntrafuseSksId, FabDefenceUasSksId);
- // 730mm 标准莫辛枪管的前准星槽:追加 MDR BLK LBL ALX 脚架(16 与 20 型号)。
- AddItemIdsToSlot(items, MosinBarrel730Id, MosinBarrel730Label, SightSlotName, AlxBipod16Id, AlxBipod20Id);
- // SVT-40 标准枪口装置的 mod_sight_front 前准星槽:追加 MDR BLK LBL ALX 脚架(16 与 20 型号)。
- AddItemIdsToSlot(items, Svt40MuzzleStdId, Svt40MuzzleStdLabel, SightSlotName, AlxBipod16Id, AlxBipod20Id);
- // PPSh-41 枪托槽:追加 Benelli M3 可伸缩枪托、PKM / PKP 枪托、Ultima MP-155 握把、
- // KS-23 金属枪托、M14 SAGE International M14ALCS (MOD-0) 枪托与 Zveno PK 缓冲管转接器。
- AddItemIdsToSlot(items, Ppsh41Id, Ppsh41Label, StockSlotName, BenelliM3TelescopicStockId, PkmWoodenStockId, PkZenitPt2StockId, PkpPolymerStockId, UltimaMp155PistolGripId, Ks23MetalStockId, M14AlcsButtstockId, ZvenoBufferTubeId);
- // SKS / OP-SKS 照门固定环的 mod_sight_rear 照门槽:追加 TKPD 导轨防尘盖。
- AddItemIdsToSlot(items, SksRearSightBlockId, SksRearSightBlockLabel, SightRearSlotName, TkpdRailedDustCoverId);
- AddItemIdsToSlot(items, OpsksRearSightBlockId, OpsksRearSightBlockLabel, SightRearSlotName, TkpdRailedDustCoverId);
- // SVT-40 625mm 枪管的 mod_sight_rear 照门槽:追加 TKPD 导轨防尘盖与 5 种 SKS 导气管防尘盖。
- AddItemIdsToSlot(items, Svt40Barrel625Id, Svt40Barrel625Label, SightRearSlotName,
- [TkpdRailedDustCoverId, .. SksGasTubeCovers.Select(x => x.Id)]);
- // SVDS 照门固定环的 mod_handguard 护木槽:追加莫辛 200mm、M700 全部 4 种、ORSIS T-5000M、SVDS 枪管、SVT-40 625mm 枪管与照门固定环自身。
- AddItemIdsToSlot(items, SvdsRearSightBlockId, SvdsRearSightBlockLabel, HandguardSlotName,
- MosinBarrel200Id, M700Barrel660Id, M700Barrel508ThreadedId, M700BarrelStainless660Id, M700BarrelStainless508ThreadedId, T5000Barrel660Id,
- SvdsBarrelId, Svt40Barrel625Id, SvdsRearSightBlockId);
- // SVDS 照门固定环的 mod_sight_rear 照门槽:追加 TKPD 导轨防尘盖与 4 种导气管件(3 种 SKS 防尘盖 + UltiMAK M1-B)。
- AddItemIdsToSlot(items, SvdsRearSightBlockId, SvdsRearSightBlockLabel, SightRearSlotName,
- [TkpdRailedDustCoverId, .. SvdsGasTubeItems.Select(x => x.Id)]);
- // PPSh-41 防尘盖与 HUXWRX HX-QD 消音器互不兼容。
- AddDustCoverSuppressorConflict(items);
- // 两个 SKS 枪身套件(机匣槽)与除 KS-23 金属枪托之外的全部 PPSh-41 枪托互不兼容。
- AddSksChassisConflicts(items);
- // 两个 SKS 枪身套件与 PPSh-41 的 71 发弹鼓互不兼容。
- AddSksChassisDrumConflict(items);
- // KS-23 金属枪托与两个 SKS 枪身套件枪托槽可装的配件互不兼容。
- AddKs23StockSksChassisStockPartConflicts(items);
- // TKPD 导轨防尘盖与 SKS / OP-SKS 枪本体互不兼容。
- AddDustCoverSksConflicts(items);
- // TKPD 导轨防尘盖与自身互不兼容(防止重复安装)。
- AddTkpdSelfConflict(items);
- // TKPD 导轨防尘盖与 SVT-40 / AVT-40 枪本体双向互不兼容。
- AddDustCoverSvtAvtConflicts(items);
- // SVDS 照门固定环引入的互斥(移植枪管、TKPD 与 SVDS 枪本体;SVDS 枪管防重;照门固定环与 PPSh-41 防尘盖)。
- AddSvdsConflicts(items);
- // MDR BLK LBL ALX 20 脚架与自身互不兼容(防止重复安装)。
- AddAlxBipod20SelfConflict(items);
- // 5 种 SKS 导气管防尘盖与 UltiMAK M1-B 彼此(含与自身)互不兼容,使一把武器上最多只能装一个。
- AddGasTubeMutualConflicts(items);
- // Aim Sports“三轨”的第一个战术配件槽:追加多种前握把、SV-98 隔热带与 Fortis Shift 前握把。
- AddItemIdsToSlot(items, AimSportsTriRailId, AimSportsTriRailLabel, AimSportsTriRailTacticalSlotName, [.. AimSportsTriRailForegripIds, Sv98HeatRibbonId, FortisShiftForegripId]);
- // Aim Sports“三轨”的第二个战术配件槽:追加 SV-98 隔热带。
- AddItemIdsToSlot(items, AimSportsTriRailId, AimSportsTriRailLabel, AimSportsTriRailSecondTacticalSlotName, Sv98HeatRibbonId);
- // Aim Sports“三轨”的瞄具槽:追加 M14 DCSB 瞄具基座。
- AddItemIdsToSlot(items, AimSportsTriRailId, AimSportsTriRailLabel, ScopeSlotName, M14DcsbMountId);
- // Alpha Dog 9x19 声音抑制器的 mod_scope 槽:追加 M14 DCSB 瞄具基座。
- AddItemIdsToSlot(items, AlphaDogSuppressorId, AlphaDogSuppressorLabel, ScopeSlotName, M14DcsbMountId);
- // Fab Defence UAS SKS 枪身套件的下导轨(mod_tactical_002):追加 MDR BLK LBL ALX 20 脚架与 AK-100 聚合物护木兼容的全部前握把。
- AddItemIdsToSlot(items, FabDefenceUasSksId, FabDefenceUasSksLabel, FabDefenceUasLowerRailSlotName, [AlxBipod20Id, .. Ak100PolymerHandguardForegripIds]);
- // UltiMAK M1-B AK 导气管套件的战术配件槽(mod_tactical_000):追加 MDR BLK LBL ALX 20 脚架。
- AddItemIdsToSlot(items, UltimakM1BId, UltimakM1BLabel, UltimakM1BTacticalSlotName, AlxBipod20Id);
- // M14ALCS (MOD-0) 枪托的握把位:追加 AR-15 Tactical Dynamics 镂空手枪式握把、
- // Tyrant Designs MOD Chevron 镂空手枪式握把(黑 / 黄 / 红)与 AS VAL Rotor 43 手枪式握把。
- AddItemIdsToSlot(items, M14AlcsButtstockId, M14ButtstockLabel, M14AlcsPistolGripSlotName,
- TacticalDynamicsSkeletonizedGripId, TyrantChevronGripBlackId, TyrantChevronGripYellowId, TyrantChevronGripRedId, AsValRotor43GripId);
- // UZI StormWerkz 护木底轨的 mod_tactical 槽:追加 Zenit RK 系列前握把。
- AddItemIdsToSlot(items, StormwerkzLowerHandguardRailId, StormwerkzLowerHandguardLabel, TacticalSlotName, ZenitRkForegripIds);
- // AA-12 457mm 枪管的 mod_mount 导轨槽:追加 M60 脚架。
- AddItemIdsToSlot(items, Aa12Barrel457Id, Aa12Barrel457Label, MountSlotName, M60BipodId);
- // RPD 520mm 枪管的 mod_muzzle 枪口槽:追加 AKM PBS-1 消音器。
- AddItemIdsToSlot(items, RpdBarrel520Id, RpdBarrel520Label, MuzzleSlotName, AkmPbs1Id);
- // MP-18 与 Marlin MXLR 的 mod_stock 枪托槽:追加 KS-23 金属枪托。
- AddItemIdsToSlot(items, Mp18RifleId, Mp18RifleLabel, StockSlotName, Ks23MetalStockId);
- AddItemIdsToSlot(items, MarlinMxlrId, MarlinMxlrLabel, StockSlotName, Ks23MetalStockId);
- // MTs-255-12 的 mod_handguard 护木槽:追加 MP-18 的全部护木;
- // mod_stock 枪托槽:追加雷明顿 Model 870 支持的全部枪托。
- AddItemIdsToSlot(items, Mts255Id, Mts255Label, HandguardSlotName, Mp18HandguardWoodId, Mp18HandguardPlasticId);
- AddItemIdsToSlot(items, Mts255Id, Mts255Label, StockSlotName, M870StockIds);
- // 20x1mm 玩具枪的膛室:保留 7.62x25 托卡列夫全部 7 种弹药兼容(不动 ammoCaliber;其原装弹匣不直接支持,改由 MXLR 弹仓供弹)。
- AddAmmoIdsToContainer(items, ToyGunId, ToyGunLabel, isChamber: true, [.. Caliber762x25Ammo.Select(x => x.Id)]);
- // Marlin MXLR 5 发管状弹仓的装填位:追加 7.62x25 托卡列夫全部 7 种弹药。
- AddAmmoIdsToContainer(items, MxlrMagId, MxlrMagLabel, isChamber: false, [.. Caliber762x25Ammo.Select(x => x.Id)]);
- // 20x1mm 玩具枪的 mod_magazine 槽:追加 Marlin MXLR 5 发管状弹仓。
- AddItemIdsToSlot(items, ToyGunId, ToyGunLabel, MagazineSlotName, MxlrMagId);
- // EMTI-019 基座的 mod_scope 槽:追加 DCSB 瞄具基座。
- AddItemIdsToSlot(items, EmtiId, EmtiLabel, ScopeSlotName, M14DcsbMountId);
- }
- catch (Exception ex)
- {
- logger.Error("WeaponCrossModding failed: " + ex.Message);
- }
- return Task.CompletedTask;
- }
- /// <summary>
- /// 往 <paramref name="ownerId"/> 名为 <paramref name="slotName"/> 的槽的各 Filter 追加 <paramref name="itemIds"/>(幂等)。
- /// </summary>
- private void AddItemIdsToSlot(
- Dictionary<MongoId, TemplateItem> items,
- string ownerId,
- string ownerLabel,
- string slotName,
- params string[] itemIds)
- {
- if (!items.TryGetValue(ownerId, out TemplateItem? owner))
- {
- logger.Warning($"WeaponCrossModding: {ownerLabel} id '{ownerId}' not found in Items");
- return;
- }
- IEnumerable<Slot>? slots = owner.Properties?.Slots;
- if (slots is null)
- {
- logger.Warning($"WeaponCrossModding: {ownerLabel} has no slots");
- return;
- }
- foreach (Slot slot in slots.Where(s => s is not null && string.Equals(s.Name, slotName, StringComparison.OrdinalIgnoreCase)))
- {
- IEnumerable<SlotFilter>? filters = slot.Properties?.Filters;
- if (filters is null)
- {
- continue;
- }
- foreach (SlotFilter filter in filters)
- {
- foreach (string itemId in itemIds)
- {
- AddToFilter(filter, itemId, owner, slot);
- }
- }
- }
- }
- /// <summary>
- /// 往 <paramref name="ownerId"/> 的膛室(Chambers)或弹匣装填位(Cartridges)各 Filter 追加弹药 id(幂等)。
- /// 这两者都是 <see cref="Slot"/> 列表,其 <c>Properties.Filters[].Filter</c> 决定可容纳的弹药模板。
- /// </summary>
- private void AddAmmoIdsToContainer(
- Dictionary<MongoId, TemplateItem> items,
- string ownerId,
- string ownerLabel,
- bool isChamber,
- params string[] ammoIds)
- {
- if (!items.TryGetValue(ownerId, out TemplateItem? owner))
- {
- logger.Warning($"WeaponCrossModding: {ownerLabel} id '{ownerId}' not found in Items");
- return;
- }
- IEnumerable<Slot>? containers = isChamber ? owner.Properties?.Chambers : owner.Properties?.Cartridges;
- if (containers is null)
- {
- logger.Warning($"WeaponCrossModding: {ownerLabel} has no {(isChamber ? "chambers" : "cartridges")}");
- return;
- }
- foreach (Slot container in containers.Where(c => c is not null))
- {
- IEnumerable<SlotFilter>? filters = container.Properties?.Filters;
- if (filters is null)
- {
- continue;
- }
- foreach (SlotFilter filter in filters)
- {
- foreach (string ammoId in ammoIds)
- {
- AddToFilter(filter, ammoId, owner, container);
- }
- }
- }
- }
- /// <summary>
- /// 让 PPSh-41 防尘盖与 HUXWRX HX-QD 消音器(含黄褐色变体)互不兼容(幂等)。
- /// 防尘盖为原版物品、必定存在;消音器由 WTT-ContentBackport 注入,若不在 Items 中则跳过
- /// (防尘盖侧足以建立冲突,且避开了第三方 mod 的加载时序依赖)。
- /// </summary>
- private void AddDustCoverSuppressorConflict(Dictionary<MongoId, TemplateItem> items)
- {
- AddConflictingItems(items, Ppsh41DustCoverId, "PPSh-41 dust cover", HuxwrxHxQdId, HuxwrxHxQdTanId);
- AddConflictingItems(items, HuxwrxHxQdId, "HUXWRX HX-QD", Ppsh41DustCoverId);
- AddConflictingItems(items, HuxwrxHxQdTanId, "HUXWRX HX-QD (Tan)", Ppsh41DustCoverId);
- }
- /// <summary>
- /// 让两个 SKS 枪身套件(装于 PPSh-41 机匣槽)与除 KS-23 金属枪托之外的
- /// 全部 PPSh-41 枪托双向互不兼容(幂等)。
- /// Zveno 由 WTT-ContentBackport 注入,若缺失则跳过该项。
- /// </summary>
- private void AddSksChassisConflicts(Dictionary<MongoId, TemplateItem> items)
- {
- foreach ((string chassisId, string chassisLabel) in SksChassisKits)
- {
- AddConflictingItems(items, chassisId, chassisLabel, [.. Ppsh41StockConflicts.Select(x => x.Id)]);
- foreach ((string stockId, string stockLabel) in Ppsh41StockConflicts)
- {
- AddConflictingItems(items, stockId, stockLabel, chassisId);
- }
- }
- }
- /// <summary>
- /// 让两个 SKS 枪身套件(装于 PPSh-41 机匣槽)与 PPSh-41 的 71 发弹鼓双向互不兼容(幂等)。
- /// 两者均为原版物品、必定存在,故双向建立冲突。
- /// </summary>
- private void AddSksChassisDrumConflict(Dictionary<MongoId, TemplateItem> items)
- {
- foreach ((string chassisId, string chassisLabel) in SksChassisKits)
- {
- AddConflictingItems(items, chassisId, chassisLabel, Ppsh71DrumMagId);
- AddConflictingItems(items, Ppsh71DrumMagId, "PPSh-41 71-round drum", chassisId);
- }
- }
- /// <summary>
- /// 让 KS-23 金属枪托与两个 SKS 枪身套件枪托槽可装的配件双向互不兼容(幂等)。
- /// 所有相关物品均为原版物品、必定存在,故双向建立冲突。
- /// </summary>
- private void AddKs23StockSksChassisStockPartConflicts(Dictionary<MongoId, TemplateItem> items)
- {
- foreach ((string partId, string partLabel) in SksChassisStockParts)
- {
- AddConflictingItems(items, Ks23MetalStockId, "KS-23 metal stock", partId);
- AddConflictingItems(items, partId, partLabel, Ks23MetalStockId);
- }
- }
- /// <summary>
- /// 让 TKPD 导轨防尘盖与 SKS / OP-SKS 枪本体双向互不兼容(幂等)。
- /// SKS / OP-SKS 为原版物品;TKPD 导轨防尘盖由 WTT-ContentBackport 注入,若缺失则跳过。
- /// </summary>
- private void AddDustCoverSksConflicts(Dictionary<MongoId, TemplateItem> items)
- {
- AddConflictingItems(items, TkpdRailedDustCoverId, TkpdRailedDustCoverLabel, SksWeaponId, OpsksWeaponId);
- AddConflictingItems(items, SksWeaponId, "SKS", TkpdRailedDustCoverId);
- AddConflictingItems(items, OpsksWeaponId, "OP-SKS", TkpdRailedDustCoverId);
- }
- /// <summary>
- /// 让 TKPD 导轨防尘盖与 SVT-40 / AVT-40 枪本体双向互不兼容(幂等)。
- /// SVT-40 / AVT-40 为原版物品;TKPD 导轨防尘盖由 WTT-ContentBackport 注入,若缺失则跳过。
- /// </summary>
- private void AddDustCoverSvtAvtConflicts(Dictionary<MongoId, TemplateItem> items)
- {
- AddConflictingItems(items, TkpdRailedDustCoverId, TkpdRailedDustCoverLabel, Svt40WeaponId, Avt40WeaponId);
- AddConflictingItems(items, Svt40WeaponId, "SVT-40", TkpdRailedDustCoverId);
- AddConflictingItems(items, Avt40WeaponId, "AVT-40", TkpdRailedDustCoverId);
- }
- /// <summary>
- /// SVDS 照门固定环引入的互斥(幂等):
- /// 移植到护木槽的枪管(含 SVT-40 625mm 枪管)与 SVDS 枪本体双向互斥(避免经照门固定环装到原版 SVDS 上);
- /// TKPD 导轨防尘盖与 SVDS 枪本体双向互斥;SVDS 枪管与自身互斥(防止装两个);
- /// SVDS 照门固定环与 PPSh-41 防尘盖、TAPCO Intrafuse SKS 枪身套件双向互斥;
- /// SVDS 照门固定环护木槽的原版护木与 PPSh-41 枪本体双向互斥。
- /// TKPD 与 SVDS 枪管由 WTT-ContentBackport 注入,若缺失则跳过其侧。
- /// </summary>
- private void AddSvdsConflicts(Dictionary<MongoId, TemplateItem> items)
- {
- AddConflictingItems(items, SvdsWeaponId, "SVDS", [.. SvdsMovedBarrels.Select(x => x.Id)]);
- foreach ((string barrelId, string barrelLabel) in SvdsMovedBarrels)
- {
- AddConflictingItems(items, barrelId, barrelLabel, SvdsWeaponId);
- }
- AddConflictingItems(items, TkpdRailedDustCoverId, TkpdRailedDustCoverLabel, SvdsWeaponId);
- AddConflictingItems(items, SvdsWeaponId, "SVDS", TkpdRailedDustCoverId);
- // SVDS 照门固定环护木槽新增的 SVT-40 625mm 枪管与 SVDS 枪本体双向互斥。
- AddConflictingItems(items, Svt40Barrel625Id, Svt40Barrel625Label, SvdsWeaponId);
- AddConflictingItems(items, SvdsWeaponId, "SVDS", Svt40Barrel625Id);
- AddConflictingItems(items, SvdsBarrelId, SvdsBarrelLabel, SvdsBarrelId);
- AddConflictingItems(items, SvdsRearSightBlockId, SvdsRearSightBlockLabel, Ppsh41DustCoverId);
- AddConflictingItems(items, Ppsh41DustCoverId, "PPSh-41 dust cover", SvdsRearSightBlockId);
- AddConflictingItems(items, SvdsRearSightBlockId, SvdsRearSightBlockLabel, TapcoIntrafuseSksId);
- AddConflictingItems(items, TapcoIntrafuseSksId, "TAPCO Intrafuse SKS", SvdsRearSightBlockId);
- AddConflictingItems(items, Ppsh41Id, Ppsh41Label, [.. SvdsHandguards.Select(x => x.Id)]);
- foreach ((string handguardId, string handguardLabel) in SvdsHandguards)
- {
- AddConflictingItems(items, handguardId, handguardLabel, Ppsh41Id);
- }
- }
- /// <summary>
- /// 让 TKPD 导轨防尘盖与自身互不兼容(幂等),防止重复安装。
- /// </summary>
- private void AddTkpdSelfConflict(Dictionary<MongoId, TemplateItem> items)
- {
- AddConflictingItems(items, TkpdRailedDustCoverId, TkpdRailedDustCoverLabel, TkpdRailedDustCoverId);
- }
- /// <summary>
- /// 让 MDR BLK LBL ALX 20 脚架与自身互不兼容(幂等),防止重复安装。
- /// ALX 20 由 WTT-ContentBackport 注入,若缺失则跳过。
- /// </summary>
- private void AddAlxBipod20SelfConflict(Dictionary<MongoId, TemplateItem> items)
- {
- AddConflictingItems(items, AlxBipod20Id, AlxBipod20Label, AlxBipod20Id);
- }
- /// <summary>
- /// 让 5 种 SKS 导气管防尘盖与 UltiMAK M1-B AK 导气管套件彼此之间(含与自身)互不兼容(幂等),使一把武器上最多只能装一个。
- /// </summary>
- private void AddGasTubeMutualConflicts(Dictionary<MongoId, TemplateItem> items)
- {
- string[] ids = [.. ExclusiveGasTubeItems.Select(x => x.Id)];
- foreach ((string id, string label) in ExclusiveGasTubeItems)
- {
- AddConflictingItems(items, id, label, ids);
- }
- }
- /// <summary>
- /// 往 <paramref name="ownerId"/> 的 ConflictingItems 追加 <paramref name="conflictIds"/>(幂等)。
- /// </summary>
- private void AddConflictingItems(
- Dictionary<MongoId, TemplateItem> items,
- string ownerId,
- string ownerLabel,
- params string[] conflictIds)
- {
- if (!items.TryGetValue(ownerId, out TemplateItem? owner))
- {
- logger.Debug($"WeaponCrossModding: {ownerLabel} id '{ownerId}' not in Items, skip conflicting items");
- return;
- }
- owner.Properties ??= new TemplateItemProperties();
- owner.Properties.ConflictingItems ??= new HashSet<MongoId>();
- foreach (string conflictId in conflictIds)
- {
- if (owner.Properties.ConflictingItems.Add(conflictId))
- {
- logger.Info($"WeaponCrossModding: added conflicting item '{conflictId}' to '{ownerLabel}' ({owner.Name})");
- }
- else
- {
- logger.Debug($"WeaponCrossModding: conflicting item '{conflictId}' already on '{ownerLabel}' ({owner.Name})");
- }
- }
- }
- private void AddToFilter(SlotFilter? filter, string itemId, TemplateItem parent, Slot slot)
- {
- if (filter is null)
- {
- return;
- }
- filter.Filter ??= new HashSet<MongoId>();
- if (filter.Filter.Add(itemId))
- {
- logger.Info($"WeaponCrossModding: added '{itemId}' to slot '{slot.Name}' ({parent.Name})");
- }
- else
- {
- logger.Debug($"WeaponCrossModding: '{itemId}' already in slot '{slot.Name}' ({parent.Name})");
- }
- }
- }
|