From 29b4a5e5f7e1611b7854d06a7c205a7615e06e20 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 09:41:38 +0200 Subject: [PATCH] Issue #314: added apply actions --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwworld/actionapply.cpp | 28 +++++++++++++++++++ apps/openmw/mwworld/actionapply.hpp | 42 +++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwworld/actionapply.cpp create mode 100644 apps/openmw/mwworld/actionapply.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 36e59f6bd9..bb3f76f3c2 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -50,7 +50,7 @@ add_openmw_dir (mwworld refdata worldimp physicssystem scene globals class action nullaction actionteleport containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata weather inventorystore ptr actionopen actionread - actionequip timestamp actionalchemy cellstore + actionequip timestamp actionalchemy cellstore actionapply ) add_openmw_dir (mwclass diff --git a/apps/openmw/mwworld/actionapply.cpp b/apps/openmw/mwworld/actionapply.cpp new file mode 100644 index 0000000000..c5228d798b --- /dev/null +++ b/apps/openmw/mwworld/actionapply.cpp @@ -0,0 +1,28 @@ + +#include "actionapply.hpp" + +#include "class.hpp" + +namespace MWWorld +{ + ActionApply::ActionApply (const Ptr& target, const std::string& id, const Ptr& actor) + : mTarget (target), mId (id), mActor (actor) + {} + + void ActionApply::execute() + { + MWWorld::Class::get (mTarget).apply (mTarget, mId, mActor); + } + + + ActionApplyWithSkill::ActionApplyWithSkill (const Ptr& target, const std::string& id, + const Ptr& actor, int skillIndex, int usageType) + : mTarget (target), mId (id), mActor (actor), mSkillIndex (skillIndex), mUsageType (usageType) + {} + + void ActionApplyWithSkill::execute() + { + if (MWWorld::Class::get (mTarget).apply (mTarget, mId, mActor)) + MWWorld::Class::get (mTarget).skillUsageSucceeded (mActor, mSkillIndex, mUsageType); + } +} diff --git a/apps/openmw/mwworld/actionapply.hpp b/apps/openmw/mwworld/actionapply.hpp new file mode 100644 index 0000000000..972417e02d --- /dev/null +++ b/apps/openmw/mwworld/actionapply.hpp @@ -0,0 +1,42 @@ + +#ifndef GAME_MWWORLD_ACTIONAPPLY_H +#define GAME_MWWORLD_ACTIONAPPLY_H + +#include + +#include "action.hpp" +#include "ptr.hpp" + +namespace MWWorld +{ + class ActionApply : public Action + { + Ptr mTarget; + std::string mId; + Ptr mActor; + + public: + + ActionApply (const Ptr& target, const std::string& id, const Ptr& actor); + + virtual void execute(); + }; + + class ActionApplyWithSkill : public Action + { + Ptr mTarget; + std::string mId; + Ptr mActor; + int mSkillIndex; + int mUsageType; + + public: + + ActionApplyWithSkill (const Ptr& target, const std::string& id, const Ptr& actor, + int skillIndex, int usageType); + + virtual void execute(); + }; +} + +#endif