openmw-tes3coop/apps/openmw/mwworld/actionapply.cpp

36 lines
1,013 B
C++
Raw Normal View History

2012-07-13 07:41:38 +00:00
#include "actionapply.hpp"
#include "class.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
2012-07-13 07:41:38 +00:00
namespace MWWorld
{
2012-07-27 10:00:10 +00:00
ActionApply::ActionApply (const Ptr& target, const std::string& id)
: Action (false, target), mId (id)
2012-07-13 07:41:38 +00:00
{}
2012-07-27 10:00:10 +00:00
void ActionApply::executeImp (const Ptr& actor)
2012-07-13 07:41:38 +00:00
{
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
getTarget().getClass().apply (getTarget(), mId, actor);
2012-07-13 07:41:38 +00:00
}
ActionApplyWithSkill::ActionApplyWithSkill (const Ptr& target, const std::string& id,
2012-07-27 10:00:10 +00:00
int skillIndex, int usageType)
: Action (false, target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
2012-07-13 07:41:38 +00:00
{}
2012-07-27 10:00:10 +00:00
void ActionApplyWithSkill::executeImp (const Ptr& actor)
2012-07-13 07:41:38 +00:00
{
MWBase::Environment::get().getWorld()->breakInvisibility(actor);
if (getTarget().getClass().apply (getTarget(), mId, actor) && mUsageType!=-1)
getTarget().getClass().skillUsageSucceeded (actor, mSkillIndex, mUsageType);
2012-07-13 07:41:38 +00:00
}
}