Adds support for scripts for item use handling.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
26
src/Battling/ScriptHandling/ItemUseScript.hpp
Normal file
26
src/Battling/ScriptHandling/ItemUseScript.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef ITEMUSESCRIPT_HPP
|
||||
#define ITEMUSESCRIPT_HPP
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
class Creature;
|
||||
|
||||
class ItemUseScript {
|
||||
public:
|
||||
virtual ~ItemUseScript() = default;
|
||||
|
||||
/// @brief Is the item an item we are able to use?
|
||||
[[nodiscard]] virtual bool IsItemUsable() const { return false; }
|
||||
/// @brief Do we need to use the item on a creature?
|
||||
[[nodiscard]] virtual bool IsCreatureUseItem() const { return false; }
|
||||
/// @brief Can the item be used on the given creature.
|
||||
[[nodiscard]] virtual bool IsUseValidForCreature([[maybe_unused]] Creature* creature) const { return false; }
|
||||
|
||||
/// @brief Can the item be held?
|
||||
[[nodiscard]] virtual bool IsHoldable() const { return false; }
|
||||
|
||||
virtual void OnUse() const {}
|
||||
virtual void OnCreatureUse([[maybe_unused]] Creature* creature) const {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ITEMUSESCRIPT_HPP
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CREATURELIB_SCRIPTRESOLVER_HPP
|
||||
|
||||
#include "BattleScript.hpp"
|
||||
#include "ItemUseScript.hpp"
|
||||
#include "ScriptCategory.hpp"
|
||||
|
||||
namespace CreatureLib::Battling {
|
||||
@@ -9,6 +10,9 @@ namespace CreatureLib::Battling {
|
||||
|
||||
class ScriptResolver {
|
||||
public:
|
||||
ScriptResolver() {}
|
||||
NO_COPY_OR_MOVE(ScriptResolver)
|
||||
|
||||
virtual ~ScriptResolver() = default;
|
||||
|
||||
virtual void Initialize([[maybe_unused]] BattleLibrary* library){};
|
||||
@@ -16,6 +20,8 @@ namespace CreatureLib::Battling {
|
||||
[[maybe_unused]] const ArbUt::StringView& scriptName) {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
virtual ItemUseScript* LoadItemScript([[maybe_unused]] const ArbUt::StringView& scriptName) { return nullptr; };
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user