Skip to content

Commit 4077787

Browse files
committed
Finished implementing Quest
Fixed wrong Tag on RegionDataEntry
1 parent 40edfd4 commit 4077787

10 files changed

Lines changed: 753 additions & 3 deletions

File tree

ESPSharp/ESPSharp.csproj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@
439439
<DesignTime>True</DesignTime>
440440
<DependentUpon>Projectile.tt</DependentUpon>
441441
</Compile>
442+
<Compile Include="Records\GeneratedCode\Quest.cs">
443+
<AutoGen>True</AutoGen>
444+
<DesignTime>True</DesignTime>
445+
<DependentUpon>Quest.tt</DependentUpon>
446+
</Compile>
442447
<Compile Include="Records\GeneratedCode\Race.cs">
443448
<AutoGen>True</AutoGen>
444449
<DesignTime>True</DesignTime>
@@ -516,6 +521,11 @@
516521
<DesignTime>True</DesignTime>
517522
<DependentUpon>BodyModel.tt</DependentUpon>
518523
</Compile>
524+
<Compile Include="SubrecordCollections\GeneratedCode\QuestStage.cs">
525+
<AutoGen>True</AutoGen>
526+
<DesignTime>True</DesignTime>
527+
<DependentUpon>QuestStage.tt</DependentUpon>
528+
</Compile>
519529
<Compile Include="SubrecordCollections\GeneratedCode\RegionArea.cs">
520530
<AutoGen>True</AutoGen>
521531
<DesignTime>True</DesignTime>
@@ -779,6 +789,10 @@
779789
<Generator>TextTemplatingFileGenerator</Generator>
780790
<LastGenOutput>Projectile.cs</LastGenOutput>
781791
</None>
792+
<None Include="Records\GeneratedCode\Quest.tt">
793+
<Generator>TextTemplatingFileGenerator</Generator>
794+
<LastGenOutput>Quest.cs</LastGenOutput>
795+
</None>
782796
<None Include="Records\GeneratedCode\Race.tt">
783797
<Generator>TextTemplatingFileGenerator</Generator>
784798
<LastGenOutput>Race.cs</LastGenOutput>
@@ -823,6 +837,10 @@
823837
<Generator>TextTemplatingFileGenerator</Generator>
824838
<LastGenOutput>Weather.cs</LastGenOutput>
825839
</None>
840+
<None Include="SubrecordCollections\GeneratedCode\QuestStage.tt">
841+
<Generator>TextTemplatingFileGenerator</Generator>
842+
<LastGenOutput>QuestStage.cs</LastGenOutput>
843+
</None>
826844
<None Include="SubrecordCollections\GeneratedCode\RegionArea.tt">
827845
<Generator>TextTemplatingFileGenerator</Generator>
828846
<LastGenOutput>RegionArea.cs</LastGenOutput>
@@ -1136,6 +1154,11 @@
11361154
<DesignTime>True</DesignTime>
11371155
<DependentUpon>ProjectileData.tt</DependentUpon>
11381156
</Compile>
1157+
<Compile Include="Subrecords\GeneratedCode\QuestData.cs">
1158+
<AutoGen>True</AutoGen>
1159+
<DesignTime>True</DesignTime>
1160+
<DependentUpon>QuestData.tt</DependentUpon>
1161+
</Compile>
11391162
<Compile Include="Subrecords\GeneratedCode\QuestTargetData.cs">
11401163
<AutoGen>True</AutoGen>
11411164
<DesignTime>True</DesignTime>
@@ -1386,6 +1409,10 @@
13861409
<Generator>TextTemplatingFileGenerator</Generator>
13871410
<LastGenOutput>ProjectileData.cs</LastGenOutput>
13881411
</None>
1412+
<None Include="Subrecords\GeneratedCode\QuestData.tt">
1413+
<Generator>TextTemplatingFileGenerator</Generator>
1414+
<LastGenOutput>QuestData.cs</LastGenOutput>
1415+
</None>
13891416
<None Include="Subrecords\GeneratedCode\RegionDataHeader.tt">
13901417
<Generator>TextTemplatingFileGenerator</Generator>
13911418
<LastGenOutput>RegionDataHeader.cs</LastGenOutput>

ESPSharp/Record.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ public static Record CreateRecord(string Tag)
358358
case "REGN":
359359
outRecord = new Region();
360360
break;
361+
case "DIAL":
362+
outRecord = new DialogTopic();
363+
break;
364+
case "QUST":
365+
outRecord = new Quest();
366+
break;
361367
default:
362368
outRecord = new GenericRecord();
363369
break;
Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
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 Quest : Record, IEditorID {
18+
public SimpleSubrecord<String> EditorID { get; set; }
19+
public RecordReference Script { get; set; }
20+
public SimpleSubrecord<String> Name { get; set; }
21+
public SimpleSubrecord<String> LargeIcon { get; set; }
22+
public SimpleSubrecord<String> SmallIcon { get; set; }
23+
public QuestData Data { get; set; }
24+
public List<Condition> Conditions { get; set; }
25+
public List<QuestStage> Stages { get; set; }
26+
public List<QuestObjective> Objectives { get; set; }
27+
28+
public override void ReadData(ESPReader reader, long dataEnd)
29+
{
30+
while (reader.BaseStream.Position < dataEnd)
31+
{
32+
string subTag = reader.PeekTag();
33+
34+
switch (subTag)
35+
{
36+
case "EDID":
37+
if (EditorID == null)
38+
EditorID = new SimpleSubrecord<String>();
39+
40+
EditorID.ReadBinary(reader);
41+
break;
42+
case "SCRI":
43+
if (Script == null)
44+
Script = new RecordReference();
45+
46+
Script.ReadBinary(reader);
47+
break;
48+
case "FULL":
49+
if (Name == null)
50+
Name = new SimpleSubrecord<String>();
51+
52+
Name.ReadBinary(reader);
53+
break;
54+
case "ICON":
55+
if (LargeIcon == null)
56+
LargeIcon = new SimpleSubrecord<String>();
57+
58+
LargeIcon.ReadBinary(reader);
59+
break;
60+
case "MICO":
61+
if (SmallIcon == null)
62+
SmallIcon = new SimpleSubrecord<String>();
63+
64+
SmallIcon.ReadBinary(reader);
65+
break;
66+
case "DATA":
67+
if (Data == null)
68+
Data = new QuestData();
69+
70+
Data.ReadBinary(reader);
71+
break;
72+
case "CTDA":
73+
if (Conditions == null)
74+
Conditions = new List<Condition>();
75+
76+
Condition tempCTDA = new Condition();
77+
tempCTDA.ReadBinary(reader);
78+
Conditions.Add(tempCTDA);
79+
break;
80+
case "INDX":
81+
if (Stages == null)
82+
Stages = new List<QuestStage>();
83+
84+
QuestStage tempINDX = new QuestStage();
85+
tempINDX.ReadBinary(reader);
86+
Stages.Add(tempINDX);
87+
break;
88+
case "QOBJ":
89+
if (Objectives == null)
90+
Objectives = new List<QuestObjective>();
91+
92+
QuestObjective tempQOBJ = new QuestObjective();
93+
tempQOBJ.ReadBinary(reader);
94+
Objectives.Add(tempQOBJ);
95+
break;
96+
default:
97+
throw new Exception();
98+
}
99+
}
100+
}
101+
102+
public override void WriteData(ESPWriter writer)
103+
{
104+
if (EditorID != null)
105+
EditorID.WriteBinary(writer);
106+
if (Script != null)
107+
Script.WriteBinary(writer);
108+
if (Name != null)
109+
Name.WriteBinary(writer);
110+
if (LargeIcon != null)
111+
LargeIcon.WriteBinary(writer);
112+
if (SmallIcon != null)
113+
SmallIcon.WriteBinary(writer);
114+
if (Data != null)
115+
Data.WriteBinary(writer);
116+
if (Conditions != null)
117+
foreach (var item in Conditions)
118+
item.WriteBinary(writer);
119+
if (Stages != null)
120+
foreach (var item in Stages)
121+
item.WriteBinary(writer);
122+
if (Objectives != null)
123+
foreach (var item in Objectives)
124+
item.WriteBinary(writer);
125+
}
126+
127+
public override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
128+
{
129+
XElement subEle;
130+
if (EditorID != null)
131+
{
132+
ele.TryPathTo("EditorID", true, out subEle);
133+
EditorID.WriteXML(subEle, master);
134+
}
135+
if (Script != null)
136+
{
137+
ele.TryPathTo("Script", true, out subEle);
138+
Script.WriteXML(subEle, master);
139+
}
140+
if (Name != null)
141+
{
142+
ele.TryPathTo("Name", true, out subEle);
143+
Name.WriteXML(subEle, master);
144+
}
145+
if (LargeIcon != null)
146+
{
147+
ele.TryPathTo("Icon/Large", true, out subEle);
148+
LargeIcon.WriteXML(subEle, master);
149+
}
150+
if (SmallIcon != null)
151+
{
152+
ele.TryPathTo("Icon/Small", true, out subEle);
153+
SmallIcon.WriteXML(subEle, master);
154+
}
155+
if (Data != null)
156+
{
157+
ele.TryPathTo("Data", true, out subEle);
158+
Data.WriteXML(subEle, master);
159+
}
160+
if (Conditions != null)
161+
{
162+
ele.TryPathTo("Conditions", true, out subEle);
163+
List<string> xmlNames = new List<string>{"Condition"};
164+
int i = 0;
165+
foreach (var entry in Conditions)
166+
{
167+
i = i % xmlNames.Count();
168+
XElement newEle = new XElement(xmlNames[i]);
169+
entry.WriteXML(newEle, master);
170+
subEle.Add(newEle);
171+
i++;
172+
}
173+
}
174+
if (Stages != null)
175+
{
176+
ele.TryPathTo("Stages", true, out subEle);
177+
List<string> xmlNames = new List<string>{"Stage"};
178+
int i = 0;
179+
foreach (var entry in Stages)
180+
{
181+
i = i % xmlNames.Count();
182+
XElement newEle = new XElement(xmlNames[i]);
183+
entry.WriteXML(newEle, master);
184+
subEle.Add(newEle);
185+
i++;
186+
}
187+
}
188+
if (Objectives != null)
189+
{
190+
ele.TryPathTo("Objectives", true, out subEle);
191+
List<string> xmlNames = new List<string>{"Objective"};
192+
int i = 0;
193+
foreach (var entry in Objectives)
194+
{
195+
i = i % xmlNames.Count();
196+
XElement newEle = new XElement(xmlNames[i]);
197+
entry.WriteXML(newEle, master);
198+
subEle.Add(newEle);
199+
i++;
200+
}
201+
}
202+
}
203+
204+
public override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
205+
{
206+
XElement subEle;
207+
208+
if (ele.TryPathTo("EditorID", false, out subEle))
209+
{
210+
if (EditorID == null)
211+
EditorID = new SimpleSubrecord<String>();
212+
213+
EditorID.ReadXML(subEle, master);
214+
}
215+
if (ele.TryPathTo("Script", false, out subEle))
216+
{
217+
if (Script == null)
218+
Script = new RecordReference();
219+
220+
Script.ReadXML(subEle, master);
221+
}
222+
if (ele.TryPathTo("Name", false, out subEle))
223+
{
224+
if (Name == null)
225+
Name = new SimpleSubrecord<String>();
226+
227+
Name.ReadXML(subEle, master);
228+
}
229+
if (ele.TryPathTo("Icon/Large", false, out subEle))
230+
{
231+
if (LargeIcon == null)
232+
LargeIcon = new SimpleSubrecord<String>();
233+
234+
LargeIcon.ReadXML(subEle, master);
235+
}
236+
if (ele.TryPathTo("Icon/Small", false, out subEle))
237+
{
238+
if (SmallIcon == null)
239+
SmallIcon = new SimpleSubrecord<String>();
240+
241+
SmallIcon.ReadXML(subEle, master);
242+
}
243+
if (ele.TryPathTo("Data", false, out subEle))
244+
{
245+
if (Data == null)
246+
Data = new QuestData();
247+
248+
Data.ReadXML(subEle, master);
249+
}
250+
if (ele.TryPathTo("Conditions", false, out subEle))
251+
{
252+
if (Conditions == null)
253+
Conditions = new List<Condition>();
254+
255+
foreach (XElement e in subEle.Elements())
256+
{
257+
Condition tempCTDA = new Condition();
258+
tempCTDA.ReadXML(e, master);
259+
Conditions.Add(tempCTDA);
260+
}
261+
}
262+
if (ele.TryPathTo("Stages", false, out subEle))
263+
{
264+
if (Stages == null)
265+
Stages = new List<QuestStage>();
266+
267+
foreach (XElement e in subEle.Elements())
268+
{
269+
QuestStage tempINDX = new QuestStage();
270+
tempINDX.ReadXML(e, master);
271+
Stages.Add(tempINDX);
272+
}
273+
}
274+
if (ele.TryPathTo("Objectives", false, out subEle))
275+
{
276+
if (Objectives == null)
277+
Objectives = new List<QuestObjective>();
278+
279+
foreach (XElement e in subEle.Elements())
280+
{
281+
QuestObjective tempQOBJ = new QuestObjective();
282+
tempQOBJ.ReadXML(e, master);
283+
Objectives.Add(tempQOBJ);
284+
}
285+
}
286+
}
287+
288+
}
289+
}

0 commit comments

Comments
 (0)