forked from teamnwah/openmw-tes3coop
Port over more game logic to the visitor pattern
This commit is contained in:
parent
9ea475d00c
commit
abcf91be5b
1 changed files with 52 additions and 32 deletions
|
@ -1691,31 +1691,32 @@ namespace MWWorld
|
||||||
|
|
||||||
osg::Vec2f World::getNorthVector (CellStore* cell)
|
osg::Vec2f World::getNorthVector (CellStore* cell)
|
||||||
{
|
{
|
||||||
/*
|
MWWorld::Ptr northmarker = cell->search("northmarker");
|
||||||
MWWorld::CellRefList<ESM::Static>& statics = cell->get<ESM::Static>();
|
|
||||||
MWWorld::LiveCellRef<ESM::Static>* ref = statics.find("northmarker");
|
if (northmarker.isEmpty())
|
||||||
if (!ref)
|
|
||||||
return osg::Vec2f(0, 1);
|
return osg::Vec2f(0, 1);
|
||||||
|
|
||||||
osg::Quat orient (-ref->mData.getPosition().rot[2], osg::Vec3f(0,0,1));
|
osg::Quat orient (-northmarker.getRefData().getPosition().rot[2], osg::Vec3f(0,0,1));
|
||||||
osg::Vec3f dir = orient * osg::Vec3f(0,1,0);
|
osg::Vec3f dir = orient * osg::Vec3f(0,1,0);
|
||||||
osg::Vec2f d (dir.x(), dir.y());
|
osg::Vec2f d (dir.x(), dir.y());
|
||||||
return d;
|
return d;
|
||||||
*/
|
|
||||||
return osg::Vec2f();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::getDoorMarkers (CellStore* cell, std::vector<World::DoorMarker>& out)
|
struct GetDoorMarkerVisitor
|
||||||
{
|
{
|
||||||
/*
|
GetDoorMarkerVisitor(std::vector<World::DoorMarker>& out)
|
||||||
MWWorld::CellRefList<ESM::Door>& doors = cell->get<ESM::Door>();
|
: mOut(out)
|
||||||
CellRefList<ESM::Door>::List& refList = doors.mList;
|
|
||||||
for (CellRefList<ESM::Door>::List::iterator it = refList.begin(); it != refList.end(); ++it)
|
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Door>& ref = *it;
|
}
|
||||||
|
|
||||||
if (!ref.mData.isEnabled())
|
std::vector<World::DoorMarker>& mOut;
|
||||||
continue;
|
|
||||||
|
bool operator()(const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Door>& ref = *static_cast<MWWorld::LiveCellRef<ESM::Door>* >(ptr.getBase());
|
||||||
|
|
||||||
|
if (!ref.mData.isEnabled() || ref.mData.isDeleted())
|
||||||
|
return true;
|
||||||
|
|
||||||
if (ref.mRef.getTeleport())
|
if (ref.mRef.getTeleport())
|
||||||
{
|
{
|
||||||
|
@ -1731,7 +1732,7 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cellid.mPaged = true;
|
cellid.mPaged = true;
|
||||||
positionToIndex(
|
MWBase::Environment::get().getWorld()->positionToIndex(
|
||||||
ref.mRef.getDoorDest().pos[0],
|
ref.mRef.getDoorDest().pos[0],
|
||||||
ref.mRef.getDoorDest().pos[1],
|
ref.mRef.getDoorDest().pos[1],
|
||||||
cellid.mIndex.mX,
|
cellid.mIndex.mX,
|
||||||
|
@ -1743,10 +1744,16 @@ namespace MWWorld
|
||||||
|
|
||||||
newMarker.x = pos.pos[0];
|
newMarker.x = pos.pos[0];
|
||||||
newMarker.y = pos.pos[1];
|
newMarker.y = pos.pos[1];
|
||||||
out.push_back(newMarker);
|
mOut.push_back(newMarker);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
*/
|
};
|
||||||
|
|
||||||
|
void World::getDoorMarkers (CellStore* cell, std::vector<World::DoorMarker>& out)
|
||||||
|
{
|
||||||
|
GetDoorMarkerVisitor visitor(out);
|
||||||
|
cell->forEachType<ESM::Door>(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::setWaterHeight(const float height)
|
void World::setWaterHeight(const float height)
|
||||||
|
@ -2241,24 +2248,37 @@ namespace MWWorld
|
||||||
return osg::Vec3f(0,1,0);
|
return osg::Vec3f(0,1,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::getContainersOwnedBy (const MWWorld::Ptr& npc, std::vector<MWWorld::Ptr>& out)
|
struct GetContainersOwnedByVisitor
|
||||||
|
{
|
||||||
|
GetContainersOwnedByVisitor(const MWWorld::Ptr& owner, std::vector<MWWorld::Ptr>& out)
|
||||||
|
: mOwner(owner)
|
||||||
|
, mOut(out)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr mOwner;
|
||||||
|
std::vector<MWWorld::Ptr>& mOut;
|
||||||
|
|
||||||
|
bool operator()(const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
if (ptr.getRefData().isDeleted())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (Misc::StringUtils::ciEqual(ptr.getCellRef().getOwner(), mOwner.getCellRef().getRefId()))
|
||||||
|
mOut.push_back(ptr);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void World::getContainersOwnedBy (const MWWorld::Ptr& owner, std::vector<MWWorld::Ptr>& out)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells();
|
const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells();
|
||||||
for (Scene::CellStoreCollection::const_iterator cellIt = collection.begin(); cellIt != collection.end(); ++cellIt)
|
for (Scene::CellStoreCollection::const_iterator cellIt = collection.begin(); cellIt != collection.end(); ++cellIt)
|
||||||
{
|
{
|
||||||
MWWorld::CellRefList<ESM::Container>& containers = (*cellIt)->get<ESM::Container>();
|
GetContainersOwnedByVisitor visitor (owner, out);
|
||||||
CellRefList<ESM::Container>::List& refList = containers.mList;
|
(*cellIt)->forEachType<ESM::Container>(visitor);
|
||||||
for (CellRefList<ESM::Container>::List::iterator container = refList.begin(); container != refList.end(); ++container)
|
|
||||||
{
|
|
||||||
MWWorld::Ptr ptr (&*container, *cellIt);
|
|
||||||
if (ptr.getRefData().isDeleted())
|
|
||||||
continue;
|
|
||||||
if (Misc::StringUtils::ciEqual(ptr.getCellRef().getOwner(), npc.getCellRef().getRefId()))
|
|
||||||
out.push_back(ptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ListObjectsVisitor
|
struct ListObjectsVisitor
|
||||||
|
@ -2776,11 +2796,11 @@ namespace MWWorld
|
||||||
|
|
||||||
MWWorld::Ptr World::getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id )
|
MWWorld::Ptr World::getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id )
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if ( ptr.getCell()->isExterior() ) {
|
if ( ptr.getCell()->isExterior() ) {
|
||||||
return getClosestMarkerFromExteriorPosition(mPlayer->getLastKnownExteriorPosition(), id);
|
return getClosestMarkerFromExteriorPosition(mPlayer->getLastKnownExteriorPosition(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// Search for a 'nearest' marker, counting each cell between the starting
|
// Search for a 'nearest' marker, counting each cell between the starting
|
||||||
// cell and the exterior as a distance of 1. If an exterior is found, jump
|
// cell and the exterior as a distance of 1. If an exterior is found, jump
|
||||||
// to the nearest exterior marker, without further interior searching.
|
// to the nearest exterior marker, without further interior searching.
|
||||||
|
|
Loading…
Reference in a new issue