diff --git a/Maple2.File.Generator/XmlFeatureLocaleGenerator.cs b/Maple2.File.Generator/XmlFeatureLocaleGenerator.cs index c31fec7..1cb6a47 100644 --- a/Maple2.File.Generator/XmlFeatureLocaleGenerator.cs +++ b/Maple2.File.Generator/XmlFeatureLocaleGenerator.cs @@ -77,11 +77,16 @@ private string ProcessTypeField(GeneratorExecutionContext context, IFieldSymbol return string.Empty; } + string keywordName = propertyName; + if (keywordName == "event") { + keywordName = "@" + keywordName; + } + string type = field.Type.ToDisplayString(); return $@" private List<{type}> {field.Name}_; -public {type} {propertyName} => {field.Name}_.ResolveFeatureLocale(); +public {type} {keywordName} => {field.Name}_.ResolveFeatureLocale(); [XmlElement(""{propertyName}"")] public List<{type}> _{field.Name} {{ @@ -98,6 +103,11 @@ private string ProcessListField(GeneratorExecutionContext context, IFieldSymbol return string.Empty; } + string keywordName = propertyName; + if (keywordName == "event") { + keywordName = "@" + keywordName; + } + string type = field.Type.ToDisplayString(); string concreteList = type.Replace("IList", "List"); @@ -117,7 +127,7 @@ private string ProcessListField(GeneratorExecutionContext context, IFieldSymbol return $@" private {concreteList} {field.Name}_; -public {type} {propertyName} => {field.Name}_.{resolver}({groupBy.ToString()}).ToList(); +public {type} {keywordName} => {field.Name}_.{resolver}({groupBy.ToString()}).ToList(); [XmlElement(""{propertyName}"")] public {concreteList} _{field.Name} {{ diff --git a/Maple2.File.Parser/Enum/TimeEventType.cs b/Maple2.File.Parser/Enum/TimeEventType.cs new file mode 100644 index 0000000..b6ba50a --- /dev/null +++ b/Maple2.File.Parser/Enum/TimeEventType.cs @@ -0,0 +1,11 @@ +namespace Maple2.File.Parser.Enum; + +public enum TimeEventType { + Boss = 1, + HiddenRealmPortal = 2, + Unknown3 = 3, + FieldInteractObject = 4, // balloons, chest, etc. + GlobalEvent = 5, + KritiasChestPuzzle = 6, + KritiasInvasion = 7, +} diff --git a/Maple2.File.Parser/Maple2.File.Parser.csproj b/Maple2.File.Parser/Maple2.File.Parser.csproj index 76d44f4..0ca034b 100644 --- a/Maple2.File.Parser/Maple2.File.Parser.csproj +++ b/Maple2.File.Parser/Maple2.File.Parser.csproj @@ -13,7 +13,7 @@ MapleStory2, File, Parser, m2d, xml true - 2.1.18 + 2.1.19 net8.0 README.md enable diff --git a/Maple2.File.Parser/ServerTableParser.cs b/Maple2.File.Parser/ServerTableParser.cs index 0f7e04a..8c13838 100644 --- a/Maple2.File.Parser/ServerTableParser.cs +++ b/Maple2.File.Parser/ServerTableParser.cs @@ -37,6 +37,7 @@ public class ServerTableParser { private readonly XmlSerializer fishBoxSerializer; private readonly XmlSerializer adventureIdExpTableSerializer; private readonly XmlSerializer adventureExpTableSerializer; + private readonly XmlSerializer timeEventDataSerializer; public ServerTableParser(M2dReader xmlReader) { this.xmlReader = xmlReader; @@ -67,6 +68,7 @@ public ServerTableParser(M2dReader xmlReader) { fishBoxSerializer = new XmlSerializer(typeof(FishBoxRoot)); adventureIdExpTableSerializer = new XmlSerializer(typeof(AdventureIdExpTableRoot)); adventureExpTableSerializer = new XmlSerializer(typeof(AdventureExpTableRoot)); + timeEventDataSerializer = new XmlSerializer(typeof(TimeEventDataRoot)); // var seen = new HashSet(); // this.bankTypeSerializer.UnknownAttribute += (sender, args) => { @@ -527,4 +529,15 @@ public ServerTableParser(M2dReader xmlReader) { yield return (exp.type, exp); } } + + public IEnumerable<(int Id, TimeEventData Data)> ParseTimeEventData() { + string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry("table/Server/timeEventData.xml"))); + var reader = XmlReader.Create(new StringReader(xml)); + var data = timeEventDataSerializer.Deserialize(reader) as TimeEventDataRoot; + Debug.Assert(data != null); + + foreach (TimeEventData entry in data.@event) { + yield return (entry.id, entry); + } + } } diff --git a/Maple2.File.Parser/Xml/Common/Condition.cs b/Maple2.File.Parser/Xml/Common/Condition.cs index 9237289..452a7e0 100644 --- a/Maple2.File.Parser/Xml/Common/Condition.cs +++ b/Maple2.File.Parser/Xml/Common/Condition.cs @@ -7,7 +7,7 @@ namespace Maple2.File.Parser.Xml.Common; [XmlType(Namespace = "Common")] public partial class Condition { [M2dEnum] public ConditionType type = ConditionType.unknown; - [XmlAttribute] public long value; + [XmlAttribute] public long value = 1; [M2dArray] public string[] code = Array.Empty(); // split on ',' and '-' [M2dArray] public string[] target = Array.Empty(); // split on ',' and ':' [XmlAttribute] public int partyCount; diff --git a/Maple2.File.Parser/Xml/Table/Server/SpawnInteractObject.cs b/Maple2.File.Parser/Xml/Table/Server/SpawnInteractObject.cs index eb2a1da..5c0638b 100644 --- a/Maple2.File.Parser/Xml/Table/Server/SpawnInteractObject.cs +++ b/Maple2.File.Parser/Xml/Table/Server/SpawnInteractObject.cs @@ -20,4 +20,5 @@ public partial class SpawnInteractObject : IFeatureLocale { [XmlAttribute] public string normal = string.Empty; [XmlAttribute] public string reactable = string.Empty; [XmlAttribute] public float scale; + [XmlAttribute] public bool isKeepAnimate; } diff --git a/Maple2.File.Parser/Xml/Table/Server/TimeEventData.cs b/Maple2.File.Parser/Xml/Table/Server/TimeEventData.cs new file mode 100644 index 0000000..3ca46e9 --- /dev/null +++ b/Maple2.File.Parser/Xml/Table/Server/TimeEventData.cs @@ -0,0 +1,59 @@ +using System.Xml.Serialization; +using M2dXmlGenerator; +using Maple2.File.Parser.Enum; + +namespace Maple2.File.Parser.Xml.Table.Server; + +// ./data/server/table/Server/timeEventData.xml +[XmlRoot("ms2")] +public partial class TimeEventDataRoot { + [M2dFeatureLocale(Selector = "id")] private IList _event; +} + +public partial class TimeEventData : IFeatureLocale { + [XmlAttribute] public int id; + [M2dEnum] public TimeEventType type = TimeEventType.Boss; + [XmlAttribute] public int prob; + [XmlAttribute] public string startTime = "2014-1-1-00-05-00"; + [XmlAttribute] public string endTime = "2099-12-31-12-00-00"; + [XmlAttribute] public string cycleTime = string.Empty; + [XmlAttribute] public string randomTime = string.Empty; + [XmlAttribute] public string lifeTime = string.Empty; + [XmlAttribute] public bool individualChannelSpawn; + [XmlAttribute] public bool screenNotice; + [XmlAttribute] public bool chatNotice; + [XmlAttribute] public float variableCountByChannelCount; + [M2dArray] public int[] targetFields = Array.Empty(); + [XmlAttribute] public bool noticeMap; + [M2dArray] public int[] targetSpawnPointIDs = Array.Empty(); + [XmlAttribute] public int tag; + [M2dArray] public string[] targetSpawnTags = Array.Empty(); + [M2dArray] public int[] npcIDs = Array.Empty(); + [XmlAttribute] public bool lifeTimeText1; + [XmlAttribute] public bool unique; + [XmlAttribute] public int roomID; + [XmlAttribute] public int roomCount; + [XmlAttribute] public int interactCount; + [XmlAttribute] public int interactID; + [XmlAttribute] public bool keepAnimate; + [XmlAttribute] public string interactModel = string.Empty; + [XmlAttribute] public string interactAsset = string.Empty; + [XmlAttribute] public string interactNormal = string.Empty; + [XmlAttribute] public string interactReactable = string.Empty; + [XmlAttribute] public string popupMessage = string.Empty; + [XmlAttribute] public string soundID = string.Empty; + [XmlAttribute] public string eventName1 = string.Empty; + [XmlAttribute] public string eventName2 = string.Empty; + [XmlAttribute] public string eventName3 = string.Empty; + [M2dArray] public int[] eventField1 = Array.Empty(); + [M2dArray] public int[] eventField2 = Array.Empty(); + [M2dArray] public int[] eventField3 = Array.Empty(); + [XmlAttribute] public int triggerID; + [XmlAttribute] public string key = string.Empty; + [XmlAttribute] public int value; + [XmlAttribute] public int fieldWarGroupID; + [XmlAttribute] public int eventDurationStartHour; + [XmlAttribute] public int eventDurationEndHour; + [XmlAttribute] public int eventDurationStartMin; + [XmlAttribute] public int eventDurationEndMin; +} diff --git a/Maple2.File.Tests/ServerTableParserTest.cs b/Maple2.File.Tests/ServerTableParserTest.cs index a54a5d3..ecec84a 100644 --- a/Maple2.File.Tests/ServerTableParserTest.cs +++ b/Maple2.File.Tests/ServerTableParserTest.cs @@ -327,4 +327,14 @@ public void TestAdventureExp() { continue; } } + + [TestMethod] + public void TestTimeEventData() { + var parser = new ServerTableParser(TestUtils.ServerReader); + + var timedEventData = parser.ParseTimeEventData(); + foreach ((_, _) in parser.ParseTimeEventData()) { + continue; + } + } }