Files
mir_server/server/LogicServer/base/BoxDrop.h

161 lines
3.5 KiB
C
Raw Normal View History

2025-01-09 17:45:40 +08:00
#pragma once
//////////////////////////////////////////////////////////////////////////
// 宝箱掉落类,负责加载掉落配置和执行掉落
//
class CBoxDropMgr;
class CBoxDrop : public CBaseScriptExportObject, public CCustomLogicLuaConfig
{
public:
friend class CBoxDropMgr;
typedef CBaseScriptExportObject Inherit;
CBoxDrop();
/*
* Comments:
* Param const char * pFile:
* @Return bool: truefalse
* @Remark:
drop = {
{ id=522 ,count=1,strong =0,quality =-1,propability=10800, group=0},
{ id=523 ,count=1,strong =0,quality =-1,propability=10800, group=0},
{ id=524 ,count=1,strong =0,quality =-1,propability=10800, group=0},
}
*/
bool load(const char *pFile);
/*
* Comments:
* @Return DropItemList:
*/
DropItemList drop(void * pEntity =0);
/*
* Comments:
* @Return DropItemList:
*/
DropItemList proabilityDrop(void * pEntity =0);
/*
* Comments: release会减少引用计数0destroy销毁对象
* @Return void:
*/
void destroy();
inline virtual const char* getClassName() const
{
return CBoxDrop::m_sClassName;
}
protected:
~CBoxDrop(){}
/*
* Comments:
* @Return bool:
*/
bool loadData();
/*
* Comments:
* @Return void:
*/
void releaseData();
//设置物品的属性
void SetItemInfo(DropItemList& pInfo,ONEDROPDATA * pData );
/*
* Comments:
* Param ONEDROPDATA * pData:
* Param int sex:
* Param int job:
* @Return bool: truefalse
*/
inline bool CanDrop(ONEDROPDATA *pData, int sex, int job)
{
if(pData->bSex >=0 && sex >=0 && pData->bSex != sex)
{
return false;
}
if(pData->bJob > 0 && job > 0 && pData->bJob != job)
{
return false;
}
return true;
}
private:
DROPGROUP m_dropGroup;
static TCHAR m_sClassName[32];
DECLARE_OBJECT_COUNTER(CBoxDrop)
};
//////////////////////////////////////////////////////////////////////////
// 宝箱掉落管理器;负责管理宝箱管理对象
class CBoxDropMgr
{
public:
CBoxDropMgr() : m_dataAllocator("CBoxDropMgr"){}
virtual ~CBoxDropMgr();
/*
* Comments:
* @Return CBoxDropMgr&:
*/
static CBoxDropMgr& getSingleton();
/*
* Comments:
* @Return void:
*/
static void initialize();
/*
* Comments:
* @Return void:
*/
static void release();
/*
* Comments:
* Param const char * pKey:
* Param bool bAddToGOMgr:
* @Return CBoxDrop*:
*/
CBoxDrop* createBoxDrop(const char *pKey);
/*
* Comments:
* Param CBoxDrop * bd:
* @Return void:
* @CBoxDrop::release()
*/
void destroyBoxDrop(CBoxDrop *bd);
static CBoxDropMgr *s_BoxDropMgr;
static LONG s_boxDropMgrCnt;
protected:
/*
* Comments:
* Param CBoxDrop * bd:
* @Return void:
* @Remark:
*/
void removeFromList(CBoxDrop *bd);
void destroyBoxDropImpl(CBoxDrop *bd);
private:
CSingleObjectAllocator<CBoxDrop> m_dataAllocator;
CVector<CBoxDrop*> m_boxObjectList;
};