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

@@ -1,5 +0,0 @@
namespace EggLink.DanhengServer.Data.Config;
public class AnchorInfo : PositionInfo
{
}

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; }
}

View File

@@ -0,0 +1,5 @@
namespace EggLink.DanhengServer.Data.Config.Scene;
public class AnchorInfo : PositionInfo
{
}

View File

@@ -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;
}

View File

@@ -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
{

View File

@@ -1,4 +1,4 @@
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class MonsterInfo : PositionInfo
{

View File

@@ -1,4 +1,4 @@
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class NpcInfo : PositionInfo
{

View File

@@ -1,6 +1,6 @@
using EggLink.DanhengServer.Util;
namespace EggLink.DanhengServer.Data.Config;
namespace EggLink.DanhengServer.Data.Config.Scene;
public class PositionInfo
{

View File

@@ -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
{