#pragma once #include //#include #include "K3DTypes.h" #include "NpcResource.h" #include "Enc.h" #include "SStringDB.h" class KUIWnd; struct NpcResourceClient : public NpcResourceBase { ENC_INT real_uid; }; // QA 테스트 시 NPC 아이디 확인을 위한 구조체 ( 개발 시 에만 쓰임 ) typedef struct stNpcIdentityforDev { int m_uNpcID; string m_strNpcName; stNpcIdentityforDev() : m_strNpcName( "" ) { } }NPCIDENTITYFORDEV; class SNpcResourceDB { protected: 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< NpcResourceClient*, hashPr_mod_ENC_INT > m_hashNpcResource; KHash< NpcEventPeriodResourceBase*, hashPr_mod_ENC_INT > m_hashNpcEventPeriodResource; void Init(); void Destroy(); void Load(); public: inline NpcEventPeriodResourceBase* GetNpcPeriodInfo( int nID ) { NpcEventPeriodResourceBase *pFindNPC = NULL; if( m_hashNpcEventPeriodResource.lookup( nID, pFindNPC ) ) { return pFindNPC; } return NULL; } inline NpcResourceBase* GetNpcInfo( ENC_INT nID ) { NpcResourceClient* pFindItem = NULL; if( m_hashNpcResource.lookup( nID, pFindItem ) ) { return pFindItem; } return NULL; } inline int GetNpcModelID( ENC_INT nID ) { NpcResourceClient* pFindItem = NULL; if( m_hashNpcResource.lookup( nID, pFindItem ) ) { // return pFindItem->; } return 0; } inline const char* GetNpcName( ENC_INT nID ) { NpcResourceClient* pFindItem = NULL; if( m_hashNpcResource.lookup( nID, pFindItem ) ) { return GetStringDB().GetString( pFindItem->name_text_id ); } return "Not Found"; } inline const char* GetNpcJobName( ENC_INT nID ) { NpcResourceClient* pFindItem = NULL; if( m_hashNpcResource.lookup( nID, pFindItem ) ) { return GetStringDB().GetString( pFindItem->text_id ); } return "Not Found"; } inline const char* GetCobFileName( ENC_INT nID ) { NpcResourceClient* pFindItem = NULL; if( m_hashNpcResource.lookup( nID, pFindItem ) ) { return pFindItem->model_file; } return "Not Found"; } inline void GetFaceCut( ENC_INT nID, K3DVector & vPos ) { NpcResourceClient* pFindItem = NULL; if( m_hashNpcResource.lookup( nID, pFindItem ) ) { vPos.x = (float)pFindItem->face_x; vPos.y = (float)pFindItem->face_y; vPos.z = (float)pFindItem->face_z; } } inline float GetDirection( ENC_INT nID ) { NpcResourceClient* pFindItem = NULL; if( m_hashNpcResource.lookup( nID, pFindItem ) ) { return (float)pFindItem->face; } return 0.0f; } struct NPCPosInfo { NPCPosInfo( ENC_INT id, const char *szName, int _x, int _y ) : nID( id ), strName( szName ), x( _x ), y (_y ) {} ENC_INT nID; std::string strName; int x, y; }; struct NPCRenderInfo : public NPCPosInfo { /// 2011.03.18 - prodongi NPCRenderInfo( ENC_INT id, const char *szName, int _x, int _y, char _is_periodic, int _begin_of_period, int _end_of_period, char _type ) : NPCPosInfo( id, szName, _x, _y), wnd(NULL), zoomWnd(NULL), is_render(false), is_periodic(_is_periodic), begin_of_period(_begin_of_period), end_of_period(_end_of_period), type(_type) { } bool is_render; char is_periodic; int begin_of_period; int end_of_period; KUIWnd* wnd; KUIWnd* zoomWnd; /// 2011.03.18 - prodongi char type; }; int GetNpcItemCode( int nWearType, NpcResourceBase* pNpcResource ); void EnumNPC( std::vector< NPCRenderInfo > * pList ); vector GetNpcIdentityList( string strFindItemName ); public: SNpcResourceDB(); ~SNpcResourceDB(); static SNpcResourceDB* m_pThis; }; SNpcResourceDB & GetNpcResourceDB();