refactor: 引擎自治 — 不再需要外部传 SetFireSchedule
- SimulationEngine.Initialize 内建 BuildFireUnits/BuildDroneGroups → 自动调 Planner - 删除 FullPipelineTests 中的 BuildFireSchedule/_lastFireSchedule/手动 SetFireSchedule - Unity Managers 删除手动 SetFireSchedule 调用 - 引擎是 Planner 的唯一调用者,测试和 UI 不再碰火控逻辑
This commit is contained in:
parent
77351d8198
commit
50ec14bb24
Binary file not shown.
@ -100,7 +100,6 @@ namespace CounterDrone.Unity
|
||||
|
||||
var runner = gameObject.AddComponent<SimulationRunner>();
|
||||
runner.Awake();
|
||||
runner.Engine.SetFireSchedule(plan.MergedSchedule);
|
||||
runner.LoadAndStart(taskId);
|
||||
runner.Engine.TimeScale = 10f;
|
||||
|
||||
|
||||
@ -118,7 +118,6 @@ namespace CounterDrone.Unity
|
||||
Runner = GetComponent<SimulationRunner>();
|
||||
if (Runner == null) Runner = gameObject.AddComponent<SimulationRunner>();
|
||||
else Runner.enabled = true;
|
||||
Runner.Engine.SetFireSchedule(plan.MergedSchedule);
|
||||
Runner.LoadAndStart(taskId);
|
||||
|
||||
// 设置倍速
|
||||
|
||||
@ -21,7 +21,6 @@ namespace CounterDrone.Core.Tests
|
||||
private readonly FrameDataStore _frameStore;
|
||||
private readonly SQLiteConnection _mainDb;
|
||||
private List<AmmunitionSpec> _ammoCatalog;
|
||||
private List<FireEvent> _lastFireSchedule;
|
||||
private string _taskId = string.Empty;
|
||||
|
||||
public FullPipelineTests()
|
||||
@ -52,14 +51,6 @@ namespace CounterDrone.Core.Tests
|
||||
{
|
||||
var engine = new SimulationEngine(_scenario, _frameStore, new DamageModelRouter(), _paths);
|
||||
|
||||
// 如果有推荐方案,生成发射计划
|
||||
var detail = _scenario.GetTaskDetail(_taskId)!;
|
||||
if (detail.Equipment.Any(e => e.EquipmentRole == (int)EquipmentRole.LaunchPlatform))
|
||||
{
|
||||
var schedule = BuildFireSchedule(detail);
|
||||
engine.SetFireSchedule(schedule);
|
||||
}
|
||||
|
||||
engine.Initialize(_taskId);
|
||||
engine.TimeScale = 8f; // 8倍速加速
|
||||
for (int i = 0; i < maxTicks; i++)
|
||||
@ -71,13 +62,9 @@ namespace CounterDrone.Core.Tests
|
||||
return engine;
|
||||
}
|
||||
|
||||
/// <summary>从推荐方案的时机参数生成发射计划</summary>
|
||||
private List<FireEvent> BuildFireSchedule(TaskFullConfig detail)
|
||||
{
|
||||
return _lastFireSchedule ?? new List<FireEvent>();
|
||||
}
|
||||
private static readonly string ReportOutputDir = Path.Combine(
|
||||
AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "..", "..", "reports");
|
||||
|
||||
/// <summary>创建默认火力单元并调用 Planner 生成方案</summary>
|
||||
private DefensePlan ApplyDefensePlan(PlatformType? preferredPlatform = null)
|
||||
{
|
||||
var detail = _scenario.GetTaskDetail(_taskId)!;
|
||||
@ -141,9 +128,7 @@ namespace CounterDrone.Core.Tests
|
||||
var planner = new DefaultDefensePlanner(_ammoCatalog);
|
||||
var result = planner.Plan(fireUnits, threats, detail.Scene);
|
||||
|
||||
_lastFireSchedule = result.Best.MergedSchedule;
|
||||
|
||||
// 写入云团参数(从规划方案派生的简化参数)
|
||||
// 写入云团参数
|
||||
if (threats.Count > 0)
|
||||
{
|
||||
var t = threats[0];
|
||||
@ -156,7 +141,6 @@ namespace CounterDrone.Core.Tests
|
||||
AerosolType = platType == PlatformType.AirBased ? (int)AerosolType.InertGas : (int)AerosolType.InertGas,
|
||||
PositionX = mid.X, PositionY = mid.Y, PositionZ = mid.Z,
|
||||
DisperseHeight = (float)t.Target.TypicalAltitude,
|
||||
RecommendedTiming = _lastFireSchedule.Count > 0 ? _lastFireSchedule[0].FireTime : 0,
|
||||
Source = "Algorithm",
|
||||
PositionMode = (int)PositionMode.AlgorithmRecommended,
|
||||
});
|
||||
@ -165,9 +149,6 @@ namespace CounterDrone.Core.Tests
|
||||
return result.Best;
|
||||
}
|
||||
|
||||
private static readonly string ReportOutputDir = Path.Combine(
|
||||
AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "..", "..", "reports");
|
||||
|
||||
private void VerifyAndExportReport(SimulationEngine eng, DroneEntity drone)
|
||||
{
|
||||
var detail = _scenario.GetTaskDetail(_taskId)!;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user