using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HaloObjects;

namespace HaloPlugins.Xbox
{
    public class sbsp
    {
       public List<MetaNode> Fields = new List<MetaNode>();

       public sbsp()
       {
           Fields.AddRange(new MetaNode[] {
           new Value("BSP Meta Size", typeof(int)),
           new Value("BSP Meta Offset", typeof(int)),
           new Value("Lightmap Raw Meta Offset", typeof(int)),
           new TagReference("sbsp"),
           new Value("Unknown", typeof(int)),
           new Value("Unknown", typeof(int)),
           new Reflexive("Collision Materials", 20, new MetaNode[] { 
               new TagReference("Unused"),
               new Unused(4),
               new TagReference("Shader"),
           }),
           new Reflexive("Collision Bsp", 68, new MetaNode[] { 
               new Reflexive("3D Nodes", 8, new MetaNode[] { //8
                   new Value("Plane", typeof(short)),
                   new Value("Back child", typeof(short)),
                   new Value("Flag/padding/Unknown", typeof(byte)),
                   new Value("Front Child", typeof(short)),
                   new Value("Flag/padding/Unknown2", typeof(byte)),
               }),
               new Reflexive("Planes", 16, 16, new MetaNode[] { 
                   new Value("Plane i", typeof(float)),
                   new Value("Plane j", typeof(float)),
                   new Value("Plane k", typeof(float)),
                   new Value("Plane d", typeof(float)),
               }),
               new Reflexive("Leaves", 4, new MetaNode[] { 
                   new Bitmask("Flags", new string[] { "Contains_Double-Sided_Surfaces" }, 8),
                   new Value("BSP 2D Reference Count", typeof(byte)),
                   new Value("First BSP 2D Reference", typeof(short)),
               }),
               new Reflexive("BSP 2D Refrences", 4, new MetaNode[] { 
                   new Value("Plane", typeof(short)),
                   new Value("BSP 2D Node", typeof(short)),
               }),
               new Reflexive("BSP2D Nodes", 16, 16, new MetaNode[] { 
                   new Value("Plane i", typeof(float)),
                   new Value("Plane j", typeof(float)),
                   new Value("Plane d", typeof(float)),
                   new Value("Left Child", typeof(short)),
                   new Value("Right Child", typeof(short)),
               }),
               new Reflexive("Surfaces", 8, new MetaNode[] { 
                   new Value("Plane", typeof(short)),
                   new Value("First Edge", typeof(short)),
                   new Bitmask("Flags", new string[] { "Two-Sided", "Invisible", "Climable", "Breakable", "Invaild", "Conveyor" }, 8),
                   new Value("Breakable Surface #", typeof(byte)),
                   new Value("Material #", typeof(short)),
               }),
               new Reflexive("Edges", 12, new MetaNode[] { 
                   new Value("Start Vertex", typeof(short)),
                   new Value("End Vertex", typeof(short)),
                   new Value("Forward Edge", typeof(short)),
                   new Value("Backward Edge", typeof(short)),
                   new Value("Left Surface", typeof(short)),
                   new Value("Right Surface", typeof(short)),
               }),
               new Reflexive("Collsion Model", 16, 16, new MetaNode[] { 
                   new Value("Point X", typeof(float)),
                   new Value("Point Y", typeof(float)),
                   new Value("Point Z", typeof(float)),
                   new Value("First Edge", typeof(short)),
                   new Unused(2),
               }),
               new Value("Unknown", typeof(float)),
           }),
           new Value("Vehicle Floor", typeof(float)),
           new Value("Vehicle Ceiling", typeof(float)),
           new Unused(8),
           new Reflexive("Leaves", 8, new MetaNode[] { 
               new Value("Cluster", typeof(short)),
               new Value("Surface Count", typeof(short)),
               new Value("Surface refrence", typeof(int)),
           }),
           new Value("World Bounds X", typeof(float)),
           new Value("...To", typeof(float)),
           new Value("World Bounds Y", typeof(float)),
           new Value("...To", typeof(float)),
           new Value("World Bounds Z", typeof(float)),
           new Value("...To", typeof(float)),
           new Reflexive("Surface References", 8, new MetaNode[] { 
               new Value("Strip Index", typeof(short)),
               new Value("Lightmap Triangle Index", typeof(short)),
               new Value("BSP Node Index", typeof(int)),
           }),
           new Reflexive("Cluster Data", 1, new MetaNode[] { 
               new Value("Data", typeof(byte)),
           }),
           new Reflexive("Cluster Portals", 36, new MetaNode[] { //16
               new Value("Back Cluster", typeof(short)),
               new Value("Front Cluster", typeof(short)),
               new Value("Plane Index", typeof(int)),
               new Value("Centroid X", typeof(float)),
               new Value("Centroid Y", typeof(float)),
               new Value("Centroid Z", typeof(float)),
               new Value("Bounding Radius", typeof(float)),
               new Bitmask("Flags", new string[] { "AI_Cannot_Hear_Through_This", "One-Way", "Door", "No-Way", "One-Way_Reversed", "No_One_Can_Hear_Through_This" }, 32),
               new Reflexive("Vertices", 12, 16, new MetaNode[] { 
                   new Value("X", typeof(float)),
                   new Value("Y", typeof(float)),
                   new Value("Z", typeof(float)),
               }),
           }),
           new Reflexive("Fog Planes", 24, new MetaNode[] { //16
               new Value("Scenario Planar Fog Index", typeof(short)),
               new Value("Plane i", typeof(float)),
               new Value("Plane j", typeof(float)),
               new Value("Plane k", typeof(float)),
               new Value("Plane d", typeof(float)),
               new Bitmask("Flags", new string[] { "Extend_Infinitely_While_Visible", "Do_Not_Floodfill", "Aggressive_Floodfill" }, 32),
               new Value("Priority", typeof(short)),
           }),
           new Unused(24),
           new Reflexive("Weather Pallete", 120, new MetaNode[] { //16
               new String32("Name"),
               new TagReference("Weather_System"),
               new Unused(36),
               new TagReference("Wind"),
               new Value("Wind Direction i", typeof(float)),
               new Value("Wind Direction j", typeof(float)),
               new Value("Wind Direction k", typeof(float)),
               new Value("Wind Magnitude", typeof(float)),
               new StringID("Wind Scale Function"),
               new Unused(16),
           }),
           new Reflexive("Weather Polyhedral", 24, new MetaNode[] { //16
               new Value("Bounding Sphere Center X", typeof(float)),
               new Value("Bounding Sphere Center Y", typeof(float)),
               new Value("Bounding Sphere Center Z", typeof(float)),
               new Value("Bounding Sphere Radius", typeof(float)),
               new Reflexive("Planes", 16, new MetaNode[] { //16
                   new Value("i", typeof(float)),
                   new Value("j", typeof(float)),
                   new Value("k", typeof(float)),
                   new Value("d", typeof(float)),
               }),
           }),
           new Reflexive("Sound Data", 36, new MetaNode[] { 
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
           }),
           new Reflexive("Detail Objects", 176, new MetaNode[] { 
               new Value("Vertice Count", typeof(short)),
               new Value("Face Count", typeof(short)),
               new Value("Total Part Count", typeof(short)),
               new Value("Shadow-Casting Triangle Cour", typeof(short)),
               new Value("Shadow-Casting Part Cour", typeof(short)),
               new Value("Opaque Point Count", typeof(short)),
               new Value("Opaque Vertex Count", typeof(short)),
               new Value("Opaque Part Count", typeof(short)),
               new Value("Opaque Max Nodes/Vertex", typeof(short)),
               new Value("Transparent Mox Nodes/Vertex", typeof(short)),
               new Value("Shadow-Casting Rigid Triangle", typeof(short)),
               new Value("Geometry Classification", typeof(short)),
               new Value("Geometry Compression Flags", typeof(int)),
               new Value("Hardware Node Count", typeof(short)),
               new Value("Node Map Size", typeof(short)),
               new Value("", typeof(short)),
               new Value("Software Plane Count", typeof(short)),
               new Value("Total Subpart Cont", typeof(short)),
               new Bitmask("Section Lighting Flags", new string[] { "Has_Im_Texcoords", "Has_Im_Inc._Rad.", "Has_Im_Colors", "Has_Im_prt" }, 16),
               new Value("Raw Offset", typeof(int)),
               new Value("Raw Size", typeof(int)),
               new Value("Raw Header Size", typeof(int)),
               new Value("Raw Data Size", typeof(int)),
               new Reflexive("Resources", 16, new MetaNode[] { 
                   new Value("Unknown", typeof(int)),
                   new Value("Unknown", typeof(int)),
                   new Value("Size", typeof(int)),
                   new Value("Offset", typeof(int)),
               }),
               new Ident("Owner_Tag_Section_Offset"),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Max X", typeof(float)),
               new Value("Min X", typeof(float)),
               new Value("Max Y", typeof(float)),
               new Value("Min Y", typeof(float)),
               new Value("Max Z", typeof(float)),
               new Value("Max Z", typeof(float)),
               new Value("Scenario Sky Index", typeof(short)),
               new Value("Media Index", typeof(short)),
               new Value("Scenario Visible Sky Index", typeof(short)),
               new Value("Scenario Atmospheric Fog Index", typeof(short)),
               new Value("Planar Fog Designator", typeof(short)),
               new Value("Visible Fog Plane Index", typeof(short)),
               new Value("Background Sound Index", typeof(short)),
               new Value("Sound Environment Index", typeof(short)),
               new Value("Weather Index", typeof(short)),
               new Value("Transition Structure BSP", typeof(short)),
               new Bitmask("Flags", new string[] { "One-Way_Portal", "Door_Portal", "Postprocessed_Geometry", "Is_the_Sky" }, 32),
               new Reflexive("Predicted Resources", 8, new MetaNode[] { //16
                   new Value("Type Enum", typeof(short)),
                   new Value("", typeof(short)),
                   new Ident("Resource"),
               }),
               new Reflexive("Portals", 2, new MetaNode[] { //16
                   new Value("Index", typeof(short)),
               }),
               new Value("Checksum From Structure", typeof(int)),
               new Reflexive("Instanced Geometry References", 2, new MetaNode[] { //16
                   new Value("Instanced Geometry Index", typeof(short)),
               }),
               new Unused(8),
               new Reflexive("Index Reorder Table", 1, 16, new MetaNode[] {
                   new Value("Index", typeof(byte)),
               }),
           }),
           new Reflexive("Materials", 32, new MetaNode[] { 
               new TagReference("Old_Shader"),
               new TagReference("Shader"),
               new Reflexive("Properties", 8, new MetaNode[] { 
                   new HaloObjects.Enum("Type", new string[] {  }, 16),
                   new Value("Real Value", typeof(float)),
                   new Unused(2),
               }),
               new Value("Breakable Surface Index", typeof(short)),
               new Unused(6),
           }),
           new Reflexive("Sky Owner Cluster", 2, new MetaNode[] { 
               new Value("Cluster Owner", typeof(short)),
           }),
           new Reflexive("Conveyor Surfaces", 24, new MetaNode[] { //16
               new Value("U i", typeof(float)),
               new Value("U j", typeof(float)),
               new Value("U k", typeof(float)),
               new Value("V i", typeof(float)),
               new Value("V j", typeof(float)),
               new Value("V j", typeof(float)),
           }),
           new Reflexive("Breakable Surfaces", 24, new MetaNode[] { //16
               new Value("Instanced Geometry Instance", typeof(short)),
               new Value("Breakable Surface Index", typeof(short)),
               new Value("Centroid X", typeof(float)),
               new Value("Centroid Y", typeof(float)),
               new Value("Centroid Z", typeof(float)),
               new Value("Radius", typeof(float)),
               new Value("Collision Surface Index", typeof(int)),
           }),
           new Reflexive("Pathfinding Data", 116, new MetaNode[] { 
               new Reflexive("Sectors", 8, new MetaNode[] { 
                   new Bitmask("Path-Finding Sector Flags", new string[] { "Sector_Walkable", "Sector_Breakable", "Sector_Mobile", "Sector_BSP_Source", "Floor", "Ceiling", "Wall_North", "Wall_South", "Wall_East", "Wall_West", "Crouchable", "Aligned", "Sector_Step", "Sector_Interior" }, 16),
                   new Value("Hint Index", typeof(short)),
                   new Value("First Link (Do Not Set Manually)", typeof(int)),
               }),
               new Reflexive("Links", 16, new MetaNode[] { 
                   new Value("Vertex 1", typeof(short)),
                   new Value("Vertex 2", typeof(short)),
                   new Bitmask("Link Flags", new string[] { "Sector_Link_from_Collision", "Sector_Intersection_Link", "Sector_Link_BSP_2D_Creation_Error", "Sector_Link_Topology_Error", "Sector_Link_Chain_Error", "Sector_Link_Both_Sectors_Walkable", "Sector_Link_Magic_Hanging_Link", "Sector_Link_Threshold", "Sector_Link_Crouchable", "Sector_Link_Wall_Base", "Sector_Link_Ledge", "Sector_Link_Leanable", "Sector_Link_Start_Corner", "Sector_Link_End_Corner" }, 16),
                   new Value("Hint Index", typeof(short)),
                   new Value("Foward Link", typeof(short)),
                   new Value("Reverse Link", typeof(short)),
                   new Value("Left Sector", typeof(short)),
                   new Value("Right Sector", typeof(short)),
               }),
               new Reflexive("Refs", 4, new MetaNode[] { 
                   new Value("Node Ref/Sector Ref", typeof(int)),
               }),
               new Reflexive("BSP 2D Nodes", 20, new MetaNode[] { //16
                   new Value("Plane I", typeof(float)),
                   new Value("Plane J", typeof(float)),
                   new Value("Plane D", typeof(float)),
                   new Value("Left Child", typeof(int)),
                   new Value("Right Child", typeof(int)),
               }),
               new Unused(8),
               new Reflexive("Verticies", 12, new MetaNode[] { //16
                   new Value("X", typeof(float)),
                   new Value("Y", typeof(float)),
                   new Value("Z", typeof(float)),
               }),
               new Reflexive("Object Refs", 28, new MetaNode[] { 
                   new Bitmask("Flags", new string[] { "Mobile" }, 32),
                   new Value("First Sector", typeof(int)),
                   new Value("Last Sector", typeof(int)),
                   new Reflexive("Bsps", 16, new MetaNode[] { 
                       new Value("Bsp Reference", typeof(int)),
                       new Value("First Sector", typeof(int)),
                       new Value("Last Sector", typeof(int)),
                       new Value("Node Index", typeof(int)),
                   }),
                   new Reflexive("Nodes", 4, new MetaNode[] {
                       new Value("Reference Frame Index", typeof(byte)),
                       new Value("Projection Axis", typeof(byte)),
                       new Bitmask("Projection Sign", new string[] { "Projection Sign" }, 16),
                   }),
               }),
               new Reflexive("Pathfinding Hints", 20, new MetaNode[] { 
                   new HaloObjects.Enum("Hint Type", new string[] {  }, 16),
                   new Value("Hint Data 0", typeof(short)),
                   new Value("Hint Data 1", typeof(short)),
                   new Value("Hint Data 2", typeof(short)),
                   new Value("Hint Data 3", typeof(short)),
                   new Value("Hint Data 4", typeof(short)),
                   new Value("Hint Data 5", typeof(short)),
                   new Value("Hint Data 6", typeof(short)),
                   new Value("Hint Data 7", typeof(short)),
                   new Unused(2),
               }),
               new Reflexive("Instanced Geometry Refs", 4, new MetaNode[] { 
                   new Value("Pathfinding Object Index", typeof(short)),
                   new Value("Unknown", typeof(short)),
               }),
               new Value("Structure Checksum", typeof(int)),
               new Unused(32),
               new Reflexive("User Placed Hints", 72, new MetaNode[] { 
                   new Unused(16),
                   new Reflexive("Line Segment Geometry", 34,  new MetaNode[] { //36
                       new Bitmask("Flags", new string[] { "Bidirectional", "Closed" }, 16),
                       new Value("Part 0 X", typeof(float)),
                       new Value("Part 0 Y", typeof(float)),
                       new Value("Part 0 Z", typeof(float)),
                       new Value("Reference Frame", typeof(int)),
                       new Value("Part 1 X", typeof(float)),
                       new Value("Part 1 Y", typeof(float)),
                       new Value("Part 1 Z", typeof(float)),
                       new Value("Reference Frame", typeof(int)),
                   }),
                   new Reflexive("Parallelogram Geometry", 66, new MetaNode[] { //68
                       new Bitmask("Flags", new string[] { "Bidirectional", "Closed" }, 16),
                       new Value("Part 0 X", typeof(float)),
                       new Value("Part 0 Y", typeof(float)),
                       new Value("Part 0 Z", typeof(float)),
                       new Value("Reference Frame", typeof(int)),
                       new Value("Part 1 X", typeof(float)),
                       new Value("Part 1 Y", typeof(float)),
                       new Value("Part 1 Z", typeof(float)),
                       new Value("Reference Frame", typeof(int)),
                       new Value("Part 2 X", typeof(float)),
                       new Value("Part 2 Y", typeof(float)),
                       new Value("Part 2 Z", typeof(float)),
                       new Value("Reference Frame", typeof(int)),
                       new Value("Part 3 X", typeof(float)),
                       new Value("Part 3 Y", typeof(float)),
                       new Value("Part 3 Z", typeof(float)),
                       new Value("Reference Frame", typeof(int)),
                   }),
                   new Unused(8), // Polygon Geometry?
                   new Reflexive("Jump Hints", 8, new MetaNode[] { 
                       new Bitmask("Flags", new string[] { "Bidirectional", "Closed" }, 16),
                       new Value("Geometry Index", typeof(short)),
                       new Value("Force Jump Height Enum", typeof(short)),
                       new Bitmask("Control Flags", new string[] { "Magic_Lift" }, 16),
                   }),
                   new Reflexive("Climb Hints", 4, new MetaNode[] { 
                       new Bitmask("Flags", new string[] { "Bidirectional", "Closed" }, 16),
                       new Value("Geometry Index", typeof(short)),
                   }),
                   new Unused(8), // Well Hints
                   new Reflexive("Flight Hints", 8, new MetaNode[] { 
                       new Reflexive("Points", 12, new MetaNode[] { //16
                           new Value("i", typeof(float)),
                           new Value("j", typeof(float)),
                           new Value("k", typeof(float)),
                       }),
                   }),
               }),
           }),
           new Unused(8),
           new Reflexive("Background Sound Palette", 100, new MetaNode[] { 
               new String32("Name"),
               new TagReference("Background_Sound"),
               new TagReference("Inside_Cluster_Sound"),
               new Value("Cutoff Distance", typeof(float)),
               new Bitmask("Scale Flags", new string[] { "Override_Default_Scale", "Use_Adjacent_Cluster_As_Portal_Scale", "Use_Adjacent_Cluster_As_Exterior_Scale", "Scale_With_Weather_Intensity" }, 32),
               new Value("Interior Scale", typeof(float)),
               new Value("Portal Scale", typeof(float)),
               new Value("Exterior Scale", typeof(float)),
               new Value("Interpolation Speed", typeof(float)),
               new Value("unused?", typeof(int)),
               new Value("unused?", typeof(int)),
               new Value("unused?", typeof(int)),
               new Value("unused?", typeof(int)),
               new Value("unused?", typeof(float)),
               new Value("unused?", typeof(int)),
               new Value("unused?", typeof(int)),
           }),
           new Reflexive("Sound Environment Palette", 72, new MetaNode[] { 
               new String32("Name"),
               new TagReference("Sound_Environment"),
               new Value("Cutoff Distance", typeof(float)),
               new Value("Interpolation Speed", typeof(float)),
               new Unused(24),
           }),
           new Reflexive("Sound PAS Data", 1, new MetaNode[] { 
               new Value("Data", typeof(byte)),
           }),
           new Reflexive("Markers", 60, new MetaNode[] { //16
               new String32("Name"),
               new Value("Rotation i", typeof(float)),
               new Value("Rotation j", typeof(float)),
               new Value("Rotation k", typeof(float)),
               new Value("Rotation w", typeof(float)),
               new Value("Position X", typeof(float)),
               new Value("Position Y", typeof(float)),
               new Value("Position Z", typeof(float)),
           }),
           new Reflexive("Runtime Decals", 16, new MetaNode[] { 
               new Value("Unknown", typeof(float)),
               new Value("Unknown", typeof(float)),
               new Value("Unknown", typeof(float)),
               new Value("Unknown", typeof(int)),
           }),
           new Reflexive("Environment Object Palette", 20, new MetaNode[] { 
               new TagReference("Definition"),
               new TagReference("Model"),
               new Unused(4),
           }),
           new Reflexive("Environment Objects", 104, new MetaNode[] { //16
               new String32("Name"),
               new Value("Rotation i", typeof(float)),
               new Value("Rotation j", typeof(float)),
               new Value("Rotation k", typeof(float)),
               new Value("Rotation w", typeof(float)),
               new Value("X", typeof(float)),
               new Value("Y", typeof(float)),
               new Value("Z", typeof(float)),
               new Value("Palette Index", typeof(short)),
               new Value("Unique ID", typeof(int)),
               new Value("Exported Object Type", typeof(short)),
               new String32("Scenario Object Name"),
               new Unused(4),
           }),
           new Unused(44),
           new Reflexive("Bsp Permutations", 200, new MetaNode[] { 
               new Value("Total Vertex Count", typeof(short)),
               new Value("Total Triangle count", typeof(short)),
               new Value("Total Part Count", typeof(short)),
               new Value("Shadow-Casting Triangle Count", typeof(short)),
               new Value("Shadow-Casting Part Count", typeof(short)),
               new Value("Opaque Point Count", typeof(short)),
               new Value("Opaque Vertex Count", typeof(short)),
               new Value("Opaque Part Count", typeof(short)),
               new Value("Opaque Max Nodes/Vertex", typeof(short)),
               new Value("Transparent Max Nodes/Vertex", typeof(short)),
               new Value("Shadow-Casting Rigid Triangle", typeof(short)),
               new HaloObjects.Enum("Geometry Classification", new string[] {  }, 16),
               new Reflexive("Bounding Box", 40, new MetaNode[] {//16
                   new Value("Min X", typeof(float)),
                   new Value("Max X", typeof(float)),
                   new Value("Min Y", typeof(float)),
                   new Value("Max Y", typeof(float)),
                   new Value("Min Z", typeof(float)),
                   new Value("Max Z", typeof(float)),
                   new Value("Min U", typeof(float)),
                   new Value("Max U", typeof(float)),
                   new Value("Min V", typeof(float)),
                   new Value("Max V", typeof(float)),
           }),
           new Bitmask("Geometry Compression Flags", new string[] { "Compressed_Postion", "Compressed_Texcoord", "Compressed_Secondary_Texcoord" }, 16),
           new Value("Hardware Node Count", typeof(byte)),
           new Value("Node Map Size", typeof(byte)),
           new Value("Software Plane Count", typeof(byte)),
           new Value("Total Subpart Count", typeof(byte)),
           new Bitmask("Section Lighting Flags", new string[] { "Has_Im_Texcoords", "Has_Im_Inc._Rad.", "Has_Im_Colors", "Has_Im_Prt" }, 16),
           new Value("Raw Offset", typeof(int)),
           new Value("Raw Size", typeof(int)),
           new Value("Header Size", typeof(int)),
           new Value("Size - Header Size", typeof(int)),
           new Reflexive("Resources", 16, new MetaNode[] { 
               new HaloObjects.Enum("Type", new string[] {  }, 32),
               new Value("Primary Locator", typeof(short)),
               new Value("Secondary Locator", typeof(short)),
               new Value("Resource Data Size", typeof(int)),
               new Value("Resource Data Offset", typeof(int)),
           }),
           new Ident("Owner Tag Section Offset"),
           new Value("Unknown", typeof(int)),
           new Value("Unknown", typeof(int)),
           new Reflexive("Render Data", 64, new MetaNode[] { 
               new Reflexive("Parts", 0, new MetaNode[] { 
               }),
               new Reflexive("Subparts", 0, new MetaNode[] { 
               }),
               new Reflexive("Visibility Bounds", 0, new MetaNode[] { 
               }),
               new Reflexive("Raw Vertices", 0, new MetaNode[] { 
               }),
               new Reflexive("Strip Indices", 0, new MetaNode[] { 
               }),
               new Reflexive("Visibility MOPP Code", 1, new MetaNode[] { 
                   new Value("Data", typeof(byte)),
               }),
               new Reflexive("MOPP Reorder Table", 0, new MetaNode[] { 
               }),
               new Reflexive("Vertex Buffers", 0, new MetaNode[] { 
               }),
           }),
           new Reflexive("Index Reorder Table", 4, new MetaNode[] { 
               new Value("Index", typeof(short)),
               new Unused(2),
           }),
           new Value("Checksum", typeof(int)),
           new Value("Bounding Sphere X", typeof(float)),
           new Value("Bounding Sphere Y", typeof(float)),
           new Value("Bounding Sphere Z", typeof(float)),
           new Value("Bounding Sphere Radius", typeof(float)),
           new Reflexive("3D Nodes", 8, 8, new MetaNode[] { 
               new Value("Plane", typeof(short)),
               new Value("Back child", typeof(short)),
               new Value("Flag/padding/Unknown", typeof(byte)),
               new Value("Front Child", typeof(short)),
               new Value("Flag/padding/Unknown2", typeof(byte)),
           }),
           new Reflexive("Planes", 16, 16, new MetaNode[] { //16
               new Value("Plane i", typeof(float)),
               new Value("Plane j", typeof(float)),
               new Value("Plane k", typeof(float)),
               new Value("Plane d", typeof(float)),
           }),
           new Reflexive("Leaves", 4, new MetaNode[] { 
               new Bitmask("Flags", new string[] { "Contains_Double-Sided_Surfaces" }, 8),
               new Value("BSP 2D Reference Count", typeof(byte)),
               new Value("First BSP 2D Reference", typeof(short)),
           }),
           new Reflexive("BSP 2D References", 4, new MetaNode[] { //16
               new Value("Plane", typeof(short)),
               new Value("BSP 2D Node", typeof(short)),
           }),
           new Reflexive("BSP 2D Nodes", 16, 16, new MetaNode[] { //16
               new Value("Plane i", typeof(float)),
               new Value("Plane j", typeof(float)),
               new Value("Plane d", typeof(float)),
               new Value("Left Child", typeof(short)),
               new Value("Right Child", typeof(short)),
           }),
           new Reflexive("Surfaces", 8, 8, new MetaNode[] { 
               new Value("Plane", typeof(short)),
               new Value("First Edge", typeof(short)),
               new Bitmask("Flags", new string[] { "Two-Sided", "Invisible", "Climable", "Breakable", "Invaild", "Conveyor" }, 8),
               new Value("Breakable Surface #", typeof(byte)),
               new Value("Material #", typeof(short)),
           }),
           new Reflexive("Edges", 12, new MetaNode[] { 
               new Value("Start Vertex", typeof(short)),
               new Value("End Vertex", typeof(short)),
               new Value("Forward Edge", typeof(short)),
               new Value("Backward Edge", typeof(short)),
               new Value("Left Surface", typeof(short)),
               new Value("Right Surface", typeof(short)),
           }),
           new Reflexive("Vertices", 16, new MetaNode[] { //16
               new Value("Point X", typeof(float)),
               new Value("Point Y", typeof(float)),
               new Value("Point Z", typeof(float)),
               new Value("First Edge", typeof(short)),
               new Unused(2),
           }),
           new Reflexive("BSP Physics", 112, new MetaNode[] { 
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(float)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(float)),
               new Value("Unknown", typeof(float)),
               new Value("Unknown", typeof(float)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Unused(12),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Reflexive("MOPP Code Data", 1, 16, new MetaNode[] { 
                   new Value("Data", typeof(byte)),
               }),
               new Value("Unknown", typeof(int)),
           }),
           new Reflexive("Render Leaves", 8, new MetaNode[] { 
               new Value("Cluster", typeof(short)),
               new Value("Surface Reference Count", typeof(short)),
               new Value("First Surface Reference Index", typeof(int)),
           }),
           new Reflexive("Surface References", 8, new MetaNode[] { 
               new Value("Strip Index", typeof(short)),
               new Value("Lightmap Triangle", typeof(short)),
               new Value("BSP Node Index", typeof(int)),
           }),
       }),
       new Reflexive("Instanced Geometry Instances", 88, new MetaNode[] { //16
           new Value("Scale", typeof(float)),
           new Value("Forward i", typeof(float)),
           new Value("Forward j", typeof(float)),
           new Value("Forward k", typeof(float)),
           new Value("Left i", typeof(float)),
           new Value("Left j", typeof(float)),
           new Value("Left k", typeof(float)),
           new Value("Up i", typeof(float)),
           new Value("Up j", typeof(float)),
           new Value("Up k", typeof(float)),
           new Value("Position X", typeof(float)),
           new Value("Position Y", typeof(float)),
           new Value("Position Z", typeof(float)),
           new Value("Instance Definition #", typeof(short)),
           new Bitmask("Flags", new string[] { "Not_In_Lightprobes" }, 16),
           new Value("Checksum", typeof(int)),
           new Unused(20),
           new StringID("Name"),
           new HaloObjects.Enum("Pathfinding Policy", new string[] {  }, 32),//16
       }),
       new Reflexive("Ambience Sound Clusters", 20, new MetaNode[] { 
           new Unused(4),
           new Reflexive("Enclosing Portal Designators", 4, new MetaNode[] { 
               new Value("Portal Designator", typeof(short)),
               new Unused(2),
           }),
           new Reflexive("Interior Cluster Indices", 4, new MetaNode[] { 
               new Value("Interior Cluster Index", typeof(short)),
               new Unused(2),
           }),
       }),
       new Reflexive("Reverb Sound Clusters", 20, new MetaNode[] { 
           new Unused(4),
           new Reflexive("Enclosing Portal Designators", 4, new MetaNode[] { 
               new Value("Portal Designator", typeof(short)),
               new Unused(2),
           }),
           new Reflexive("Interior Cluster Indices", 4, new MetaNode[] { 
               new Value("Interior Cluster Index", typeof(short)),
               new Unused(2),
           }),
       }),
       new Reflexive("Transparent Planes", 20, new MetaNode[] { //16
           new Value("Section Index", typeof(short)),
           new Value("Part Index", typeof(short)),
           new Value("Plane i", typeof(float)),
           new Value("Plane j", typeof(float)),
           new Value("Plane k", typeof(float)),
           new Value("Plane d", typeof(float)),
       }),
       new Value("Vehicle Sperical Limit Radius", typeof(float)),
       new Value("Vehicle Sperical Limit X", typeof(float)),
       new Value("Vehicle Sperical Limit Y", typeof(float)),
       new Value("Vehicle Sperical Limit Z", typeof(float)),
       new Unused(96),
       new Reflexive("Debug Info", 88, new MetaNode[] { 
           new Unused(64),
           new Reflexive("Unknown", 72, new MetaNode[] { 
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               new Unused(40),
               new Reflexive("Unknown", 4, new MetaNode[] {
                   new Unused(4),
               }),
               new Reflexive("Unknown", 4, new MetaNode[] {
                   new Unused(4),
               }),
               new Unused(8),
               new Reflexive("Unknown", 4, new MetaNode[] {
                   new Unused(4),
               }),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
               //new Value("Unknown", typeof(int)),
           }),
           //new Unused(16),
           new Reflexive("Unknown", 56, new MetaNode[] {
               new Unused(32),
               new Reflexive("Unknown", 32, new MetaNode[] {
                   new Unused(32),
               }),
               new Reflexive("Unknown", 4, new MetaNode[] {
                   new Unused(4),
               }),
               new Reflexive("Unknown", 4, new MetaNode[] {
                   new Unused(4),
               }),
           }),
           new Reflexive("Unknown", 64, new MetaNode[] {
               new Unused(32),
               new Reflexive("Unknown", 32, new MetaNode[] {
                   new Unused(32),
               }),
               new Unused(8),
               new Reflexive("Unknown", 4, new MetaNode[] {
                   new Unused(4),
               }),
               new Unused(8),
           }),
       }),
       new TagReference("Decorators"),
       new Reflexive("MOPP Code", 1, 16, new MetaNode[] { 
           new Value("Data", typeof(byte)),
       }),
       new Unused(4),
       new Value("MOPP Bounds Min X", typeof(float)),
       new Value("MOPP Bounds Min Y", typeof(float)),
       new Value("MOPP Bounds Min Z", typeof(float)),
       new Value("MOPP Bounds Max X", typeof(float)),
       new Value("MOPP Bounds Max Y", typeof(float)),
       new Value("MOPP Bounds Max Z", typeof(float)),
       new Reflexive("MOPP Code", 1, 16, new MetaNode[] { 
           new Value("Data", typeof(byte)),
       }),
       new Reflexive("Breakable Surface Key Table", 32, new MetaNode[] { 
           new Value("Instance Geometry Index", typeof(short)),
           new Value("Breakable Surface Index", typeof(short)),
           new Value("Seed Surface Index", typeof(int)),
           new Value("X0", typeof(float)),
           new Value("X1", typeof(float)),
           new Value("Y0", typeof(float)),
           new Value("Y1", typeof(float)),
           new Value("Z0", typeof(float)),
           new Value("Z1", typeof(float)),
       }),
       new Reflexive("Water Definitions", 172, new MetaNode[] { 
           new TagReference("Shader"),
           new Reflexive("Section", 64, new MetaNode[] { 
               new Reflexive("Parts", 0, new MetaNode[] { 
               }),
               new Reflexive("Subparts", 0, new MetaNode[] { 
               }),
               new Reflexive("Visibility Bounds", 0, new MetaNode[] { 
               }),
               new Reflexive("Raw Vertices", 0, new MetaNode[] { 
               }),
               new Reflexive("Strip Indices", 0, new MetaNode[] { 
               }),
               new Reflexive("Visibility MOPP Code", 1, new MetaNode[] { 
                   new Value("Data", typeof(byte)),
               }),
               new Reflexive("MOPP Reorder Table", 0, new MetaNode[] { 
               }),
               new Reflexive("Vertex Buffers", 0, new MetaNode[] { 
               }),
           }),
           new Value("Block Offset", typeof(int)),
           new Value("Block Size", typeof(int)),
           new Value("Section Data Size", typeof(int)),
           new Value("Resource Data Size", typeof(int)),
           new Reflexive("Resources", 16, new MetaNode[] { 
               new HaloObjects.Enum("Type", new string[] {  }, 16),
               new Value("Primary Locator", typeof(short)),
               new Value("Secondary Locator", typeof(short)),
               new Value("Resource Size", typeof(short)),
               new Value("Resource Data Size", typeof(int)),
               new Value("Resource Data Offset", typeof(int)),
           }),
           new Value("Unknown", typeof(int)),
           new Value("Unknown", typeof(int)),
           new Ident("Owner Tag Section Offset"),
           //new Value("Unknown", typeof(short)),
           new Value("Sun Spot Color R", typeof(float)),
           new Value("Sun Spot Color G", typeof(float)),
           new Value("Sun Spot Color B", typeof(float)),
           new Value("Reflection Tint R", typeof(float)),
           new Value("Reflection Tint G", typeof(float)),
           new Value("Reflection Tint B", typeof(float)),
           new Value("Refraction Tint R", typeof(float)),
           new Value("Refraction Tint G", typeof(float)),
           new Value("Refraction Tint B", typeof(float)),
           new Value("Horizion Color R", typeof(float)),
           new Value("Horizion Color G", typeof(float)),
           new Value("Horizion Color B", typeof(float)),
           new Value("Sun Specular Power", typeof(float)),
           new Value("Reflection Bump Scale", typeof(float)),
           new Value("Refraction Bump Scale", typeof(float)),
           new Value("Fresnel Scale", typeof(float)),
           new Value("Sun Dir Heading", typeof(float)),
           new Value("Sun Dir Pitch", typeof(float)),
           new Value("FOV", typeof(float)),
           new Value("Aspect", typeof(float)),
           new Value("Height", typeof(float)),
           new Value("Farz", typeof(float)),
           new Value("Rotate Offset", typeof(float)),
           new Value("Center i", typeof(float)),
           new Value("Center j", typeof(float)),
           new Value("Extents i", typeof(float)),
           new Value("Extents j", typeof(float)),
           new Value("Fog Near", typeof(float)),
           new Value("Fog Far", typeof(float)),
           new Value("Dynamic Height Bias", typeof(float)),
       }),
       new Reflexive("Portal - Device Mapping", 16, new MetaNode[] { 
           new Reflexive("Device Portal Association", 14, new MetaNode[] { 
               new Value("Unique ID", typeof(int)),
               new Value("Origin BSP Index", typeof(short)),
               new HaloObjects.Enum("Type", new string[] {  }, 16),
               new Value("First Game Potal Index", typeof(short)),
               new Value("Game Portal Count", typeof(short)),
               new Unused(2),
           }),
           new Reflexive("Game Portal To Portal Map", 4, new MetaNode[] { 
               new Value("Portal Index", typeof(short)),
               new Unused(2),
           }),
       }),
       new Reflexive("Audibility", 52, new MetaNode[] { 
           new Value("Door Portal Count", typeof(int)),
           new Value("Cluster Distance Bounds", typeof(float)),
           new Value("...To", typeof(float)),
           new Reflexive("Encoded Door Pas", 4, new MetaNode[] { 
               new Value("Unknown", typeof(int)),
           }),
           new Reflexive("Cluster Door Portal Encoded Pas", 4, new MetaNode[] { 
               new Value("Unknown", typeof(int)),
           }),
           new Reflexive("AI Deafening Pas", 4, new MetaNode[] {
               new Value("Unknown", typeof(int)),
           }),
           // Was 4
           new Reflexive("Cluster Distances", 1, new MetaNode[] {
               new Value("Unknown", typeof(byte)),
           }),
           // Was 4
           new Reflexive("Machine Door Mapping", 1, new MetaNode[] { 
               new Value("Unknown", typeof(byte)),
               //new Value("Machine Door Index", typeof(short)),
               //new Unused(2),
           }),
       }),
       new Reflexive("Object Fake Lightprobes", 92, new MetaNode[] { 
           new Value("Unique ID", typeof(int)),
           new Value("Origin BSP Index", typeof(short)),
           new HaloObjects.Enum("Type", new string[] {  }, 16),
           new HaloObjects.Enum("Source", new string[] { }, 16),
           new Value("Unknown", typeof(short)),
           new Value("Ambient R", typeof(float)),
           new Value("Ambient G", typeof(float)),
           new Value("Ambient B", typeof(float)),
           new Value("Shadow Direction i", typeof(float)),
           new Value("Shadow Direction j", typeof(float)),
           new Value("Shadow Direction k", typeof(float)),
           new Value("Lighting Accuracy", typeof(float)),
           new Value("Shadow Opacity", typeof(float)),
           new Value("Primary Direction Color R", typeof(float)),
           new Value("Primary Direction Color G", typeof(float)),
           new Value("Primary Direction Color B", typeof(float)),
           new Value("Primary Direction i", typeof(float)),
           new Value("Primary Direction j", typeof(float)),
           new Value("Primary Direction k", typeof(float)),
           new Value("Secondary Direction Color R", typeof(float)),
           new Value("Secondary Direction Color G", typeof(float)),
           new Value("Secondary Direction Color B", typeof(float)),
           new Value("Secondary Direction i", typeof(float)),
           new Value("Secondary Direction j", typeof(float)),
           new Value("Secondary Direction k", typeof(float)),
       }),
       new Reflexive("Decorators", 48, new MetaNode[] { 
           new Value("Grid Origin X", typeof(float)),
           new Value("Grid Origin Y", typeof(float)),
           new Value("Grid Origin Z", typeof(float)),
           new Value("Cell Count Per Dimension", typeof(float)),
           new Reflexive("Cache Blocks", 44, new MetaNode[] { 
               new Value("Block Offset", typeof(uint)),
               new Value("Block Size", typeof(uint)),
               new Value("Section Data Size", typeof(uint)),
               new Value("Resource Data Size", typeof(uint)),
               new Reflexive("Resources", 16, new MetaNode[] { 
                   new HaloObjects.Enum("Type", new string[] {  }, 32),
                   new Value("Primary Locator", typeof(short)),
                   new Value("Secondary Locator", typeof(short)),
                   new Value("Resource Data Size", typeof(uint)),
                   new Value("Resource Data Offset", typeof(uint)),
               }),
               new Ident("Owner Tag Section Offset"),
               new Value("Unknown", typeof(int)),
               new Value("Unknown", typeof(int)),
               new Reflexive("Cache Block Data", 40, new MetaNode[] { 
                   new Reflexive("Placements", 0, new MetaNode[] { 
                   }),
                   new Reflexive("Decal Vertices", 0, new MetaNode[] { 
                   }),
                   new Reflexive("Decal Indices", 0, new MetaNode[] { 
                   }),
                   new Reflexive("Sprite Vertices", 0, new MetaNode[] { 
                   }),
                   new Reflexive("Sprite Indices", 0, new MetaNode[] { 
                   }),
               }),
           }),
           new Reflexive("Groups", 24, new MetaNode[] { 
               new Value("Decorator Set", typeof(short)),
               new HaloObjects.Enum("Decorator Type", new string[] { "Model", "Floating_Decal", "Projected_Decal", "Screen_Facing_Quad", "Axis_Rotating_Quad", "Cross_Quad" }, 32),
               new Value("Shader Index", typeof(short)),
               new Value("Compressed Radius", typeof(short)),
               new Value("Cluster", typeof(short)),
               new Value("Cache Block #", typeof(short)),
               new Value("Decorator Start Index", typeof(byte)),
               new Value("Decorator Count", typeof(byte)),
               new Value("Vertex Start Offset", typeof(byte)),
               new Value("Vertex Count", typeof(byte)),
               new Value("Index Start Offset", typeof(byte)),
               new Value("Index Count", typeof(byte)),
               new Value("Compressed Bounding Center", typeof(float)),
           }),
           new Reflexive("Cells", 24, new MetaNode[] { 
               new Value("Child Index", typeof(short)),
               new Value("Child Index", typeof(short)),
               new Value("Child Index", typeof(short)),
               new Value("Child Index", typeof(short)),
               new Value("Child Index", typeof(short)),
               new Value("Child Index", typeof(short)),
               new Value("Child Index", typeof(short)),
               new Value("Child Index", typeof(short)),
               new Value("Cache Block Index", typeof(short)),
               new Value("Group Count", typeof(short)),
               new Value("Group Start Index", typeof(int)),
           }),
           new Reflexive("Decals", 68, new MetaNode[] { 
               new Value("Decorator Set", typeof(short)),
               new Value("Decorator Class", typeof(short)),
               new Value("Decorator Permutation", typeof(short)),
               new Value("Sprite Index", typeof(short)),
               new Value("Position X", typeof(float)),
               new Value("Position Y", typeof(float)),
               new Value("Position Z", typeof(float)),
               new Value("Left i", typeof(float)),
               new Value("Left j", typeof(float)),
               new Value("Left k", typeof(float)),
               new Value("Up i", typeof(float)),
               new Value("Up j", typeof(float)),
               new Value("Up k", typeof(float)),
               new Value("Extents i", typeof(float)),
               new Value("Extents j", typeof(float)),
               new Value("Extents k", typeof(float)),
               new Value("Previous Position X", typeof(float)),
               new Value("Previous Position Y", typeof(float)),
               new Value("Previous Position Z", typeof(float)),
           }),
       }),
       });
   }
    }
}
