- 新增 IDefensePlanner 接口 + DefaultDefensePlanner 实现 - FireUnit 重构为统一平台模型(Type/Position/CruiseSpeed/ReleaseAltitude/MuzzleVelocity) - DroneGroup 加入威胁指数(类型系数×速度系数)和优先级排序 - 五步流水线:威胁排序→弹药匹配→候选生成→贪心分配→时序生成 - 弹药精确匹配,不降级;临界方案基于50%概率阈值 - 删除 IDefenseAdvisor/DefaultDefenseAdvisor/RecommendMultiGroup - AlgorithmFactory 注册 IDefensePlanner - 测试更新:DefensePlannerTests 替代旧测试,FullPipelineTests 适配新 API - Unity Managers 更新调用 - 125 测试全通过
50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using CounterDrone.Core.Algorithms;
|
|
using Xunit;
|
|
|
|
namespace CounterDrone.Core.Tests
|
|
{
|
|
public class AlgorithmFactoryTests
|
|
{
|
|
[Fact]
|
|
public void Create_ReturnsDefaultImplementations()
|
|
{
|
|
var dispersion = AlgorithmFactory.Create<ICloudDispersionModel>();
|
|
Assert.IsType<GaussianPuffDispersion>(dispersion);
|
|
|
|
var damage = AlgorithmFactory.Create<IDamageModel>();
|
|
Assert.IsType<DamageModelRouter>(damage);
|
|
|
|
var planner = AlgorithmFactory.Create<IDefensePlanner>();
|
|
Assert.IsType<DefaultDefensePlanner>(planner);
|
|
}
|
|
|
|
[Fact]
|
|
public void Register_ReplacesImplementation()
|
|
{
|
|
AlgorithmFactory.Register<ICloudDispersionModel>(() => new MockDispersion());
|
|
var instance = AlgorithmFactory.Create<ICloudDispersionModel>();
|
|
Assert.IsType<MockDispersion>(instance);
|
|
AlgorithmFactory.Register<ICloudDispersionModel>(() => new GaussianPuffDispersion());
|
|
}
|
|
}
|
|
|
|
public class MockDispersion : ICloudDispersionModel
|
|
{
|
|
public Vector3 Center => new();
|
|
public float Radius => 100f;
|
|
public float CoreDensity => 1f;
|
|
public float EffectiveRadius => 100f;
|
|
public ParticleParams Particles => new();
|
|
public bool IsDissipated => false;
|
|
public int Phase => 2;
|
|
public float Elapsed => 10f;
|
|
|
|
public void Initialize(CounterDrone.Core.Models.AmmunitionSpec ammo,
|
|
CounterDrone.Core.Models.CombatScene env, Vector3 releasePos, float releaseTime)
|
|
{ }
|
|
public void Tick(float deltaTime, float windSpeed,
|
|
CounterDrone.Core.Models.WindDirection windDir)
|
|
{ }
|
|
}
|
|
}
|