mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-03 04:36:03 +08:00
Fix Basic Rogue Event
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
namespace EggLink.DanhengServer.Data.Config;
|
||||
|
||||
public class AnchorInfo : PositionInfo
|
||||
{
|
||||
}
|
||||
62
Common/Data/Config/Rogue/RogueDialogueBaseConfigInfo.cs
Normal file
62
Common/Data/Config/Rogue/RogueDialogueBaseConfigInfo.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
Common/Data/Config/Rogue/RogueDialogueEventConfigInfo.cs
Normal file
6
Common/Data/Config/Rogue/RogueDialogueEventConfigInfo.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace EggLink.DanhengServer.Data.Config.Rogue;
|
||||
|
||||
public class RogueDialogueEventConfigInfo
|
||||
{
|
||||
public List<RogueDialogueEventOptionConfigInfo> OptionList { get; set; } = [];
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace EggLink.DanhengServer.Data.Config.Rogue;
|
||||
|
||||
public class RogueDialogueEventOptionDynamicConfigInfo
|
||||
{
|
||||
public int DisplayID { get; set; }
|
||||
public int DisplayID2 { get; set; }
|
||||
}
|
||||
22
Common/Data/Config/Rogue/RogueNPCConfigInfo.cs
Normal file
22
Common/Data/Config/Rogue/RogueNPCConfigInfo.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Common/Data/Config/Rogue/RogueNPCDialogueConfigInfo.cs
Normal file
8
Common/Data/Config/Rogue/RogueNPCDialogueConfigInfo.cs
Normal 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; }
|
||||
}
|
||||
5
Common/Data/Config/Scene/AnchorInfo.cs
Normal file
5
Common/Data/Config/Scene/AnchorInfo.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class AnchorInfo : PositionInfo
|
||||
{
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using EggLink.DanhengServer.Enums.Scene;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Config;
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class FloorInfo
|
||||
{
|
||||
@@ -42,35 +42,35 @@ public class FloorInfo
|
||||
|
||||
// Cache anchors
|
||||
foreach (var group in Groups.Values)
|
||||
foreach (var prop in group.PropList)
|
||||
// Check if prop can be teleported to
|
||||
if (prop.AnchorID > 0)
|
||||
{
|
||||
// Put inside cached teleport list to send to client when they request map info
|
||||
CachedTeleports.TryAdd(prop.MappingInfoID, prop);
|
||||
UnlockedCheckpoints.Add(prop);
|
||||
|
||||
// Force prop to be in the unlocked state
|
||||
prop.State = PropStateEnum.CheckPointEnable;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(prop.InitLevelGraph))
|
||||
{
|
||||
var json = prop.InitLevelGraph;
|
||||
|
||||
// Hacky way to setup prop triggers
|
||||
if (json.Contains("Maze_GroupProp_OpenTreasure_WhenMonsterDie"))
|
||||
foreach (var prop in group.PropList)
|
||||
// Check if prop can be teleported to
|
||||
if (prop.AnchorID > 0)
|
||||
{
|
||||
//prop.Trigger = new TriggerOpenTreasureWhenMonsterDie(group.Id);
|
||||
}
|
||||
else if (json.Contains("Common_Console"))
|
||||
{
|
||||
prop.CommonConsole = true;
|
||||
}
|
||||
// Put inside cached teleport list to send to client when they request map info
|
||||
CachedTeleports.TryAdd(prop.MappingInfoID, prop);
|
||||
UnlockedCheckpoints.Add(prop);
|
||||
|
||||
// Clear for garbage collection
|
||||
prop.ValueSource = null;
|
||||
prop.InitLevelGraph = null;
|
||||
}
|
||||
// Force prop to be in the unlocked state
|
||||
prop.State = PropStateEnum.CheckPointEnable;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(prop.InitLevelGraph))
|
||||
{
|
||||
var json = prop.InitLevelGraph;
|
||||
|
||||
// Hacky way to setup prop triggers
|
||||
if (json.Contains("Maze_GroupProp_OpenTreasure_WhenMonsterDie"))
|
||||
{
|
||||
//prop.Trigger = new TriggerOpenTreasureWhenMonsterDie(group.Id);
|
||||
}
|
||||
else if (json.Contains("Common_Console"))
|
||||
{
|
||||
prop.CommonConsole = true;
|
||||
}
|
||||
|
||||
// Clear for garbage collection
|
||||
prop.ValueSource = null;
|
||||
prop.InitLevelGraph = null;
|
||||
}
|
||||
|
||||
Loaded = true;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using EggLink.DanhengServer.Util;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Config;
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class GroupInfo
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace EggLink.DanhengServer.Data.Config;
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class MonsterInfo : PositionInfo
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace EggLink.DanhengServer.Data.Config;
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class NpcInfo : PositionInfo
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using EggLink.DanhengServer.Util;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Config;
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class PositionInfo
|
||||
{
|
||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Config;
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class PropInfo : PositionInfo
|
||||
{
|
||||
@@ -1,31 +0,0 @@
|
||||
using EggLink.DanhengServer.Data.Config;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Excel;
|
||||
|
||||
[ResourceEntity("RogueNPCDialogue.json")]
|
||||
public class RogueNPCDialogueExcel : ExcelResource
|
||||
{
|
||||
public int RogueNPCID { get; set; }
|
||||
public int DialogueProgress { get; set; }
|
||||
public int HandbookEventID { get; set; }
|
||||
public string DialoguePath { get; set; } = "";
|
||||
|
||||
[JsonIgnore] public DialogueInfo? DialogueInfo { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return RogueNPCID * 100 + DialogueProgress;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.RogueNPCDialogueData.Add(GetId(), this);
|
||||
}
|
||||
|
||||
public bool CanUseInVer(int version)
|
||||
{
|
||||
GameData.RogueHandBookEventData.TryGetValue(HandbookEventID, out var handbookEvent);
|
||||
return DialogueInfo != null && handbookEvent != null && handbookEvent.EventTypeList.Contains(version);
|
||||
}
|
||||
}
|
||||
28
Common/Data/Excel/RogueNPCExcel.cs
Normal file
28
Common/Data/Excel/RogueNPCExcel.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using EggLink.DanhengServer.Data.Config;
|
||||
using EggLink.DanhengServer.Data.Config.Rogue;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Excel;
|
||||
|
||||
[ResourceEntity("RogueNPC.json")]
|
||||
public class RogueNPCExcel : ExcelResource
|
||||
{
|
||||
public int RogueNPCID { get; set; }
|
||||
public string NPCJsonPath { get; set; } = string.Empty;
|
||||
|
||||
public RogueNPCConfigInfo? RogueNpcConfig { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return RogueNPCID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.RogueNPCData.TryAdd(RogueNPCID, this);
|
||||
}
|
||||
|
||||
public bool CanUseInVer(int version)
|
||||
{
|
||||
return RogueNpcConfig != null;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using EggLink.DanhengServer.Data.Config;
|
||||
using EggLink.DanhengServer.Data.Config.Scene;
|
||||
using EggLink.DanhengServer.Data.Custom;
|
||||
using EggLink.DanhengServer.Data.Excel;
|
||||
using EggLink.DanhengServer.Enums.Rogue;
|
||||
@@ -201,7 +201,7 @@ public static class GameData
|
||||
public static Dictionary<int, List<int>> RogueMiracleGroupData { get; set; } = [];
|
||||
public static Dictionary<int, RogueMiracleDisplayExcel> RogueMiracleDisplayData { get; private set; } = [];
|
||||
public static Dictionary<int, RogueMonsterExcel> RogueMonsterData { get; private set; } = [];
|
||||
public static Dictionary<int, RogueNPCDialogueExcel> RogueNPCDialogueData { get; private set; } = [];
|
||||
public static Dictionary<int, RogueNPCExcel> RogueNPCData { get; private set; } = [];
|
||||
public static Dictionary<int, RogueRoomExcel> RogueRoomData { get; private set; } = [];
|
||||
public static Dictionary<int, RogueTalentExcel> RogueTalentData { get; private set; } = [];
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Reflection;
|
||||
using EggLink.DanhengServer.Data.Config;
|
||||
using EggLink.DanhengServer.Data.Config.Rogue;
|
||||
using EggLink.DanhengServer.Data.Config.Scene;
|
||||
using EggLink.DanhengServer.Data.Custom;
|
||||
using EggLink.DanhengServer.Data.Excel;
|
||||
using EggLink.DanhengServer.Enums.Rogue;
|
||||
@@ -361,9 +363,9 @@ public class ResourceManager
|
||||
{
|
||||
Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadingItem", I18nManager.Translate("Word.DialogueInfo")));
|
||||
var count = 0;
|
||||
foreach (var dialogue in GameData.RogueNPCDialogueData)
|
||||
foreach (var dialogue in GameData.RogueNPCData)
|
||||
{
|
||||
var path = ConfigManager.Config.Path.ResourcePath + "/" + dialogue.Value.DialoguePath;
|
||||
var path = ConfigManager.Config.Path.ResourcePath + "/" + dialogue.Value.NPCJsonPath;
|
||||
var file = new FileInfo(path);
|
||||
if (!file.Exists) continue;
|
||||
try
|
||||
@@ -371,14 +373,11 @@ public class ResourceManager
|
||||
using var reader = file.OpenRead();
|
||||
using StreamReader reader2 = new(reader);
|
||||
var text = reader2.ReadToEnd().Replace("$type", "Type");
|
||||
var dialogueInfo = JsonConvert.DeserializeObject<DialogueInfo>(text);
|
||||
var dialogueInfo = JsonConvert.DeserializeObject<RogueNPCConfigInfo>(text);
|
||||
if (dialogueInfo != null)
|
||||
{
|
||||
dialogue.Value.DialogueInfo = dialogueInfo;
|
||||
dialogue.Value.RogueNpcConfig = dialogueInfo;
|
||||
dialogueInfo.Loaded();
|
||||
if (dialogueInfo.DialogueIds.Count == 0)
|
||||
// set to invalid
|
||||
dialogue.Value.DialogueInfo = null;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -390,7 +389,7 @@ public class ResourceManager
|
||||
}
|
||||
}
|
||||
|
||||
if (count < GameData.RogueNPCDialogueData.Count)
|
||||
if (count < GameData.RogueNPCData.Count)
|
||||
Logger.Warn(I18nManager.Translate("Server.ServerInfo.ConfigMissing",
|
||||
I18nManager.Translate("Word.DialogueInfo"),
|
||||
$"{ConfigManager.Config.Path.ResourcePath}/Config/Level/Rogue/Dialogue",
|
||||
|
||||
Reference in New Issue
Block a user