Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Object.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include "../entity/Entity.hpp"
6 #include "RehtiReader.hpp"
7 
11 class Object
12 {
13 public:
14  Object(int id, std::string instanceId, std::string name, Coordinates coordinates, unsigned int rotation, reader::ObjectType objectType);
15 
16  Object(const GeneralObjectStruct& object, const ObjectLocation& location, reader::ObjectType objectType);
17 
18  virtual ~Object() = default;
19 
25  const int& getId();
26 
32  const std::string& getInstanceId();
33 
39  const std::string& getName();
40 
46  const Coordinates& getLocation();
47 
53  const unsigned int& getRotation();
54 
61 
68  virtual bool canInteract(Entity& entity) { return false; };
69 
74  virtual void interact(Entity& entity) { std::cout << "Cannot interact with this object" << std::endl; };
75 
76 private:
77  int idM;
78  std::string instanceIdM;
79  std::string nameM;
81  unsigned int rotationM;
83 };
Base pure virtual Entity class. Different types of enities inherit this.
Definition: Entity.hpp:17
Represents generic object in the game world.
Definition: Object.hpp:12
int idM
Unique id for object type (For example, tree, rock, etc)
Definition: Object.hpp:74
std::string instanceIdM
Unique id for object instance (For example, tree 1, tree at 2 etc)
Definition: Object.hpp:78
virtual ~Object()=default
const std::string & getInstanceId()
Get the instance id of the object.
Definition: Object.cpp:18
std::string nameM
Definition: Object.hpp:79
const reader::ObjectType & getObjectType()
Get the ObjectType of object.
Definition: Object.cpp:38
Coordinates coordinatesM
Definition: Object.hpp:80
const Coordinates & getLocation()
Get the location of the object.
Definition: Object.cpp:28
unsigned int rotationM
Definition: Object.hpp:81
const int & getId()
Get the id of the object.
Definition: Object.cpp:13
virtual bool canInteract(Entity &entity)
Check if the object can be interacted with by a entity. There might be several reason for not being a...
Definition: Object.hpp:68
const std::string & getName()
Get the name of the object.
Definition: Object.cpp:23
Object(int id, std::string instanceId, std::string name, Coordinates coordinates, unsigned int rotation, reader::ObjectType objectType)
Definition: Object.cpp:3
virtual void interact(Entity &entity)
Interact with the object.
Definition: Object.hpp:74
const unsigned int & getRotation()
Get the rotation of the object.
Definition: Object.cpp:33
reader::ObjectType objectTypeM
Definition: Object.hpp:82
ObjectType
Definition: ObjectReader.hpp:90
Struct for coordinates.
Definition: Coordinates.hpp:7
Definition: ObjectReader.hpp:42
Describes the location of an object on the map. This is used to spawn object instances on the map.
Definition: ObjectReader.hpp:17