File interactable.hpp¶
Enums
-
class Interactable : public ISaveable
- #include <interactable.hpp>
Defines an object that is interactable in-game by a player’s action
Public Functions
-
Interactable()
Empty constructor
-
Interactable(const std::string &path)
Constructor using a JSON file.
-
Interactable(const std::string &type, Vector2 tilePos, int tileSize)
Construct from type name
-
Interactable(InteractableInRoomBin bin)
Construct from a bin
-
virtual ~Interactable() = default¶
-
virtual nlohmann::json dumpJson()
Dump JSON data.
-
bool isValid() const
Whether this Interactable is valid
-
Rectangle getRect() const
Get the Rectangle of this Interactable
-
const std::string &getType() const
Get this Interactable’s type.
-
Vector2 getWorldPos() const
Get the World position of this Interactable.
-
bool isOnTouch() const
Get the onTouch member.
-
void setOnTouch(bool onTouch)
Set whether this interactable will be invoked when player touches it.
-
void interact()
Invoke the interact method. Each interactable has a script with an ‘interact’ function.
-
void setType(const std::string &type)
Change the interactable’s type .
-
void setProp(std::string key, std::string value)
Set a property of this interactable.
-
void setProps(nlohmann::json j)
Set properties using a nlohmann::json object.
-
void addProp(PropType propType, const std::string &name)
Add a property based on the chosen property type.
-
void setScriptSourcePath(const std::string &newPath)
Set the source script file path.
-
const std::string &getScriptSourcePath()
Get source script file.
-
nlohmann::json &getProps()
Get the properties json object.
-
nlohmann::json *getPropsPtr()
Get a pointer to the properties.
-
void setDisplayTitle(const std::string &newTitle)
Set the Interactable’s display title (shown in Editor)
-
std::string &getDisplayTitle()
Get the Interactable’s display title.
Private Members
-
bool valid¶
Whether this Interactable is valid
-
std::string type¶
The type of this Interactable
-
std::string displayTitle¶
The displayed title in the Editor.
-
Vector2 tilePos¶
The position of this Interactable in terms of tiles
-
Vector2 absolutePos¶
The absolute position of this Interactable in the world scene
-
Rectangle rect¶
The Rectangle of this Interactable
-
bool onTouch¶
Whether this interactable will be interacted with on touch.
-
std::unique_ptr<nlohmann::json> props¶
A json object describing the properties of an interactable.
-
std::string scriptPath¶
Script file path
-
Interactable()