|
|
|
@ -50,7 +50,8 @@ namespace MWScript
|
|
|
|
|
|
|
|
|
|
InterpreterContext::InterpreterContext (MWWorld::Environment& environment,
|
|
|
|
|
MWScript::Locals *locals, MWWorld::Ptr reference)
|
|
|
|
|
: mEnvironment (environment), mLocals (locals), mReference (reference)
|
|
|
|
|
: mEnvironment (environment), mLocals (locals), mReference (reference),
|
|
|
|
|
mActivationHandled (false)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
int InterpreterContext::getLocalShort (int index) const
|
|
|
|
@ -197,11 +198,46 @@ namespace MWScript
|
|
|
|
|
return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool InterpreterContext::hasBeenActivated() const
|
|
|
|
|
bool InterpreterContext::hasBeenActivated (const MWWorld::Ptr& ptr)
|
|
|
|
|
{
|
|
|
|
|
if (!mActivated.isEmpty() && mActivated==ptr)
|
|
|
|
|
{
|
|
|
|
|
mActivationHandled = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool InterpreterContext::hasActivationBeenHandled() const
|
|
|
|
|
{
|
|
|
|
|
return mActivationHandled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InterpreterContext::activate (const MWWorld::Ptr& ptr,
|
|
|
|
|
boost::shared_ptr<MWWorld::Action> action)
|
|
|
|
|
{
|
|
|
|
|
mActivated = ptr;
|
|
|
|
|
mActivationHandled = false;
|
|
|
|
|
mAction = action;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InterpreterContext::executeActivation()
|
|
|
|
|
{
|
|
|
|
|
if (!mAction.get())
|
|
|
|
|
throw std::runtime_error ("activation failed, because no action to perform");
|
|
|
|
|
|
|
|
|
|
mAction->execute (mEnvironment);
|
|
|
|
|
mActivationHandled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InterpreterContext::clearActivation()
|
|
|
|
|
{
|
|
|
|
|
mActivated = MWWorld::Ptr();
|
|
|
|
|
mActivationHandled = false;
|
|
|
|
|
mAction.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float InterpreterContext::getSecondsPassed() const
|
|
|
|
|
{
|
|
|
|
|
return mEnvironment.mFrameDuration;
|
|
|
|
@ -245,4 +281,3 @@ namespace MWScript
|
|
|
|
|
return getReference ("", true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|