123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799 |
- using Cysharp.Threading.Tasks;
- using KYFramework;
- using Model;
- using SimulationServer.Utils;
- using SimulationSingleServer.Utils;
- using Unity.Mathematics;
- namespace SimulationServer;
- [Event]
- public class CreateMHTaskEventHandler : AEvent<CreateMHTask>
- {
- protected override UniTask Run(CreateMHTask config)
- {
- // TODO 创建灭火任务
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- FirePoint point = config.EditorConfig.firePoints.Find(fire => fire.FirePointId == config.MHTaskConfig.FirePointId);
- // 创建火点
- var fireGround = ComponentFactory.Create<FireGround, FirePoint>(point);
- fireGround.FirePointName = point.FirePointId;
- // 创建灭火任务
- var mission = ComponentFactory.Create<MHRescueMission, FireGround, double>(fireGround, point.InitialArea);
- mission.AddComponent<TotalEconomicalComponent>();
- mission.AddComponent<TotalTaskPerformanceComponent>();
- mission.AddComponent<EquipmentComponent>();
- mission.MissionId = "灭火任务 " + config.MHTaskConfig.TotalMHId;
- taskSys.MHRescueMissions.Add(mission);
- //查询坡度
- mission.slope = Util.GetSlope(point.FirePointLongitude,
- point.FirePointLatitude, 30);
- Log.Info($"创建任务 : {config.MHTaskConfig.TotalMHId}");
- //创建吊桶灭火任务
- foreach (MHTask mhTask in config.MHTaskConfig.mHTask)
- {
- Log.Info($"创建灭火任务 : {mhTask.missionInformation.MissionName}");
- if (mhTask.aircraftInfos == null) continue;
- for (int i = 0; i < mhTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == mhTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, mhTask.MissionPoints[0], new[] { point });
- AircraftMH aircraft = ComponentFactory.Create<AircraftMH, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = mhTask.aircraftInfos[i].AircraftType;
- aircraft.AircraftId = mhTask.aircraftInfos[i].AircraftId;
- aircraft.fireGround = fireGround;
- aircraft.mhRescueMission = mission;
- mission.aircrafts.Add(aircraft);
- aircraft.Airport = flightPlanEditor.originbase.BaseName;
- aircraft.TaskName = mhTask.missionInformation.MissionName;
- mission.End += aircraft.End;
- aircraft.AddComponent<StaticCapacityComponent>();
- aircraft.AddComponent<TaskPerformanceComponent>();
- aircraft.AddComponent<EconomicalComponent>();
- aircraft.TaskReadyTime = mhTask.missionInformation.TakeoffPreparationTime;
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- }
- //创建机降灭火任务
- foreach (DMMHTask dmmhTask in config.MHTaskConfig.dMMHTask)
- {
- Log.Info($"创建地面灭火任务 : {dmmhTask.missionInformation.MissionName}");
- if (dmmhTask.aircraftInfos == null) continue;
- for (int i = 0; i < dmmhTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == dmmhTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, dmmhTask.MissionPoints[0], new[] { point });
- AircraftMHWithPersion aircraftWithPerson = ComponentFactory.Create<AircraftMHWithPersion, FlightPlanEditor>(flightPlanEditor);
- mission.End += aircraftWithPerson.End;
- aircraftWithPerson.Name = dmmhTask.aircraftInfos[i].AircraftType;
- aircraftWithPerson.fireGround = fireGround;
- aircraftWithPerson.mhRescueMission = mission;
- aircraftWithPerson.GroundPersonnel = (int)dmmhTask.GroundPersonnel;
- aircraftWithPerson.LandingPersonnel = (int)dmmhTask.LandingPersonnel;
- aircraftWithPerson.NextMissionId = dmmhTask.NextTaskId;
- aircraftWithPerson.TaskName = dmmhTask.missionInformation.MissionName;
- aircraftWithPerson.TaskReadyTime = dmmhTask.missionInformation.TakeoffPreparationTime;
- aircraftWithPerson.AircraftId = dmmhTask.aircraftInfos[i].AircraftId;
- mission.aircrafts.Add(aircraftWithPerson);
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- }
- //创建索滑降任务
- foreach (SHJTask shjTask in config.MHTaskConfig.sHJTask)
- {
- Log.Info($"创建索滑降任务 : {shjTask.missionInformation.MissionName}");
- if (shjTask.aircraftInfos == null) continue;
- for (int i = 0; i < shjTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == shjTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- MissionPoint missionPoint = null;
- foreach (var item in shjTask.SHJParameters)
- {
- if (aircraftParameter.Id == item.AircraftId)
- missionPoint = item.MissionPoints_SHJ[0];
- }
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, missionPoint, new[] { point });
- AircraftSHJ aircraftSHJ = ComponentFactory.Create<AircraftSHJ, FlightPlanEditor, SHJTask>(flightPlanEditor, shjTask);
- mission.End += aircraftSHJ.End;
- aircraftSHJ.AircraftId = shjTask.aircraftInfos[i].AircraftId;
- aircraftSHJ.TaskReadyTime = shjTask.missionInformation.TakeoffPreparationTime;
- foreach (var item in config.MHTaskConfig.sHJTask)
- {
- foreach (var item1 in item.SHJParameters)
- {
- if (aircraftSHJ.AircraftId == item1.AircraftId)
- {
- aircraftSHJ.SHJParameter = item1;
- }
- }
- }
- mission.aircrafts.Add(aircraftSHJ);
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateZCTaskEventHandler : AEvent<CreateZCTask>
- {
- protected override UniTask Run(CreateZCTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- ZCRescueMission mission = ComponentFactory.Create<ZCRescueMission>();
- taskSys.ZCRescueMissions.Add(mission);
- mission.MissionId = $"侦擦任务 {config.ZCTask.missionInformation.MissionName}";
- FirePoint point = config.EditorConfig.firePoints.Find(f => f.FirePointId == config.ZCTask.FirePointId);
- for (int i = 0; i < config.ZCTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.ZCTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, config.ZCTask.MissionPoints[0], new[] { point });
- //创建飞机
- int index = i;
- AircraftZC aircraft = ComponentFactory.Create<AircraftZC, FlightPlanEditor, ZCTask, int>(flightPlanEditor, config.ZCTask, index);
- aircraft.AddComponent<StaticCapacityComponent>();
- aircraft.AddComponent<TaskPerformanceComponent>();
- aircraft.AddComponent<EconomicalComponent>();
- aircraft.TaskReadyTime = config.ZCTask.missionInformation.TakeoffPreparationTime;
- aircraft.AircraftId = config.ZCTask.aircraftInfos[i].AircraftId;
- foreach (var item in config.ZCTask.ZCMethods)
- {
- if (aircraft.AircraftId == item.AircraftId)
- {
- aircraft.ZCMethod = item;
- }
- }
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- mission.AircraftZCs.Add(aircraft);
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateXHTaskEventHandler : AEvent<CreateXHTask>
- {
- protected override UniTask Run(CreateXHTask config)
- {
- // TODO 创建巡护任务
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- XHRescueMission mission = ComponentFactory.Create<XHRescueMission>();
- mission.AddComponent<XHTotalTaskPerformanceComponent>();
- mission.AddComponent<EquipmentComponent>();
- mission.MissionId = $"巡护任务 {config.XHTask.missionInformation.MissionId}";
- taskSys.XHRescueMissions.Add(mission);
- FirePoint point = config.EditorConfig.firePoints.Find(f => f.FirePointId == config.XHTask.FirePointId);
- mission.FireGround = ComponentFactory.Create<FireGround, FirePoint>(point);
- for (int i = 0; i < config.XHTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.XHTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- string content = HttpManager.Get(HttpInterface.routes, new List<string>
- {
- "fName"
- }, new List<string>
- {
- config.XHTask.airroute[0].AirRouteName
- });
- var routes = JsonHelper.FromJson<RouteDB>(content);
- //routes.data.lstPoints => AirRoute[]
- AirRoute[] airRoutes = new AirRoute[routes.data[0].lstPoints.Count];
- for (int j = 0; j < routes.data[0].lstPoints.Count; j++)
- {
- airRoutes[j] = new AirRoute
- {
- AirRouteLongitude = routes.data[0].lstPoints[j].lon,
- AirRouteLatitude = routes.data[0].lstPoints[j].lat,
- AirRouteHeight = routes.data[0].lstPoints[j].dem
- };
- }
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, airRoutes, config.XHTask.MissionPoints[0], new[] { point });
- AircraftXH aircraft = ComponentFactory.Create<AircraftXH, FlightPlanEditor, string, string>(flightPlanEditor,
- config.XHTask.aircraftInfos[i].AircraftType, config.XHTask.aircraftInfos[i].AircraftId);
- aircraft.TaskReadyTime = config.XHTask.missionInformation.TakeoffPreparationTime;
- Log.Info($"Name:{config.XHTask.missionInformation.MissionName} AircraftId:{config.XHTask.aircraftInfos[i].AircraftId}");
- mission.AircraftXHs.Add(aircraft);
- mission.End += aircraft.End;
- aircraft.AddComponent<XHStaticCapacityComponent>();
- aircraft.AddComponent<XHEconomicalComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateSeaSJEventHandler : AEvent<CreateSeaSJTask>
- {
- protected override UniTask Run(CreateSeaSJTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- SeaSJRescueMission mission = ComponentFactory.Create<SeaSJRescueMission>();
- mission.date = taskSys.date;
- taskSys.SeaSJRescueMissions.Add(mission);
- mission.MissionId = $"海上搜索救援任务 {config.SeaSJTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.SeaSJTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.SeaSJTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- TargetPoint targetPoint = config.EditorConfig.targetPoints.Find(t => t.TargetPointId == config.SeaSJTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new TargetPoint[] { targetPoint });
- AircraftSJ aircraft = ComponentFactory.Create<AircraftSJ, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.SeaSJTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.SeaSJTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.SeaSJTask;
- aircraft.AircraftId = config.SeaSJTask.aircraftInfos[i].AircraftId;
- foreach (var item in config.SeaSJTask.SearchModes)
- {
- if (aircraft.AircraftId == item.AircraftId)
- aircraft.SearchMode = item;
- }
- foreach (var item in config.SeaSJTask.missionSearchPayloads)
- {
- if (aircraft.AircraftId == item.AircraftId)
- aircraft.searchMissionPayload = item;
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateLandSJEventHandler : AEvent<CreateLandSXTask>
- {
- protected override UniTask Run(CreateLandSXTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- LandSJRescueMission mission = ComponentFactory.Create<LandSJRescueMission>();
- mission.date = taskSys.date;
- taskSys.LandSJRescueMissions.Add(mission);
- mission.MissionId = $"陆上搜寻救援任务 {config.LandSXTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.LandSXTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.LandSXTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- TargetPoint targetPoint = config.EditorConfig.targetPoints.Find(t => t.TargetPointId == config.LandSXTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new TargetPoint[] { targetPoint });
- AircraftLandSJ aircraft = ComponentFactory.Create<AircraftLandSJ, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.LandSXTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.LandSXTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.LandSXTask;
- aircraft.AircraftId = config.LandSXTask.aircraftInfos[i].AircraftId;
- aircraft.MissionEndPoint = new MissionEndPoint
- {
- MissionEndPointLongitude = targetPoint.TargetPointLongitude,
- MissionEndPointLatitude = targetPoint.TargetPointLatitude,
- MissionEndPointHeight = targetPoint.TargetPointHeight
- };
- foreach (var item in config.LandSXTask.SearchModes)
- {
- if (item.AircraftId == aircraft.AircraftId)
- aircraft.SearchMissionMode = item;
- }
- foreach (var item in config.LandSXTask.missionSearchPayloads)
- {
- if (aircraft.AircraftId == item.AircraftId)
- aircraft.searchMissionPayload = item;
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- [Event]
- public class CreateKZDYEventHandler : AEvent<CreateKZDYTask>
- {
- protected override UniTask Run(CreateKZDYTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- KZDYMission mission = ComponentFactory.Create<KZDYMission>();
- mission.date = taskSys.date;
- taskSys.KZDYMissions.Add(mission);
- mission.MissionId = $"空中吊运救援任务 {config.KZDYTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.KZDYTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.KZDYTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- TargetPoint targetPoint = config.EditorConfig.targetPoints.Find(t => t.TargetPointId == config.KZDYTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new TargetPoint[] { targetPoint });
- AircraftDY aircraft = ComponentFactory.Create<AircraftDY, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.KZDYTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.KZDYTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.KZDYTask;
- aircraft.AircraftId = config.KZDYTask.aircraftInfos[i].AircraftId;
- aircraft.MissionEndPoint = new MissionEndPoint
- {
- MissionEndPointLongitude = targetPoint.TargetPointLongitude,
- MissionEndPointLatitude = targetPoint.TargetPointLatitude,
- MissionEndPointHeight = targetPoint.TargetPointHeight
- };
- foreach (var item in config.KZDYTask.KZDYParameters)
- {
- if (item.AircraftId == aircraft.AircraftId)
- {
- aircraft.taskParameter = item;
- }
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateKTKSEventHandler : AEvent<CreateKTKSTask>
- {
- protected override UniTask Run(CreateKTKSTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- KTKSMission mission = ComponentFactory.Create<KTKSMission>();
- mission.date = taskSys.date;
- taskSys.KTKSMissions.Add(mission);
- mission.MissionId = $"空投空送任务 {config.KTKSTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.KTKSTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.KTKSTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- TargetPoint targetPoint = config.EditorConfig.targetPoints.Find(t => t.TargetPointId == config.KTKSTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new TargetPoint[] { targetPoint });
- AircraftKTKS aircraft = ComponentFactory.Create<AircraftKTKS, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.KTKSTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.KTKSTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.KTKSTask;
- aircraft.AircraftId = config.KTKSTask.aircraftInfos[i].AircraftId;
- aircraft.rescueDemandInfo = config.EditorConfig.rescueDemandInfos.Find(t => t.DemandPointName == config.KTKSTask.missionInformation.TargetPoint);
- //aircraft.MissionEndPoint = new MissionEndPoint
- //{
- // MissionEndPointLongitude = targetPoint.TargetPointLongitude,
- // MissionEndPointLatitude = targetPoint.TargetPointLatitude,
- // MissionEndPointHeight = targetPoint.TargetPointHeight
- //};
- foreach (var item in config.KTKSTask.KTKSParameters)
- {
- if (item.AircraftId == aircraft.AircraftId)
- {
- aircraft.taskParameter = item;
- }
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateZSJYEventHandler : AEvent<CreateZSJYTask>
- {
- protected override UniTask Run(CreateZSJYTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- ZSJYMission mission = ComponentFactory.Create<ZSJYMission>();
- mission.date = taskSys.date;
- taskSys.ZSJYMissions.Add(mission);
- mission.MissionId = $"着水救援任务 {config.ZSJYTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.ZSJYTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.ZSJYTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- TargetPoint targetPoint = config.EditorConfig.targetPoints.Find(t => t.TargetPointId == config.ZSJYTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new TargetPoint[] { targetPoint });
- AircraftZS aircraft = ComponentFactory.Create<AircraftZS, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.ZSJYTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.ZSJYTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.ZSJYTask;
- aircraft.AircraftId = config.ZSJYTask.aircraftInfos[i].AircraftId;
- //aircraft.MissionEndPoint = new MissionEndPoint
- //{
- // MissionEndPointLongitude = targetPoint.TargetPointLongitude,
- // MissionEndPointLatitude = targetPoint.TargetPointLatitude,
- // MissionEndPointHeight = targetPoint.TargetPointHeight
- //};
- foreach (var item in config.ZSJYTask.ZSJYParameters)
- {
- if (item.AircraftId == aircraft.AircraftId)
- {
- aircraft.taskParameter = item;
- }
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateJJJYEventHandler : AEvent<CreateJJJYTask>
- {
- protected override UniTask Run(CreateJJJYTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- JJJYMission mission = ComponentFactory.Create<JJJYMission>();
- mission.date = taskSys.date;
- taskSys.JJJYMissions.Add(mission);
- mission.MissionId = $"机降救援任务 {config.JJJYTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.JJJYTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.JJJYTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- TargetPoint targetPoint = config.EditorConfig.targetPoints.Find(t => t.TargetPointId == config.JJJYTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new TargetPoint[] { targetPoint });
- AircraftJJ aircraft = ComponentFactory.Create<AircraftJJ, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.JJJYTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.JJJYTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.JJJYTask;
- aircraft.AircraftId = config.JJJYTask.aircraftInfos[i].AircraftId;
- aircraft.rescueDemandInfo = config.EditorConfig.rescueDemandInfos.Find(t => t.DemandPointName == config.JJJYTask.missionInformation.TargetPoint);
- //aircraft.MissionEndPoint = new MissionEndPoint
- //{
- // MissionEndPointLongitude = targetPoint.TargetPointLongitude,
- // MissionEndPointLatitude = targetPoint.TargetPointLatitude,
- // MissionEndPointHeight = targetPoint.TargetPointHeight
- //};
- foreach (var item in config.JJJYTask.JJJYParameters)
- {
- if (item.AircraftId == aircraft.AircraftId)
- {
- aircraft.taskParameter = item;
- }
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateSHJEventHandler : AEvent<CreateSHJTask>
- {
- protected override UniTask Run(CreateSHJTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- SHJMission mission = ComponentFactory.Create<SHJMission>();
- mission.date = taskSys.date;
- taskSys.SHJMissions.Add(mission);
- mission.MissionId = $"索滑降救援任务 {config.SHJTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.SHJTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.AircraftID == config.SHJTask.aircraftInfos[i].AircraftType);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- TargetPoint targetPoint = config.EditorConfig.targetPoints.Find(t => t.TargetPointId == config.SHJTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new TargetPoint[] { targetPoint });
- AircraftSHJ aircraft = ComponentFactory.Create<AircraftSHJ, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.SHJTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.SHJTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.content = config.SHJTask;
- aircraft.AircraftId = config.SHJTask.aircraftInfos[i].AircraftId;
- aircraft.missionEndPoint = new MissionEndPoint
- {
- MissionEndPointLongitude = targetPoint.TargetPointLongitude,
- MissionEndPointLatitude = targetPoint.TargetPointLatitude,
- MissionEndPointHeight = targetPoint.TargetPointHeight
- };
- foreach (var item in config.SHJTask.SHJParameters)
- {
- if (item.AircraftId == aircraft.AircraftId)
- {
- aircraft.SHJParameter = item;
- }
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateXCJJEventHandler : AEvent<CreateXCJJTask>
- {
- protected override UniTask Run(CreateXCJJTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- XCJJMission mission = ComponentFactory.Create<XCJJMission>();
- mission.date = taskSys.date;
- taskSys.XCJJMissions.Add(mission);
- mission.MissionId = $"现场急救任务 {config.XCJJTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.XCJJTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.Id == config.XCJJTask.aircraftInfos[i].AircraftId);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- MedicalTargetPoint targetPoint = config.EditorConfig.medicalTargetPoints.Find(t => t.TargetPointId == config.XCJJTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new MedicalTargetPoint[] { targetPoint });
- AircraftXCJJ aircraft = ComponentFactory.Create<AircraftXCJJ, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.XCJJTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.XCJJTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.XCJJTask;
- aircraft.AircraftId = config.XCJJTask.aircraftInfos[i].AircraftId;
- aircraft.Airport = originBase.BaseName;
- aircraft.load = aircraftParameter.taskLoad;
- aircraft.AircraftType = aircraftParameter.AircraftSubType;
- aircraft.hospitalAirport = config.XCJJTask.missionInformation.Hospital;
- var hospital = config.EditorConfig.hospitals.Find(t => t.BaseName == config.XCJJTask.missionInformation.Hospital);
- aircraft.hospitalPoint = new MissionEndPoint()
- {
- MissionEndPointLatitude = hospital.BaseLatitude,
- MissionEndPointLongitude = hospital.BaseLongitude,
- MissionEndPointHeight = hospital.BaseHeight
- };
- foreach (var item in config.XCJJTask.XCJJParameters)
- {
- if (item.AircraftId == aircraft.AircraftId)
- {
- aircraft.taskParameter = item;
- }
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateYLZYEventHandler : AEvent<CreateYLZYTask>
- {
- protected override UniTask Run(CreateYLZYTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- YLZYMission mission = ComponentFactory.Create<YLZYMission>();
- mission.date = taskSys.date;
- taskSys.YLZYMissions.Add(mission);
- mission.MissionId = $"医疗转运任务 {config.YLZYTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.YLZYTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.Id == config.YLZYTask.aircraftInfos[i].AircraftId);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- MedicalTargetPoint targetPoint = config.EditorConfig.medicalTargetPoints.Find(t => t.TargetPointId == config.YLZYTask.missionInformation.TargetPointId);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new MedicalTargetPoint[] { targetPoint });
- AircraftYLZY aircraft = ComponentFactory.Create<AircraftYLZY, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.YLZYTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.YLZYTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.YLZYTask;
- aircraft.AircraftId = config.YLZYTask.aircraftInfos[i].AircraftId;
- aircraft.Airport = originBase.BaseName;
- aircraft.load = aircraftParameter.taskLoad;
- aircraft.AircraftType = aircraftParameter.AircraftSubType;
- aircraft.hospitalAirport = config.YLZYTask.missionInformation.Hospital;
- var hospital = config.EditorConfig.hospitals.Find(t => t.BaseName == config.YLZYTask.missionInformation.Hospital);
- aircraft.hospitalPoint = new MissionEndPoint()
- {
- MissionEndPointLatitude = hospital.BaseLatitude,
- MissionEndPointLongitude = hospital.BaseLongitude,
- MissionEndPointHeight = hospital.BaseHeight
- };
- foreach (var item in config.YLZYTask.YLZYParameters)
- {
- if (item.AircraftId == aircraft.AircraftId)
- {
- aircraft.taskParameter = item;
- }
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- [Event]
- public class CreateYLWPYSEventHandler : AEvent<CreateYLWPYSTask>
- {
- protected override UniTask Run(CreateYLWPYSTask config)
- {
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- YLWPYSMission mission = ComponentFactory.Create<YLWPYSMission>();
- mission.date = taskSys.date;
- taskSys.YLWPYSMissions.Add(mission);
- mission.MissionId = $"医疗物品运送 {config.YLWPYSTask.missionInformation.MissionName}";
- mission.ExecutionContext = config.EditorConfig.runCounts;
- //mission.AddComponent<SJTotalTaskPerformanceComponent>();
- for (int i = 0; i < config.YLWPYSTask.aircraftInfos.Length; i++)
- {
- //飞机参数
- var aircraftParameter = config.EditorConfig.aircraftParameters.Find(
- a => a.Id == config.YLWPYSTask.aircraftInfos[i].AircraftId);
- //基地
- var originBase = config.EditorConfig.bases.Find(b => b.BaseId == aircraftParameter.AirportId);
- MedicalSuppliesInfo targetPoint = config.EditorConfig.medicalSuppliesInfos.Find(t => t.TargetPointName == config.YLWPYSTask.missionInformation.TargetPoint);
- //创建飞行计划编辑器
- var flightPlanEditor = FlightPlanEditor.Create(aircraftParameter, config.EditorConfig.cityWeather, originBase, new MedicalSuppliesInfo[] { targetPoint });
- AircraftYLWPYS aircraft = ComponentFactory.Create<AircraftYLWPYS, FlightPlanEditor>(flightPlanEditor);
- aircraft.Name = config.YLWPYSTask.aircraftInfos[i].AircraftType;
- aircraft.TaskReadyTime = config.YLWPYSTask.missionInformation.TakeoffPreparationTime;
- mission.aircrafts.Add(aircraft);
- aircraft.taskContent = config.YLWPYSTask;
- aircraft.AircraftId = config.YLWPYSTask.aircraftInfos[i].AircraftId;
- aircraft.Airport = originBase.BaseName;
- aircraft.load = aircraftParameter.taskLoad;
- aircraft.AircraftType = aircraftParameter.AircraftSubType;
- foreach (var item in config.YLWPYSTask.YLWPYSParameters)
- {
- if (item.AircraftId == aircraft.AircraftId)
- {
- aircraft.taskParameter = item;
- }
- }
- aircraft.AddComponent<SJStaticCapacityComponent>();
- Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
- }
- return UniTask.CompletedTask;
- }
- }
- }
|