mirror of
https://github.com/celisej567/LibBSP.git
synced 2026-01-04 06:10:07 +03:00
Allow access to a BSP's BSPReader from outside the class.
This commit is contained in:
@@ -70,8 +70,6 @@ namespace LibBSP {
|
||||
|
||||
private MapType _version;
|
||||
|
||||
private BSPReader _reader;
|
||||
|
||||
// Map structures
|
||||
// Quake 1/GoldSrc
|
||||
private Entities _entities;
|
||||
@@ -106,13 +104,18 @@ namespace LibBSP {
|
||||
private GameLump _gameLump;
|
||||
private StaticProps _staticProps;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="BSPReader"/> object in use by this <see cref="BSP"/> class.
|
||||
/// </summary>
|
||||
public BSPReader reader { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The version of this BSP. Do not change this unless you want to force reading a BSP as a certain format.
|
||||
/// </summary>
|
||||
public MapType version {
|
||||
get {
|
||||
if (_version == MapType.Undefined) {
|
||||
_version = _reader.GetVersion();
|
||||
_version = reader.GetVersion();
|
||||
}
|
||||
return _version;
|
||||
}
|
||||
@@ -124,7 +127,7 @@ namespace LibBSP {
|
||||
/// <summary>
|
||||
/// Is the BSP file in big endian format?
|
||||
/// </summary>
|
||||
public bool bigEndian { get { return _reader.bigEndian; } }
|
||||
public bool bigEndian { get { return reader.bigEndian; } }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Entities"/> object in the BSP file, if available.
|
||||
@@ -134,7 +137,7 @@ namespace LibBSP {
|
||||
if (_entities == null) {
|
||||
int index = Entity.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_entities = Entity.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_entities = Entity.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _entities;
|
||||
@@ -149,7 +152,7 @@ namespace LibBSP {
|
||||
if (_planes == null) {
|
||||
int index = PlaneExtensions.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_planes = PlaneExtensions.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_planes = PlaneExtensions.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _planes;
|
||||
@@ -164,7 +167,7 @@ namespace LibBSP {
|
||||
if (_textures == null) {
|
||||
int index = Texture.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_textures = Texture.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_textures = Texture.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _textures;
|
||||
@@ -179,7 +182,7 @@ namespace LibBSP {
|
||||
if (_vertices == null) {
|
||||
int index = UIVertexExtensions.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_vertices = UIVertexExtensions.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_vertices = UIVertexExtensions.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _vertices;
|
||||
@@ -194,7 +197,7 @@ namespace LibBSP {
|
||||
if (_nodes == null) {
|
||||
int index = Node.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_nodes = Node.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_nodes = Node.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _nodes;
|
||||
@@ -209,7 +212,7 @@ namespace LibBSP {
|
||||
if (_texInfo == null) {
|
||||
int index = TextureInfo.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_texInfo = TextureInfo.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_texInfo = TextureInfo.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _texInfo;
|
||||
@@ -224,7 +227,7 @@ namespace LibBSP {
|
||||
if (_faces == null) {
|
||||
int index = Face.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_faces = Face.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_faces = Face.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _faces;
|
||||
@@ -239,7 +242,7 @@ namespace LibBSP {
|
||||
if (_leaves == null) {
|
||||
int index = Leaf.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_leaves = Leaf.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_leaves = Leaf.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _leaves;
|
||||
@@ -254,7 +257,7 @@ namespace LibBSP {
|
||||
if (_edges == null) {
|
||||
int index = Edge.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_edges = Edge.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_edges = Edge.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _edges;
|
||||
@@ -269,7 +272,7 @@ namespace LibBSP {
|
||||
if (_models == null) {
|
||||
int index = Model.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_models = Model.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_models = Model.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _models;
|
||||
@@ -284,7 +287,7 @@ namespace LibBSP {
|
||||
if (_brushes == null) {
|
||||
int index = Brush.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_brushes = Brush.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_brushes = Brush.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _brushes;
|
||||
@@ -299,7 +302,7 @@ namespace LibBSP {
|
||||
if (_brushSides == null) {
|
||||
int index = BrushSide.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_brushSides = BrushSide.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_brushSides = BrushSide.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _brushSides;
|
||||
@@ -314,7 +317,7 @@ namespace LibBSP {
|
||||
if (_materials == null) {
|
||||
int index = Texture.GetIndexForMaterialLump(version);
|
||||
if (index >= 0) {
|
||||
_materials = Texture.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_materials = Texture.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _materials;
|
||||
@@ -329,7 +332,7 @@ namespace LibBSP {
|
||||
if (_originalFaces == null) {
|
||||
int index = Face.GetIndexForOriginalFacesLump(version);
|
||||
if (index >= 0) {
|
||||
_originalFaces = Face.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_originalFaces = Face.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _originalFaces;
|
||||
@@ -344,7 +347,7 @@ namespace LibBSP {
|
||||
if (_texDatas == null) {
|
||||
int index = TextureData.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_texDatas = TextureData.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_texDatas = TextureData.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _texDatas;
|
||||
@@ -359,7 +362,7 @@ namespace LibBSP {
|
||||
if (_dispInfos == null) {
|
||||
int index = DisplacementInfo.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_dispInfos = DisplacementInfo.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_dispInfos = DisplacementInfo.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _dispInfos;
|
||||
@@ -374,7 +377,7 @@ namespace LibBSP {
|
||||
if (_dispVerts == null) {
|
||||
int index = DisplacementVertex.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_dispVerts = DisplacementVertex.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_dispVerts = DisplacementVertex.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _dispVerts;
|
||||
@@ -389,7 +392,7 @@ namespace LibBSP {
|
||||
if (_cubemaps == null) {
|
||||
int index = Cubemap.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_cubemaps = Cubemap.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_cubemaps = Cubemap.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _cubemaps;
|
||||
@@ -405,7 +408,7 @@ namespace LibBSP {
|
||||
NumList.DataType type;
|
||||
int index = NumList.GetIndexForMarkSurfacesLump(version, out type);
|
||||
if (index >= 0) {
|
||||
_markSurfaces = NumList.LumpFactory(_reader.ReadLumpNum(index, version), type);
|
||||
_markSurfaces = NumList.LumpFactory(reader.ReadLumpNum(index, version), type);
|
||||
}
|
||||
}
|
||||
return _markSurfaces;
|
||||
@@ -421,7 +424,7 @@ namespace LibBSP {
|
||||
NumList.DataType type;
|
||||
int index = NumList.GetIndexForSurfEdgesLump(version, out type);
|
||||
if (index >= 0) {
|
||||
_surfEdges = NumList.LumpFactory(_reader.ReadLumpNum(index, version), type);
|
||||
_surfEdges = NumList.LumpFactory(reader.ReadLumpNum(index, version), type);
|
||||
}
|
||||
}
|
||||
return _surfEdges;
|
||||
@@ -437,7 +440,7 @@ namespace LibBSP {
|
||||
NumList.DataType type;
|
||||
int index = NumList.GetIndexForMarkBrushesLump(version, out type);
|
||||
if (index >= 0) {
|
||||
_markBrushes = NumList.LumpFactory(_reader.ReadLumpNum(index, version), type);
|
||||
_markBrushes = NumList.LumpFactory(reader.ReadLumpNum(index, version), type);
|
||||
}
|
||||
}
|
||||
return _markBrushes;
|
||||
@@ -453,7 +456,7 @@ namespace LibBSP {
|
||||
NumList.DataType type;
|
||||
int index = NumList.GetIndexForIndicesLump(version, out type);
|
||||
if (index >= 0) {
|
||||
_indices = NumList.LumpFactory(_reader.ReadLumpNum(index, version), type);
|
||||
_indices = NumList.LumpFactory(reader.ReadLumpNum(index, version), type);
|
||||
}
|
||||
}
|
||||
return _indices;
|
||||
@@ -469,7 +472,7 @@ namespace LibBSP {
|
||||
NumList.DataType type;
|
||||
int index = NumList.GetIndexForTexTableLump(version, out type);
|
||||
if (index >= 0) {
|
||||
_texTable = NumList.LumpFactory(_reader.ReadLumpNum(index, version), type);
|
||||
_texTable = NumList.LumpFactory(reader.ReadLumpNum(index, version), type);
|
||||
}
|
||||
}
|
||||
return _texTable;
|
||||
@@ -485,7 +488,7 @@ namespace LibBSP {
|
||||
NumList.DataType type;
|
||||
int index = NumList.GetIndexForDisplacementTrianglesLump(version, out type);
|
||||
if (index >= 0) {
|
||||
_displacementTriangles = NumList.LumpFactory(_reader.ReadLumpNum(index, version), type);
|
||||
_displacementTriangles = NumList.LumpFactory(reader.ReadLumpNum(index, version), type);
|
||||
}
|
||||
}
|
||||
return _displacementTriangles;
|
||||
@@ -500,7 +503,7 @@ namespace LibBSP {
|
||||
if (_gameLump == null) {
|
||||
int index = GameLump.GetIndexForLump(version);
|
||||
if (index >= 0) {
|
||||
_gameLump = GameLump.LumpFactory(_reader.ReadLumpNum(index, version), version);
|
||||
_gameLump = GameLump.LumpFactory(reader.ReadLumpNum(index, version), version);
|
||||
}
|
||||
}
|
||||
return _gameLump;
|
||||
@@ -587,7 +590,7 @@ namespace LibBSP {
|
||||
/// </summary>
|
||||
/// <param name="filePath">The path to the .BSP file.</param>
|
||||
public BSP(string filePath) {
|
||||
_reader = new BSPReader(new FileInfo(filePath));
|
||||
reader = new BSPReader(new FileInfo(filePath));
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
@@ -597,7 +600,7 @@ namespace LibBSP {
|
||||
/// </summary>
|
||||
/// <param name="file">A reference to the .BSP file.</param>
|
||||
public BSP(FileInfo file) {
|
||||
_reader = new BSPReader(file);
|
||||
reader = new BSPReader(file);
|
||||
this.filePath = file.FullName;
|
||||
}
|
||||
|
||||
@@ -605,7 +608,7 @@ namespace LibBSP {
|
||||
/// Tells the <see cref="BSPReader"/> object to release file handles for the BSP file.
|
||||
/// </summary>
|
||||
public void Close() {
|
||||
_reader.Close();
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user