#ifndef CMAPOBJ_H
#define CMAPOBJ_H

#include "tempest/box.h"
#include "async/object.h"
#include "map/WMOchunks.h"
#include "tempest/vector.h"
#include "storm/list.h"
#include "map/VBBList.h"

DECLARE_STRUCT(CMapObj);
DECLARE_STRUCT(CMapObjGroup);

STORM_TS_LIST(CMapObjGroup);

struct CMapObjGroup;

struct CMapObj
{
    int32_t objectIndex;
    int32_t unk_04;
    int32_t unk_08;
    CMapObj* mapObjPtr1;
    int32_t unk_10;
    CMapObj* mapObjPtr2;
    int32_t unk_18;
    char m_wmoName[260];
    SMOHeader *header;
    char* textureNameList;
    char* groupNameList;
    char* skybox;
    SMOGroupInfo* groupInfo;
    C3Vector* portalVertexList;
    SMOPortal* portalList;
    SMOPortalRef* portalRefList;
    C3Vector* visBlockVertList;
    SMOVisibleBlock* visBlockList;
    SMOLight* lightList;
    SMODoodadSet* doodadSetList;
    char* doodadNameList;
    SMODoodadDef* doodadDefList;
    SMOFog* fogList;
    C4Plane* convexVolumePlanes;
    SMOMaterial* materialList;
    int32_t texturesSize;
    int32_t groupNameSize;
    int32_t groupInfoCount;
    int32_t planeVertCount;
    int32_t portalsCount;
    int32_t portalRefCount;
    int32_t visBlockVertCount;
    int32_t visBlockCount;
    int32_t ligtsCount;
    int32_t doodadSetCount;
    int32_t doodadNameSize;
    int32_t doodadDefCount;
    int32_t fogsCount;
    int32_t convexVolumePlaneCount;
    int32_t materialsCount;
    uint32_t argb_color;
    int32_t unk_1A4;
    CAaBox bbox;
    float distToCamera;
    int32_t unk_1C4;
    int32_t unk_1C8;
    void* pWmoData;
    int32_t wmoFileSize;
    int32_t refCount;
    float flushTimer;
    CAsyncObject* asyncObject;
    int32_t isGroupLoaded;
    int32_t unk_1E4;
    TSExplicitList_CMapObjGroup mapObjGroupList;
    int32_t mapObjGroupCount;
    CMapObjGroup* mapObjGroupArray[512];
};

struct CMapObjGroup
{
    int32_t objectIndex;
    VBBList_Block* vertsBlock;
    VBBList_Block* transparencyVertsBlock;
    VBBList_Block* indicesBlock;
    VBBList_Block* liquidVertsBlock;
    VBBList_Block* liquidIndicesBlock;
    float timer;
    void* unk_1C;
    int32_t unk_20;
    int32_t unk_24;
    int32_t unk_28;
    int16_t unk_2C[2];
    int32_t flags;
    CAaBox bbox;
    float distToCamera;
    int32_t portalStart;
    int32_t portalCount;
    int32_t fogs;
    uint16_t transparencyBatchesCount;
    uint16_t intBatchCount;
    int32_t extBatchCount;
    void* CAaBspNodePtr1;
    void* CAaBspNodePtr2;
    uint16_t* nodeFaceIndices;
    int32_t bspNodesCount;
    int32_t nodeFaceIndicesCount;
    int32_t unk_7C;
    int32_t unk_80;
    int32_t unk_84;
    int32_t unk_88;
    int32_t unk_8C;
    int32_t unk_90;
    int32_t unk_94;
    int32_t unk_98;
    int32_t unk_9C;
    int32_t unk_A0;
    int32_t unk_A4;
    int32_t unk_A8;
    int32_t unk_AC;
    int32_t unk_B0;
    CAaBox bbox2;
    int32_t unk_CC;
    int32_t unkFlags;
    int32_t unk_D4;
    int32_t minimapTag;
    char* groupName;
    SMOPoly* polyList;
    uint16_t* indices;
    int32_t unk_E8;
    C3Vector* vertexList;
    C3Vector* normalList;
    C2Vector* textureVertexList;
    int32_t unk_F8;
    SMOBatch* batchList;
    int32_t unk_100;
    int32_t unk_104;
    uint16_t* doodadRefList;
    CImVector* colorVertexList;
    CImVector* colorVertexListExtra;
    int32_t unk_114;
    C2iVector liquidVerts;
    C2iVector liquidTiles;
    C3Vector liquidCorner;
    int32_t luquidMaterialId;
    SMOLiquidVert* liquidVertexList;
    SMOLTile* liquidTileList;
    float liquidHeight;
    int32_t unk_144;
    int32_t unk_148;
    int32_t unkFlag;
    int32_t unk_150;
    int32_t polyListSize;
    int32_t indicesCount;
    int32_t unk_15C;
    int32_t vertexListCount;
    int32_t normalListCount;
    int32_t textureVertexListCount;
    int32_t unk_16C;
    int32_t batchListCount;
    int32_t unk_174;
    int32_t doodadRefListCount;
    int32_t colorVertexListSize;
    int32_t colorVertexListExtraSize;

    int32_t wmoGroupId;
    void* filePtr;
    int32_t fileSize;
    CMapObj* parent;
    int32_t unk_194;
    CAsyncObject* asyncObjPtr;
    int32_t unkLoadedFlag;
    int32_t unkIndexMin1;
    int32_t unkIndexMax1;
    uint16_t unkIndexMin2;
    uint16_t unkIndexMax2;
    int32_t TSExplicitList__m_linkoffset;
    void* TSExplicitList__ptr;
    void* TSExplicitList__ptr2;
    CMapObjGroup* perv;
    CMapObjGroup* next;
};

#endif