2010-05-29 07:25:38 +00:00
|
|
|
#include "layers.h"
|
2008-01-13 11:15:32 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CLayers::CLayers()
|
|
|
|
{
|
|
|
|
m_GroupsNum = 0;
|
|
|
|
m_GroupsStart = 0;
|
|
|
|
m_LayersNum = 0;
|
|
|
|
m_LayersStart = 0;
|
|
|
|
m_pGameGroup = 0;
|
|
|
|
m_pGameLayer = 0;
|
2010-08-10 04:28:17 +00:00
|
|
|
m_pTeleLayer = 0;
|
|
|
|
m_pSpeedupLayer = 0;
|
2010-08-27 05:19:10 +00:00
|
|
|
m_pFrontLayer = 0;
|
2010-08-27 23:30:50 +00:00
|
|
|
m_pSwitchLayer = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pMap = 0;
|
|
|
|
}
|
2008-01-13 11:15:32 +00:00
|
|
|
|
2010-10-06 21:44:10 +00:00
|
|
|
void CLayers::Dest()
|
|
|
|
{
|
|
|
|
m_GroupsNum = 0;
|
|
|
|
m_GroupsStart = 0;
|
|
|
|
m_LayersNum = 0;
|
|
|
|
m_LayersStart = 0;
|
|
|
|
m_pGameGroup = 0;
|
|
|
|
m_pGameLayer = 0;
|
|
|
|
m_pTeleLayer = 0;
|
|
|
|
m_pSpeedupLayer = 0;
|
|
|
|
m_pFrontLayer = 0;
|
|
|
|
m_pSwitchLayer = 0;
|
|
|
|
m_pMap = 0;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CLayers::Init(class IKernel *pKernel)
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pMap = pKernel->RequestInterface<IMap>();
|
|
|
|
m_pMap->GetType(MAPITEMTYPE_GROUP, &m_GroupsStart, &m_GroupsNum);
|
|
|
|
m_pMap->GetType(MAPITEMTYPE_LAYER, &m_LayersStart, &m_LayersNum);
|
2008-01-13 11:15:32 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int g = 0; g < NumGroups(); g++)
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemGroup *pGroup = GetGroup(g);
|
|
|
|
for(int l = 0; l < pGroup->m_NumLayers; l++)
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemLayer *pLayer = GetLayer(pGroup->m_StartLayer+l);
|
2008-03-29 11:44:03 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pLayer->m_Type == LAYERTYPE_TILES)
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemLayerTilemap *pTilemap = reinterpret_cast<CMapItemLayerTilemap *>(pLayer);
|
|
|
|
if(pTilemap->m_Flags&1)
|
2008-01-29 21:39:41 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pGameLayer = pTilemap;
|
|
|
|
m_pGameGroup = pGroup;
|
|
|
|
|
|
|
|
// make sure the game group has standard settings
|
|
|
|
m_pGameGroup->m_OffsetX = 0;
|
|
|
|
m_pGameGroup->m_OffsetY = 0;
|
|
|
|
m_pGameGroup->m_ParallaxX = 100;
|
|
|
|
m_pGameGroup->m_ParallaxY = 100;
|
|
|
|
m_pGameGroup->m_UseClipping = 0;
|
|
|
|
m_pGameGroup->m_ClipX = 0;
|
|
|
|
m_pGameGroup->m_ClipY = 0;
|
|
|
|
m_pGameGroup->m_ClipW = 0;
|
|
|
|
m_pGameGroup->m_ClipH = 0;
|
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
//break;
|
2008-01-29 21:39:41 +00:00
|
|
|
}
|
2010-08-10 04:28:17 +00:00
|
|
|
if(pTilemap->m_Flags&2)
|
|
|
|
m_pTeleLayer = pTilemap;
|
|
|
|
if(pTilemap->m_Flags&4)
|
|
|
|
m_pSpeedupLayer = pTilemap;
|
2010-08-27 05:19:10 +00:00
|
|
|
if(pTilemap->m_Flags&8)
|
|
|
|
m_pFrontLayer = pTilemap;
|
2010-08-27 23:30:50 +00:00
|
|
|
if(pTilemap->m_Flags&16)
|
|
|
|
m_pSwitchLayer = pTilemap;
|
2010-08-25 14:15:59 +00:00
|
|
|
}
|
2008-01-13 11:15:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemGroup *CLayers::GetGroup(int Index) const
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
return static_cast<CMapItemGroup *>(m_pMap->GetItem(m_GroupsStart+Index, 0, 0));
|
2008-01-13 11:15:32 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemLayer *CLayers::GetLayer(int Index) const
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
return static_cast<CMapItemLayer *>(m_pMap->GetItem(m_LayersStart+Index, 0, 0));
|
2008-01-13 11:15:32 +00:00
|
|
|
}
|