修改了末敏弹子弹扫描二次确认逻辑,用转一圈的时间来保证二次确认
This commit is contained in:
parent
22660eb7a1
commit
14220062f4
@ -322,7 +322,7 @@ namespace ActiveProtect.Models
|
||||
$" 距离目标: {missileRunningState.DistanceToTarget:F2}\n" +
|
||||
$" 发动机工作时间: {missileRunningState.EngineBurnTime:F2}/{MaxEngineBurnTime:F2}\n" +
|
||||
$" 有引导: {(missileRunningState.HasGuidance ? "是" : "否")}\n" +
|
||||
$" 失去引导时间: {missileRunningState.LostGuidanceTime:F2}";
|
||||
$" 失去引导时间: {missileRunningState.LostGuidanceTime:F2}\n";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -152,14 +152,14 @@ namespace ActiveProtect.Models
|
||||
public class MillimeterWaveRadiometer : Sensor
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作频率
|
||||
/// 工作频率(3mm 或 8mm)
|
||||
/// </summary>
|
||||
public double Frequency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 灵敏度
|
||||
/// 辐射温度差检测阈值,辐射计高温物体与低温物体的检测温差,单位K,默认 50K
|
||||
/// </summary>
|
||||
public double Sensitivity { get; set; }
|
||||
public double DetectionTemperatureDifferenceThreshold { get; set; } = 50;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
@ -167,12 +167,12 @@ namespace ActiveProtect.Models
|
||||
/// <param name="position">辐射计的位置</param>
|
||||
/// <param name="orientation">辐射计的朝向</param>
|
||||
/// <param name="frequency">工作频率</param>
|
||||
/// <param name="sensitivity">灵敏度</param>
|
||||
public MillimeterWaveRadiometer(Vector3D position, Orientation orientation, double frequency, double sensitivity)
|
||||
/// <param name="detectionTemperatureDifferenceThreshold">辐射检测阈值</param>
|
||||
public MillimeterWaveRadiometer(Vector3D position, Orientation orientation, double frequency, double detectionTemperatureDifferenceThreshold)
|
||||
: base(position, orientation)
|
||||
{
|
||||
Frequency = frequency;
|
||||
Sensitivity = sensitivity;
|
||||
DetectionTemperatureDifferenceThreshold = detectionTemperatureDifferenceThreshold;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -39,8 +39,8 @@ namespace ActiveProtect.Models
|
||||
// 攻击速度 500 m/s
|
||||
private const double AttackSpeed = 500;
|
||||
|
||||
// 是否检测到目标
|
||||
private bool targetDetected;
|
||||
// 检测到目标的时间
|
||||
private double? lastDetectionTime = null;
|
||||
|
||||
/// <summary>
|
||||
/// 螺旋角度
|
||||
@ -66,7 +66,6 @@ namespace ActiveProtect.Models
|
||||
{
|
||||
currentStage = SubmunitionStage.Separation;
|
||||
spiralAngle = 0;
|
||||
targetDetected = false;
|
||||
detectionAngle = 0;
|
||||
|
||||
// 初始化传感器
|
||||
@ -164,11 +163,9 @@ namespace ActiveProtect.Models
|
||||
private void UpdateSpiralScanStage(double deltaTime)
|
||||
{
|
||||
GuidanceAcceleration = Vector3D.Zero;
|
||||
Velocity = new Vector3D(0, -VerticalDescentSpeed, 0);
|
||||
|
||||
// 螺旋扫描
|
||||
spiralAngle %= (2 * Math.PI);
|
||||
spiralAngle += SpiralRotationSpeed * deltaTime;
|
||||
// 更新螺旋角度
|
||||
spiralAngle = (spiralAngle + SpiralRotationSpeed * deltaTime) % (2 * Math.PI);
|
||||
|
||||
// 计算水平速度分量
|
||||
double horizontalSpeed = VerticalDescentSpeed * Math.Tan(ScanAngle);
|
||||
@ -179,7 +176,7 @@ namespace ActiveProtect.Models
|
||||
);
|
||||
|
||||
// 更新速度
|
||||
Velocity = new Vector3D(horizontalVelocity.X, -VerticalDescentSpeed, horizontalVelocity.Z);
|
||||
Velocity = new(horizontalVelocity.X, -VerticalDescentSpeed, horizontalVelocity.Z);
|
||||
|
||||
// 计算扫描方向
|
||||
Vector3D scanDirection = new(
|
||||
@ -191,18 +188,27 @@ namespace ActiveProtect.Models
|
||||
if (DetectTarget(scanDirection))
|
||||
{
|
||||
Console.WriteLine("检测到目标");
|
||||
if (!targetDetected)
|
||||
double currentTime = SimulationManager.CurrentTime;
|
||||
if (lastDetectionTime == null)
|
||||
{
|
||||
targetDetected = true;
|
||||
detectionAngle = spiralAngle;
|
||||
lastDetectionTime = currentTime;
|
||||
}
|
||||
else if (Math.Abs(spiralAngle - detectionAngle) < 0.1) // 允许一定的误差
|
||||
else
|
||||
{
|
||||
double timeSinceLastDetection = currentTime - lastDetectionTime.Value;
|
||||
// 重新检测到目标的时间大于等于螺旋周期的90%,则二次确认目标
|
||||
if (timeSinceLastDetection >= 0.9 * 2 * Math.PI / SpiralRotationSpeed)
|
||||
{
|
||||
Console.WriteLine($"目标确认,进入攻击阶段。距离上次检测时间:{timeSinceLastDetection:F2}秒");
|
||||
currentStage = SubmunitionStage.Attack;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (((AltimeterSensorData)altimeter.GetSensorData()).Altitude <= SelfDestructHeight)
|
||||
// 使用模式匹配简化类型转换
|
||||
if (altimeter.GetSensorData() is AltimeterSensorData altimeterData &&
|
||||
altimeterData.Altitude <= SelfDestructHeight)
|
||||
{
|
||||
currentStage = SubmunitionStage.SelfDestruct;
|
||||
}
|
||||
@ -273,7 +279,7 @@ namespace ActiveProtect.Models
|
||||
/// <returns>子弹状态</returns>
|
||||
public override string GetStatus()
|
||||
{
|
||||
return $"{base.GetStatus()}\nSubmunition Stage: {currentStage}\nDetection Angle: {detectionAngle * 180 / Math.PI:F2}°\nSpiral Angle: {spiralAngle * 180 / Math.PI:F2}°\nTarget Detected: {targetDetected}";
|
||||
return $"{base.GetStatus()}\nSubmunition Stage: {currentStage}\nDetection Angle: {detectionAngle * 180 / Math.PI:F2}°\nSpiral Angle: {spiralAngle * 180 / Math.PI:F2}°\nTarget Detected: {lastDetectionTime != null}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user