|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
| 6 | +using System.IO; |
| 7 | +using System.Xml.Linq; |
| 8 | +using ESPSharp.Enums; |
| 9 | +using ESPSharp.Enums.Flags; |
| 10 | +using ESPSharp.Interfaces; |
| 11 | +using ESPSharp.Subrecords; |
| 12 | +using ESPSharp.SubrecordCollections; |
| 13 | +using ESPSharp.DataTypes; |
| 14 | + |
| 15 | +namespace ESPSharp.Records |
| 16 | +{ |
| 17 | + public partial class Tree : Record, IEditorID { |
| 18 | + public SimpleSubrecord<String> EditorID { get; set; } |
| 19 | + public ObjectBounds ObjectBounds { get; set; } |
| 20 | + public Model Model { get; set; } |
| 21 | + public Icon Icon { get; set; } |
| 22 | + public SpeedtreeSeeds SpeedtreeSeeds { get; set; } |
| 23 | + public TreeData Data { get; set; } |
| 24 | + public BillboardDimensions BillboardDimensions { get; set; } |
| 25 | + |
| 26 | + public override void ReadData(ESPReader reader, long dataEnd) |
| 27 | + { |
| 28 | + while (reader.BaseStream.Position < dataEnd) |
| 29 | + { |
| 30 | + string subTag = reader.PeekTag(); |
| 31 | + |
| 32 | + switch (subTag) |
| 33 | + { |
| 34 | + case "EDID": |
| 35 | + if (EditorID == null) |
| 36 | + EditorID = new SimpleSubrecord<String>(); |
| 37 | + |
| 38 | + EditorID.ReadBinary(reader); |
| 39 | + break; |
| 40 | + case "OBND": |
| 41 | + if (ObjectBounds == null) |
| 42 | + ObjectBounds = new ObjectBounds(); |
| 43 | + |
| 44 | + ObjectBounds.ReadBinary(reader); |
| 45 | + break; |
| 46 | + case "MODL": |
| 47 | + if (Model == null) |
| 48 | + Model = new Model(); |
| 49 | + |
| 50 | + Model.ReadBinary(reader); |
| 51 | + break; |
| 52 | + case "ICON": |
| 53 | + if (Icon == null) |
| 54 | + Icon = new Icon(); |
| 55 | + |
| 56 | + Icon.ReadBinary(reader); |
| 57 | + break; |
| 58 | + case "SNAM": |
| 59 | + if (SpeedtreeSeeds == null) |
| 60 | + SpeedtreeSeeds = new SpeedtreeSeeds(); |
| 61 | + |
| 62 | + SpeedtreeSeeds.ReadBinary(reader); |
| 63 | + break; |
| 64 | + case "CNAM": |
| 65 | + if (Data == null) |
| 66 | + Data = new TreeData(); |
| 67 | + |
| 68 | + Data.ReadBinary(reader); |
| 69 | + break; |
| 70 | + case "BNAM": |
| 71 | + if (BillboardDimensions == null) |
| 72 | + BillboardDimensions = new BillboardDimensions(); |
| 73 | + |
| 74 | + BillboardDimensions.ReadBinary(reader); |
| 75 | + break; |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + public override void WriteData(ESPWriter writer) |
| 81 | + { |
| 82 | + if (EditorID != null) |
| 83 | + EditorID.WriteBinary(writer); |
| 84 | + if (ObjectBounds != null) |
| 85 | + ObjectBounds.WriteBinary(writer); |
| 86 | + if (Model != null) |
| 87 | + Model.WriteBinary(writer); |
| 88 | + if (Icon != null) |
| 89 | + Icon.WriteBinary(writer); |
| 90 | + if (SpeedtreeSeeds != null) |
| 91 | + SpeedtreeSeeds.WriteBinary(writer); |
| 92 | + if (Data != null) |
| 93 | + Data.WriteBinary(writer); |
| 94 | + if (BillboardDimensions != null) |
| 95 | + BillboardDimensions.WriteBinary(writer); |
| 96 | + } |
| 97 | + |
| 98 | + public override void WriteDataXML(XElement ele, ElderScrollsPlugin master) |
| 99 | + { |
| 100 | + XElement subEle; |
| 101 | + if (EditorID != null) |
| 102 | + { |
| 103 | + ele.TryPathTo("EditorID", true, out subEle); |
| 104 | + EditorID.WriteXML(subEle, master); |
| 105 | + } |
| 106 | + if (ObjectBounds != null) |
| 107 | + { |
| 108 | + ele.TryPathTo("ObjectBounds", true, out subEle); |
| 109 | + ObjectBounds.WriteXML(subEle, master); |
| 110 | + } |
| 111 | + if (Model != null) |
| 112 | + { |
| 113 | + ele.TryPathTo("Model", true, out subEle); |
| 114 | + Model.WriteXML(subEle, master); |
| 115 | + } |
| 116 | + if (Icon != null) |
| 117 | + { |
| 118 | + ele.TryPathTo("Icon", true, out subEle); |
| 119 | + Icon.WriteXML(subEle, master); |
| 120 | + } |
| 121 | + if (SpeedtreeSeeds != null) |
| 122 | + { |
| 123 | + ele.TryPathTo("SpeedtreeSeeds", true, out subEle); |
| 124 | + SpeedtreeSeeds.WriteXML(subEle, master); |
| 125 | + } |
| 126 | + if (Data != null) |
| 127 | + { |
| 128 | + ele.TryPathTo("Data", true, out subEle); |
| 129 | + Data.WriteXML(subEle, master); |
| 130 | + } |
| 131 | + if (BillboardDimensions != null) |
| 132 | + { |
| 133 | + ele.TryPathTo("BillboardDimensions", true, out subEle); |
| 134 | + BillboardDimensions.WriteXML(subEle, master); |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + public override void ReadDataXML(XElement ele, ElderScrollsPlugin master) |
| 139 | + { |
| 140 | + XElement subEle; |
| 141 | + |
| 142 | + if (ele.TryPathTo("EditorID", false, out subEle)) |
| 143 | + { |
| 144 | + if (EditorID == null) |
| 145 | + EditorID = new SimpleSubrecord<String>(); |
| 146 | + |
| 147 | + EditorID.ReadXML(subEle, master); |
| 148 | + } |
| 149 | + if (ele.TryPathTo("ObjectBounds", false, out subEle)) |
| 150 | + { |
| 151 | + if (ObjectBounds == null) |
| 152 | + ObjectBounds = new ObjectBounds(); |
| 153 | + |
| 154 | + ObjectBounds.ReadXML(subEle, master); |
| 155 | + } |
| 156 | + if (ele.TryPathTo("Model", false, out subEle)) |
| 157 | + { |
| 158 | + if (Model == null) |
| 159 | + Model = new Model(); |
| 160 | + |
| 161 | + Model.ReadXML(subEle, master); |
| 162 | + } |
| 163 | + if (ele.TryPathTo("Icon", false, out subEle)) |
| 164 | + { |
| 165 | + if (Icon == null) |
| 166 | + Icon = new Icon(); |
| 167 | + |
| 168 | + Icon.ReadXML(subEle, master); |
| 169 | + } |
| 170 | + if (ele.TryPathTo("SpeedtreeSeeds", false, out subEle)) |
| 171 | + { |
| 172 | + if (SpeedtreeSeeds == null) |
| 173 | + SpeedtreeSeeds = new SpeedtreeSeeds(); |
| 174 | + |
| 175 | + SpeedtreeSeeds.ReadXML(subEle, master); |
| 176 | + } |
| 177 | + if (ele.TryPathTo("Data", false, out subEle)) |
| 178 | + { |
| 179 | + if (Data == null) |
| 180 | + Data = new TreeData(); |
| 181 | + |
| 182 | + Data.ReadXML(subEle, master); |
| 183 | + } |
| 184 | + if (ele.TryPathTo("BillboardDimensions", false, out subEle)) |
| 185 | + { |
| 186 | + if (BillboardDimensions == null) |
| 187 | + BillboardDimensions = new BillboardDimensions(); |
| 188 | + |
| 189 | + BillboardDimensions.ReadXML(subEle, master); |
| 190 | + } |
| 191 | + } |
| 192 | + |
| 193 | + } |
| 194 | +} |
0 commit comments