Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Maple2.File.Parser/Maple2.File.Parser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageTags>MapleStory2, File, Parser, m2d, xml</PackageTags>
<!-- Use following lines to write the generated files to disk. -->
<EmitCompilerGeneratedFiles Condition=" '$(Configuration)' == 'Debug' ">true</EmitCompilerGeneratedFiles>
<PackageVersion>2.4.23</PackageVersion>
<PackageVersion>2.4.24</PackageVersion>
<TargetFramework>net8.0</TargetFramework>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
24 changes: 24 additions & 0 deletions Maple2.File.Parser/TableParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public class TableParser {
private readonly XmlSerializer maidRecipeSerializer;
private readonly XmlSerializer maidRecipeGroupSerializer;
private readonly XmlSerializer maidSalarySerializer;
private readonly XmlSerializer reactorSerializer;
private readonly XmlSerializer reactorStateSerializer;

private readonly string locale;
private readonly string language;
Expand Down Expand Up @@ -240,6 +242,8 @@ public TableParser(M2dReader xmlReader, string language) {
maidRecipeSerializer = new XmlSerializer(typeof(MaidRecipeRoot));
maidRecipeGroupSerializer = new XmlSerializer(typeof(MaidRecipeGroupRoot));
maidSalarySerializer = new XmlSerializer(typeof(MaidSalaryRoot));
reactorSerializer = new XmlSerializer(typeof(ReactorRoot));
reactorStateSerializer = new XmlSerializer(typeof(ReactorStateRoot));

locale = FeatureLocaleFilter.Locale.ToLower();
this.language = language;
Expand Down Expand Up @@ -1824,4 +1828,24 @@ public IEnumerable<JobTableNew> ParseJobTableNew() {
yield return (entry.id, entry);
}
}

public IEnumerable<(int Id, Reactor Reactor)> ParseReactor() {
XmlReader reader = xmlReader.GetXmlReader(xmlReader.GetEntry("table/reactor.xml"));
var data = reactorSerializer.Deserialize(reader) as ReactorRoot;
Debug.Assert(data != null);

foreach (Reactor reactor in data.reactor) {
yield return (reactor.id, reactor);
}
}

public IEnumerable<(int Id, ReactorState State)> ParseReactorState() {
XmlReader reader = xmlReader.GetXmlReader(xmlReader.GetEntry("table/reactorstate.xml"));
var data = reactorStateSerializer.Deserialize(reader) as ReactorStateRoot;
Debug.Assert(data != null);

foreach (ReactorState state in data.reactorState) {
yield return (state.id, state);
}
}
}
29 changes: 29 additions & 0 deletions Maple2.File.Parser/Xml/Table/Reactor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Xml.Serialization;
using M2dXmlGenerator;

namespace Maple2.File.Parser.Xml.Table;

// ./data/xml/table/reactor.xml
[XmlRoot("ms2")]
public partial class ReactorRoot {
[M2dFeatureLocale(Selector = "id")] private IList<Reactor> _reactor;
}

public partial class Reactor : IFeatureLocale {
[XmlAttribute] public int id;
[XmlAttribute] public float reactDistance;
// Bracket-wrapped comma list, e.g. "[100, 101, 102, 103]". Consumers strip
// the surrounding [] and split on ','; M2dArray cannot parse it directly
// because int.Parse would choke on the leading '[' / trailing ']' tokens.
[XmlAttribute] public string reactorStateList = string.Empty;
[XmlAttribute] public string connectedEffect = string.Empty;
// gameEventId links this reactor definition to a GameEvent whose eventType is
// "reactor" (GMS2 client RE: reactor+0x70 read by CReactor_CheckReactorGameEvent).
[XmlAttribute] public int gameEventId;
// Escaped XML fragment: <items><v itemID="..." grade="..." count="..." /></items>.
// Consumers deserialize this separately if they need the reward item list.
[XmlAttribute] public string rewardItemListXml = string.Empty;
[XmlAttribute] public int reactTimeMSec = 15000;
[XmlAttribute] public string reactAnimation = string.Empty;
[XmlAttribute] public string createAnimation = string.Empty;
}
29 changes: 29 additions & 0 deletions Maple2.File.Parser/Xml/Table/ReactorState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Xml.Serialization;

namespace Maple2.File.Parser.Xml.Table;

// ./data/xml/table/reactorstate.xml
[XmlRoot("ms2")]
public class ReactorStateRoot {
[XmlElement] public List<ReactorState> reactorState;
}

public class ReactorState {
[XmlAttribute] public int id;
// Observed values: connect, sleep, reward.
[XmlAttribute] public string type = string.Empty;
[XmlAttribute] public int nextTimeSec;
[XmlAttribute] public int expireTimeSec;
[XmlAttribute] public string kfmName = string.Empty;
[XmlAttribute] public string startAni = string.Empty;
[XmlAttribute] public string idleAni = string.Empty;
[XmlAttribute] public string actionStringKey = string.Empty;

// Only present on states of type="connect"; absent (self-closing tag) on other states.
[XmlElement] public CondItem condItem;

public class CondItem {
[XmlAttribute] public int code;
[XmlAttribute] public int consume;
}
}
14 changes: 14 additions & 0 deletions Maple2.File.Tests/TableParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -888,4 +888,18 @@ public void TestMaid() {
continue;
}
}

[TestMethod]
public void TestReactor() {
foreach ((_, _) in _parser.ParseReactor()) {
continue;
}
}

[TestMethod]
public void TestReactorState() {
foreach ((_, _) in _parser.ParseReactorState()) {
continue;
}
}
}
Loading