-
Notifications
You must be signed in to change notification settings - Fork 324
/
ContainerRecord.cs
103 lines (81 loc) · 2.4 KB
/
ContainerRecord.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Project: Daggerfall Unity
// Copyright: Copyright (C) 2009-2023 Daggerfall Workshop
// Web Site: http://www.dfworkshop.net
// License: MIT License (http://www.opensource.org/licenses/mit-license.php)
// Source Code: https://github.com/Interkarma/daggerfall-unity
// Original Author: Gavin Clayton (interkarma@dfworkshop.net)
// Contributors:
//
// Notes:
//
using System.IO;
namespace DaggerfallConnect.Save
{
/// <summary>
/// Container record.
/// SaveTreeRecordTypes = 0x34
/// </summary>
public class ContainerRecord : SaveTreeBaseRecord
{
#region Fields
ContainerRecordData parsedData;
#endregion
#region Properties
public ContainerRecordData ParsedData
{
get { return parsedData; }
set { parsedData = value; }
}
/// <summary>
/// Returns true if this is a wagon.
/// </summary>
public bool IsWagon
{
get { return WagonCheck(); }
}
#endregion
#region Structures
/// <summary>
/// Container records have a variable number of unknown bytes.
/// Can often be just a single byte, so does not seem to be reliably useful.
/// </summary>
public struct ContainerRecordData
{
public byte[] unknown;
}
#endregion
#region Constructors
public ContainerRecord()
{
}
public ContainerRecord(BinaryReader reader, int length)
: base(reader, length)
{
ReadNativeContainerData();
}
#endregion
#region Private Methods
void ReadNativeContainerData()
{
// Must be a container type
if (recordType != RecordTypes.Container)
return;
// Prepare stream
MemoryStream stream = new MemoryStream(RecordData);
BinaryReader reader = new BinaryReader(stream);
// Read container data
parsedData = new ContainerRecordData();
parsedData.unknown = reader.ReadBytes(RecordLength);
// Close stream
reader.Close();
}
bool WagonCheck()
{
if (recordRoot.SpriteIndex == 4)
return true;
else
return false;
}
#endregion
}
}