本文整理汇总了C++中MapCell::SetLoaded方法的典型用法代码示例。如果您正苦于以下问题:C++ MapCell::SetLoaded方法的具体用法?C++ MapCell::SetLoaded怎么用?C++ MapCell::SetLoaded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapCell
的用法示例。
在下文中一共展示了MapCell::SetLoaded方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateAndSpawnGameObject
// Spawns the object too, without which you can not interact with the object
GameObject* MapMgr::CreateAndSpawnGameObject(uint32 entryID, float x, float y, float z, float o, float scale)
{
GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(entryID);
if(!goi)
{
LOG_DEBUG("Error looking up entry in CreateAndSpawnGameObject");
return NULL;
}
LOG_DEBUG("CreateAndSpawnGameObject: By Entry '%u'", entryID);
GameObject* go = CreateGameObject(entryID);
//Player *chr = m_session->GetPlayer();
uint32 mapid = GetMapId();
// Setup game object
go->CreateFromProto(entryID, mapid, x, y, z, o);
go->SetScale(scale);
go->InitAI();
go->PushToWorld(this);
// Create spawn instance
GOSpawn* gs = new GOSpawn;
gs->entry = go->GetEntry();
gs->facing = go->GetOrientation();
gs->faction = go->GetFaction();
gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
gs->id = objmgr.GenerateGameObjectSpawnID();
gs->o = 0.0f;
gs->o1 = go->GetParentRotation(0);
gs->o2 = go->GetParentRotation(2);
gs->o3 = go->GetParentRotation(3);
gs->scale = go->GetScale();
gs->x = go->GetPositionX();
gs->y = go->GetPositionY();
gs->z = go->GetPositionZ();
gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0);
//gs->stateNpcLink = 0;
gs->overrides = go->GetOverrides();
uint32 cx = GetPosX(x);
uint32 cy = GetPosY(y);
GetBaseMap()->GetSpawnsListAndCreate(cx, cy)->GOSpawns.push_back(gs);
go->m_spawn = gs;
MapCell* mCell = GetCell(cx, cy);
if(mCell != NULL)
mCell->SetLoaded();
return go;
}
示例2: HandleGOPhaseCommand
bool ChatHandler::HandleGOPhaseCommand(const char* args, WorldSession* m_session)
{
char* sPhase = strtok((char*)args, " ");
if(!sPhase)
return false;
uint32 newphase = atoi(sPhase);
bool Save = false;
char* pSave = strtok(NULL, " ");
if(pSave)
Save = (atoi(pSave) > 0 ? true : false);
GameObject* go = m_session->GetPlayer()->GetSelectedGo();
if(!go)
{
RedSystemMessage(m_session, "No selected GameObject...");
return true;
}
go->Phase(PHASE_SET, newphase);
GOSpawn* gs = go->m_spawn;
if(gs == NULL)
{
RedSystemMessage(m_session, "The GameObject got no spawn, not saving and not logging...");
return true;
}
//VLack: We have to have a spawn, or SaveToDB would write a 0 into the first column (ID), and would erroneously overwrite something in the DB.
//The code which saves creatures is a bit more forgiving, as it creates a new spawn on-demand, but the gameobject code does not.
gs->phase = go->GetPhase();
uint32 cx = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
uint32 cy = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());
MapCell* mCell = m_session->GetPlayer()->GetMapMgr()->GetCell(cx, cy);
if(mCell != NULL)
mCell->SetLoaded();
if(Save == true)
{
// If we're saving, create template and add index
go->SaveToDB();
go->m_loadedFromDB = true;
}
sGMLog.writefromsession(m_session, "phased gameobject %s to %u, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, newphase, gs->entry, m_session->GetPlayer()->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : "");
return true;
}
示例3: HandleGOSpawn
bool ChatHandler::HandleGOSpawn(const char* args, WorldSession* m_session)
{
std::stringstream sstext;
char* pEntryID = strtok((char*)args, " ");
if(!pEntryID)
return false;
uint32 EntryID = atoi(pEntryID);
bool Save = false;
char* pSave = strtok(NULL, " ");
if(pSave)
Save = (atoi(pSave) > 0 ? true : false);
GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(EntryID);
if(!goi)
{
sstext << "GameObject Info '" << EntryID << "' Not Found" << '\0';
SystemMessage(m_session, sstext.str().c_str());
return true;
}
LOG_DEBUG("Spawning GameObject By Entry '%u'", EntryID);
sstext << "Spawning GameObject By Entry '" << EntryID << "'" << '\0';
SystemMessage(m_session, sstext.str().c_str());
Player* chr = m_session->GetPlayer();
GameObject* go = chr->GetMapMgr()->CreateGameObject(EntryID);
uint32 mapid = chr->GetMapId();
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
go->CreateFromProto(EntryID, mapid, x, y, z, o);
go->PushToWorld(chr->GetMapMgr());
go->Phase(PHASE_SET, chr->GetPhase());
// Create spawn instance
GOSpawn* gs = new GOSpawn;
gs->entry = go->GetEntry();
gs->facing = go->GetOrientation();
gs->faction = go->GetFaction();
gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
gs->id = objmgr.GenerateGameObjectSpawnID();
gs->o = 0.0f;
gs->o1 = go->GetParentRotation(0);
gs->o2 = go->GetParentRotation(2);
gs->o3 = go->GetParentRotation(3);
gs->scale = go->GetScale();
gs->x = go->GetPositionX();
gs->y = go->GetPositionY();
gs->z = go->GetPositionZ();
gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0);
//gs->stateNpcLink = 0;
gs->phase = go->GetPhase();
gs->overrides = go->GetOverrides();
uint32 cx = chr->GetMapMgr()->GetPosX(chr->GetPositionX());
uint32 cy = chr->GetMapMgr()->GetPosY(chr->GetPositionY());
chr->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx, cy)->GOSpawns.push_back(gs);
go->m_spawn = gs;
MapCell* mCell = chr->GetMapMgr()->GetCell(cx, cy);
if(mCell != NULL)
mCell->SetLoaded();
if(Save == true)
{
// If we're saving, create template and add index
go->SaveToDB();
go->m_loadedFromDB = true;
}
sGMLog.writefromsession(m_session, "spawned gameobject %s, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, gs->entry, chr->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : "");
return true;
}
示例4: HandleGOSpawn
bool ChatHandler::HandleGOSpawn(const char *args, WorldSession *m_session)
{
std::stringstream sstext;
char* pEntryID = strtok((char*)args, " ");
if (!pEntryID)
return false;
uint32 EntryID = atoi(pEntryID);
bool Save = false;
char* pSave = strtok(NULL, " ");
if (pSave)
Save = (atoi(pSave)>0?true:false);
GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(EntryID);
if(!goi)
{
sstext << "GameObject Info '" << EntryID << "' Not Found" << '\0';
SystemMessage(m_session, sstext.str().c_str());
return true;
}
sLog.outDebug("Spawning GameObject By Entry '%u'", EntryID);
sstext << "Spawning GameObject By Entry '" << EntryID << "'" << '\0';
SystemMessage(m_session, sstext.str().c_str());
GameObject *go = m_session->GetPlayer()->GetMapMgr()->CreateGameObject(EntryID);
Player *chr = m_session->GetPlayer();
uint32 mapid = chr->GetMapId();
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
go->SetInstanceID(chr->GetInstanceID());
go->CreateFromProto(EntryID,mapid,x,y,z,o);
/* fuck blizz coordinate system */
go->SetFloatValue(GAMEOBJECT_ROTATION_02, sinf(o / 2));
go->SetFloatValue(GAMEOBJECT_ROTATION_03, cosf(o / 2));
go->PushToWorld(m_session->GetPlayer()->GetMapMgr());
// Create sapwn instance
GOSpawn * gs = new GOSpawn;
gs->entry = go->GetEntry();
gs->facing = go->GetOrientation();
gs->faction = go->GetUInt32Value(GAMEOBJECT_FACTION);
gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
gs->id = objmgr.GenerateGameObjectSpawnID();
gs->o = go->GetFloatValue(GAMEOBJECT_ROTATION);
gs->o1 = go->GetFloatValue(GAMEOBJECT_ROTATION_01);
gs->o2 = go->GetFloatValue(GAMEOBJECT_ROTATION_02);
gs->o3 = go->GetFloatValue(GAMEOBJECT_ROTATION_03);
gs->scale = go->GetFloatValue(OBJECT_FIELD_SCALE_X);
gs->x = go->GetPositionX();
gs->y = go->GetPositionY();
gs->z = go->GetPositionZ();
gs->state = go->GetUInt32Value(GAMEOBJECT_STATE);
//gs->stateNpcLink = 0;
uint32 cx = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
uint32 cy = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());
m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx,cy)->GOSpawns.push_back(gs);
go->m_spawn = gs;
MapCell * mCell = m_session->GetPlayer()->GetMapMgr()->GetCell( cx, cy );
if( mCell != NULL )
mCell->SetLoaded();
if(Save == true)
{
// If we're saving, create template and add index
go->SaveToDB();
go->m_loadedFromDB = true;
}
sGMLog.writefromsession( m_session, "spawned gameobject %s, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, gs->entry, m_session->GetPlayer()->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : "" );
return true;
}