mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 19:45:32 +00:00
encapsulated water level
This commit is contained in:
parent
79e723ad06
commit
b72c1c2c58
4 changed files with 20 additions and 7 deletions
|
@ -132,7 +132,7 @@ namespace MWScript
|
|||
{
|
||||
MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell();
|
||||
if (cell->getCell()->hasWater())
|
||||
runtime.push (cell->mWaterLevel);
|
||||
runtime.push (cell->getWaterLevel());
|
||||
else
|
||||
runtime.push (-std::numeric_limits<float>().max());
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ namespace MWScript
|
|||
if (cell->getCell()->isExterior())
|
||||
throw std::runtime_error("Can't set water level in exterior cell");
|
||||
|
||||
cell->mWaterLevel = level;
|
||||
MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel);
|
||||
cell->setWaterLevel (level);
|
||||
MWBase::Environment::get().getWorld()->setWaterHeight (cell->getWaterLevel());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -169,8 +169,8 @@ namespace MWScript
|
|||
if (cell->getCell()->isExterior())
|
||||
throw std::runtime_error("Can't set water level in exterior cell");
|
||||
|
||||
cell->mWaterLevel +=level;
|
||||
MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel);
|
||||
cell->setWaterLevel (cell->getWaterLevel()+level);
|
||||
MWBase::Environment::get().getWorld()->setWaterHeight(cell->getWaterLevel());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -233,6 +233,16 @@ namespace MWWorld
|
|||
return Ptr();
|
||||
}
|
||||
|
||||
float CellStore::getWaterLevel() const
|
||||
{
|
||||
return mWaterLevel;
|
||||
}
|
||||
|
||||
void CellStore::setWaterLevel (float level)
|
||||
{
|
||||
mWaterLevel = level;
|
||||
}
|
||||
|
||||
void CellStore::load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm)
|
||||
{
|
||||
if (mState!=State_Loaded)
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace MWWorld
|
|||
const ESM::Cell *mCell;
|
||||
State mState;
|
||||
std::vector<std::string> mIds;
|
||||
float mWaterLevel;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -82,7 +83,9 @@ namespace MWWorld
|
|||
///< Will return an empty Ptr if cell is not loaded. Does not check references in
|
||||
/// containers.
|
||||
|
||||
float mWaterLevel;
|
||||
float getWaterLevel() const;
|
||||
|
||||
void setWaterLevel (float level);
|
||||
|
||||
// Lists for each individual object type
|
||||
CellRefList<ESM::Activator> mActivators;
|
||||
|
|
|
@ -1760,7 +1760,7 @@ namespace MWWorld
|
|||
if (!(cell->getCell()->mData.mFlags & ESM::Cell::HasWater)) {
|
||||
return false;
|
||||
}
|
||||
return pos.z < cell->mWaterLevel;
|
||||
return pos.z < cell->getWaterLevel();
|
||||
}
|
||||
|
||||
bool World::isOnGround(const MWWorld::Ptr &ptr) const
|
||||
|
|
Loading…
Reference in a new issue