|
|
|
@ -56,47 +56,54 @@ void OMW::Engine::executeLocalScripts()
|
|
|
|
|
|
|
|
|
|
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
|
|
|
|
{
|
|
|
|
|
mEnvironment.mFrameDuration = evt.timeSinceLastFrame;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
mEnvironment.mFrameDuration = evt.timeSinceLastFrame;
|
|
|
|
|
|
|
|
|
|
// global scripts
|
|
|
|
|
mEnvironment.mGlobalScripts->run (mEnvironment);
|
|
|
|
|
// global scripts
|
|
|
|
|
mEnvironment.mGlobalScripts->run (mEnvironment);
|
|
|
|
|
|
|
|
|
|
bool changed = mEnvironment.mWorld->hasCellChanged();
|
|
|
|
|
bool changed = mEnvironment.mWorld->hasCellChanged();
|
|
|
|
|
|
|
|
|
|
// local scripts
|
|
|
|
|
executeLocalScripts(); // This does not handle the case where a global script causes a cell
|
|
|
|
|
// change, followed by a cell change in a local script during the same
|
|
|
|
|
// frame.
|
|
|
|
|
// local scripts
|
|
|
|
|
executeLocalScripts(); // This does not handle the case where a global script causes a cell
|
|
|
|
|
// change, followed by a cell change in a local script during the same
|
|
|
|
|
// frame.
|
|
|
|
|
|
|
|
|
|
// passing of time
|
|
|
|
|
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
|
|
|
|
|
mEnvironment.mWorld->advanceTime (
|
|
|
|
|
mEnvironment.mFrameDuration*mEnvironment.mWorld->getTimeScaleFactor()/3600);
|
|
|
|
|
// passing of time
|
|
|
|
|
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
|
|
|
|
|
mEnvironment.mWorld->advanceTime (
|
|
|
|
|
mEnvironment.mFrameDuration*mEnvironment.mWorld->getTimeScaleFactor()/3600);
|
|
|
|
|
|
|
|
|
|
if (changed) // keep change flag for another frame, if cell changed happend in local script
|
|
|
|
|
mEnvironment.mWorld->markCellAsUnchanged();
|
|
|
|
|
if (changed) // keep change flag for another frame, if cell changed happend in local script
|
|
|
|
|
mEnvironment.mWorld->markCellAsUnchanged();
|
|
|
|
|
|
|
|
|
|
// update actors
|
|
|
|
|
mEnvironment.mMechanicsManager->update();
|
|
|
|
|
// update actors
|
|
|
|
|
mEnvironment.mMechanicsManager->update();
|
|
|
|
|
|
|
|
|
|
if (focusFrameCounter++ == focusUpdateFrame)
|
|
|
|
|
{
|
|
|
|
|
std::string handle = mEnvironment.mWorld->getFacedHandle();
|
|
|
|
|
if (focusFrameCounter++ == focusUpdateFrame)
|
|
|
|
|
{
|
|
|
|
|
std::string handle = mEnvironment.mWorld->getFacedHandle();
|
|
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
|
|
if (!handle.empty())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
|
|
|
|
|
if (!handle.empty())
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
|
|
|
|
|
|
|
|
|
|
if (!ptr.isEmpty())
|
|
|
|
|
name = MWWorld::Class::get (ptr).getName (ptr);
|
|
|
|
|
}
|
|
|
|
|
if (!ptr.isEmpty())
|
|
|
|
|
name = MWWorld::Class::get (ptr).getName (ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!name.empty())
|
|
|
|
|
std::cout << "Object: " << name << std::endl;
|
|
|
|
|
if (!name.empty())
|
|
|
|
|
std::cout << "Object: " << name << std::endl;
|
|
|
|
|
|
|
|
|
|
focusFrameCounter = 0;
|
|
|
|
|
focusFrameCounter = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const std::exception& e)
|
|
|
|
|
{
|
|
|
|
|
std::cerr << "Error in framelistener: " << e.what() << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|