Files
Leviathan/Client/Game/engine/TerrainEngine/TerrainLowQualityWaterInfo.h
T
2026-06-01 12:46:52 +02:00

111 lines
3.3 KiB
C++

#pragma once
#include "EnvironmentInfo.h"
#include "TerrainSeamlessWorldInfoForClient.h"
class CTerrainLowQualityWaterInfo
{
public:
enum INFO_STATE
{
_LOAD_INFO_ = 0,
_DELETE_INFO_,
_COMPLETE_INFO_,
};
private:
std::string m_strWaterFileName;
int m_nMapX;
int m_nMapY;
int m_nSegMentCount; ///< 이넘이 0이면 더이상 그려지는 세그먼트가 없다는 뜻
WATERAREA_HEADER* m_pLQWaterInfo;
int m_nWaterCount;
int m_nWaterAttribute;
int m_nWaterType;
INFO_STATE m_nState;
public:
bool CheckMap( int nMapX, int nMapY )
{
if( nMapX == m_nMapX && nMapY == m_nMapY )
return true;
return false;
}
void AddSegMent()
{
m_nSegMentCount += 1;
if( m_nState == _DELETE_INFO_ )
m_nState = _LOAD_INFO_;
}
void DeleteSegMent()
{
m_nSegMentCount -= 1;
if(m_nSegMentCount <= 0)
m_nState = _DELETE_INFO_;
}
void SetCompleteInfo() { m_nState = _COMPLETE_INFO_; }
int GetWaterCount() { return m_nWaterCount; }
INFO_STATE GetState() { return m_nState; }
WATERAREA_HEADER* GetWaterInfo(int nCount){ return &m_pLQWaterInfo[nCount]; }
int GetMapX() { return m_nMapX; }
int GetMapY() { return m_nMapY; }
public:
CTerrainLowQualityWaterInfo( KStream* pStream, const CTerrainSeamlessWorldInfo* pSeamlessWorldInfo,
const char* szWaterFileName, int nMapX, int nMapY) : m_nMapX(0)
, m_nMapY(0)
, m_nSegMentCount(1)
, m_nWaterCount(0)
, m_pLQWaterInfo(NULL)
, m_nWaterAttribute( 0 )
, m_nWaterType( 0 )
, m_nState( _DELETE_INFO_ )
{
float fMapLen = float( pSeamlessWorldInfo->GetTileCountPerSegment() ) * float(pSeamlessWorldInfo->GetSegmentCountPerMap() ) * pSeamlessWorldInfo->GetTileLength();
m_strWaterFileName = szWaterFileName;
m_nMapX = nMapX;
m_nMapY = nMapY;
pStream->Read( &m_nWaterCount, sizeof( m_nWaterCount ) );
if(m_nWaterCount > 0)
{
m_nState = _LOAD_INFO_;
m_pLQWaterInfo = new WATERAREA_HEADER[m_nWaterCount];
for( int x = 0; x < m_nWaterCount; x++ )
{
pStream->Read( &m_pLQWaterInfo[x], sizeof( m_pLQWaterInfo[x] ) );
m_pLQWaterInfo[x].vLeftTop.x += (int)( (float)nMapX * fMapLen );
m_pLQWaterInfo[x].vLeftTop.y += (int)( (float)nMapY * fMapLen );
m_pLQWaterInfo[x].vRightBottom.x += (int)( (float)nMapX * fMapLen );
m_pLQWaterInfo[x].vRightBottom.y += (int)( (float)nMapY * fMapLen );
m_pLQWaterInfo[x].vCenter.x += (int)( (float)nMapX * fMapLen );
m_pLQWaterInfo[x].vCenter.y += (int)( (float)nMapY * fMapLen );
m_pLQWaterInfo[x].vCenter.z = m_pLQWaterInfo[x].vLeftTop.z;
if( m_pLQWaterInfo[x].vLeftTop.x > m_pLQWaterInfo[x].vRightBottom.x )
{
float fTemp = m_pLQWaterInfo[x].vRightBottom.x;
m_pLQWaterInfo[x].vRightBottom.x = m_pLQWaterInfo[x].vLeftTop.x;
m_pLQWaterInfo[x].vLeftTop.x = fTemp;
}
if( m_pLQWaterInfo[x].vLeftTop.y < m_pLQWaterInfo[x].vRightBottom.y )
{
float fTemp = m_pLQWaterInfo[x].vRightBottom.y;
m_pLQWaterInfo[x].vRightBottom.y = m_pLQWaterInfo[x].vLeftTop.y;
m_pLQWaterInfo[x].vLeftTop.y = fTemp;
}
}
}
delete pStream;
}
~CTerrainLowQualityWaterInfo()
{
SAFE_DELETE_ARRAY(m_pLQWaterInfo);
}
};