Files
Leviathan/Client/Game/game/DB/SMonsterDB.h
T
2026-06-01 12:46:52 +02:00

237 lines
4.9 KiB
C++

#pragma once
//#include <string>
#include <toolkit/khash.h>
#include <mmo/ArType.h>
#include "K3DTypes.h"
#include "Enc.h"
#include "SLog.h"
#include "SStringDB.h"
#include "MonsterBase.h"
#include "GameRule.h"
//////////////////////////////////////////////////////////////////////////
/// 몬스터 리소스 데이타 관리.
class SMonsterDB
{
public:
SMonsterDB();
~SMonsterDB();
inline _MONSTER_INFO_FILE* GetMonsterData( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE * pFindMob = NULL;
if( m_hashMonster.lookup( nMonsterID, pFindMob ) == false )
{
return NULL;
}
return pFindMob;
}
inline int GetTextID( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->name_id;
return -1;
}
inline const char * GetCobFileName( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
{
return pMob->model;
}
return "Empty_String";
}
inline AR_UNIT GetScale( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->scale;
return 1.f;
}
inline AR_UNIT GetSize( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->size;
return GameRule::DEFAULT_HUMAN_SIZE;
}
inline int GetMobLevel( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->level;
return 0;
}
inline int GetMobAttackType( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->monster_type;
return 0;
}
inline int GetFightType( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->fight_type;
return 0;
}
inline int GetSlantType( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE * pFindMob = NULL;
if( m_hashMonster.lookup( nMonsterID, pFindMob ) == false )
{
return 0;
}
return pFindMob->slant_type;
}
inline int GetMotionSpeed( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
{
return pMob->nAttack_motion_speed;
}
return 0;
}
inline K3DVertex GetMonsterCameraPos( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
{
return K3DVertex( pMob->nCamera_x, pMob->nCamera_y, pMob->nCamera_z );
}
return K3DVertex(0,-8,1);
}
inline int GetWalkType( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob ) return pMob->walk_type;
return 0;
}
inline int GetGradeIconID( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->monster_grade_icon;
return 0;
}
std::string GetGradeString( const int nRank )
{
std::string strGrade( "" );
switch( nRank )
{
case MonsterBase::MONSTER_INSTANCE: strGrade.append( S( 690000070 ) /*인스턴스 몬스터*/ ); break;
case MonsterBase::MONSTER_BASIC: strGrade.append( S( 690000071 ) /*베이직 몬스터*/ ); break;
case MonsterBase::MONSTER_RARE: strGrade.append( S( 690000072 ) /*"레어 몬스터*/ ); break;
case MonsterBase::MONSTER_SPECIAL: strGrade.append( S( 690000073 ) /*스페셜 몬스터*/ ); break;
case MonsterBase::MONSTER_UNIQUE: strGrade.append( S( 690000074 ) /*유니크 몬스터*/ ); break;
case MonsterBase::MONSTER_UNKNOWN: strGrade.append( "추후 새로 추가 될 등급" ); break;
default:
{
SDEBUGLOG( "[몬스터 DB] 알수 없는 몬스터 등급 입니다. - [%u]", nRank );
assert( NULL );
}
break;
}
return strGrade;
}
inline bool IsPossibleTaming( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
{
if( pMob->taming_code ||
pMob->creature_taming_code )
return true;
}
return false;
}
inline int GetSpeciesID( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->species_id;
return 0;
}
inline int GetAffiliationID( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->affiliation_id;
return 0;
}
inline int GetAffiliationDetailID( ENC_INT nMonsterID )
{
_MONSTER_INFO_FILE* pMob = GetMonsterData(nMonsterID);
if( pMob )
return pMob->affiliationDetail_id;
return 0;
}
void ReLoad();
protected:
void Init();
void Destroy();
void Load();
struct hashPr_mod_ENC_INT
{
typedef ENC_INT Key;
static inline unsigned getindex( const Key& key, int nCapacity ) { return unsigned( key.hash_id() ) % nCapacity; }
static inline bool isequal( const Key& key1, const Key& key2 ) { return key1 == key2; }
static inline bool isless( const Key& key1, const Key& key2 ) { return key1.prior( key2 ); }
};
KHash< _MONSTER_INFO_FILE*, hashPr_mod_ENC_INT > m_hashMonster;
public:
static SMonsterDB* m_pThis;
};
SMonsterDB & GetMonsterDB();