Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
VersionConverter121To122.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
3using XmlUtilities;
4
5namespace Game {
7 public override string SourceVersion => "1.21";
8
9 public override string TargetVersion => "1.22";
10
11 public override void ConvertProjectXml(XElement projectNode) {
12 XmlUtils.SetAttributeValue(projectNode, "Version", TargetVersion);
13 foreach (XElement item in projectNode.Element("Subsystems").Elements()) {
14 foreach (XElement item2 in from e in item.Elements("Values")
15 where XmlUtils.GetAttributeValue(e, "Name", string.Empty) == "CreatureSpawn"
16 select e) {
17 XmlUtils.SetAttributeValue(item2, "Name", "Spawn");
18 foreach (XElement item3 in from e in item2.Elements("Value")
19 where XmlUtils.GetAttributeValue(e, "Name", string.Empty) == "CreaturesData"
20 select e) {
21 XmlUtils.SetAttributeValue(item3, "Name", "SpawnsData");
22 }
23 foreach (XElement item4 in from e in item2.Elements("Value")
24 where XmlUtils.GetAttributeValue(e, "Name", string.Empty) == "CreaturesGenerated"
25 select e) {
26 XmlUtils.SetAttributeValue(item4, "Name", "IsSpawned");
27 }
28 }
29 }
30 }
31
32 public override void ConvertWorld(string directoryName) {
33 string path = Storage.CombinePaths(directoryName, "Project.xml");
34 XElement xElement;
35 using (Stream stream = Storage.OpenFile(path, OpenFileMode.Read)) {
36 xElement = XmlUtils.LoadXmlFromStream(stream, null, true);
37 }
38 ConvertProjectXml(xElement);
39 using (Stream stream2 = Storage.OpenFile(path, OpenFileMode.Create)) {
40 XmlUtils.SaveXmlToStream(xElement, stream2, null, true);
41 }
42 }
43 }
44}
static Stream OpenFile(string path, OpenFileMode openFileMode)
static string CombinePaths(params string[] paths)
override void ConvertWorld(string directoryName)
override void ConvertProjectXml(XElement projectNode)
static void SetAttributeValue(XElement node, string attributeName, object value)
static object GetAttributeValue(XElement node, string attributeName, Type type)
static XElement LoadXmlFromStream(Stream stream, Encoding encoding, bool throwOnError)
static void SaveXmlToStream(XElement node, Stream stream, Encoding encoding, bool throwOnError)