fix: DefaultScenarios.Seed 幂等检查修复(SQL LIKE 中 [] 是通配符)

搜索关键字 [Demo]→Demo(避免 SQL LIKE 字符类误匹配)

版本升级时删除旧 Demo 任务后重建(而非跳过)
This commit is contained in:
tian 2026-06-15 17:19:43 +08:00
parent 274779309d
commit c379e849f0
5 changed files with 10 additions and 4 deletions

View File

@ -39,7 +39,7 @@ src/Unity/Assets/Scripts/Managers/ ← 桥接脚本
```csharp
var scenario = GetComponent<ScenarioManager>();
var demos = scenario.Search("[Demo]", null, null, 1, 100);
var demos = scenario.Search("Demo", null, null, 1, 100);
// → 返回 6 个预设想定:
// [Demo] 无防御-无人机抵达目标
// [Demo] 管控区域侵入

View File

@ -13,8 +13,14 @@ namespace CounterDrone.Core
{
public static void Seed(IScenarioService scenario, DefaultData d)
{
var existing = scenario.SearchTasks("[Demo]", null, null, 1, 100);
if (existing.TotalCount > 0) return;
// 检测旧格式任务(名称含 [Demo],但 SQL LIKE 中 [] 是通配符,搜索 "Demo"
var existing = scenario.SearchTasks("Demo", null, null, 1, 100);
if (existing.TotalCount > 0)
{
// 版本升级:删除旧 Demo 任务,重新创建
foreach (var t in existing.Items)
scenario.DeleteTask(t.Id);
}
SeedNoDefense(scenario, d);
SeedZoneIntrusion(scenario, d);

View File

@ -46,7 +46,7 @@ namespace CounterDrone.Unity
if (_usePreset)
{
// 方式1直接使用预设想定最简单
var demos = scenario.SearchTasks("[Demo]", null, null, 1, 1);
var demos = scenario.SearchTasks("Demo", null, null, 1, 1);
if (demos.TotalCount == 0)
{
Debug.LogError("无预设想定,请确认 defaults.json 已放入 StreamingAssets");