浏览代码

添加陆上搜救任务部分脚本

liyang 7 月之前
父节点
当前提交
588a46835b

+ 1 - 1
Models/SimulationCommon/TaskConfig.cs

@@ -246,6 +246,6 @@ public class TaskConfig
     public List<XHTask> xHTask = new List<XHTask>();
     [JsonProperty("海上搜救任务")]
     public List<SeaSouJiuTask> seaSouJiuTasks = new List<SeaSouJiuTask>();
-    [JsonProperty("上搜救任务")]
+    [JsonProperty("上搜救任务")]
     public List<LandSouJiuTask> LandSouJiuTasks = new List<LandSouJiuTask>();
 }

+ 3 - 0
SimulationServer/Component/TaskComponent.cs

@@ -12,6 +12,7 @@ public class TaskComponent : Component
     public List<XHRescueMission> XHRescueMissions;
     public List<ZCRescueMission> ZCRescueMissions;
     public List<SeaSJRescueMission> SeaSJRescueMissions;
+    public List<LandSJRescueMission> LandSJRescueMissions;
 
     public SJAllTotalTaskPerformanceComponent SJAllTotalTaskPerformance = new SJAllTotalTaskPerformanceComponent();
     public Dictionary<string, Dictionary<string, List<string>>> alltotalReport = new();
@@ -32,6 +33,7 @@ public class TaskComponent : Component
         XHRescueMissions?.ForEach(r => r.Start());
         ZCRescueMissions?.ForEach(r => r.Start());
         SeaSJRescueMissions?.ForEach(r => r.Start());
+        LandSJRescueMissions?.ForEach(r => r.Start());
     }
 
     public void SaveSJ(Dictionary<string, Dictionary<string, string>> totalReport)
@@ -108,6 +110,7 @@ public class TaskComponentAwakeSystem : AwakeSystem<TaskComponent>
         self.ZCRescueMissions = new List<ZCRescueMission>();
         self.XHRescueMissions = new List<XHRescueMission>();
         self.SeaSJRescueMissions = new List<SeaSJRescueMission>();
+        self.LandSJRescueMissions = new List<LandSJRescueMission>();
     }
 }
 

+ 5 - 5
SimulationServer/Entity/AircraftLandSJ.cs

@@ -19,6 +19,7 @@ public class AircraftLandSJ : AircraftEntity
     int MinLength = 1000;//最小等高线节点数
     double TrueH = 200;//航线真实高度
     int JG = 5;//输出等高线节点间隔
+    public LandSouJiuTask taskContent;
 
     public GetNCData getNCData;
     public override void Reset()
@@ -70,22 +71,21 @@ public class AircraftLandSJ : AircraftEntity
 
         if (survivalTime * 3600 > time)
         {
-            Success = true;
+            //Success = true;
         }
         else
         {
-            Success = false;
+            //Success = false;
         }
     }
 }
 
 [ObjectSystem]
-public class AircraftSJAwakeSystem : AwakeSystem<AircraftSJ, FlightPlanEditor>
+public class AircraftLandSJAwakeSystem : AwakeSystem<AircraftLandSJ, FlightPlanEditor>
 {
-    public override void Awake(AircraftSJ self, FlightPlanEditor flightPlanEditor)
+    public override void Awake(AircraftLandSJ self, FlightPlanEditor flightPlanEditor)
     {
         self.FlightPlanEditor = flightPlanEditor;
-        self.helper = new EquationHelper(HttpInterface.baseUrl);
         self.Awake();
     }
 }

+ 7 - 7
SimulationServer/Entity/LandSJRescueMission.cs

@@ -8,7 +8,7 @@ public class LandSJRescueMission : Entity
 {
     public string MissionId; // 任务ID
     public bool Success; // 任务是否成功
-    public List<AircraftSJ> aircrafts = new List<AircraftSJ>();
+    public List<AircraftLandSJ> aircrafts = new List<AircraftLandSJ>();
 
     public bool IsRunning;
     public double SimulationTime;
@@ -81,7 +81,7 @@ public class LandSJRescueMission : Entity
 
     public void SaveAircraftSJDatas()
     {
-        foreach (AircraftSJ aircraftEntity in aircrafts)
+        foreach (AircraftLandSJ aircraftEntity in aircrafts)
         {
             string key = aircraftEntity.AircraftId;
             if (!aircraftSJDatas.ContainsKey(key))
@@ -90,7 +90,7 @@ public class LandSJRescueMission : Entity
             }
             if (!aircraftSJDatas[key].ContainsKey("识别成功率"))
                 aircraftSJDatas[key]["识别成功率"] = new List<string>();
-            aircraftSJDatas[key]["识别成功率"].Add(aircraftEntity.isseePerson ? "1" : "0");
+            //aircraftSJDatas[key]["识别成功率"].Add(aircraftEntity.isseePerson ? "1" : "0");
             if (!aircraftSJDatas[key].ContainsKey("任务准备时间"))
                 aircraftSJDatas[key]["任务准备时间"] = new List<string>();
             aircraftSJDatas[key]["任务准备时间"].Add(aircraftEntity.TaskReadyTime.ToString());
@@ -102,13 +102,13 @@ public class LandSJRescueMission : Entity
             aircraftSJDatas[key]["总飞行时间"].Add(aircraftEntity.TotalTime.ToString());
             if (!aircraftSJDatas[key].ContainsKey("人员存活率"))
                 aircraftSJDatas[key]["人员存活率"] = new List<string>();
-            aircraftSJDatas[key]["人员存活率"].Add(aircraftEntity.Success ? "1" : "0");
+            //aircraftSJDatas[key]["人员存活率"].Add(aircraftEntity.Success ? "1" : "0");
         }
     }
 
     public void SaveSJ()
     {
-        foreach (AircraftSJ aircraftEntity in aircrafts)
+        foreach (AircraftLandSJ aircraftEntity in aircrafts)
         {
             var staticCapacity = aircraftEntity.GetComponent<SJStaticCapacityComponent>();
 
@@ -213,9 +213,9 @@ public class LandSJRescueMission : Entity
 
 
 [ObjectSystem]
-public class SeaSJRescueMissionUpdateSystem : UpdateSystem<SeaSJRescueMission>
+public class LandSJRescueMissionUpdateSystem : UpdateSystem<LandSJRescueMission>
 {
-    public override void Update(SeaSJRescueMission self)
+    public override void Update(LandSJRescueMission self)
     {
         if (!self.IsRunning) return;
 

+ 37 - 0
SimulationServer/EventHandler/CreateTaskEventHandler.cs

@@ -243,6 +243,43 @@ public class CreateSeaSJEventHandler : AEvent<CreateSeaSJTask>
             Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
         }
         
+        return UniTask.CompletedTask;
+    }
+}
+
+[Event]
+public class CreateLandSJEventHandler : AEvent<CreateLandSJTask>
+{
+    protected override UniTask Run(CreateLandSJTask config)
+    {
+        var taskSys = Game.Scene.GetComponent<TaskComponent>();
+        LandSJRescueMission mission = ComponentFactory.Create<LandSJRescueMission>();
+        taskSys.LandSJRescueMissions.Add(mission);
+        mission.MissionId = $"陆上搜索救援任务 {config.LandSJTask.missionInformation.MissionName}";
+        mission.ExecutionContext = config.EditorConfig.runCounts;
+        mission.AddComponent<SJTotalTaskPerformanceComponent>(); // Land
+        for (int i = 0; i < config.LandSJTask.missionInformation.AircraftInfos.Length; i++)
+        {
+            //飞机参数
+            var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
+                a => a.AircraftID == config.LandSJTask.missionInformation.AircraftInfos[i]);
+            //基地
+            var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
+
+            TargetPoint targetPoint = config.EditorConfig.targetPoints.Find(t => t.TargetPointId == config.LandSJTask.TargetPointId);
+            //创建飞行计划编辑器
+            var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new TargetPoint[] { targetPoint });
+
+            AircraftLandSJ aircraft = ComponentFactory.Create<AircraftLandSJ, FlightPlanEditor>(flightPlanEditor);
+            aircraft.Name = config.LandSJTask.missionInformation.AircraftInfos[i];
+            aircraft.TaskReadyTime = config.LandSJTask.missionInformation.TakeoffPreparationTime;
+            mission.aircrafts.Add(aircraft);
+            aircraft.taskContent = config.LandSJTask;
+            aircraft.AircraftId = config.LandSJTask.missionInformation.AircraftId[i];
+            aircraft.AddComponent<SJStaticCapacityComponent>();
+            Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
+        }
+
         return UniTask.CompletedTask;
     }
 }