Commit Graph

54 Commits

Author SHA1 Message Date
46ce1234ee 修复 Unity 编译错误:变量冲突、DroneWave.DroneType 不存在、nullable 警告
- SimulationBootstrap: scenario 变量名冲突 → sc
- ManagerVerification: DroneWave.DroneType → Target (DroneWave 无此属性)
- ReportManager: string? → 拆为两个重载避免 nullable annotation 警告
2026-06-18 15:27:13 +08:00
ad0eaf47da 完善模型属性:加 Model/Description 字段,TaskNumber→ScenarioNumber,Task→Info,Task→Scenario 方法名
- DroneProfile/DroneSpec: 加 Model、Description
- Scenario: 加 Description,TaskNumber→ScenarioNumber
- EquipmentDeployment/FireUnitSpec: 加 Description
- ScenarioConfig: Task→Info
- ScenarioService: CreateTask→CreateScenario 等方法名统一
- 238 单元测试通过
2026-06-18 15:15:41 +08:00
ca0ce8aa52 重命名核心模型:TargetConfig→DroneProfile, SimTask→Scenario, TaskFullConfig→ScenarioConfig, TaskId→ScenarioId
- DroneType 枚举清理:移除 Electric/Piston,重编号 HighSpeed=2
- planner_config.json / defaults.json 同步迁移
- 238 单元测试全部通过
2026-06-18 15:02:58 +08:00
5909c86402 fix: ManagerVerification waypoint 缺 Speed 字段 2026-06-17 23:25:08 +08:00
6098186f34 perf: 回放优先用内存 LiveFrames — 仿真刚结束时避免读数据库
FrameDataStore:
- Flush() 后保留 LiveFrames 副本在内存
- BeginRecording() / Discard() 时清除 LiveFrames

ReplayController:
- LoadReplay(taskId, frameStore) 优先取 LiveFrames
- frameStore 为 null 或 LiveFrames 为空时回退读 SQLite
- SimulationRunner 暴露 FrameStore 供 ReplayController 传入
2026-06-17 16:07:24 +08:00
5d79e26e0f feat: ScenarioManager 接入 DataService — 前端启动前即可管理基础数据 2026-06-17 15:54:20 +08:00
e782062377 feat: Unity 端接入 DataService — 前端可直接 CRUD 基础数据
SimulationRunner 新增 DataService 属性
SimulationBootstrap 自动创建 DataService 并注入 Runner
前端调用: runner.DataService.GetAllDrones() 等
2026-06-17 15:50:22 +08:00
120f2805ec feat: 基础数据 CRUD — 统一命名,建表入库,DataService 提供全 CRUD
类名规范化:
- FireUnitTemplate → FireUnitSpec(火力单元规格)
- TargetPreset → DroneSpec(无人机规格)
- DetectionPreset → SensorSpec(传感器规格)
- WeatherPreset → EnvironmentSpec(环境规格)
- RoutePreset → RouteTemplate(航线模板)

DefaultData 属性重命名:
- Targets → Drones, DetectionEquipment → Sensors, Weather → Environments
- JSON 兼容: JsonPropertyName 保持原键名

新增: IDataService + DataService — 7 类基础数据全 CRUD
新增: 6 个 Repository(SpecRepositories.cs)
新增: DatabaseManager 自动建表 + 种子数据(RouteTemplate.Waypoints JSON 序列化存储)

测试: 243 通过
2026-06-17 12:36:49 +08:00
e250093a16 docs: 更新对接文档 V1.4,同步实体属性变更
- 事件示例:cloud.Dispersion.Center → cloud.PosX/Y/Z, cloud.Radius
- API 列表:新增 Platforms 访问
- 新增 EntitySnapshot 字段文档(VelX/Y/Z)
- 新增实体属性速查表(所有 5 种实体)
- 测试状态更新:243 测试 9 秒全部通过
- Unity 脚本同步更新
2026-06-17 12:20:55 +08:00
ce9d44db7e perf: 仿真期间零字符串分配,JSON 序列化推迟到 Flush
EntitySnapshot 新增原始字段(DamageStage/Hp/CloudRadius等), CollectSnapshots 直接填值

FrameDataStore buffer 改为 FrameRecord 结构体, Flush 时统一拼 JSON

SimulationRunner 直接读 snap.CloudRadius/CloudOpacity, 移除 JsonDocument.Parse

删除 SimulationEngine 的 StringBuilder 和 Str() 方法
2026-06-15 19:18:44 +08:00
5c2b95d777 perf: FrameDataStore 改为内存缓存+结束时批量写入
RecordFrame: 仅内存追加, 零磁盘IO

Flush: 仿真Stop时单次事务批量InsertAll

BeginRecording/Discard/BufferedFrameCount 新API

SimulationEngine: 移除 _frameDb 持久连接, RecordFrames默认true

SimulationRunner: 移除所有 Debug.Log 每帧日志

ReplayController: 适配 ReadFrames 新API

FrameDataStoreTests: 6项覆盖 录制/刷新/读取/丢弃/清理
2026-06-15 18:25:21 +08:00
c379e849f0 fix: DefaultScenarios.Seed 幂等检查修复(SQL LIKE 中 [] 是通配符)
搜索关键字 [Demo]→Demo(避免 SQL LIKE 字符类误匹配)

版本升级时删除旧 Demo 任务后重建(而非跳过)
2026-06-15 17:19:43 +08:00
274779309d fix: Unity 脚本清理旧引用
ScenarioManager.SaveRoute: groupId→waveId 参数重命名

ManagerVerification: 移除冗余手动插弹药(DB已自动种子)

SimulationBootstrap: 更新为预设/自定义双模式模板
2026-06-15 16:29:31 +08:00
5f589c9644 refactor: SimulationBootstrap 更新为前端参考模板
两种模式: 预设(选[Demo]想定) / 自定义(DefaultData预设组装)

移除手动插弹药(已自动种子), 使用 DefaultData 天气/目标/航线/火力单元预设

UnityPathProvider 从 StreamingAssets 自动复制数据文件

前端文档: 快速开始改为挂 SimulationBootstrap 即运行
2026-06-15 16:27:45 +08:00
18f7b79401 fix: UnityPathProvider 首次运行自动复制数据文件
从 StreamingAssets 自动拷贝 defaults.json + planner_config.json 到 persistentDataPath

前端文档更新: 文件放 Assets/StreamingAssets/ 即可,无需手动放 persistentDataPath
2026-06-15 16:25:05 +08:00
8eeb43f0e8 feat: 统一默认数据架构 (defaults.json + DefaultData)
单一数据源 data/defaults.json,含弹药/编队/火力单元/无人机/探测/天气六类预设

版本追踪: Meta 表 + version 字段,更新时 InsertOrReplace,不删用户数据

名称统一 [Demo] 前缀,UI 中可识别为模拟数据

删除: DefaultAmmunition.cs, DefaultFireUnits.cs, default_ammo.json, default_formations.json, TestAmmo.cs

TestPathProvider 自动复制数据文件到测试目录

集成测试精简: 4个简单变体跳过,保留6个核心场景,39s
2026-06-15 15:46:20 +08:00
56d345189e refactor: 编组概念拆分为批次(WaveId)+火力单元(FireUnit)
Breaking: Group表/枚举/Service/Repository移除; GroupId->WaveId; DroneGroup->DroneWave; DroneGroupId->DroneWaveId; GroupManager删除

Docs: CHANGELOG 0.7.0; 总体架构 V10; DefensePlanner V4; 实施计划 V1.4; 对接文档 V1.2

Tests: 204/204 pass
2026-06-15 15:13:48 +08:00
11f8cb2c79 feat: detection-driven planning (v0.6.0)
Planner no longer has god-view. It assumes threats enter from detection boundary (unified info network earliest detection point), not route start.

Core: DetectionCalculator (EO attenuated by Visibility, radar/IR unaffected; earliest detection via segment-circle intersection). EquipmentDeployment: drop DetectionRadius, add RadarRange/EORange/IRange/DetectionAccuracy. FireUnit detection fields activated in BuildFireUnits. IDefensePlanner.Plan adds 4th param detectionSources.

Engine: BuildDetectionSources merges standalone detectors + fire-unit self-detection into unified list, passed to planner.

Fix: Solve robustness when GenerateFireEventsAt returns empty (detection boundary too late to intercept).

Tests 193 to 208 (+15). 0 warnings.
2026-06-15 12:52:57 +08:00
3b8fb4ee86 refactor: code cleanup - warnings, dead code, naming
Warnings (9 to 0): events declared nullable, _cache nullable, IDamageModel param nullable.

Dead code removed: DefaultFormations class + FormationTemplate; AlgorithmTypes legacy types (ThreatProfile/DefenseRecommendation/DefenseSolution/MultiGroupRecommendation/RecommendedPlatform/RecommendedDetection); DroneEntity CurrentWaypointIndex/FormationOffsetX/Y/ApplyFormationOffset/wind params; Vector3 operators+Length+DistanceTo; CloudExpansionModel Phase2Duration/TimeToDensity; Kinematics EstimatedShellTime/GaussianConcentration; InterceptCandidate write-only fields (CoverageDuration/FlightTime/ShellFlightTime); ParticleParams EmitRate/ColorHex.

Naming: DefaultDefensePlanner -> DefensePlanner (only impl of IDefensePlanner); inCloudTime -> inCloudDistance (returns meters not seconds); DamageAssessment class summary fixed; wind comments clarified (drone wind removed vs cloud wind active).

Tests: 191 pass, 0 warnings.
2026-06-14 15:52:05 +08:00
8515f7821a feat(v0.5.0): weather into planner + unified physics model
Planner no longer writes local physics formulas. All kinematics/geometry/damage go through shared utility classes (Kinematics/RouteGeometry/CloudExpansionModel/DamageAssessment).

Core: RouteGeometry (route geometry), PlannerConfig + planner_config.json (config externalization). Planner route-aware layout (offset along tangent), cloud overlap 20pct. DroneEntity arc-length driven.

Fixes: PathInSphere cloud-frame correction (root cause), GaussianPuffDispersion hardcoded Sunny, ComputeEffectiveRadius cloud age, planner wind offset, remove drone wind bias.

Tests 167 to 191, 41s. Windy scenarios pass.
2026-06-14 14:49:53 +08:00
5e29536b8b build: 更新 Unity DLL + SqliteConnectionTracker 最终修复 2026-06-13 12:35:04 +08:00
a19dced505 fix: SqliteConnectionTracker — AssemblyReloadEvents.beforeAssemblyReload 安全关闭
- 静态追踪所有 SQLiteConnection,domain reload 前 Dispose 全部
- 替换所有 GC.Collect+WaitForPendingFinalizers 为 Tracker 模式
- DatabaseManager、ScenarioManager、中、SimulationRunner 等全部 Track/Untrack
2026-06-13 12:30:48 +08:00
5c23e92587 fix: OnDisable 加 GC.Collect+WaitForPendingFinalizers 防 SQLite 析构崩溃
- sqlite-net PreparedSqlLiteInsertCommand 析构器在 GC 线程跑 sqlite3_finalize
- Domain reload 时 SQLite native 可能已卸载 → 崩溃
- GC.Collect+WaitForPendingFinalizers 确保析构器在 native 还活着时完成
2026-06-13 12:24:09 +08:00
45387fee73 refactor: 删除所有逻辑fallback——缺失配置报错而非静默跳过
- DefaultDefensePlanner: 空catalog抛ArgumentEx, 缺ammo类型抛InvalidOp
- AmmunitionSpec? → AmmunitionSpec(非空), 删除 ==null 静默返回
- 删除 0.8f射程安全系数, 1.5f时间窗口乘数
- AlgorithmFactory 移除IDefensePlanner(null)注册
- SimulationEngine 构造必须传planner,6个调用点全部更新
2026-06-13 12:19:21 +08:00
fe7eb723a1 refactor: 清除 SimEvent alias 遗留——统一使用 using CounterDrone.Core.Simulation 2026-06-13 11:50:49 +08:00
50ec14bb24 refactor: 引擎自治 — 不再需要外部传 SetFireSchedule
- SimulationEngine.Initialize 内建 BuildFireUnits/BuildDroneGroups → 自动调 Planner
- 删除 FullPipelineTests 中的 BuildFireSchedule/_lastFireSchedule/手动 SetFireSchedule
- Unity Managers 删除手动 SetFireSchedule 调用
- 引擎是 Planner 的唯一调用者,测试和 UI 不再碰火控逻辑
2026-06-13 09:58:11 +08:00
5667aef495 fix: OnDisable + Dispose 替代 OnDestroy + Close,修复 domain reload SQLite 崩溃
OnDisable 在 domain reload 前触发,Dispose() 清理 prepared statements 并调用 GC.SuppressFinalize,阻止 GC finalizer 线程崩溃
2026-06-13 09:42:10 +08:00
2bb8ba2e1e fix: Manager OnDestroy 关闭 SQLite 连接,修复 domain reload 崩溃
- 所有 Manager 在 Awake 保存 _db 引用,OnDestroy 调用 Close()
- ScenarioManager/ModelManager/ReportManager/GroupManager/SimulationRunner 全部修复
- 崩溃原因:domain reload 时 GC finalizer 线程清理 prepared statements,DB 未关闭导致 sqlite3_finalize 竞态
2026-06-13 09:35:53 +08:00
7d080bc929 fix: Unity 测试配置 - 火力单元改为 8×3 发(与集成测试一致) 2026-06-13 09:19:30 +08:00
66537d1621 fix: Unity 脚本编译错误 - 缺少 AVector3 别名和 detail 变量 2026-06-13 09:16:47 +08:00
3a2f68b02b refactor: 删除 SimulationRunner.BuildFireSchedule fallback
- Planner 输出直接传给 Engine.SetFireSchedule
- ManagerVerification/SimulationBootstrap 在 LoadAndStart 前设置 fire schedule
- 引擎不再需要从 CloudDispersal 反推发射计划
2026-06-13 09:15:21 +08:00
317f47280b refactor: DefensePlanner 替代 DefenseAdvisor
- 新增 IDefensePlanner 接口 + DefaultDefensePlanner 实现
- FireUnit 重构为统一平台模型(Type/Position/CruiseSpeed/ReleaseAltitude/MuzzleVelocity)
- DroneGroup 加入威胁指数(类型系数×速度系数)和优先级排序
- 五步流水线:威胁排序→弹药匹配→候选生成→贪心分配→时序生成
- 弹药精确匹配,不降级;临界方案基于50%概率阈值
- 删除 IDefenseAdvisor/DefaultDefenseAdvisor/RecommendMultiGroup
- AlgorithmFactory 注册 IDefensePlanner
- 测试更新:DefensePlannerTests 替代旧测试,FullPipelineTests 适配新 API
- Unity Managers 更新调用
- 125 测试全通过
2026-06-12 18:20:25 +08:00
c4d9ccc4fa feat: 空基平台飞行与投弹功能
- PlatformEntity: 新增状态机 Idle→FlyingToTarget→ReadyToRelease
- EquipmentDeployment: 新增 CruiseSpeed 字段(空基平台巡航速度)
- MunitionEntity: 空投弹药继承载机速度矢量,替代自由落体
- Kinematics: 新增 AirDropPosition/AirDropFallTime/DirectionVelocity 工具方法
- SimulationEngine: 空基平台先飞后投,AdjustFireTimesForAirBased 补偿飞行耗时
- SimulationRunner: 空基平台 3D 可视化(蓝色 Capsule)
- 集成测试 Scenario_AirBased_PlatformFliesAndDrops 通过(8x 加速)
- 实施文档同步进度
2026-06-12 17:38:21 +08:00
b7afe23238 fix: ManagerVerification用固定tickDt替代Editor不稳定的Time.deltaTime 2026-06-12 16:36:03 +08:00
845f8dcd1b 所有Manager Awake改成public + ManagerVerification直调Awake 2026-06-12 16:32:31 +08:00
1bbe5d28c5 fix: 报告生成空列表保护 + 仿真后关闭引擎防DB锁 2026-06-12 16:26:10 +08:00
aa6e4d3508 fix: TargetConfig加GroupId=default匹配RoutePlan 2026-06-12 16:21:02 +08:00
6bbad9155a fix: SimulationRunner也补SendMessage(Awake) 2026-06-12 16:18:25 +08:00
fb6c4c7c12 fix: ManagerVerification手动插入默认弹药, 数据库无JSON时表为空 2026-06-12 16:16:48 +08:00
1eba842487 fix: Edit模式下AddComponent不调Awake, 显式SendMessage 2026-06-12 16:11:51 +08:00
59732d2542 ScenarioManager.Awake加try-catch定位根因 2026-06-12 16:08:18 +08:00
b40392c64a fix: ManagerVerification显式调用Awake避免ContextMenu不触发 2026-06-12 16:06:32 +08:00
5851ce2ea8 fix: ManagerVerification + SimulationBootstrap适配多编队 Route/WaypointGroups 2026-06-12 16:04:49 +08:00
6f56cff655 fix: ScenarioManager重复Service属性导致编译失败 2026-06-12 15:52:15 +08:00
12cb6576fe 多批次Phase1: RoutePlan改Id主键+Waypoint加GroupId+ScenarioService/Engine/所有测试适配 2026-06-12 15:33:37 +08:00
b77c308517 补充GroupManager + 架构文档V8(事件驱动/FireSchedule/三阶段扩散) 2026-06-12 14:52:07 +08:00
f2204bf3b4 fix: SimulationRunner解析函数缺失 + 变量声明丢失 2026-06-12 14:43:07 +08:00
98e16ea720 CloudDispersal加SalvoRounds/Spacing, FireSchedule按间隔展开云团, 拦截成功 2026-06-12 11:32:17 +08:00
2d14c17d9c 默认弹药改为JSON文件导入 + DatabaseManager种子数据 + 测试手动插入, 129测试通过 2026-06-12 11:17:59 +08:00
6a184d9bf8 推荐算法ComputeEffectiveRadius用高斯公式,BuildFireSchedule去掉算法逻辑,129测试通过 2026-06-12 11:03:30 +08:00