This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
neofx-zoomedit/Room.h

95 lines
2.3 KiB
C
Raw Normal View History

#ifndef ROOM_H_
#define ROOM_H_
#include "Polygon.h"
2008-02-15 11:01:04 +00:00
#include "SharedPtr.h"
#include "LevelObject.h"
2008-02-13 21:06:01 +00:00
#include "VertexProvider.h"
2008-02-15 11:01:04 +00:00
#include "EdgeProvider.h"
#include <string>
2008-02-15 11:01:04 +00:00
class Room : public LevelObject, private VertexProvider, private EdgeProvider {
private:
2008-02-15 11:01:04 +00:00
Polygon polygon;
std::string name;
2007-10-30 20:07:00 +00:00
float height;
2008-02-15 11:01:04 +00:00
std::vector<Edge> edges;
public:
2007-10-30 20:07:00 +00:00
Room() {height = 10;}
2007-12-05 22:02:03 +00:00
Room(std::string name) {this->name = name; height = 10;}
2008-02-15 11:01:04 +00:00
Room(const Room &room) : name(room.name), height(room.height) {
for(Polygon::const_iterator v = room.polygon.begin(); v != room.polygon.end(); v++)
addVertex(*v);
}
const Room& operator=(const Room &room);
std::string &getName() {return name;}
const std::string &getName() const {return name;}
void setName(const std::string &name) {this->name = name;}
2007-10-30 20:07:00 +00:00
float getHeight() const {return height;}
void setHeight(float height) {this->height = height;}
2008-02-15 11:01:04 +00:00
void addVertex(Vertex v);
const Polygon& getPolygon() const {return polygon;}
2008-02-15 22:44:03 +00:00
virtual bool hit(const Vertex &v) const {return polygon.contains(v);}
virtual int getPriority() const {return 0;}
2008-02-15 11:01:04 +00:00
virtual std::vector<SharedPtr<LevelObject> > getChildren();
2008-02-13 21:06:01 +00:00
virtual const char* getType() const {
return "Room";
}
2008-01-13 16:41:01 +00:00
virtual void move(float x, float y) {
2008-02-09 12:21:00 +00:00
Vertex m(x, y);
2008-02-15 11:01:04 +00:00
for(Polygon::iterator v = polygon.begin(); v != polygon.end(); v++)
2008-02-09 12:21:00 +00:00
*v += m;
2008-01-13 16:41:01 +00:00
}
virtual void rotate(Vertex m, float a);
2008-02-13 21:06:01 +00:00
virtual const Vertex* getVertex(size_t id) const {
2008-02-15 11:01:04 +00:00
return &polygon[id];
2008-02-13 21:06:01 +00:00
}
virtual size_t getVertexCount() const {
2008-02-15 11:01:04 +00:00
return polygon.size();
2008-02-13 21:06:01 +00:00
}
virtual void moveVertex(size_t id, float x, float y) {
2008-02-15 11:01:04 +00:00
polygon[id] += Vertex(x, y);
2008-02-13 21:06:01 +00:00
}
virtual void rotateVertex(size_t id, Vertex m, float a) {
rotate(m, a);
2008-02-13 21:06:01 +00:00
}
2008-02-15 11:01:04 +00:00
virtual const Edge* getEdge(size_t id) const {
return &edges[id];
}
virtual size_t getEdgeCount() const {
return edges.size();
}
virtual void moveEdge(size_t id, float x, float y) {
moveVertex(id, x, y);
moveVertex((id+1)%polygon.size(), x, y);
}
virtual void rotateEdge(size_t id, Vertex m, float a) {
rotate(m, a);
2008-02-15 11:01:04 +00:00
}
};
#endif /*ROOM_H_*/