2017-09-15 08:22:51 -07:00
|
|
|
using System.Collections.Generic;
|
2018-01-31 21:09:08 -06:00
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
using ACE.Entity.Enum;
|
2017-09-15 08:22:51 -07:00
|
|
|
|
|
|
|
|
namespace ACE.DatLoader.Entity
|
|
|
|
|
{
|
2018-01-31 21:09:08 -06:00
|
|
|
public class CellStruct : IUnpackable
|
2017-09-15 08:22:51 -07:00
|
|
|
{
|
2018-01-31 21:09:08 -06:00
|
|
|
public CVertexArray VertexArray { get; } = new CVertexArray();
|
|
|
|
|
public Dictionary<ushort, Polygon> Polygons { get; } = new Dictionary<ushort, Polygon>();
|
|
|
|
|
public List<ushort> Portals { get; } = new List<ushort>();
|
|
|
|
|
public BSPTree CellBSP { get; } = new BSPTree();
|
|
|
|
|
public Dictionary<ushort, Polygon> PhysicsPolygons { get; } = new Dictionary<ushort, Polygon>();
|
|
|
|
|
public BSPTree PhysicsBSP { get; } = new BSPTree();
|
2017-09-15 08:22:51 -07:00
|
|
|
public BSPTree DrawingBSP { get; set; }
|
|
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
public void Unpack(BinaryReader reader)
|
|
|
|
|
{
|
2018-02-03 20:41:21 -06:00
|
|
|
var numPolygons = reader.ReadUInt32();
|
|
|
|
|
var numPhysicsPolygons = reader.ReadUInt32();
|
|
|
|
|
var numPortals = reader.ReadUInt32();
|
2017-09-15 08:22:51 -07:00
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
VertexArray.Unpack(reader);
|
2017-09-15 08:22:51 -07:00
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
Polygons.Unpack(reader, numPolygons);
|
2017-09-15 08:22:51 -07:00
|
|
|
|
|
|
|
|
for (uint i = 0; i < numPortals; i++)
|
2018-01-31 21:09:08 -06:00
|
|
|
Portals.Add(reader.ReadUInt16());
|
2017-09-15 08:22:51 -07:00
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
reader.AlignBoundary();
|
2017-09-15 08:22:51 -07:00
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
CellBSP.Unpack(reader, BSPType.Cell);
|
2017-09-15 08:22:51 -07:00
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
PhysicsPolygons.Unpack(reader, numPhysicsPolygons);
|
2017-09-15 08:22:51 -07:00
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
PhysicsBSP.Unpack(reader, BSPType.Physics);
|
2017-09-15 08:22:51 -07:00
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
uint hasDrawingBSP = reader.ReadUInt32();
|
|
|
|
|
if (hasDrawingBSP != 0)
|
|
|
|
|
{
|
|
|
|
|
DrawingBSP = new BSPTree();
|
|
|
|
|
DrawingBSP.Unpack(reader, BSPType.Drawing);
|
|
|
|
|
}
|
2017-09-15 08:22:51 -07:00
|
|
|
|
2018-01-31 21:09:08 -06:00
|
|
|
reader.AlignBoundary();
|
2017-09-15 08:22:51 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|