diff --git a/src/CounterDrone.Core/Algorithms/GaussianPuffDispersion.cs b/src/CounterDrone.Core/Algorithms/GaussianPuffDispersion.cs index 7bbb49b..1e3e554 100644 --- a/src/CounterDrone.Core/Algorithms/GaussianPuffDispersion.cs +++ b/src/CounterDrone.Core/Algorithms/GaussianPuffDispersion.cs @@ -26,6 +26,7 @@ namespace CounterDrone.Core.Algorithms public ParticleParams Particles { get; } = new(); public bool IsDissipated { get; private set; } public int Phase => _inPhase3 ? 3 : (_elapsed < 0.01f ? 1 : 2); + public float Elapsed => _elapsed; public void Initialize(AmmunitionSpec ammo, CombatScene env, Vector3 releasePos, float releaseTime) { diff --git a/src/CounterDrone.Core/Algorithms/ICloudDispersionModel.cs b/src/CounterDrone.Core/Algorithms/ICloudDispersionModel.cs index 99b97c5..014307e 100644 --- a/src/CounterDrone.Core/Algorithms/ICloudDispersionModel.cs +++ b/src/CounterDrone.Core/Algorithms/ICloudDispersionModel.cs @@ -15,5 +15,7 @@ namespace CounterDrone.Core.Algorithms bool IsDissipated { get; } /// 当前扩散阶段:1=爆轰膨胀, 2=湍流扩散, 3=高斯扩散 int Phase { get; } + /// 云团已存在时间(秒) + float Elapsed { get; } } } diff --git a/src/CounterDrone.Core/Simulation/SimulationEngine.cs b/src/CounterDrone.Core/Simulation/SimulationEngine.cs index ea56da5..9ea4baf 100644 --- a/src/CounterDrone.Core/Simulation/SimulationEngine.cs +++ b/src/CounterDrone.Core/Simulation/SimulationEngine.cs @@ -241,7 +241,7 @@ namespace CounterDrone.Core.Simulation foreach (var d in _drones) list.Add(new EntitySnapshot { EntityId = d.Id, EntityType = Models.EntityType.Drone, PosX = d.PosX, PosY = d.PosY, PosZ = d.PosZ, StateData = JsonSerializer.Serialize(new { damageStage = (int)_damageModel.GetDamageStage(1 - d.Hp), hp = d.Hp }) }); foreach (var c in _clouds) - list.Add(new EntitySnapshot { EntityId = c.Id, EntityType = Models.EntityType.Cloud, PosX = c.Dispersion.Center.X, PosY = c.Dispersion.Center.Y, PosZ = c.Dispersion.Center.Z, StateData = JsonSerializer.Serialize(new { radius = c.Dispersion.Radius, opacity = c.Dispersion.Particles.Opacity, phase = c.Dispersion.Phase }) }); + list.Add(new EntitySnapshot { EntityId = c.Id, EntityType = Models.EntityType.Cloud, PosX = c.Dispersion.Center.X, PosY = c.Dispersion.Center.Y, PosZ = c.Dispersion.Center.Z, StateData = JsonSerializer.Serialize(new { radius = c.Dispersion.Radius, opacity = c.Dispersion.Particles.Opacity, phase = c.Dispersion.Phase, elapsed = c.Dispersion.Elapsed }) }); return list; } } diff --git a/test/unit/CounterDrone.Core.Tests/AlgorithmFactoryTests.cs b/test/unit/CounterDrone.Core.Tests/AlgorithmFactoryTests.cs index 742e4d1..87abc62 100644 --- a/test/unit/CounterDrone.Core.Tests/AlgorithmFactoryTests.cs +++ b/test/unit/CounterDrone.Core.Tests/AlgorithmFactoryTests.cs @@ -37,6 +37,7 @@ namespace CounterDrone.Core.Tests 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)