You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw-tes3mp/apps/openmw/mwworld/actiontake.cpp

30 lines
891 B
C++

#include "actiontake.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "class.hpp"
#include "containerstore.hpp"
namespace MWWorld
{
ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {}
void ActionTake::executeImp (const Ptr& actor)
{
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);
}
}