#include "GestionTerrain.h"
#include <TileMap.hpp>
#include <ResourceLoader.hpp>
#include <Sprite.hpp>
#include <Texture.hpp>

using namespace godot;

GestionTerrain::GestionTerrain()
{
	Godot::print("Constructeur Terrain");
}

GestionTerrain::~GestionTerrain()
{
}

void GestionTerrain::_register_methods()
{
	Godot::print("Register");
	register_method("_process", &GestionTerrain::_process);
	register_method("_init", &GestionTerrain::_init);
	register_method("_ready", &GestionTerrain::_ready);
}

void GestionTerrain::_process()
{
}

void GestionTerrain::_init()
{
}

void GestionTerrain::_ready()
{
}

void GestionTerrain::AjoutMur(int sizeX, int sizeY, int posX, int posY)
{
	
}

void GestionTerrain::AjoutSolSolide(int sizeX, int sizeY, int posX, int posY)
{
	Godot::print("Ajout sol solide");
	Transform2D t;
	Vector2 v;
	Size2 s;

	//setup de la size
	s.x = sizeX;
	s.y = sizeY;
	v.x = posX;
	v.y = posY;
	t.set_origin(v);
	t.scale(s);
	
	StaticBody2D* m = StaticBody2D::_new();

	Sprite* sprite = Sprite::_new();

	Ref<Texture> texture_ptr = ResourceLoader::get_singleton()->load("res://sol.png");
	sprite->set_texture(texture_ptr);

	m->add_child(sprite);
	m->set_transform(t);

	add_child(m);
}

void GestionTerrain::AjoutSolTraversable(int sizeX, int sizeY, int posX, int posY)
{
}

void GestionTerrain::SuppressionTout()
{
}

void GestionTerrain::GenerationCarte()
{
	AjoutSolSolide(1, 1, 85, 300);
	AjoutSolSolide(1, 1, 255, 300);
	AjoutSolSolide(1, 1, 340, 300);
	AjoutSolSolide(1, 1, 425, 300);
}
