From a100f5d4c4c0fc28713e9445d484dbb2802c1d24 Mon Sep 17 00:00:00 2001 From: Somebody Date: Wed, 17 Jul 2024 14:21:24 +0800 Subject: [PATCH] Fix bug - The Sms will not be showed when the mission runs --- Common/Data/Excel/PerformanceDExcel.cs | 30 ++++++++++++++++++++ Common/Data/GameData.cs | 1 + Common/Data/ResourceManager.cs | 33 ++++++++++++++++++++-- GameServer/Game/Task/LevelTask.cs | 10 +++++-- GameServer/Game/Task/PerformanceTrigger.cs | 31 +++++++++++++++++--- 5 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 Common/Data/Excel/PerformanceDExcel.cs diff --git a/Common/Data/Excel/PerformanceDExcel.cs b/Common/Data/Excel/PerformanceDExcel.cs new file mode 100644 index 00000000..48f8a5ba --- /dev/null +++ b/Common/Data/Excel/PerformanceDExcel.cs @@ -0,0 +1,30 @@ +using EggLink.DanhengServer.Data.Config; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EggLink.DanhengServer.Data.Excel +{ + [ResourceEntity("PerformanceD.json")] + public class PerformanceDExcel : ExcelResource + { + public int PerformanceID { get; set; } + public string PerformancePath { get; set; } = ""; + + [JsonIgnore] + public LevelGraphConfigInfo? ActInfo { get; set; } + + public override int GetId() + { + return PerformanceID; + } + + public override void Loaded() + { + GameData.PerformanceDData.Add(PerformanceID, this); + } + } +} diff --git a/Common/Data/GameData.cs b/Common/Data/GameData.cs index ab56992e..53e116b8 100644 --- a/Common/Data/GameData.cs +++ b/Common/Data/GameData.cs @@ -120,6 +120,7 @@ namespace EggLink.DanhengServer.Data public static Dictionary MessageSectionConfigData { get; private set; } = []; public static Dictionary MessageContactsConfigData { get; private set; } = []; public static Dictionary MessageItemConfigData { get; private set; } = []; + public static Dictionary PerformanceDData { get; private set; } = []; public static Dictionary PerformanceEData { get; private set; } = []; public static Dictionary StoryLineData { get; private set; } = []; public static Dictionary StroyLineTrialAvatarDataData { get; private set; } = []; diff --git a/Common/Data/ResourceManager.cs b/Common/Data/ResourceManager.cs index c5356c75..f88d8f20 100644 --- a/Common/Data/ResourceManager.cs +++ b/Common/Data/ResourceManager.cs @@ -398,10 +398,39 @@ namespace EggLink.DanhengServer.Data { Logger.Error(I18nManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name, I18nManager.Translate("Word.Error")), ex); } - } - if (count < GameData.PerformanceEData.Count) + foreach (var performance in GameData.PerformanceDData.Values) + { + if (performance.PerformancePath == "") + { + count++; + continue; + } + + var path = ConfigManager.Config.Path.ResourcePath + "/" + performance.PerformancePath; + var file = new FileInfo(path); + if (!file.Exists) continue; + try + { + using var reader = file.OpenRead(); + using StreamReader reader2 = new(reader); + var text = reader2.ReadToEnd().Replace("$type", "Type"); + var obj = JObject.Parse(text); + if (obj != null) + { + LevelGraphConfigInfo info = LevelGraphConfigInfo.LoadFromJsonObject(obj); + performance.ActInfo = info; + count++; + } + } + catch (Exception ex) + { + Logger.Error(I18nManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name, I18nManager.Translate("Word.Error")), ex); + } + } + + if (count < GameData.PerformanceEData.Count + GameData.PerformanceDData.Count) { // looks like many dont exist //Logger.Warn("Performance infos are missing, please check your resources folder: " + ConfigManager.Config.Path.ResourcePath + "/Config/Level/Mission/*/Act. Performances may not work!"); diff --git a/GameServer/Game/Task/LevelTask.cs b/GameServer/Game/Task/LevelTask.cs index ae16e68e..c1a927f4 100644 --- a/GameServer/Game/Task/LevelTask.cs +++ b/GameServer/Game/Task/LevelTask.cs @@ -101,8 +101,14 @@ namespace EggLink.DanhengServer.GameServer.Game.Task { if (act is TriggerPerformance triggerPerformance) { - if (triggerPerformance.PerformanceType != ELevelPerformanceTypeEnum.E) return; - Player.TaskManager?.PerformanceTrigger.TriggerPerformance(triggerPerformance.PerformanceID, subMission); + if (triggerPerformance.PerformanceType == ELevelPerformanceTypeEnum.E) + { + Player.TaskManager?.PerformanceTrigger.TriggerPerformanceE(triggerPerformance.PerformanceID, subMission); + } + else if (triggerPerformance.PerformanceType == ELevelPerformanceTypeEnum.D) + { + Player.TaskManager?.PerformanceTrigger.TriggerPerformanceD(triggerPerformance.PerformanceID, subMission); + } } } diff --git a/GameServer/Game/Task/PerformanceTrigger.cs b/GameServer/Game/Task/PerformanceTrigger.cs index a0012e16..1ec4f756 100644 --- a/GameServer/Game/Task/PerformanceTrigger.cs +++ b/GameServer/Game/Task/PerformanceTrigger.cs @@ -15,16 +15,39 @@ namespace EggLink.DanhengServer.Game.Task { public PlayerInstance Player { get; } = player; - public void TriggerPerformance(int performanceId, SubMissionExcel subMission) + public void TriggerPerformanceE(int performanceEId, SubMissionExcel subMission) { - GameData.PerformanceEData.TryGetValue(performanceId, out var excel); + GameData.PerformanceEData.TryGetValue(performanceEId, out var excel); if (excel != null) { - TriggerPerformance(excel, subMission); + TriggerPerformanceE(excel, subMission); } } - public void TriggerPerformance(PerformanceEExcel excel, SubMissionExcel subMission) + public void TriggerPerformanceE(PerformanceEExcel excel, SubMissionExcel subMission) + { + if (excel.ActInfo == null) return; + foreach (var act in excel.ActInfo.OnInitSequece) + { + Player.TaskManager?.LevelTask.TriggerInitAct(act, subMission); + } + + foreach (var act in excel.ActInfo.OnStartSequece) + { + Player.TaskManager?.LevelTask.TriggerStartAct(act, subMission); + } + } + + public void TriggerPerformanceD(int performanceDId, SubMissionExcel subMission) + { + GameData.PerformanceDData.TryGetValue(performanceDId, out var excel); + if (excel != null) + { + TriggerPerformanceD(excel, subMission); + } + } + + public void TriggerPerformanceD(PerformanceDExcel excel, SubMissionExcel subMission) { if (excel.ActInfo == null) return; foreach (var act in excel.ActInfo.OnInitSequece)