#pragma once
#include <iostream>
#include <vector>
#include <raylib.h>
#include <map>

namespace MPFW {
	namespace HL {
		struct Lump {
			std::string name, data;
		};

		class WAD { // WAD3 file format
			std::vector<Lump> lumps;
		public:
			bool loaded = false;
			int lumpCount;
			WAD();
			WAD(std::string path);
			void LoadWAD(std::string path);
			std::vector<Lump> getLumps() {
				return lumps;
			}
			~WAD();
		};

		struct Plane {
			Vector3 a, b, c, u, v;
			std::string texturename;
			float rotation, uOffset, uScale, vOffset, vScale;

		};

		struct Brush {
			std::vector<Plane> planes;
		};

		class GenericClass {
		public:
			std::string classname;
			virtual void onCreate() = 0;
			virtual void onUpdate() = 0;
			virtual void onDestroy() = 0;
		};

		class GenericOriginedClass : public GenericClass {
		public:
			Vector3 origin;
			virtual void onCreate() = 0;
			virtual void onUpdate() = 0;
			virtual void onDestroy() = 0;
		};

		class GenericUnknownClass : public GenericClass{
		public:
			std::map<std::string, std::string> fields;
			void onCreate() {}
			void onUpdate() {}
			void onDestroy() {}
		};

		class WorldSpawnClass : public GenericClass {
		public:
			std::string wad;
			int defaultteam, newunit, gametitle, startdark, maxrange, sounds, mapversion;
			std::vector<Plane> planes;
			void onCreate() {}
			void onUpdate() {}
			void onDestroy() {}
		};

		struct __HLParseKeyVal {
			std::string key, val;
		};

		class Map {
		public:
			std::vector<GenericClass*> mapdata;
			Map();
			Map(std::string path);
			void Load(std::string path);
			~Map();
		};
	}
}