#ifndef poly2d_h
#define poly2d_h

#include "math.h"
#include "vector2d.h"//shouldnt be necessary
#include "line2d.h"//shouldnt be necessary
#include "physpoint.h"
#include <list>
using namespace std;

class wallrangeT {
public:
    float low, high;
};


class lc {
public:
    line2d* l;
    bool flipped;
    list<wallrangeT> range;
    float low, high;

    int ltexid;

    void checkagainst(lc& other);

    bool alone;

    // A default constructor
    lc() {};


    ~lc() {
        //delete l;
        range.clear();
    };
};
class poly2d {
public:
    int lnum;
    lc* l;
    float floor, roof;
    int floortex, rooftex;
    vector2d centre;
    float furthestpointdist;//TODO check playeris within this distance!


    // A default constructor
    poly2d() {};


    ~poly2d() {
        delete[] l;
    };

    void draw();
    int pnpoly(float x, float y);
    void docolwall(physpoint& player, bool& onground);
    void docolfloor(physpoint& player, bool& onground);
    void getcentre();
    void sortflipped();

};

#endif
