diff --git a/ThreatSource/data/jammers/smoke_grenades/surround.json b/ThreatSource/data/jammers/smoke_grenades/surround.json index cf3eb03..4f088f7 100644 --- a/ThreatSource/data/jammers/smoke_grenades/surround.json +++ b/ThreatSource/data/jammers/smoke_grenades/surround.json @@ -3,6 +3,7 @@ "zh": "周边烟幕弹", "en": "Surround Smoke Grenade" }, + "type": "SmokeGrenade", "smokeType": "Wall", "concentration": 0.2, "duration": 60.0, diff --git a/ThreatSource/data/jammers/smoke_grenades/top.json b/ThreatSource/data/jammers/smoke_grenades/top.json index ac7917b..e720ca6 100644 --- a/ThreatSource/data/jammers/smoke_grenades/top.json +++ b/ThreatSource/data/jammers/smoke_grenades/top.json @@ -3,6 +3,7 @@ "zh": "顶部烟幕弹", "en": "Top Smoke Grenade" }, + "type": "SmokeGrenade", "smokeType": "Cloud", "concentration": 0.2, "duration": 60.0, diff --git a/ThreatSource/src/Data/DataModels.cs b/ThreatSource/src/Data/DataModels.cs index 9ac6d15..aac0916 100644 --- a/ThreatSource/src/Data/DataModels.cs +++ b/ThreatSource/src/Data/DataModels.cs @@ -461,22 +461,34 @@ namespace ThreatSource.Data } /// - /// 烟幕弹数据模型 + /// 干扰机数据模型 /// /// - /// 包含烟幕弹的基本信息和参数 - /// 用于创建和初始化烟幕弹实例 + /// 包含干扰机的基本信息和参数 + /// 用于创建和初始化干扰机实例 /// - public class SmokeGrenadeData + public class JammerData { /// - /// 获取或设置烟幕弹的多语言名称 + /// 获取或设置干扰机的多语言名称 /// /// /// 包含中英文名称 /// 用于显示和文档 /// public LocalizedName Name { get; set; } = new(); + + /// + /// 获取或设置干扰机的类型 + /// + /// + /// 可选值: + /// - LaserJammer:激光干扰机 + /// - IRJammer:红外干扰机 + /// - MMWJammer:毫米波干扰机 + /// - SmokeGrenade:烟幕弹 + /// + public string Type { get; set; } = ""; /// /// 获取或设置烟幕弹的配置 diff --git a/ThreatSource/src/Data/ThreatSourceDataManager.cs b/ThreatSource/src/Data/ThreatSourceDataManager.cs index d2d736b..ccad0db 100644 --- a/ThreatSource/src/Data/ThreatSourceDataManager.cs +++ b/ThreatSource/src/Data/ThreatSourceDataManager.cs @@ -37,7 +37,7 @@ namespace ThreatSource.Data private readonly Dictionary _sensors = new(); private readonly Dictionary _targets = new(); private readonly Dictionary _weathers = new(); - private readonly Dictionary _smokeGrenades = new(); + private readonly Dictionary _jammers = new(); /// /// 初始化威胁源数据管理器 /// @@ -61,6 +61,7 @@ namespace ThreatSource.Data LoadSensors(Path.Combine(path, "sensors")); LoadTargets(Path.Combine(path, "targets")); LoadWeathers(Path.Combine(path, "weathers")); + LoadJammers(Path.Combine(path, "jammers")); } /// @@ -250,13 +251,13 @@ namespace ThreatSource.Data } /// - /// 加载烟幕弹数据 + /// 加载干扰机数据 /// - private void LoadSmokeGrenades(string path) + private void LoadJammers(string path) { if (!Directory.Exists(path)) { - Console.WriteLine($"烟幕弹数据目录不存在:{path}"); + Console.WriteLine($"干扰机数据目录不存在:{path}"); return; } @@ -265,17 +266,17 @@ namespace ThreatSource.Data try { var jsonContent = File.ReadAllText(file); - var data = JsonSerializer.Deserialize(jsonContent, _jsonOptions); + var data = JsonSerializer.Deserialize(jsonContent, _jsonOptions); if (data != null) { string model = Path.GetFileNameWithoutExtension(file); - _smokeGrenades[model] = data; - Console.WriteLine($"已加载烟幕弹数据:{model}"); + _jammers[model] = data; + Console.WriteLine($"已加载干扰机数据:{model}"); } } catch (Exception ex) { - Console.WriteLine($"加载烟幕弹数据文件失败:{file},错误:{ex.Message}"); + Console.WriteLine($"加载干扰机数据文件失败:{file},错误:{ex.Message}"); Console.WriteLine($"异常堆栈:{ex.StackTrace}"); } } @@ -342,15 +343,15 @@ namespace ThreatSource.Data } /// - /// 获取烟幕弹配置数据 + /// 获取干扰机配置数据 /// - /// 烟幕弹型号 - /// 烟幕弹配置数据 - public SmokeGrenadeData GetSmokeGrenade(string model) + /// 干扰机型号 + /// 干扰机配置数据 + public JammerData GetJammer(string model) { - if (_smokeGrenades.TryGetValue(model, out var data)) + if (_jammers.TryGetValue(model, out var data)) return data; - throw new KeyNotFoundException($"SmokeGrenade {model} not found"); + throw new KeyNotFoundException($"Jammer {model} not found"); } @@ -380,8 +381,8 @@ namespace ThreatSource.Data public IEnumerable GetAvailableWeathers() => _weathers.Keys; /// - /// 获取所有可用的烟幕弹ID列表 + /// 获取所有可用的干扰机ID列表 /// - public IEnumerable GetAvailableSmokeGrenades() => _smokeGrenades.Keys; + public IEnumerable GetAvailableJammers() => _jammers.Keys; } } \ No newline at end of file diff --git a/ThreatSource/src/Data/ThreatSourceFactory.cs b/ThreatSource/src/Data/ThreatSourceFactory.cs index 2d9db7a..1212daf 100644 --- a/ThreatSource/src/Data/ThreatSourceFactory.cs +++ b/ThreatSource/src/Data/ThreatSourceFactory.cs @@ -266,18 +266,24 @@ namespace ThreatSource.Data /// /// 创建烟幕弹实例 /// - /// 烟幕弹型号 + /// 干扰机型号 /// 初始运动参数 - /// 烟幕弹实例 - public SmokeGrenade CreateSmokeGrenade(string smokeGrenadeModel, MotionParameters motionParameters) + /// 干扰机实例 + public IJammer CreateJammer(string jammerModel, MotionParameters motionParameters) { - var data = _dataManager.GetSmokeGrenade(smokeGrenadeModel); - return new SmokeGrenade( - smokeGrenadeModel, - data.SmokeGrenadeConfig, - motionParameters, - _simulationManager - ); + var data = _dataManager.GetJammer(jammerModel); + switch (data.Type) + { + case "SmokeGrenade": + return new SmokeGrenade( + jammerModel, + data.SmokeGrenadeConfig, + motionParameters, + _simulationManager + ); + default: + throw new ArgumentException($"不支持的干扰机类型: {data.Type}"); + } } } } \ No newline at end of file diff --git a/ThreatSource/src/Guidance/LaserSemiActiveGuidanceSystem.cs b/ThreatSource/src/Guidance/LaserSemiActiveGuidanceSystem.cs index e22bf6e..2490620 100644 --- a/ThreatSource/src/Guidance/LaserSemiActiveGuidanceSystem.cs +++ b/ThreatSource/src/Guidance/LaserSemiActiveGuidanceSystem.cs @@ -2,6 +2,7 @@ using ThreatSource.Utils; using ThreatSource.Simulation; using ThreatSource.Sensor; using ThreatSource.Indicator; +using ThreatSource.Jammer; using System.Diagnostics; using ThreatSource.Jamming; using AirTransmission; @@ -315,29 +316,37 @@ namespace ThreatSource.Guidance /// 烟幕事件 private void OnSmokeScreen(SmokeScreenEvent evt) { - if (evt == null) return; - - // 创建干扰参数 - var parameters = new JammingParameters + if (evt != null && evt.SmokeGrenadeId != null) { - Type = JammingType.SmokeScreen, - SourcePosition = evt.Position, - Direction = evt.Orientation, - AngleRange = evt.SmokeType == SmokeScreenType.Wall ? Math.PI : Math.PI * 2, // 墙状烟幕为半球形覆盖,云状为全方位 - SmokeConcentration = evt.Concentration, - SmokeType = evt.SmokeType, - SmokeThickness = evt.SmokeType == SmokeScreenType.Wall ? evt.Width : evt.Width * 2, // 墙状使用宽度,云状使用直径 - Duration = evt.RemainingTime, - Mode = JammingMode.Obscuration - }; + // 获取烟幕弹的配置 + var smokeGrenade = SimulationManager.GetEntityById(evt.SmokeGrenadeId) as SmokeGrenade; + if (smokeGrenade != null) + { + var config = smokeGrenade.config; - // 使用JammableComponent进行干扰判断 - ApplyJamming(parameters); - - // 如果被干扰,记录信息 - if (IsJammed) - { - Debug.WriteLine($"激光半主动制导系统被烟幕干扰 - 浓度: {evt.Concentration}g/m³, 位置: {evt.Position}, 类型: {evt.SmokeType}"); + // 创建干扰参数 + var parameters = new JammingParameters + { + Type = JammingType.SmokeScreen, + SourcePosition = smokeGrenade.Position, + Direction = smokeGrenade.Orientation.ToVector(), + AngleRange = config.SmokeType == SmokeScreenType.Wall ? Math.PI : Math.PI * 2, // 墙状烟幕为半球形覆盖,云状为全方位 + SmokeConcentration = config.Concentration, + SmokeType = config.SmokeType, + SmokeThickness = config.Thickness, + Duration = config.Duration, + Mode = JammingMode.Obscuration + }; + + // 使用JammableComponent进行干扰判断 + ApplyJamming(parameters); + + // 如果被干扰,记录信息 + if (IsJammed) + { + Debug.WriteLine($"激光半主动制导系统被烟幕干扰 - 浓度: {config.Concentration}g/m³, 位置: {smokeGrenade.Position}, 类型: {config.SmokeType}"); + } + } } } diff --git a/ThreatSource/src/Jammer/SmokeGrenade.cs b/ThreatSource/src/Jammer/SmokeGrenade.cs index 72755ac..fcb5397 100644 --- a/ThreatSource/src/Jammer/SmokeGrenade.cs +++ b/ThreatSource/src/Jammer/SmokeGrenade.cs @@ -18,7 +18,7 @@ namespace ThreatSource.Jammer /// /// 烟幕配置 /// - private readonly SmokeGrenadeConfig config; + public readonly SmokeGrenadeConfig config; /// /// 获取干扰器类型 diff --git a/docs/project/develop_log.md b/docs/project/develop_log.md index 1c94f15..9d633e8 100644 --- a/docs/project/develop_log.md +++ b/docs/project/develop_log.md @@ -7,6 +7,8 @@ - 事件描述 - 分析处理 +## 2005-04-10 增加了 Jammer 架构,实现了烟幕弹逻辑 + ## 2025-04-09 改进各导弹导弹制导系统的大气透过率计算 - 使用AtmosphereDllWrapper封装的计算函数,实现了激光在大气中传输的透过率精确计算 diff --git a/tools/ComprehensiveMissileSimulator.cs b/tools/ComprehensiveMissileSimulator.cs index d847e36..2e9aca4 100644 --- a/tools/ComprehensiveMissileSimulator.cs +++ b/tools/ComprehensiveMissileSimulator.cs @@ -70,6 +70,8 @@ namespace ThreatSource.Tools.MissileSimulation // 添加各种传感器和指示器 AddSensorsAndDesignators(); + // 添加烟幕弹 + AddSmokeGrenade(); } @@ -106,6 +108,23 @@ namespace ThreatSource.Tools.MissileSimulation tank.LaunchLaserDecoy(new Vector3D(0, 0, 1), 50, 25, 20); } + /// + /// 添加烟幕弹 + /// + private void AddSmokeGrenade() + { + var motionParameters = new MotionParameters + { + Position = new Vector3D(100, 0, 0), + Orientation = new Orientation(Math.PI, 0, 0), + InitialSpeed = 0.0 + }; + string smokeGrenadeId = "SG_1"; + var smokeGrenade = _threatSourceFactory.CreateJammer("surround", motionParameters); + simulationManager.RegisterEntity(smokeGrenadeId, smokeGrenade); + Console.WriteLine($"注册烟幕弹 {smokeGrenadeId}"); + } + /// /// 添加激光半主动制导导弹 ///