mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-08 09:37:53 +00:00
31 lines
872 B
C++
31 lines
872 B
C++
|
|
#include "actiontake.hpp"
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
#include "../mwbase/world.hpp"
|
|
|
|
#include "../mwgui/window_manager.hpp"
|
|
|
|
#include "class.hpp"
|
|
#include "containerstore.hpp"
|
|
|
|
namespace MWWorld
|
|
{
|
|
ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {}
|
|
|
|
void ActionTake::execute()
|
|
{
|
|
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
|
return;
|
|
|
|
// insert into player's inventory
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
|
|
|
|
MWWorld::Class::get (player).getContainerStore (player).add (mObject);
|
|
|
|
// 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);
|
|
}
|
|
}
|