123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- using Cysharp.Threading.Tasks;
- using KYFramework;
- using Model;
- using Newtonsoft.Json;
- using SimulationServer.Utils;
- using SimulationSingleServer.Utils;
- using static Org.BouncyCastle.Math.EC.ECCurve;
- using static System.Runtime.InteropServices.JavaScript.JSType;
- using Define = SimulationServer.Utils.Define;
- namespace SimulationServer;
- [Event]
- public class ServerStartEventHandler : AEvent<ServerStart>
- {
- protected override UniTask Run(ServerStart a)
- {
- Log.Info("读取配置文件!");
- var taskSys = Game.Scene.GetComponent<TaskComponent>();
- taskSys.date = DateTime.Now.ToString().Replace("/","-").Replace(":","-").Replace(" ","-");
-
- HttpInterface.serverIp = File.ReadAllText("dbIp.txt");
- SimulationCommon.Util.serverIp = HttpInterface.serverIp;
-
- string ec_path = "Missions/editor_config.json";
- string tc_path = "Missions/task_config.json";
- if (!File.Exists(ec_path))
- {
- Log.Error("editor_config.json文件不存在!");
- return UniTask.CompletedTask;
- }
- if (!File.Exists(tc_path))
- {
- Log.Error("task_config.json文件不存在!");
- return UniTask.CompletedTask;
- }
- string ec_str = File.ReadAllText("Missions/editor_config.json");
- string tc_str = File.ReadAllText("Missions/task_config.json");
-
-
- EditorConfig? editorConfig = JsonConvert.DeserializeObject<EditorConfig>(ec_str);
-
-
-
-
-
-
-
- TaskConfig? taskConfig = JsonConvert.DeserializeObject<TaskConfig>(tc_str);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (editorConfig == null || taskConfig == null)
- {
- Log.Error("配置文件解析失败!");
- return UniTask.CompletedTask;
- }
- foreach (var item in editorConfig.targetPoints)
- {
- if (item.TargetType.Type == "遇险人员" || item.TargetType.Type == "车辆" || item.TargetType.Type == "航空器")
- {
- taskSys.isLand = true;
- }
- else if (item.TargetType.Type == "落水人员" || item.TargetType.Type == "救生筏" || item.TargetType.Type == "船舶" || item.TargetType.Type == "大规模落水人群")
- {
- taskSys.isSea = true;
- }
-
- break;
- }
-
- TaskComponent.Weather = new Weather();
- var temp = TaskComponent.Weather.day_temp.Replace("°C", "");
- Define.TEMPERATURE = double.Parse(temp);
- var wind_temp = TaskComponent.Weather.day_wind_comp.Replace("级", "").Split('-');
- Define.WIND = double.Parse(wind_temp[0]);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- foreach (var XCJJTask in taskConfig.XCJJTasks)
- {
- taskSys.missionCount++;
- Game.EventSystem.Publish(new CreateXCJJTask
- { EditorConfig = editorConfig, XCJJTask = XCJJTask });
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- taskSys.ExecutionContext = editorConfig.runCounts;
- taskSys.Start();
- return UniTask.CompletedTask;
- }
- }
|