Class Interactable

class Interactable : public ISaveable

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 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.