本文整理汇总了C++中CellStore类的典型用法代码示例。如果您正苦于以下问题:C++ CellStore类的具体用法?C++ CellStore怎么用?C++ CellStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CellStore类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cell
MWWorld::Ptr CellStore::moveTo(const Ptr &object, CellStore *cellToMoveTo)
{
if (cellToMoveTo == this)
throw std::runtime_error("moveTo: object is already in this cell");
// We assume that *this is in State_Loaded since we could hardly have reference to a live object otherwise.
if (mState != State_Loaded)
throw std::runtime_error("moveTo: can't move object from a non-loaded cell (how did you get this object anyway?)");
// Ensure that the object actually exists in the cell
SearchByRefNumVisitor searchVisitor(object.getCellRef().getRefNum());
forEach(searchVisitor);
if (!searchVisitor.mFound)
throw std::runtime_error("moveTo: object is not in this cell");
// Objects with no refnum can't be handled correctly in the merging process that happens
// on a save/load, so do a simple copy & delete for these objects.
if (!object.getCellRef().getRefNum().hasContentFile())
{
MWWorld::Ptr copied = object.getClass().copyToCell(object, *cellToMoveTo, object.getRefData().getCount());
object.getRefData().setCount(0);
object.getRefData().setBaseNode(NULL);
return copied;
}
MovedRefTracker::iterator found = mMovedHere.find(object.getBase());
if (found != mMovedHere.end())
{
// Special case - object didn't originate in this cell
// Move it back to its original cell first
CellStore* originalCell = found->second;
assert (originalCell != this);
originalCell->moveFrom(object, this);
mMovedHere.erase(found);
// Now that object is back to its rightful owner, we can move it
if (cellToMoveTo != originalCell)
{
originalCell->moveTo(object, cellToMoveTo);
}
updateMergedRefs();
return MWWorld::Ptr(object.getBase(), cellToMoveTo);
}
cellToMoveTo->moveFrom(object, this);
mMovedToAnotherCell.insert(std::make_pair(object.getBase(), cellToMoveTo));
updateMergedRefs();
return MWWorld::Ptr(object.getBase(), cellToMoveTo);
}
示例2:
void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, CellStore& cell) const
{
if (cell.getState()!=CellStore::State_Loaded)
cell.load (mStore, mReader);
ESM::CellState cellState;
cell.saveState (cellState);
writer.startRecord (ESM::REC_CSTA);
cellState.mId.save (writer);
cellState.save (writer);
cell.writeFog(writer);
cell.writeReferences (writer);
writer.endRecord (ESM::REC_CSTA);
}
示例3: Ptr
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
bool searchInContainers)
{
if (cell.getState()==CellStore::State_Unloaded)
cell.preload (mStore, mReader);
if (cell.getState()==CellStore::State_Preloaded)
{
if (cell.hasId (name))
{
cell.load (mStore, mReader);
}
else
return Ptr();
}
Ptr ptr = cell.search (name);
if (!ptr.isEmpty())
return ptr;
if (searchInContainers)
return cell.searchInContainer (name);
return Ptr();
}
示例4: Ptr
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
bool searchInContainers)
{
if (cell.getState()==CellStore::State_Unloaded)
cell.preload ();
if (cell.getState()==CellStore::State_Preloaded)
{
if (cell.hasId (name))
{
cell.load ();
}
else
return Ptr();
}
Ptr ptr = cell.search (name);
if (!ptr.isEmpty() && MWWorld::CellStore::isAccessible(ptr.getRefData(), ptr.getCellRef()))
return ptr;
if (searchInContainers)
return cell.searchInContainer (name);
return Ptr();
}
示例5: getCell
bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type,
const std::map<int, int>& contentFileMap)
{
if (type==ESM::REC_CSTA)
{
ESM::CellState state;
state.mId.load (reader);
CellStore *cellStore = 0;
try
{
cellStore = getCell (state.mId);
}
catch (...)
{
// silently drop cells that don't exist anymore
std::cerr << "Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)" << std::endl;
reader.skipRecord();
return true;
}
state.load (reader);
cellStore->loadState (state);
if (state.mHasFogOfWar)
cellStore->readFog(reader);
if (cellStore->getState()!=CellStore::State_Loaded)
cellStore->load ();
GetCellStoreCallback callback(*this);
cellStore->readReferences (reader, contentFileMap, &callback);
return true;
}
return false;
}
示例6: getCell
bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type,
const std::map<int, int>& contentFileMap)
{
if (type==ESM::REC_CSTA)
{
ESM::CellState state;
state.mId.load (reader);
CellStore *cellStore = 0;
try
{
cellStore = getCell (state.mId);
}
catch (...)
{
// silently drop cells that don't exist anymore
reader.skipRecord();
return true;
/// \todo log
}
state.load (reader);
cellStore->loadState (state);
if (state.mHasFogOfWar)
cellStore->readFog(reader);
if (cellStore->getState()!=CellStore::State_Loaded)
cellStore->load (mStore, mReader);
cellStore->readReferences (reader, contentFileMap);
return true;
}
return false;
}
示例7: insertCell
void Scene::insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener)
{
InsertFunctor functor (cell, rescale, *loadingListener, *mPhysics, mRendering);
cell.forEach (functor);
}
示例8: load
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
{
CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName);
bool loadcell = (mCurrentCell == NULL);
if(!loadcell)
loadcell = *mCurrentCell != *cell;
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen();
std::string loadingInteriorText = "#{sLoadingMessage2}";
loadingListener->setLabel(loadingInteriorText);
Loading::ScopedLoad load(loadingListener);
mRendering.enableTerrain(false);
if(!loadcell)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]);
float x = Ogre::Radian(position.rot[0]).valueDegrees();
float y = Ogre::Radian(position.rot[1]).valueDegrees();
float z = Ogre::Radian(position.rot[2]).valueDegrees();
world->rotateObject(world->getPlayerPtr(), x, y, z);
world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true);
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5);
return;
}
std::cout << "Changing to interior\n";
// remove active
CellStoreCollection::iterator active = mActiveCells.begin();
// count number of cells to unload
int numUnload = 0;
while (active!=mActiveCells.end())
{
++active;
++numUnload;
}
// unload
int current = 0;
active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
unloadCell (active++);
++current;
}
int refsToLoad = cell->count();
loadingListener->setProgressRange(refsToLoad);
// Load cell.
std::cout << "cellName: " << cell->getCell()->mName << std::endl;
//Loading Interior loading text
loadCell (cell, loadingListener);
mCurrentCell = cell;
// adjust fog
mRendering.configureFog(*mCurrentCell);
// adjust player
playerCellChange (mCurrentCell, position);
// Sky system
MWBase::Environment::get().getWorld()->adjustSky();
mCellChanged = true;
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5);
}
示例9: load
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
{
CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName);
bool loadcell = (mCurrentCell == NULL);
if(!loadcell)
loadcell = *mCurrentCell != *cell;
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen();
std::string loadingInteriorText = "#{sLoadingMessage2}";
loadingListener->setLabel(loadingInteriorText);
Loading::ScopedLoad load(loadingListener);
mRendering.enableTerrain(false);
if(!loadcell)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]);
float x = Ogre::Radian(position.rot[0]).valueDegrees();
float y = Ogre::Radian(position.rot[1]).valueDegrees();
float z = Ogre::Radian(position.rot[2]).valueDegrees();
world->rotateObject(world->getPlayerPtr(), x, y, z);
world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true);
MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5);
return;
}
std::cout << "Changing to interior\n";
// unload
int current = 0;
CellStoreCollection::iterator active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
unloadCell (active++);
++current;
}
int refsToLoad = cell->count();
loadingListener->setProgressRange(refsToLoad);
// Load cell.
std::cout << "cellName: " << cell->getCell()->mName << std::endl;
loadCell (cell, loadingListener);
changePlayerCell(cell, position, true);
// adjust fog
mRendering.configureFog(*mCurrentCell);
// Sky system
MWBase::Environment::get().getWorld()->adjustSky();
mCellChanged = true; MWBase::Environment::get().getWindowManager()->fadeScreenIn(0.5);
MWBase::Environment::get().getWindowManager()->changeCell(mCurrentCell);
// Delay the map update until scripts have been given a chance to run.
// If we don't do this, objects that should be disabled will still appear on the map.
mNeedMapUpdate = true;
}
示例10:
bool operator== (const CellStore& left, const CellStore& right)
{
return left.getCell()->getCellId()==right.getCell()->getCellId();
}