diff --git a/docs/对接文档_Unity前端.md b/docs/对接文档_Unity前端.md index 70c3ce2..f27b38a 100644 --- a/docs/对接文档_Unity前端.md +++ b/docs/对接文档_Unity前端.md @@ -1,7 +1,7 @@ # 后端对接文档(Unity 前端) -> **版本**:V1.3 -> **日期**:2026-06-15 +> **版本**:V1.4 +> **日期**:2026-06-17 > **Unity 版本**:2022.3.62f3c1 --- @@ -60,7 +60,7 @@ runner.Engine.TimeScale = 4f; // 加速 // 订阅事件 runner.Engine.OnMunitionLaunched += m => Instantiate(shellPrefab, ToVector3(m.PosX, m.PosY, m.PosZ)); -runner.Engine.OnCloudGenerated += c => SpawnCloud(c.Dispersion.Center, c.Dispersion.Radius); +runner.Engine.OnCloudGenerated += c => SpawnCloud(c.PosX, c.PosY, c.PosZ, c.Radius); runner.Engine.OnDroneDestroyed += d => PlayExplosion(d.PosX, d.PosY, d.PosZ); runner.Engine.OnTargetDetected += (d, det) => ShowDetectionMark(d.PosX, d.PosY, d.PosZ); runner.Engine.OnDroneReachedTarget += d => ShowReached(d.PosX, d.PosY, d.PosZ); @@ -132,7 +132,7 @@ var runner = GetComponent(); runner.Engine.SetFireSchedule(fireEvents); // 从推荐方案取 runner.LoadAndStart(taskId); runner.Engine.TimeScale = 4f; -runner.Engine.State / Drones / Clouds / Munitions / DetectionEntities / Events +runner.Engine.State / Drones / Clouds / Munitions / Platforms / DetectionEntities / Events runner.Stop(); ``` @@ -155,6 +155,32 @@ replay.LoadReplay(taskId); // replay.TotalFrames / replay.GetFrame(frameIndex) ``` +### EntitySnapshot(每帧推送) + +| 字段 | 类型 | 说明 | +|------|------|------| +| `EntityId` | string | 实体唯一 ID | +| `EntityType` | enum | Drone/Platform/Munition/Cloud/DetectionEquip | +| `PosX/Y/Z` | float | 三维位置 | +| `VelX/Y/Z` | float | 瞬时速度 (m/s) | +| `Hp` | float | 无人机血量 (0~1) | +| `DamageStage` | int | 损伤阶段 (0~N) | +| `PlatformStateStr` | string | 平台状态 (Idle/FlyingToTarget/ReadyToRelease) | +| `CloudRadius` | float | 云团有效半径 | +| `CloudOpacity` | float | 云团不透明度 (0~1) | +| `CloudPhase` | int | 云团扩散阶段 (1/2/3) | +| `CloudElapsed` | float | 云团已存在时间 (s) | + +### 实体属性(直接访问) + +| 实体 | 关键属性 | +|------|------| +| **DroneEntity** | Id, PosX/Y/Z, Hp, Status, ExposureTime, TargetType, PowerType, Wingspan, CruiseSpeed, Route, TraveledArc, TotalArc, Progress | +| **CloudEntity** | Id, PosX/Y/Z, Radius, Density, Phase, Elapsed, IsDissipated, AerosolType | +| **MunitionEntity** | Id, PosX/Y/Z, Velocity, StartX/Y/Z, LaunchTime, ElapsedTime, LaunchAngle, Azimuth, MuzzleVelocity, FlightDuration, TargetX/Y/Z, ReleaseAltitude, HasArrived | +| **PlatformEntity** | Id, PosX/Y/Z, CurrentVelocity, State, MunitionCount, Cooldown, MuzzleVelocity, CruiseSpeed, ReleaseAltitude, TargetX/Y/Z, FlightDistance | +| **DetectionEntity** | Id, PosX/Y/Z, Source, IsInRange(), IsDetected() | + --- ## 五、默认数据 @@ -201,4 +227,4 @@ dotnet publish -c Release -o ../../unity_plugins | 实体事件映射 | `docs/design/technical/仿真器实体与事件映射.md` | | 任务跟踪 | `docs/implementation/tasks/实施计划与任务跟踪.md` | | 测试报告 | `test/reports/`(每次集成测试自动生成) | -| 测试状态 | **191 测试,24 秒(集成)** | +| 测试状态 | **243 测试,9 秒(全部通过)** | diff --git a/src/Unity/Assets/Plugins/CounterDrone.Core/CounterDrone.Core.dll b/src/Unity/Assets/Plugins/CounterDrone.Core/CounterDrone.Core.dll index 7698b58..5b0da09 100644 Binary files a/src/Unity/Assets/Plugins/CounterDrone.Core/CounterDrone.Core.dll and b/src/Unity/Assets/Plugins/CounterDrone.Core/CounterDrone.Core.dll differ diff --git a/src/Unity/Assets/Scripts/Managers/SimulationRunner.cs b/src/Unity/Assets/Scripts/Managers/SimulationRunner.cs index edcb22c..51a49f5 100644 --- a/src/Unity/Assets/Scripts/Managers/SimulationRunner.cs +++ b/src/Unity/Assets/Scripts/Managers/SimulationRunner.cs @@ -92,12 +92,11 @@ namespace CounterDrone.Unity { if (!_clouds.ContainsKey(cloud.Id)) { - var pos = new UVector3(cloud.Dispersion.Center.X, cloud.Dispersion.Center.Y, cloud.Dispersion.Center.Z); + var pos = new UVector3(cloud.PosX, cloud.PosY, cloud.PosZ); var prefab = _cloudPrefab != null ? _cloudPrefab : GameObject.CreatePrimitive(PrimitiveType.Sphere); var go = Instantiate(prefab, pos, Quaternion.identity); go.name = cloud.Id; - float r = cloud.Dispersion.Radius; - go.transform.localScale = UVector3.one * r; + go.transform.localScale = UVector3.one * cloud.Radius; var mat = go.GetComponent().material; mat.color = new Color(1, 0, 0, 0.3f); _clouds[cloud.Id] = go;