mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-07-15 14:21:24 +08:00
Fix for Bounds XML not exporting null composite children
This commit is contained in:
parent
70ebdd8360
commit
a6a2acab75
|
@ -100,6 +100,7 @@ namespace CodeWalker.GameFiles
|
||||||
|
|
||||||
public enum BoundsType : byte
|
public enum BoundsType : byte
|
||||||
{
|
{
|
||||||
|
None = 255, //not contained in files, but used as a placeholder in XML conversion
|
||||||
Sphere = 0,
|
Sphere = 0,
|
||||||
Capsule = 1,
|
Capsule = 1,
|
||||||
Box = 3,
|
Box = 3,
|
||||||
|
@ -466,11 +467,17 @@ namespace CodeWalker.GameFiles
|
||||||
}
|
}
|
||||||
public static void WriteXmlNode(Bounds b, StringBuilder sb, int indent, string name = "Bounds")
|
public static void WriteXmlNode(Bounds b, StringBuilder sb, int indent, string name = "Bounds")
|
||||||
{
|
{
|
||||||
if (b == null) return;
|
if (b == null)
|
||||||
|
{
|
||||||
|
YbnXml.SelfClosingTag(sb, indent, "Item type=\"" + BoundsType.None.ToString() + "\"");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
YbnXml.OpenTag(sb, indent, name + " type=\"" + b.Type.ToString() + "\"");
|
YbnXml.OpenTag(sb, indent, name + " type=\"" + b.Type.ToString() + "\"");
|
||||||
b.WriteXml(sb, indent + 1);
|
b.WriteXml(sb, indent + 1);
|
||||||
YbnXml.CloseTag(sb, indent, name);
|
YbnXml.CloseTag(sb, indent, name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static Bounds ReadXmlNode(XmlNode node, object owner = null, BoundComposite parent = null)
|
public static Bounds ReadXmlNode(XmlNode node, object owner = null, BoundComposite parent = null)
|
||||||
{
|
{
|
||||||
if (node == null) return null;
|
if (node == null) return null;
|
||||||
|
@ -498,6 +505,7 @@ namespace CodeWalker.GameFiles
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
case BoundsType.None: return null;
|
||||||
case BoundsType.Sphere: return new BoundSphere();
|
case BoundsType.Sphere: return new BoundSphere();
|
||||||
case BoundsType.Capsule: return new BoundCapsule();
|
case BoundsType.Capsule: return new BoundCapsule();
|
||||||
case BoundsType.Box: return new BoundBox();
|
case BoundsType.Box: return new BoundBox();
|
||||||
|
@ -2656,16 +2664,9 @@ namespace CodeWalker.GameFiles
|
||||||
var cind = indent + 1;
|
var cind = indent + 1;
|
||||||
YbnXml.OpenTag(sb, indent, "Children");
|
YbnXml.OpenTag(sb, indent, "Children");
|
||||||
foreach (var child in c)
|
foreach (var child in c)
|
||||||
{
|
|
||||||
if (c == null)
|
|
||||||
{
|
|
||||||
YbnXml.SelfClosingTag(sb, cind, "Item");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Bounds.WriteXmlNode(child, sb, cind, "Item");
|
Bounds.WriteXmlNode(child, sb, cind, "Item");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
YbnXml.CloseTag(sb, indent, "Children");
|
YbnXml.CloseTag(sb, indent, "Children");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2681,17 +2682,10 @@ namespace CodeWalker.GameFiles
|
||||||
{
|
{
|
||||||
var blist = new List<Bounds>();
|
var blist = new List<Bounds>();
|
||||||
foreach (XmlNode inode in cnodes)
|
foreach (XmlNode inode in cnodes)
|
||||||
{
|
|
||||||
if (inode.HasChildNodes)
|
|
||||||
{
|
{
|
||||||
var b = Bounds.ReadXmlNode(inode, Owner, this);
|
var b = Bounds.ReadXmlNode(inode, Owner, this);
|
||||||
blist.Add(b);
|
blist.Add(b);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
blist.Add(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var arr = blist.ToArray();
|
var arr = blist.ToArray();
|
||||||
Children = new ResourcePointerArray64<Bounds>();
|
Children = new ResourcePointerArray64<Bounds>();
|
||||||
Children.data_items = arr;
|
Children.data_items = arr;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user