1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 21:32:42 +00:00
OpenMW/apps/openmw/mwworld/actiontake.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.4 KiB
C++
Raw Normal View History

2010-08-07 20:25:17 +02:00
#include "actiontake.hpp"
#include "../mwbase/environment.hpp"
2014-01-07 19:49:16 +01:00
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwgui/inventorywindow.hpp"
2010-08-07 20:25:17 +02:00
#include "class.hpp"
#include "containerstore.hpp"
2010-08-07 20:25:17 +02:00
namespace MWWorld
{
2012-09-04 20:56:28 +02:00
ActionTake::ActionTake(const MWWorld::Ptr& object)
: Action(true, object)
{
}
2010-08-07 20:25:17 +02:00
void ActionTake::executeImp(const Ptr& actor)
2010-08-07 20:25:17 +02:00
{
// When in GUI mode, we should use drag and drop
if (actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
{
MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
if (mode == MWGui::GM_Inventory || mode == MWGui::GM_Container)
{
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->pickUpObject(getTarget());
return;
}
}
2023-12-31 17:12:46 +00:00
int count = getTarget().getCellRef().getCount();
if (getTarget().getClass().isGold(getTarget()))
count *= getTarget().getClass().getValue(getTarget());
MWBase::Environment::get().getMechanicsManager()->itemTaken(actor, getTarget(), MWWorld::Ptr(), count);
MWWorld::Ptr newitem = *actor.getClass().getContainerStore(actor).add(getTarget(), count);
MWBase::Environment::get().getWorld()->deleteObject(getTarget());
setTarget(newitem);
2010-08-07 20:25:17 +02:00
}
}