Fix Basic Rogue Event

This commit is contained in:
Somebody
2024-08-10 15:16:29 +08:00
parent fe7c51c996
commit b8e7b41d5e
37 changed files with 225 additions and 101 deletions

View File

@@ -0,0 +1,62 @@
using EggLink.DanhengServer.Internationalization;
using EggLink.DanhengServer.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueDialogueBaseConfigInfo
{
public string OptionPath { get; set; } = string.Empty;
public string DialoguePath { get; set; } = string.Empty;
public LevelGraphConfigInfo? DialogueInfo { get; set; }
public RogueDialogueEventConfigInfo? OptionInfo { get; set; }
public void Loaded()
{
var logger = Logger.GetByClassName();
if (!string.IsNullOrEmpty(OptionPath))
{
var path = ConfigManager.Config.Path.ResourcePath + "/" + OptionPath;
var file = new FileInfo(path);
if (!file.Exists) return;
try
{
using var reader = file.OpenRead();
using StreamReader reader2 = new(reader);
var text = reader2.ReadToEnd();
var info = JsonConvert.DeserializeObject<RogueDialogueEventConfigInfo>(text);
OptionInfo = info;
}
catch (Exception ex)
{
logger.Error(
I18nManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name,
I18nManager.Translate("Word.Error")), ex);
}
}
if (!string.IsNullOrEmpty(DialoguePath))
{
var path = ConfigManager.Config.Path.ResourcePath + "/" + DialoguePath;
var file = new FileInfo(path);
if (!file.Exists) return;
try
{
using var reader = file.OpenRead();
using StreamReader reader2 = new(reader);
var text = reader2.ReadToEnd().Replace("$type", "Type");
var obj = JObject.Parse(text);
var info = LevelGraphConfigInfo.LoadFromJsonObject(obj);
DialogueInfo = info;
}
catch (Exception ex)
{
logger.Error(
I18nManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name,
I18nManager.Translate("Word.Error")), ex);
}
}
}
}

View File

@@ -0,0 +1,6 @@
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueDialogueEventConfigInfo
{
public List<RogueDialogueEventOptionConfigInfo> OptionList { get; set; } = [];
}

View File

@@ -0,0 +1,13 @@
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueDialogueEventOptionConfigInfo
{
public int OptionID { get; set; }
public int DisplayID { get; set; }
public int SpecialOptionID { get; set; }
public Dictionary<int, RogueDialogueEventOptionDynamicConfigInfo> DynamicMap { get; set; } = [];
public int DescValue { get; set; }
public int DescValue2 { get; set; }
public int DescValue3 { get; set; }
public int DescValue4 { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueDialogueEventOptionDynamicConfigInfo
{
public int DisplayID { get; set; }
public int DisplayID2 { get; set; }
}

View File

@@ -0,0 +1,22 @@
using EggLink.DanhengServer.Enums.Rogue;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueNPCConfigInfo
{
[JsonConverter(typeof(StringEnumConverter))]
public RogueDialogueTypeEnum DialogueType { get; set; }
public List<RogueNPCDialogueConfigInfo> DialogueList { get; set; } = [];
public void Loaded()
{
if (DialogueList.Count == 0) return;
foreach (var info in DialogueList)
{
info.Loaded();
}
}
}

View File

@@ -0,0 +1,8 @@
namespace EggLink.DanhengServer.Data.Config.Rogue;
public class RogueNPCDialogueConfigInfo : RogueDialogueBaseConfigInfo
{
public int DialogueProgress { get; set; }
public int UnlockID { get; set; }
public int TalkNameID { get; set; }
}