From 0f73bbf55ee8fec538c9c918950352280f4dc4e5 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Sat, 13 Jun 2026 11:40:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=A5=E5=91=8A=E6=98=BE=E7=A4=BAPer?= =?UTF-8?q?-unit=E5=8F=91=E5=B0=84=E6=95=B0=20+=20=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=A0=87=E6=98=8E=E7=81=AB=E5=8A=9B=E5=8D=95=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 五、我方部署: 从实际发射事件统计每个火力单元发射数(非想定数据) - 六、事件时序: 新增"火力单元"列,标注每发隶属哪个单元 - PlatformId→火力单元映射复用(去重) --- data/default_fireunits.json | 63 ------------------- src/CounterDrone.Core/DefaultFireUnits.cs | 2 - .../Services/ReportGenerator.cs | 37 ++++++++--- 3 files changed, 30 insertions(+), 72 deletions(-) delete mode 100644 data/default_fireunits.json diff --git a/data/default_fireunits.json b/data/default_fireunits.json deleted file mode 100644 index abeba18..0000000 --- a/data/default_fireunits.json +++ /dev/null @@ -1,63 +0,0 @@ -[ - { - "Id": "ground-standard", - "Name": "标准地基火力单元", - "PlatformType": 1, - "GunCount": 4, - "ChannelsPerGun": 4, - "ChannelInterval": 1.0, - "Cooldown": 5.0, - "AmmoChangeTime": 30.0, - "MuzzleVelocity": 800.0, - "AmmoTypes": [0, 1], - "RadarRange": 15000.0, - "EORange": 8000.0, - "IRRange": 5000.0 - }, - { - "Id": "ground-light", - "Name": "轻型地基火力单元", - "PlatformType": 1, - "GunCount": 2, - "ChannelsPerGun": 4, - "ChannelInterval": 1.0, - "Cooldown": 5.0, - "AmmoChangeTime": 30.0, - "MuzzleVelocity": 800.0, - "AmmoTypes": [0, 1], - "RadarRange": 10000.0, - "EORange": 6000.0, - "IRRange": 3000.0 - }, - { - "Id": "ground-heavy", - "Name": "重型地基火力单元", - "PlatformType": 1, - "GunCount": 6, - "ChannelsPerGun": 4, - "ChannelInterval": 1.0, - "Cooldown": 5.0, - "AmmoChangeTime": 30.0, - "MuzzleVelocity": 600.0, - "AmmoTypes": [0, 1, 2], - "RadarRange": 20000.0, - "EORange": 10000.0, - "IRRange": 6000.0 - }, - { - "Id": "air-standard", - "Name": "标准空基火力单元", - "PlatformType": 0, - "GunCount": 1, - "ChannelsPerGun": 8, - "ChannelInterval": 1.0, - "Cooldown": 5.0, - "AmmoChangeTime": 30.0, - "CruiseSpeed": 55.0, - "ReleaseAltitude": 1500.0, - "AmmoTypes": [0, 1], - "RadarRange": 0.0, - "EORange": 12000.0, - "IRRange": 8000.0 - } -] diff --git a/src/CounterDrone.Core/DefaultFireUnits.cs b/src/CounterDrone.Core/DefaultFireUnits.cs index 2bf2147..67fc059 100644 --- a/src/CounterDrone.Core/DefaultFireUnits.cs +++ b/src/CounterDrone.Core/DefaultFireUnits.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.Text.Json; -using CounterDrone.Core.Models; namespace CounterDrone.Core { diff --git a/src/CounterDrone.Core/Services/ReportGenerator.cs b/src/CounterDrone.Core/Services/ReportGenerator.cs index c28f747..bf4cb44 100644 --- a/src/CounterDrone.Core/Services/ReportGenerator.cs +++ b/src/CounterDrone.Core/Services/ReportGenerator.cs @@ -86,24 +86,47 @@ namespace CounterDrone.Core.Services sb.AppendLine(); } + // 构建 PlatformId → 火力单元 映射(去重,五和六共用) + var platToEquip = new Dictionary(); + var unitLaunchCounts = new Dictionary(); + int platIdx = 1, unitNum = 0; + for (int ei = 0; ei < config.Equipment.Count; ei++) + { + var eq = config.Equipment[ei]; + if (eq.EquipmentRole != (int)EquipmentRole.LaunchPlatform) continue; + int channels = (eq.GunCount ?? 1) * (eq.ChannelsPerGun ?? 1); + for (int j = 0; j < eq.Quantity; j++) + { + unitNum++; + for (int c = 0; c < channels; c++) + platToEquip[$"plat_{platIdx++}"] = unitNum; + } + } + foreach (var e in events.Where(e => e.Type == SimEventType.MunitionLaunched)) + { + if (platToEquip.TryGetValue(e.SourceId, out var u)) + unitLaunchCounts[u] = unitLaunchCounts.GetValueOrDefault(u, 0) + 1; + } + // === 五、我方部署 === sb.AppendLine("## 五、我方部署"); sb.AppendLine(); - sb.AppendLine($"| 装备 | 数量 |"); + sb.AppendLine($"| 火力单元 | 发射数 |"); sb.AppendLine($"|------|------|"); - sb.AppendLine($"| 发射平台 | {platforms.Sum(p => p.Quantity)} 台 |"); - sb.AppendLine($"| 云团位置 | ({config.Cloud.PositionX:F0}, {config.Cloud.PositionY:F0}, {config.Cloud.PositionZ:F0}) |"); - sb.AppendLine($"| 释放高度 | {config.Cloud.DisperseHeight:F0} m |"); + foreach (var kv in unitLaunchCounts.OrderBy(kv => kv.Key)) + sb.AppendLine($"| #{kv.Key} | {kv.Value} |"); sb.AppendLine(); // === 六、事件时序 === sb.AppendLine("## 六、事件时序"); sb.AppendLine(); - sb.AppendLine("| 时间(s) | 事件 | 详情 |"); - sb.AppendLine("|---------|------|------|"); + sb.AppendLine("| 时间(s) | 事件 | 详情 | 火力单元 |"); + sb.AppendLine("|---------|------|------|:------:|"); int munitionIdx = 0, cloudIdx = 0; foreach (var e in events.OrderBy(e => e.OccurredAt)) { + string unitCell = e.Type == SimEventType.MunitionLaunched && platToEquip.TryGetValue(e.SourceId, out var u) + ? $"#{u}" : "-"; var desc = e.Type switch { SimEventType.MunitionLaunched => $"第 {++munitionIdx} 发", @@ -114,7 +137,7 @@ namespace CounterDrone.Core.Services SimEventType.SimulationEnd => "仿真结束", _ => e.Description, }; - sb.AppendLine($"| {e.OccurredAt:F1} | {TranslateEvent(e.Type)} | {desc} |"); + sb.AppendLine($"| {e.OccurredAt:F1} | {TranslateEvent(e.Type)} | {desc} | {unitCell} |"); } sb.AppendLine();