mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 02:09:44 +00:00
Implement MWWorld::Class::isItem(ptr) and remove a hacky MWLua::WorldView::isItem.
This commit is contained in:
parent
2f2b952e12
commit
4fd07cb58d
17 changed files with 34 additions and 5 deletions
|
@ -23,6 +23,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -86,6 +86,11 @@ namespace MWClass
|
|||
return !name.empty() ? name : ref->mBase->mId.getRefIdString();
|
||||
}
|
||||
|
||||
bool Light::isItem(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return ptr.get<ESM::Light>()->mBase->mData.mFlags & ESM::Light::Carry;
|
||||
}
|
||||
|
||||
std::unique_ptr<MWWorld::Action> Light::activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const
|
||||
{
|
||||
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
||||
|
|
|
@ -36,6 +36,8 @@ namespace MWClass
|
|||
|
||||
bool showsInInventory(const MWWorld::ConstPtr& ptr) const override;
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override;
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace MWClass
|
|||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool isItem(const MWWorld::ConstPtr&) const override { return true; }
|
||||
|
||||
std::unique_ptr<MWWorld::Action> activate(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const override;
|
||||
///< Generate action for activation
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ namespace MWLua
|
|||
const MWWorld::Class& objClass = ptr.getClass();
|
||||
if (objClass.isActor())
|
||||
mGlobalScripts.actorActive(obj);
|
||||
if (mWorldView.isItem(ptr))
|
||||
if (objClass.isItem(ptr))
|
||||
mGlobalScripts.itemActive(obj);
|
||||
}
|
||||
else if (luaDebug)
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace MWLua
|
|||
return &mDoorsInScene;
|
||||
if (typeid(cls) == typeid(MWClass::Container))
|
||||
return &mContainersInScene;
|
||||
if (cls.hasToolTip(ptr))
|
||||
if (cls.isItem(ptr))
|
||||
return &mItemsInScene;
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -58,9 +58,6 @@ namespace MWLua
|
|||
void load(ESM::ESMReader& esm);
|
||||
void save(ESM::ESMWriter& esm) const;
|
||||
|
||||
// TODO: move this functionality to MWClass
|
||||
bool isItem(const MWWorld::Ptr& ptr) { return chooseGroup(ptr) == &mItemsInScene; }
|
||||
|
||||
private:
|
||||
struct ObjectGroup
|
||||
{
|
||||
|
|
|
@ -323,6 +323,9 @@ namespace MWWorld
|
|||
|
||||
virtual bool isDoor() const { return false; }
|
||||
|
||||
// True if it is an item that can be picked up.
|
||||
virtual bool isItem(const MWWorld::ConstPtr& ptr) const { return false; }
|
||||
|
||||
virtual bool isBipedal(const MWWorld::ConstPtr& ptr) const;
|
||||
virtual bool canFly(const MWWorld::ConstPtr& ptr) const;
|
||||
virtual bool canSwim(const MWWorld::ConstPtr& ptr) const;
|
||||
|
|
Loading…
Reference in a new issue