2010-08-07 18:25:17 +00:00
|
|
|
|
|
|
|
#include "actiontake.hpp"
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2012-05-25 16:45:17 +00:00
|
|
|
#include "../mwgui/window_manager.hpp"
|
2012-04-23 13:27:03 +00:00
|
|
|
|
2010-08-07 18:25:17 +00:00
|
|
|
#include "class.hpp"
|
2012-02-23 11:38:25 +00:00
|
|
|
#include "containerstore.hpp"
|
2010-08-07 18:25:17 +00:00
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {}
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
void ActionTake::execute()
|
2010-08-07 18:25:17 +00:00
|
|
|
{
|
2012-05-25 16:45:17 +00:00
|
|
|
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
|
|
|
return;
|
|
|
|
|
2010-08-07 18:25:17 +00:00
|
|
|
// insert into player's inventory
|
2012-04-23 13:27:03 +00:00
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
|
2010-08-07 18:25:17 +00:00
|
|
|
|
2012-02-23 11:38:25 +00:00
|
|
|
MWWorld::Class::get (player).getContainerStore (player).add (mObject);
|
2010-08-07 18:25:17 +00:00
|
|
|
|
2012-05-15 16:05:53 +00:00
|
|
|
// remove from world, if the item is currently in the world (it could also be in a container)
|
|
|
|
if (mObject.isInCell())
|
|
|
|
MWBase::Environment::get().getWorld()->deleteObject (mObject);
|
2010-08-07 18:25:17 +00:00
|
|
|
}
|
|
|
|
}
|