mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-14 05:44:34 +01:00
Init enter game
This commit is contained in:
7
Common/Data/Config/TimeStampConfig.cs
Normal file
7
Common/Data/Config/TimeStampConfig.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace KianaBH.Data.Config;
|
||||
|
||||
public class TimestampConfig
|
||||
{
|
||||
public uint TimeStampForBakedReader { get; set; }
|
||||
}
|
||||
|
||||
24
Common/Data/Excel/ActChallengeDataExcel.cs
Normal file
24
Common/Data/Excel/ActChallengeDataExcel.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("ActChallengeData.json")]
|
||||
public class ActChallengeDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("actId")] public uint ActId { get; set; }
|
||||
[JsonPropertyName("difficulty")] public uint Difficulty { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)ActId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
if (!GameData.ActChallengeData.ContainsKey(GetId()))
|
||||
{
|
||||
GameData.ActChallengeData[GetId()] = new List<ActChallengeDataExcel>();
|
||||
}
|
||||
GameData.ActChallengeData[GetId()].Add(this);
|
||||
}
|
||||
}
|
||||
17
Common/Data/Excel/ActivityTowerExcel.cs
Normal file
17
Common/Data/Excel/ActivityTowerExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("ActivityTower.json")]
|
||||
public class ActivityTowerExcel : ExcelResource
|
||||
{
|
||||
public uint ActivityID { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)ActivityID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.ActivityTowerData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
20
Common/Data/Excel/AffixListExcel.cs
Normal file
20
Common/Data/Excel/AffixListExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("AffixList.json")]
|
||||
public class AffixListExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("affixID")] public int AffixID { get; set; }
|
||||
[JsonPropertyName("level")] public int Level { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return AffixID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.AffixListData.Add(AffixID, this);
|
||||
}
|
||||
}
|
||||
27
Common/Data/Excel/AvatarDataExcel.cs
Normal file
27
Common/Data/Excel/AvatarDataExcel.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("AvatarData.json")]
|
||||
public class AvatarDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("avatarID")] public int AvatarID { get; set; }
|
||||
[JsonPropertyName("unlockStar")] public int UnlockStar { get; set; }
|
||||
[JsonPropertyName("initialWeapon")] public int InitialWeapon { get; set; }
|
||||
[JsonPropertyName("skillList")] public List<int> SkillList { get; set; } = [];
|
||||
public int DefaultDressId { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return AvatarID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
if (AvatarID != 316 && (AvatarID < 9000 || AvatarID > 20000))
|
||||
{
|
||||
GameData.AvatarData.Add(AvatarID, this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
22
Common/Data/Excel/AvatarSubSkillDataExcel.cs
Normal file
22
Common/Data/Excel/AvatarSubSkillDataExcel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("AvatarSubSkillData.json")]
|
||||
public class AvatarSubSkillDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("skillId")] public int SkillId { get; set; }
|
||||
[JsonPropertyName("unlockScoin")] public int UnlockScoin { get; set; }
|
||||
[JsonPropertyName("maxLv")] public int MaxLv { get; set; }
|
||||
[JsonPropertyName("avatarSubSkillId")] public int AvatarSubSkillId { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return AvatarSubSkillId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.AvatarSubSkillData.Add(AvatarSubSkillId, this);
|
||||
}
|
||||
}
|
||||
17
Common/Data/Excel/AvatarTutorialExcel.cs
Normal file
17
Common/Data/Excel/AvatarTutorialExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("AvatarTutorial.json")]
|
||||
public class AvatarTutorialExcel : ExcelResource
|
||||
{
|
||||
public uint ActivityID { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)ActivityID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.AvatarTutorialData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
25
Common/Data/Excel/ChapterGroupConfigExcel.cs
Normal file
25
Common/Data/Excel/ChapterGroupConfigExcel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using KianaBH.Data.Config;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("ChapterGroupConfig.json")]
|
||||
public class ChapterGroupConfigExcel : ExcelResource
|
||||
{
|
||||
public uint ID { get; set; }
|
||||
public uint GroupType { get; set; }
|
||||
public TimestampConfig? BeginShowTime { get; set; }
|
||||
public TimestampConfig? BeginTime { get; set; }
|
||||
public uint BeginShowLevel { get; set; }
|
||||
public List<uint> SiteList { get; set; } = [];
|
||||
public uint UnlockLevel { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)ID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.ChapterGroupConfigData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
21
Common/Data/Excel/CityEventPhotoExcel.cs
Normal file
21
Common/Data/Excel/CityEventPhotoExcel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using KianaBH.Data.Config;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("CityEventPhoto.json")]
|
||||
public class CityEventPhotoExcel : ExcelResource
|
||||
{
|
||||
public uint PhotoID { get; set; }
|
||||
[JsonPropertyName("photoType")] public uint PhotoType { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)PhotoID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.CityEventPhotoData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
17
Common/Data/Excel/CollectionExcel.cs
Normal file
17
Common/Data/Excel/CollectionExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("Collection.json")]
|
||||
public class CollectionExcel : ExcelResource
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.CollectionData.Add(ID, this);
|
||||
}
|
||||
}
|
||||
19
Common/Data/Excel/CustomHeadDataExcel.cs
Normal file
19
Common/Data/Excel/CustomHeadDataExcel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("CustomHeadData.json")]
|
||||
public class CustomHeadDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("headID")] public uint HeadID { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)HeadID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.CustomHeadData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
20
Common/Data/Excel/DressDataExcel.cs
Normal file
20
Common/Data/Excel/DressDataExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("DressData.json")]
|
||||
public class DressDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("dressID")] public uint DressID { get; set; }
|
||||
[JsonPropertyName("avatarIDList")] public List<uint> AvatarIDList { get; set; } = [];
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)DressID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.DressData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
30
Common/Data/Excel/ElfAstraMateDataExcel.cs
Normal file
30
Common/Data/Excel/ElfAstraMateDataExcel.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("Elf_AstraMate_Data.json")]
|
||||
public class ElfAstraMateDataExcel : ExcelResource
|
||||
{
|
||||
public uint ElfID { get; set; }
|
||||
public uint MaxLevel { get; set; }
|
||||
public uint MaxRarity { get; set; }
|
||||
|
||||
[JsonIgnore] public List<ElfSkillDataExcel> SkillList = [];
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)ElfID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.ElfAstraMateData.Add(GetId(), this);
|
||||
}
|
||||
|
||||
public override void AfterAllDone()
|
||||
{
|
||||
GameData.ElfSkillData.TryGetValue(GetId(), out var Skills);
|
||||
if (Skills == null || !Skills.ElfIds.Contains(ElfID)) return;
|
||||
SkillList.Add(Skills);
|
||||
}
|
||||
}
|
||||
18
Common/Data/Excel/ElfSkillDataExcel.cs
Normal file
18
Common/Data/Excel/ElfSkillDataExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("ElfSkillData.json")]
|
||||
public class ElfSkillDataExcel : ExcelResource
|
||||
{
|
||||
public uint ElfSkillID { get; set; }
|
||||
public uint MaxLv { get; set; }
|
||||
public List<uint> ElfIds { get; set; } = [];
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)ElfSkillID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.ElfSkillData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
18
Common/Data/Excel/EntryThemeDataExcel.cs
Normal file
18
Common/Data/Excel/EntryThemeDataExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("EntryThemeData.json")]
|
||||
public class EntryThemeDataExcel : ExcelResource
|
||||
{
|
||||
public uint SpaceShipConfigId { get; set; }
|
||||
public List<uint> ThemeBgmConfigList { get; set; } = [];
|
||||
public List<uint> ThemeTagList { get; set; } = [];
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)SpaceShipConfigId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.EntryThemeData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
16
Common/Data/Excel/EntryThemeItemDataExcel.cs
Normal file
16
Common/Data/Excel/EntryThemeItemDataExcel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("EntryThemeItemData.json")]
|
||||
public class EntryThemeItemDataExcel : ExcelResource
|
||||
{
|
||||
public int ThemeItemID { get; set; }
|
||||
public override int GetId()
|
||||
{
|
||||
return ThemeItemID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.EntryThemeItemData.Add(ThemeItemID, this);
|
||||
}
|
||||
}
|
||||
19
Common/Data/Excel/FrameDataExcel.cs
Normal file
19
Common/Data/Excel/FrameDataExcel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("FrameData.json")]
|
||||
public class FrameDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("id")] public uint Id { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)Id;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.FrameData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
18
Common/Data/Excel/GeneralActivityExcel.cs
Normal file
18
Common/Data/Excel/GeneralActivityExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("GeneralActivity.json")]
|
||||
public class GeneralActivityExcel : ExcelResource
|
||||
{
|
||||
public uint AcitivityID { get; set; }
|
||||
public uint Series { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)AcitivityID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.GeneralActivityData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
24
Common/Data/Excel/GeneralActivityStageGroupExcel.cs
Normal file
24
Common/Data/Excel/GeneralActivityStageGroupExcel.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("GeneralActivityStageGroup.json")]
|
||||
public class GeneralActivityStageGroupExcel : ExcelResource
|
||||
{
|
||||
public uint AcitivityId { get; set; }
|
||||
public uint StageGroupId { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)AcitivityId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
if (!GameData.GeneralActivityStageGroupData.ContainsKey(GetId()))
|
||||
{
|
||||
GameData.GeneralActivityStageGroupData[GetId()] = new List<GeneralActivityStageGroupExcel>();
|
||||
}
|
||||
GameData.GeneralActivityStageGroupData[GetId()].Add(this);
|
||||
}
|
||||
}
|
||||
20
Common/Data/Excel/GodWarEventExcel.cs
Normal file
20
Common/Data/Excel/GodWarEventExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("GodWarEvent.json")]
|
||||
public class GodWarEventExcel : ExcelResource
|
||||
{
|
||||
public uint EventID { get; set; }
|
||||
public int EventType { get; set; }
|
||||
public List<uint> ParamsVar { get; set; } = [];
|
||||
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)EventID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.GodWarEventData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
17
Common/Data/Excel/GodWarMainAvatarExcel.cs
Normal file
17
Common/Data/Excel/GodWarMainAvatarExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("GodWarMainAvatar.json")]
|
||||
public class GodWarMainAvatarExcel : ExcelResource
|
||||
{
|
||||
public int MainAvatarID { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return MainAvatarID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.GodWarMainAvatarData.Add(MainAvatarID, this);
|
||||
}
|
||||
}
|
||||
20
Common/Data/Excel/GodWarRelationDataExcel.cs
Normal file
20
Common/Data/Excel/GodWarRelationDataExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("GodWarRelationData.json")]
|
||||
public class GodWarRelationDataExcel : ExcelResource
|
||||
{
|
||||
public int AvatarID { get; set; }
|
||||
public int RoleID { get; set; }
|
||||
public int Level { get; set; }
|
||||
public int MaxLevel { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return AvatarID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.GodWarRelationData.Add(this);
|
||||
}
|
||||
}
|
||||
17
Common/Data/Excel/GodWarSupportAvatarExcel.cs
Normal file
17
Common/Data/Excel/GodWarSupportAvatarExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("GodWarSupportAvatar.json")]
|
||||
public class GodWarSupportAvatarExcel : ExcelResource
|
||||
{
|
||||
public int SupportAvatarID { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return SupportAvatarID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.GodWarSupportAvatarData.Add(SupportAvatarID, this);
|
||||
}
|
||||
}
|
||||
22
Common/Data/Excel/GodWarTaleScheduleExcel.cs
Normal file
22
Common/Data/Excel/GodWarTaleScheduleExcel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using KianaBH.Data.Config;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("GodWarTaleSchedule.json")]
|
||||
public class GodWarTaleScheduleExcel : ExcelResource
|
||||
{
|
||||
public uint TaleScheduleID { get; set; }
|
||||
public List<uint> TaleIDList { get; set; } = [];
|
||||
public TimestampConfig? BeginTime { get; set; }
|
||||
public TimestampConfig? EndTime { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)TaleScheduleID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.GodWarTaleScheduleData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
19
Common/Data/Excel/GodWarTalentDataExcel.cs
Normal file
19
Common/Data/Excel/GodWarTalentDataExcel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("GodWarTalentData.json")]
|
||||
public class GodWarTalentDataExcel : ExcelResource
|
||||
{
|
||||
public uint TalentID { get; set; }
|
||||
public uint MaxLevel { get; set; }
|
||||
public List<uint> TaleIDList { get; set; } = [];
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)TalentID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.GodWarTalentData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
22
Common/Data/Excel/MaterialDataExcel.cs
Normal file
22
Common/Data/Excel/MaterialDataExcel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("MaterialData.json")]
|
||||
public class MaterialDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("ID")] public int Id { get; set; }
|
||||
[JsonPropertyName("rarity")] public int Rarity { get; set; }
|
||||
[JsonPropertyName("maxRarity")] public int MaxRarity { get; set; }
|
||||
[JsonPropertyName("quantityLimit")] public int QuantityLimit { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.MaterialData.Add(Id, this);
|
||||
}
|
||||
}
|
||||
22
Common/Data/Excel/MissionDataExcel.cs
Normal file
22
Common/Data/Excel/MissionDataExcel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("MissionData.json")]
|
||||
public class MissionDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("id")] public uint Id { get; set; }
|
||||
[JsonPropertyName("totalProgress")] public uint TotalProgress { get; set; }
|
||||
public uint Priority { get; set; }
|
||||
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)Id;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.MissionData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
20
Common/Data/Excel/PhonePendantDataExcel.cs
Normal file
20
Common/Data/Excel/PhonePendantDataExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("PhonePendantData.json")]
|
||||
public class PhonePendantDataExcel : ExcelResource
|
||||
{
|
||||
public uint PendantId { get; set; }
|
||||
public uint Rarity { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)PendantId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.PhonePendantData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
21
Common/Data/Excel/RandomPlotDataExcel.cs
Normal file
21
Common/Data/Excel/RandomPlotDataExcel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("RandomPlotData.json")]
|
||||
public class RandomPlotDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("plotId")] public uint PlotId { get; set; }
|
||||
[JsonPropertyName("startDialogId")] public uint StartDialogId { get; set; }
|
||||
[JsonPropertyName("finishDialogIdList")] public List<uint> FinishDialogIdList { get; set; } = [];
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)PlotId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.RandomPlotData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
17
Common/Data/Excel/RecommendPanelExcel.cs
Normal file
17
Common/Data/Excel/RecommendPanelExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("RecommendPanel.json")]
|
||||
public class RecommendPanelExcel : ExcelResource
|
||||
{
|
||||
public uint PanelId { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)PanelId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.RecommendPanelData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
28
Common/Data/Excel/StageDataMainExcel.cs
Normal file
28
Common/Data/Excel/StageDataMainExcel.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("StageData_Main.json")]
|
||||
public class StageDataMainExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("levelId")] public uint LevelId { get; set; }
|
||||
[JsonPropertyName("maxProgress")] public uint MaxProgress { get; set; }
|
||||
[JsonPropertyName("challengeList")] public List<ChallengeData> ChallengeList { get; set; } = [];
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)LevelId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.StageDataMain.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ChallengeData
|
||||
{
|
||||
[JsonPropertyName("challengeId")] public uint ChallengeId { get; set; }
|
||||
[JsonPropertyName("rewardId")] public uint RewardId { get; set; }
|
||||
}
|
||||
21
Common/Data/Excel/StepMissionCompensationExcel.cs
Normal file
21
Common/Data/Excel/StepMissionCompensationExcel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("StepMissionCompensation.json")]
|
||||
public class StepMissionCompensationExcel : ExcelResource
|
||||
{
|
||||
public uint CompensationId { get; set; }
|
||||
public uint UnlockLevel { get; set; }
|
||||
public List<uint> MainLineStepIdList { get; set; } = [];
|
||||
public List<uint> NewChallengeStepIdList { get; set; } = [];
|
||||
public List<uint> OldChallengeStepIdList { get; set; } = [];
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)CompensationId;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.StepMissionCompensationData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
26
Common/Data/Excel/StigmataDataExcel.cs
Normal file
26
Common/Data/Excel/StigmataDataExcel.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("StigmataData.json")]
|
||||
public class StigmataDataExcel : ExcelResource
|
||||
{
|
||||
public int ID { get; set; }
|
||||
[JsonPropertyName("maxLv")] public int MaxLv { get; set; }
|
||||
[JsonPropertyName("rarity")] public int Rarity { get; set; }
|
||||
[JsonPropertyName("maxRarity")] public int MaxRarity { get; set; }
|
||||
[JsonPropertyName("evoID")] public int EvoID { get; set; }
|
||||
[JsonPropertyName("quality")] public int Quality { get; set; }
|
||||
[JsonPropertyName("isSecurityProtect")] public bool IsSecurityProtect { get; set; }
|
||||
[JsonPropertyName("protect")] public bool Protect { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.StigmataData.Add(ID, this);
|
||||
}
|
||||
}
|
||||
21
Common/Data/Excel/ThemeDataAvatarExcel.cs
Normal file
21
Common/Data/Excel/ThemeDataAvatarExcel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("ThemeData_Avatar.json")]
|
||||
public class ThemeDataAvatarExcel : ExcelResource
|
||||
{
|
||||
public uint AvatarData { get; set; }
|
||||
public List<uint> BuffList { get; set; } = [];
|
||||
[JsonPropertyName("avatarIDList")] public List<uint> AvatarIDList { get; set; } = [];
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)AvatarData;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.ThemeDataAvatar.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
20
Common/Data/Excel/TutorialDataExcel.cs
Normal file
20
Common/Data/Excel/TutorialDataExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("TutorialData.json")]
|
||||
public class TutorialDataExcel : ExcelResource
|
||||
{
|
||||
[JsonPropertyName("id")] public uint Id { get; set; }
|
||||
[JsonPropertyName("index")] public uint Index { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return (int)Id;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.TutorialData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
25
Common/Data/Excel/WeaponDataExcel.cs
Normal file
25
Common/Data/Excel/WeaponDataExcel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data.Excel;
|
||||
|
||||
[ResourceEntity("WeaponData.json")]
|
||||
public class WeaponDataExcel : ExcelResource
|
||||
{
|
||||
public int ID { get; set; }
|
||||
[JsonPropertyName("weaponMainID")] public int WeaponMainID { get; set; }
|
||||
[JsonPropertyName("maxLv")] public int MaxLv { get; set; }
|
||||
[JsonPropertyName("rarity")] public int Rarity { get; set; }
|
||||
[JsonPropertyName("maxRarity")] public int MaxRarity { get; set; }
|
||||
[JsonPropertyName("evoID")] public int EvoID { get; set; }
|
||||
[JsonPropertyName("protect")] public bool Protect { get; set; }
|
||||
|
||||
public override int GetId()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.WeaponData.Add(ID, this);
|
||||
}
|
||||
}
|
||||
18
Common/Data/ExcelResource.cs
Normal file
18
Common/Data/ExcelResource.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace KianaBH.Data;
|
||||
|
||||
public abstract class ExcelResource
|
||||
{
|
||||
public abstract int GetId();
|
||||
|
||||
public virtual void Loaded()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Finalized()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void AfterAllDone()
|
||||
{
|
||||
}
|
||||
}
|
||||
45
Common/Data/GameData.cs
Normal file
45
Common/Data/GameData.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using KianaBH.Data.Excel;
|
||||
using KianaBH.Util.Extensions;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KianaBH.Data;
|
||||
|
||||
public static class GameData
|
||||
{
|
||||
public static Dictionary<int, List<ActChallengeDataExcel>> ActChallengeData { get; private set; } = [];
|
||||
public static Dictionary<int, ActivityTowerExcel> ActivityTowerData { get; private set; } = [];
|
||||
public static Dictionary<int, AffixListExcel> AffixListData { get; private set; } = [];
|
||||
public static Dictionary<int, AvatarDataExcel> AvatarData { get; private set; } = [];
|
||||
public static Dictionary<int, AvatarSubSkillDataExcel> AvatarSubSkillData { get; private set; } = [];
|
||||
public static Dictionary<int, AvatarTutorialExcel> AvatarTutorialData { get; private set; } = [];
|
||||
public static Dictionary<int, CollectionExcel> CollectionData { get; private set; } = [];
|
||||
public static Dictionary<int, CustomHeadDataExcel> CustomHeadData { get; private set; } = [];
|
||||
public static Dictionary<int, DressDataExcel> DressData { get; private set; } = [];
|
||||
public static Dictionary<int, ElfAstraMateDataExcel> ElfAstraMateData { get; private set; } = [];
|
||||
public static Dictionary<int, ElfSkillDataExcel> ElfSkillData { get; private set; } = [];
|
||||
public static Dictionary<int, EntryThemeDataExcel> EntryThemeData { get; private set; } = [];
|
||||
public static Dictionary<int, EntryThemeItemDataExcel> EntryThemeItemData { get; private set; } = [];
|
||||
public static Dictionary<int, FrameDataExcel> FrameData { get; private set; } = [];
|
||||
public static Dictionary<int, List<GeneralActivityStageGroupExcel>> GeneralActivityStageGroupData { get; private set; } = [];
|
||||
public static Dictionary<int, GeneralActivityExcel> GeneralActivityData { get; private set; } = [];
|
||||
public static Dictionary<int, GodWarEventExcel> GodWarEventData { get; private set; } = [];
|
||||
public static Dictionary<int, GodWarMainAvatarExcel> GodWarMainAvatarData { get; private set; } = [];
|
||||
public static List<GodWarRelationDataExcel> GodWarRelationData { get; private set; } = [];
|
||||
public static Dictionary<int, GodWarSupportAvatarExcel> GodWarSupportAvatarData { get; private set; } = [];
|
||||
public static Dictionary<int, GodWarTaleScheduleExcel> GodWarTaleScheduleData { get; private set; } = [];
|
||||
public static Dictionary<int, GodWarTalentDataExcel> GodWarTalentData { get; private set; } = [];
|
||||
public static Dictionary<int, MaterialDataExcel> MaterialData { get; private set; } = [];
|
||||
public static Dictionary<int, MissionDataExcel> MissionData { get; private set; } = [];
|
||||
public static Dictionary<int, RecommendPanelExcel> RecommendPanelData { get; private set; } = [];
|
||||
public static Dictionary<int, StageDataMainExcel> StageDataMain { get; private set; } = [];
|
||||
public static Dictionary<int, StepMissionCompensationExcel> StepMissionCompensationData { get; private set; } = [];
|
||||
public static Dictionary<int, StigmataDataExcel> StigmataData { get; private set; } = [];
|
||||
public static Dictionary<int, ThemeDataAvatarExcel> ThemeDataAvatar { get; private set; } = [];
|
||||
public static Dictionary<int, WeaponDataExcel> WeaponData { get; private set; } = [];
|
||||
public static Dictionary<int, ChapterGroupConfigExcel> ChapterGroupConfigData { get; private set; } = [];
|
||||
public static Dictionary<int, PhonePendantDataExcel> PhonePendantData { get; private set; } = [];
|
||||
public static Dictionary<int, TutorialDataExcel> TutorialData { get; private set; } = [];
|
||||
public static Dictionary<int, CityEventPhotoExcel> CityEventPhotoData { get; private set; } = [];
|
||||
public static Dictionary<int, RandomPlotDataExcel> RandomPlotData { get; private set; } = [];
|
||||
}
|
||||
13
Common/Data/Models/Dispatch/DispatchQuery.cs
Normal file
13
Common/Data/Models/Dispatch/DispatchQuery.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KianaBH.Data.Models.Dispatch;
|
||||
|
||||
public class DispatchQuery
|
||||
{
|
||||
[Required] public string? Version { get; set; }
|
||||
[FromQuery(Name = "t")] public int Timestamp { get; set; }
|
||||
public string? Lang { get; set; }
|
||||
public int Uid { get; set; }
|
||||
public string? Token { get; set; }
|
||||
}
|
||||
17
Common/Data/Models/Dispatch/QueryDispatchModels.cs
Normal file
17
Common/Data/Models/Dispatch/QueryDispatchModels.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace KianaBH.Data.Models.Dispatch;
|
||||
|
||||
public class QueryDispatchResponse
|
||||
{
|
||||
public int Retcode { get; set; }
|
||||
public List<RegionInfo> RegionList { get; set; } = [];
|
||||
|
||||
|
||||
public class RegionInfo
|
||||
{
|
||||
public string? DispatchUrl { get; set; }
|
||||
public object? Ext { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int Retcode { get; set; }
|
||||
public string? Title { get; set; }
|
||||
}
|
||||
}
|
||||
30
Common/Data/Models/Dispatch/QueryGatewayModels.cs
Normal file
30
Common/Data/Models/Dispatch/QueryGatewayModels.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using KianaBH.Util.Extensions;
|
||||
using KianaBH.Configuration;
|
||||
|
||||
namespace KianaBH.Data.Models.Dispatch;
|
||||
|
||||
public class QueryGatewayResponse
|
||||
{
|
||||
public long ServerCurTime { get; set; } = Extensions.GetUnixSec();
|
||||
public int ServerCurTimezone { get; set; } = (int)TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).TotalHours;
|
||||
public string RegionName { get; set; } = "KianaBH";
|
||||
public string Msg { get; set; } = "";
|
||||
public bool IsDataReady { get; set; } = true;
|
||||
public int Retcode { get; set; }
|
||||
|
||||
public string? AccountUrl { get; set; }
|
||||
public ServerInfo? Gameserver { get; set; }
|
||||
public ServerInfo? Gateway { get; set; }
|
||||
public List<string> ExResourceUrlList { get; set; } = [];
|
||||
public List<string> ExAudioAndVideoUrlList { get; set; } = [];
|
||||
public List<string> AssetBundleUrlList { get; set; } = [];
|
||||
public HotfixManfiset? Manifest { get; set; }
|
||||
public Dictionary<string, object> Ext { get; set; } = new();
|
||||
|
||||
public class ServerInfo
|
||||
{
|
||||
public string? Ip { get; set; }
|
||||
public bool IsKcp { get; set; }
|
||||
public int Port { get; set; }
|
||||
}
|
||||
}
|
||||
34
Common/Data/Models/Sdk/ComboGranterModels.cs
Normal file
34
Common/Data/Models/Sdk/ComboGranterModels.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using KianaBH.Util.Extensions;
|
||||
|
||||
namespace KianaBH.Data.Models.Sdk;
|
||||
|
||||
public class ComboGranterData
|
||||
{
|
||||
public string? Uid { get; set; }
|
||||
public string? Token { get; set; }
|
||||
}
|
||||
|
||||
public class ComboGranterRequest
|
||||
{
|
||||
[Required]
|
||||
[JsonConverter(typeof(JsonStringToObjectConverter<ComboGranterData>))]
|
||||
public ComboGranterData? Data { get; set; }
|
||||
}
|
||||
|
||||
public class ComboGranterResponse : ResponseBase
|
||||
{
|
||||
public new ComboGranterResponseData? Data { get; set; }
|
||||
|
||||
public class ComboGranterResponseData
|
||||
{
|
||||
public uint AccountType { get; set; }
|
||||
public string? OpenId { get; set; }
|
||||
public string? ComboId { get; set; }
|
||||
public string? ComboToken { get; set; }
|
||||
public bool Heartbeat { get; set; }
|
||||
public string? Data { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
6
Common/Data/Models/Sdk/DeviceFingerprintController.cs
Normal file
6
Common/Data/Models/Sdk/DeviceFingerprintController.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace KianaBH.Data.Models.Sdk;
|
||||
public class GetDeviceFingerprintRequest
|
||||
{
|
||||
public string? DeviceFp { get; set; }
|
||||
}
|
||||
|
||||
20
Common/Data/Models/Sdk/GameWeatherModels.cs
Normal file
20
Common/Data/Models/Sdk/GameWeatherModels.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace KianaBH.Data.Models.Sdk;
|
||||
|
||||
public class GetWeatherResponse : ResponseBase
|
||||
{
|
||||
public new GetWeatherResponseData? Data { get; set; }
|
||||
|
||||
public class GetWeatherResponseData
|
||||
{
|
||||
public int Timezone { get; set; }
|
||||
public List<HourlyWeatherData> Hourly { get; set; } = [];
|
||||
|
||||
public class HourlyWeatherData
|
||||
{
|
||||
public int Condition { get; set; }
|
||||
public int Hour { get; set; }
|
||||
public string? Date { get; set; }
|
||||
public int Temp { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Common/Data/Models/Sdk/MdkShieldModels.cs
Normal file
42
Common/Data/Models/Sdk/MdkShieldModels.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace KianaBH.Data.Models.Sdk;
|
||||
|
||||
public class MdkShieldLoginRequest
|
||||
{
|
||||
public string? Account { get; set; }
|
||||
public string? Password { get; set; }
|
||||
public bool IsCrypto { get; set; }
|
||||
}
|
||||
|
||||
public class MdkShieldVerifyRequest
|
||||
{
|
||||
public string? Uid { get; set; }
|
||||
public string? Token { get; set; }
|
||||
}
|
||||
|
||||
// TODO: Move this to DB instead
|
||||
public class MdkShieldAccountData
|
||||
{
|
||||
public string? Token { get; set; }
|
||||
public string? Uid { get; set; }
|
||||
|
||||
public string Email { get; set; } = "";
|
||||
public string IsEmailVerify { get; set; } = "0";
|
||||
public string AreaCode { get; set; } = "";
|
||||
public string Country { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public string Realname { get; set; } = "";
|
||||
}
|
||||
|
||||
public class MdkShieldResponse : ResponseBase
|
||||
{
|
||||
public new MdkShieldResponseData? Data { get; set; }
|
||||
|
||||
public class MdkShieldResponseData
|
||||
{
|
||||
public MdkShieldAccountData? Account { get; set; }
|
||||
public bool DeviceGrantRequired { get; set; }
|
||||
public bool ReactiveRequired { get; set; }
|
||||
public bool RealpersonRequired { get; set; }
|
||||
public bool SafeMobileRequeired { get; set; }
|
||||
}
|
||||
}
|
||||
9
Common/Data/Models/Sdk/ResponseBase.cs
Normal file
9
Common/Data/Models/Sdk/ResponseBase.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace KianaBH.Data.Models.Sdk;
|
||||
|
||||
public class ResponseBase
|
||||
{
|
||||
public string Message { get; set; } = "OK";
|
||||
public bool Success { get; set; } = true;
|
||||
public int Retcode { get; set; }
|
||||
public object? Data { get; set; }
|
||||
}
|
||||
33
Common/Data/ResourceEntity.cs
Normal file
33
Common/Data/ResourceEntity.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace KianaBH.Data;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class ResourceEntity : Attribute
|
||||
{
|
||||
[Obsolete("No effect")]
|
||||
public ResourceEntity(string fileName, bool isCritical = false, bool isMultifile = false)
|
||||
{
|
||||
if (isMultifile)
|
||||
FileName = new List<string>(fileName.Split(','));
|
||||
else
|
||||
FileName = [fileName];
|
||||
IsCritical = isCritical;
|
||||
}
|
||||
|
||||
|
||||
public ResourceEntity(string fileName, bool isMultifile = false)
|
||||
{
|
||||
if (isMultifile)
|
||||
FileName = new List<string>(fileName.Split(','));
|
||||
else
|
||||
FileName = [fileName];
|
||||
}
|
||||
|
||||
public ResourceEntity(string fileName)
|
||||
{
|
||||
FileName = [fileName];
|
||||
}
|
||||
|
||||
public List<string> FileName { get; private set; }
|
||||
|
||||
[Obsolete("No effect")] public bool IsCritical { get; private set; } // deprecated
|
||||
}
|
||||
169
Common/Data/ResourceManager.cs
Normal file
169
Common/Data/ResourceManager.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using KianaBH.Internationalization;
|
||||
using KianaBH.Util;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace KianaBH.Data;
|
||||
|
||||
public class ResourceManager
|
||||
{
|
||||
public static Logger Logger { get; } = new("ResourceManager");
|
||||
public static bool IsLoaded { get; set; }
|
||||
|
||||
public static void LoadGameData()
|
||||
{
|
||||
LoadExcel();
|
||||
}
|
||||
|
||||
public static void LoadExcel()
|
||||
{
|
||||
var classes = Assembly.GetExecutingAssembly().GetTypes(); // Get all classes in the assembly
|
||||
List<ExcelResource> resList = [];
|
||||
|
||||
foreach (var cls in classes.Where(x => x.IsSubclassOf(typeof(ExcelResource))))
|
||||
{
|
||||
var res = LoadSingleExcelResource(cls);
|
||||
if (res != null) resList.AddRange(res);
|
||||
}
|
||||
|
||||
foreach (var cls in resList) cls.AfterAllDone();
|
||||
}
|
||||
|
||||
public static List<T>? LoadSingleExcel<T>(Type cls) where T : ExcelResource, new()
|
||||
{
|
||||
return LoadSingleExcelResource(cls) as List<T>;
|
||||
}
|
||||
|
||||
public static List<ExcelResource>? LoadSingleExcelResource(Type cls)
|
||||
{
|
||||
var attribute = (ResourceEntity?)Attribute.GetCustomAttribute(cls, typeof(ResourceEntity));
|
||||
|
||||
if (attribute == null) return null;
|
||||
var resource = (ExcelResource)Activator.CreateInstance(cls)!;
|
||||
var count = 0;
|
||||
List<ExcelResource> resList = [];
|
||||
foreach (var fileName in attribute.FileName)
|
||||
try
|
||||
{
|
||||
var path = ConfigManager.Config.Path.ResourcePath + "/ExcelOutput/" + fileName;
|
||||
var file = new FileInfo(path);
|
||||
if (!file.Exists)
|
||||
{
|
||||
Logger.Error(I18NManager.Translate("Server.ServerInfo.FailedToReadItem", fileName,
|
||||
I18NManager.Translate("Word.NotFound")));
|
||||
continue;
|
||||
}
|
||||
|
||||
var json = file.OpenText().ReadToEnd();
|
||||
using (var reader = new JsonTextReader(new StringReader(json)))
|
||||
{
|
||||
reader.Read();
|
||||
switch (reader.TokenType)
|
||||
{
|
||||
case JsonToken.StartArray:
|
||||
{
|
||||
// array
|
||||
var jArray = JArray.Parse(json);
|
||||
foreach (var item in jArray)
|
||||
{
|
||||
var res = JsonConvert.DeserializeObject(item.ToString(), cls);
|
||||
resList.Add((ExcelResource)res!);
|
||||
((ExcelResource?)res)?.Loaded();
|
||||
count++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case JsonToken.StartObject:
|
||||
{
|
||||
// dictionary
|
||||
var jObject = JObject.Parse(json);
|
||||
foreach (var (_, obj) in jObject)
|
||||
{
|
||||
var instance = JsonConvert.DeserializeObject(obj!.ToString(), cls);
|
||||
|
||||
if (((ExcelResource?)instance)?.GetId() == 0 || (ExcelResource?)instance == null)
|
||||
{
|
||||
// Deserialize as JObject to handle nested dictionaries
|
||||
var nestedObject = JsonConvert.DeserializeObject<JObject>(obj.ToString());
|
||||
|
||||
foreach (var nestedItem in nestedObject ?? [])
|
||||
{
|
||||
var nestedInstance =
|
||||
JsonConvert.DeserializeObject(nestedItem.Value!.ToString(), cls);
|
||||
resList.Add((ExcelResource)nestedInstance!);
|
||||
((ExcelResource?)nestedInstance)?.Loaded();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resList.Add((ExcelResource)instance);
|
||||
((ExcelResource)instance).Loaded();
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource.Finalized();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(
|
||||
I18NManager.Translate("Server.ServerInfo.FailedToReadItem", fileName,
|
||||
I18NManager.Translate("Word.Error")), ex);
|
||||
}
|
||||
|
||||
Logger.Info(I18NManager.Translate("Server.ServerInfo.LoadedItems", count.ToString(), cls.Name));
|
||||
|
||||
return resList;
|
||||
}
|
||||
|
||||
public static T? LoadCustomFile<T>(string filetype, string filename)
|
||||
{
|
||||
var type = I18NManager.Translate("Word." + filetype);
|
||||
Logger.Info(I18NManager.Translate("Server.ServerInfo.LoadingItem", type));
|
||||
FileInfo file = new(ConfigManager.Config.Path.DataPath + $"/{filename}.json");
|
||||
T? customFile = default;
|
||||
if (!file.Exists)
|
||||
{
|
||||
Logger.Warn(I18NManager.Translate("Server.ServerInfo.ConfigMissing", type,
|
||||
$"{ConfigManager.Config.Path.DataPath}/{filename}.json", type));
|
||||
return customFile;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var reader = file.OpenRead();
|
||||
using StreamReader reader2 = new(reader);
|
||||
var text = reader2.ReadToEnd();
|
||||
var json = JsonConvert.DeserializeObject<T>(text);
|
||||
customFile = json;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("Error in reading " + file.Name, ex);
|
||||
}
|
||||
|
||||
switch (customFile)
|
||||
{
|
||||
case Dictionary<int, int> d:
|
||||
Logger.Info(I18NManager.Translate("Server.ServerInfo.LoadedItems", d.Count.ToString(), type));
|
||||
break;
|
||||
case Dictionary<int, List<int>> di:
|
||||
Logger.Info(I18NManager.Translate("Server.ServerInfo.LoadedItems", di.Count.ToString(), type));
|
||||
break;
|
||||
default:
|
||||
Logger.Info(I18NManager.Translate("Server.ServerInfo.LoadedItem", filetype));
|
||||
break;
|
||||
}
|
||||
|
||||
return customFile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user