summaryrefslogtreecommitdiffstats
path: root/LevelVertex.h
blob: a7212934578254da8bfbd3d803a01dfed4c14354 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef LEVELVERTEX_H_
#define LEVELVERTEX_H_

#include "LevelObject.h"
#include "VertexProvider.h"


class LevelVertex : public LevelObject {
  private:
    VertexProvider *provider;
    size_t id;
    
  public:
    LevelVertex(VertexProvider *p, size_t i, LevelObject *parent)
    : LevelObject(parent), provider(p), id(i) {}
    
    virtual const char* getType() const {
      return "LevelVertex";
    }
    
    virtual bool hit(const Vertex &v, float scale) const {
      return (provider->getVertex(id)->distanceSq(v) < (3.5f*3.5f)/(scale*scale));
    }
    
    virtual int getPriority() const {
      return 1000;
    }
    
    virtual void move(float x, float y) {
      provider->moveVertex(id, x, y);
    }
    
    virtual void rotate(Vertex m, float a) {
      provider->rotateVertex(id, m, a);
    }
    
    virtual bool canConnect() const {return provider->canConnectVertex(id);}
    virtual void connect() {provider->connectVertex(id);}
    
    const Vertex* operator->() const {return provider->getVertex(id);}
    const Vertex& operator*() const {return *provider->getVertex(id);}
};

#endif /*LEVELVERTEX_H_*/