1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 09:49:55 +00:00
openmw-tes3mp/apps/openmw/mwworld/actiontake.cpp

30 lines
861 B
C++
Raw Normal View History

2010-08-07 18:25:17 +00:00
#include "actiontake.hpp"
#include "../mwbase/environment.hpp"
#include "../mwgui/window_manager.hpp"
2010-08-07 18:25:17 +00:00
#include "class.hpp"
#include "world.hpp"
#include "containerstore.hpp"
2010-08-07 18:25:17 +00:00
namespace MWWorld
{
ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {}
void ActionTake::execute()
2010-08-07 18:25: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
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
2010-08-07 18:25:17 +00:00
MWWorld::Class::get (player).getContainerStore (player).add (mObject);
2010-08-07 18:25:17 +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
}
}