12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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 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>();
- 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;
- }
-
- 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 mhTask in taskConfig.mHTaskConfigs)
- {
- Game.EventSystem.Publish(new CreateMHTask
- { EditorConfig = editorConfig, MHTaskConfig = mhTask });
- }
-
- foreach (var zcTask in taskConfig.zCTask)
- {
- Game.EventSystem.Publish(new CreateZCTask
- { EditorConfig = editorConfig, ZCTask = zcTask });
- }
-
- foreach (var xhTask in taskConfig.xHTask)
- {
- Game.EventSystem.Publish(new CreateXHTask
- { EditorConfig = editorConfig, XHTask = xhTask });
- }
-
-
- foreach (var seaSJTask in taskConfig.seaSouJiuTasks)
- {
-
-
-
-
-
-
- Game.EventSystem.Publish(new CreateSeaSJTask
- { EditorConfig = editorConfig, SeaSJTask = seaSJTask });
- }
- taskSys.ExecutionContext = editorConfig.runCounts;
- taskSys.Start();
- return UniTask.CompletedTask;
- }
- }
|